CMS 3D CMS Logo

HcalCastorDetId.cc
Go to the documentation of this file.
4 
6 
7 HcalCastorDetId::HcalCastorDetId(uint32_t rawid) : DetId(rawid) {}
8 
9 void HcalCastorDetId::buildMe(Section section, bool true_for_positive_eta, int sector, int module) {
10  sector -= 1; // we count sector from 1-16 instead of 0-15
11  id_ |= (true_for_positive_eta << 8) | (sector << 4) | module;
12 }
13 
14 HcalCastorDetId::HcalCastorDetId(Section section, bool true_for_positive_eta, int sector, int module)
15  : DetId(DetId::Calo, SubdetectorId) {
16  buildMe(section, true_for_positive_eta, sector, module);
17 }
18 
19 HcalCastorDetId::HcalCastorDetId(bool true_for_positive_eta, int sector, int module)
20  : DetId(DetId::Calo, SubdetectorId) {
21  buildMe(Section(Unknown), true_for_positive_eta, sector, module);
22 }
23 
25  if (!gen.null() && (gen.det() != DetId::Calo || gen.subdetId() != SubdetectorId)) {
26  throw cms::Exception("Invalid DetId")
27  << "Cannot initialize CASTORDetId from " << std::hex << gen.rawId() << std::dec;
28  }
29  id_ = gen.rawId();
30 }
31 
33  if (!gen.null() && (gen.det() != DetId::Calo || gen.subdetId() != SubdetectorId)) {
34  throw cms::Exception("Invalid DetId") << "Cannot assign Castor DetId from " << std::hex << gen.rawId() << std::dec;
35  }
36 
37  id_ = gen.rawId();
38 
39  return *this;
40 }
41 
42 /*
43 int HcalCastorDetId::channel() const {
44  int channelid = 16*(sector-1)+module;
45  return channelid;
46 }
47 */
48 
50  const int mod = module();
51 
52  Section sect;
53  if (mod <= 2) {
54  sect = HcalCastorDetId::EM;
55  } else {
56  if (mod > 2 && mod <= 14) {
57  sect = HcalCastorDetId::HAD;
58  } else {
60  }
61  }
62  return sect;
63 }
64 
65 uint32_t HcalCastorDetId::denseIndex() const {
66  return (kNumberCellsPerEnd * (zside() + 1) / 2 + kNumberSectorsPerEnd * (module() - 1) + sector() - 1);
67 }
68 
69 bool HcalCastorDetId::validDetId(Section iSection, bool posEta, int iSector, int iModule) {
70  return (0 < iSector && kNumberSectorsPerEnd >= iSector && 0 < iModule && kNumberModulesPerEnd >= iModule);
71 }
72 
74  return HcalCastorDetId(
76 }
77 
78 std::ostream& operator<<(std::ostream& s, const HcalCastorDetId& id) {
79  s << "(CASTOR" << ((id.zside() == 1) ? ("+") : ("-"));
80 
81  switch (id.section()) {
82  case (HcalCastorDetId::EM):
83  s << " EM ";
84  break;
85  case (HcalCastorDetId::HAD):
86  s << " HAD ";
87  break;
88  default:
89  s << " UNKNOWN ";
90  }
91 
92  return s << id.sector() << ',' << id.module() << ',' << ')';
93 }
static bool validDetId(Section iSection, bool posEta, int iSector, int iMod)
void buildMe(Section section, bool true_for_positive_eta, int sector, int module)
std::ostream & operator<<(std::ostream &s, const HcalCastorDetId &id)
static HcalCastorDetId detIdFromDenseIndex(uint32_t di)
int module() const
get the module (1-2 for EM, 1-12 for HAD)
int zside() const
get the z-side of the cell (1/-1)
int sector() const
get the sector (1-16)
static const int SubdetectorId
HcalCastorDetId & operator=(const DetId &id)
Definition: DetId.h:17
uint32_t id_
Definition: DetId.h:69
Section section() const
get the section
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
uint32_t denseIndex() const