CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
BTLNumberingScheme.cc
Go to the documentation of this file.
3 
4 #include <iostream>
5 #include <cstring>
6 
7 //#define EDM_ML_DEBUG
8 
10 #ifdef EDM_ML_DEBUG
11  edm::LogInfo("MTDGeom") << "Creating BTLNumberingScheme";
12 #endif
13 }
14 
16 #ifdef EDM_ML_DEBUG
17  edm::LogInfo("MTDGeom") << "Deleting BTLNumberingScheme";
18 #endif
19 }
20 
21 uint32_t BTLNumberingScheme::getUnitID(const MTDBaseNumber& baseNumber) const {
22  const uint32_t nLevels(baseNumber.getLevels());
23 
24 #ifdef EDM_ML_DEBUG
25  edm::LogInfo("MTDGeom") << "BTLNumberingScheme geometry levels = " << nLevels;
26 #endif
27 
28  if (9 > nLevels) {
29  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
30  << "Not enough levels found in MTDBaseNumber ( " << nLevels << ") Returning 0";
31  return 0;
32  }
33 
34 #ifdef EDM_ML_DEBUG
35  edm::LogInfo("MTDGeom") << baseNumber.getLevelName(0) << ", " << baseNumber.getLevelName(1) << ", "
36  << baseNumber.getLevelName(2) << ", " << baseNumber.getLevelName(3) << ", "
37  << baseNumber.getLevelName(4) << ", " << baseNumber.getLevelName(5) << ", "
38  << baseNumber.getLevelName(6) << ", " << baseNumber.getLevelName(7) << ", "
39  << baseNumber.getLevelName(8);
40 #endif
41 
42  const uint32_t crystal(baseNumber.getCopyNumber(0));
43 
44  const uint32_t modCopy(baseNumber.getCopyNumber(2));
45  const uint32_t rodCopy(baseNumber.getCopyNumber(3));
46 
47  const std::string_view& modName(baseNumber.getLevelName(2)); // name of module volume
48  uint32_t pos = modName.find("Positive");
49 
50  const uint32_t zside = (pos <= modName.size() ? 1 : 0);
51  std::string_view baseName = modName.substr(modName.find(':') + 1);
52 
53  int tmptyp = ::atoi(&baseName.at(7));
54  if (tmptyp == 17) {
55  tmptyp = 2;
56  } else if (tmptyp == 33) {
57  tmptyp = 3;
58  }
59  const int modtyp(tmptyp);
60 
61  // error checking
62 
63  if (1 > crystal || 64 < crystal) {
64  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
65  << "****************** Bad crystal number = " << crystal
66  << ", Volume Number = " << baseNumber.getCopyNumber(0);
67  return 0;
68  }
69 
70  if (1 > modtyp || 3 < modtyp) {
71  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
72  << "****************** Bad module name = " << modName
73  << ", Volume Name = " << baseNumber.getLevelName(2);
74  return 0;
75  }
76 
77  if (1 > modCopy || 54 < modCopy) {
78  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
79  << "****************** Bad module copy = " << modCopy
80  << ", Volume Number = " << baseNumber.getCopyNumber(2);
81  return 0;
82  }
83 
84  if (1 > rodCopy || 36 < rodCopy) {
85  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
86  << "****************** Bad rod copy = " << rodCopy
87  << ", Volume Number = " << baseNumber.getCopyNumber(4);
88  return 0;
89  }
90 
91  // all inputs are fine. Go ahead and decode
92 
93  BTLDetId thisBTLdetid(zside, rodCopy, modCopy, modtyp, crystal);
94  const uint32_t intindex = thisBTLdetid.rawId();
95 
96 #ifdef EDM_ML_DEBUG
97  edm::LogInfo("MTDGeom") << "BTL Numbering scheme: "
98  << " rod = " << rodCopy << " zside = " << zside << " module = " << modCopy
99  << " modtyp = " << modtyp << " crystal = " << crystal << " Raw Id = " << intindex << "\n"
100  << thisBTLdetid;
101 #endif
102 
103  return intindex;
104 }
~BTLNumberingScheme() override
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
int zside(DetId const &)
int getLevels() const
Log< level::Info, false > LogInfo
uint32_t getUnitID(const MTDBaseNumber &baseNumber) const override
int getCopyNumber(int level) const
Detector identifier class for the Barrel Timing Layer. The crystal count must start from 0...
Definition: BTLDetId.h:18
std::string_view const & getLevelName(int level) const
Log< level::Warning, false > LogWarning