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 public:
31 
34  CSCDetId(uint32_t id) : DetId(id) {}
35  CSCDetId(DetId id) : DetId(id) {}
36 
41  CSCDetId(int iendcap, int istation, int iring, int ichamber, int ilayer = 0) : DetId(DetId::Muon, MuonSubdetId::CSC) {
42  id_ |= init(iendcap, istation, iring, ichamber, ilayer);
43  }
44 
47  CSCDetId chamberId() const {
48  // build chamber id by removing layer bits
49  return CSCDetId(id_ - layer());
50  }
51 
56  int layer() const { return (id_ & MASK_LAYER); }
57 
62  int chamber() const { return ((id_ >> START_CHAMBER) & MASK_CHAMBER); }
63 
68  int ring() const {
69  if (((id_ >> START_STATION) & MASK_STATION) == 1)
70  return (detIdToInt((id_ >> START_RING) & MASK_RING));
71  else
72  return (((id_ >> START_RING) & MASK_RING));
73  }
74 
79  int station() const { return ((id_ >> START_STATION) & MASK_STATION); }
80 
85  int endcap() const { return ((id_ >> START_ENDCAP) & MASK_ENDCAP); }
86 
91  short int zendcap() const { return (endcap() != 1 ? -1 : +1); }
92 
96  unsigned short iChamberType() const { return iChamberType(station(), ring()); }
97 
105  int channel(int istrip) {
106  if (ring() == 4)
107  // strips 1-48 mapped to channels 1-16:
108  // 1+17+33->1, 2+18+34->2, .... 16+32+48->16
109  return 1 + (istrip - 1) % 16;
110  else
111  return istrip;
112  }
113 
117  bool isME1a() const;
118  bool isME1b() const;
119  bool isME11() const;
120  bool isME12() const;
121  bool isME13() const;
122  bool isME21() const;
123  bool isME22() const;
124  bool isME31() const;
125  bool isME32() const;
126  bool isME41() const;
127  bool isME42() const;
128 
129  // static methods
130  // Used when we need information about subdetector labels.
131 
146  static int rawIdMaker(int iendcap, int istation, int iring, int ichamber, int ilayer) {
147  return ((DetId::Muon & 0xF) << (DetId::kDetOffset)) | // set Muon flag
148  ((MuonSubdetId::CSC & 0x7) << (DetId::kSubdetOffset)) | // set CSC flag
149  init(iendcap, istation, iring, ichamber, ilayer);
150  } // set CSC id
151 
156  static int layer(int index) { return (index & MASK_LAYER); }
157 
162  static int chamber(int index) { 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) { return ((index >> START_STATION) & MASK_STATION); }
180 
185  static int endcap(int index) { return ((index >> START_ENDCAP) & MASK_ENDCAP); }
186 
193  static unsigned short iChamberType(unsigned short istation, unsigned short iring);
194 
214  int triggerSector() const;
215 
229  int triggerCscId() const;
230 
234  static int minEndcapId() { return MIN_ENDCAP; }
235  static int maxEndcapId() { return MAX_ENDCAP; }
236  static int minStationId() { return MIN_STATION; }
237  static int maxStationId() { return MAX_STATION; }
238  static int minRingId() { return MIN_RING; }
239  static int maxRingId() { return MAX_RING; }
240  static int minChamberId() { return MIN_CHAMBER; }
241  static int maxChamberId() { return MAX_CHAMBER; }
242  static int minLayerId() { return MIN_LAYER; }
243  static int maxLayerId() { return MAX_LAYER; }
244 
249  static std::string chamberName(int endcap, int station, int ring, int chamber);
251  std::string chamberName() const;
256  static std::string layerName(int endcap, int station, int ring, int chamber, int layer);
257  std::string layerName() const;
258 
259 private:
264  static uint32_t init(int iendcap, int istation, int iring, int ichamber, int ilayer) {
265  if (istation == 1)
266  iring = intToDetId(iring);
267 
268  return (ilayer & MASK_LAYER) | ((ichamber & MASK_CHAMBER) << START_CHAMBER) | ((iring & MASK_RING) << START_RING) |
269  ((istation & MASK_STATION) << START_STATION) | ((iendcap & MASK_ENDCAP) << START_ENDCAP);
270  }
271 
282  static int intToDetId(int iring) {
283  // change iring = 1, 2, 3, 4 input to 2, 3, 4, 1 for use inside the DetId
284  // i.e. ME1b, ME12, ME13, ME1a externally become stored internally in order ME1a, ME1b, ME12, ME13
285  int i = (iring + 1) % 4;
286  if (i == 0)
287  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)
296  i = 4;
297  return i;
298  }
299 
300  // The following define the bit-packing implementation...
301 
302  // The maximum numbers of various parts
303  enum eMaxNum { MAX_ENDCAP = 2, MAX_STATION = 4, MAX_RING = 4, MAX_CHAMBER = 36, MAX_LAYER = 6 };
304  // We count from 1
305  enum eMinNum { MIN_ENDCAP = 1, MIN_STATION = 1, MIN_RING = 1, MIN_CHAMBER = 1, MIN_LAYER = 1 };
306 
307  // BITS_det is no. of binary bits required to label 'det' but allow 0 as a wild-card character
308  // Keep as multiples of 3 so that number can be easily decodable from octal
310 
311  // MASK_det is binary bits set to pick off the bits for 'det' (defined as octal)
312  enum eMaskBitDet { MASK_ENDCAP = 07, MASK_STATION = 07, MASK_RING = 07, MASK_CHAMBER = 077, MASK_LAYER = 07 };
313 
314  // START_det is bit position (counting from zero) at which bits for 'det' start in 'rawId' word
320  };
321 };
322 
323 #endif
static int endcap(int index)
Definition: CSCDetId.h:185
static int minRingId()
Definition: CSCDetId.h:238
bool isME31() const
Definition: CSCDetId.cc:69
short int zendcap() const
Definition: CSCDetId.h:91
static int minEndcapId()
Definition: CSCDetId.h:234
bool isME12() const
Definition: CSCDetId.cc:65
bool isME22() const
Definition: CSCDetId.cc:68
CSCDetId(DetId id)
Definition: CSCDetId.h:35
static int rawIdMaker(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:146
int triggerCscId() const
Definition: CSCDetId.cc:22
int layer() const
Definition: CSCDetId.h:56
static const int kSubdetOffset
Definition: DetId.h:22
CSCDetId()
Definition: CSCDetId.h:30
static int maxStationId()
Definition: CSCDetId.h:237
unsigned short iChamberType() const
Definition: CSCDetId.h:96
static int maxRingId()
Definition: CSCDetId.h:239
bool isME32() const
Definition: CSCDetId.cc:70
CSCDetId(uint32_t id)
Definition: CSCDetId.h:34
static int minChamberId()
Definition: CSCDetId.h:240
static int station(int index)
Definition: CSCDetId.h:179
eStartBitDet
Definition: CSCDetId.h:315
static int ring(int index)
Definition: CSCDetId.h:168
static int intToDetId(int iring)
Definition: CSCDetId.h:282
int channel(int istrip)
Definition: CSCDetId.h:105
Definition: Muon.py:1
std::string chamberName() const
Definition: CSCDetId.cc:92
static int minStationId()
Definition: CSCDetId.h:236
static int maxEndcapId()
Definition: CSCDetId.h:235
bool isME21() const
Definition: CSCDetId.cc:67
int chamber() const
Definition: CSCDetId.h:62
CSCDetId(int iendcap, int istation, int iring, int ichamber, int ilayer=0)
Definition: CSCDetId.h:41
bool isME1a() const
Definition: CSCDetId.cc:62
Definition: DetId.h:17
bool isME1b() const
Definition: CSCDetId.cc:63
static int minLayerId()
Definition: CSCDetId.h:242
int station() const
Definition: CSCDetId.h:79
static int maxChamberId()
Definition: CSCDetId.h:241
bool isME11() const
Definition: CSCDetId.cc:64
CSCDetId chamberId() const
Definition: CSCDetId.h:47
std::ostream & operator<<(std::ostream &os, const CSCDetId &id)
Definition: CSCDetId.cc:96
static uint32_t init(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:264
bool isME41() const
Definition: CSCDetId.cc:71
uint32_t id_
Definition: DetId.h:69
std::string layerName() const
Definition: CSCDetId.cc:94
int endcap() const
Definition: CSCDetId.h:85
static int chamber(int index)
Definition: CSCDetId.h:162
static const int kDetOffset
Definition: DetId.h:21
bool isME42() const
Definition: CSCDetId.cc:72
static int detIdToInt(int iring)
Definition: CSCDetId.h:291
int triggerSector() const
Definition: CSCDetId.cc:3
int ring() const
Definition: CSCDetId.h:68
static constexpr int CSC
Definition: MuonSubdetId.h:12
static int maxLayerId()
Definition: CSCDetId.h:243
static int layer(int index)
Definition: CSCDetId.h:156
bool isME13() const
Definition: CSCDetId.cc:66