CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch9/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         os<<"_";
00080         buf += os.str();
00081       }
00082       {
00083         std::stringstream os;
00084         if (_id->roll()==1)
00085           os<<"Backward";
00086         else if (_id->roll() == 3)
00087           os<<"Forward";
00088         else if (_id->roll() == 2)
00089         os <<"Middle";
00090         buf += os.str();
00091       }
00092     }
00093     else {
00094       buf="RE";
00095       
00096       {
00097         std::stringstream os;
00098         os << std::setw(2)<<std::setfill('+')<<_id->station()*_id->region()
00099            <<std::setfill(' ')<<"_";
00100         buf += os.str();    
00101       }
00102       
00103       {
00104         std::stringstream os;
00105         os <<"R"<<_id->ring();
00106         os <<"_CH"<<std::setw(2)<<std::setfill('0')<<this->segment();
00107         buf += os.str();
00108       } 
00109 
00110       {
00111         buf += "_";
00112         std::stringstream os;
00113         if (_id->roll()==1)
00114           os<<"A";
00115         else if (_id->roll() == 2)
00116           os<<"B";
00117         else if (_id->roll() == 3)
00118           os <<"C";
00119         else if (_id->roll() == 4)
00120           os <<"D";
00121         buf += os.str();
00122       }
00123     }
00124     _n=buf;
00125   }
00126   return _n;
00127 }
00128 
00129 std::string 
00130 RPCGeomServ::shortname()
00131 {
00132   if (_sn.size()<1)
00133     {
00134     std::string buf;
00135 
00136     if (_id->region()==0){
00137       std::stringstream os;
00138       os <<"RB"<<_id->station();
00139       if (_id->station()<=2){
00140         if (_id->layer()==1){
00141           os<<"in";
00142         }else{
00143           os<<"out";
00144         }
00145       }else{
00146         if (_id->sector()== 4 && _id->station()==4){
00147           if ( _id->subsector()==1){
00148             os<<"--";
00149           }
00150           else if ( _id->subsector()==2){
00151             os <<",-";
00152           }
00153           else if ( _id->subsector()==3){
00154             os <<"+";
00155           }
00156           else if ( _id->subsector()==4){
00157             os <<"++";
00158           }
00159         }else{
00160           if (_id->subsector()==1)
00161             os <<",-";
00162           else
00163             os <<"+";
00164         }
00165       }
00166       if (_id->roll()==1)
00167         os<<" B";
00168       else if (_id->roll() == 3)
00169         os<<" F";
00170       else if (_id->roll() == 2)
00171         os<<" M";
00172       buf += os.str();
00173     }
00174     else {
00175       std::stringstream os;
00176       os <<"Ri"<<_id->ring()<<" Su"<<_id->subsector();
00177       buf += os.str();
00178     }
00179     _sn=buf;
00180   }
00181   return _sn;
00182 }
00183 
00184 //returns a vector with number of channels for each chip in each FEB
00185 std::vector<int> RPCGeomServ::channelInChip(){
00186 
00187   std::vector<int> chipCh(4,8);//Endcap
00188   
00189   if(_id->region()==0){//Barrel
00190     chipCh.clear();
00191 
00192     if (_id->station()<3 && _id->layer()==1){ // i.e. RB1in ||RB2in  
00193       chipCh.push_back(7);
00194       chipCh.push_back(8);
00195     }else if (_id->station() == 1 || _id->station() == 3){//i.e. RB1out || RB3 
00196       chipCh.push_back(7);
00197       chipCh.push_back(7);
00198     }else if (_id->station() == 2){// i.e. RB2out
00199       chipCh.push_back(6);
00200       chipCh.push_back(8);
00201     }else if (_id->sector() == 4 || _id->sector()==10 ||(_id->sector() == 8 &&  _id->subsector()!=1) || (_id->sector() == 12  &&  _id->subsector()==1)){
00202       chipCh.push_back(6);//i.e. Sector 4 &  10 RB4 and Sector 8 &12 RB4+
00203       chipCh.push_back(6);
00204     }else {
00205       chipCh.push_back(8);
00206       chipCh.push_back(8);
00207     }   
00208   }
00209 
00210   return chipCh;
00211 }
00212 
00213 
00214 int 
00215 RPCGeomServ::eta_partition()
00216 {
00217   if (_t<-90){
00218     if (_id->region() == 0 ){
00219       if (this->inverted()) {
00220         _t = 3*(_id->ring())+ (3-_id->roll())-1;
00221       }else{
00222         _t = 3*(_id->ring())+ _id->roll()-2;
00223       }
00224     }else{
00225       _t = _id->region() * (3*(3-_id->ring()) + _id->roll() + 7);
00226     }
00227   }
00228   return _t;
00229 } 
00230 
00231 int
00232 RPCGeomServ::chambernr()
00233 {
00234 
00235   // Station1
00236   if( _id->station() ==1) {
00237     
00238     // in
00239     if(_id->layer() ==1) { 
00240       
00241       if(_id->roll()==1) 
00242         _cnr = 1;
00243       else 
00244         _cnr = 2;
00245     }
00246     //out
00247     else 
00248       {
00249         if(_id->roll()==1) 
00250           _cnr = 3;
00251         else 
00252           _cnr = 4;
00253         
00254       }
00255   }
00256 
00257 
00258   //Station 2
00259   if (_id->station()==2) {
00260    
00261     //in
00262     if(_id->layer()==1) {
00263       
00264       if(_id->roll()==1)//backward
00265         _cnr = 5;
00266       if(_id->roll()==3)//forward
00267         _cnr=6;
00268       if(_id->roll()==2)//middle
00269         _cnr=7;
00270     }
00271     //out
00272     else {
00273       
00274       if(_id->roll()==2)
00275         
00276         _cnr=7;
00277 
00278       if(_id->roll()==1)
00279         _cnr=8;
00280       if(_id->roll()==3)
00281         _cnr=9;
00282     
00283     }
00284   }
00285     
00286   //RB3- RB3+
00287   if(_id->station()==3)
00288     {
00289       if(_id->subsector()==1) {
00290         
00291         if(_id->roll()==1)
00292           _cnr=10;
00293         else 
00294           _cnr=11;
00295       }
00296       else {
00297         
00298         if(_id->roll()==1)
00299           _cnr=12;
00300         else
00301           _cnr=13;
00302       }
00303       
00304     }
00305 
00306   //RB4
00307   if(_id->station()==4) {
00308     
00309     if (_id->sector()== 4) {
00310       
00311       if ( _id->subsector()==2){//RB4-
00312         
00313         if(_id->roll()==1)
00314           _cnr=14;
00315         else
00316           _cnr=15;
00317         
00318       }
00319       
00320       if ( _id->subsector()==3){//RB4+
00321         
00322         if(_id->roll()==1)
00323           _cnr=16;
00324         else
00325           _cnr=17;
00326         
00327       }
00328       
00329       if ( _id->subsector()==1) {//RB4--
00330         
00331         if(_id->roll()==1)
00332           _cnr=18;
00333         else
00334           _cnr=19;
00335       }
00336       
00337       if ( _id->subsector()==4){//RB4++
00338         
00339         if(_id->roll()==1)
00340           _cnr=20;
00341         else
00342           _cnr=21;
00343         
00344       }
00345       
00346     }  
00347     
00348     else 
00349       
00350       {
00351         if(_id->subsector()==1) {
00352           
00353           if(_id->roll()==1)
00354             _cnr=14;
00355           else 
00356             _cnr=15;
00357         }
00358         else {
00359           
00360           if(_id->roll()==1)
00361             _cnr=16;
00362           else
00363             _cnr=17;
00364         } 
00365       } 
00366   }
00367   
00368 
00369   // _cnr=10;
00370   return _cnr;
00371   
00372 }
00373 
00374 int 
00375 RPCGeomServ::segment(){
00376   int seg=0;
00377   int nsec=36;
00378   int nsub=6;
00379   if ( _id->ring()==1 &&  _id->station() > 1) {
00380     nsub=3;
00381     nsec=18;
00382   }
00383   seg =_id->subsector()+nsub*(_id->sector()-1);//+1;
00384   //  if(seg==nsec+1)seg=1;
00385   return seg;
00386 }
00387 
00388 bool
00389 RPCGeomServ::inverted()
00390 {
00391   // return !(this->zpositive() && this->aclockwise());
00392   return !(this->zpositive());
00393 }
00394 
00395 
00396 bool
00397 RPCGeomServ::zpositive()
00398 {
00399   if (_id->region()==0 && _t<-90 ){
00400     if (_id->ring()<0){
00401       _z=false;
00402     }
00403     if (_id->ring()==0){
00404       if (_id->sector() == 1 || _id->sector() == 4 ||
00405           _id->sector() == 5 || _id->sector() == 8 ||
00406           _id->sector() == 9 || _id->sector() == 12){
00407         _z=false;
00408       }
00409     } 
00410   }
00411  
00412   return _z;
00413 }
00414 
00415 bool
00416 RPCGeomServ::aclockwise()
00417 {
00418   if (_id->region()==0 && _t<-90 ){
00419     if (_id->ring() > 0){
00420       if (_id->layer()==2){
00421         _a=false;
00422       }
00423     }else if(_id->ring() <0){
00424       if (_id->layer()==1){
00425         _a=false;
00426       }
00427     }else if(_id->ring() ==0) {
00428       if ((_id->sector() == 1 || _id->sector() == 4 ||
00429            _id->sector() == 5 || _id->sector() == 8 ||
00430            _id->sector() == 9 || _id->sector() == 12) && _id->layer()==1)
00431         _a=false;
00432       else if ((_id->sector() == 2 || _id->sector() == 3 ||
00433                 _id->sector() == 6 || _id->sector() == 7 ||
00434                 _id->sector() == 10|| _id->sector() == 11) && _id->layer()==2)
00435         _a=false;
00436     }
00437   }
00438   return _a;
00439 }
00440 
00441 
00442 
00443 
00444 
00445 RPCGeomServ::RPCGeomServ() : _id(0), _n(""), _sn(""), _t (-99), _z(false), _a(false)
00446 {} 
00447 
00448