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 }
HcalCastorDetId::kNumberSectorsPerEnd
Definition: HcalCastorDetId.h:69
HcalCastorDetId::validDetId
static bool validDetId(Section iSection, bool posEta, int iSector, int iMod)
Definition: HcalCastorDetId.cc:69
HcalCastorDetId::operator=
HcalCastorDetId & operator=(const DetId &id)
Definition: HcalCastorDetId.cc:32
mod
T mod(const T &a, const T &b)
Definition: ecalDccMap.h:4
HcalGenericDetId.h
HcalCastorDetId::SubdetectorId
static const int SubdetectorId
Definition: HcalCastorDetId.h:28
HcalCastorDetId::kNumberModulesPerEnd
Definition: HcalCastorDetId.h:68
HcalCastorDetId::Section
Section
Definition: HcalCastorDetId.h:25
DetId::Calo
Definition: DetId.h:29
HcalCastorDetId::Unknown
Definition: HcalCastorDetId.h:25
DetId
Definition: DetId.h:17
HcalCastorDetId::detIdFromDenseIndex
static HcalCastorDetId detIdFromDenseIndex(uint32_t di)
Definition: HcalCastorDetId.cc:73
operator<<
std::ostream & operator<<(std::ostream &s, const HcalCastorDetId &id)
Definition: HcalCastorDetId.cc:78
alignCSCRings.s
s
Definition: alignCSCRings.py:92
HcalCastorDetId::section
Section section() const
get the section
Definition: HcalCastorDetId.cc:49
gen
Definition: PythiaDecays.h:13
HcalCastorDetId
Definition: HcalCastorDetId.h:23
HcalCastorDetId::module
int module() const
get the module (1-2 for EM, 1-12 for HAD)
Definition: HcalCastorDetId.h:58
DetId::id_
uint32_t id_
Definition: DetId.h:69
dumpRecoGeometry_cfg.Calo
Calo
Definition: dumpRecoGeometry_cfg.py:191
HcalCastorDetId::zside
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalCastorDetId.h:50
HcalCastorDetId::sector
int sector() const
get the sector (1-16)
Definition: HcalCastorDetId.h:62
HcalCastorDetId::buildMe
void buildMe(Section section, bool true_for_positive_eta, int sector, int module)
Definition: HcalCastorDetId.cc:9
Exception
Definition: hltDiff.cc:246
hgcalPlots.section
section
Definition: hgcalPlots.py:2049
HcalCastorDetId::HAD
Definition: HcalCastorDetId.h:25
Exception.h
HcalCastorDetId.h
HcalCastorDetId::denseIndex
uint32_t denseIndex() const
Definition: HcalCastorDetId.cc:65
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
HcalCastorDetId::kNumberCellsPerEnd
Definition: HcalCastorDetId.h:70
HcalCastorDetId::EM
Definition: HcalCastorDetId.h:25
HcalCastorDetId::HcalCastorDetId
HcalCastorDetId()
Definition: HcalCastorDetId.cc:5