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 
114  // static methods
115  // Used when we need information about subdetector labels.
116 
131  static int rawIdMaker(int iendcap, int istation, int iring, int ichamber, int ilayer) {
132  return ((DetId::Muon & 0xF) << (DetId::kDetOffset)) | // set Muon flag
133  ((MuonSubdetId::CSC & 0x7) << (DetId::kSubdetOffset)) | // set CSC flag
134  init(iendcap, istation, iring, ichamber, ilayer);
135  } // set CSC id
136 
141  static int layer(int index) { return (index & MASK_LAYER); }
142 
147  static int chamber(int index) { return ((index >> START_CHAMBER) & MASK_CHAMBER); }
148 
153  static int ring(int index) {
154  if (((index >> START_STATION) & MASK_STATION) == 1)
155  return (detIdToInt((index >> START_RING) & MASK_RING));
156  else
157  return ((index >> START_RING) & MASK_RING);
158  }
159 
164  static int station(int index) { return ((index >> START_STATION) & MASK_STATION); }
165 
170  static int endcap(int index) { return ((index >> START_ENDCAP) & MASK_ENDCAP); }
171 
178  static unsigned short iChamberType(unsigned short istation, unsigned short iring);
179 
199  int triggerSector() const;
200 
214  int triggerCscId() const;
215 
219  static int minEndcapId() { return MIN_ENDCAP; }
220  static int maxEndcapId() { return MAX_ENDCAP; }
221  static int minStationId() { return MIN_STATION; }
222  static int maxStationId() { return MAX_STATION; }
223  static int minRingId() { return MIN_RING; }
224  static int maxRingId() { return MAX_RING; }
225  static int minChamberId() { return MIN_CHAMBER; }
226  static int maxChamberId() { return MAX_CHAMBER; }
227  static int minLayerId() { return MIN_LAYER; }
228  static int maxLayerId() { return MAX_LAYER; }
229 
234  static std::string chamberName(int endcap, int station, int ring, int chamber);
235  std::string chamberName() const;
236 
237 private:
242  static uint32_t init(int iendcap, int istation, int iring, int ichamber, int ilayer) {
243  if (istation == 1)
244  iring = intToDetId(iring);
245 
246  return (ilayer & MASK_LAYER) | ((ichamber & MASK_CHAMBER) << START_CHAMBER) | ((iring & MASK_RING) << START_RING) |
247  ((istation & MASK_STATION) << START_STATION) | ((iendcap & MASK_ENDCAP) << START_ENDCAP);
248  }
249 
260  static int intToDetId(int iring) {
261  // change iring = 1, 2, 3, 4 input to 2, 3, 4, 1 for use inside the DetId
262  // i.e. ME1b, ME12, ME13, ME1a externally become stored internally in order ME1a, ME1b, ME12, ME13
263  int i = (iring + 1) % 4;
264  if (i == 0)
265  i = 4;
266  return i;
267  }
268 
269  static int detIdToInt(int iring) {
270  // reverse intToDetId: change 1, 2, 3, 4 inside the DetId to 4, 1, 2, 3 for external use
271  // i.e. output ring # 1, 2, 3, 4 in ME1 means ME1b, ME12, ME13, ME1a as usual in the offline software.
272  int i = (iring - 1);
273  if (i == 0)
274  i = 4;
275  return i;
276  }
277 
278  // The following define the bit-packing implementation...
279 
280  // The maximum numbers of various parts
281  enum eMaxNum { MAX_ENDCAP = 2, MAX_STATION = 4, MAX_RING = 4, MAX_CHAMBER = 36, MAX_LAYER = 6 };
282  // We count from 1
283  enum eMinNum { MIN_ENDCAP = 1, MIN_STATION = 1, MIN_RING = 1, MIN_CHAMBER = 1, MIN_LAYER = 1 };
284 
285  // BITS_det is no. of binary bits required to label 'det' but allow 0 as a wild-card character
286  // Keep as multiples of 3 so that number can be easily decodable from octal
288 
289  // MASK_det is binary bits set to pick off the bits for 'det' (defined as octal)
290  enum eMaskBitDet { MASK_ENDCAP = 07, MASK_STATION = 07, MASK_RING = 07, MASK_CHAMBER = 077, MASK_LAYER = 07 };
291 
292  // START_det is bit position (counting from zero) at which bits for 'det' start in 'rawId' word
298  };
299 };
300 
301 #endif
CSCDetId::BITS_CHAMBER
Definition: CSCDetId.h:287
CSCDetId::maxStationId
static int maxStationId()
Definition: CSCDetId.h:222
MuonSubdetId::CSC
static constexpr int CSC
Definition: MuonSubdetId.h:12
mps_fire.i
i
Definition: mps_fire.py:355
CSCDetId::MAX_ENDCAP
Definition: CSCDetId.h:281
CSCDetId::detIdToInt
static int detIdToInt(int iring)
Definition: CSCDetId.h:269
CSCDetId::CSCDetId
CSCDetId(DetId id)
Definition: CSCDetId.h:35
CSCDetId::BITS_ENDCAP
Definition: CSCDetId.h:287
CSCDetId::ring
int ring() const
Definition: CSCDetId.h:68
CSCDetId::zendcap
short int zendcap() const
Definition: CSCDetId.h:91
CSCDetId::eMinNum
eMinNum
Definition: CSCDetId.h:283
CSCDetId::CSCDetId
CSCDetId()
Definition: CSCDetId.h:30
CSCDetId::ring
static int ring(int index)
Definition: CSCDetId.h:153
CSCDetId::rawIdMaker
static int rawIdMaker(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:131
CSCDetId::minChamberId
static int minChamberId()
Definition: CSCDetId.h:225
CSCDetId::MASK_CHAMBER
Definition: CSCDetId.h:290
CSCDetId::iChamberType
unsigned short iChamberType() const
Definition: CSCDetId.h:96
CSCDetId::START_ENDCAP
Definition: CSCDetId.h:297
CSCDetId::endcap
static int endcap(int index)
Definition: CSCDetId.h:170
CSCDetId::station
static int station(int index)
Definition: CSCDetId.h:164
Muon
Definition: Muon.py:1
CSCDetId::channel
int channel(int istrip)
Definition: CSCDetId.h:105
CSCDetId::minStationId
static int minStationId()
Definition: CSCDetId.h:221
DetId::kSubdetOffset
static const int kSubdetOffset
Definition: DetId.h:22
DetId
Definition: DetId.h:17
CSCDetId::BITS_STATION
Definition: CSCDetId.h:287
CSCDetId::triggerCscId
int triggerCscId() const
Definition: CSCDetId.cc:22
CSCDetId::eMaxNum
eMaxNum
Definition: CSCDetId.h:281
CSCDetId::minEndcapId
static int minEndcapId()
Definition: CSCDetId.h:219
CSCDetId::CSCDetId
CSCDetId(uint32_t id)
Definition: CSCDetId.h:34
CSCDetId::eMaskBitDet
eMaskBitDet
Definition: CSCDetId.h:290
CSCDetId::maxRingId
static int maxRingId()
Definition: CSCDetId.h:224
CSCDetId::layer
int layer() const
Definition: CSCDetId.h:56
CSCDetId::MIN_STATION
Definition: CSCDetId.h:283
GeomDetEnumerators::CSC
Definition: GeomDetEnumerators.h:17
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
CSCDetId::START_STATION
Definition: CSCDetId.h:296
CSCDetId::BITS_LAYER
Definition: CSCDetId.h:287
CSCDetId::minLayerId
static int minLayerId()
Definition: CSCDetId.h:227
CSCDetId::triggerSector
int triggerSector() const
Definition: CSCDetId.cc:3
CSCDetId::intToDetId
static int intToDetId(int iring)
Definition: CSCDetId.h:260
CSCDetId::eNumBitDet
eNumBitDet
Definition: CSCDetId.h:287
CSCDetId::BITS_RING
Definition: CSCDetId.h:287
DetId::id_
uint32_t id_
Definition: DetId.h:69
CSCDetId::MASK_ENDCAP
Definition: CSCDetId.h:290
CSCDetId
Definition: CSCDetId.h:26
CSCDetId::MIN_LAYER
Definition: CSCDetId.h:283
CSCDetId::maxChamberId
static int maxChamberId()
Definition: CSCDetId.h:226
CSCDetId::MASK_LAYER
Definition: CSCDetId.h:290
CSCDetId::chamberId
CSCDetId chamberId() const
Definition: CSCDetId.h:47
CSCDetId::MAX_CHAMBER
Definition: CSCDetId.h:281
CSCDetId::chamber
int chamber() const
Definition: CSCDetId.h:62
CSCDetId::maxEndcapId
static int maxEndcapId()
Definition: CSCDetId.h:220
CSCDetId::START_RING
Definition: CSCDetId.h:295
CSCDetId::init
static uint32_t init(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:242
MuonSubdetId.h
CSCDetId::eStartBitDet
eStartBitDet
Definition: CSCDetId.h:293
DetId::kDetOffset
static const int kDetOffset
Definition: DetId.h:21
CSCDetId::MIN_ENDCAP
Definition: CSCDetId.h:283
CSCDetId::MAX_LAYER
Definition: CSCDetId.h:281
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:290
triggerObjects_cff.id
id
Definition: triggerObjects_cff.py:31
CSCDetId::endcap
int endcap() const
Definition: CSCDetId.h:85
CSCDetId::chamberName
std::string chamberName() const
Definition: CSCDetId.cc:67
CSCDetId::maxLayerId
static int maxLayerId()
Definition: CSCDetId.h:228
operator<<
std::ostream & operator<<(std::ostream &os, const CSCDetId &id)
Definition: CSCDetId.cc:69
CSCDetId::layer
static int layer(int index)
Definition: CSCDetId.h:141
AlignmentPI::index
index
Definition: AlignmentPayloadInspectorHelper.h:46
CSCDetId::MAX_STATION
Definition: CSCDetId.h:281
CSCDetId::chamber
static int chamber(int index)
Definition: CSCDetId.h:147
DetId::Muon
Definition: DetId.h:26
CSCDetId::MIN_RING
Definition: CSCDetId.h:283
CSCDetId::station
int station() const
Definition: CSCDetId.h:79
CSCDetId::MAX_RING
Definition: CSCDetId.h:281
MuonSubdetId
Definition: MuonSubdetId.h:9
CSCDetId::MASK_STATION
Definition: CSCDetId.h:290
CSCDetId::START_CHAMBER
Definition: CSCDetId.h:294
CSCDetId::minRingId
static int minRingId()
Definition: CSCDetId.h:223
CSCDetId::MIN_CHAMBER
Definition: CSCDetId.h:283