CMS 3D CMS Logo

HGCalNumberingScheme.cc
Go to the documentation of this file.
1 // File: HGCalNumberingScheme.cc
3 // Description: Numbering scheme for High Granularity Calorimeter
9 #include <iostream>
10 
11 //#define EDM_ML_DEBUG
12 
14  const DetId::Detector& det,
15  const std::string & name) :
16  hgcons_(hgc), mode_(hgc.geomMode()), det_(det), name_(name) {
17 #ifdef EDM_ML_DEBUG
18  edm::LogVerbatim("HGCSim") << "Creating HGCalNumberingScheme for " << name_
19  << " Det " << det_;
20 #endif
21 }
22 
24 #ifdef EDM_ML_DEBUG
25  edm::LogVerbatim("HGCSim") << "Deleting HGCalNumberingScheme";
26 #endif
27 }
28 
29 uint32_t HGCalNumberingScheme::getUnitID(int layer, int module, int cell,
30  int iz, const G4ThreeVector &pos,
31  double& wt) {
32  // module is the copy number of the wafer as placed in the layer
33  uint32_t index(0);
34  wt = 1.0;
37  int cellU(0), cellV(0), waferType(-1), waferU(0), waferV(0);
38  if (cell >= 0) {
39  waferType = module/1000000;
40  waferU = module%100;
41  if ((module/10000)%10 > 0) waferU = -waferU;
42  waferV = (module/100)%100;
43  if ((module/100000)%10 > 0) waferV = -waferV;
44  cellU = cell%100;
45  cellV = (cell/100)%100;
46  } else if (mode_ == HGCalGeometryMode::Hexagon8Full) {
47  double xx = (pos.z() > 0) ? pos.x() : -pos.x();
48  hgcons_.waferFromPosition(xx,pos.y(),layer,waferU,waferV,cellU,
49  cellV,waferType,wt);
50  }
51  if (waferType >= 0) {
52  index = HGCSiliconDetId(det_,iz,waferType,layer,waferU,waferV,
53  cellU,cellV).rawId();
54 #ifdef EDM_ML_DEBUG
55  edm::LogVerbatim("HGCSim") << "OK WaferType " << waferType << " Wafer "
56  << waferU << ":" << waferV << " Cell "
57  << cellU << ":" << cellV;
58  } else {
59  edm::LogVerbatim("HGCSim") << "Bad WaferType " << waferType;
60 #endif
61  }
62  } else if (mode_ == HGCalGeometryMode::Trapezoid) {
63  std::array<int,3> id = hgcons_.assignCellTrap(pos.x(),pos.y(),pos.z(),
64  layer,false);
65  if (id[2] >= 0) {
66  index = HGCScintillatorDetId(id[2], layer, iz*id[0], id[1]).rawId();
67 #ifdef EDM_ML_DEBUG
68  edm::LogVerbatim("HGCSim") << "Eta/Phi " << id[0] << ":" << id[1]
69  << " Type " << id[2] << " Layer|iz "
70  << layer << ":" << iz << " "
71  << HGCScintillatorDetId(index);
72  } else {
73  edm::LogVerbatim("HGCSim") << "Eta/Phi " << id[0] << ":" << id[1]
74  << " Type " << id[2] << " Layer|iz " << layer
75  << ":" << iz;
76 #endif
77  }
78 
79  }
80 #ifdef EDM_ML_DEBUG
81  edm::LogVerbatim("HGCSim") << "HGCalNumberingScheme::i/p " << det_ << ":"
82  << layer << ":" << module << ":" << cell << ":"
83  << iz << ":" << pos.x() << ":" << pos.y() << ":"
84  << pos.z() << " ID " << std::hex << index
85  << std::dec << " wt " << wt;
86 #endif
87  return index;
88 }
HGCalNumberingScheme()=delete
void waferFromPosition(const double x, const double y, int &wafer, int &icell, int &celltyp) const
const HGCalGeometryMode::GeometryMode mode_
const HGCalDDDConstants & hgcons_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:47
uint32_t getUnitID(int layer, int module, int cell, int iz, const G4ThreeVector &pos, double &wt)
assigns the det id to a hit
Detector
Definition: DetId.h:26
std::array< int, 3 > assignCellTrap(float x, float y, float z, int lay, bool reco) const
Definition: vlib.h:208