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(
88  int lay, int waferU, int waferV, int cellU, int cellV, bool reco, bool all, bool debug = false) const;
89  std::pair<float, float> locateCell(const HGCSiliconDetId&, bool debug = false) const;
90  std::pair<float, float> locateCell(const HGCScintillatorDetId&, bool debug = false) const;
91  std::pair<float, float> locateCellHex(int cell, int wafer, bool reco) const;
92  std::pair<float, float> locateCellTrap(int lay, int ieta, int iphi, bool reco) const;
93  int levelTop(int ind = 0) const { return hgpar_->levelT_[ind]; }
94  bool maskCell(const DetId& id, int corners) const;
95  int maxCellUV() const { return (tileTrapezoid() ? hgpar_->nCellsFine_ : 2 * hgpar_->nCellsFine_); }
96  int maxCells(bool reco) const;
97  int maxCells(int lay, bool reco) const;
98  int maxModules() const { return modHalf_; }
99  int maxModulesPerLayer() const { return maxWafersPerLayer_; }
100  int maxRows(int lay, bool reco) const;
101  double minSlope() const { return hgpar_->slopeMin_[0]; }
102  int modifyUV(int uv, int type1, int type2) const;
103  int modules(int lay, bool reco) const;
104  int modulesInit(int lay, bool reco) const;
105  double mouseBite(bool reco) const;
106  int numberCells(bool reco) const;
107  std::vector<int> numberCells(int lay, bool reco) const;
108  int numberCellsHexagon(int wafer) const;
109  int numberCellsHexagon(int lay, int waferU, int waferV, bool flag) const;
110  std::pair<double, double> rangeR(double z, bool reco) const;
111  std::pair<double, double> rangeRLayer(int lay, bool reco) const;
112  std::pair<double, double> rangeZ(bool reco) const;
113  std::pair<int, int> rowColumnWafer(const int wafer) const;
114  int sectors() const { return hgpar_->nSectors_; }
115  std::pair<int, int> simToReco(int cell, int layer, int mod, bool half) const;
116  int tileCount(int layer, int ring) const;
117  bool tileExist(int zside, int layer, int ring, int phi) const {
118  int indx = HGCalTileIndex::tileIndex(layer, ring, 0);
119  auto itr = hgpar_->tileInfoMap_.find(indx);
120  bool ok = (itr == hgpar_->tileInfoMap_.end()) ? false : HGCalTileIndex::tileExist(itr->second.hex, zside, phi);
121  return ok;
122  }
123  std::pair<int, int> tileRings(int layer) const {
125  int ll = layer - hgpar_->firstLayer_;
126  if (ll >= 0 && ll < static_cast<int>(hgpar_->tileRingRange_.size()))
127  return hgpar_->tileRingRange_[ll];
128  }
129  return std::make_pair(0, 0);
130  }
131  int tileSiPM(int sipm) const { return ((sipm > 0) ? HGCalTypes::SiPMSmall : HGCalTypes::SiPMLarge); }
132  bool tileTrapezoid() const {
135  }
136  std::pair<int, int> tileType(int layer, int ring, int phi) const {
137  int indx = HGCalTileIndex::tileIndex(layer, ring, phi);
138  int type(-1), sipm(-1);
139  auto itr = hgpar_->tileInfoMap_.find(indx);
140  if (itr != hgpar_->tileInfoMap_.end()) {
141  type = 1 + (itr->second).type;
142  sipm = ((itr->second).sipm == HGCalTypes::SiPMLarge) ? 0 : 1;
143  }
144  return std::make_pair(type, sipm);
145  }
146  unsigned int volumes() const { return hgpar_->moduleLayR_.size(); }
147  int waferFromCopy(int copy) const;
148  void waferFromPosition(const double x, const double y, int& wafer, int& icell, int& celltyp) const;
149  void waferFromPosition(const double x,
150  const double y,
151  const int layer,
152  int& waferU,
153  int& waferV,
154  int& cellU,
155  int& cellV,
156  int& celltype,
157  double& wt,
158  bool extend = false,
159  bool debug = false) const;
160  bool waferHexagon6() const {
162  }
163  bool waferHexagon8() const {
166  }
167  bool waferInLayer(int wafer, int lay, bool reco) const;
168  bool waferFullInLayer(int wafer, int lay, bool reco) const;
169  int waferCount(const int type) const { return ((type == 0) ? waferMax_[2] : waferMax_[3]); }
170  int waferMax() const { return waferMax_[1]; }
171  int waferMin() const { return waferMax_[0]; }
172  std::pair<double, double> waferParameters(bool reco) const;
173  std::pair<double, double> waferPosition(int wafer, bool reco) const;
174  std::pair<double, double> waferPosition(int lay, int waferU, int waferV, bool reco, bool debug = false) const;
175  unsigned int waferFileSize() const { return hgpar_->waferInfoMap_.size(); }
176  int waferFileIndex(unsigned int kk) const {
177  if (kk < hgpar_->waferInfoMap_.size()) {
178  auto itr = hgpar_->waferInfoMap_.begin();
179  std::advance(itr, kk);
180  return itr->first;
181  } else
182  return 0;
183  }
184  std::tuple<int, int, int> waferFileInfo(unsigned int kk) const {
185  if (kk < hgpar_->waferInfoMap_.size()) {
186  auto itr = hgpar_->waferInfoMap_.begin();
187  std::advance(itr, kk);
188  return std::make_tuple(itr->second.type, itr->second.part, itr->second.orient);
189  } else
190  return std::make_tuple(0, 0, 0);
191  }
192  std::tuple<int, int, int> waferFileInfoFromIndex(int kk) const {
193  auto itr = hgpar_->waferInfoMap_.find(kk);
194  if (itr != hgpar_->waferInfoMap_.end()) {
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  bool waferFileInfoExist(int kk) const { return (hgpar_->waferInfoMap_.find(kk) != hgpar_->waferInfoMap_.end()); }
200  double waferSepar(bool reco) const {
202  }
204  HepGeom::Point3D<float>& loc, const DetId& id, bool useWafer, bool reco, bool debug) const {
205  HGCSiliconDetId detid(id);
206  double x(0), y(0);
207  if (useWafer) {
208  auto xyw = waferPositionNoRot(detid.layer(), detid.waferU(), detid.waferV(), reco, debug);
209  x = xyw.first;
210  y = xyw.second;
211  }
212  auto xy = getXY(detid.layer(), (x + loc.x()), (y + loc.y()), false);
213  double zz =
214  (detid.zside() < 0) ? -(loc.z() + waferZ(detid.layer(), reco)) : (loc.z() + waferZ(detid.layer(), reco));
215  double xx = (detid.zside() < 0) ? -xy.first : xy.first;
216  return GlobalPoint(xx, xy.second, zz);
217  }
218  double waferSize(bool reco) const {
220  }
221  int wafers() const;
222  int wafers(int layer, int type) const;
223  int waferToCopy(int wafer) const {
224  return ((wafer >= 0) && (wafer < static_cast<int>(hgpar_->waferCopy_.size())))
225  ? hgpar_->waferCopy_[wafer]
226  : static_cast<int>(hgpar_->waferCopy_.size());
227  }
228  // wafer transverse thickness classification (2 = coarse, 1 = fine)
229  int waferTypeT(int wafer) const {
230  return ((wafer >= 0) && (wafer < static_cast<int>(hgpar_->waferTypeT_.size()))) ? hgpar_->waferTypeT_[wafer] : 0;
231  }
232  // wafer longitudinal thickness classification (1 = 100um, 2 = 200um, 3=300um)
233  int waferTypeL(int wafer) const {
234  return ((wafer >= 0) && (wafer < static_cast<int>(hgpar_->waferTypeL_.size()))) ? hgpar_->waferTypeL_[wafer] : 0;
235  }
236  int waferType(DetId const& id, bool fromFile = false) const;
237  int waferType(int layer, int waferU, int waferV, bool fromFile = false) const;
238  std::tuple<int, int, int> waferType(HGCSiliconDetId const& id, bool fromFile = false) const;
239  std::pair<int, int> waferTypeRotation(
240  int layer, int waferU, int waferV, bool fromFile = false, bool debug = false) const;
241  int waferUVMax() const { return hgpar_->waferUVMax_; }
242  bool waferVirtual(int layer, int waferU, int waferV) const;
243  double waferZ(int layer, bool reco) const;
244 
245 private:
246  int cellHex(double xx,
247  double yy,
248  const double& cellR,
249  const std::vector<double>& posX,
250  const std::vector<double>& posY) const;
251  void cellHex(
252  double xloc, double yloc, int cellType, int& cellU, int& cellV, bool extend = false, bool debug = false) const;
253  std::pair<int, float> getIndex(int lay, bool reco) const;
254  int layerFromIndex(int index, bool reco) const;
255  bool isValidCell(int layindex, int wafer, int cell) const;
256  bool isValidCell8(int lay, int waferU, int waferV, int cellU, int cellV, int type) const;
257  int32_t waferIndex(int wafer, int index) const;
258  bool waferInLayerTest(int wafer, int lay, bool full) const;
259  std::pair<double, double> waferPositionNoRot(int lay, int waferU, int waferV, bool reco, bool debug = false) const;
260  std::pair<double, double> waferPosition(int waferU, int waferV, bool reco) const;
261 
263  const double k_horizontalShift = 1.0;
264  const float dPhiMin = 0.02;
265  typedef std::array<std::vector<int32_t>, 2> Simrecovecs;
266  typedef std::array<int, 3> HGCWaferParam;
268  constexpr static double tan30deg_ = 0.5773502693;
269  const double sqrt3_;
271  const bool fullAndPart_;
272  double rmax_, hexside_;
273  double rmaxT_, hexsideT_;
275  std::array<uint32_t, 2> tot_layers_;
278  std::map<int, HGCWaferParam> waferLayer_;
279  std::array<int, 4> waferMax_;
280  std::unordered_map<int32_t, bool> waferIn_;
281 };
282 
283 #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
constexpr uint16_t localY(uint16_t py)
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
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