CMS 3D CMS Logo

EcalEndcapNumberingScheme.cc
Go to the documentation of this file.
1 // File: EcalEndcapNumberingScheme.cc
3 // Description: Numbering scheme for endcap electromagnetic calorimeter
7 
8 #include <iostream>
9 #include <iomanip>
10 
12  edm::LogInfo("EcalGeom") << "Creating EcalEndcapNumberingScheme";
13 }
14 
16  edm::LogInfo("EcalGeom") << "Deleting EcalEndcapNumberingScheme";
17 }
18 uint32_t EcalEndcapNumberingScheme::getUnitID(const EcalBaseNumber& baseNumber) const {
19  const uint32_t nLevels(baseNumber.getLevels());
20 
21  //LogDebug("EcalGeom") << "ECalEndcapNumberingScheme geometry levels = " << nLevels;
22 
23  if (7 > nLevels) {
24  edm::LogWarning("EcalGeom") << "ECalEndcapNumberingScheme::getUnitID(): "
25  << "Not enough levels found in EcalBaseNumber ( " << nLevels << ") Returning 0";
26  return 0;
27  }
28 
29  if (nLevels <= 10) {
30  // Static geometry
31 
32  if (baseNumber.getLevels() < 1) {
33  edm::LogWarning("EcalGeom") << "EalEndcaplNumberingScheme::getUnitID: No "
34  << "level found in EcalBaseNumber Returning 0";
35  return 0;
36  }
37 
38  int PVid = baseNumber.getCopyNumber(0);
39  int MVid = 1;
40  if (baseNumber.getLevels() > 1)
41  MVid = baseNumber.getCopyNumber(1);
42  else
43  edm::LogWarning("EcalGeom") << "ECalEndcapNumberingScheme::getUnitID: Null"
44  << " pointer to alveole ! Use default id=1";
45 
46  int zside = baseNumber.getCopyNumber("EREG");
47  zside = 2 * (1 - zside) + 1;
48  int module_number = MVid;
49  int crystal_number = PVid;
50 
51  uint32_t intindex = EEDetId(module_number, crystal_number, zside, EEDetId::SCCRYSTALMODE).rawId();
52 
53  //LogDebug("EcalGeom") << "EcalEndcapNumberingScheme: zside = " << zside
54  // << " super crystal = " << module_number << " crystal = "
55  // << crystal_number << " packed index = 0x" << std::hex
56  // << intindex << std::dec;
57 
58  return intindex;
59  } else {
60  // algorithmic geometry
61 
62  const int ic(baseNumber.getCopyNumber(0) % 100); // crystal #, 0-44
63  const int icx(ic / 10);
64  const int icy(ic % 5);
65  const int is(baseNumber.getCopyNumber(2) % 100); // supercrystal #, 0-99
66  const int isx(is / 10);
67  const int isy(is % 10);
68 
69  const int iq(3 - 2 * baseNumber.getCopyNumber(3)); // quadrant #, -1, +1
70  const int id(3 - 2 * baseNumber.getCopyNumber(5)); // dee #, -1, +1
71 
72  const int iz(3 - 2 * baseNumber.getCopyNumber(7)); // z: -1, +1
73 
74  const int ix(50 + id * iz * (5 * isx + icx + 1) - (id * iz - 1) / 2); // x: 1-100
75  const int iy(50 + id * iq * (5 * isy + icy + 1) - (id * iq - 1) / 2); // y: 1-100
76 
77  const uint32_t idet(DetId(DetId::Ecal, EEDetId::Subdet) | (((0 < iz ? 0x4000 : 0)) + (ix << 7) + iy));
78 
79  //*************************** ERROR CHECKING **********************************
80 
81  if (0 > icx || 4 < icx || 0 > icy || 4 < icy) {
82  edm::LogWarning("EdalGeom") << "ECalEndcapNumberingScheme::getUnitID(): "
83  << "****************** Bad crystal number = " << ic
84  << ", Volume Name = " << baseNumber.getLevelName(0);
85  return 0;
86  }
87 
88  if (0 > isx || 9 < isx || 0 > isy || 9 < isy) {
89  edm::LogWarning("EdalGeom") << "ECalEndcapNumberingScheme::getUnitID(): "
90  << "****************** Bad supercrystal number = " << is
91  << ", Volume Name = " << baseNumber.getLevelName(3);
92  return 0;
93  }
94 
95  if (1 != iq && -1 != iq) {
96  edm::LogWarning("EdalGeom") << "ECalEndcapNumberingScheme::getUnitID(): "
97  << "****************** Bad quadrant number = " << iq
98  << ", Volume Name = " << baseNumber.getLevelName(4);
99  return 0;
100  }
101 
102  if (1 != id && -1 != id) {
103  edm::LogWarning("EdalGeom") << "ECalEndcapNumberingScheme::getUnitID(): "
104  << "****************** Bad dee number = " << id
105  << ", Volume Name = " << baseNumber.getLevelName(6);
106  return 0;
107  }
108 
109  if (-1 != iz && 1 != iz) {
110  edm::LogWarning("EdalGeom") << "ECalEndcapNumberingScheme::getUnitID(): "
111  << "****************** Bad z-end number = " << iz
112  << ", Volume Name = " << baseNumber.getLevelName(8);
113  return 0;
114  }
115 
116  if (!EEDetId::validDetId(ix, iy, iz)) {
117  edm::LogWarning("EdalGeom") << "ECalEndcapNumberingScheme::getUnitID(): "
118  << "****************** Bad DetId numbers = " << ix << ", " << iy << ", " << iz;
119  return 0;
120  }
121 
122  //*************************************************************************************
123  /*
124  edm::LogWarning("EdalGeom") << "ECalEndcapNumberingScheme::getUnitID(): "
125  <<std::dec<< ix << ", " << iy << ", " <<iq << ", " << id << ", " << iz << ", " << std::hex << idet ;
126 
127  edm::LogWarning("EdalGeom") << "ECalEndcapNumberingScheme::EEDetId: "
128  << EEDetId(idet) ;
129 */
130  return idet;
131  }
132 }
EcalBaseNumber::getCopyNumber
int getCopyNumber(int level) const
Definition: EcalBaseNumber.cc:23
EEDetId::SCCRYSTALMODE
static const int SCCRYSTALMODE
Definition: EEDetId.h:336
EcalBaseNumber::getLevelName
std::string const & getLevelName(int level) const
Definition: EcalBaseNumber.cc:34
ecaldqm::zside
int zside(DetId const &)
Definition: EcalDQMCommonUtils.cc:189
EcalEndcapNumberingScheme::getUnitID
uint32_t getUnitID(const EcalBaseNumber &baseNumber) const override
Definition: EcalEndcapNumberingScheme.cc:18
EEDetId.h
edm::LogInfo
Definition: MessageLogger.h:254
EcalBaseNumber
Definition: EcalBaseNumber.h:12
DetId
Definition: DetId.h:17
EcalNumberingScheme
Definition: EcalNumberingScheme.h:14
EcalEndcapNumberingScheme::EcalEndcapNumberingScheme
EcalEndcapNumberingScheme()
Definition: EcalEndcapNumberingScheme.cc:11
EEDetId
Definition: EEDetId.h:14
edm::LogWarning
Definition: MessageLogger.h:141
DetId::Ecal
Definition: DetId.h:27
EcalBaseNumber::getLevels
int getLevels() const
Definition: EcalBaseNumber.cc:21
DetId::rawId
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
EEDetId::validDetId
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
EcalEndcapNumberingScheme::~EcalEndcapNumberingScheme
~EcalEndcapNumberingScheme() override
Definition: EcalEndcapNumberingScheme.cc:15
EcalEndcapNumberingScheme.h
EEDetId::Subdet
Definition: EEDetId.h:19