CMS 3D CMS Logo

HGCalDDDConstants.h
Go to the documentation of this file.
1 #ifndef HGCalCommonData_HGCalDDDConstants_h
2 #define HGCalCommonData_HGCalDDDConstants_h
3 
28 #include <CLHEP/Geometry/Point3D.h>
29 
30 #include <array>
31 #include <memory>
32 #include <string>
33 #include <vector>
34 #include <unordered_map>
35 
37 public:
39  ~HGCalDDDConstants() = default;
40 
41  std::pair<int, int> assignCell(float x, float y, int lay, int subSec, bool reco) const;
42  std::array<int, 5> assignCellHex(float x, float y, int zside, int lay, bool reco, bool extend, bool debug) const;
43  std::array<int, 3> assignCellTrap(float x, float y, float z, int lay, bool reco) const;
44  std::vector<int> calibCells(bool hd, bool full) const {
45  if (hd) {
47  } else {
49  }
50  }
51  double calibCellRad(bool hd) const { return (hd ? hgpar_->calibCellRHD_ : hgpar_->calibCellRLD_); }
52  bool cassetteMode() const {
56  }
57  bool cassetteShiftScintillator(int zside, int layer, int iphi) const;
58  bool cassetteShiftSilicon(int zside, int layer, int waferU, int waferV) const;
59  int cassetteTile(int iphi) const {
61  }
62  std::pair<double, double> cellEtaPhiTrap(int type, int irad) const;
63  bool cellInLayer(int waferU, int waferV, int cellU, int cellV, int lay, int zside, bool reco) const;
64  const HGCalCellOffset* cellOffset() const { return cellOffset_.get(); }
65  double cellSizeHex(int type) const;
66  inline std::pair<double, double> cellSizeTrap(int type, int irad) const {
67  return std::make_pair(hgpar_->radiusLayer_[type][irad - 1], hgpar_->radiusLayer_[type][irad]);
68  }
69  double cellThickness(int layer, int waferU, int waferV) const;
70  int32_t cellType(int type, int waferU, int waferV, int iz, int fwdBack, int orient) const;
71  double distFromEdgeHex(double x, double y, double z) const;
72  double distFromEdgeTrap(double x, double y, double z) const;
73  void etaPhiFromPosition(const double x,
74  const double y,
75  const double z,
76  const int layer,
77  int& ieta,
78  int& iphi,
79  int& type,
80  double& wt) const;
81  inline int firstLayer() const { return hgpar_->firstLayer_; }
82  inline HGCalGeometryMode::GeometryMode geomMode() const { return mode_; }
83  int getLayer(double z, bool reco) const;
84  int getLayerOffset() const { return hgpar_->layerOffset_; }
85  HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const;
86  std::vector<HGCalParameters::hgtrap> getModules() const;
87  inline const HGCalParameters* getParameter() const { return hgpar_; }
88  int getPhiBins(int lay) const;
89  std::pair<double, double> getRangeR(int, bool reco) const;
90  std::pair<int, int> getREtaRange(int lay) const;
91  inline const std::vector<double>& getRadiusLayer(int layer) const {
93  }
94  inline HGCalParameters::hgtrform getTrForm(unsigned int k) const { return hgpar_->getTrForm(k); }
95  inline unsigned int getTrFormN() const { return hgpar_->trformIndex_.size(); }
96  std::vector<HGCalParameters::hgtrform> getTrForms() const;
97  int getTypeTrap(int layer) const;
98  int getTypeHex(int layer, int waferU, int waferV) const;
99  std::pair<double, double> getXY(int layer, double x, double y, bool forwd) const;
100  inline int getUVMax(int type) const { return ((type == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_); }
101  double guardRingOffset(bool reco) const;
102  bool isHalfCell(int waferType, int cell) const;
103  bool isValidHex(int lay, int mod, int cell, bool reco) const;
104  bool isValidHex8(int lay, int waferU, int waferV, bool fullAndPart) const;
105  bool isValidHex8(int lay, int modU, int modV, int cellU, int cellV, bool fullAndPart) const;
106  bool isValidTrap(int zside, int lay, int ieta, int iphi) const;
107  int lastLayer(bool reco) const;
108  int layerIndex(int lay, bool reco) const;
109  unsigned int layers(bool reco) const;
110  unsigned int layersInit(bool reco) const;
111  inline int layerType(int lay) const {
113  }
114  std::pair<float, float> localToGlobal8(
115  int zside, int lay, int waferU, int waferV, double localX, double localY, bool reco, bool debug) const;
116  std::pair<float, float> locateCell(int cell, int lay, int type, bool reco) const;
117  std::pair<float, float> locateCell(int zside,
118  int lay,
119  int waferU,
120  int waferV,
121  int cellU,
122  int cellV,
123  bool reco,
124  bool all,
125  bool norot,
126  bool cog,
127  bool debug) const;
128  std::pair<float, float> locateCell(const HGCSiliconDetId&, bool cog, bool debug) const;
129  std::pair<float, float> locateCell(const HGCScintillatorDetId&, bool debug) const;
130  std::pair<float, float> locateCellHex(int cell, int wafer, bool reco) const;
131  std::pair<float, float> locateCellTrap(int zside, int lay, int ieta, int iphi, bool reco, bool debug) const;
132  inline int levelTop(int ind = 0) const { return hgpar_->levelT_[ind]; }
133  bool maskCell(const DetId& id, int corners) const;
134  inline int maxCellUV() const { return (tileTrapezoid() ? hgpar_->nCellsFine_ : 2 * hgpar_->nCellsFine_); }
135  int maxCells(bool reco) const;
136  int maxCells(int lay, bool reco) const;
137  inline int maxModules() const { return modHalf_; }
138  inline int maxModulesPerLayer() const { return maxWafersPerLayer_; }
139  int maxRows(int lay, bool reco) const;
140  inline double minSlope() const { return hgpar_->slopeMin_[0]; }
141  int modifyUV(int uv, int type1, int type2) const;
142  int modules(int lay, bool reco) const;
143  int modulesInit(int lay, bool reco) const;
144  double mouseBite(bool reco) const;
145  int numberCells(bool reco) const;
146  std::vector<int> numberCells(int lay, bool reco) const;
147  int numberCellsHexagon(int wafer) const;
148  int numberCellsHexagon(int lay, int waferU, int waferV, bool flag) const;
149  inline int partialWaferType(int lay, int waferU, int waferV) const {
150  int indx = HGCalWaferIndex::waferIndex(lay, waferU, waferV);
151  auto ktr = hgpar_->waferInfoMap_.find(indx);
152  int part = (ktr != hgpar_->waferInfoMap_.end()) ? (ktr->second).part : HGCalTypes::WaferFull;
153  return part;
154  }
155  std::pair<double, double> rangeR(double z, bool reco) const;
156  std::pair<double, double> rangeRLayer(int lay, bool reco) const;
157  std::pair<double, double> rangeZ(bool reco) const;
158  std::pair<int, int> rowColumnWafer(const int wafer) const;
159  inline int sectors() const { return hgpar_->nSectors_; }
160  double sensorSizeOffset(bool reco) const;
161  std::pair<int, int> simToReco(int cell, int layer, int mod, bool half) const;
162  int tileCount(int layer, int ring) const;
163  bool tileExist(int zside, int layer, int ring, int phi) const;
164  HGCalParameters::tileInfo tileInfo(int zside, int layer, int ring) const;
165  bool tilePhiEdge(double phi, int layer, int iphi) const;
166  bool tileRingEdge(double rho, int layer, int ring) const;
167  std::pair<int, int> tileRings(int layer) const;
168  inline int tileSiPM(int sipm) const { return ((sipm > 0) ? HGCalTypes::SiPMSmall : HGCalTypes::SiPMLarge); }
169  bool tileTrapezoid() const {
173  }
174  std::pair<int, int> tileType(int layer, int ring, int phi) const;
175  inline bool trapezoidFile() const {
178  }
179  inline bool v17OrLess() const { return (mode_ < HGCalGeometryMode::Hexagon8CalibCell); }
180  inline unsigned int volumes() const { return hgpar_->moduleLayR_.size(); }
181  int waferFromCopy(int copy) const;
182  void waferFromPosition(const double x, const double y, int& wafer, int& icell, int& celltyp) const;
183  void waferFromPosition(const double x,
184  const double y,
185  const int zside,
186  const int layer,
187  int& waferU,
188  int& waferV,
189  int& cellU,
190  int& cellV,
191  int& celltype,
192  double& wt,
193  bool extend,
194  bool debug) const;
195  inline bool waferHexagon6() const {
197  }
198  inline bool waferHexagon8() const {
203  }
204  inline bool waferHexagon8File() const {
208  }
209  inline bool waferHexagon8Fine() const { return ((mode_ == HGCalGeometryMode::Hexagon8FineCell)); }
210  inline bool waferHexagon8Module() const {
213  }
214  bool waferInLayer(int wafer, int lay, bool reco) const;
215  bool waferFullInLayer(int wafer, int lay, bool reco) const;
216  inline int waferCount(const int type) const { return ((type == 0) ? waferMax_[2] : waferMax_[3]); }
217  HGCalParameters::waferInfo waferInfo(int lay, int waferU, int waferV) const;
218  inline int waferMax() const { return waferMax_[1]; }
219  inline int waferMin() const { return waferMax_[0]; }
220  std::pair<double, double> waferParameters(bool reco) const;
221  std::pair<double, double> waferPosition(int wafer, bool reco) const;
222  std::pair<double, double> waferPosition(int lay, int waferU, int waferV, bool reco, bool debug) const;
223  inline unsigned int waferFileSize() const { return hgpar_->waferInfoMap_.size(); }
224  int waferFileIndex(unsigned int kk) const;
225  std::tuple<int, int, int, int> waferFileInfo(unsigned int kk) const;
226  std::tuple<int, int, int, int> waferFileInfoFromIndex(int kk) const;
227  inline bool waferFileInfoExist(int kk) const {
228  return (hgpar_->waferInfoMap_.find(kk) != hgpar_->waferInfoMap_.end());
229  }
231  HepGeom::Point3D<float>& loc, const DetId& id, bool useWafer, bool reco, bool debug) const;
232  inline double waferSepar(bool reco) const {
234  }
235  inline double waferSize(bool reco) const {
237  }
238  int wafers() const;
239  int wafers(int layer, int type) const;
240  inline int waferToCopy(int wafer) const {
241  return ((wafer >= 0) && (wafer < static_cast<int>(hgpar_->waferCopy_.size())))
242  ? hgpar_->waferCopy_[wafer]
243  : static_cast<int>(hgpar_->waferCopy_.size());
244  }
245  // wafer transverse thickness classification (2 = coarse, 1 = fine)
246  inline int waferTypeT(int wafer) const {
247  return ((wafer >= 0) && (wafer < static_cast<int>(hgpar_->waferTypeT_.size()))) ? hgpar_->waferTypeT_[wafer] : 0;
248  }
249  // wafer longitudinal thickness classification (1 = 100um, 2 = 200um, 3=300um)
250  inline int waferTypeL(int wafer) const {
251  return ((wafer >= 0) && (wafer < static_cast<int>(hgpar_->waferTypeL_.size()))) ? hgpar_->waferTypeL_[wafer] : 0;
252  }
253  int waferType(DetId const& id, bool fromFile) const;
254  int waferType(int layer, int waferU, int waferV, bool fromFile) const;
255  std::tuple<int, int, int> waferType(HGCSiliconDetId const& id, bool fromFile) const;
256  std::pair<int, int> waferTypeRotation(int layer, int waferU, int waferV, bool fromFile, bool debug) const;
257  inline int waferUVMax() const { return hgpar_->waferUVMax_; }
258  bool waferVirtual(int layer, int waferU, int waferV) const;
259  double waferZ(int layer, bool reco) const;
260 
261 private:
262  int cellHex(double xx,
263  double yy,
264  const double& cellR,
265  const std::vector<double>& posX,
266  const std::vector<double>& posY) const;
267  void cellHex(
268  double xloc, double yloc, int cellType, int place, int part, int& cellU, int& cellV, bool extend, bool debug)
269  const;
270  std::pair<int, float> getIndex(int lay, bool reco) const;
271  int layerFromIndex(int index, bool reco) const;
272  bool isValidCell(int layindex, int wafer, int cell) const;
273  bool isValidCell8(int lay, int waferU, int waferV, int cellU, int cellV, int type) const;
274  int32_t waferIndex(int wafer, int index) const;
275  bool waferInLayerTest(int wafer, int lay, bool full) const;
276  std::pair<double, double> waferPositionNoRot(int lay, int waferU, int waferV, bool reco, bool debug) const;
277  std::pair<double, double> waferPosition(int waferU, int waferV, bool reco) const;
278 
280  std::unique_ptr<HGCalCell> hgcell_;
281  std::unique_ptr<HGCalCellUV> hgcellUV_;
282  std::unique_ptr<HGCalCellOffset> cellOffset_;
284  constexpr static double k_horizontalShift = 1.0;
285  constexpr static float dPhiMin = 0.02;
286  typedef std::array<std::vector<int32_t>, 2> Simrecovecs;
287  typedef std::array<int, 3> HGCWaferParam;
289  constexpr static double tan30deg_ = 0.5773502693;
290  constexpr static double tol_ = 0.001;
291  const double sqrt3_;
293  const bool fullAndPart_;
294  double rmax_, hexside_;
295  double rmaxT_, hexsideT_;
297  std::array<uint32_t, 2> tot_layers_;
300  std::map<int, HGCWaferParam> waferLayer_;
301  std::array<int, 4> waferMax_;
302  std::unordered_map<int32_t, bool> waferIn_;
303 };
304 
305 #endif
bool maskCell(const DetId &id, int corners) const
std::pair< double, double > rangeRLayer(int lay, bool reco) const
double waferZ(int layer, bool reco) const
static constexpr double tol_
void waferFromPosition(const double x, const double y, int &wafer, int &icell, int &celltyp) const
std::pair< double, double > rangeZ(bool reco) const
std::pair< int, int > tileRings(int layer) const
unsigned int layersInit(bool reco) const
static constexpr int32_t WaferCenter
Definition: HGCalTypes.h:21
int waferToCopy(int wafer) const
bool isValidCell(int layindex, int wafer, int cell) const
std::pair< double, double > cellSizeTrap(int type, int irad) const
int getPhiBins(int lay) const
HGCalCassette hgcassette_
bool cassetteShiftScintillator(int zside, int layer, int iphi) const
std::pair< double, double > cellEtaPhiTrap(int type, int irad) const
unsigned int volumes() const
int scintType(const int layer) const
const HGCalParameters * getParameter() const
def all(container)
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
bool waferInLayerTest(int wafer, int lay, bool full) const
std::pair< double, double > waferParameters(bool reco) const
std::vector< int > moduleLayR_
bool waferFullInLayer(int wafer, int lay, bool reco) const
double distFromEdgeTrap(double x, double y, double z) const
std::unique_ptr< HGCalCellUV > hgcellUV_
Simrecovecs max_modules_layer_
HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const
std::array< std::vector< int32_t >, 2 > Simrecovecs
int32_t waferU(const int32_t index)
HGCalParameters::waferInfo waferInfo(int lay, int waferU, int waferV) const
bool trapezoidFile() const
bool isValidHex(int lay, int mod, int cell, bool reco) const
bool tileRingEdge(double rho, int layer, int ring) const
int getLayerOffset() const
std::pair< int, int > getREtaRange(int lay) const
int lastLayer(bool reco) const
int waferTypeT(int wafer) const
std::pair< double, double > getXY(int layer, double x, double y, bool forwd) const
bool waferHexagon8() const
std::pair< int, int > waferTypeRotation(int layer, int waferU, int waferV, bool fromFile, bool debug) const
int modulesInit(int lay, bool reco) const
std::unordered_map< int32_t, bool > waferIn_
int zside(DetId const &)
int layerFromIndex(int index, bool reco) const
int firstLayer() const
std::vector< uint32_t > trformIndex_
HGCalGeometryMode::GeometryMode geomMode() const
int32_t cellType(int type, int waferU, int waferV, int iz, int fwdBack, int orient) const
bool waferHexagon6() const
bool isValidHex8(int lay, int waferU, int waferV, bool fullAndPart) const
const std::vector< double > & getRadiusLayer(int layer) const
~HGCalDDDConstants()=default
const HGCalCellOffset * cellOffset() const
hgtrform getTrForm(unsigned int k) const
bool v17OrLess() const
std::pair< double, double > getRangeR(int, bool reco) const
HGCalGeomTools geomTools_
bool waferInLayer(int wafer, int lay, bool reco) const
HGCalParameters::tileInfo tileInfo(int zside, int layer, int ring) const
std::map< int, HGCWaferParam > waferLayer_
static constexpr int32_t WaferFull
Definition: HGCalTypes.h:35
unsigned int waferFileSize() const
std::unique_ptr< HGCalCell > hgcell_
int getTypeHex(int layer, int waferU, int waferV) const
bool isHalfCell(int waferType, int cell) const
bool waferHexagon8Fine() const
int maxCells(bool reco) const
bool waferFileInfoExist(int kk) const
std::tuple< int, int, int, int > waferFileInfoFromIndex(int kk) const
std::tuple< int, int, int, int > waferFileInfo(unsigned int kk) const
std::array< int, 5 > assignCellHex(float x, float y, int zside, int lay, bool reco, bool extend, bool debug) const
int waferFileIndex(unsigned int kk) const
int maxModulesPerLayer() const
HGCalDDDConstants(const HGCalParameters *hp, const std::string &name)
int layerIndex(int lay, bool reco) const
Definition: GenABIO.cc:168
bool cellInLayer(int waferU, int waferV, int cellU, int cellV, int lay, int zside, bool reco) const
int getUVMax(int type) const
bool isValidCell8(int lay, int waferU, int waferV, int cellU, int cellV, int type) const
std::pair< int, int > simToReco(int cell, int layer, int mod, bool half) const
std::pair< int, float > getIndex(int lay, bool reco) const
int tileSiPM(int sipm) const
bool isValidTrap(int zside, int lay, int ieta, int iphi) const
bool waferVirtual(int layer, int waferU, int waferV) const
int tileCount(int layer, int ring) const
std::pair< int, int > assignCell(float x, float y, int lay, int subSec, bool reco) const
std::vector< int > calibCellPartHD_
std::vector< HGCalParameters::hgtrap > getModules() const
double mouseBite(bool reco) const
unsigned int layers(bool reco) const
bool tileTrapezoid() const
std::pair< int, int > tileType(int layer, int ring, int phi) const
bool tilePhiEdge(double phi, int layer, int iphi) const
std::pair< float, float > locateCellTrap(int zside, int lay, int ieta, int iphi, bool reco, bool debug) const
int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV, bool old=false)
int getTypeTrap(int layer) const
int32_t tileCassette(int32_t, int32_t, int32_t, int32_t)
bool waferHexagon8Module() const
double cellSizeHex(int type) const
std::vector< int > calibCellFullHD_
std::vector< int > layerType_
std::pair< double, double > rangeR(double z, bool reco) const
std::pair< double, double > waferPosition(int wafer, bool reco) const
void etaPhiFromPosition(const double x, const double y, const double z, const int layer, int &ieta, int &iphi, int &type, double &wt) const
std::vector< double > slopeMin_
Definition: DetId.h:17
std::array< int, 4 > waferMax_
static constexpr double k_ScaleToDDD
int numberCellsHexagon(int wafer) const
std::array< int, 3 > assignCellTrap(float x, float y, float z, int lay, bool reco) const
#define debug
Definition: HDRShower.cc:19
bool tileExist(int zside, int layer, int ring, int phi) const
double minSlope() const
GlobalPoint waferLocal2Global(HepGeom::Point3D< float > &loc, const DetId &id, bool useWafer, bool reco, bool debug) const
int numberCells(bool reco) const
part
Definition: HCALResponse.h:20
std::pair< float, float > locateCellHex(int cell, int wafer, bool reco) const
double cellThickness(int layer, int waferU, int waferV) const
int waferType(DetId const &id, bool fromFile) const
std::pair< int, int > rowColumnWafer(const int wafer) const
unsigned int getTrFormN() const
HGCalParameters::hgtrform getTrForm(unsigned int k) const
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
bool waferHexagon8File() const
int maxRows(int lay, bool reco) const
const HGCalGeometryMode::GeometryMode mode_
int32_t waferIndex(int wafer, int index) const
std::vector< HGCalParameters::hgtrform > getTrForms() const
double waferSepar(bool reco) const
fixed size matrix
int getLayer(double z, bool reco) const
bool cassetteShiftSilicon(int zside, int layer, int waferU, int waferV) const
static constexpr float dPhiMin
std::vector< int > calibCells(bool hd, bool full) const
std::array< int, 3 > HGCWaferParam
bool cassetteMode() const
int32_t waferV(const int32_t index)
int waferTypeL(int wafer) const
std::vector< int > waferCopy_
static constexpr double tan30deg_
double guardRingOffset(bool reco) const
std::vector< int > calibCellPartLD_
std::unique_ptr< HGCalCellOffset > cellOffset_
int cassetteTile(int iphi) const
double sensorSizeOffset(bool reco) const
std::vector< double > radiusLayer_[2]
std::array< uint32_t, 2 > tot_layers_
std::vector< int > waferTypeT_
int modules(int lay, bool reco) const
double calibCellRad(bool hd) const
std::vector< int > levelT_
int modifyUV(int uv, int type1, int type2) const
waferInfo_map waferInfoMap_
std::pair< float, float > localToGlobal8(int zside, int lay, int waferU, int waferV, double localX, double localY, bool reco, bool debug) const
const HGCalParameters * hgpar_
int levelTop(int ind=0) const
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
int cellHex(double xx, double yy, const double &cellR, const std::vector< double > &posX, const std::vector< double > &posY) const
int partialWaferType(int lay, int waferU, int waferV) const
std::vector< int > waferTypeL_
std::pair< double, double > waferPositionNoRot(int lay, int waferU, int waferV, bool reco, bool debug) const
static constexpr double k_horizontalShift
double waferSize(bool reco) const
double distFromEdgeHex(double x, double y, double z) const
int layerType(int lay) const
int waferFromCopy(int copy) const
std::vector< int > calibCellFullLD_
int waferCount(const int type) const