CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_2_9_HLT1_bphpatch4/src/Geometry/RPCGeometry/src/RPCGeomServ.cc

Go to the documentation of this file.
00001 #include "Geometry/RPCGeometry/interface/RPCGeomServ.h"
00002 #include "DataFormats/MuonDetId/interface/RPCDetId.h"
00003 #include <sstream>
00004 #include <iomanip>
00005 
00006 RPCGeomServ::RPCGeomServ::RPCGeomServ(const RPCDetId& id) : 
00007   _id(&id), _n(""), _sn(""), _t(-99), _z(true), _a(true)
00008 {}
00009 
00010 
00011 RPCGeomServ::~RPCGeomServ()
00012 {}
00013  
00014 std::string 
00015 RPCGeomServ::name()
00016 {
00017   if (_n.size()<1){
00018     std::string buf;
00019     
00020     if (_id->region()==0){
00021       buf="W";
00022       {
00023         std::stringstream os;
00024         os << std::setw(2)<<std::setfill('+')<<_id->ring()
00025            <<std::setfill(' ')<<"_";
00026         buf += os.str();
00027       }
00028       
00029       {
00030         std::stringstream os;
00031         os <<"RB"<<_id->station();
00032         if (_id->station()<=2) {
00033           if (_id->layer()==1)
00034             os<<"in";
00035           else
00036             os<<"out";
00037         }
00038         //os<<"_";
00039         buf += os.str();
00040       }
00041       
00042       
00043       {
00044         std::stringstream os;
00045         //      os <<"S"<<std::setw(2)<<std::setfill('0')
00046         //   <<_id->sector()<<std::setfill(' ');
00047         if (_id->station()>2){
00048           if (_id->sector()== 4 && _id->station()==4){
00049             if ( _id->subsector()==1){
00050               os<<"--";
00051             }
00052             else if ( _id->subsector()==2){
00053               os <<"-";
00054             }
00055             else if ( _id->subsector()==3){
00056               os <<"+";
00057             }
00058             else if ( _id->subsector()==4){
00059               os <<"++";
00060             }
00061           }
00062           
00063           if(_id->station()==3){
00064             if (_id->subsector()==1)
00065               os <<"-";
00066             else
00067               os <<"+";
00068           }else if(_id->station()==4 && _id->sector()!=9 && _id->sector()!=11 && _id->sector()!=4){
00069             if (_id->subsector()==1)
00070               os <<"-";
00071             else
00072               os <<"+";
00073           }
00074         }
00075         
00076         os<<"_";
00077         os <<"S"<<std::setw(2)<<std::setfill('0')
00078            <<_id->sector()<<std::setfill(' ');
00079         buf += os.str();
00080       }
00081       {
00082         std::stringstream os;
00083         if (_id->roll()==1)
00084           os<<"_Backward";
00085         else if (_id->roll() == 3)
00086           os<<"_Forward";
00087         else if (_id->roll() == 2)
00088         os <<"_Middle";
00089         buf += os.str();
00090       }
00091     }
00092     else {
00093       buf="RE";
00094       
00095       {
00096         std::stringstream os;
00097         os << std::setw(2)<<std::setfill('+')<<_id->station()*_id->region()
00098            <<std::setfill(' ')<<"_";
00099         buf += os.str();    
00100       }
00101       
00102       {
00103         std::stringstream os;
00104         os <<"R"<<_id->ring();
00105         os <<"_CH"<<std::setw(2)<<std::setfill('0')<<this->segment();
00106         buf += os.str();
00107       } 
00108 
00109       {
00110         std::stringstream os;
00111         if (_id->roll()==1)
00112           os<<"_A";
00113         else if (_id->roll() == 2)
00114           os<<"_B";
00115         else if (_id->roll() == 3)
00116           os <<"_C";
00117         else if (_id->roll() == 4)
00118           os <<"_D";
00119         buf += os.str();
00120       }
00121     }
00122     _n=buf;
00123   }
00124   return _n;
00125 }
00126  
00127 
00128 std::string 
00129 RPCGeomServ::chambername()
00130 {
00131   if (_n.size()<1){
00132     std::string buf;
00133     
00134     if (_id->region()==0){
00135       buf="W";
00136       {
00137         std::stringstream os;
00138         os << std::setw(2)<<std::setfill('+')<<_id->ring()
00139            <<std::setfill(' ')<<"_";
00140         buf += os.str();
00141       }
00142       
00143       {
00144         std::stringstream os;
00145         os <<"RB"<<_id->station();
00146         if (_id->station()<=2) {
00147           if (_id->layer()==1)
00148             os<<"in";
00149           else
00150             os<<"out";
00151         }
00152         //os<<"_";
00153         buf += os.str();
00154       }
00155       
00156       
00157       {
00158         std::stringstream os;
00159         //      os <<"S"<<std::setw(2)<<std::setfill('0')
00160         //   <<_id->sector()<<std::setfill(' ');
00161         if (_id->station()>2){
00162           if (_id->sector()== 4 && _id->station()==4){
00163             if ( _id->subsector()==1){
00164               os<<"--";
00165             }
00166             else if ( _id->subsector()==2){
00167               os <<"-";
00168             }
00169             else if ( _id->subsector()==3){
00170               os <<"+";
00171             }
00172             else if ( _id->subsector()==4){
00173               os <<"++";
00174             }
00175           }
00176           
00177           if(_id->station()==3){
00178             if (_id->subsector()==1)
00179               os <<"-";
00180             else
00181               os <<"+";
00182           }else if(_id->station()==4 && _id->sector()!=9 && _id->sector()!=11 && _id->sector()!=4){
00183             if (_id->subsector()==1)
00184               os <<"-";
00185             else
00186               os <<"+";
00187           }
00188         }
00189         
00190         os<<"_";
00191         os <<"S"<<std::setw(2)<<std::setfill('0')
00192            <<_id->sector()<<std::setfill(' ');
00193         buf += os.str();
00194       }
00195       
00196     }
00197     else {
00198       buf="RE";
00199       
00200       {
00201         std::stringstream os;
00202         os << std::setw(2)<<std::setfill('+')<<_id->station()*_id->region()
00203            <<std::setfill(' ')<<"_";
00204         buf += os.str();    
00205       }
00206       
00207       {
00208         std::stringstream os;
00209         os <<"R"<<_id->ring();
00210         os <<"_CH"<<std::setw(2)<<std::setfill('0')<<this->segment();
00211         buf += os.str();
00212       } 
00213 
00214       
00215     }
00216     _n=buf;
00217   }
00218   return _n;
00219 }
00220 
00221 std::string 
00222 RPCGeomServ::shortname()
00223 {
00224   if (_sn.size()<1)
00225     {
00226     std::string buf;
00227 
00228     if (_id->region()==0){
00229       std::stringstream os;
00230       os <<"RB"<<_id->station();
00231       if (_id->station()<=2){
00232         if (_id->layer()==1){
00233           os<<"in";
00234         }else{
00235           os<<"out";
00236         }
00237       }else{
00238         if (_id->sector()== 4 && _id->station()==4){
00239           if ( _id->subsector()==1){
00240             os<<"--";
00241           }
00242           else if ( _id->subsector()==2){
00243             os <<",-";
00244           }
00245           else if ( _id->subsector()==3){
00246             os <<"+";
00247           }
00248           else if ( _id->subsector()==4){
00249             os <<"++";
00250           }
00251         }else{
00252           if (_id->subsector()==1)
00253             os <<",-";
00254           else
00255             os <<"+";
00256         }
00257       }
00258       if (_id->roll()==1)
00259         os<<" B";
00260       else if (_id->roll() == 3)
00261         os<<" F";
00262       else if (_id->roll() == 2)
00263         os<<" M";
00264       buf += os.str();
00265     }
00266     else {
00267       std::stringstream os;
00268       os <<"Ri"<<_id->ring()<<" Su"<<_id->subsector();
00269       buf += os.str();
00270     }
00271     _sn=buf;
00272   }
00273   return _sn;
00274 }
00275 
00276 //returns a vector with number of channels for each chip in each FEB
00277 std::vector<int> RPCGeomServ::channelInChip(){
00278 
00279   std::vector<int> chipCh(4,8);//Endcap
00280   
00281   if(_id->region()==0){//Barrel
00282     chipCh.clear();
00283 
00284     if (_id->station()<3 && _id->layer()==1){ // i.e. RB1in ||RB2in  
00285       chipCh.push_back(7);
00286       chipCh.push_back(8);
00287     }else if (_id->station() == 1 || _id->station() == 3){//i.e. RB1out || RB3 
00288       chipCh.push_back(7);
00289       chipCh.push_back(7);
00290     }else if (_id->station() == 2){// i.e. RB2out
00291       chipCh.push_back(6);
00292       chipCh.push_back(8);
00293     }else if (_id->sector() == 4 || _id->sector()==10 ||(_id->sector() == 8 &&  _id->subsector()!=1) || (_id->sector() == 12  &&  _id->subsector()==1)){
00294       chipCh.push_back(6);//i.e. Sector 4 &  10 RB4 and Sector 8 &12 RB4+
00295       chipCh.push_back(6);
00296     }else {
00297       chipCh.push_back(8);
00298       chipCh.push_back(8);
00299     }   
00300   }
00301 
00302   return chipCh;
00303 }
00304 
00305 
00306 int 
00307 RPCGeomServ::eta_partition()
00308 {
00309   if (_t<-90){
00310     if (_id->region() == 0 ){
00311       if (this->inverted()) {
00312         _t = 3*(_id->ring())+ (3-_id->roll())-1;
00313       }else{
00314         _t = 3*(_id->ring())+ _id->roll()-2;
00315       }
00316     }else{
00317       _t = _id->region() * (3*(3-_id->ring()) + _id->roll() + 7);
00318     }
00319   }
00320   return _t;
00321 } 
00322 
00323 int
00324 RPCGeomServ::chambernr()
00325 {
00326 
00327   // Station1
00328   if( _id->station() ==1) {
00329     
00330     // in
00331     if(_id->layer() ==1) { 
00332       
00333       if(_id->roll()==1) 
00334         _cnr = 1;
00335       else 
00336         _cnr = 2;
00337     }
00338     //out
00339     else 
00340       {
00341         if(_id->roll()==1) 
00342           _cnr = 3;
00343         else 
00344           _cnr = 4;
00345         
00346       }
00347   }
00348 
00349 
00350   //Station 2
00351   if (_id->station()==2) {
00352    
00353     //in
00354     if(_id->layer()==1) {
00355       
00356       if(_id->roll()==1)//backward
00357         _cnr = 5;
00358       if(_id->roll()==3)//forward
00359         _cnr=6;
00360       if(_id->roll()==2)//middle
00361         _cnr=7;
00362     }
00363     //out
00364     else {
00365       
00366       if(_id->roll()==2)
00367         
00368         _cnr=7;
00369 
00370       if(_id->roll()==1)
00371         _cnr=8;
00372       if(_id->roll()==3)
00373         _cnr=9;
00374     
00375     }
00376   }
00377     
00378   //RB3- RB3+
00379   if(_id->station()==3)
00380     {
00381       if(_id->subsector()==1) {
00382         
00383         if(_id->roll()==1)
00384           _cnr=10;
00385         else 
00386           _cnr=11;
00387       }
00388       else {
00389         
00390         if(_id->roll()==1)
00391           _cnr=12;
00392         else
00393           _cnr=13;
00394       }
00395       
00396     }
00397 
00398   //RB4
00399   if(_id->station()==4) {
00400     
00401     if (_id->sector()== 4) {
00402       
00403       if ( _id->subsector()==2){//RB4-
00404         
00405         if(_id->roll()==1)
00406           _cnr=14;
00407         else
00408           _cnr=15;
00409         
00410       }
00411       
00412       if ( _id->subsector()==3){//RB4+
00413         
00414         if(_id->roll()==1)
00415           _cnr=16;
00416         else
00417           _cnr=17;
00418         
00419       }
00420       
00421       if ( _id->subsector()==1) {//RB4--
00422         
00423         if(_id->roll()==1)
00424           _cnr=18;
00425         else
00426           _cnr=19;
00427       }
00428       
00429       if ( _id->subsector()==4){//RB4++
00430         
00431         if(_id->roll()==1)
00432           _cnr=20;
00433         else
00434           _cnr=21;
00435         
00436       }
00437       
00438     }  
00439     
00440     else 
00441       
00442       {
00443         if(_id->subsector()==1) {
00444           
00445           if(_id->roll()==1)
00446             _cnr=14;
00447           else 
00448             _cnr=15;
00449         }
00450         else {
00451           
00452           if(_id->roll()==1)
00453             _cnr=16;
00454           else
00455             _cnr=17;
00456         } 
00457       } 
00458   }
00459   
00460 
00461   // _cnr=10;
00462   return _cnr;
00463   
00464 }
00465 
00466 int 
00467 RPCGeomServ::segment(){
00468   int seg=0;
00469   int nsec=36;
00470   int nsub=6;
00471   if ( _id->ring()==1 &&  _id->station() > 1) {
00472     nsub=3;
00473     nsec=18;
00474   }
00475   seg =_id->subsector()+nsub*(_id->sector()-1);//+1;
00476   //  if(seg==nsec+1)seg=1;
00477   return seg;
00478 }
00479 
00480 bool
00481 RPCGeomServ::inverted()
00482 {
00483   // return !(this->zpositive() && this->aclockwise());
00484   return !(this->zpositive());
00485 }
00486 
00487 
00488 bool
00489 RPCGeomServ::zpositive()
00490 {
00491   if (_id->region()==0 && _t<-90 ){
00492     if (_id->ring()<0){
00493       _z=false;
00494     }
00495     if (_id->ring()==0){
00496       if (_id->sector() == 1 || _id->sector() == 4 ||
00497           _id->sector() == 5 || _id->sector() == 8 ||
00498           _id->sector() == 9 || _id->sector() == 12){
00499         _z=false;
00500       }
00501     } 
00502   }
00503  
00504   return _z;
00505 }
00506 
00507 bool
00508 RPCGeomServ::aclockwise()
00509 {
00510   if (_id->region()==0 && _t<-90 ){
00511     if (_id->ring() > 0){
00512       if (_id->layer()==2){
00513         _a=false;
00514       }
00515     }else if(_id->ring() <0){
00516       if (_id->layer()==1){
00517         _a=false;
00518       }
00519     }else if(_id->ring() ==0) {
00520       if ((_id->sector() == 1 || _id->sector() == 4 ||
00521            _id->sector() == 5 || _id->sector() == 8 ||
00522            _id->sector() == 9 || _id->sector() == 12) && _id->layer()==1)
00523         _a=false;
00524       else if ((_id->sector() == 2 || _id->sector() == 3 ||
00525                 _id->sector() == 6 || _id->sector() == 7 ||
00526                 _id->sector() == 10|| _id->sector() == 11) && _id->layer()==2)
00527         _a=false;
00528     }
00529   }
00530   return _a;
00531 }
00532 
00533 
00534 
00535 
00536 
00537 RPCGeomServ::RPCGeomServ() : _id(0), _n(""), _sn(""), _t (-99), _z(false), _a(false)
00538 {} 
00539 
00540