CMS 3D CMS Logo

SiStripDetId.h
Go to the documentation of this file.
1 #ifndef DataFormats_SiStripDetId_SiStripDetId_h
2 #define DataFormats_SiStripDetId_SiStripDetId_h
3 
7 #include <ostream>
8 
9 class SiStripDetId;
10 
12 std::ostream &operator<<(std::ostream &, const SiStripDetId &);
13 
19 class SiStripDetId : public DetId {
20 public:
21  // ---------- Constructors, enumerated types ----------
22 
24  SiStripDetId() : DetId() { ; }
25 
27  SiStripDetId(const uint32_t &raw_id) : DetId(raw_id) { ; }
28 
30  SiStripDetId(const DetId &det_id) : DetId(det_id.rawId()) { ; }
31 
33  SiStripDetId(Detector det, int subdet) : DetId(det, subdet) { ; }
34 
42 
43  // ---------- Common methods ----------
44 
46  inline SubDetector subDetector() const;
47 
50 
52  inline uint32_t glued() const;
53 
55  inline uint32_t stereo() const;
56 
58  inline uint32_t partnerDetId() const;
59 
61  inline double stripLength() const;
62 
64  inline unsigned int numberOfAPVs() const;
65 
66  // ---------- Constructors that set "reserved" field ----------
67 
69  SiStripDetId(const uint32_t &raw_id, const uint16_t &reserved) : DetId(raw_id) {
70  id_ &= (~static_cast<uint32_t>(reservedMask_ << reservedStartBit_));
72  }
73 
74  // -----------------------------------------------------------------------------
75  //
76 
78  SiStripDetId(const DetId &det_id, const uint16_t &reserved) : DetId(det_id.rawId()) {
79  id_ &= (~static_cast<uint32_t>(reservedMask_ << reservedStartBit_));
81  }
82 
84  inline uint16_t reserved() const;
85 
86 private:
88  static const uint16_t reservedStartBit_ = 20;
89 
91  static const uint32_t sterStartBit_ = 0;
92 
94  static const uint16_t reservedMask_ = 0x7;
95 
97  static const uint32_t sterMask_ = 0x3;
98 
99  static const unsigned layerStartBit_ = 14;
100  static const unsigned layerMask_ = 0x7;
101  static const unsigned ringStartBitTID_ = 9;
102  static const unsigned ringMaskTID_ = 0x3;
103  static const unsigned ringStartBitTEC_ = 5;
104  static const unsigned ringMaskTEC_ = 0x7;
105 };
106 
107 // ---------- inline methods ----------
108 
110  return static_cast<SiStripDetId::SubDetector>(subdetId());
111 }
112 
115  switch (subDetector()) {
116  case TIB:
117  geometry =
119  break;
120  case TOB:
121  geometry =
123  break;
124  case TID:
125  switch ((id_ >> ringStartBitTID_) & ringMaskTID_) {
126  case 1:
128  break;
129  case 2:
131  break;
132  case 3:
134  break;
135  }
136  break;
137  case TEC:
138  switch ((id_ >> ringStartBitTEC_) & ringMaskTEC_) {
139  case 1:
141  break;
142  case 2:
144  break;
145  case 3:
147  break;
148  case 4:
150  break;
151  case 5:
153  break;
154  case 6:
156  break;
157  case 7:
159  break;
160  }
161  case UNKNOWN:
162  default:;
163  }
164  return geometry;
165 }
166 
167 uint32_t SiStripDetId::glued() const {
168  uint32_t testId = (id_ >> sterStartBit_) & sterMask_;
169  return (testId == 0) ? 0 : (id_ - testId);
170 }
171 
172 uint32_t SiStripDetId::stereo() const { return (((id_ >> sterStartBit_) & sterMask_) == 1) ? 1 : 0; }
173 
174 uint32_t SiStripDetId::partnerDetId() const {
175  uint32_t testId = (id_ >> sterStartBit_) & sterMask_;
176  if (testId == 1) {
177  testId = id_ + 1;
178  } else if (testId == 2) {
179  testId = id_ - 1;
180  } else {
181  testId = 0;
182  }
183  return testId;
184 }
185 
186 double SiStripDetId::stripLength() const { return 0.; }
187 
188 uint16_t SiStripDetId::reserved() const { return static_cast<uint16_t>((id_ >> reservedStartBit_) & reservedMask_); }
189 
190 unsigned int SiStripDetId::numberOfAPVs() const {
191  const auto &moduleGeometry = this->moduleGeometry();
192 
193  // Check for unknown geometry and throw a meaningful exception
195  throw cms::Exception("InvalidModuleGeometry")
196  << "Error in SiStripDetId::numberOfAPVs(): Module geometry is UNKNOWNGEOMETRY. "
197  << "This indicates an invalid or unsupported module geometry for the current DetId: " << this->rawId();
198  }
199 
200  // Determine the number of APVs based on the module geometry
205  return 6;
206  } else {
207  return 4;
208  }
209 }
210 
211 #endif // DataFormats_SiStripDetId_SiStripDetId_h
static const unsigned ringStartBitTID_
Definition: SiStripDetId.h:101
uint16_t reserved() const
Definition: SiStripDetId.h:188
static const uint32_t sterStartBit_
Definition: SiStripDetId.h:91
static constexpr auto TID
Definition: SiStripDetId.h:39
std::ostream & operator<<(std::ostream &, const SiStripDetId &)
Definition: SiStripDetId.cc:4
SiStripModuleGeometry moduleGeometry() const
Definition: SiStripDetId.h:113
static const uint32_t sterMask_
Definition: SiStripDetId.h:97
static const unsigned layerStartBit_
Definition: SiStripDetId.h:99
SiStripDetId(const DetId &det_id, const uint16_t &reserved)
Definition: SiStripDetId.h:78
uint32_t glued() const
Definition: SiStripDetId.h:167
SubDetector subDetector() const
Definition: SiStripDetId.h:109
double stripLength() const
Definition: SiStripDetId.h:186
SiStripDetId(const uint32_t &raw_id, const uint16_t &reserved)
Definition: SiStripDetId.h:69
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
unsigned int numberOfAPVs() const
Definition: SiStripDetId.h:190
SiStripDetId(const DetId &det_id)
Definition: SiStripDetId.h:30
SiStripDetId(Detector det, int subdet)
Definition: SiStripDetId.h:33
uint32_t stereo() const
Definition: SiStripDetId.h:172
static constexpr auto UNKNOWN
Definition: SiStripDetId.h:37
static const uint16_t reservedMask_
Definition: SiStripDetId.h:94
static const unsigned layerMask_
Definition: SiStripDetId.h:100
SiStripModuleGeometry
Definition: SiStripEnums.h:8
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
SiStripDetId(const uint32_t &raw_id)
Definition: SiStripDetId.h:27
static constexpr auto TOB
Definition: SiStripDetId.h:40
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:19
Definition: DetId.h:17
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
Detector
Definition: DetId.h:24
uint32_t id_
Definition: DetId.h:69
static constexpr auto TIB
Definition: SiStripDetId.h:38
static const unsigned ringMaskTEC_
Definition: SiStripDetId.h:104
uint32_t partnerDetId() const
Definition: SiStripDetId.h:174
static const unsigned ringStartBitTEC_
Definition: SiStripDetId.h:103
static const unsigned ringMaskTID_
Definition: SiStripDetId.h:102
static const uint16_t reservedStartBit_
Definition: SiStripDetId.h:88
static constexpr auto TEC
Definition: SiStripDetId.h:41