CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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  HGCalTypes::CellType cellType(int type, int waferU, int waferV) 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 isHalfCell(int waferType, int cell) const
std::pair< double, double > cellSizeTrap(int type, int irad) const
bool isValidTrap(int lay, int ieta, int iphi) const
std::tuple< int, int, int > waferFileInfo(unsigned int kk) const
int getTypeTrap(int layer) const
GlobalPoint waferLocal2Global(HepGeom::Point3D< float > &loc, const DetId &id, bool useWafer, bool reco, bool debug) const
int getLayer(double z, bool reco) const
std::vector< HGCalParameters::hgtrap > getModules() const
bool waferHexagon6() const
int scintType(const int layer) const
void waferFromPosition(const double x, const double y, int &wafer, int &icell, int &celltyp) const
int tileSiPM(int sipm) const
int waferFileIndex(unsigned int kk) const
std::vector< int > moduleLayR_
double cellSizeHex(int type) const
HGCalParameters::hgtrform getTrForm(unsigned int k) const
Simrecovecs max_modules_layer_
int lastLayer(bool reco) const
std::pair< int, int > waferTypeRotation(int layer, int waferU, int waferV, bool fromFile=false, bool debug=false) const
double cellThickness(int layer, int waferU, int waferV) const
unsigned int layersInit(bool reco) const
std::array< std::vector< int32_t >, 2 > Simrecovecs
int32_t waferU(const int32_t index)
int waferU() const
const HGCalParameters * getParameter() const
bool cellInLayer(int waferU, int waferV, int cellU, int cellV, int lay, bool reco) const
int maxRows(int lay, bool reco) const
int getTypeHex(int layer, int waferU, int waferV) const
unsigned int waferFileSize() const
bool waferInLayerTest(int wafer, int lay, bool full) const
bool tileExist(int zside, int layer, int ring, int phi) const
int zside() const
get the z-side of the cell (1/-1)
std::unordered_map< int32_t, bool > waferIn_
int zside(DetId const &)
int modulesInit(int lay, bool reco) const
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
std::vector< uint32_t > trformIndex_
bool isValidHex(int lay, int mod, int cell, bool reco) const
bool isValidCell8(int lay, int waferU, int waferV, int cellU, int cellV, int type) const
int cellHex(double xx, double yy, const double &cellR, const std::vector< double > &posX, const std::vector< double > &posY) const
int32_t waferIndex(int wafer, int index) const
int layerIndex(int lay, bool reco) const
constexpr std::array< uint8_t, layerIndexSize > layer
HGCalGeomTools geomTools_
std::pair< float, float > locateCellHex(int cell, int wafer, bool reco) const
const std::vector< double > & getRadiusLayer(int layer) const
std::pair< double, double > rangeR(double z, bool reco) 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 modules(int lay, bool reco) const
std::pair< int, int > simToReco(int cell, int layer, int mod, bool half) const
unsigned int getTrFormN() const
double distFromEdgeTrap(double x, double y, double z) const
std::pair< double, double > rangeZ(bool reco) const
std::pair< int, int > tileRings(int layer) const
unsigned int layers(bool reco) const
int numberCellsHexagon(int wafer) const
std::vector< HGCalParameters::hgtrform > getTrForms() const
std::pair< double, double > cellEtaPhiTrap(int type, int irad) const
double mouseBite(bool reco) const
hgtrform getTrForm(unsigned int k) const
std::pair< int, float > getIndex(int lay, bool reco) const
int layer() const
get the layer #
HGCalDDDConstants(const HGCalParameters *hp, const std::string &name)
std::pair< float, float > locateCellTrap(int lay, int ieta, int iphi, bool reco) const
std::pair< float, float > localToGlobal8(int lay, int waferU, int waferV, double localX, double localY, bool reco, bool debug) const
int waferV() const
double waferSepar(bool reco) const
bool tileTrapezoid() const
Definition: GenABIO.cc:168
double minSlope() const
HGCalGeometryMode::GeometryMode geomMode() const
double waferSize(bool reco) const
bool isValidCell(int layindex, int wafer, int cell) const
int waferTypeL(int wafer) const
int getPhiBins(int lay) const
int maxCellUV() const
HGCalTypes::CellType cellType(int type, int waferU, int waferV) const
std::pair< int, int > getREtaRange(int lay) const
std::pair< int, int > rowColumnWafer(const int wafer) const
double waferZ(int layer, bool reco) const
def all
workaround iterator generators for ROOT classes
Definition: cmstools.py:25
std::pair< double, double > getXY(int layer, double x, double y, bool forwd) const
bool waferVirtual(int layer, int waferU, int waferV) const
std::vector< double > slopeMin_
Basic2DVector< T > xy() const
Definition: DetId.h:17
std::array< int, 4 > waferMax_
int waferFromCopy(int copy) const
static constexpr double k_ScaleToDDD
#define debug
Definition: HDRShower.cc:19
constexpr uint16_t localX(uint16_t px)
int waferToCopy(int wafer) const
bool maskCell(const DetId &id, int corners) const
int waferUVMax() const
constexpr uint16_t localY(uint16_t py, uint16_t n)
std::array< int, 5 > assignCellHex(float x, float y, int lay, bool reco, bool extend=false, bool debug=false) const
int numberCells(bool reco) const
bool waferFullInLayer(int wafer, int lay, bool reco) const
bool isValidHex8(int lay, int waferU, int waferV, bool fullAndPart=false) const
const HGCalGeometryMode::GeometryMode mode_
int waferCount(const int type) const
std::pair< double, double > waferParameters(bool reco) const
bool waferFileInfoExist(int kk) const
std::array< int, 3 > HGCWaferParam
int32_t waferV(const int32_t index)
std::vector< int > waferCopy_
std::tuple< int, int, int > waferFileInfoFromIndex(int kk) const
bool waferHexagon8() const
int tileCount(int layer, int ring) const
bool tileExist(const int32_t *hex, int32_t zside, int32_t phi)
std::pair< double, double > waferPosition(int wafer, bool reco) const
std::pair< int, int > assignCell(float x, float y, int lay, int subSec, bool reco) const
static constexpr double tan30deg_
const double k_horizontalShift
std::array< int, 3 > assignCellTrap(float x, float y, float z, int lay, bool reco) const
std::vector< double > radiusLayer_[2]
std::array< uint32_t, 2 > tot_layers_
int firstLayer() const
std::vector< int > waferTypeT_
std::vector< int > levelT_
int maxModules() const
int levelTop(int ind=0) const
int maxModulesPerLayer() const
waferInfo_map waferInfoMap_
HGCalParameters::hgtrap getModule(unsigned int k, bool hexType, bool reco) const
std::pair< double, double > waferPositionNoRot(int lay, int waferU, int waferV, bool reco, bool debug=false) const
const HGCalParameters * hgpar_
std::pair< int, int > tileType(int layer, int ring, int phi) const
int layerFromIndex(int index, bool reco) const
int maxCells(bool reco) const
int modifyUV(int uv, int type1, int type2) const
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
tileInfo_map tileInfoMap_
void etaPhiFromPosition(const double x, const double y, const double z, const int layer, int &ieta, int &iphi, int &type, double &wt) const
int waferTypeT(int wafer) const
std::vector< int > waferTypeL_
std::pair< double, double > rangeRLayer(int lay, bool reco) const
int getUVMax(int type) const
int getLayerOffset() const
double distFromEdgeHex(double x, double y, double z) const
bool waferInLayer(int wafer, int lay, bool reco) const
int waferType(DetId const &id, bool fromFile=false) const
unsigned int volumes() const