CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RPCGeomServ.cc
Go to the documentation of this file.
3 #include <sstream>
4 #include <iomanip>
5 
6 RPCGeomServ::RPCGeomServ::RPCGeomServ(const RPCDetId& id) :
7  _id(&id), _n(""), _sn(""), _t(-99), _z(true), _a(true)
8 {}
9 
10 
12 {}
13 
14 std::string
16 {
17  if (_n.size()<1){
18  std::string buf;
19 
20  if (_id->region()==0){
21  buf="W";
22  {
23  std::stringstream os;
24  os << std::setw(2)<<std::setfill('+')<<_id->ring()
25  <<std::setfill(' ')<<"_";
26  buf += os.str();
27  }
28 
29  {
30  std::stringstream os;
31  os <<"RB"<<_id->station();
32  if (_id->station()<=2) {
33  if (_id->layer()==1)
34  os<<"in";
35  else
36  os<<"out";
37  }
38  //os<<"_";
39  buf += os.str();
40  }
41 
42 
43  {
44  std::stringstream os;
45  // os <<"S"<<std::setw(2)<<std::setfill('0')
46  // <<_id->sector()<<std::setfill(' ');
47  if (_id->station()>2){
48  if (_id->sector()== 4 && _id->station()==4){
49  if ( _id->subsector()==1){
50  os<<"--";
51  }
52  else if ( _id->subsector()==2){
53  os <<"-";
54  }
55  else if ( _id->subsector()==3){
56  os <<"+";
57  }
58  else if ( _id->subsector()==4){
59  os <<"++";
60  }
61  }
62 
63  if(_id->station()==3){
64  if (_id->subsector()==1)
65  os <<"-";
66  else
67  os <<"+";
68  }else if(_id->station()==4 && _id->sector()!=9 && _id->sector()!=11 && _id->sector()!=4){
69  if (_id->subsector()==1)
70  os <<"-";
71  else
72  os <<"+";
73  }
74  }
75 
76  os<<"_";
77  os <<"S"<<std::setw(2)<<std::setfill('0')
78  <<_id->sector()<<std::setfill(' ');
79  buf += os.str();
80  }
81  {
82  std::stringstream os;
83  if (_id->roll()==1)
84  os<<"_Backward";
85  else if (_id->roll() == 3)
86  os<<"_Forward";
87  else if (_id->roll() == 2)
88  os <<"_Middle";
89  buf += os.str();
90  }
91  }
92  else {
93  buf="RE";
94 
95  {
96  std::stringstream os;
97  os << std::setw(2)<<std::setfill('+')<<_id->station()*_id->region()
98  <<std::setfill(' ')<<"_";
99  buf += os.str();
100  }
101 
102  {
103  std::stringstream os;
104  os <<"R"<<_id->ring();
105  os <<"_CH"<<std::setw(2)<<std::setfill('0')<<this->segment();
106  buf += os.str();
107  }
108 
109  {
110  std::stringstream os;
111  if (_id->roll()==1)
112  os<<"_A";
113  else if (_id->roll() == 2)
114  os<<"_B";
115  else if (_id->roll() == 3)
116  os <<"_C";
117  else if (_id->roll() == 4)
118  os <<"_D";
119  buf += os.str();
120  }
121  }
122  _n=buf;
123  }
124  return _n;
125 }
126 
127 
128 std::string
130 {
131  if (_n.size()<1){
132  std::string buf;
133 
134  if (_id->region()==0){
135  buf="W";
136  {
137  std::stringstream os;
138  os << std::setw(2)<<std::setfill('+')<<_id->ring()
139  <<std::setfill(' ')<<"_";
140  buf += os.str();
141  }
142 
143  {
144  std::stringstream os;
145  os <<"RB"<<_id->station();
146  if (_id->station()<=2) {
147  if (_id->layer()==1)
148  os<<"in";
149  else
150  os<<"out";
151  }
152  //os<<"_";
153  buf += os.str();
154  }
155 
156 
157  {
158  std::stringstream os;
159  // os <<"S"<<std::setw(2)<<std::setfill('0')
160  // <<_id->sector()<<std::setfill(' ');
161  if (_id->station()>2){
162  if (_id->sector()== 4 && _id->station()==4){
163  if ( _id->subsector()==1){
164  os<<"--";
165  }
166  else if ( _id->subsector()==2){
167  os <<"-";
168  }
169  else if ( _id->subsector()==3){
170  os <<"+";
171  }
172  else if ( _id->subsector()==4){
173  os <<"++";
174  }
175  }
176 
177  if(_id->station()==3){
178  if (_id->subsector()==1)
179  os <<"-";
180  else
181  os <<"+";
182  }else if(_id->station()==4 && _id->sector()!=9 && _id->sector()!=11 && _id->sector()!=4){
183  if (_id->subsector()==1)
184  os <<"-";
185  else
186  os <<"+";
187  }
188  }
189 
190  os<<"_";
191  os <<"S"<<std::setw(2)<<std::setfill('0')
192  <<_id->sector()<<std::setfill(' ');
193  buf += os.str();
194  }
195 
196  }
197  else {
198  buf="RE";
199 
200  {
201  std::stringstream os;
202  os << std::setw(2)<<std::setfill('+')<<_id->station()*_id->region()
203  <<std::setfill(' ')<<"_";
204  buf += os.str();
205  }
206 
207  {
208  std::stringstream os;
209  os <<"R"<<_id->ring();
210  os <<"_CH"<<std::setw(2)<<std::setfill('0')<<this->segment();
211  buf += os.str();
212  }
213 
214 
215  }
216  _n=buf;
217  }
218  return _n;
219 }
220 
221 std::string
223 {
224  if (_sn.size()<1)
225  {
226  std::string buf;
227 
228  if (_id->region()==0){
229  std::stringstream os;
230  os <<"RB"<<_id->station();
231  if (_id->station()<=2){
232  if (_id->layer()==1){
233  os<<"in";
234  }else{
235  os<<"out";
236  }
237  }else{
238  if (_id->sector()== 4 && _id->station()==4){
239  if ( _id->subsector()==1){
240  os<<"--";
241  }
242  else if ( _id->subsector()==2){
243  os <<",-";
244  }
245  else if ( _id->subsector()==3){
246  os <<"+";
247  }
248  else if ( _id->subsector()==4){
249  os <<"++";
250  }
251  }else{
252  if (_id->subsector()==1)
253  os <<",-";
254  else
255  os <<"+";
256  }
257  }
258  if (_id->roll()==1)
259  os<<" B";
260  else if (_id->roll() == 3)
261  os<<" F";
262  else if (_id->roll() == 2)
263  os<<" M";
264  buf += os.str();
265  }
266  else {
267  std::stringstream os;
268  os <<"Ri"<<_id->ring()<<" Su"<<_id->subsector();
269  buf += os.str();
270  }
271  _sn=buf;
272  }
273  return _sn;
274 }
275 
276 //returns a vector with number of channels for each chip in each FEB
277 std::vector<int> RPCGeomServ::channelInChip(){
278 
279  std::vector<int> chipCh(4,8);//Endcap
280 
281  if(_id->region()==0){//Barrel
282  chipCh.clear();
283 
284  if (_id->station()<3 && _id->layer()==1){ // i.e. RB1in ||RB2in
285  chipCh.push_back(7);
286  chipCh.push_back(8);
287  }else if (_id->station() == 1 || _id->station() == 3){//i.e. RB1out || RB3
288  chipCh.push_back(7);
289  chipCh.push_back(7);
290  }else if (_id->station() == 2){// i.e. RB2out
291  chipCh.push_back(6);
292  chipCh.push_back(8);
293  }else if (_id->sector() == 4 || _id->sector()==10 ||(_id->sector() == 8 && _id->subsector()!=1) || (_id->sector() == 12 && _id->subsector()==1)){
294  chipCh.push_back(6);//i.e. Sector 4 & 10 RB4 and Sector 8 &12 RB4+
295  chipCh.push_back(6);
296  }else {
297  chipCh.push_back(8);
298  chipCh.push_back(8);
299  }
300  }
301 
302  return chipCh;
303 }
304 
305 
306 int
308 {
309  if (_t<-90){
310  if (_id->region() == 0 ){
311  if (this->inverted()) {
312  _t = 3*(_id->ring())+ (3-_id->roll())-1;
313  }else{
314  _t = 3*(_id->ring())+ _id->roll()-2;
315  }
316  }else{
317  _t = _id->region() * (3*(3-_id->ring()) + _id->roll() + 7);
318  }
319  }
320  return _t;
321 }
322 
323 int
325 {
326 
327  // Station1
328  if( _id->station() ==1) {
329 
330  // in
331  if(_id->layer() ==1) {
332 
333  if(_id->roll()==1)
334  _cnr = 1;
335  else
336  _cnr = 2;
337  }
338  //out
339  else
340  {
341  if(_id->roll()==1)
342  _cnr = 3;
343  else
344  _cnr = 4;
345 
346  }
347  }
348 
349 
350  //Station 2
351  if (_id->station()==2) {
352 
353  //in
354  if(_id->layer()==1) {
355 
356  if(_id->roll()==1)//backward
357  _cnr = 5;
358  if(_id->roll()==3)//forward
359  _cnr=6;
360  if(_id->roll()==2)//middle
361  _cnr=7;
362  }
363  //out
364  else {
365 
366  if(_id->roll()==2)
367 
368  _cnr=7;
369 
370  if(_id->roll()==1)
371  _cnr=8;
372  if(_id->roll()==3)
373  _cnr=9;
374 
375  }
376  }
377 
378  //RB3- RB3+
379  if(_id->station()==3)
380  {
381  if(_id->subsector()==1) {
382 
383  if(_id->roll()==1)
384  _cnr=10;
385  else
386  _cnr=11;
387  }
388  else {
389 
390  if(_id->roll()==1)
391  _cnr=12;
392  else
393  _cnr=13;
394  }
395 
396  }
397 
398  //RB4
399  if(_id->station()==4) {
400 
401  if (_id->sector()== 4) {
402 
403  if ( _id->subsector()==2){//RB4-
404 
405  if(_id->roll()==1)
406  _cnr=14;
407  else
408  _cnr=15;
409 
410  }
411 
412  if ( _id->subsector()==3){//RB4+
413 
414  if(_id->roll()==1)
415  _cnr=16;
416  else
417  _cnr=17;
418 
419  }
420 
421  if ( _id->subsector()==1) {//RB4--
422 
423  if(_id->roll()==1)
424  _cnr=18;
425  else
426  _cnr=19;
427  }
428 
429  if ( _id->subsector()==4){//RB4++
430 
431  if(_id->roll()==1)
432  _cnr=20;
433  else
434  _cnr=21;
435 
436  }
437 
438  }
439 
440  else
441 
442  {
443  if(_id->subsector()==1) {
444 
445  if(_id->roll()==1)
446  _cnr=14;
447  else
448  _cnr=15;
449  }
450  else {
451 
452  if(_id->roll()==1)
453  _cnr=16;
454  else
455  _cnr=17;
456  }
457  }
458  }
459 
460 
461  // _cnr=10;
462  return _cnr;
463 
464 }
465 
466 int
468  int seg=0;
469  int nsec=36;
470  int nsub=6;
471  if ( _id->ring()==1 && _id->station() > 1) {
472  nsub=3;
473  nsec=18;
474  }
475  seg =_id->subsector()+nsub*(_id->sector()-1);//+1;
476  // if(seg==nsec+1)seg=1;
477  return seg;
478 }
479 
480 bool
482 {
483  // return !(this->zpositive() && this->aclockwise());
484  return !(this->zpositive());
485 }
486 
487 
488 bool
490 {
491  if (_id->region()==0 && _t<-90 ){
492  if (_id->ring()<0){
493  _z=false;
494  }
495  if (_id->ring()==0){
496  if (_id->sector() == 1 || _id->sector() == 4 ||
497  _id->sector() == 5 || _id->sector() == 8 ||
498  _id->sector() == 9 || _id->sector() == 12){
499  _z=false;
500  }
501  }
502  }
503 
504  return _z;
505 }
506 
507 bool
509 {
510  if (_id->region()==0 && _t<-90 ){
511  if (_id->ring() > 0){
512  if (_id->layer()==2){
513  _a=false;
514  }
515  }else if(_id->ring() <0){
516  if (_id->layer()==1){
517  _a=false;
518  }
519  }else if(_id->ring() ==0) {
520  if ((_id->sector() == 1 || _id->sector() == 4 ||
521  _id->sector() == 5 || _id->sector() == 8 ||
522  _id->sector() == 9 || _id->sector() == 12) && _id->layer()==1)
523  _a=false;
524  else if ((_id->sector() == 2 || _id->sector() == 3 ||
525  _id->sector() == 6 || _id->sector() == 7 ||
526  _id->sector() == 10|| _id->sector() == 11) && _id->layer()==2)
527  _a=false;
528  }
529  }
530  return _a;
531 }
532 
533 
534 
535 
536 
537 RPCGeomServ::RPCGeomServ() : _id(0), _n(""), _sn(""), _t (-99), _z(false), _a(false)
538 {}
539 
540 
virtual int chambernr()
Definition: RPCGeomServ.cc:324
virtual std::string chambername()
Definition: RPCGeomServ.cc:129
std::string _sn
Definition: RPCGeomServ.h:29
virtual int eta_partition()
Definition: RPCGeomServ.cc:307
std::vector< int > channelInChip()
Definition: RPCGeomServ.cc:277
std::string _n
Definition: RPCGeomServ.h:28
virtual std::string name()
Definition: RPCGeomServ.cc:15
int roll() const
Definition: RPCDetId.h:122
int ring() const
Definition: RPCDetId.h:74
virtual bool aclockwise()
Definition: RPCGeomServ.cc:508
virtual ~RPCGeomServ()
Definition: RPCGeomServ.cc:11
virtual std::string shortname()
Definition: RPCGeomServ.cc:222
int layer() const
Definition: RPCDetId.h:110
virtual int segment()
Definition: RPCGeomServ.cc:467
virtual bool zpositive()
Definition: RPCGeomServ.cc:489
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
virtual bool inverted()
Definition: RPCGeomServ.cc:481
const RPCDetId * _id
Definition: RPCGeomServ.h:27
int region() const
Region id: 0 for Barrel, +/-1 For +/- Endcap.
Definition: RPCDetId.h:65
int station() const
Definition: RPCDetId.h:98