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 
115  if( det() == DetId::Tracker &&
116  subdetId() == static_cast<int>(SiStripDetId::TIB) ) {
117  return SiStripDetId::TIB;
118  } else if ( det() == DetId::Tracker &&
119  subdetId() == static_cast<int>(SiStripDetId::TID) ) {
120  return SiStripDetId::TID;
121  } else if ( det() == DetId::Tracker &&
122  subdetId() == static_cast<int>(SiStripDetId::TOB) ) {
123  return SiStripDetId::TOB;
124  } else if ( det() == DetId::Tracker &&
125  subdetId() == static_cast<int>(SiStripDetId::TEC) ) {
126  return SiStripDetId::TEC;
127  } else {
128  return SiStripDetId::UNKNOWN;
129  }
130 }
131 
133  switch(subDetector()) {
134  case TIB: return int((id_>>layerStartBit_) & layerMask_)<3? IB1 : IB2;
135  case TOB: return int((id_>>layerStartBit_) & layerMask_)<5? OB2 : OB1;
136  case TID: switch ((id_>>ringStartBitTID_) & ringMaskTID_) {
137  case 1: return W1A;
138  case 2: return W2A;
139  case 3: return W3A;
140  }
141  case TEC: switch ((id_>>ringStartBitTEC_) & ringMaskTEC_) {
142  case 1: return W1B;
143  case 2: return W2B;
144  case 3: return W3B;
145  case 4: return W4;
146  case 5: return W5;
147  case 6: return W6;
148  case 7: return W7;
149  }
150  case UNKNOWN: default: return UNKNOWNGEOMETRY;
151  }
152 }
153 
154 uint32_t SiStripDetId::glued() const {
155  if ( ((id_>>sterStartBit_) & sterMask_ ) == 1 ) {
156  return ( id_ - 1 );
157  } else if ( ((id_>>sterStartBit_) & sterMask_ ) == 2 ) {
158  return ( id_ - 2 );
159  } else { return 0; }
160 }
161 
162 uint32_t SiStripDetId::stereo() const {
163  if ( ((id_>>sterStartBit_ ) & sterMask_ ) == 1 ) {
164  return ( (id_>>sterStartBit_) & sterMask_ );
165  } else { return 0; }
166 }
167 
168 uint32_t SiStripDetId::partnerDetId() const {
169  if ( ((id_>>sterStartBit_) & sterMask_ ) == 1 ) {
170  return ( id_ + 1 );
171  } else if ( ((id_>>sterStartBit_) & sterMask_ ) == 2 ) {
172  return ( id_ - 1 );
173  } else { return 0; }
174 }
175 
177  return 0.;
178 }
179 
180 
181 uint16_t SiStripDetId::reserved() const {
182  return static_cast<uint16_t>( (id_>>reservedStartBit_) & reservedMask_ );
183 }
184 
185 #endif // DataFormats_SiStripDetId_SiStripDetId_h
186 
static const unsigned ringStartBitTID_
Definition: SiStripDetId.h:105
static const uint32_t sterStartBit_
Definition: SiStripDetId.h:95
uint32_t stereo() const
Definition: SiStripDetId.h:162
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
uint32_t partnerDetId() const
Definition: SiStripDetId.h:168
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:181
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:154
Detector
Definition: DetId.h:24
uint32_t id_
Definition: DetId.h:55
static const unsigned ringMaskTEC_
Definition: SiStripDetId.h:108
double stripLength() const
Definition: SiStripDetId.h:176
static const unsigned ringStartBitTEC_
Definition: SiStripDetId.h:107
ModuleGeometry moduleGeometry() const
Definition: SiStripDetId.h:132
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