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 high density wafer with depltetion thickness of 120 mum
19  1 low density wafer with depletion thickness of 200 mum
20  2 low density wafer with depletion thickness of 300 mum
21  3 high density wafer with depletion thickness of 200 mum)
22  [28:31] Detector type (HGCalEE or HGCalHSi)
23 */
24 class HGCSiliconDetId : public DetId {
25 public:
26  enum waferType { HGCalHD120 = 0, HGCalLD200 = 1, HGCalLD300 = 2, HGCalHD200 = 3 };
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 
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 
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 
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 
87  return HGCSiliconDetId(det(), zside(), 0, layer(), waferU(), waferV(), 0, 0);
88  }
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() == HGCalLD200) || (type() == HGCalLD300)); }
99  constexpr bool highDensity() const { return ((type() == HGCalHD120) || (type() == HGCalHD200)); }
100  constexpr int32_t depletion() const {
102  }
103 
105  constexpr int32_t zside() const { return (((id_ >> kHGCalZsideOffset) & kHGCalZsideMask) ? -1 : 1); }
106 
108  constexpr int32_t layer() const { return (id_ >> kHGCalLayerOffset) & kHGCalLayerMask; }
109 
111  constexpr int32_t cellU() const { return (id_ >> kHGCalCellUOffset) & kHGCalCellUMask; }
112  constexpr int32_t cellV() const { return (id_ >> kHGCalCellVOffset) & kHGCalCellVMask; }
113  constexpr std::pair<int32_t, int32_t> cellUV() const { return std::pair<int32_t, int32_t>(cellU(), cellV()); }
114  constexpr int32_t cellX() const {
115  int32_t N = ((type() == HGCalHD120) || (type() == HGCalHD200)) ? HGCalHighDensityN : HGCalLowDensityN;
116  return (3 * (cellV() - N) + 2);
117  }
118  constexpr int32_t cellY() const {
119  int32_t N = ((type() == HGCalHD120) || (type() == HGCalHD200)) ? HGCalHighDensityN : HGCalLowDensityN;
120  return (2 * cellU() - (N + cellV()));
121  }
122  constexpr std::pair<int32_t, int32_t> cellXY() const { return std::pair<int32_t, int32_t>(cellX(), cellY()); }
123 
125  constexpr int32_t waferUAbs() const { return (id_ >> kHGCalWaferUOffset) & kHGCalWaferUMask; }
126  constexpr int32_t waferVAbs() const { return (id_ >> kHGCalWaferVOffset) & kHGCalWaferVMask; }
127  constexpr int32_t waferU() const {
129  }
130  constexpr int32_t waferV() const {
132  }
133  constexpr std::pair<int32_t, int32_t> waferUV() const { return std::pair<int32_t, int32_t>(waferU(), waferV()); }
134  constexpr int32_t waferX() const { return (-2 * waferU() + waferV()); }
135  constexpr int32_t waferY() const { return (2 * waferV()); }
136  constexpr std::pair<int32_t, int32_t> waferXY() const { return std::pair<int32_t, int32_t>(waferX(), waferY()); }
138  int32_t& ty, int32_t& zs, int32_t& ly, int32_t& wU, int32_t& wV, int32_t& cU, int32_t& cV) const {
139  ty = type();
140  zs = zside();
141  ly = layer();
142  wU = waferU();
143  wV = waferV();
144  cU = cellU();
145  cV = cellV();
146  }
147 
148  // get trigger cell u,v
149  constexpr int32_t triggerCellU() const {
150  int32_t N = ((type() == HGCalHD120) || (type() == HGCalHD200)) ? HGCalHighDensityN : HGCalLowDensityN;
151  int32_t NT = ((type() == HGCalHD120) || (type() == HGCalHD200)) ? HGCalFineTrigger : HGCalCoarseTrigger;
152  return (cellU() >= N && cellV() >= N)
153  ? cellU() / NT
154  : ((cellU() < N && cellU() <= cellV()) ? cellU() / NT : (1 + (cellU() - (cellV() % NT + 1)) / NT));
155  }
156  constexpr int32_t triggerCellV() const {
157  int32_t N = ((type() == HGCalHD120) || (type() == HGCalHD200)) ? HGCalHighDensityN : HGCalLowDensityN;
158  int32_t NT = ((type() == HGCalHD120) || (type() == HGCalHD200)) ? HGCalFineTrigger : HGCalCoarseTrigger;
159  return (cellU() >= N && cellV() >= N)
160  ? cellV() / NT
161  : ((cellU() < N && cellU() <= cellV()) ? ((cellV() - cellU()) / NT + cellU() / NT) : cellV() / NT);
162  }
163  constexpr std::pair<int32_t, int32_t> triggerCellUV() const {
164  return std::pair<int32_t, int32_t>(triggerCellU(), triggerCellV());
165  }
166 
168  constexpr bool isEE() const { return (det() == HGCalEE); }
169  constexpr bool isHE() const { return (det() == HGCalHSi); }
170  constexpr bool isForward() const { return true; }
171 
173 
174 public:
175  static constexpr uint32_t kHGCalCellUOffset = 0;
176  static constexpr uint32_t kHGCalCellUMask = 0x1F;
177  static constexpr uint32_t kHGCalCellVOffset = 5;
178  static constexpr uint32_t kHGCalCellVMask = 0x1F;
179  static constexpr uint32_t kHGCalWaferUOffset = 10;
180  static constexpr uint32_t kHGCalWaferUMask = 0xF;
181  static constexpr uint32_t kHGCalWaferUSignOffset = 14;
182  static constexpr uint32_t kHGCalWaferUSignMask = 0x1;
183  static constexpr uint32_t kHGCalWaferVOffset = 15;
184  static constexpr uint32_t kHGCalWaferVMask = 0xF;
185  static constexpr uint32_t kHGCalWaferVSignOffset = 19;
186  static constexpr uint32_t kHGCalWaferVSignMask = 0x1;
187  static constexpr uint32_t kHGCalLayerOffset = 20;
188  static constexpr uint32_t kHGCalLayerMask = 0x1F;
189  static constexpr uint32_t kHGCalZsideOffset = 25;
190  static constexpr uint32_t kHGCalZsideMask = 0x1;
191  static constexpr uint32_t kHGCalTypeOffset = 26;
192  static constexpr uint32_t kHGCalTypeMask = 0x3;
193 };
194 
195 std::ostream& operator<<(std::ostream&, const HGCSiliconDetId& id);
196 
197 #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)