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  // Discriminate pre-TDR and TDR scenarios
36 
37  const bool preTDR = (baseNumber.getLevelName(3).find("Ring") != std::string::npos);
38 
39  const uint32_t modCopy(baseNumber.getCopyNumber(2));
40 
41  const std::string_view& ringName(baseNumber.getLevelName(3)); // name of ring volume
42  int modtyp(0);
43  std::string_view baseName = ringName.substr(ringName.find(':') + 1);
44  int ringCopy(::atoi(baseName.data() + 4));
45 
46  uint32_t discN, sectorS, sectorN;
47  if (!preTDR) {
48  discN = (baseNumber.getLevelName(4).find("Disc1") != std::string::npos) ? 0 : 1;
49  sectorS = (baseNumber.getLevelName(3).find("Front") != std::string::npos) ? 0 : 1;
50  sectorN = baseNumber.getCopyNumber(3);
51 
52  ETLDetId tmpId;
53  ringCopy = static_cast<int>(tmpId.encodeSector(discN, sectorS, sectorN));
54 
55  modtyp = (baseNumber.getLevelName(2).find("_Left") != std::string::npos) ? 1 : 2;
56  }
57 
58  // Side choice: up to scenario D38 is given by level 7 (HGCal v9)
59  int nSide(7);
60  const std::string_view& sideName(baseNumber.getLevelName(nSide));
61  // Side choice: from scenario D41 is given by level 8 (HGCal v10)
62  if (sideName.find("CALOECTSFront") != std::string::npos) {
63  nSide = 8;
64  }
65  const uint32_t sideCopy(baseNumber.getCopyNumber(nSide));
66  const uint32_t zside(sideCopy == 1 ? 1 : 0);
67 
68 #ifdef EDM_ML_DEBUG
69  edm::LogInfo("MTDGeom") << baseNumber.getLevelName(0) << ", " << baseNumber.getLevelName(1) << ", "
70  << baseNumber.getLevelName(2) << ", " << baseNumber.getLevelName(3) << ", "
71  << baseNumber.getLevelName(4) << ", " << baseNumber.getLevelName(5) << ", "
72  << baseNumber.getLevelName(6) << ", " << baseNumber.getLevelName(7) << ", "
73  << baseNumber.getLevelName(8) << ", " << baseNumber.getLevelName(9) << ", "
74  << baseNumber.getLevelName(10) << ", " << baseNumber.getLevelName(11);
75 #endif
76 
77  // error checking
78 
79  if ((modtyp != 0 && preTDR) || (modtyp == 0 && !preTDR)) {
80  edm::LogWarning("MTDGeom") << "ETLNumberingScheme::getUnitID(): "
81  << "****************** Bad module name = " << modtyp
82  << ", Volume Name = " << baseNumber.getLevelName(4);
83  return 0;
84  }
85 
86  if ((preTDR && (1 > modCopy || ETLDetId::kETLv1maxModule < modCopy)) ||
87  (!preTDR && (1 > modCopy ||
88  static_cast<unsigned>(std::max(ETLDetId::kETLv4maxModule, ETLDetId::kETLv5maxModule)) < modCopy))) {
89  edm::LogWarning("MTDGeom") << "ETLNumberingScheme::getUnitID(): "
90  << "****************** Bad module copy = " << modCopy
91  << ", Volume Number = " << baseNumber.getCopyNumber(4);
92  return 0;
93  }
94 
95  if ((preTDR && (1 > ringCopy || ETLDetId::kETLv1maxRing < ringCopy)) ||
96  (!preTDR && (1 > ringCopy || ETLDetId::kETLv4maxRing < ringCopy))) {
97  edm::LogWarning("MTDGeom") << "ETLNumberingScheme::getUnitID(): "
98  << "****************** Bad ring copy = " << ringCopy
99  << ", Volume Number = " << baseNumber.getCopyNumber(3);
100  return 0;
101  }
102 
103  // all inputs are fine. Go ahead and decode
104 
105  ETLDetId thisETLdetid(zside, ringCopy, modCopy, modtyp);
106  const uint32_t intindex = thisETLdetid.rawId();
107 
108 #ifdef EDM_ML_DEBUG
109  edm::LogInfo("MTDGeom") << "ETL Numbering scheme: "
110  << " ring = " << ringCopy << " zside = " << zside << " module = " << modCopy
111  << " modtyp = " << modtyp << " Raw Id = " << intindex << thisETLdetid;
112 #endif
113  if (!preTDR) {
114  ETLDetId altETLdetid(zside, discN, sectorS, sectorN, modCopy, modtyp);
115  const uint32_t altintindex = altETLdetid.rawId();
116  if (intindex != altintindex) {
117  edm::LogWarning("MTDGeom") << "Incorrect alternative construction \n"
118  << "disc = " << discN << " disc side = " << sectorS << " sector = " << sectorN << "\n"
119  << altETLdetid;
120  }
121  }
122 
123  return intindex;
124 }
int getCopyNumber(int level) const
int getLevels() const
static constexpr int kETLv4maxModule
Definition: ETLDetId.h:41
int zside(DetId const &)
static constexpr int kETLv1maxModule
Definition: ETLDetId.h:29
uint32_t encodeSector(uint32_t &disc, uint32_t &discside, uint32_t &sector) const
Definition: ETLDetId.h:90
std::string_view const & getLevelName(int level) const
static constexpr int kETLv1maxRing
Definition: ETLDetId.h:28
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:15
uint32_t getUnitID(const MTDBaseNumber &baseNumber) const override
Log< level::Warning, false > LogWarning
static constexpr int kETLv5maxModule
Definition: ETLDetId.h:46
static constexpr int kETLv4maxRing
Definition: ETLDetId.h:39