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  //LAYER
61  int layer = 1;
62  if (barrel && station==1) layer = trlayer;
63  if (barrel && station==2) layer = trlayer-2;
64 
65  //SUBSECTOR
66  int subsector = 1;
67 
68  if (barrel) {
69  if (station==3 && subs=="+") subsector = 2;
70  if (station==4 &&
71  ( sector==1 || sector==2 || sector==3
72  || sector==5 || sector==6
73  || sector==7 || sector==8
74  || sector==10 || sector==12)
75  && (subs=="+")) {
76  subsector = 2;
77  }
78 
79  if (station==4 && sector==4) {
80  if (subs=="--") subsector=1;
81  if (subs=="-") subsector=2;
82  if (subs=="+") subsector=3;
83  if (subs=="++") subsector=4;
84  }
85  }
86 
87  // ROLL
88  int iroll=0;
89 
90  if (roll=="Backward" || roll=="A") iroll = 1;
91  else if (roll=="Central" || roll=="B") iroll = 2;
92  else if (roll=="Forward" || roll=="C") iroll = 3;
93  else if (roll=="D") iroll = 4;
94  else {
95  std::cout << "** RPC: DBSpecToDetUnit, how to assigne roll to: "
96  <<roll<<" ???" << std::endl;
97  }
98 
99  int trIndex = 0;
100  if(barrel){
101  //cout <<" BARREL: " << endl;
102  int eta_id = 6+ring;
103  int plane_id = station;
104  if(trlayer==2) plane_id=5;
105  if(trlayer==4) plane_id=6;
106  int sector_id = sector*3;
107  int copy_id = subsector;
108  int roll_id = iroll;
109  trIndex=(eta_id*10000+plane_id*1000+sector_id*10+copy_id)*10+roll_id;
110  }
111  else {
112  // cout << "ENDCAP : " << endl;
113  int eta_id = trlayer;
114  if(ring>0) eta_id = 12-trlayer;
115  int plane_id = abs(ring);
116  int sector_id = sector;
117 
118  if (region <0){
119  if (sector_id < 20 ){
120  sector_id = 19+ 1-sector_id;
121  }else{
122  sector_id = 36+20-sector_id;
123  }
124  }
125  sector_id-=1;
126 
127  //
128  int copy_id = 1;
129  int roll_id = iroll;
130  trIndex=(eta_id*10000+plane_id*1000+sector_id*10+copy_id)*10+ roll_id;
131  }
132  this->buildfromTrIndex(trIndex);
133 }
134 
135 void
137 {
138  trind = trIndex;
139  int eta_id = trIndex/100000;
140  int region=0;
141  int ring =0;
142  if (eta_id <=3 ){
143  region = -1;
144  ring = eta_id;
145  }
146  else if (eta_id >=9 ) {
147  region = 1;
148  ring = 12-eta_id;
149  }
150  else{
151  region = 0;
152  ring = eta_id - 6;
153  }
154  trIndex = trIndex%100000;
155  int plane_id = trIndex/10000;
156  int station=0;
157  int layer=0;
158  if (plane_id <=4){
159  station = plane_id;
160  layer = 1;
161  }
162  else{
163  station = plane_id -4;
164  layer = 2;
165  }
166  trIndex = trIndex%10000;
167  int sector_id = trIndex/100;
168  if (region!=0) {
169  if ( !(ring == 1 && station > 1 && region==1)) {
170  sector_id+=1;
171  if (sector_id==37)sector_id=1;
172  }
173  }
174  if (region==-1){
175  if (sector_id < 20 ){
176  sector_id = 19+ 1-sector_id;
177  }else{
178  sector_id = 36+20-sector_id;
179  }
180  }
181  trIndex = trIndex%100;
182  int copy_id = trIndex/10;
183  int sector=(sector_id-1)/3+1;
184  if (region!=0) {
185  sector=(sector+1)/2;
186  }
187  int subsector=0;
188  if ( region == 0 ) {
189  subsector = copy_id;
190  }
191  else {
192  if ( ring == 1 && station > 1) {
193  // 20 degree chambers
194  subsector = ((sector_id+1)/2-1)%3+1;
195  }else {
196  // 10 degree chambers
197  subsector = (sector_id-1)%6+1;
198  }
199 // std::cout <<" RE"<<station*region<<"/"<<ring<<" sector_id "<<sector_id
200 // << " sector "<<sector <<" sub "<<subsector<<std::endl;
201  }
202 
203 
204  int roll=trIndex%10;
205  this->init(region,ring,station,sector,layer,subsector,roll);
206 }
207 
208 
209 
210 void
211 RPCDetId::init(int region,int ring,int station,int sector,
212  int layer,int subsector,int roll)
213 {
214  int minRing=0;
215  int maxRing=RPCDetId::maxRingForwardId;
216  if (!region)
217  {
220  }
221 
222  if ( region < minRegionId || region > maxRegionId ||
223  ring < minRing || ring > maxRing ||
224  station < minStationId || station > maxStationId ||
225  sector < minSectorId || sector > maxSectorId ||
226  layer < minLayerId || layer > maxLayerId ||
227  subsector < minSubSectorId || subsector > maxSubSectorId ||
228  roll < minRollId || roll > maxRollId) {
229  throw cms::Exception("InvalidDetId") << "RPCDetId ctor:"
230  << " Invalid parameters: "
231  << " region "<<region
232  << " ring "<<ring
233  << " station "<<station
234  << " sector "<<sector
235  << " layer "<<layer
236  << " subsector "<<subsector
237  << " roll "<<roll
238  << std::endl;
239  }
240 
241 
242  int regionInBits=region-minRegionId;
243  int ringInBits =0;
244  if(region != 0) ringInBits = ring - minRingForwardId;
245  if(!region) ringInBits = ring + RingBarrelOffSet - minRingBarrelId;
246 
247  int stationInBits=station-minStationId;
248  int sectorInBits=sector-(minSectorId+1);
249  int layerInBits=layer-minLayerId;
250  int subSectorInBits=subsector-(minSubSectorId+1);
251  int rollInBits=roll;
252 
253  id_ |= ( regionInBits & RegionMask_) << RegionStartBit_ |
254  ( ringInBits & RingMask_) << RingStartBit_ |
255  ( stationInBits & StationMask_) << StationStartBit_ |
256  ( sectorInBits & SectorMask_) << SectorStartBit_ |
257  ( layerInBits & LayerMask_) << LayerStartBit_ |
258  ( subSectorInBits & SubSectorMask_) << SubSectorStartBit_ |
259  ( rollInBits & RollMask_) << RollStartBit_ ;
260 
261 }
262 
263 
264 
265 std::ostream& operator<<( std::ostream& os, const RPCDetId& id ){
266 
267 
268  os << " Re "<<id.region()
269  << " Ri "<<id.ring()
270  << " St "<<id.station()
271  << " Se "<<id.sector()
272  << " La "<<id.layer()
273  << " Su "<<id.subsector()
274  << " Ro "<<id.roll()
275  << " Tr "<<id.trIndex()
276  <<" ";
277 
278  return os;
279 }
280 
281 
static const int maxStationId
Definition: RPCDetId.h:147
RPCDetId()
Definition: RPCDetId.cc:12
static const unsigned int RingMask_
Definition: RPCDetId.h:177
static const int SubSectorStartBit_
Definition: RPCDetId.h:193
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:136
void init(int region, int ring, int station, int sector, int layer, int subsector, int roll)
Definition: RPCDetId.cc:211
static const int maxLayerId
Definition: RPCDetId.h:157
int trind
Definition: RPCDetId.h:211
static const int maxRingForwardId
Definition: RPCDetId.h:141
static const int minRingBarrelId
Definition: RPCDetId.h:142
#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:159
static const int LayerStartBit_
Definition: RPCDetId.h:189
static const int minSectorId
Definition: RPCDetId.h:149
static const int StationStartBit_
Definition: RPCDetId.h:180
int roll() const
Definition: RPCDetId.h:122
static const unsigned int SectorMask_
Definition: RPCDetId.h:186
static const int minRegionId
Definition: RPCDetId.h:137
static const unsigned int LayerMask_
Definition: RPCDetId.h:190
int ring() const
Definition: RPCDetId.h:74
static const int maxSubSectorId
Definition: RPCDetId.h:160
static const int RingStartBit_
Definition: RPCDetId.h:176
static const int RegionStartBit_
Definition: RPCDetId.h:172
static const int RegionMask_
Definition: RPCDetId.h:173
static const unsigned int SubSectorMask_
Definition: RPCDetId.h:194
static const int maxRollId
Definition: RPCDetId.h:167
static const int SectorStartBit_
Definition: RPCDetId.h:185
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:144
static const int maxRegionId
Definition: RPCDetId.h:138
static const int minStationId
Definition: RPCDetId.h:146
static const int RollStartBit_
Definition: RPCDetId.h:197
static const unsigned int StationMask_
Definition: RPCDetId.h:181
int layer() const
Definition: RPCDetId.h:110
Definition: DetId.h:20
int trIndex() const
Definition: RPCDetId.h:127
uint32_t id_
Definition: DetId.h:57
static const int maxRingBarrelId
Definition: RPCDetId.h:143
static const int maxSectorId
Definition: RPCDetId.h:150
int sector() const
Sector id: the group of chambers at same phi (and increasing r)
Definition: RPCDetId.h:104
int subsector() const
SubSector id : some sectors are divided along the phi direction in subsectors (from 1 to 4 in Barrel...
Definition: RPCDetId.h:116
static const int minRingForwardId
Definition: RPCDetId.h:140
static const int RPC
Definition: MuonSubdetId.h:16
static const unsigned int RollMask_
Definition: RPCDetId.h:198
tuple cout
Definition: gather_cfg.py:41
Detector det() const
get the detector field from this detid
Definition: DetId.h:37
static const int minLayerId
Definition: RPCDetId.h:156
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:65
int station() const
Definition: RPCDetId.h:98