CMS 3D CMS Logo

HcalZDCDetId.cc
Go to the documentation of this file.
3 
10 
12 
13 HcalZDCDetId::HcalZDCDetId(uint32_t rawid) : DetId(rawid) {}
14 
15 HcalZDCDetId::HcalZDCDetId(Section section, bool true_for_positive_eta, int channel)
16  : DetId(DetId::Calo, SubdetectorId) {
17  if (section == RPD) {
19  id_ |= kZDCRPDMask;
20  id_ |= ((channel - 1) & kZDCChannelMask);
21  } else {
24  }
25  if (true_for_positive_eta)
26  id_ |= kZDCZsideMask;
27 }
28 
30  if (!gen.null() && (gen.det() != Calo || gen.subdetId() != SubdetectorId)) {
31  throw cms::Exception("Invalid DetId") << "Cannot initialize ZDCDetId from " << std::hex << gen.rawId() << std::dec;
32  }
33  id_ = gen.rawId();
34 }
35 
37  if (!gen.null() && (gen.det() != Calo || gen.subdetId() != SubdetectorId)) {
38  throw cms::Exception("Invalid DetId") << "Cannot assign ZDCDetId from " << std::hex << gen.rawId() << std::dec;
39  }
40  id_ = gen.rawId();
41  return *this;
42 }
43 
45  if (id_ & kZDCRPDMask)
46  return RPD;
47  else
49 }
50 
51 int HcalZDCDetId::depth() const {
52  const int se(section());
53  if (se == EM)
54  return 1;
55  else if (se == HAD)
56  return (channel() + 2);
57  else if (se == RPD)
58  return 2;
59  else
60  return channel();
61 }
62 
63 int HcalZDCDetId::channel() const {
64  const int se(section());
65  if (se == RPD)
66  return (1 + (id_ & kZDCChannelMask));
67  else
68  return (id_ & kZDCChannelMask);
69 }
70 
71 uint32_t HcalZDCDetId::denseIndex() const {
72  const int se(section());
73  uint32_t di =
74  (channel() - 1 +
75  (se == RPD ? 2 * kDepRun1 + (zside() < 0 ? 0 : kDepRPD)
76  : ((zside() < 0 ? 0 : kDepRun1) + (se == HAD ? kDepEM : (se == LUM ? kDepEM + kDepHAD : 0)))));
77  return di;
78 }
79 
81  if (validDenseIndex(di)) {
82  bool lz(false);
83  uint32_t dp(0);
84  Section se(Unknown);
85  if (di >= 2 * kDepRun1) {
86  lz = (di >= (kDepRun1 + kDepTot));
87  se = RPD;
88  dp = 1 + ((di - 2 * kDepRun1) % kDepRPD);
89  } else {
90  lz = (di >= kDepRun1);
91  uint32_t in = (di % kDepRun1);
92  se = (in < kDepEM ? EM : (in < kDepEM + kDepHAD ? HAD : LUM));
93  dp = (EM == se ? in + 1 : (HAD == se ? in - kDepEM + 1 : in - kDepEM - kDepHAD + 1));
94  }
95  return HcalZDCDetId(se, lz, dp);
96  } else {
97  return HcalZDCDetId();
98  }
99 }
100 
102  bool flag = (dp >= 1 && (((se == EM) && (dp <= kDepEM)) || ((se == HAD) && (dp <= kDepHAD)) ||
103  ((se == LUM) && (dp <= kDepLUM)) || ((se == RPD) && (dp <= kDepRPD))));
104  return flag;
105 }
106 
107 std::ostream& operator<<(std::ostream& s, const HcalZDCDetId& id) {
108  s << "(ZDC" << ((id.zside() == 1) ? ("+") : ("-"));
109  switch (id.section()) {
110  case (HcalZDCDetId::EM):
111  s << " EM ";
112  break;
113  case (HcalZDCDetId::HAD):
114  s << " HAD ";
115  break;
116  case (HcalZDCDetId::LUM):
117  s << " LUM ";
118  break;
119  case (HcalZDCDetId::RPD):
120  s << " RPD ";
121  break;
122  default:
123  s << " UNKNOWN ";
124  }
125  return s << id.channel() << "," << id.depth() << ')';
126 }
HcalZDCDetId::kZDCSectionMask
static const int kZDCSectionMask
Definition: HcalZDCDetId.h:19
HcalZDCDetId::detIdFromDenseIndex
static HcalZDCDetId detIdFromDenseIndex(uint32_t di)
Definition: HcalZDCDetId.cc:80
HcalZDCDetId::HAD
Definition: HcalZDCDetId.h:23
HcalZDCDetId::kDepRun1
Definition: HcalZDCDetId.h:61
HcalZDCDetId::Section
Section
Definition: HcalZDCDetId.h:23
HcalZDCDetId::depth
int depth() const
get the depth (1 for EM, channel + 1 for HAD, 2 for RPD, not sure yet for LUM, leave as default)
Definition: HcalZDCDetId.cc:51
HcalZDCDetId::kZDCSectionOffset
static const int kZDCSectionOffset
Definition: HcalZDCDetId.h:20
HcalZDCDetId::channel
int channel() const
get the channel
Definition: HcalZDCDetId.cc:63
HcalZDCDetId::HcalZDCDetId
HcalZDCDetId()
Definition: HcalZDCDetId.cc:11
HcalZDCDetId::kZDCZsideMask
static const int kZDCZsideMask
Definition: HcalZDCDetId.h:21
HcalZDCDetId.h
DetId::Calo
Definition: DetId.h:29
HcalZDCDetId::validDetId
static bool validDetId(Section se, int dp)
Definition: HcalZDCDetId.cc:101
DetId
Definition: DetId.h:17
HcalZDCDetId
Definition: HcalZDCDetId.h:16
alignCSCRings.s
s
Definition: alignCSCRings.py:92
HcalZDCDetId::kZDCRPDMask
static const int kZDCRPDMask
Definition: HcalZDCDetId.h:22
Calorimetry_cff.dp
dp
Definition: Calorimetry_cff.py:158
HcalZDCDetId::SubdetectorId
static const int SubdetectorId
Definition: HcalZDCDetId.h:25
HcalZDCDetId::operator=
HcalZDCDetId & operator=(const DetId &id)
Definition: HcalZDCDetId.cc:36
gen
Definition: PythiaDecays.h:13
HcalZDCDetId::zside
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:39
HcalZDCDetId::kDepLUM
Definition: HcalZDCDetId.h:59
HcalZDCDetId::kDepEM
Definition: HcalZDCDetId.h:57
HcalZDCDetId::RPD
Definition: HcalZDCDetId.h:23
DetId::id_
uint32_t id_
Definition: DetId.h:69
dumpRecoGeometry_cfg.Calo
Calo
Definition: dumpRecoGeometry_cfg.py:191
recoMuon::in
Definition: RecoMuonEnumerators.h:6
HcalZDCDetId::Unknown
Definition: HcalZDCDetId.h:23
HcalZDCDetId::validDenseIndex
static bool validDenseIndex(uint32_t di)
Definition: HcalZDCDetId.h:49
HcalZDCDetId::kZDCChannelMask
static const int kZDCChannelMask
Definition: HcalZDCDetId.h:18
HcalZDCDetId::kDepRPD
Definition: HcalZDCDetId.h:60
HcalZDCDetId::kDepTot
Definition: HcalZDCDetId.h:62
Exception
Definition: hltDiff.cc:245
hgcalPlots.section
section
Definition: hgcalPlots.py:2679
HcalZDCDetId::kDepHAD
Definition: HcalZDCDetId.h:58
Exception.h
HcalZDCDetId::LUM
Definition: HcalZDCDetId.h:23
HcalZDCDetId::denseIndex
uint32_t denseIndex() const
Definition: HcalZDCDetId.cc:71
operator<<
std::ostream & operator<<(std::ostream &s, const HcalZDCDetId &id)
Definition: HcalZDCDetId.cc:107
HcalZDCDetId::section
Section section() const
get the section
Definition: HcalZDCDetId.cc:44
HcalZDCDetId::EM
Definition: HcalZDCDetId.h:23
TauDecayModes.dec
dec
Definition: TauDecayModes.py:142
RemoveAddSevLevel.flag
flag
Definition: RemoveAddSevLevel.py:117