CMS 3D CMS Logo

HGCalDDDConstants.h
Go to the documentation of this file.
1 #ifndef HGCalCommonData_HGCalDDDConstants_h
2 #define HGCalCommonData_HGCalDDDConstants_h
3 
27 #include <CLHEP/Geometry/Point3D.h>
28 
29 #include <array>
30 #include <memory>
31 #include <string>
32 #include <vector>
33 #include <unordered_map>
34 
36 public:
38  ~HGCalDDDConstants() = default;
39 
40  std::pair<int, int> assignCell(float x, float y, int lay, int subSec, bool reco) const;
41  std::array<int, 5> assignCellHex(float x, float y, int lay, bool reco, bool extend = false, bool debug = false) const;
42  std::array<int, 3> assignCellTrap(float x, float y, float z, int lay, bool reco) const;
43  std::pair<double, double> cellEtaPhiTrap(int type, int irad) const;
44  bool cellInLayer(int waferU, int waferV, int cellU, int cellV, int lay, bool reco) const;
45  double cellSizeHex(int type) const;
46  inline std::pair<double, double> cellSizeTrap(int type, int irad) const {
47  return std::make_pair(hgpar_->radiusLayer_[type][irad - 1], hgpar_->radiusLayer_[type][irad]);
48  }
49  double cellThickness(int layer, int waferU, int waferV) const;
50  int32_t cellType(int type, int waferU, int waferV, int iz, int fwdBack, int orient) const;
51  double distFromEdgeHex(double x, double y, double z) const;
52  double distFromEdgeTrap(double x, double y, double z) const;
53  void etaPhiFromPosition(const double x,
54  const double y,
55  const double z,
56  const int layer,
57  int& ieta,
58  int& iphi,
59  int& type,
60  double& wt) const;
61  inline int firstLayer() const { return hgpar_->firstLayer_; }
62  inline HGCalGeometryMode::GeometryMode geomMode() const { return mode_; }
63  int getLayer(double z, bool reco) const;
64  int getLayerOffset() const { return hgpar_->layerOffset_; }
65  HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const;
66  std::vector<HGCalParameters::hgtrap> getModules() const;
67  inline const HGCalParameters* getParameter() const { return hgpar_; }
68  int getPhiBins(int lay) const;
69  std::pair<int, int> getREtaRange(int lay) const;
70  inline const std::vector<double>& getRadiusLayer(int layer) const {
72  }
73  inline HGCalParameters::hgtrform getTrForm(unsigned int k) const { return hgpar_->getTrForm(k); }
74  inline unsigned int getTrFormN() const { return hgpar_->trformIndex_.size(); }
75  std::vector<HGCalParameters::hgtrform> getTrForms() const;
76  int getTypeTrap(int layer) const;
77  int getTypeHex(int layer, int waferU, int waferV) const;
78  std::pair<double, double> getXY(int layer, double x, double y, bool forwd) const;
79  inline int getUVMax(int type) const { return ((type == 0) ? hgpar_->nCellsFine_ : hgpar_->nCellsCoarse_); }
80  bool isHalfCell(int waferType, int cell) const;
81  bool isValidHex(int lay, int mod, int cell, bool reco) const;
82  bool isValidHex8(int lay, int waferU, int waferV, bool fullAndPart = false) const;
83  bool isValidHex8(int lay, int modU, int modV, int cellU, int cellV, bool fullAndPart = false) const;
84  bool isValidTrap(int zside, int lay, int ieta, int iphi) const;
85  int lastLayer(bool reco) const;
86  int layerIndex(int lay, bool reco) const;
87  unsigned int layers(bool reco) const;
88  unsigned int layersInit(bool reco) const;
89  inline int layerType(int lay) const {
91  }
92  std::pair<float, float> localToGlobal8(
93  int lay, int waferU, int waferV, double localX, double localY, bool reco, bool debug) const;
94  std::pair<float, float> locateCell(int cell, int lay, int type, bool reco) const;
95  std::pair<float, float> locateCell(int lay,
96  int waferU,
97  int waferV,
98  int cellU,
99  int cellV,
100  bool reco,
101  bool all,
102  bool norot = false,
103  bool debug = false) const;
104  std::pair<float, float> locateCell(const HGCSiliconDetId&, bool debug = false) const;
105  std::pair<float, float> locateCell(const HGCScintillatorDetId&, bool debug = false) const;
106  std::pair<float, float> locateCellHex(int cell, int wafer, bool reco) const;
107  std::pair<float, float> locateCellTrap(int lay, int ieta, int iphi, bool reco, bool debug = false) const;
108  inline int levelTop(int ind = 0) const { return hgpar_->levelT_[ind]; }
109  bool maskCell(const DetId& id, int corners) const;
110  inline int maxCellUV() const { return (tileTrapezoid() ? hgpar_->nCellsFine_ : 2 * hgpar_->nCellsFine_); }
111  int maxCells(bool reco) const;
112  int maxCells(int lay, bool reco) const;
113  inline int maxModules() const { return modHalf_; }
114  inline int maxModulesPerLayer() const { return maxWafersPerLayer_; }
115  int maxRows(int lay, bool reco) const;
116  inline double minSlope() const { return hgpar_->slopeMin_[0]; }
117  int modifyUV(int uv, int type1, int type2) const;
118  int modules(int lay, bool reco) const;
119  int modulesInit(int lay, bool reco) const;
120  double mouseBite(bool reco) const;
121  int numberCells(bool reco) const;
122  std::vector<int> numberCells(int lay, bool reco) const;
123  int numberCellsHexagon(int wafer) const;
124  int numberCellsHexagon(int lay, int waferU, int waferV, bool flag) const;
125  std::pair<double, double> rangeR(double z, bool reco) const;
126  std::pair<double, double> rangeRLayer(int lay, bool reco) const;
127  std::pair<double, double> rangeZ(bool reco) const;
128  std::pair<int, int> rowColumnWafer(const int wafer) const;
129  inline int sectors() const { return hgpar_->nSectors_; }
130  std::pair<int, int> simToReco(int cell, int layer, int mod, bool half) const;
131  int tileCount(int layer, int ring) const;
132  bool tileExist(int zside, int layer, int ring, int phi) const;
133  HGCalParameters::tileInfo tileInfo(int zside, int layer, int ring) const;
134  std::pair<int, int> tileRings(int layer) const;
135  inline int tileSiPM(int sipm) const { return ((sipm > 0) ? HGCalTypes::SiPMSmall : HGCalTypes::SiPMLarge); }
136  bool tileTrapezoid() const {
139  }
140  std::pair<int, int> tileType(int layer, int ring, int phi) const;
141  inline bool trapezoidFile() const {
144  }
145  inline unsigned int volumes() const { return hgpar_->moduleLayR_.size(); }
146  int waferFromCopy(int copy) const;
147  void waferFromPosition(const double x, const double y, int& wafer, int& icell, int& celltyp) const;
148  void waferFromPosition(const double x,
149  const double y,
150  const int layer,
151  int& waferU,
152  int& waferV,
153  int& cellU,
154  int& cellV,
155  int& celltype,
156  double& wt,
157  bool extend = false,
158  bool debug = false) const;
159  inline bool waferHexagon6() const {
161  }
162  inline bool waferHexagon8() const {
166  }
167  inline bool waferHexagon8File() const {
170  }
171  bool waferInLayer(int wafer, int lay, bool reco) const;
172  bool waferFullInLayer(int wafer, int lay, bool reco) const;
173  inline int waferCount(const int type) const { return ((type == 0) ? waferMax_[2] : waferMax_[3]); }
174  HGCalParameters::waferInfo waferInfo(int lay, int waferU, int waferV) const;
175  inline int waferMax() const { return waferMax_[1]; }
176  inline int waferMin() const { return waferMax_[0]; }
177  std::pair<double, double> waferParameters(bool reco) const;
178  std::pair<double, double> waferPosition(int wafer, bool reco) const;
179  std::pair<double, double> waferPosition(int lay, int waferU, int waferV, bool reco, bool debug = false) const;
180  inline unsigned int waferFileSize() const { return hgpar_->waferInfoMap_.size(); }
181  int waferFileIndex(unsigned int kk) const;
182  std::tuple<int, int, int> waferFileInfo(unsigned int kk) const;
183  std::tuple<int, int, int> waferFileInfoFromIndex(int kk) const;
184  inline bool waferFileInfoExist(int kk) const {
185  return (hgpar_->waferInfoMap_.find(kk) != hgpar_->waferInfoMap_.end());
186  }
188  HepGeom::Point3D<float>& loc, const DetId& id, bool useWafer, bool reco, bool debug) const;
189  inline double waferSepar(bool reco) const {
191  }
192  inline double waferSize(bool reco) const {
194  }
195  int wafers() const;
196  int wafers(int layer, int type) const;
197  inline int waferToCopy(int wafer) const {
198  return ((wafer >= 0) && (wafer < static_cast<int>(hgpar_->waferCopy_.size())))
199  ? hgpar_->waferCopy_[wafer]
200  : static_cast<int>(hgpar_->waferCopy_.size());
201  }
202  // wafer transverse thickness classification (2 = coarse, 1 = fine)
203  inline int waferTypeT(int wafer) const {
204  return ((wafer >= 0) && (wafer < static_cast<int>(hgpar_->waferTypeT_.size()))) ? hgpar_->waferTypeT_[wafer] : 0;
205  }
206  // wafer longitudinal thickness classification (1 = 100um, 2 = 200um, 3=300um)
207  inline int waferTypeL(int wafer) const {
208  return ((wafer >= 0) && (wafer < static_cast<int>(hgpar_->waferTypeL_.size()))) ? hgpar_->waferTypeL_[wafer] : 0;
209  }
210  int waferType(DetId const& id, bool fromFile = false) const;
211  int waferType(int layer, int waferU, int waferV, bool fromFile = false) const;
212  std::tuple<int, int, int> waferType(HGCSiliconDetId const& id, bool fromFile = false) const;
213  std::pair<int, int> waferTypeRotation(
214  int layer, int waferU, int waferV, bool fromFile = false, bool debug = false) const;
215  inline int waferUVMax() const { return hgpar_->waferUVMax_; }
216  bool waferVirtual(int layer, int waferU, int waferV) const;
217  double waferZ(int layer, bool reco) const;
218 
219 private:
220  int cellHex(double xx,
221  double yy,
222  const double& cellR,
223  const std::vector<double>& posX,
224  const std::vector<double>& posY) const;
225  void cellHex(double xloc,
226  double yloc,
227  int cellType,
228  int place,
229  int part,
230  int& cellU,
231  int& cellV,
232  bool extend = false,
233  bool debug = false) const;
234  std::pair<int, float> getIndex(int lay, bool reco) const;
235  int layerFromIndex(int index, bool reco) const;
236  bool isValidCell(int layindex, int wafer, int cell) const;
237  bool isValidCell8(int lay, int waferU, int waferV, int cellU, int cellV, int type) const;
238  int32_t waferIndex(int wafer, int index) const;
239  bool waferInLayerTest(int wafer, int lay, bool full) const;
240  std::pair<double, double> waferPositionNoRot(int lay, int waferU, int waferV, bool reco, bool debug = false) const;
241  std::pair<double, double> waferPosition(int waferU, int waferV, bool reco) const;
242 
244  std::unique_ptr<HGCalCell> hgcell_;
245  std::unique_ptr<HGCalCellUV> hgcellUV_;
247  const double k_horizontalShift = 1.0;
248  const float dPhiMin = 0.02;
249  typedef std::array<std::vector<int32_t>, 2> Simrecovecs;
250  typedef std::array<int, 3> HGCWaferParam;
252  constexpr static double tan30deg_ = 0.5773502693;
253  const double sqrt3_;
255  const bool fullAndPart_;
256  double rmax_, hexside_;
257  double rmaxT_, hexsideT_;
259  std::array<uint32_t, 2> tot_layers_;
262  std::map<int, HGCWaferParam> waferLayer_;
263  std::array<int, 4> waferMax_;
264  std::unordered_map<int32_t, bool> waferIn_;
265 };
266 
267 #endif
bool maskCell(const DetId &id, int corners) const
std::pair< float, float > locateCellTrap(int lay, int ieta, int iphi, bool reco, bool debug=false) const
std::pair< double, double > rangeRLayer(int lay, bool reco) const
double waferZ(int layer, bool reco) const
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
std::tuple< int, int, int > waferFileInfoFromIndex(int kk) const
int getPhiBins(int lay) const
HGCalCassette hgcassette_
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 isValidHex8(int lay, int waferU, int waferV, bool fullAndPart=false) const
std::pair< int, int > waferTypeRotation(int layer, int waferU, int waferV, bool fromFile=false, bool debug=false) 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
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
const std::vector< double > & getRadiusLayer(int layer) const
~HGCalDDDConstants()=default
hgtrform getTrForm(unsigned int k) const
constexpr std::array< uint8_t, layerIndexSize > layer
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_
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
int maxCells(bool reco) const
bool waferFileInfoExist(int kk) 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
std::pair< float, float > localToGlobal8(int lay, int waferU, int waferV, double localX, double localY, bool reco, bool debug) const
Definition: GenABIO.cc:168
int waferType(DetId const &id, bool fromFile=false) 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< 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
int getTypeTrap(int layer) const
double cellSizeHex(int type) const
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
std::tuple< int, int, int > waferFileInfo(unsigned int kk) const
bool tileExist(int zside, int layer, int ring, int phi) const
bool cellInLayer(int waferU, int waferV, int cellU, int cellV, int lay, bool reco) const
double minSlope() const
GlobalPoint waferLocal2Global(HepGeom::Point3D< float > &loc, const DetId &id, bool useWafer, bool reco, bool debug) const
constexpr uint16_t localX(uint16_t px)
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
constexpr uint16_t localY(uint16_t py, uint16_t n)
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::array< int, 5 > assignCellHex(float x, float y, int lay, bool reco, bool extend=false, bool debug=false) const
std::vector< HGCalParameters::hgtrform > getTrForms() const
double waferSepar(bool reco) const
fixed size matrix
int getLayer(double z, bool reco) const
std::array< int, 3 > HGCWaferParam
int32_t waferV(const int32_t index)
int waferTypeL(int wafer) const
std::vector< int > waferCopy_
static constexpr double tan30deg_
std::pair< double, double > waferPositionNoRot(int lay, int waferU, int waferV, bool reco, bool debug=false) const
const double k_horizontalShift
std::vector< double > radiusLayer_[2]
std::array< uint32_t, 2 > tot_layers_
std::vector< int > waferTypeT_
int modules(int lay, bool reco) const
std::vector< int > levelT_
int modifyUV(int uv, int type1, int type2) const
waferInfo_map waferInfoMap_
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
std::vector< int > waferTypeL_
double waferSize(bool reco) const
double distFromEdgeHex(double x, double y, double z) const
int layerType(int lay) const
int waferFromCopy(int copy) const
int waferCount(const int type) const