CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCDetId.h
Go to the documentation of this file.
1 #ifndef MuonDetId_RPCDetId_h
2 #define MuonDetId_RPCDetId_h
3 
16 
17 #include <iosfwd>
18 
19 class RPCDetId :public DetId {
20 
21  public:
22 
23  RPCDetId();
24 
27  RPCDetId(uint32_t id);
28  RPCDetId(DetId id);
29 
30 
32  RPCDetId(int region,
33  int ring,
34  int station,
35  int sector,
36  int layer,
37  int subsector,
38  int roll);
39 
40 
42  bool operator < (const RPCDetId& r) const{
43  if (r.station() == this->station() ){
44  if (this->layer() == r.layer() ){
45 
46  return this->rawId()<r.rawId();
47  }
48  else{
49  return (this->layer() < r.layer());
50  }
51  }
52  else {
53  return this->station() < r.station();
54  }
55  }
56 
57  void buildfromDB(int region, int ring, int layer, int sector,
58  const std::string& subsector,
59  const std::string& roll,
60  const std::string& dbname);
61 
63  void buildfromTrIndex(int trIndex);
64 
66  int region() const{
67  return int((id_>>RegionStartBit_) & RegionMask_) + minRegionId;
68  }
69 
70 
75  int ring() const{
76 
77  int ring_= (id_>>RingStartBit_) & RingMask_;
78 
79  if(ring_ <RingBarrelOffSet){
80 
81  if(this->region() == 0)
82  {
83  throw cms::Exception("InvalidDetId") << "RPCDetId ctor:"
84  << " Ring - Region Inconsistency, "
85  << " region "<< this->region()
86  << " ring "<<ring_
87  << std::endl;
88  }
89 
90  return int(ring_ + minRingForwardId);
91 
92  } else { // if(ring_ >= RingBarrelOffSet)
93  return int(ring_ - RingBarrelOffSet + minRingBarrelId);
94  }
95  }
96 
99  int station() const{
100  return int((id_>>StationStartBit_) & StationMask_) + minStationId;
101  }
102 
103 
105  int sector() const{
106  return int((id_>>SectorStartBit_) & SectorMask_) + (minSectorId+1);
107  }
108 
111  int layer() const{
112  return int((id_>>LayerStartBit_) & LayerMask_) + minLayerId;
113  }
114 
115 
117  int subsector() const{
118  return int((id_>>SubSectorStartBit_) & SubSectorMask_) + (minSubSectorId+1);
119  }
120 
123  int roll() const{
124  return int((id_>>RollStartBit_) & RollMask_); // value 0 is used as wild card
125  }
126 
127 
128  int trIndex() const{
129  return trind;
130  }
131 
133  RPCDetId chamberId() const {
134  return RPCDetId(id_ & chamberIdMask_);
135  }
136 
137 
138  static const int minRegionId= -1;
139  static const int maxRegionId= 1;
140 
141  static const int minRingForwardId= 1;
142  static const int maxRingForwardId= 3;
143  static const int minRingBarrelId= -2;
144  static const int maxRingBarrelId= 2;
145  static const int RingBarrelOffSet= 3;
146 
147  static const int minStationId= 1;
148  static const int maxStationId= 4;
149 
150  static const int minSectorId= 0;
151  static const int maxSectorId= 12;
152  static const int minSectorBarrelId= 1;
153  static const int maxSectorBarrelId= 12;
154  static const int minSectorForwardId= 1;
155  static const int maxSectorForwardId= 6;
156 
157  static const int minLayerId= 1;
158  static const int maxLayerId= 2;
159 
160  static const int minSubSectorId= 0;
161  static const int maxSubSectorId= 6;
162  static const int minSubSectorBarrelId= 1;
163  static const int maxSubSectorBarrelId= 4;
164  static const int minSubSectorForwardId= 1;
165  static const int maxSubSectorForwardId= 6;
166 
167  static const int minRollId= 0;
168  static const int maxRollId= 4;
169 
170 
171  private:
172  static const int RegionNumBits_ = 2;
173  static const int RegionStartBit_ = 0;
174  static const int RegionMask_ = 0X3;
175 
176  static const int RingNumBits_ = 3;
178  static const unsigned int RingMask_ = 0X7;
179 
180  static const int StationNumBits_ = 2;
182  static const unsigned int StationMask_ = 0X3;
183 
184 
185  static const int SectorNumBits_ = 4;
187  static const unsigned int SectorMask_ = 0XF;
188 
189  static const int LayerNumBits_ = 1;
191  static const unsigned int LayerMask_ = 0X1;
192 
193  static const int SubSectorNumBits_ = 3;
195  static const unsigned int SubSectorMask_ = 0X7;
196 
197  static const int RollNumBits_ = 3;
199  static const unsigned int RollMask_ = 0X7;
200 
201  static const uint32_t chamberIdMask_ = ~(RollMask_<<RollStartBit_);
202 
203  private:
204  void init(int region,
205  int ring,
206  int station,
207  int sector,
208  int layer,
209  int subsector,
210  int roll);
211 
212  int trind;
213 }; // RPCDetId
214 
215 std::ostream& operator<<( std::ostream& os, const RPCDetId& id );
216 
217 #endif
static const int maxStationId
Definition: RPCDetId.h:148
RPCDetId()
Definition: RPCDetId.cc:14
static const unsigned int RingMask_
Definition: RPCDetId.h:178
static const int SubSectorStartBit_
Definition: RPCDetId.h:194
static const int minSectorBarrelId
Definition: RPCDetId.h:152
void buildfromDB(int region, int ring, int layer, int sector, const std::string &subsector, const std::string &roll, const std::string &dbname)
Definition: RPCDetId.cc:46
static const int RegionNumBits_
Definition: RPCDetId.h:172
static const int maxSubSectorBarrelId
Definition: RPCDetId.h:163
void buildfromTrIndex(int trIndex)
Built from the trigger det Index.
Definition: RPCDetId.cc:139
void init(int region, int ring, int station, int sector, int layer, int subsector, int roll)
Definition: RPCDetId.cc:214
static const int maxLayerId
Definition: RPCDetId.h:158
int trind
Definition: RPCDetId.h:212
static const int maxRingForwardId
Definition: RPCDetId.h:142
static const int minRingBarrelId
Definition: RPCDetId.h:143
static const int RollNumBits_
Definition: RPCDetId.h:197
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
static const int minSubSectorId
Definition: RPCDetId.h:160
static const int LayerStartBit_
Definition: RPCDetId.h:190
static const int minRollId
Definition: RPCDetId.h:167
static const int minSectorId
Definition: RPCDetId.h:150
uint32_t rawId() const
get the raw id
Definition: DetId.h:45
static const int RingNumBits_
Definition: RPCDetId.h:176
RPCDetId chamberId() const
Return the corresponding ChamberId.
Definition: RPCDetId.h:133
static const int StationStartBit_
Definition: RPCDetId.h:181
int roll() const
Definition: RPCDetId.h:123
static const int minSubSectorForwardId
Definition: RPCDetId.h:164
static const unsigned int SectorMask_
Definition: RPCDetId.h:187
static const int minRegionId
Definition: RPCDetId.h:138
static const unsigned int LayerMask_
Definition: RPCDetId.h:191
int ring() const
Definition: RPCDetId.h:75
static const int maxSubSectorId
Definition: RPCDetId.h:161
static const int StationNumBits_
Definition: RPCDetId.h:180
static const int maxSectorBarrelId
Definition: RPCDetId.h:153
static const char ring_[]
static const int minSectorForwardId
Definition: RPCDetId.h:154
static const int RingStartBit_
Definition: RPCDetId.h:177
static const int LayerNumBits_
Definition: RPCDetId.h:189
static const int RegionStartBit_
Definition: RPCDetId.h:173
static const int RegionMask_
Definition: RPCDetId.h:174
static const unsigned int SubSectorMask_
Definition: RPCDetId.h:195
static const int maxRollId
Definition: RPCDetId.h:168
static const int SectorStartBit_
Definition: RPCDetId.h:186
static const int RingBarrelOffSet
Definition: RPCDetId.h:145
static const int maxRegionId
Definition: RPCDetId.h:139
static const int minStationId
Definition: RPCDetId.h:147
static const int RollStartBit_
Definition: RPCDetId.h:198
bool operator<(const RPCDetId &r) const
Sort Operator based on the raw detector id.
Definition: RPCDetId.h:42
static const unsigned int StationMask_
Definition: RPCDetId.h:182
int layer() const
Definition: RPCDetId.h:111
Definition: DetId.h:20
int trIndex() const
Definition: RPCDetId.h:128
static const int SectorNumBits_
Definition: RPCDetId.h:185
uint32_t id_
Definition: DetId.h:57
static const int maxRingBarrelId
Definition: RPCDetId.h:144
static const int SubSectorNumBits_
Definition: RPCDetId.h:193
static const int maxSectorId
Definition: RPCDetId.h:151
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:105
int subsector() const
SubSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel...
Definition: RPCDetId.h:117
static const int minRingForwardId
Definition: RPCDetId.h:141
static const unsigned int RollMask_
Definition: RPCDetId.h:199
static const int minSubSectorBarrelId
Definition: RPCDetId.h:162
static const int maxSectorForwardId
Definition: RPCDetId.h:155
static const int minLayerId
Definition: RPCDetId.h:157
static const int maxSubSectorForwardId
Definition: RPCDetId.h:165
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:66
int station() const
Definition: RPCDetId.h:99
static const uint32_t chamberIdMask_
Definition: RPCDetId.h:201