CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC2/src/DataFormats/MuonDetId/interface/GEMDetId.h

Go to the documentation of this file.
00001 #ifndef MuonDetId_GEMDetId_h
00002 #define MuonDetId_GEMDetId_h
00003 
00010 #include <DataFormats/DetId/interface/DetId.h>
00011 #include <FWCore/Utilities/interface/Exception.h>
00012 
00013 #include <iosfwd>
00014 #include <iostream>
00015 
00016 class GEMDetId :public DetId {
00017   
00018  public:
00019       
00020   GEMDetId();
00021 
00024   GEMDetId(uint32_t id);
00025   GEMDetId(DetId id);
00026 
00027 
00029   GEMDetId(int region, 
00030            int ring,
00031            int station, 
00032            int layer,
00033            int chamber,
00034            int roll);
00035            
00036 
00038   bool operator < (const GEMDetId& r) const{
00039     if (r.station() == this->station()  ){
00040       if (this->layer() ==  r.layer()  ){
00041         return this->rawId()<r.rawId();
00042       }
00043       else{
00044         return (this->layer() < r.layer());
00045       }
00046     }
00047     else {
00048       return this->station() < r.station();
00049     }
00050   }
00051 
00053   int region() const{
00054     return int((id_>>RegionStartBit_) & RegionMask_) + minRegionId;
00055   }
00056 
00059   int ring() const{
00060       return int((id_>>RingStartBit_) & RingMask_) + minRingId;
00061   }
00062 
00064   int station() const{
00065     return int((id_>>StationStartBit_) & StationMask_) + minStationId;
00066   }
00067 
00069   int layer() const{
00070     return int((id_>>LayerStartBit_) & LayerMask_) + minLayerId;
00071   }
00072 
00074   int chamber() const{
00075     return int((id_>>ChamberStartBit_) & ChamberMask_) + (minChamberId+1);
00076   }
00077 
00080   int roll() const{
00081     return int((id_>>RollStartBit_) & RollMask_); // value 0 is used as wild card
00082   }
00083 
00084 
00086   GEMDetId chamberId() const {
00087     return GEMDetId(id_ & chamberIdMask_);
00088   }
00089 
00090   static const int minRegionId=     -1;
00091   static const int maxRegionId=      1;
00092  
00093   static const int minRingId=   1;
00094   static const int maxRingId=   3;
00095 
00096   static const int minStationId=     1;
00097   static const int maxStationId=     4;
00098 
00099   static const int minChamberId=     0;
00100   static const int maxChamberId=     36;
00101 
00102   static const int minLayerId=     1;
00103   static const int maxLayerId=     2;
00104 
00105   static const int minRollId=     0;
00106   static const int maxRollId=    15;
00107 
00108  private:
00109   static const int RegionNumBits_  =  2;
00110   static const int RegionStartBit_ =  0;  
00111   static const int RegionMask_     =  0X3;
00112 
00113   static const int RingNumBits_  =  3;
00114   static const int RingStartBit_ =  RegionStartBit_+RegionNumBits_;  
00115   static const unsigned int RingMask_     =  0X7;
00116 
00117   static const int StationNumBits_  =  3;
00118   static const int StationStartBit_ =  RingStartBit_+RingNumBits_;  
00119   static const unsigned int StationMask_     =  0X7;
00120 
00121 
00122   static const int ChamberNumBits_  =  6;
00123   static const int ChamberStartBit_ =  StationStartBit_+StationNumBits_;  
00124   static const unsigned int ChamberMask_     =  0X3F;
00125 
00126   static const int LayerNumBits_  =  1;
00127   static const int LayerStartBit_ =  ChamberStartBit_+ChamberNumBits_;  
00128   static const unsigned int LayerMask_     =  0X1;
00129 
00130   static const int RollNumBits_  =  5;
00131   static const int RollStartBit_ =  LayerStartBit_+LayerNumBits_;  
00132   static const unsigned int RollMask_     =  0X1F;
00133  
00134   static const uint32_t chamberIdMask_ = ~(RollMask_<<RollStartBit_);
00135 
00136  private:
00137   void init(int region, 
00138             int ring,
00139             int station, 
00140             int layer,
00141             int chamber,
00142             int roll);
00143   
00144   int trind;
00145 }; // GEMDetId
00146 
00147 std::ostream& operator<<( std::ostream& os, const GEMDetId& id );
00148 
00149 #endif