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;
252 
253 private:
258  static uint32_t init(int iendcap, int istation, int iring, int ichamber, int ilayer) {
259  if (istation == 1)
260  iring = intToDetId(iring);
261 
262  return (ilayer & MASK_LAYER) | ((ichamber & MASK_CHAMBER) << START_CHAMBER) | ((iring & MASK_RING) << START_RING) |
263  ((istation & MASK_STATION) << START_STATION) | ((iendcap & MASK_ENDCAP) << START_ENDCAP);
264  }
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)
281  i = 4;
282  return i;
283  }
284 
285  static int detIdToInt(int iring) {
286  // reverse intToDetId: change 1, 2, 3, 4 inside the DetId to 4, 1, 2, 3 for external use
287  // i.e. output ring # 1, 2, 3, 4 in ME1 means ME1b, ME12, ME13, ME1a as usual in the offline software.
288  int i = (iring - 1);
289  if (i == 0)
290  i = 4;
291  return i;
292  }
293 
294  // The following define the bit-packing implementation...
295 
296  // The maximum numbers of various parts
297  enum eMaxNum { MAX_ENDCAP = 2, MAX_STATION = 4, MAX_RING = 4, MAX_CHAMBER = 36, MAX_LAYER = 6 };
298  // We count from 1
299  enum eMinNum { MIN_ENDCAP = 1, MIN_STATION = 1, MIN_RING = 1, MIN_CHAMBER = 1, MIN_LAYER = 1 };
300 
301  // BITS_det is no. of binary bits required to label 'det' but allow 0 as a wild-card character
302  // Keep as multiples of 3 so that number can be easily decodable from octal
304 
305  // MASK_det is binary bits set to pick off the bits for 'det' (defined as octal)
306  enum eMaskBitDet { MASK_ENDCAP = 07, MASK_STATION = 07, MASK_RING = 07, MASK_CHAMBER = 077, MASK_LAYER = 07 };
307 
308  // START_det is bit position (counting from zero) at which bits for 'det' start in 'rawId' word
314  };
315 };
316 
317 #endif
CSCDetId::BITS_CHAMBER
Definition: CSCDetId.h:303
CSCDetId::maxStationId
static int maxStationId()
Definition: CSCDetId.h:237
MuonSubdetId::CSC
static constexpr int CSC
Definition: MuonSubdetId.h:12
mps_fire.i
i
Definition: mps_fire.py:428
CSCDetId::MAX_ENDCAP
Definition: CSCDetId.h:297
CSCDetId::detIdToInt
static int detIdToInt(int iring)
Definition: CSCDetId.h:285
CSCDetId::CSCDetId
CSCDetId(DetId id)
Definition: CSCDetId.h:35
CSCDetId::BITS_ENDCAP
Definition: CSCDetId.h:303
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
CSCDetId::zendcap
short int zendcap() const
Definition: CSCDetId.h:91
CSCDetId::isME32
bool isME32() const
Definition: CSCDetId.cc:70
CSCDetId::isME31
bool isME31() const
Definition: CSCDetId.cc:69
CSCDetId::eMinNum
eMinNum
Definition: CSCDetId.h:299
CSCDetId::CSCDetId
CSCDetId()
Definition: CSCDetId.h:30
CSCDetId::ring
static int ring(int index)
Definition: CSCDetId.h:168
CSCDetId::rawIdMaker
static int rawIdMaker(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:146
CSCDetId::minChamberId
static int minChamberId()
Definition: CSCDetId.h:240
CSCDetId::isME22
bool isME22() const
Definition: CSCDetId.cc:68
CSCDetId::isME1a
bool isME1a() const
Definition: CSCDetId.cc:62
CSCDetId::MASK_CHAMBER
Definition: CSCDetId.h:306
CSCDetId::iChamberType
unsigned short iChamberType() const
Definition: CSCDetId.h:96
CSCDetId::START_ENDCAP
Definition: CSCDetId.h:313
CSCDetId::endcap
static int endcap(int index)
Definition: CSCDetId.h:185
CSCDetId::isME12
bool isME12() const
Definition: CSCDetId.cc:65
CSCDetId::station
static int station(int index)
Definition: CSCDetId.h:179
Muon
Definition: Muon.py:1
CSCDetId::channel
int channel(int istrip)
Definition: CSCDetId.h:105
CSCDetId::minStationId
static int minStationId()
Definition: CSCDetId.h:236
DetId::kSubdetOffset
static const int kSubdetOffset
Definition: DetId.h:22
DetId
Definition: DetId.h:17
CSCDetId::BITS_STATION
Definition: CSCDetId.h:303
CSCDetId::triggerCscId
int triggerCscId() const
Definition: CSCDetId.cc:22
CSCDetId::eMaxNum
eMaxNum
Definition: CSCDetId.h:297
CSCDetId::minEndcapId
static int minEndcapId()
Definition: CSCDetId.h:234
CSCDetId::CSCDetId
CSCDetId(uint32_t id)
Definition: CSCDetId.h:34
CSCDetId::eMaskBitDet
eMaskBitDet
Definition: CSCDetId.h:306
CSCDetId::maxRingId
static int maxRingId()
Definition: CSCDetId.h:239
CSCDetId::layer
int layer() const
Definition: CSCDetId.h:56
CSCDetId::MIN_STATION
Definition: CSCDetId.h:299
GeomDetEnumerators::CSC
Definition: GeomDetEnumerators.h:17
CSCDetId::START_STATION
Definition: CSCDetId.h:312
CSCDetId::BITS_LAYER
Definition: CSCDetId.h:303
CSCDetId::minLayerId
static int minLayerId()
Definition: CSCDetId.h:242
CSCDetId::triggerSector
int triggerSector() const
Definition: CSCDetId.cc:3
CSCDetId::intToDetId
static int intToDetId(int iring)
Definition: CSCDetId.h:276
CSCDetId::eNumBitDet
eNumBitDet
Definition: CSCDetId.h:303
CSCDetId::BITS_RING
Definition: CSCDetId.h:303
DetId::id_
uint32_t id_
Definition: DetId.h:69
CSCDetId::MASK_ENDCAP
Definition: CSCDetId.h:306
CSCDetId
Definition: CSCDetId.h:26
CSCDetId::MIN_LAYER
Definition: CSCDetId.h:299
CSCDetId::maxChamberId
static int maxChamberId()
Definition: CSCDetId.h:241
CSCDetId::MASK_LAYER
Definition: CSCDetId.h:306
CSCDetId::isME21
bool isME21() const
Definition: CSCDetId.cc:67
CSCDetId::chamberId
CSCDetId chamberId() const
Definition: CSCDetId.h:47
CSCDetId::MAX_CHAMBER
Definition: CSCDetId.h:297
CSCDetId::chamber
int chamber() const
Definition: CSCDetId.h:62
CSCDetId::maxEndcapId
static int maxEndcapId()
Definition: CSCDetId.h:235
CSCDetId::START_RING
Definition: CSCDetId.h:311
CSCDetId::init
static uint32_t init(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:258
MuonSubdetId.h
CSCDetId::isME41
bool isME41() const
Definition: CSCDetId.cc:71
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CSCDetId::eStartBitDet
eStartBitDet
Definition: CSCDetId.h:309
CSCDetId::isME1b
bool isME1b() const
Definition: CSCDetId.cc:63
DetId::kDetOffset
static const int kDetOffset
Definition: DetId.h:21
CSCDetId::MIN_ENDCAP
Definition: CSCDetId.h:299
CSCDetId::MAX_LAYER
Definition: CSCDetId.h:297
CSCDetId::CSCDetId
CSCDetId(int iendcap, int istation, int iring, int ichamber, int ilayer=0)
Definition: CSCDetId.h:41
DetId.h
CSCDetId::MASK_RING
Definition: CSCDetId.h:306
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:29
CSCDetId::endcap
int endcap() const
Definition: CSCDetId.h:85
CSCDetId::chamberName
std::string chamberName() const
Definition: CSCDetId.cc:86
CSCDetId::maxLayerId
static int maxLayerId()
Definition: CSCDetId.h:243
operator<<
std::ostream & operator<<(std::ostream &os, const CSCDetId &id)
Definition: CSCDetId.cc:88
CSCDetId::layer
static int layer(int index)
Definition: CSCDetId.h:156
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
CSCDetId::MAX_STATION
Definition: CSCDetId.h:297
CSCDetId::isME11
bool isME11() const
Definition: CSCDetId.cc:64
CSCDetId::isME13
bool isME13() const
Definition: CSCDetId.cc:66
CSCDetId::chamber
static int chamber(int index)
Definition: CSCDetId.h:162
CSCDetId::isME42
bool isME42() const
Definition: CSCDetId.cc:72
DetId::Muon
Definition: DetId.h:26
CSCDetId::MIN_RING
Definition: CSCDetId.h:299
CSCDetId::station
int station() const
Definition: CSCDetId.h:79
CSCDetId::MAX_RING
Definition: CSCDetId.h:297
MuonSubdetId
Definition: MuonSubdetId.h:9
CSCDetId::MASK_STATION
Definition: CSCDetId.h:306
CSCDetId::START_CHAMBER
Definition: CSCDetId.h:310
CSCDetId::minRingId
static int minRingId()
Definition: CSCDetId.h:238
CSCDetId::MIN_CHAMBER
Definition: CSCDetId.h:299