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