CMS 3D CMS Logo

EcalBarrelNumberingScheme.cc
Go to the documentation of this file.
1 // File: EcalBarrelNumberingScheme.cc
3 // Description: Numbering scheme for barrel electromagnetic calorimeter
7 
8 //#define EDM_ML_DEBUG
9 
11  edm::LogVerbatim("EcalGeom") << "Creating EcalBarrelNumberingScheme";
12 }
13 
15  edm::LogVerbatim("EcalGeom") << "Deleting EcalBarrelNumberingScheme";
16 }
17 
18 uint32_t EcalBarrelNumberingScheme::getUnitID(const EcalBaseNumber& baseNumber) const {
19  const uint32_t nLevels(baseNumber.getLevels());
20 
21 #ifdef EDM_ML_DEBUG
22  edm::LogVerbatim("EcalGeom") << "ECalBarrelNumberingScheme geometry levels = " << nLevels;
23 #endif
24  if (12 > nLevels) {
25  edm::LogWarning("EcalGeom") << "ECalBarrelNumberingScheme::getUnitID(): "
26  << "Not enough levels found in EcalBaseNumber ( " << nLevels << ") Returning 0";
27  return 0;
28  }
29 
30  const std::string& cryName(baseNumber.getLevelName(0).substr(0, 7)); // name of crystal volume
31 
32  const int cryType(::atoi(cryName.c_str() + 5));
33 
34  const int off(13 < nLevels ? 3 : 0);
35 
36  const uint32_t wallCopy(baseNumber.getCopyNumber(3 + off));
37  const uint32_t hawCopy(baseNumber.getCopyNumber(4 + off));
38  const uint32_t fawCopy(baseNumber.getCopyNumber(5 + off));
39  const uint32_t supmCopy(baseNumber.getCopyNumber(6 + off));
40 #ifdef EDM_ML_DEBUG
41  edm::LogVerbatim("EcalGeom") << nLevels << ", " << off << ", " << cryType << ", " << baseNumber.getLevelName(0) << ":"
42  << baseNumber.getCopyNumber(0) << ", " << baseNumber.getLevelName(1) << ":"
43  << baseNumber.getCopyNumber(1) << ", " << baseNumber.getLevelName(2) << ":"
44  << baseNumber.getCopyNumber(2) << ", " << baseNumber.getLevelName(3) << ":"
45  << baseNumber.getCopyNumber(3) << ", " << baseNumber.getLevelName(4) << ":"
46  << baseNumber.getCopyNumber(4) << ", " << baseNumber.getLevelName(5) << ":"
47  << baseNumber.getCopyNumber(5) << ", " << baseNumber.getLevelName(6) << ":"
48  << baseNumber.getCopyNumber(6) << ", " << baseNumber.getLevelName(7) << ":"
49  << baseNumber.getCopyNumber(7) << ", " << baseNumber.getLevelName(8) << ":"
50  << baseNumber.getCopyNumber(8) << ", " << baseNumber.getLevelName(9) << ":"
51  << baseNumber.getCopyNumber(9) << ", " << baseNumber.getLevelName(10) << ":"
52  << baseNumber.getCopyNumber(10);
53 #endif
54  // error checking
55 
56  if (1 > cryType || 17 < cryType) {
57  edm::LogWarning("EdalGeom") << "ECalBarrelNumberingScheme::getUnitID(): "
58  << "****************** Bad crystal name = " << cryName
59  << ", Volume Name = " << baseNumber.getLevelName(0);
60  return 0;
61  }
62 
63  if (1 > wallCopy || 5 < wallCopy) {
64  edm::LogWarning("EcalGeom") << "ECalBarrelNumberingScheme::getUnitID(): "
65  << "****************** Bad wall copy = " << wallCopy
66  << ", Volume Name = " << baseNumber.getLevelName(3);
67  return 0;
68  }
69 
70  if (1 > hawCopy || 2 < hawCopy) {
71  edm::LogWarning("EcalGeom") << "ECalBarrelNumberingScheme::getUnitID(): "
72  << "****************** Bad haw copy = " << hawCopy
73  << ", Volume Name = " << baseNumber.getLevelName(4);
74  return 0;
75  }
76 
77  if (1 > fawCopy || 10 < fawCopy) {
78  edm::LogWarning("EcalGeom") << "ECalBarrelNumberingScheme::getUnitID(): "
79  << "****************** Bad faw copy = " << fawCopy
80  << ", Volume Name = " << baseNumber.getLevelName(5);
81  return 0;
82  }
83 
84  if (1 > supmCopy || 36 < supmCopy) {
85  edm::LogWarning("EcalGeom") << "ECalBarrelNumberingScheme::getUnitID(): "
86  << "****************** Bad supermodule copy = " << supmCopy
87  << ", Volume Name = " << baseNumber.getLevelName(6);
88  return 0;
89  }
90 
91  // all inputs are fine. Go ahead and decode
92 
93  const int32_t zsign(18 < supmCopy ? -1 : 1);
94 
95  const int32_t eta(5 * (cryType - 1) + wallCopy);
96 
97  const int32_t phi(18 < supmCopy ? 20 * (supmCopy - 19) + 2 * (10 - fawCopy) + 3 - hawCopy
98  : 20 * (supmCopy - 1) + 2 * (fawCopy - 1) + hawCopy);
99 
100  const int32_t intindex(EBDetId(zsign * eta, phi).rawId());
101 
102  /*
103  static int count ( 1 ) ;
104  if( 0==count%1000 )
105  {
106  std::cout<<"************************** NLEVELS="<<nLevels
107  <<", eta="<<eta<<", phi="<<phi<<", zsign="<<zsign<<std::endl;
108  }
109  ++count;
110 */
111 #ifdef EDM_ML_DEBUG
112  edm::LogVerbatim("EcalGeom") << "EcalBarrelNumberingScheme: "
113  << "supmCopy = " << supmCopy << ", fawCopy = " << fawCopy << ", hawCopy = " << hawCopy
114  << ", wallCopy = " << wallCopy << ", cryType = " << cryType
115  << "\n zsign = " << zsign << ", eta = " << eta << ", phi = " << phi
116  << ", packed index = 0x" << std::hex << intindex << std::dec;
117 #endif
118  return intindex;
119 }
EcalBaseNumber::getCopyNumber
int getCopyNumber(int level) const
Definition: EcalBaseNumber.cc:24
EcalBaseNumber::getLevelName
std::string const & getLevelName(int level) const
Definition: EcalBaseNumber.cc:35
EcalBarrelNumberingScheme::~EcalBarrelNumberingScheme
~EcalBarrelNumberingScheme() override
Definition: EcalBarrelNumberingScheme.cc:14
EBDetId
Definition: EBDetId.h:17
EBDetId.h
EcalBaseNumber
Definition: EcalBaseNumber.h:12
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
EcalNumberingScheme
Definition: EcalNumberingScheme.h:14
EcalBarrelNumberingScheme::getUnitID
uint32_t getUnitID(const EcalBaseNumber &baseNumber) const override
Definition: EcalBarrelNumberingScheme.cc:18
PVValHelper::eta
Definition: PVValidationHelpers.h:69
EcalBarrelNumberingScheme::EcalBarrelNumberingScheme
EcalBarrelNumberingScheme()
Definition: EcalBarrelNumberingScheme.cc:10
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
EcalBarrelNumberingScheme.h
EcalBaseNumber::getLevels
int getLevels() const
Definition: EcalBaseNumber.cc:22
DDAxes::phi
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143