CMS 3D CMS Logo

BTLNumberingScheme.cc
Go to the documentation of this file.
3 
4 #include <iostream>
5 #include <cstring>
6 
7 //#define EDM_ML_DEBUG
8 
11 #ifdef EDM_ML_DEBUG
12  edm::LogInfo("MTDGeom") << "Creating BTLNumberingScheme";
13 #endif
14 }
15 
17 #ifdef EDM_ML_DEBUG
18  edm::LogInfo("MTDGeom") << "Deleting BTLNumberingScheme";
19 #endif
20 }
21 
22 uint32_t BTLNumberingScheme::getUnitID(const MTDBaseNumber& baseNumber) const {
23 
24  const uint32_t nLevels ( baseNumber.getLevels() ) ;
25 
26 #ifdef EDM_ML_DEBUG
27  edm::LogInfo("MTDGeom") << "BTLNumberingScheme geometry levels = " << nLevels;
28 #endif
29 
30  if( 9 > nLevels )
31  {
32  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
33  << "Not enough levels found in MTDBaseNumber ( "
34  << nLevels
35  << ") Returning 0" ;
36  return 0;
37  }
38 
39 #ifdef EDM_ML_DEBUG
40  edm::LogInfo("MTDGeom") << baseNumber.getLevelName(0) << ", "
41  << baseNumber.getLevelName(1) << ", "
42  << baseNumber.getLevelName(2) << ", "
43  << baseNumber.getLevelName(3) << ", "
44  << baseNumber.getLevelName(4) << ", "
45  << baseNumber.getLevelName(5) << ", "
46  << baseNumber.getLevelName(6) << ", "
47  << baseNumber.getLevelName(7) << ", "
48  << baseNumber.getLevelName(8);
49 #endif
50 
51  const uint32_t crystal ( baseNumber.getCopyNumber( 0 ) ) ;
52 
53  const uint32_t modCopy ( baseNumber.getCopyNumber( 2 ) ) ;
54  const uint32_t rodCopy ( baseNumber.getCopyNumber( 3 ) ) ;
55 
56  const std::string& modName ( baseNumber.getLevelName( 2 ) ) ; // name of module volume
57  uint32_t pos = modName.find("Positive");
58 
59  const uint32_t zside = ( pos <= strlen(modName.c_str()) ? 1 : 0 );
60  std::string baseName = modName.substr(modName.find(":")+1);
61 
62  // trick to accomodate both 54, 42 and 48 modules designs
63  const int modtyp ( ::atoi( (baseName.substr(8,1)).c_str() ) == 9 ||
64  ::atoi( (baseName.substr(8,1)).c_str() ) == 5 ||
65  (::atoi( (baseName.substr(8,1)).c_str() ) == 7 && ::atoi( (baseName.substr(7,1)).c_str() ) == 1 ) ?
66  ::atoi( (baseName.substr(7,1)).c_str() ) + 1 : ::atoi( (baseName.substr(7,1)).c_str() ) ) ;
67 
68  // error checking
69 
70  if( 1 > crystal ||
71  64 < crystal )
72  {
73  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
74  << "****************** Bad crystal number = "
75  << crystal
76  << ", Volume Number = "
77  << baseNumber.getCopyNumber(0);
78  return 0 ;
79  }
80 
81  if( 1 > modtyp ||
82  3 < modtyp )
83  {
84  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
85  << "****************** Bad module name = "
86  << modName
87  << ", Volume Name = "
88  << baseNumber.getLevelName(2) ;
89  return 0 ;
90  }
91 
92  if( 1 > modCopy ||
93  54 < modCopy )
94  {
95  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
96  << "****************** Bad module copy = "
97  << modCopy
98  << ", Volume Number = "
99  << baseNumber.getCopyNumber(2) ;
100  return 0 ;
101  }
102 
103  if( 1 > rodCopy ||
104  36 < rodCopy )
105  {
106  edm::LogWarning("MTDGeom") << "BTLNumberingScheme::getUnitID(): "
107  << "****************** Bad rod copy = "
108  << rodCopy
109  << ", Volume Number = "
110  << baseNumber.getCopyNumber(4) ;
111  return 0 ;
112  }
113 
114  // all inputs are fine. Go ahead and decode
115 
116  BTLDetId thisBTLdetid( zside, rodCopy, modCopy, modtyp, crystal );
117  const int32_t intindex = thisBTLdetid.rawId() ;
118 
119 #ifdef EDM_ML_DEBUG
120  edm::LogInfo("MTDGeom") << "BTL Numbering scheme: "
121  << " rod = " << rodCopy
122  << " zside = " << zside
123  << " module = " << modCopy
124  << " modtyp = " << modtyp
125  << " crystal = " << crystal
126  << " Raw Id = " << intindex
127  << thisBTLdetid;
128 #endif
129 
130  return intindex ;
131 }
~BTLNumberingScheme() override
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
int zside(DetId const &)
int getLevels() const
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 const & getLevelName(int level) const