CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCDetId.cc
Go to the documentation of this file.
1 
11 
13 
14 
15 RPCDetId::RPCDetId(uint32_t id):DetId(id),trind(0) {
16  // std::cout<<" constructor of the RPCDetId" <<std::endl;
18  throw cms::Exception("InvalidDetId") << "RPCDetId ctor:"
19  << " det: " << det()
20  << " subdet: " << subdetId()
21  << " is not a valid RPC id";
22  }
23 }
24 RPCDetId::RPCDetId(DetId id):DetId(id),trind(0) {
25  // std::cout<<" constructor of the RPCDetId" <<std::endl;
27  throw cms::Exception("InvalidDetId") << "RPCDetId ctor:"
28  << " det: " << det()
29  << " subdet: " << subdetId()
30  << " is not a valid RPC id";
31  }
32 }
33 
34 
35 
36 RPCDetId::RPCDetId(int region, int ring, int station, int sector, int layer,int subsector, int roll):
37  DetId(DetId::Muon, MuonSubdetId::RPC),trind(0)
38 {
39  this->init(region,ring,station,sector,layer,subsector,roll);
40 }
41 
42 
43 void
44 RPCDetId::buildfromDB(int region, int ring, int trlayer, int sector,
45  const std::string& subs,
46  const std::string& roll,
47  const std::string& dbname){
48 
49  bool barrel = (region==0);
50  //STATION
51  int station = -1;
52  if (barrel) {
53  if (trlayer==1 || trlayer==2) station = 1;
54  else if (trlayer==3 || trlayer==4) station = 2;
55  else station = trlayer-2;
56  } else {
57  station = abs(ring);
58  }
59 
60 
61  //LAYER
62  //int layer = 1;
63  //if (barrel && station==1) layer = trlayer;
64  //if (barrel && station==2) layer = trlayer-2;
65 
66  //SUBSECTOR
67  int subsector = 1;
68 
69  if (barrel) {
70  if (station==3 && subs=="+") subsector = 2;
71  if (station==4 &&
72  ( sector==1 || sector==2 || sector==3
73  || sector==5 || sector==6
74  || sector==7 || sector==8
75  || sector==10 || sector==12)
76  && (subs=="+")) {
77  subsector = 2;
78  }
79 
80  if (station==4 && sector==4) {
81  if (subs=="--") subsector=1;
82  if (subs=="-") subsector=2;
83  if (subs=="+") subsector=3;
84  if (subs=="++") subsector=4;
85  }
86  }
87 
88  // ROLL
89  int iroll=0;
90 
91  if (roll=="Backward" || roll=="A") iroll = 1;
92  else if (roll=="Central" || roll=="B") iroll = 2;
93  else if (roll=="Forward" || roll=="C") iroll = 3;
94  else if (roll=="D") iroll = 4;
95  else {
96  std::cout << "** RPC: DBSpecToDetUnit, how to assigne roll to: "
97  <<roll<<" ???" << std::endl;
98  }
99 
100  int trIndex = 0;
101  if(barrel){
102  //cout <<" BARREL: " << endl;
103  int eta_id = 6+ring;
104  int plane_id = station;
105  if(trlayer==2) plane_id=5;
106  if(trlayer==4) plane_id=6;
107  int sector_id = sector*3;
108  int copy_id = subsector;
109  int roll_id = iroll;
110  trIndex=(eta_id*10000+plane_id*1000+sector_id*10+copy_id)*10+roll_id;
111  }
112  else {
113  // cout << "ENDCAP : " << endl;
114  int eta_id = trlayer;
115  if(ring>0) eta_id = 12-trlayer;
116  int plane_id = abs(ring);
117  int sector_id = sector;
118 
119  if (region <0){
120  if (sector_id < 20 ){
121  sector_id = 19+ 1-sector_id;
122  }else{
123  sector_id = 36+20-sector_id;
124  }
125  }
126  sector_id-=1;
127 
128  //
129  int copy_id = 1;
130  int roll_id = iroll;
131  trIndex=(eta_id*10000+plane_id*1000+sector_id*10+copy_id)*10+ roll_id;
132  }
133  this->buildfromTrIndex(trIndex);
134 }
135 
136 void
138 {
139  trind = trIndex;
140  int eta_id = trIndex/100000;
141  int region=0;
142  int ring =0;
143  if (eta_id <=3 ){
144  region = -1;
145  ring = eta_id;
146  }
147  else if (eta_id >=9 ) {
148  region = 1;
149  ring = 12-eta_id;
150  }
151  else{
152  region = 0;
153  ring = eta_id - 6;
154  }
155  trIndex = trIndex%100000;
156  int plane_id = trIndex/10000;
157  int station=0;
158  int layer=0;
159  if (plane_id <=4){
160  station = plane_id;
161  layer = 1;
162  }
163  else{
164  station = plane_id -4;
165  layer = 2;
166  }
167  trIndex = trIndex%10000;
168  int sector_id = trIndex/100;
169  if (region!=0) {
170  if ( !(ring == 1 && station > 1 && region==1)) {
171  sector_id+=1;
172  if (sector_id==37)sector_id=1;
173  }
174  }
175  if (region==-1){
176  if (sector_id < 20 ){
177  sector_id = 19+ 1-sector_id;
178  }else{
179  sector_id = 36+20-sector_id;
180  }
181  }
182  trIndex = trIndex%100;
183  int copy_id = trIndex/10;
184  int sector=(sector_id-1)/3+1;
185  if (region!=0) {
186  sector=(sector+1)/2;
187  }
188  int subsector=0;
189  if ( region == 0 ) {
190  subsector = copy_id;
191  }
192  else {
193  if ( ring == 1 && station > 1) {
194  // 20 degree chambers
195  subsector = ((sector_id+1)/2-1)%3+1;
196  }else {
197  // 10 degree chambers
198  subsector = (sector_id-1)%6+1;
199  }
200 // std::cout <<" RE"<<station*region<<"/"<<ring<<" sector_id "<<sector_id
201 // << " sector "<<sector <<" sub "<<subsector<<std::endl;
202  }
203 
204 
205  int roll=trIndex%10;
206  this->init(region,ring,station,sector,layer,subsector,roll);
207 }
208 
209 
210 
211 void
212 RPCDetId::init(int region,int ring,int station,int sector,
213  int layer,int subsector,int roll)
214 {
215  int minRing=0;
216  int maxRing=RPCDetId::maxRingForwardId;
217  if (!region)
218  {
221  }
222 
223  if ( region < minRegionId || region > maxRegionId ||
224  ring < minRing || ring > maxRing ||
225  station < minStationId || station > maxStationId ||
226  sector < minSectorId || sector > maxSectorId ||
227  layer < minLayerId || layer > maxLayerId ||
228  subsector < minSubSectorId || subsector > maxSubSectorId ||
229  roll < minRollId || roll > maxRollId) {
230  throw cms::Exception("InvalidDetId") << "RPCDetId ctor:"
231  << " Invalid parameters: "
232  << " region "<<region
233  << " ring "<<ring
234  << " station "<<station
235  << " sector "<<sector
236  << " layer "<<layer
237  << " subsector "<<subsector
238  << " roll "<<roll
239  << std::endl;
240  }
241 
242 
243  int regionInBits=region-minRegionId;
244  int ringInBits =0;
245  if(region != 0) ringInBits = ring - minRingForwardId;
246  if(!region) ringInBits = ring + RingBarrelOffSet - minRingBarrelId;
247 
248  int stationInBits=station-minStationId;
249  int sectorInBits=sector-(minSectorId+1);
250  int layerInBits=layer-minLayerId;
251  int subSectorInBits=subsector-(minSubSectorId+1);
252  int rollInBits=roll;
253 
254  id_ |= ( regionInBits & RegionMask_) << RegionStartBit_ |
255  ( ringInBits & RingMask_) << RingStartBit_ |
256  ( stationInBits & StationMask_) << StationStartBit_ |
257  ( sectorInBits & SectorMask_) << SectorStartBit_ |
258  ( layerInBits & LayerMask_) << LayerStartBit_ |
259  ( subSectorInBits & SubSectorMask_) << SubSectorStartBit_ |
260  ( rollInBits & RollMask_) << RollStartBit_ ;
261 
262 }
263 
264 
265 
266 std::ostream& operator<<( std::ostream& os, const RPCDetId& id ){
267 
268 
269  os << " Re "<<id.region()
270  << " Ri "<<id.ring()
271  << " St "<<id.station()
272  << " Se "<<id.sector()
273  << " La "<<id.layer()
274  << " Su "<<id.subsector()
275  << " Ro "<<id.roll()
276  << " Tr "<<id.trIndex()
277  <<" ";
278 
279  return os;
280 }
281 
282 
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
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
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
#define abs(x)
Definition: mlp_lapack.h:159
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 minSectorId
Definition: RPCDetId.h:151
static const int StationStartBit_
Definition: RPCDetId.h:182
int roll() const
Definition: RPCDetId.h:124
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 RingStartBit_
Definition: RPCDetId.h:178
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
int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:39
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
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
uint32_t id_
Definition: DetId.h:57
static const int maxRingBarrelId
Definition: RPCDetId.h:145
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 int RPC
Definition: MuonSubdetId.h:16
static const unsigned int RollMask_
Definition: RPCDetId.h:200
tuple cout
Definition: gather_cfg.py:121
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
static const int minLayerId
Definition: RPCDetId.h:158
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:67
int station() const
Definition: RPCDetId.h:100