CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CSCDetId.h
Go to the documentation of this file.
1 #ifndef MuonDetId_CSCDetId_h
2 #define MuonDetId_CSCDetId_h
3 
19 #include <iosfwd>
22 
23 class CSCDetId;
24 
25 std::ostream& operator<<( std::ostream& os, const CSCDetId& id );
26 
27 class CSCDetId : public DetId {
28 
29 public:
30 
33  CSCDetId();
34 
37  CSCDetId(uint32_t id);
38  CSCDetId(DetId id);
39 
44  CSCDetId( int iendcap, int istation,
45  int iring, int ichamber,
46  int ilayer = 0 );
47 
50  CSCDetId( const CSCDetId& id )
51  : DetId(id.id_) { }
52 
55  CSCDetId chamberId() const {
56  // build chamber id by removing layer bits
57  return CSCDetId( id_ - layer() ) ; }
58 
63  int layer() const {
64  return (id_ & MASK_LAYER); }
65 
70  int chamber() const {
71  return ( (id_>>START_CHAMBER) & MASK_CHAMBER ); }
72 
77  int ring() const {
78  if (((id_>>START_STATION) & MASK_STATION) == 1)
79  return ( detIdToInt((id_>>START_RING) & MASK_RING ));
80  else
81  return (((id_>>START_RING) & MASK_RING ));
82  }
83 
88  int station() const {
89  return ( (id_>>START_STATION) & MASK_STATION ); }
90 
95  int endcap() const {
96  return ( (id_>>START_ENDCAP) & MASK_ENDCAP ); }
97 
102  short int zendcap() const {
103  return ( endcap()!=1 ? -1 : +1 );
104  }
105 
109  unsigned short iChamberType() {
110  return iChamberType( station(), ring() );
111  }
112 
120  int channel( int istrip ) {
121  if ( ring()== 4 )
122  // strips 1-48 mapped to channels 1-16:
123  // 1+17+33->1, 2+18+34->2, .... 16+32+48->16
124  return 1 + (istrip-1)%16;
125  else
126  return istrip;
127  }
128 
129  // static methods
130  // Used when we need information about subdetector labels.
131 
146  static int rawIdMaker( int iendcap, int istation, int iring,
147  int ichamber, int ilayer ) {
148  return ( (DetId::Muon&0xF)<<(DetId::kDetOffset) ) | // set Muon flag
149  ( (MuonSubdetId::CSC&0x7)<<(DetId::kSubdetOffset) ) | // set CSC flag
150  init(iendcap, istation, iring, ichamber, ilayer) ; } // set CSC id
151 
156  static int layer( int index ) {
157  return (index & MASK_LAYER); }
158 
163  static int chamber( int index ) {
164  return ( (index>>START_CHAMBER) & MASK_CHAMBER ); }
165 
170  static int ring( int index ) {
171  if (((index>>START_STATION) & MASK_STATION) == 1)
172  return ( detIdToInt((index>>START_RING) & MASK_RING ));
173  else
174  return (( index>>START_RING) & MASK_RING );
175  }
176 
181  static int station( int index ) {
182  return ( (index>>START_STATION) & MASK_STATION ); }
183 
188  static int endcap( int index ) {
189  return ( (index>>START_ENDCAP) & MASK_ENDCAP ); }
190 
197  static unsigned short iChamberType( unsigned short istation, unsigned short iring );
198 
218  int triggerSector() const;
219 
233  int triggerCscId() const;
234 
238  static int minEndcapId() { return MIN_ENDCAP; }
239  static int maxEndcapId() { return MAX_ENDCAP; }
240  static int minStationId() { return MIN_STATION; }
241  static int maxStationId() { return MAX_STATION; }
242  static int minRingId() { return MIN_RING; }
243  static int maxRingId() { return MAX_RING; }
244  static int minChamberId() { return MIN_CHAMBER; }
245  static int maxChamberId() { return MAX_CHAMBER; }
246  static int minLayerId() { return MIN_LAYER; }
247  static int maxLayerId() { return MAX_LAYER; }
248 
249 private:
250 
255  static uint32_t init( int iendcap, int istation,
256  int iring, int ichamber, int ilayer ) {
257 
258  if (istation == 1)
259  iring = intToDetId(iring);
260 
261  return
262  (ilayer & MASK_LAYER) |
263  ( (ichamber & MASK_CHAMBER) << START_CHAMBER ) |
264  ( (iring & MASK_RING) << START_RING ) |
265  ( (istation & MASK_STATION) << START_STATION ) |
266  ( (iendcap & MASK_ENDCAP) << START_ENDCAP ) ; }
267 
278  static int intToDetId(int iring) {
279  // change iring = 1, 2, 3, 4 input to 2, 3, 4, 1 for use inside the DetId
280  // i.e. ME1b, ME12, ME13, ME1a externally become stored internally in order ME1a, ME1b, ME12, ME13
281  int i = (iring+1)%4;
282  if (i == 0)
283  i = 4;
284  return i;
285  }
286 
287  static int detIdToInt(int iring) {
288  // reverse intToDetId: change 1, 2, 3, 4 inside the DetId to 4, 1, 2, 3 for external use
289  // i.e. output ring # 1, 2, 3, 4 in ME1 means ME1b, ME12, ME13, ME1a as usual in the offline software.
290  int i = (iring-1);
291  if (i == 0)
292  i = 4;
293  return i;
294  }
295 
296  // The following define the bit-packing implementation...
297 
298  // The maximum numbers of various parts
300  // We count from 1
302 
303  // BITS_det is no. of binary bits required to label 'det' but allow 0 as a wild-card character
304  // Keep as multiples of 3 so that number can be easily decodable from octal
306 
307  // MASK_det is binary bits set to pick off the bits for 'det' (defined as octal)
309 
310  // START_det is bit position (counting from zero) at which bits for 'det' start in 'rawId' word
313 };
314 
315 #endif
316 
317 
int chamber() const
Definition: CSCDetId.h:70
static int endcap(int index)
Definition: CSCDetId.h:188
int i
Definition: DBlmapReader.cc:9
static int minRingId()
Definition: CSCDetId.h:242
static int minEndcapId()
Definition: CSCDetId.h:238
static int rawIdMaker(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:146
static const int kSubdetOffset
Definition: DetId.h:23
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
CSCDetId()
Definition: CSCDetId.cc:5
static int maxStationId()
Definition: CSCDetId.h:241
static int maxRingId()
Definition: CSCDetId.h:243
int layer() const
Definition: CSCDetId.h:63
CSCDetId(const CSCDetId &id)
Definition: CSCDetId.h:50
static int minChamberId()
Definition: CSCDetId.h:244
static int station(int index)
Definition: CSCDetId.h:181
eStartBitDet
Definition: CSCDetId.h:311
int endcap() const
Definition: CSCDetId.h:95
static int ring(int index)
Definition: CSCDetId.h:170
static int intToDetId(int iring)
Definition: CSCDetId.h:278
static const int CSC
Definition: MuonSubdetId.h:15
int channel(int istrip)
Definition: CSCDetId.h:120
static int minStationId()
Definition: CSCDetId.h:240
static int maxEndcapId()
Definition: CSCDetId.h:239
CSCDetId chamberId() const
Definition: CSCDetId.h:55
unsigned short iChamberType()
Definition: CSCDetId.h:109
int ring() const
Definition: CSCDetId.h:77
Definition: DetId.h:20
short int zendcap() const
Definition: CSCDetId.h:102
static int minLayerId()
Definition: CSCDetId.h:246
static int maxChamberId()
Definition: CSCDetId.h:245
static uint32_t init(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:255
uint32_t id_
Definition: DetId.h:57
int triggerSector() const
Definition: CSCDetId.cc:47
int triggerCscId() const
Definition: CSCDetId.cc:67
static int chamber(int index)
Definition: CSCDetId.h:163
static const int kDetOffset
Definition: DetId.h:22
static int detIdToInt(int iring)
Definition: CSCDetId.h:287
int station() const
Definition: CSCDetId.h:88
static int maxLayerId()
Definition: CSCDetId.h:247
static int layer(int index)
Definition: CSCDetId.h:156