CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/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 ),
00008     _n( "" ),
00009     _sn( "" ),
00010     _cn( "" ),
00011     _t( -99 ),
00012     _z( true ),
00013     _a( true )
00014 {}
00015 
00016 RPCGeomServ::~RPCGeomServ( void )
00017 {}
00018  
00019 std::string 
00020 RPCGeomServ::name( void )
00021 {
00022   if( _n.size() < 1 )
00023   {
00024     int station = _id->station();
00025     int region = _id->region();
00026     int roll = _id->roll();
00027     int ring = _id->ring();
00028     int layer = _id->layer();
00029     int sector = _id->sector();
00030     int subsector = _id->subsector();
00031 
00032     std::stringstream os;
00033     
00034     if( region == 0 )
00035     {
00036       os << "W";
00037       os << std::setw(2) << std::setfill('+') << ring
00038          << std::setfill(' ') << "_";
00039 
00040       os << "RB" << station;
00041       if ( station <= 2){
00042         (layer == 1 ) ? os << "in" : os << "out";
00043         
00044       }else if( station > 2 )
00045       {
00046         if( sector == 4 && station == 4 )
00047         {
00048           if( subsector == 1 )
00049           {
00050             os << "--";
00051           }
00052           else if( subsector == 2 )
00053           {
00054             os << "-";
00055           }
00056           else if( subsector == 3 )
00057           {
00058             os << "+";
00059           }
00060           else if( subsector == 4 )
00061           {
00062             os << "++";
00063           }
00064         }
00065           
00066         if( station == 3 )
00067         {
00068           if( subsector == 1 )
00069             os << "-";
00070           else
00071             os << "+";
00072         }       
00073         else if( station == 4
00074                  && sector != 9
00075                  && sector !=11
00076                  && sector != 4 )
00077         {
00078           if( subsector == 1 )
00079             os << "-";
00080           else
00081             os << "+";
00082         }
00083       }
00084         
00085       os << "_";
00086       os << "S" << std::setw(2) << std::setfill('0')
00087          << sector << std::setfill(' ');
00088       if( roll == 1 )
00089         os << "_Backward";
00090       else if( roll == 3 )
00091         os << "_Forward";
00092       else if( roll == 2 )
00093         os << "_Middle";
00094     }
00095     else
00096     {
00097       os << "RE";
00098 
00099       os << std::setw(2) << std::setfill('+') << station * region
00100          << std::setfill(' ') << "_";
00101 
00102       os << "R" << ring;
00103       os << "_CH" << std::setw(2) << std::setfill('0') << this->segment();
00104 
00105       if( roll == 1 )
00106         os << "_A";
00107       else if( roll == 2 )
00108         os << "_B";
00109       else if( roll == 3 )
00110         os << "_C";
00111       else if( roll == 4 )
00112         os << "_D";
00113     }
00114     _n = os.str();
00115   }
00116   return _n;
00117 }
00118 
00119 std::string 
00120 RPCGeomServ::chambername()
00121 {
00122   if( _cn.size() < 1 )
00123   {
00124     int station = _id->station();
00125     int region = _id->region();
00126     int ring = _id->ring();
00127     int layer = _id->layer();
00128     int sector = _id->sector();
00129     int subsector = _id->subsector();
00130 
00131     std::stringstream os;
00132     
00133     if( region == 0 )
00134     {
00135       os << "W";
00136 
00137       os << std::setw(2) << std::setfill('+') << ring
00138          << std::setfill(' ') << "_";
00139 
00140       os << "RB" << station;
00141       if ( station <= 2 ) {
00142         
00143         (layer == 1 ) ? os << "in" : os << "out";
00144         
00145       }else if( station > 2 )
00146       {
00147         if( sector == 4 && station == 4 )
00148         {
00149           if( subsector == 1 )
00150           {
00151             os << "--";
00152           }
00153           else if( subsector == 2 )
00154           {
00155             os << "-";
00156           }
00157           else if( subsector == 3 )
00158           {
00159             os << "+";
00160           }
00161           else if( subsector == 4 )
00162           {
00163             os <<"++";
00164           }
00165         }
00166           
00167         if( station == 3 )
00168         {
00169           if( subsector == 1 )
00170             os << "-";
00171           else
00172             os << "+";
00173         }
00174         else if( station == 4
00175                  && sector != 9
00176                  && sector != 11
00177                  && sector != 4 )
00178         {
00179           if( subsector == 1 )
00180             os << "-";
00181           else
00182             os << "+";
00183         }
00184       }
00185         
00186       os << "_";
00187       os << "S" << std::setw(2) << std::setfill('0')
00188          << sector << std::setfill(' ');
00189     }
00190     else
00191     {
00192       os << "RE"; 
00193     
00194       os << std::setw(2) << std::setfill('+') << station * region
00195          << std::setfill(' ') << "_";
00196 
00197       os << "R" << ring;
00198       os << "_CH" << std::setw(2) << std::setfill('0') << this->segment();
00199     }
00200     _cn = os.str();
00201   }
00202   return _cn;
00203 }
00204 
00205 std::string 
00206 RPCGeomServ::shortname( void )
00207 {
00208   if( _sn.size() < 1 )
00209   {
00210     int station = _id->station();
00211     int region = _id->region();
00212     int roll = _id->roll();
00213     int ring = _id->ring();
00214     int layer = _id->layer();
00215     int sector = _id->sector();
00216     int subsector = _id->subsector();
00217 
00218     std::stringstream os;
00219 
00220     if( region == 0 )
00221     {
00222       os << "RB" << station;
00223       if( station <= 2 ){
00224 
00225         (layer == 1 ) ? os << "in" : os << "out";
00226 
00227       }
00228       else
00229       {
00230         if( sector == 4 && station == 4 )
00231         {
00232           if( subsector == 1 )
00233           {
00234             os << "--";
00235           }
00236           else if( subsector == 2 )
00237           {
00238             os << ",-";
00239           }
00240           else if( subsector == 3 )
00241           {
00242             os << "+";
00243           }
00244           else if( subsector == 4 )
00245           {
00246             os << "++";
00247           }
00248         }
00249         else
00250         {
00251           if( subsector == 1 )
00252             os << ",-";
00253           else
00254             os << "+";
00255         }
00256       }
00257       if( roll == 1 )
00258         os << " B";
00259       else if( roll == 3 )
00260         os << " F";
00261       else if( roll == 2 )
00262         os << " M";
00263     }
00264     else
00265     {
00266       os << "Ri" << ring << " Su" << subsector;
00267     }
00268     _sn = os.str();
00269   }
00270   return _sn;
00271 }
00272 
00273 // returns a vector with number of channels for each chip in each FEB
00274 std::vector<int>
00275 RPCGeomServ::channelInChip( void )
00276 {
00277   std::vector<int> chipCh(4,8);//Endcap
00278   
00279   if(_id->region()==0){//Barrel
00280     chipCh.clear();
00281 
00282     int station = _id->station();
00283   
00284     if (station<3 && _id->layer()==1){ // i.e. RB1in ||RB2in  
00285       chipCh.push_back(7);
00286       chipCh.push_back(8);
00287     }else if (station == 1 || station == 3){//i.e. RB1out || RB3 
00288       chipCh.push_back(7);
00289       chipCh.push_back(7);
00290     }else if (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( void )
00468 {
00469   int nsub = 6;
00470   int station = _id->station();
00471   int ring = _id->ring();
00472   ( ring == 1 && station > 1 ) ? nsub = 3 : nsub = 6;
00473 
00474   return( _id->subsector() + nsub * ( _id->sector() - 1 ));
00475 }
00476 
00477 bool
00478 RPCGeomServ::inverted()
00479 {
00480   // return !(this->zpositive() && this->aclockwise());
00481   return !(this->zpositive());
00482 }
00483 
00484 
00485 bool
00486 RPCGeomServ::zpositive()
00487 {
00488   if (_id->region()==0 && _t<-90 ){
00489     if (_id->ring()<0){
00490       _z=false;
00491     }
00492     if (_id->ring()==0){
00493       if (_id->sector() == 1 || _id->sector() == 4 ||
00494           _id->sector() == 5 || _id->sector() == 8 ||
00495           _id->sector() == 9 || _id->sector() == 12){
00496         _z=false;
00497       }
00498     } 
00499   }
00500  
00501   return _z;
00502 }
00503 
00504 bool
00505 RPCGeomServ::aclockwise()
00506 {
00507   if (_id->region()==0 && _t<-90 ){
00508     if (_id->ring() > 0){
00509       if (_id->layer()==2){
00510         _a=false;
00511       }
00512     }else if(_id->ring() <0){
00513       if (_id->layer()==1){
00514         _a=false;
00515       }
00516     }else if(_id->ring() ==0) {
00517       if ((_id->sector() == 1 || _id->sector() == 4 ||
00518            _id->sector() == 5 || _id->sector() == 8 ||
00519            _id->sector() == 9 || _id->sector() == 12) && _id->layer()==1)
00520         _a=false;
00521       else if ((_id->sector() == 2 || _id->sector() == 3 ||
00522                 _id->sector() == 6 || _id->sector() == 7 ||
00523                 _id->sector() == 10|| _id->sector() == 11) && _id->layer()==2)
00524         _a=false;
00525     }
00526   }
00527   return _a;
00528 }
00529 
00530 RPCGeomServ::RPCGeomServ() : _id(0), _n(""), _sn(""), _cn(""), _t (-99), _z(false), _a(false)
00531 {} 
00532 
00533