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