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