CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
116  if ( det() == DetId::Tracker) {
117  if ( subdetId() == static_cast<int>(SiStripDetId::TEC) ) {
118  result = SiStripDetId::TEC;
119  } else if ( subdetId() == static_cast<int>(SiStripDetId::TID) ) {
120  result = SiStripDetId::TID;
121  } else if ( subdetId() == static_cast<int>(SiStripDetId::TOB) ) {
122  result = SiStripDetId::TOB;
123  } else if ( subdetId() == static_cast<int>(SiStripDetId::TIB) ) {
124  result = SiStripDetId::TIB;
125  } else {
126  result = SiStripDetId::UNKNOWN;
127  }
128  } else {
129  result = SiStripDetId::UNKNOWN;
130  }
131  return result;
132 }
133 
136  switch(subDetector()) {
137  case TIB: geometry = int((id_>>layerStartBit_) & layerMask_)<3? IB1 : IB2;
138  break;
139  case TOB: geometry = int((id_>>layerStartBit_) & layerMask_)<5? OB2 : OB1;
140  break;
141  case TID: switch ((id_>>ringStartBitTID_) & ringMaskTID_) {
142  case 1: geometry = W1A;
143  break;
144  case 2: geometry = W2A;
145  break;
146  case 3: geometry = W3A;
147  break;
148  }
149  break;
150  case TEC: switch ((id_>>ringStartBitTEC_) & ringMaskTEC_) {
151  case 1: geometry = W1B;
152  break;
153  case 2: geometry = W2B;
154  break;
155  case 3: geometry = W3B;
156  break;
157  case 4: geometry = W4;
158  break;
159  case 5: geometry = W5;
160  break;
161  case 6: geometry = W6;
162  break;
163  case 7: geometry = W7;
164  break;
165  }
166  case UNKNOWN: default:;
167  }
168  return geometry;
169 }
170 
171 uint32_t SiStripDetId::glued() const {
172  uint32_t testId = (id_>>sterStartBit_) & sterMask_;
173  return ( testId == 0 ) ? 0 : (id_ - testId);
174 }
175 
176 uint32_t SiStripDetId::stereo() const {
177  return ( ((id_>>sterStartBit_) & sterMask_) == 1 ) ? 1 : 0;
178 }
179 
180 uint32_t SiStripDetId::partnerDetId() const {
181  uint32_t testId = (id_>>sterStartBit_) & sterMask_;
182  if ( testId == 1 ) {
183  testId = id_ + 1;
184  } else if ( testId == 2 ) {
185  testId = id_ - 1;
186  } else { testId = 0; }
187  return testId;
188 }
189 
191  return 0.;
192 }
193 
194 
195 uint16_t SiStripDetId::reserved() const {
196  return static_cast<uint16_t>( (id_>>reservedStartBit_) & reservedMask_ );
197 }
198 
199 #endif // DataFormats_SiStripDetId_SiStripDetId_h
200 
static const unsigned ringStartBitTID_
Definition: SiStripDetId.h:105
static const uint32_t sterStartBit_
Definition: SiStripDetId.h:95
uint32_t stereo() const
Definition: SiStripDetId.h:176
static const uint32_t sterMask_
Definition: SiStripDetId.h:101
static const unsigned layerStartBit_
Definition: SiStripDetId.h:103
SiStripDetId(const DetId &det_id, const uint16_t &reserved)
Definition: SiStripDetId.h:77
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
SiStripDetId(const uint32_t &raw_id, const uint16_t &reserved)
Definition: SiStripDetId.h:65
SiStripDetId(const DetId &det_id)
Definition: SiStripDetId.h:30
uint32_t rawId() const
get the raw id
Definition: DetId.h:43
SiStripDetId(Detector det, int subdet)
Definition: SiStripDetId.h:33
tuple result
Definition: query.py:137
uint32_t partnerDetId() const
Definition: SiStripDetId.h:180
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
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:37
uint16_t reserved() const
Definition: SiStripDetId.h:195
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:171
Detector
Definition: DetId.h:24
uint32_t id_
Definition: DetId.h:55
static const unsigned ringMaskTEC_
Definition: SiStripDetId.h:108
ESHandle< TrackerGeometry > geometry
double stripLength() const
Definition: SiStripDetId.h:190
static const unsigned ringStartBitTEC_
Definition: SiStripDetId.h:107
ModuleGeometry moduleGeometry() const
Definition: SiStripDetId.h:134
static const unsigned ringMaskTID_
Definition: SiStripDetId.h:106
Detector det() const
get the detector field from this detid
Definition: DetId.h:35
static const uint16_t reservedStartBit_
Definition: SiStripDetId.h:92