File indexing completed on 2025-05-02 02:40:38
0001 #ifndef Geometry_HGCalCommonData_HGCalParameters_h
0002 #define Geometry_HGCalCommonData_HGCalParameters_h
0003
0004 #include <CLHEP/Geometry/Transform3D.h>
0005 #include <array>
0006 #include <cstdint>
0007 #include <string>
0008 #include <unordered_map>
0009 #include <vector>
0010 #include "CondFormats/Serialization/interface/Serializable.h"
0011 #include "DataFormats/GeometryVector/interface/GlobalPoint.h"
0012 #include "Geometry/HGCalCommonData/interface/HGCalGeometryMode.h"
0013 #include "DD4hep/DD4hepUnits.h"
0014
0015 class HGCalParameters {
0016 public:
0017 struct waferInfo {
0018 int32_t type, part, orient, cassette;
0019 waferInfo(int32_t t = 0, int32_t p = 0, int32_t o = 0, int32_t c = 0) : type(t), part(p), orient(o), cassette(c) {}
0020 };
0021 struct tileInfo {
0022 int32_t type, sipm, cassette, hex[6];
0023 tileInfo(int32_t t = 0,
0024 int32_t s = 0,
0025 int32_t h1 = 0,
0026 int32_t h2 = 0,
0027 int32_t h3 = 0,
0028 int32_t h4 = 0,
0029 int32_t h5 = 0,
0030 int32_t h6 = 0)
0031 : type(t), sipm(s) {
0032 hex[0] = h1;
0033 hex[1] = h2;
0034 hex[2] = h3;
0035 hex[3] = h4;
0036 hex[4] = h5;
0037 hex[5] = h6;
0038 };
0039 };
0040 typedef std::vector<std::unordered_map<int32_t, int32_t> > layer_map;
0041 typedef std::unordered_map<int32_t, int32_t> wafer_map;
0042 typedef std::unordered_map<int32_t, std::pair<int32_t, int32_t> > waferT_map;
0043 typedef std::unordered_map<int32_t, waferInfo> waferInfo_map;
0044 typedef std::unordered_map<int32_t, tileInfo> tileInfo_map;
0045
0046 static constexpr double k_ScaleFromDDD = 0.1;
0047 static constexpr double k_ScaleFromDDD2 = 0.01;
0048 static constexpr double k_ScaleToDDD = 10.0;
0049 static constexpr double k_ScaleToDDD2 = 100.0;
0050 static constexpr double k_ScaleFromDDDToG4 = 1.0;
0051 static constexpr double k_ScaleToDDDFromG4 = 1.0;
0052 static constexpr double k_ScaleFromDD4hep = (1.0 / dd4hep::cm);
0053 static constexpr double k_ScaleToDD4hep = dd4hep::cm;
0054 static constexpr double k_ScaleFromDD4hepToG4 = (1.0 / dd4hep::mm);
0055 static constexpr double k_ScaleToDD4hepFromG4 = dd4hep::mm;
0056 static constexpr uint32_t k_CornerSize = 6;
0057 static constexpr double tol = 1.0e-12;
0058
0059 struct hgtrap {
0060 int lay;
0061 float bl, tl, h, dz, alpha, cellSize;
0062 };
0063
0064 struct hgtrform {
0065 int zp, lay, sec, subsec;
0066 CLHEP::Hep3Vector h3v;
0067 CLHEP::HepRotation hr;
0068 };
0069
0070 HGCalParameters(const std::string& nam);
0071 ~HGCalParameters(void) = default;
0072 void fillModule(const hgtrap& mytr, bool reco);
0073 hgtrap getModule(unsigned int k, bool reco) const;
0074 void fillTrForm(const hgtrform& mytr);
0075 hgtrform getTrForm(unsigned int k) const;
0076 void addTrForm(const CLHEP::Hep3Vector& h3v);
0077 void scaleTrForm(double);
0078 int scintCells(const int layer) const { return nPhiBinBH_[scintType(layer)]; }
0079 double scintCellSize(const int layer) const { return cellSize_[scintType(layer)]; }
0080 bool scintFine(int indx) const { return ((!tileRingFineR_.empty()) && (nPhiLayer_[indx] > 288)); }
0081 double scintRing(int indx, int irad) const;
0082 int scintType(const int layer) const { return ((layer < layerFrontBH_[1]) ? 1 : 0); }
0083 bool scintValidRing(int indx, int irad) const {
0084 return (scintFine(indx) ? ((irad >= iradMinBHFine_[indx]) && (irad <= (iradMaxBHFine_[indx] + 1)))
0085 : ((irad >= iradMinBH_[indx]) && (irad <= (iradMaxBH_[indx] + 1))));
0086 }
0087 std::array<int, 4> getID(unsigned int k) const;
0088
0089 std::string name_;
0090 int detectorType_ = 0;
0091 int useSimWt_ = 0;
0092 int nCells_ = 0;
0093 int nSectors_ = 0;
0094 int firstLayer_ = 0;
0095 int firstMixedLayer_ = 0;
0096 HGCalGeometryMode::GeometryMode mode_ = HGCalGeometryMode::Square;
0097
0098 std::vector<double> cellSize_;
0099 std::vector<double> slopeMin_;
0100 std::vector<double> zFrontMin_;
0101 std::vector<double> rMinFront_;
0102 std::vector<double> slopeTop_;
0103 std::vector<double> zFrontTop_;
0104 std::vector<double> rMaxFront_;
0105 std::vector<double> zRanges_;
0106 std::vector<int> moduleLayS_;
0107 std::vector<double> moduleBlS_;
0108 std::vector<double> moduleTlS_;
0109 std::vector<double> moduleHS_;
0110 std::vector<double> moduleDzS_;
0111 std::vector<double> moduleAlphaS_;
0112 std::vector<double> moduleCellS_;
0113 std::vector<int> moduleLayR_;
0114 std::vector<double> moduleBlR_;
0115 std::vector<double> moduleTlR_;
0116 std::vector<double> moduleHR_;
0117 std::vector<double> moduleDzR_;
0118 std::vector<double> moduleAlphaR_;
0119 std::vector<double> moduleCellR_;
0120 std::vector<uint32_t> trformIndex_;
0121 std::vector<double> trformTranX_;
0122 std::vector<double> trformTranY_;
0123 std::vector<double> trformTranZ_;
0124 std::vector<double> trformRotXX_;
0125 std::vector<double> trformRotYX_;
0126 std::vector<double> trformRotZX_;
0127 std::vector<double> trformRotXY_;
0128 std::vector<double> trformRotYY_;
0129 std::vector<double> trformRotZY_;
0130 std::vector<double> trformRotXZ_;
0131 std::vector<double> trformRotYZ_;
0132 std::vector<double> trformRotZZ_;
0133 std::vector<double> xLayerHex_;
0134 std::vector<double> yLayerHex_;
0135 std::vector<double> zLayerHex_;
0136 std::vector<double> rMinLayHex_;
0137 std::vector<double> rMaxLayHex_;
0138 std::vector<double> waferPosX_;
0139 std::vector<double> waferPosY_;
0140 wafer_map cellFineIndex_;
0141 std::vector<double> cellFineX_;
0142 std::vector<double> cellFineY_;
0143 std::vector<bool> cellFineHalf_;
0144 wafer_map cellCoarseIndex_;
0145 std::vector<double> cellCoarseX_;
0146 std::vector<double> cellCoarseY_;
0147 std::vector<bool> cellCoarseHalf_;
0148 std::vector<double> boundR_;
0149 std::vector<int> layer_;
0150 std::vector<int> layerIndex_;
0151 std::vector<int> layerGroup_;
0152 std::vector<int> cellFactor_;
0153 std::vector<int> depth_;
0154 std::vector<int> depthIndex_;
0155 std::vector<int> depthLayerF_;
0156 std::vector<int> waferCopy_;
0157 std::vector<int> waferTypeL_;
0158 std::vector<int> waferTypeT_;
0159 std::vector<int> layerGroupM_;
0160 std::vector<int> layerGroupO_;
0161 std::vector<double> rLimit_;
0162 std::vector<int> cellFine_;
0163 std::vector<int> cellCoarse_;
0164 double waferR_ = 0.;
0165 std::vector<int> levelT_;
0166 int levelZSide_ = 0;
0167 layer_map copiesInLayers_;
0168 int nCellsFine_ = 0;
0169 int nCellsCoarse_ = 0;
0170 double waferSize_ = 0.;
0171 double waferThick_ = 0.;
0172 double sensorSeparation_ = 0.;
0173 double sensorSizeOffset_ = 0.;
0174 double guardRingOffset_ = 0.;
0175 double mouseBite_ = 0.;
0176 int useOffset_ = 0;
0177 int waferUVMax_ = 0;
0178 std::vector<int> waferUVMaxLayer_;
0179 bool defineFull_ = false;
0180 std::vector<double> waferThickness_;
0181 std::vector<double> cellThickness_;
0182 std::vector<double> radius100to200_;
0183 std::vector<double> radius200to300_;
0184 int choiceType_ = 0;
0185 int nCornerCut_ = 0;
0186 double fracAreaMin_ = 0.;
0187 double zMinForRad_ = 0.;
0188 std::vector<double> radiusMixBoundary_;
0189 std::vector<int> nPhiBinBH_;
0190 std::vector<int> layerFrontBH_;
0191 std::vector<double> rMinLayerBH_;
0192 std::vector<double> radiusLayer_[2];
0193 std::vector<int> iradMinBH_;
0194 std::vector<int> iradMaxBH_;
0195 std::vector<int> iradMinBHFine_;
0196 std::vector<int> iradMaxBHFine_;
0197 double minTileSize_ = 0.;
0198 std::vector<int> firstModule_;
0199 std::vector<int> lastModule_;
0200 int layerOffset_ = 0;
0201 double layerRotation_ = 0.;
0202 std::vector<int> layerType_;
0203 std::vector<int> layerCenter_;
0204 wafer_map wafersInLayers_;
0205 wafer_map typesInLayers_;
0206 waferT_map waferTypes_;
0207 int waferMaskMode_ = 0;
0208 int waferZSide_ = 0;
0209 waferInfo_map waferInfoMap_;
0210 std::vector<std::pair<double, double> > layerRotV_;
0211 tileInfo_map tileInfoMap_;
0212 std::vector<std::pair<double, double> > tileRingR_;
0213 std::vector<std::pair<int, int> > tileRingRange_;
0214 std::vector<std::pair<double, double> > tileRingFineR_;
0215 std::vector<std::pair<int, int> > tileRingFineRange_;
0216 std::vector<int> nPhiLayer_;
0217 int cassettes_ = 0;
0218 int nphiCassette_ = 0;
0219 int nphiFineCassette_ = 0;
0220 int phiOffset_ = 0;
0221 std::vector<double> cassetteShift_;
0222 std::vector<double> cassetteShiftTile_;
0223 std::vector<double> cassetteRetractTile_;
0224 double calibCellRHD_ = 0.;
0225 std::vector<int> calibCellFullHD_;
0226 std::vector<int> calibCellPartHD_;
0227 double calibCellRLD_ = 0.;
0228 std::vector<int> calibCellFullLD_;
0229 std::vector<int> calibCellPartLD_;
0230 int tileUVMax_ = 0;
0231 int tileUVMaxFine_ = 0;
0232
0233 COND_SERIALIZABLE;
0234
0235 private:
0236 static constexpr int kMaskZside = 0x1;
0237 static constexpr int kMaskLayer = 0x7F;
0238 static constexpr int kMaskSector = 0x3FF;
0239 static constexpr int kMaskSubSec = 0x1;
0240 static constexpr int kShiftZside = 19;
0241 static constexpr int kShiftLayer = 12;
0242 static constexpr int kShiftSector = 1;
0243 static constexpr int kShiftSubSec = 0;
0244 };
0245
0246 #endif