CMS 3D CMS Logo

HGCSiliconDetId.h
Go to the documentation of this file.
1 #ifndef DataFormats_ForwardDetId_HGCSiliconDetId_H
2 #define DataFormats_ForwardDetId_HGCSiliconDetId_H 1
3 
4 #include <iosfwd>
8 
9 /* \brief description of the bit assigment
10  [0:4] u-coordinate of the cell (measured from the lower left
11  [5:9] v-coordinate of the cell corner of the wafer)
12  [10:13] abs(u) of the wafer (u-axis points along -x axis)
13  [14:14] sign of u (0:+u; 1:-u) (u=0 is at the center of beam line)
14  [15:18] abs(v) of the wafer (v-axis points 60-degree wrt x-axis)
15  [19:19] sign of v (0:+v; 1:-v) (v=0 is at the center of beam line)
16  [20:24] layer number
17  [25:25] z-side (0 for +z; 1 for -z)
18  [26:27] Type (0 fine divisions of wafer with 120 mum thick silicon
19  1 coarse divisions of wafer with 200 mum thick silicon
20  2 coarse divisions of wafer with 300 mum thick silicon
21  3 fine divisions of wafer with 200 mum thick silicon)
22  [28:31] Detector type (HGCalEE or HGCalHSi)
23 */
24 class HGCSiliconDetId : public DetId {
25 public:
27  static constexpr int32_t HGCalHighDensityN = 12;
28  static constexpr int32_t HGCalLowDensityN = 8;
29  static constexpr int32_t HGCalFineTrigger = 3;
30  static constexpr int32_t HGCalCoarseTrigger = 2;
31  static constexpr int32_t HGCal0Depletion = 120;
32  static constexpr int32_t HGCal1Depletion = 200;
33  static constexpr int32_t HGCal2Depletion = 300;
34 
36  constexpr HGCSiliconDetId() : DetId() {}
38  constexpr HGCSiliconDetId(uint32_t rawid) : DetId(rawid) {}
41  int32_t zp,
42  int32_t type,
43  int32_t layer,
44  int32_t waferU,
45  int32_t waferV,
46  int32_t cellU,
47  int32_t cellV)
48  : DetId(det, ForwardEmpty) {
49  int32_t waferUabs(std::abs(waferU)), waferVabs(std::abs(waferV));
50  int32_t waferUsign = (waferU >= 0) ? 0 : 1;
51  int32_t waferVsign = (waferV >= 0) ? 0 : 1;
52  int32_t zside = (zp < 0) ? 1 : 0;
54  ((waferUabs & kHGCalWaferUMask) << kHGCalWaferUOffset) |
55  ((waferUsign & kHGCalWaferUSignMask) << kHGCalWaferUSignOffset) |
56  ((waferVabs & kHGCalWaferVMask) << kHGCalWaferVOffset) |
57  ((waferVsign & kHGCalWaferVSignMask) << kHGCalWaferVSignOffset) |
60  }
61 
63  constexpr HGCSiliconDetId(const DetId& gen) {
64  if (!gen.null()) {
65  if ((gen.det() != HGCalEE) && (gen.det() != HGCalHSi)) {
66  throw cms::Exception("Invalid DetId")
67  << "Cannot initialize HGCSiliconDetId from " << std::hex << gen.rawId() << std::dec;
68  }
69  }
70  id_ = gen.rawId();
71  }
72 
74  constexpr HGCSiliconDetId& operator=(const DetId& gen) {
75  if (!gen.null()) {
76  if ((gen.det() != HGCalEE) && (gen.det() != HGCalHSi)) {
77  throw cms::Exception("Invalid DetId")
78  << "Cannot assign HGCSiliconDetId from " << std::hex << gen.rawId() << std::dec;
79  }
80  }
81  id_ = gen.rawId();
82  return (*this);
83  }
84 
86  constexpr HGCSiliconDetId geometryCell() const {
87  return HGCSiliconDetId(det(), zside(), 0, layer(), waferU(), waferV(), 0, 0);
88  }
89  constexpr HGCSiliconDetId moduleId() const {
90  return HGCSiliconDetId(det(), zside(), type(), layer(), waferU(), waferV(), 0, 0);
91  }
92 
94  constexpr DetId::Detector subdet() const { return det(); }
95 
97  constexpr int32_t type() const { return (id_ >> kHGCalTypeOffset) & kHGCalTypeMask; }
98  constexpr bool lowDensity() const { return ((type() == HGCalCoarseThin) || (type() == HGCalCoarseThick)); }
99  constexpr bool highDensity() const { return ((type() == HGCalFine) || (type() == HGCalFineThick)); }
100  constexpr int32_t depletion() const {
101  return ((type() == HGCalFine) ? HGCal0Depletion
103  }
104 
106  constexpr int32_t zside() const { return (((id_ >> kHGCalZsideOffset) & kHGCalZsideMask) ? -1 : 1); }
107 
109  constexpr int32_t layer() const { return (id_ >> kHGCalLayerOffset) & kHGCalLayerMask; }
110 
112  constexpr int32_t cellU() const { return (id_ >> kHGCalCellUOffset) & kHGCalCellUMask; }
113  constexpr int32_t cellV() const { return (id_ >> kHGCalCellVOffset) & kHGCalCellVMask; }
114  constexpr std::pair<int32_t, int32_t> cellUV() const { return std::pair<int32_t, int32_t>(cellU(), cellV()); }
115  constexpr int32_t cellX() const {
116  int32_t N = ((type() == HGCalFine) || (type() == HGCalFineThick)) ? HGCalHighDensityN : HGCalLowDensityN;
117  return (3 * (cellV() - N) + 2);
118  }
119  constexpr int32_t cellY() const {
120  int32_t N = ((type() == HGCalFine) || (type() == HGCalFineThick)) ? HGCalHighDensityN : HGCalLowDensityN;
121  return (2 * cellU() - (N + cellV()));
122  }
123  constexpr std::pair<int32_t, int32_t> cellXY() const { return std::pair<int32_t, int32_t>(cellX(), cellY()); }
124 
126  constexpr int32_t waferUAbs() const { return (id_ >> kHGCalWaferUOffset) & kHGCalWaferUMask; }
127  constexpr int32_t waferVAbs() const { return (id_ >> kHGCalWaferVOffset) & kHGCalWaferVMask; }
128  constexpr int32_t waferU() const {
130  }
131  constexpr int32_t waferV() const {
133  }
134  constexpr std::pair<int32_t, int32_t> waferUV() const { return std::pair<int32_t, int32_t>(waferU(), waferV()); }
135  constexpr int32_t waferX() const { return (-2 * waferU() + waferV()); }
136  constexpr int32_t waferY() const { return (2 * waferV()); }
137  constexpr std::pair<int32_t, int32_t> waferXY() const { return std::pair<int32_t, int32_t>(waferX(), waferY()); }
138  constexpr void unpack(
139  int32_t& ty, int32_t& zs, int32_t& ly, int32_t& wU, int32_t& wV, int32_t& cU, int32_t& cV) const {
140  ty = type();
141  zs = zside();
142  ly = layer();
143  wU = waferU();
144  wV = waferV();
145  cU = cellU();
146  cV = cellV();
147  }
148 
149  // get trigger cell u,v
150  constexpr int32_t triggerCellU() const {
151  int32_t N = ((type() == HGCalFine) || (type() == HGCalFineThick)) ? HGCalHighDensityN : HGCalLowDensityN;
152  int32_t NT = ((type() == HGCalFine) || (type() == HGCalFineThick)) ? HGCalFineTrigger : HGCalCoarseTrigger;
153  return (cellU() >= N && cellV() >= N)
154  ? cellU() / NT
155  : ((cellU() < N && cellU() <= cellV()) ? cellU() / NT : (1 + (cellU() - (cellV() % NT + 1)) / NT));
156  }
157  constexpr int32_t triggerCellV() const {
158  int32_t N = ((type() == HGCalFine) || (type() == HGCalFineThick)) ? HGCalHighDensityN : HGCalLowDensityN;
159  int32_t NT = ((type() == HGCalFine) || (type() == HGCalFineThick)) ? HGCalFineTrigger : HGCalCoarseTrigger;
160  return (cellU() >= N && cellV() >= N)
161  ? cellV() / NT
162  : ((cellU() < N && cellU() <= cellV()) ? ((cellV() - cellU()) / NT + cellU() / NT) : cellV() / NT);
163  }
164  constexpr std::pair<int32_t, int32_t> triggerCellUV() const {
165  return std::pair<int32_t, int32_t>(triggerCellU(), triggerCellV());
166  }
167 
169  constexpr bool isEE() const { return (det() == HGCalEE); }
170  constexpr bool isHE() const { return (det() == HGCalHSi); }
171  constexpr bool isForward() const { return true; }
172 
174 
175 public:
176  static constexpr uint32_t kHGCalCellUOffset = 0;
177  static constexpr uint32_t kHGCalCellUMask = 0x1F;
178  static constexpr uint32_t kHGCalCellVOffset = 5;
179  static constexpr uint32_t kHGCalCellVMask = 0x1F;
180  static constexpr uint32_t kHGCalWaferUOffset = 10;
181  static constexpr uint32_t kHGCalWaferUMask = 0xF;
182  static constexpr uint32_t kHGCalWaferUSignOffset = 14;
183  static constexpr uint32_t kHGCalWaferUSignMask = 0x1;
184  static constexpr uint32_t kHGCalWaferVOffset = 15;
185  static constexpr uint32_t kHGCalWaferVMask = 0xF;
186  static constexpr uint32_t kHGCalWaferVSignOffset = 19;
187  static constexpr uint32_t kHGCalWaferVSignMask = 0x1;
188  static constexpr uint32_t kHGCalLayerOffset = 20;
189  static constexpr uint32_t kHGCalLayerMask = 0x1F;
190  static constexpr uint32_t kHGCalZsideOffset = 25;
191  static constexpr uint32_t kHGCalZsideMask = 0x1;
192  static constexpr uint32_t kHGCalTypeOffset = 26;
193  static constexpr uint32_t kHGCalTypeMask = 0x3;
194 };
195 
196 std::ostream& operator<<(std::ostream&, const HGCSiliconDetId& id);
197 
198 #endif
static constexpr uint32_t kHGCalCellUOffset
static constexpr int32_t HGCal0Depletion
constexpr int32_t waferUAbs() const
get the wafer #&#39;s in u,v or in x,y
constexpr int32_t depletion() const
static constexpr uint32_t kHGCalCellVMask
static constexpr uint32_t kHGCalTypeOffset
constexpr HGCSiliconDetId(uint32_t rawid)
constexpr HGCSiliconDetId & operator=(const DetId &gen)
constexpr bool isHE() const
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
static constexpr int32_t HGCalLowDensityN
constexpr DetId::Detector subdet() const
get the subdetector
constexpr int32_t cellY() const
constexpr int32_t waferV() const
static constexpr uint32_t kHGCalWaferUMask
constexpr std::pair< int32_t, int32_t > cellUV() const
static constexpr int32_t HGCalCoarseTrigger
constexpr void unpack(int32_t &ty, int32_t &zs, int32_t &ly, int32_t &wU, int32_t &wV, int32_t &cU, int32_t &cV) const
static const HGCSiliconDetId Undefined
static constexpr uint32_t kHGCalWaferVOffset
constexpr int32_t zside() const
get the z-side of the cell (1/-1)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
constexpr HGCSiliconDetId(DetId::Detector det, int32_t zp, int32_t type, int32_t layer, int32_t waferU, int32_t waferV, int32_t cellU, int32_t cellV)
std::ostream & operator<<(std::ostream &, const HGCSiliconDetId &id)
static constexpr int32_t HGCalHighDensityN
static constexpr uint32_t kHGCalWaferUOffset
static constexpr int32_t HGCalFineTrigger
constexpr int32_t cellU() const
get the cell #&#39;s in u,v or in x,y
constexpr int32_t waferY() const
constexpr bool highDensity() const
static constexpr uint32_t kHGCalWaferVSignMask
constexpr HGCSiliconDetId geometryCell() const
static constexpr uint32_t kHGCalTypeMask
static constexpr uint32_t kHGCalLayerOffset
constexpr std::pair< int32_t, int32_t > triggerCellUV() const
constexpr int32_t waferX() const
Definition: DetId.h:17
static constexpr uint32_t kHGCalCellUMask
static constexpr int32_t HGCal2Depletion
#define N
Definition: blowfish.cc:9
static constexpr uint32_t kHGCalZsideOffset
constexpr HGCSiliconDetId moduleId() const
constexpr bool isForward() const
Detector
Definition: DetId.h:24
uint32_t id_
Definition: DetId.h:69
constexpr int32_t cellX() const
constexpr int32_t waferVAbs() const
constexpr int32_t triggerCellV() const
constexpr bool lowDensity() const
constexpr int32_t layer() const
get the layer #
constexpr int32_t cellV() const
static constexpr uint32_t kHGCalLayerMask
constexpr HGCSiliconDetId()
constexpr int32_t triggerCellU() const
static constexpr uint32_t kHGCalWaferUSignMask
constexpr std::pair< int32_t, int32_t > cellXY() const
static constexpr uint32_t kHGCalWaferVMask
static constexpr uint32_t kHGCalWaferUSignOffset
static constexpr uint32_t kHGCalWaferVSignOffset
static constexpr int32_t HGCal1Depletion
constexpr int32_t waferU() const
constexpr int32_t type() const
get the type
static constexpr uint32_t kHGCalZsideMask
constexpr std::pair< int32_t, int32_t > waferXY() const
constexpr std::pair< int32_t, int32_t > waferUV() const
constexpr bool isEE() const
consistency check : no bits left => no overhead
static constexpr uint32_t kHGCalCellVOffset
constexpr HGCSiliconDetId(const DetId &gen)