CMS 3D CMS Logo

HGCScintillatorDetId.h
Go to the documentation of this file.
1 #ifndef DataFormats_ForwardDetId_HGCScintillatorDetId_H
2 #define DataFormats_ForwardDetId_HGCScintillatorDetId_H 1
3 
4 #include <iosfwd>
5 #include <vector>
9 
10 /* \brief description of the bit assigment
11  [0:8] iphi index wrt x-axis on +z side
12  [9:16] |ring| index (starting from a minimum radius depending on type)
13  [17:21] Layer #
14  [22] Trigger(1)/Detector(0) cell
15  [23] SiPM type (0 for Small: 1 for Large)
16  [24] Granularity of the tile (0 normal; 1 fine)
17  [25:25] z-side (0 for +z; 1 for -z)
18  [26:27] Tile make (1 of type "c"; 2 of type "m")
19  [28:31] Detector type (HGCalHSc)
20 */
21 
22 class HGCScintillatorDetId : public DetId {
23 public:
30  constexpr HGCScintillatorDetId(uint32_t rawid) : DetId(rawid) {}
33  int type, int layer, int ring, int phi, bool trigger = false, int sipm = 0, int granularity = 0)
35  int zside = (ring < 0) ? 1 : 0;
36  int itrig = trigger ? 1 : 0;
37  int ringAbs = std::abs(ring);
43  }
44 
47  if (!gen.null()) {
48  if (gen.det() != HGCalHSc) {
49  throw cms::Exception("Invalid DetId")
50  << "Cannot initialize HGCScintillatorDetId from " << std::hex << gen.rawId() << std::dec;
51  }
52  }
53  id_ = gen.rawId();
54  }
55 
58  if (!gen.null()) {
59  if (gen.det() != HGCalHSc) {
60  throw cms::Exception("Invalid DetId")
61  << "Cannot assign HGCScintillatorDetId from " << std::hex << gen.rawId() << std::dec;
62  }
63  }
64  id_ = gen.rawId();
65  return (*this);
66  }
67 
70  if (trigger()) {
71  return HGCScintillatorDetId(type(), layer(), iradiusTrigger(), iphiTrigger(), false);
72  } else {
73  return HGCScintillatorDetId(type(), layer(), iradius(), iphi(), false);
74  }
75  }
76 
78  constexpr DetId::Detector subdet() const { return det(); }
79 
81  constexpr int type() const { return (id_ >> kHGCalTypeOffset) & kHGCalTypeMask; }
82  constexpr void setType(int type) {
85  }
90  }
91 
93  constexpr int zside() const { return (((id_ >> kHGCalZsideOffset) & kHGCalZsideMask) ? -1 : 1); }
94 
96  constexpr int layer() const { return (id_ >> kHGCalLayerOffset) & kHGCalLayerMask; }
97 
99  constexpr int ring() const {
100  if (trigger())
101  return (2 * ((id_ >> kHGCalRadiusOffset) & kHGCalRadiusMask));
102  else
103  return ((id_ >> kHGCalRadiusOffset) & kHGCalRadiusMask);
104  }
105  constexpr int iradiusAbs() const { return ring(); }
106  constexpr int iradius() const { return zside() * ring(); }
107  constexpr int ietaAbs() const { return ring(); }
108  constexpr int ieta() const { return zside() * ring(); }
109 
111  constexpr int iphi() const {
112  if (trigger())
113  return (2 * ((id_ >> kHGCalPhiOffset) & kHGCalPhiMask));
114  else
115  return ((id_ >> kHGCalPhiOffset) & kHGCalPhiMask);
116  }
117  constexpr std::pair<int, int> ietaphi() const { return std::pair<int, int>(ieta(), iphi()); }
118  constexpr std::pair<int, int> ringphi() const { return std::pair<int, int>(iradius(), iphi()); }
119 
121  constexpr int sipm() const { return (id_ >> kHGCalSiPMOffset) & kHGCalSiPMMask; }
122  constexpr void setSiPM(int sipm) {
123  id_ &= kHGCalSiPMMask0;
125  }
126 
128  std::vector<HGCScintillatorDetId> detectorCells() const;
129 
130  constexpr bool trigger() const { return (((id_ >> kHGCalTriggerOffset) & kHGCalTriggerMask) == 1); }
132  if (trigger())
133  return HGCScintillatorDetId(type(), layer(), iradius(), iphi(), true);
134  else
135  return HGCScintillatorDetId(type(), layer(), iradiusTrigger(), iphiTrigger(), true);
136  }
137 
139  constexpr bool isEE() const { return false; }
140  constexpr bool isHE() const { return true; }
141  constexpr bool isForward() const { return true; }
142 
144 
145 public:
146  static constexpr int kHGCalPhiOffset = 0;
147  static constexpr int kHGCalPhiMask = 0x1FF;
149  static constexpr int kHGCalRadiusMask = 0xFF;
150  static constexpr int kHGCalLayerOffset = 17;
151  static constexpr int kHGCalLayerMask = 0x1F;
153  static constexpr int kHGCalTriggerMask = 0x1;
154  static constexpr int kHGCalSiPMOffset = 23;
155  static constexpr int kHGCalSiPMMask = 0x1;
158  static constexpr int kHGCalGranularityMask0 = 0xFFDFFFFF;
159  static constexpr int kHGCalSiPMMask0 = 0xFF7FFFFF;
160  static constexpr int kHGCalZsideOffset = 25;
161  static constexpr int kHGCalZsideMask = 0x1;
162  static constexpr int kHGCalTypeOffset = 26;
163  static constexpr int kHGCalTypeMask = 0x3;
164  static constexpr int kHGCalTypeMask0 = 0xF3FFFFFF;
165 
167  if (trigger())
168  return ((ring() + 1) / 2);
169  else
170  return ring();
171  }
172  constexpr int iradiusTrigger() const { return zside() * iradiusTriggerAbs(); }
173  constexpr int iphiTrigger() const {
174  if (trigger())
175  return ((iphi() + 1) / 2);
176  else
177  return iphi();
178  }
179 };
180 
181 std::ostream& operator<<(std::ostream&, const HGCScintillatorDetId& id);
182 
183 #endif
constexpr int iradiusTrigger() const
static constexpr int kHGCalGranularityMask0
constexpr int ieta() const
constexpr HGCScintillatorDetId(uint32_t rawid)
constexpr int iphi() const
get the phi index
constexpr DetId::Detector subdet() const
get the subdetector
static constexpr int kHGCalTypeMask
constexpr int iradiusTriggerAbs() const
constexpr int ietaAbs() const
constexpr int iphiTrigger() const
static constexpr int kHGCalPhiMask
static constexpr int kHGCalZsideOffset
constexpr std::pair< int, int > ringphi() const
constexpr bool isEE() const
consistency check : no bits left => no overhead
static constexpr int kHGCalRadiusOffset
constexpr int zside() const
get the z-side of the cell (1/-1)
constexpr int sipm() const
get/set the sipm size
static constexpr int kHGCalLayerOffset
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
static constexpr int kHGCalRadiusMask
constexpr bool isForward() const
constexpr HGCScintillatorDetId(int type, int layer, int ring, int phi, bool trigger=false, int sipm=0, int granularity=0)
constexpr HGCScintillatorDetId geometryCell() const
constexpr std::pair< int, int > ietaphi() const
static constexpr int kHGCalLayerMask
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
constexpr bool trigger() const
static constexpr int kHGCalSiPMMask
static constexpr int kHGCalPhiOffset
constexpr int type() const
get/set the type
static const HGCScintillatorDetId Undefined
static constexpr int kHGCalGranularityMask
Definition: DetId.h:17
std::vector< HGCScintillatorDetId > detectorCells() const
trigger or detector cell
std::ostream & operator<<(std::ostream &, const HGCScintillatorDetId &id)
static constexpr int kHGCalZsideMask
constexpr HGCScintillatorDetId(const DetId &gen)
Detector
Definition: DetId.h:24
uint32_t id_
Definition: DetId.h:69
static constexpr int kHGCalGranularityOffset
static constexpr int kHGCalSiPMOffset
static constexpr int kHGCalTypeMask0
static constexpr int kHGCalTypeOffset
constexpr void setType(int type)
constexpr int layer() const
get the layer #
constexpr int iradius() const
static constexpr int kHGCalTriggerOffset
constexpr void setSiPM(int sipm)
constexpr int ring() const
get the eta index
constexpr void setGranularity(int granularity)
constexpr bool isHE() const
constexpr HGCScintillatorDetId triggerCell() const
constexpr HGCScintillatorDetId & operator=(const DetId &gen)
constexpr int iradiusAbs() const
static constexpr int kHGCalSiPMMask0
constexpr int granularity() const
static constexpr int kHGCalTriggerMask