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 
5 #include <ostream>
6 
7 class SiStripDetId;
8 
10 std::ostream &operator<<(std::ostream &, const SiStripDetId &);
11 
17 class SiStripDetId : public DetId {
18 public:
19  // ---------- Constructors, enumerated types ----------
20 
22  SiStripDetId() : DetId() { ; }
23 
25  SiStripDetId(const uint32_t &raw_id) : DetId(raw_id) { ; }
26 
28  SiStripDetId(const DetId &det_id) : DetId(det_id.rawId()) { ; }
29 
31  SiStripDetId(Detector det, int subdet) : DetId(det, subdet) { ; }
32 
34  enum SubDetector { UNKNOWN = 0, TIB = 3, TID = 4, TOB = 5, TEC = 6 };
35 
38 
39  // ---------- Common methods ----------
40 
42  inline SubDetector subDetector() const;
43 
45  inline ModuleGeometry moduleGeometry() const;
46 
48  inline uint32_t glued() const;
49 
51  inline uint32_t stereo() const;
52 
54  inline uint32_t partnerDetId() const;
55 
57  inline double stripLength() const;
58 
59  // ---------- Constructors that set "reserved" field ----------
60 
62  SiStripDetId(const uint32_t &raw_id, const uint16_t &reserved) : DetId(raw_id) {
63  id_ &= (~static_cast<uint32_t>(reservedMask_ << reservedStartBit_));
64  id_ |= ((reserved & reservedMask_) << reservedStartBit_);
65  }
66 
67  // -----------------------------------------------------------------------------
68  //
69 
71  SiStripDetId(const DetId &det_id, const uint16_t &reserved) : DetId(det_id.rawId()) {
72  id_ &= (~static_cast<uint32_t>(reservedMask_ << reservedStartBit_));
73  id_ |= ((reserved & reservedMask_) << reservedStartBit_);
74  }
75 
77  inline uint16_t reserved() const;
78 
79 private:
81  static const uint16_t reservedStartBit_ = 20;
82 
84  static const uint32_t sterStartBit_ = 0;
85 
87  static const uint16_t reservedMask_ = 0x7;
88 
90  static const uint32_t sterMask_ = 0x3;
91 
92  static const unsigned layerStartBit_ = 14;
93  static const unsigned layerMask_ = 0x7;
94  static const unsigned ringStartBitTID_ = 9;
95  static const unsigned ringMaskTID_ = 0x3;
96  static const unsigned ringStartBitTEC_ = 5;
97  static const unsigned ringMaskTEC_ = 0x7;
98 };
99 
100 // ---------- inline methods ----------
101 
103  return static_cast<SiStripDetId::SubDetector>(subdetId());
104 }
105 
108  switch (subDetector()) {
109  case TIB:
110  geometry = int((id_ >> layerStartBit_) & layerMask_) < 3 ? IB1 : IB2;
111  break;
112  case TOB:
113  geometry = int((id_ >> layerStartBit_) & layerMask_) < 5 ? OB2 : OB1;
114  break;
115  case TID:
116  switch ((id_ >> ringStartBitTID_) & ringMaskTID_) {
117  case 1:
118  geometry = W1A;
119  break;
120  case 2:
121  geometry = W2A;
122  break;
123  case 3:
124  geometry = W3A;
125  break;
126  }
127  break;
128  case TEC:
129  switch ((id_ >> ringStartBitTEC_) & ringMaskTEC_) {
130  case 1:
131  geometry = W1B;
132  break;
133  case 2:
134  geometry = W2B;
135  break;
136  case 3:
137  geometry = W3B;
138  break;
139  case 4:
140  geometry = W4;
141  break;
142  case 5:
143  geometry = W5;
144  break;
145  case 6:
146  geometry = W6;
147  break;
148  case 7:
149  geometry = W7;
150  break;
151  }
152  case UNKNOWN:
153  default:;
154  }
155  return geometry;
156 }
157 
158 uint32_t SiStripDetId::glued() const {
159  uint32_t testId = (id_ >> sterStartBit_) & sterMask_;
160  return (testId == 0) ? 0 : (id_ - testId);
161 }
162 
163 uint32_t SiStripDetId::stereo() const { return (((id_ >> sterStartBit_) & sterMask_) == 1) ? 1 : 0; }
164 
165 uint32_t SiStripDetId::partnerDetId() const {
166  uint32_t testId = (id_ >> sterStartBit_) & sterMask_;
167  if (testId == 1) {
168  testId = id_ + 1;
169  } else if (testId == 2) {
170  testId = id_ - 1;
171  } else {
172  testId = 0;
173  }
174  return testId;
175 }
176 
177 double SiStripDetId::stripLength() const { return 0.; }
178 
179 uint16_t SiStripDetId::reserved() const { return static_cast<uint16_t>((id_ >> reservedStartBit_) & reservedMask_); }
180 
181 #endif // DataFormats_SiStripDetId_SiStripDetId_h
static const unsigned ringStartBitTID_
Definition: SiStripDetId.h:94
static const uint32_t sterStartBit_
Definition: SiStripDetId.h:84
uint32_t stereo() const
Definition: SiStripDetId.h:163
std::ostream & operator<<(std::ostream &, const SiStripDetId &)
Definition: SiStripDetId.cc:4
static const uint32_t sterMask_
Definition: SiStripDetId.h:90
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
static const unsigned layerStartBit_
Definition: SiStripDetId.h:92
SiStripDetId(const DetId &det_id, const uint16_t &reserved)
Definition: SiStripDetId.h:71
SiStripDetId(const uint32_t &raw_id, const uint16_t &reserved)
Definition: SiStripDetId.h:62
SiStripDetId(const DetId &det_id)
Definition: SiStripDetId.h:28
SiStripDetId(Detector det, int subdet)
Definition: SiStripDetId.h:31
uint32_t partnerDetId() const
Definition: SiStripDetId.h:165
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
static const uint16_t reservedMask_
Definition: SiStripDetId.h:87
static const unsigned layerMask_
Definition: SiStripDetId.h:93
SiStripDetId(const uint32_t &raw_id)
Definition: SiStripDetId.h:25
uint16_t reserved() const
Definition: SiStripDetId.h:179
Detector identifier class for the strip tracker.
Definition: SiStripDetId.h:17
SubDetector subDetector() const
Definition: SiStripDetId.h:102
Definition: DetId.h:18
uint32_t glued() const
Definition: SiStripDetId.h:158
Detector
Definition: DetId.h:26
uint32_t id_
Definition: DetId.h:62
static const unsigned ringMaskTEC_
Definition: SiStripDetId.h:97
ESHandle< TrackerGeometry > geometry
double stripLength() const
Definition: SiStripDetId.h:177
static const unsigned ringStartBitTEC_
Definition: SiStripDetId.h:96
ModuleGeometry moduleGeometry() const
Definition: SiStripDetId.h:106
static const unsigned ringMaskTID_
Definition: SiStripDetId.h:95
static const uint16_t reservedStartBit_
Definition: SiStripDetId.h:81
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39