CMS 3D CMS Logo

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