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 
251  static std::string chamberName(int endcap, int station, int ring, int chamber);
252  std::string chamberName() const;
253 
254 private:
255 
260  static uint32_t init( int iendcap, int istation,
261  int iring, int ichamber, int ilayer ) {
262 
263  if (istation == 1)
264  iring = intToDetId(iring);
265 
266  return
267  (ilayer & MASK_LAYER) |
268  ( (ichamber & MASK_CHAMBER) << START_CHAMBER ) |
269  ( (iring & MASK_RING) << START_RING ) |
270  ( (istation & MASK_STATION) << START_STATION ) |
271  ( (iendcap & MASK_ENDCAP) << START_ENDCAP ) ; }
272 
283  static int intToDetId(int iring) {
284  // change iring = 1, 2, 3, 4 input to 2, 3, 4, 1 for use inside the DetId
285  // i.e. ME1b, ME12, ME13, ME1a externally become stored internally in order ME1a, ME1b, ME12, ME13
286  int i = (iring+1)%4;
287  if (i == 0) i = 4;
288  return i;
289  }
290 
291  static int detIdToInt(int iring) {
292  // reverse intToDetId: change 1, 2, 3, 4 inside the DetId to 4, 1, 2, 3 for external use
293  // i.e. output ring # 1, 2, 3, 4 in ME1 means ME1b, ME12, ME13, ME1a as usual in the offline software.
294  int i = (iring-1);
295  if (i == 0) i = 4;
296  return i;
297  }
298 
299  // The following define the bit-packing implementation...
300 
301  // The maximum numbers of various parts
303  // We count from 1
305 
306  // BITS_det is no. of binary bits required to label 'det' but allow 0 as a wild-card character
307  // Keep as multiples of 3 so that number can be easily decodable from octal
309 
310  // MASK_det is binary bits set to pick off the bits for 'det' (defined as octal)
312 
313  // START_det is bit position (counting from zero) at which bits for 'det' start in 'rawId' word
316 };
317 
318 #endif
319 
320 
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:23
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:314
int endcap() const
Definition: CSCDetId.h:93
static int ring(int index)
Definition: CSCDetId.h:168
static int intToDetId(int iring)
Definition: CSCDetId.h:283
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
std::string chamberName() const
Definition: CSCDetId.cc:71
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:76
static uint32_t init(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:260
uint32_t id_
Definition: DetId.h:62
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:22
static int detIdToInt(int iring)
Definition: CSCDetId.h:291
int station() const
Definition: CSCDetId.h:86
static int maxLayerId()
Definition: CSCDetId.h:245
static int layer(int index)
Definition: CSCDetId.h:154