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 #include <iostream>
9 
11  edm::LogInfo("EcalGeom") << "Creating EcalBarrelNumberingScheme";
12 }
13 
15  edm::LogInfo("EcalGeom") << "Deleting EcalBarrelNumberingScheme";
16 }
17 
18 uint32_t EcalBarrelNumberingScheme::getUnitID(const EcalBaseNumber& baseNumber) const {
19  const uint32_t nLevels(baseNumber.getLevels());
20 
21  // LogDebug("EcalGeom") << "ECalBarrelNumberingScheme geometry levels = " << nLevels;
22 
23  if (12 > nLevels) {
24  edm::LogWarning("EcalGeom") << "ECalBarrelNumberingScheme::getUnitID(): "
25  << "Not enough levels found in EcalBaseNumber ( " << nLevels << ") Returning 0";
26  return 0;
27  }
28 
29  const std::string& cryName(baseNumber.getLevelName(0)); // name of crystal volume
30 
31  const int cryType(::atoi(cryName.c_str() + 5));
32 
33  const int off(12 < nLevels ? 3 : 0);
34 
35  const uint32_t wallCopy(baseNumber.getCopyNumber(3 + off));
36  const uint32_t hawCopy(baseNumber.getCopyNumber(4 + off));
37  const uint32_t fawCopy(baseNumber.getCopyNumber(5 + off));
38  const uint32_t supmCopy(baseNumber.getCopyNumber(6 + off));
39 
40  // LogDebug("EcalGeom") << 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 
49  // error checking
50 
51  if (1 > cryType || 17 < cryType) {
52  edm::LogWarning("EdalGeom") << "ECalBarrelNumberingScheme::getUnitID(): "
53  << "****************** Bad crystal name = " << cryName
54  << ", Volume Name = " << baseNumber.getLevelName(0);
55  return 0;
56  }
57 
58  if (1 > wallCopy || 5 < wallCopy) {
59  edm::LogWarning("EcalGeom") << "ECalBarrelNumberingScheme::getUnitID(): "
60  << "****************** Bad wall copy = " << wallCopy
61  << ", Volume Name = " << baseNumber.getLevelName(3);
62  return 0;
63  }
64 
65  if (1 > hawCopy || 2 < hawCopy) {
66  edm::LogWarning("EcalGeom") << "ECalBarrelNumberingScheme::getUnitID(): "
67  << "****************** Bad haw copy = " << hawCopy
68  << ", Volume Name = " << baseNumber.getLevelName(4);
69  return 0;
70  }
71 
72  if (1 > fawCopy || 10 < fawCopy) {
73  edm::LogWarning("EcalGeom") << "ECalBarrelNumberingScheme::getUnitID(): "
74  << "****************** Bad faw copy = " << fawCopy
75  << ", Volume Name = " << baseNumber.getLevelName(5);
76  return 0;
77  }
78 
79  if (1 > supmCopy || 36 < supmCopy) {
80  edm::LogWarning("EcalGeom") << "ECalBarrelNumberingScheme::getUnitID(): "
81  << "****************** Bad supermodule copy = " << supmCopy
82  << ", Volume Name = " << baseNumber.getLevelName(6);
83  return 0;
84  }
85 
86  // all inputs are fine. Go ahead and decode
87 
88  const int32_t zsign(18 < supmCopy ? -1 : 1);
89 
90  const int32_t eta(5 * (cryType - 1) + wallCopy);
91 
92  const int32_t phi(18 < supmCopy ? 20 * (supmCopy - 19) + 2 * (10 - fawCopy) + 3 - hawCopy
93  : 20 * (supmCopy - 1) + 2 * (fawCopy - 1) + hawCopy);
94 
95  const int32_t intindex(EBDetId(zsign * eta, phi).rawId());
96 
97  /*
98  static int count ( 1 ) ;
99  if( 0==count%1000 )
100  {
101  std::cout<<"************************** NLEVELS="<<nLevels
102  <<", eta="<<eta<<", phi="<<phi<<", zsign="<<zsign<<std::endl;
103  }
104  ++count;
105 */
106  // LogDebug("EcalGeom") << "EcalBarrelNumberingScheme: "
107  // << "supmCopy = " << supmCopy
108  // << ", fawCopy = " << fawCopy
109  // << ", hawCopy = " << hawCopy
110  // << ", wallCopy = " << wallCopy
111  // << ", cryType = " << cryType
112  // << "\n zsign = " << zsign
113  // << ", eta = " << eta
114  // << ", phi = " << phi
115  // << ", packed index = 0x" << std::hex << intindex << std::dec ;
116 
117  return intindex;
118 }
std::string const & getLevelName(int level) const
int getCopyNumber(int level) const
uint32_t getUnitID(const EcalBaseNumber &baseNumber) const override
int getLevels() const