CMS 3D CMS Logo

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 public:
18  RPCDetId();
19 
22  RPCDetId(uint32_t id);
23  RPCDetId(DetId id);
24 
26  RPCDetId(int region, int ring, int station, int sector, int layer, int subsector, int roll);
27 
29  bool operator<(const RPCDetId& r) const {
30  if (r.station() == this->station()) {
31  if (this->layer() == r.layer()) {
32  return this->rawId() < r.rawId();
33  } else {
34  return (this->layer() < r.layer());
35  }
36  } else {
37  return this->station() < r.station();
38  }
39  }
40 
41  void buildfromDB(int region,
42  int ring,
43  int layer,
44  int sector,
45  const std::string& subsector,
46  const std::string& roll,
47  const std::string& dbname);
48 
50  void buildfromTrIndex(int trIndex);
51 
53  int region() const { return int((id_ >> RegionStartBit_) & RegionMask_) + minRegionId; }
54 
59  int ring() const {
60  int ring_ = (id_ >> RingStartBit_) & RingMask_;
61 
62  if (ring_ < RingBarrelOffSet) {
63  if (this->region() == 0) {
64  throw cms::Exception("InvalidDetId") << "RPCDetId ctor:"
65  << " Ring - Region Inconsistency, "
66  << " region " << this->region() << " ring " << ring_ << std::endl;
67  }
68 
69  return int(ring_ + minRingForwardId);
70 
71  } else { // if(ring_ >= RingBarrelOffSet)
73  }
74  }
75 
78  int station() const { return int((id_ >> StationStartBit_) & StationMask_) + minStationId; }
79 
81  int sector() const { return int((id_ >> SectorStartBit_) & SectorMask_) + (minSectorId + 1); }
82 
85  int layer() const { return int((id_ >> LayerStartBit_) & LayerMask_) + minLayerId; }
86 
88  int subsector() const { return int((id_ >> SubSectorStartBit_) & SubSectorMask_) + (minSubSectorId + 1); }
89 
92  int roll() const {
93  return int((id_ >> RollStartBit_) & RollMask_); // value 0 is used as wild card
94  }
95 
96  int trIndex() const { return trind; }
97 
99  RPCDetId chamberId() const { return RPCDetId(id_ & chamberIdMask_); }
100 
101  static constexpr int minRegionId = -1;
102  static constexpr int maxRegionId = 1;
103 
104  static constexpr int minRingForwardId = 1;
105  static constexpr int maxRingForwardId = 3;
106  static constexpr int minRingBarrelId = -2;
107  static constexpr int maxRingBarrelId = 2;
108  static constexpr int RingBarrelOffSet = 3;
109 
110  static constexpr int minStationId = 1;
111  static constexpr int maxStationId = 4;
112 
113  static constexpr int minSectorId = 0;
114  static constexpr int maxSectorId = 12;
115  static constexpr int minSectorBarrelId = 1;
116  static constexpr int maxSectorBarrelId = 12;
117  static constexpr int minSectorForwardId = 1;
118  static constexpr int maxSectorForwardId = 6;
119 
120  static constexpr int minLayerId = 1;
121  static constexpr int maxLayerId = 2;
122 
123  static constexpr int minSubSectorId = 0;
124  static constexpr int maxSubSectorId = 6;
125  static constexpr int minSubSectorBarrelId = 1;
126  static constexpr int maxSubSectorBarrelId = 4;
127  static constexpr int minSubSectorForwardId = 1;
128  static constexpr int maxSubSectorForwardId = 6;
129 
130  static constexpr int minRollId = 0;
131  static constexpr int maxRollId = 5; // used to be 4 ... need 5 for upgrade
132  // if we decide to divide the upgrade RE3/1 and RE4/1 up to eta=2.4
133  // and we want basically to have 0.10 eta / roll ...
134 
135 private:
136  static constexpr int RegionNumBits_ = 2;
137  static constexpr int RegionStartBit_ = 0;
138  static constexpr int RegionMask_ = 0X3;
139 
140  static constexpr int RingNumBits_ = 3;
141  static constexpr int RingStartBit_ = RegionStartBit_ + RegionNumBits_;
142  static constexpr unsigned int RingMask_ = 0X7;
143 
144  static constexpr int StationNumBits_ = 2;
145  static constexpr int StationStartBit_ = RingStartBit_ + RingNumBits_;
146  static constexpr unsigned int StationMask_ = 0X3;
147 
148  static constexpr int SectorNumBits_ = 4;
150  static constexpr unsigned int SectorMask_ = 0XF;
151 
152  static constexpr int LayerNumBits_ = 1;
154  static constexpr unsigned int LayerMask_ = 0X1;
155 
156  static constexpr int SubSectorNumBits_ = 3;
158  static constexpr unsigned int SubSectorMask_ = 0X7;
159 
160  static constexpr int RollNumBits_ = 3;
162  static constexpr unsigned int RollMask_ = 0X7;
163 
164 public:
165  static constexpr uint32_t chamberIdMask_ = ~(RollMask_ << RollStartBit_);
166 
167 private:
168  void init(int region, int ring, int station, int sector, int layer, int subsector, int roll);
169 
170  int trind;
171 }; // RPCDetId
172 
173 std::ostream& operator<<(std::ostream& os, const RPCDetId& id);
174 
175 #endif
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:81
RPCDetId()
Definition: RPCDetId.cc:13
static constexpr int RegionMask_
Definition: RPCDetId.h:138
static constexpr int minLayerId
Definition: RPCDetId.h:120
static constexpr unsigned int SectorMask_
Definition: RPCDetId.h:150
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:35
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:219
static constexpr unsigned int SubSectorMask_
Definition: RPCDetId.h:158
static constexpr int maxSectorBarrelId
Definition: RPCDetId.h:116
static constexpr int SectorStartBit_
Definition: RPCDetId.h:149
int trind
Definition: RPCDetId.h:170
static constexpr int SubSectorStartBit_
Definition: RPCDetId.h:157
RPCDetId chamberId() const
Return the corresponding ChamberId.
Definition: RPCDetId.h:99
static constexpr int minRingForwardId
Definition: RPCDetId.h:104
static constexpr uint32_t chamberIdMask_
Definition: RPCDetId.h:165
static constexpr int minRingBarrelId
Definition: RPCDetId.h:106
static constexpr int maxSubSectorBarrelId
Definition: RPCDetId.h:126
static constexpr int SubSectorNumBits_
Definition: RPCDetId.h:156
int trIndex() const
Definition: RPCDetId.h:96
static constexpr unsigned int StationMask_
Definition: RPCDetId.h:146
static constexpr int maxSectorForwardId
Definition: RPCDetId.h:118
static constexpr int minSubSectorForwardId
Definition: RPCDetId.h:127
int ring() const
Definition: RPCDetId.h:59
static constexpr int minSubSectorBarrelId
Definition: RPCDetId.h:125
bool operator<(const RPCDetId &r) const
Sort Operator based on the raw detector id.
Definition: RPCDetId.h:29
static constexpr unsigned int LayerMask_
Definition: RPCDetId.h:154
static constexpr int RegionNumBits_
Definition: RPCDetId.h:136
static constexpr int RollNumBits_
Definition: RPCDetId.h:160
static constexpr int minSectorForwardId
Definition: RPCDetId.h:117
static constexpr int maxSectorId
Definition: RPCDetId.h:114
static constexpr int maxRingBarrelId
Definition: RPCDetId.h:107
static constexpr int RollStartBit_
Definition: RPCDetId.h:161
static constexpr int minRegionId
Definition: RPCDetId.h:101
std::ostream & operator<<(std::ostream &os, const RPCDetId &id)
Definition: RPCDetId.cc:257
static constexpr int maxRollId
Definition: RPCDetId.h:131
static const char ring_[]
static constexpr int minSubSectorId
Definition: RPCDetId.h:123
static constexpr int maxRingForwardId
Definition: RPCDetId.h:105
static constexpr int RingStartBit_
Definition: RPCDetId.h:141
static constexpr int maxSubSectorForwardId
Definition: RPCDetId.h:128
static constexpr int StationStartBit_
Definition: RPCDetId.h:145
static constexpr int LayerNumBits_
Definition: RPCDetId.h:152
int roll() const
Definition: RPCDetId.h:92
int subsector() const
SubSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel...
Definition: RPCDetId.h:88
static constexpr int LayerStartBit_
Definition: RPCDetId.h:153
static constexpr int minStationId
Definition: RPCDetId.h:110
static constexpr int minSectorId
Definition: RPCDetId.h:113
static constexpr int minSectorBarrelId
Definition: RPCDetId.h:115
static constexpr int RingBarrelOffSet
Definition: RPCDetId.h:108
Definition: DetId.h:17
static constexpr int maxLayerId
Definition: RPCDetId.h:121
static constexpr int maxRegionId
Definition: RPCDetId.h:102
static constexpr int RegionStartBit_
Definition: RPCDetId.h:137
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
uint32_t id_
Definition: DetId.h:69
int station() const
Definition: RPCDetId.h:78
static constexpr unsigned int RollMask_
Definition: RPCDetId.h:162
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:53
static constexpr int RingNumBits_
Definition: RPCDetId.h:140
static constexpr unsigned int RingMask_
Definition: RPCDetId.h:142
static constexpr int StationNumBits_
Definition: RPCDetId.h:144
static constexpr int minRollId
Definition: RPCDetId.h:130
static constexpr int SectorNumBits_
Definition: RPCDetId.h:148
int layer() const
Definition: RPCDetId.h:85
static constexpr int maxSubSectorId
Definition: RPCDetId.h:124
static constexpr int maxStationId
Definition: RPCDetId.h:111