CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 {
22  id_ |= (section & kZDCSectionMask) << kZDCSectionOffset;
23  id_ |= (channel & kZDCChannelMask);
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 }
static bool validDetId(Section se, int dp)
constexpr bool null() const
is this a null id ?
Definition: DetId.h:59
static bool validDenseIndex(uint32_t di)
Definition: HcalZDCDetId.h:49
int zside() const
get the z-side of the cell (1/-1)
Definition: HcalZDCDetId.h:39
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
static const int kZDCSectionOffset
Definition: HcalZDCDetId.h:20
static const int kZDCZsideMask
Definition: HcalZDCDetId.h:21
static const int kZDCChannelMask
Definition: HcalZDCDetId.h:18
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
static const int kZDCSectionMask
Definition: HcalZDCDetId.h:19
static const int kZDCRPDMask
Definition: HcalZDCDetId.h:22
static HcalZDCDetId detIdFromDenseIndex(uint32_t di)
Definition: HcalZDCDetId.cc:80
Definition: DetId.h:17
static const int SubdetectorId
Definition: HcalZDCDetId.h:25
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
uint32_t id_
Definition: DetId.h:69
int channel() const
get the channel
Definition: HcalZDCDetId.cc:63
string section
Definition: vertexPlots.py:496
Section section() const
get the section
Definition: HcalZDCDetId.cc:44
HcalZDCDetId & operator=(const DetId &id)
Definition: HcalZDCDetId.cc:36
uint32_t denseIndex() const
Definition: HcalZDCDetId.cc:71
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46