Go to the documentation of this file.00001 #ifndef MuonDetId_RPCDetId_h
00002 #define MuonDetId_RPCDetId_h
00003
00014 #include <DataFormats/DetId/interface/DetId.h>
00015 #include <FWCore/Utilities/interface/Exception.h>
00016
00017 #include <iosfwd>
00018 #include <iostream>
00019
00020 class RPCDetId :public DetId {
00021
00022 public:
00023
00024 RPCDetId();
00025
00028 RPCDetId(uint32_t id);
00029 RPCDetId(DetId id);
00030
00031
00033 RPCDetId(int region,
00034 int ring,
00035 int station,
00036 int sector,
00037 int layer,
00038 int subsector,
00039 int roll);
00040
00041
00043 bool operator < (const RPCDetId& r) const{
00044 if (r.station() == this->station() ){
00045 if (this->layer() == r.layer() ){
00046
00047 return this->rawId()<r.rawId();
00048 }
00049 else{
00050 return (this->layer() < r.layer());
00051 }
00052 }
00053 else {
00054 return this->station() < r.station();
00055 }
00056 }
00057
00058 void buildfromDB(int region, int ring, int layer, int sector,
00059 const std::string& subsector,
00060 const std::string& roll,
00061 const std::string& dbname);
00062
00064 void buildfromTrIndex(int trIndex);
00065
00067 int region() const{
00068 return int((id_>>RegionStartBit_) & RegionMask_) + minRegionId;
00069 }
00070
00071
00076 int ring() const{
00077
00078 int ring_= (id_>>RingStartBit_) & RingMask_;
00079
00080 if(ring_ <RingBarrelOffSet){
00081
00082 if(this->region() == 0)
00083 {
00084 throw cms::Exception("InvalidDetId") << "RPCDetId ctor:"
00085 << " Ring - Region Inconsistency, "
00086 << " region "<< this->region()
00087 << " ring "<<ring_
00088 << std::endl;
00089 }
00090
00091 return int(ring_ + minRingForwardId);
00092
00093 } else {
00094 return int(ring_ - RingBarrelOffSet + minRingBarrelId);
00095 }
00096 }
00097
00100 int station() const{
00101 return int((id_>>StationStartBit_) & StationMask_) + minStationId;
00102 }
00103
00104
00106 int sector() const{
00107 return int((id_>>SectorStartBit_) & SectorMask_) + (minSectorId+1);
00108 }
00109
00112 int layer() const{
00113 return int((id_>>LayerStartBit_) & LayerMask_) + minLayerId;
00114 }
00115
00116
00118 int subsector() const{
00119 return int((id_>>SubSectorStartBit_) & SubSectorMask_) + (minSubSectorId+1);
00120 }
00121
00124 int roll() const{
00125 return int((id_>>RollStartBit_) & RollMask_);
00126 }
00127
00128
00129 int trIndex() const{
00130 return trind;
00131 }
00132
00134 RPCDetId chamberId() const {
00135 return RPCDetId(id_ & chamberIdMask_);
00136 }
00137
00138
00139 static const int minRegionId= -1;
00140 static const int maxRegionId= 1;
00141
00142 static const int minRingForwardId= 1;
00143 static const int maxRingForwardId= 3;
00144 static const int minRingBarrelId= -2;
00145 static const int maxRingBarrelId= 2;
00146 static const int RingBarrelOffSet= 3;
00147
00148 static const int minStationId= 1;
00149 static const int maxStationId= 4;
00150
00151 static const int minSectorId= 0;
00152 static const int maxSectorId= 12;
00153 static const int minSectorBarrelId= 1;
00154 static const int maxSectorBarrelId= 12;
00155 static const int minSectorForwardId= 1;
00156 static const int maxSectorForwardId= 6;
00157
00158 static const int minLayerId= 1;
00159 static const int maxLayerId= 2;
00160
00161 static const int minSubSectorId= 0;
00162 static const int maxSubSectorId= 6;
00163 static const int minSubSectorBarrelId= 1;
00164 static const int maxSubSectorBarrelId= 4;
00165 static const int minSubSectorForwardId= 1;
00166 static const int maxSubSectorForwardId= 6;
00167
00168 static const int minRollId= 0;
00169 static const int maxRollId= 4;
00170
00171
00172 private:
00173 static const int RegionNumBits_ = 2;
00174 static const int RegionStartBit_ = 0;
00175 static const int RegionMask_ = 0X3;
00176
00177 static const int RingNumBits_ = 3;
00178 static const int RingStartBit_ = RegionStartBit_+RegionNumBits_;
00179 static const unsigned int RingMask_ = 0X7;
00180
00181 static const int StationNumBits_ = 2;
00182 static const int StationStartBit_ = RingStartBit_+RingNumBits_;
00183 static const unsigned int StationMask_ = 0X3;
00184
00185
00186 static const int SectorNumBits_ = 4;
00187 static const int SectorStartBit_ = StationStartBit_+StationNumBits_;
00188 static const unsigned int SectorMask_ = 0XF;
00189
00190 static const int LayerNumBits_ = 1;
00191 static const int LayerStartBit_ = SectorStartBit_+SectorNumBits_;
00192 static const unsigned int LayerMask_ = 0X1;
00193
00194 static const int SubSectorNumBits_ = 3;
00195 static const int SubSectorStartBit_ = LayerStartBit_+LayerNumBits_;
00196 static const unsigned int SubSectorMask_ = 0X7;
00197
00198 static const int RollNumBits_ = 3;
00199 static const int RollStartBit_ = SubSectorStartBit_+SubSectorNumBits_;
00200 static const unsigned int RollMask_ = 0X7;
00201
00202 static const uint32_t chamberIdMask_ = ~(RollMask_<<RollStartBit_);
00203
00204 private:
00205 void init(int region,
00206 int ring,
00207 int station,
00208 int sector,
00209 int layer,
00210 int subsector,
00211 int roll);
00212
00213 int trind;
00214 };
00215
00216 std::ostream& operator<<( std::ostream& os, const RPCDetId& id );
00217
00218 #endif