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