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 
31 
35 
36 #ifndef EDM_ML_DEBUG
37 
40  CSCDetId(uint32_t id) : DetId(id) {}
41  CSCDetId(DetId id) : DetId(id) {}
42 
43 
48  CSCDetId( int iendcap, int istation,
49  int iring, int ichamber,
50  int ilayer = 0 ) : DetId(DetId::Muon, MuonSubdetId::CSC) {
51  id_ |= init(iendcap, istation, iring, ichamber, ilayer);
52  }
53 
54 #else
55 
56  CSCDetId(uint32_t id);
57  CSCDetId(DetId id);
58  CSCDetId( int iendcap, int istation,
59  int iring, int ichamber,
60  int ilayer = 0 );
61 
62 #endif
63 
66  CSCDetId chamberId() const {
67  // build chamber id by removing layer bits
68  return CSCDetId( id_ - layer() ) ; }
69 
74  int layer() const {
75  return (id_ & MASK_LAYER); }
76 
81  int chamber() const {
82  return ( (id_>>START_CHAMBER) & MASK_CHAMBER ); }
83 
88  int ring() const {
89  if (((id_>>START_STATION) & MASK_STATION) == 1)
90  return ( detIdToInt((id_>>START_RING) & MASK_RING ));
91  else
92  return (((id_>>START_RING) & MASK_RING ));
93  }
94 
99  int station() const {
100  return ( (id_>>START_STATION) & MASK_STATION ); }
101 
106  int endcap() const {
107  return ( (id_>>START_ENDCAP) & MASK_ENDCAP ); }
108 
113  short int zendcap() const {
114  return ( endcap()!=1 ? -1 : +1 );
115  }
116 
120  unsigned short iChamberType() {
121  return iChamberType( station(), ring() );
122  }
123 
131  int channel( int istrip ) {
132  if ( ring()== 4 )
133  // strips 1-48 mapped to channels 1-16:
134  // 1+17+33->1, 2+18+34->2, .... 16+32+48->16
135  return 1 + (istrip-1)%16;
136  else
137  return istrip;
138  }
139 
140  // static methods
141  // Used when we need information about subdetector labels.
142 
157  static int rawIdMaker( int iendcap, int istation, int iring,
158  int ichamber, int ilayer ) {
159  return ( (DetId::Muon&0xF)<<(DetId::kDetOffset) ) | // set Muon flag
160  ( (MuonSubdetId::CSC&0x7)<<(DetId::kSubdetOffset) ) | // set CSC flag
161  init(iendcap, istation, iring, ichamber, ilayer) ; } // set CSC id
162 
167  static int layer( int index ) {
168  return (index & MASK_LAYER); }
169 
174  static int chamber( int index ) {
175  return ( (index>>START_CHAMBER) & MASK_CHAMBER ); }
176 
181  static int ring( int index ) {
182  if (((index>>START_STATION) & MASK_STATION) == 1)
183  return ( detIdToInt((index>>START_RING) & MASK_RING ));
184  else
185  return (( index>>START_RING) & MASK_RING );
186  }
187 
192  static int station( int index ) {
193  return ( (index>>START_STATION) & MASK_STATION ); }
194 
199  static int endcap( int index ) {
200  return ( (index>>START_ENDCAP) & MASK_ENDCAP ); }
201 
208  static unsigned short iChamberType( unsigned short istation, unsigned short iring );
209 
229  int triggerSector() const;
230 
244  int triggerCscId() const;
245 
249  static int minEndcapId() { return MIN_ENDCAP; }
250  static int maxEndcapId() { return MAX_ENDCAP; }
251  static int minStationId() { return MIN_STATION; }
252  static int maxStationId() { return MAX_STATION; }
253  static int minRingId() { return MIN_RING; }
254  static int maxRingId() { return MAX_RING; }
255  static int minChamberId() { return MIN_CHAMBER; }
256  static int maxChamberId() { return MAX_CHAMBER; }
257  static int minLayerId() { return MIN_LAYER; }
258  static int maxLayerId() { return MAX_LAYER; }
259 
260 private:
261 
266  static uint32_t init( int iendcap, int istation,
267  int iring, int ichamber, int ilayer ) {
268 
269  if (istation == 1)
270  iring = intToDetId(iring);
271 
272  return
273  (ilayer & MASK_LAYER) |
274  ( (ichamber & MASK_CHAMBER) << START_CHAMBER ) |
275  ( (iring & MASK_RING) << START_RING ) |
276  ( (istation & MASK_STATION) << START_STATION ) |
277  ( (iendcap & MASK_ENDCAP) << START_ENDCAP ) ; }
278 
289  static int intToDetId(int iring) {
290  // change iring = 1, 2, 3, 4 input to 2, 3, 4, 1 for use inside the DetId
291  // i.e. ME1b, ME12, ME13, ME1a externally become stored internally in order ME1a, ME1b, ME12, ME13
292  int i = (iring+1)%4;
293  if (i == 0) i = 4;
294  return i;
295  }
296 
297  static int detIdToInt(int iring) {
298  // reverse intToDetId: change 1, 2, 3, 4 inside the DetId to 4, 1, 2, 3 for external use
299  // i.e. output ring # 1, 2, 3, 4 in ME1 means ME1b, ME12, ME13, ME1a as usual in the offline software.
300  int i = (iring-1);
301  if (i == 0) i = 4;
302  return i;
303  }
304 
305  // The following define the bit-packing implementation...
306 
307  // The maximum numbers of various parts
309  // We count from 1
311 
312  // BITS_det is no. of binary bits required to label 'det' but allow 0 as a wild-card character
313  // Keep as multiples of 3 so that number can be easily decodable from octal
315 
316  // MASK_det is binary bits set to pick off the bits for 'det' (defined as octal)
318 
319  // START_det is bit position (counting from zero) at which bits for 'det' start in 'rawId' word
322 };
323 
324 #endif
325 
326 
int chamber() const
Definition: CSCDetId.h:81
static int endcap(int index)
Definition: CSCDetId.h:199
int i
Definition: DBlmapReader.cc:9
static int minRingId()
Definition: CSCDetId.h:253
static int minEndcapId()
Definition: CSCDetId.h:249
CSCDetId(DetId id)
Definition: CSCDetId.h:41
static int rawIdMaker(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:157
static const int kSubdetOffset
Definition: DetId.h:21
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
CSCDetId()
Definition: CSCDetId.h:34
static int maxStationId()
Definition: CSCDetId.h:252
static int maxRingId()
Definition: CSCDetId.h:254
int layer() const
Definition: CSCDetId.h:74
CSCDetId(uint32_t id)
Definition: CSCDetId.h:40
static int minChamberId()
Definition: CSCDetId.h:255
static int station(int index)
Definition: CSCDetId.h:192
eStartBitDet
Definition: CSCDetId.h:320
int endcap() const
Definition: CSCDetId.h:106
static int ring(int index)
Definition: CSCDetId.h:181
static int intToDetId(int iring)
Definition: CSCDetId.h:289
static const int CSC
Definition: MuonSubdetId.h:13
int channel(int istrip)
Definition: CSCDetId.h:131
static int minStationId()
Definition: CSCDetId.h:251
static int maxEndcapId()
Definition: CSCDetId.h:250
CSCDetId chamberId() const
Definition: CSCDetId.h:66
CSCDetId(int iendcap, int istation, int iring, int ichamber, int ilayer=0)
Definition: CSCDetId.h:48
unsigned short iChamberType()
Definition: CSCDetId.h:120
int ring() const
Definition: CSCDetId.h:88
Definition: DetId.h:18
short int zendcap() const
Definition: CSCDetId.h:113
static int minLayerId()
Definition: CSCDetId.h:257
static int maxChamberId()
Definition: CSCDetId.h:256
static uint32_t init(int iendcap, int istation, int iring, int ichamber, int ilayer)
Definition: CSCDetId.h:266
uint32_t id_
Definition: DetId.h:55
</a ></td >< td >< ahref="RecoLocalMuon_CSCRecHit.html"> csc2DRecHits</a ></td >< tdclass="description"> CSC(x, y) rechits</td >< td >T.Cox</td ></tr >< tr >< td >< a href
int triggerSector() const
Definition: CSCDetId.cc:47
int triggerCscId() const
Definition: CSCDetId.cc:67
static int chamber(int index)
Definition: CSCDetId.h:174
static const int kDetOffset
Definition: DetId.h:20
static int detIdToInt(int iring)
Definition: CSCDetId.h:297
int station() const
Definition: CSCDetId.h:99
static int maxLayerId()
Definition: CSCDetId.h:258
static int layer(int index)
Definition: CSCDetId.h:167