CMS 3D CMS Logo

ETLNumberingScheme.cc
Go to the documentation of this file.
1 //#define EDM_ML_DEBUG
2 
4 
7 
8 #include <iostream>
9 
11 #ifdef EDM_ML_DEBUG
12  edm::LogInfo("MTDGeom") << "Creating ETLNumberingScheme";
13 #endif
14 }
15 
17 #ifdef EDM_ML_DEBUG
18  edm::LogInfo("MTDGeom") << "Deleting ETLNumberingScheme";
19 #endif
20 }
21 
22 uint32_t ETLNumberingScheme::getUnitID(const MTDBaseNumber& baseNumber) const {
23  const uint32_t nLevels(baseNumber.getLevels());
24 
25 #ifdef EDM_ML_DEBUG
26  edm::LogInfo("MTDGeom") << "ETLNumberingScheme geometry levels = " << nLevels;
27 #endif
28 
29  if (11 > nLevels) {
30  edm::LogWarning("MTDGeom") << "ETLNumberingScheme::getUnitID(): "
31  << "Not enough levels found in MTDBaseNumber ( " << nLevels << ") Returning 0";
32  return 0;
33  }
34 
35  const bool prev8(baseNumber.getLevelName(2).find("Sensor") != std::string::npos);
36 
37  const uint32_t modCopy(baseNumber.getCopyNumber(2));
38  uint32_t sensor = 0;
39  if (!prev8) {
40  sensor = baseNumber.getCopyNumber(1);
41  }
42 
43  int modtyp(0);
44 
45  uint32_t discN, sectorS, sectorN;
46  discN = (baseNumber.getLevelName(4).find("Disc1") != std::string::npos) ? 0 : 1;
47  sectorS = (baseNumber.getLevelName(3).find("Front") != std::string::npos) ? 0 : 1;
48  sectorN = baseNumber.getCopyNumber(3);
49 
50  ETLDetId tmpId;
51  int ringCopy = static_cast<int>(tmpId.encodeSector(discN, sectorS, sectorN));
52 
53  modtyp = (baseNumber.getLevelName(2).find("_Left") != std::string::npos) ? 1 : 2;
54 
55  int nSide(7);
56  const std::string_view& sideName(baseNumber.getLevelName(nSide));
57  if (sideName.find("CALOECTSFront") != std::string::npos) {
58  nSide = 8;
59  } else {
60  edm::LogWarning("MTDGeom") << "ETLNumberingScheme::getUnitID(): incorrect volume stack: \n"
61  << baseNumber.getLevelName(0) << ", " << baseNumber.getLevelName(1) << ", "
62  << baseNumber.getLevelName(2) << ", " << baseNumber.getLevelName(3) << ", "
63  << baseNumber.getLevelName(4) << ", " << baseNumber.getLevelName(5) << ", "
64  << baseNumber.getLevelName(6) << ", " << baseNumber.getLevelName(7) << ", "
65  << baseNumber.getLevelName(8) << ", " << baseNumber.getLevelName(9) << ", "
66  << baseNumber.getLevelName(10) << ", " << baseNumber.getLevelName(11) << "\nReturning 0";
67  return 0;
68  }
69  const uint32_t sideCopy(baseNumber.getCopyNumber(nSide));
70  const uint32_t zside(sideCopy == 1 ? 1 : 0);
71 
72 #ifdef EDM_ML_DEBUG
73  edm::LogInfo("MTDGeom") << baseNumber.getLevelName(0) << ", " << baseNumber.getLevelName(1) << ", "
74  << baseNumber.getLevelName(2) << ", " << baseNumber.getLevelName(3) << ", "
75  << baseNumber.getLevelName(4) << ", " << baseNumber.getLevelName(5) << ", "
76  << baseNumber.getLevelName(6) << ", " << baseNumber.getLevelName(7) << ", "
77  << baseNumber.getLevelName(8) << ", " << baseNumber.getLevelName(9) << ", "
78  << baseNumber.getLevelName(10) << ", " << baseNumber.getLevelName(11);
79 #endif
80 
81  // error checking
82 
83  if (modtyp == 0) {
84  edm::LogWarning("MTDGeom") << "ETLNumberingScheme::getUnitID(): "
85  << "****************** Bad module name = " << modtyp
86  << ", Volume Name = " << baseNumber.getLevelName(4);
87  return 0;
88  }
89 
90  if (1 > modCopy || static_cast<unsigned>(std::max(ETLDetId::kETLv4maxModule, ETLDetId::kETLv5maxModule)) < modCopy) {
91  edm::LogWarning("MTDGeom") << "ETLNumberingScheme::getUnitID(): "
92  << "****************** Bad module copy = " << modCopy
93  << ", Volume Number = " << baseNumber.getCopyNumber(4);
94  return 0;
95  }
96 
97  if (1 > ringCopy || ETLDetId::kETLv4maxRing < ringCopy) {
98  edm::LogWarning("MTDGeom") << "ETLNumberingScheme::getUnitID(): "
99  << "****************** Bad ring copy = " << ringCopy
100  << ", Volume Number = " << baseNumber.getCopyNumber(3);
101  return 0;
102  }
103 
104  // all inputs are fine. Go ahead and decode
105 
106  // Different for v8 and pre v8 ETL geometries
107  uint32_t intindex = 0;
108  uint32_t altintindex = 0;
109  if (prev8) {
110  ETLDetId thisETLdetid(zside, ringCopy, modCopy, modtyp);
111  intindex = thisETLdetid.rawId();
112 #ifdef EDM_ML_DEBUG
113  edm::LogInfo("MTDGeom") << "ETL Numbering scheme: "
114  << " ring = " << ringCopy << " zside = " << zside << " module = " << modCopy
115  << " modtyp = " << modtyp << " Raw Id = " << intindex;
116 #endif
117 
118  ETLDetId altETLdetid(zside, discN, sectorS, sectorN, modCopy, modtyp);
119  altintindex = altETLdetid.rawId();
120 
121  } else {
122  ETLDetId thisETLdetid(zside, ringCopy, modCopy, modtyp, sensor);
123  intindex = thisETLdetid.rawId();
124 #ifdef EDM_ML_DEBUG
125  edm::LogInfo("MTDGeom") << "ETL Numbering scheme: "
126  << " ring = " << ringCopy << " zside = " << zside << " module = " << modCopy
127  << " modtyp = " << modtyp << " sensor = " << sensor << " Raw Id = " << intindex;
128 #endif
129 
130  ETLDetId altETLdetid(zside, discN, sectorS, sectorN, modCopy, modtyp, sensor);
131  altintindex = altETLdetid.rawId();
132  }
133 
134  if (intindex != altintindex) {
135  edm::LogWarning("MTDGeom") << "Incorrect alternative construction \n"
136  << "disc = " << discN << " disc side = " << sectorS << " sector = " << sectorN << "\n";
137  }
138 
139  return intindex;
140 }
int getCopyNumber(int level) const
int getLevels() const
static constexpr int kETLv4maxModule
Definition: ETLDetId.h:44
int zside(DetId const &)
uint32_t encodeSector(uint32_t &disc, uint32_t &discside, uint32_t &sector) const
Definition: ETLDetId.h:102
std::string_view const & getLevelName(int level) const
Log< level::Info, false > LogInfo
~ETLNumberingScheme() override
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:16
uint32_t getUnitID(const MTDBaseNumber &baseNumber) const override
Log< level::Warning, false > LogWarning
static constexpr int kETLv5maxModule
Definition: ETLDetId.h:49
static constexpr int kETLv4maxRing
Definition: ETLDetId.h:42