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