CMS 3D CMS Logo

CSCDetId.h
Go to the documentation of this file.
1 #ifndef MuonDetId_CSCDetId_h
2 #define MuonDetId_CSCDetId_h
3 
21 
22 class CSCDetId;
23 
24 std::ostream& operator<<( std::ostream& os, const CSCDetId& id );
25 
26 class CSCDetId : public DetId {
27 
28 public:
29 
30 
34 
37  CSCDetId(uint32_t id) : DetId(id) {}
38  CSCDetId(DetId id) : DetId(id) {}
39 
40 
45  CSCDetId( int iendcap, int istation,
46  int iring, int ichamber,
47  int ilayer = 0 ) : DetId(DetId::Muon, MuonSubdetId::CSC) {
48  id_ |= init(iendcap, istation, iring, ichamber, ilayer);
49  }
50 
53  CSCDetId chamberId() const {
54  // build chamber id by removing layer bits
55  return CSCDetId( id_ - layer() ) ; }
56 
61  int layer() const {
62  return (id_ & MASK_LAYER); }
63 
68  int chamber() const {
69  return ( (id_>>START_CHAMBER) & MASK_CHAMBER ); }
70 
75  int ring() const {
76  if (((id_>>START_STATION) & MASK_STATION) == 1)
77  return ( detIdToInt((id_>>START_RING) & MASK_RING ));
78  else
79  return (((id_>>START_RING) & MASK_RING ));
80  }
81 
86  int station() const {
87  return ( (id_>>START_STATION) & MASK_STATION ); }
88 
93  int endcap() const {
94  return ( (id_>>START_ENDCAP) & MASK_ENDCAP ); }
95 
100  short int zendcap() const {
101  return ( endcap()!=1 ? -1 : +1 );
102  }
103 
107  unsigned short iChamberType() const {
108  return iChamberType( station(), ring() );
109  }
110 
118  int channel( int istrip ) {
119  if ( ring()== 4 )
120  // strips 1-48 mapped to channels 1-16:
121  // 1+17+33->1, 2+18+34->2, .... 16+32+48->16
122  return 1 + (istrip-1)%16;
123  else
124  return istrip;
125  }
126 
127  // static methods
128  // Used when we need information about subdetector labels.
129 
144  static int rawIdMaker( int iendcap, int istation, int iring,
145  int ichamber, int ilayer ) {
146  return ( (DetId::Muon&0xF)<<(DetId::kDetOffset) ) | // set Muon flag
147  ( (MuonSubdetId::CSC&0x7)<<(DetId::kSubdetOffset) ) | // set CSC flag
148  init(iendcap, istation, iring, ichamber, ilayer) ; } // set CSC id
149 
154  static int layer( int index ) {
155  return (index & MASK_LAYER); }
156 
161  static int chamber( int index ) {
162  return ( (index>>START_CHAMBER) & MASK_CHAMBER ); }
163 
168  static int ring( int index ) {
169  if (((index>>START_STATION) & MASK_STATION) == 1)
170  return ( detIdToInt((index>>START_RING) & MASK_RING ));
171  else
172  return (( index>>START_RING) & MASK_RING );
173  }
174 
179  static int station( int index ) {
180  return ( (index>>START_STATION) & MASK_STATION ); }
181 
186  static int endcap( int index ) {
187  return ( (index>>START_ENDCAP) & MASK_ENDCAP ); }
188 
195  static unsigned short iChamberType( unsigned short istation, unsigned short iring );
196 
216  int triggerSector() const;
217 
231  int triggerCscId() const;
232 
236  static int minEndcapId() { return MIN_ENDCAP; }
237  static int maxEndcapId() { return MAX_ENDCAP; }
238  static int minStationId() { return MIN_STATION; }
239  static int maxStationId() { return MAX_STATION; }
240  static int minRingId() { return MIN_RING; }
241  static int maxRingId() { return MAX_RING; }
242  static int minChamberId() { return MIN_CHAMBER; }
243  static int maxChamberId() { return MAX_CHAMBER; }
244  static int minLayerId() { return MIN_LAYER; }
245  static int maxLayerId() { return MAX_LAYER; }
246 
247 private:
248 
253  static uint32_t init( int iendcap, int istation,
254  int iring, int ichamber, int ilayer ) {
255 
256  if (istation == 1)
257  iring = intToDetId(iring);
258 
259  return
260  (ilayer & MASK_LAYER) |
261  ( (ichamber & MASK_CHAMBER) << START_CHAMBER ) |
262  ( (iring & MASK_RING) << START_RING ) |
263  ( (istation & MASK_STATION) << START_STATION ) |
264  ( (iendcap & MASK_ENDCAP) << START_ENDCAP ) ; }
265 
276  static int intToDetId(int iring) {
277  // change iring = 1, 2, 3, 4 input to 2, 3, 4, 1 for use inside the DetId
278  // i.e. ME1b, ME12, ME13, ME1a externally become stored internally in order ME1a, ME1b, ME12, ME13
279  int i = (iring+1)%4;
280  if (i == 0) i = 4;
281  return i;
282  }
283 
284  static int detIdToInt(int iring) {
285  // reverse intToDetId: change 1, 2, 3, 4 inside the DetId to 4, 1, 2, 3 for external use
286  // i.e. output ring # 1, 2, 3, 4 in ME1 means ME1b, ME12, ME13, ME1a as usual in the offline software.
287  int i = (iring-1);
288  if (i == 0) i = 4;
289  return i;
290  }
291 
292  // The following define the bit-packing implementation...
293 
294  // The maximum numbers of various parts
296  // We count from 1
298 
299  // BITS_det is no. of binary bits required to label 'det' but allow 0 as a wild-card character
300  // Keep as multiples of 3 so that number can be easily decodable from octal
302 
303  // MASK_det is binary bits set to pick off the bits for 'det' (defined as octal)
305 
306  // START_det is bit position (counting from zero) at which bits for 'det' start in 'rawId' word
309 };
310 
311 #endif
312 
313 
int chamber() const
Definition: CSCDetId.h:68
static int endcap(int index)
Definition: CSCDetId.h:186
static int minRingId()
Definition: CSCDetId.h:240
static int minEndcapId()
Definition: CSCDetId.h:236
CSCDetId(DetId id)
Definition: CSCDetId.h:38
static int rawIdMaker(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:144
static const int kSubdetOffset
Definition: DetId.h:21
CSCDetId()
Definition: CSCDetId.h:33
static int maxStationId()
Definition: CSCDetId.h:239
static int maxRingId()
Definition: CSCDetId.h:241
int layer() const
Definition: CSCDetId.h:61
CSCDetId(uint32_t id)
Definition: CSCDetId.h:37
static int minChamberId()
Definition: CSCDetId.h:242
static int station(int index)
Definition: CSCDetId.h:179
eStartBitDet
Definition: CSCDetId.h:307
int endcap() const
Definition: CSCDetId.h:93
static int ring(int index)
Definition: CSCDetId.h:168
static int intToDetId(int iring)
Definition: CSCDetId.h:276
static const int CSC
Definition: MuonSubdetId.h:13
int channel(int istrip)
Definition: CSCDetId.h:118
Definition: Muon.py:1
static int minStationId()
Definition: CSCDetId.h:238
static int maxEndcapId()
Definition: CSCDetId.h:237
CSCDetId chamberId() const
Definition: CSCDetId.h:53
CSCDetId(int iendcap, int istation, int iring, int ichamber, int ilayer=0)
Definition: CSCDetId.h:45
unsigned short iChamberType() const
Definition: CSCDetId.h:107
int ring() const
Definition: CSCDetId.h:75
Definition: DetId.h:18
short int zendcap() const
Definition: CSCDetId.h:100
static int minLayerId()
Definition: CSCDetId.h:244
static int maxChamberId()
Definition: CSCDetId.h:243
std::ostream & operator<<(std::ostream &os, const CSCDetId &id)
Definition: CSCDetId.cc:66
static uint32_t init(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:253
uint32_t id_
Definition: DetId.h:56
int triggerSector() const
Definition: CSCDetId.cc:3
int triggerCscId() const
Definition: CSCDetId.cc:23
static int chamber(int index)
Definition: CSCDetId.h:161
static const int kDetOffset
Definition: DetId.h:20
static int detIdToInt(int iring)
Definition: CSCDetId.h:284
int station() const
Definition: CSCDetId.h:86
static int maxLayerId()
Definition: CSCDetId.h:245
static int layer(int index)
Definition: CSCDetId.h:154