CMS 3D CMS Logo

ETLNumberingScheme.cc
Go to the documentation of this file.
3 
4 #include <iostream>
5 
6 //#define EDM_ML_DEBUG
7 
9 #ifdef EDM_ML_DEBUG
10  edm::LogInfo("MTDGeom") << "Creating ETLNumberingScheme";
11 #endif
12 }
13 
15 #ifdef EDM_ML_DEBUG
16  edm::LogInfo("MTDGeom") << "Deleting ETLNumberingScheme";
17 #endif
18 }
19 
20 uint32_t ETLNumberingScheme::getUnitID(const MTDBaseNumber& baseNumber) const {
21  const uint32_t nLevels(baseNumber.getLevels());
22 
23 #ifdef EDM_ML_DEBUG
24  edm::LogInfo("MTDGeom") << "ETLNumberingScheme geometry levels = " << nLevels;
25 #endif
26 
27  if (11 > nLevels) {
28  edm::LogWarning("MTDGeom") << "ETLNumberingScheme::getUnitID(): "
29  << "Not enough levels found in MTDBaseNumber ( " << nLevels << ") Returning 0";
30  return 0;
31  }
32 
33  // Discriminate pre-TDR and TDR scenarios
34 
35  const bool preTDR = (baseNumber.getLevelName(3).find("Ring") != std::string::npos);
36 
37  const uint32_t modCopy(baseNumber.getCopyNumber(2));
38 
39  const std::string& ringName(baseNumber.getLevelName(3)); // name of ring volume
40  int modtyp(0);
41  std::string baseName = ringName.substr(ringName.find(':') + 1);
42  int ringCopy(::atoi(baseName.c_str() + 4));
43 
44  uint32_t discN, sectorS, sectorN;
45  if (!preTDR) {
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  ringCopy = static_cast<int>(tmpId.encodeSector(discN, sectorS, sectorN));
52 
53  modtyp = (baseNumber.getLevelName(2).find("_Left") != std::string::npos) ? 1 : 2;
54  }
55 
56  // Side choice: up to scenario D38 is given by level 7 (HGCal v9)
57  int nSide(7);
58  const std::string& sideName(baseNumber.getLevelName(nSide));
59  // Side choice: from scenario D41 is given by level 8 (HGCal v10)
60  if (sideName.find("CALOECTSFront") != std::string::npos) {
61  nSide = 8;
62  }
63  const uint32_t sideCopy(baseNumber.getCopyNumber(nSide));
64  const uint32_t zside(sideCopy == 1 ? 1 : 0);
65 
66 #ifdef EDM_ML_DEBUG
67  edm::LogInfo("MTDGeom") << baseNumber.getLevelName(0) << ", " << baseNumber.getLevelName(1) << ", "
68  << baseNumber.getLevelName(2) << ", " << baseNumber.getLevelName(3) << ", "
69  << baseNumber.getLevelName(4) << ", " << baseNumber.getLevelName(5) << ", "
70  << baseNumber.getLevelName(6) << ", " << baseNumber.getLevelName(7) << ", "
71  << baseNumber.getLevelName(8) << ", " << baseNumber.getLevelName(9) << ", "
72  << baseNumber.getLevelName(10) << ", " << baseNumber.getLevelName(11);
73 #endif
74 
75  // error checking
76 
77  if ((modtyp != 0 && preTDR) || (modtyp == 0 && !preTDR)) {
78  edm::LogWarning("MTDGeom") << "ETLNumberingScheme::getUnitID(): "
79  << "****************** Bad module name = " << modtyp
80  << ", Volume Name = " << baseNumber.getLevelName(4);
81  return 0;
82  }
83 
84  if ((preTDR && (1 > modCopy || ETLDetId::kETLv1maxModule < modCopy)) ||
85  (!preTDR && (1 > modCopy ||
86  static_cast<unsigned>(std::max(ETLDetId::kETLv4maxModule, ETLDetId::kETLv5maxModule)) < modCopy))) {
87  edm::LogWarning("MTDGeom") << "ETLNumberingScheme::getUnitID(): "
88  << "****************** Bad module copy = " << modCopy
89  << ", Volume Number = " << baseNumber.getCopyNumber(4);
90  return 0;
91  }
92 
93  if ((preTDR && (1 > ringCopy || ETLDetId::kETLv1maxRing < ringCopy)) ||
94  (!preTDR && (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  if (!preTDR) {
112  ETLDetId altETLdetid(zside, discN, sectorS, sectorN, modCopy, modtyp);
113  const uint32_t altintindex = altETLdetid.rawId();
114  if (intindex != altintindex) {
115  edm::LogWarning("MTDGeom") << "Incorrect alternative construction \n"
116  << "disc = " << discN << " disc side = " << sectorS << " sector = " << sectorN << "\n"
117  << altETLdetid;
118  }
119  }
120 
121  return intindex;
122 }
ETLNumberingScheme::getUnitID
uint32_t getUnitID(const MTDBaseNumber &baseNumber) const override
Definition: ETLNumberingScheme.cc:20
relativeConstraints.ringName
ringName
Definition: relativeConstraints.py:54
MTDNumberingScheme
Definition: MTDNumberingScheme.h:8
ETLDetId::kETLv4maxRing
static constexpr int kETLv4maxRing
Definition: ETLDetId.h:39
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
MTDBaseNumber
Definition: MTDBaseNumber.h:15
ETLDetId::kETLv1maxModule
static constexpr int kETLv1maxModule
Definition: ETLDetId.h:29
ETLDetId::encodeSector
uint32_t encodeSector(uint32_t &disc, uint32_t &discside, uint32_t &sector) const
Definition: ETLDetId.h:88
MTDBaseNumber::getCopyNumber
int getCopyNumber(int level) const
Definition: MTDBaseNumber.cc:32
ETLDetId
Detector identifier class for the Endcap Timing Layer.
Definition: ETLDetId.h:15
edm::LogInfo
Log< level::Info, false > LogInfo
Definition: MessageLogger.h:125
ETLDetId.h
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
MTDBaseNumber::getLevels
int getLevels() const
Definition: MTDBaseNumber.cc:30
MTDBaseNumber::getLevelName
std::string const & getLevelName(int level) const
Definition: MTDBaseNumber.cc:43
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
ETLNumberingScheme::~ETLNumberingScheme
~ETLNumberingScheme() override
Definition: ETLNumberingScheme.cc:14
ETLDetId::kETLv5maxModule
static constexpr int kETLv5maxModule
Definition: ETLDetId.h:46
SiStripPI::max
Definition: SiStripPayloadInspectorHelper.h:169
ETLNumberingScheme::ETLNumberingScheme
ETLNumberingScheme()
Definition: ETLNumberingScheme.cc:8
ETLNumberingScheme.h
ETLDetId::kETLv4maxModule
static constexpr int kETLv4maxModule
Definition: ETLDetId.h:41
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
ETLDetId::kETLv1maxRing
static constexpr int kETLv1maxRing
Definition: ETLDetId.h:28