CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/L1Trigger/RPCTechnicalTrigger/src/RBCChamberORLogic.cc

Go to the documentation of this file.
00001 // $Id: RBCChamberORLogic.cc,v 1.7 2009/07/04 20:07:40 aosorio Exp $
00002 // Include files 
00003 
00004 
00005 // local
00006 #include "L1Trigger/RPCTechnicalTrigger/interface/RBCChamberORLogic.h"
00007 
00008 //-----------------------------------------------------------------------------
00009 // Implementation file for class : RBCChamberORLogic
00010 // 
00011 // 2008-10-11 : Andres Osorio
00012 //-----------------------------------------------------------------------------
00013 
00014 //=============================================================================
00015 // Standard constructor, initializes variables
00016 //=============================================================================
00017 RBCChamberORLogic::RBCChamberORLogic(  ) {
00018   
00019   m_rbname.push_back(std::string("RB1InFw"));
00020   m_rbname.push_back(std::string("RB1OutFw"));
00021   m_rbname.push_back(std::string("RB22Fw"));
00022   m_rbname.push_back(std::string("RB23Fw"));
00023   m_rbname.push_back(std::string("RB23M"));
00024   m_rbname.push_back(std::string("RB3Fw"));
00025   m_rbname.push_back(std::string("RB4Fw"));
00026   m_rbname.push_back(std::string("RB1InBk"));
00027   m_rbname.push_back(std::string("RB1OutBk"));
00028   m_rbname.push_back(std::string("RB22Bk"));
00029   m_rbname.push_back(std::string("RB23Bk"));
00030   m_rbname.push_back(std::string("RB3Bk"));
00031   m_rbname.push_back(std::string("RB4Bk"));
00032   
00033   itr2names itr = m_rbname.begin();
00034   
00035   while ( itr != m_rbname.end() )
00036   {
00037     m_chamber.insert( make_pair( (*itr) , 0 ) );
00038     ++itr;
00039   }
00040 
00041   m_maxcb    = 13;
00042   m_maxlevel = 3; // 1 <= m <= 6
00043 
00044   m_layersignal = new std::bitset<6>[2];
00045   m_layersignal[0].reset();
00046   m_layersignal[1].reset();
00047   
00048 }
00049 
00050 //=============================================================================
00051 // Destructor
00052 //=============================================================================
00053 RBCChamberORLogic::~RBCChamberORLogic() {
00054   
00055   if ( m_layersignal ) delete[] m_layersignal;
00056   
00057 } 
00058 
00059 //=============================================================================
00060 
00061 void RBCChamberORLogic::process( const RBCInput & _input, std::bitset<2> & _decision ) 
00062 {
00063   
00064   bool status(false);
00065   //std::cout << "RBCChamberORLogic> Working with chambers OR logic ..." << '\n';
00066 
00067   m_layersignal[0].reset();
00068   m_layersignal[1].reset();
00069 
00070   for (int k=0; k < 2; ++k ) 
00071   {
00072     
00073     if( _input.needmapping )
00074       this->createmap( _input.input_sec[k] );
00075     else
00076       this->copymap  ( _input.input_sec[k] );
00077     
00078     status = this->evaluateLayerOR( "RB1InFw"  , "RB1InBk" );
00079     m_layersignal[k].set( 0 , status);
00080     
00081     status = this->evaluateLayerOR( "RB1OutFw" , "RB1OutBk" );
00082     m_layersignal[k].set( 1 , status);
00083     
00084     //... RB2
00085     //... wheel -2,+2 RB2IN divided in 2 eta partitions, RB2OUT in 3 eta
00086     //... wheel -1, 0, +1 RB2IN divided in 3 eta partitions, RB2OUT in 2 eta
00087 
00088     if ( abs( _input.wheelId() ) >= 2 ) {
00089       
00090       status = this->evaluateLayerOR( "RB22Fw"   , "RB22Bk" );
00091       m_layersignal[k].set( 2 , status);
00092       
00093       bool rb23FB = this->evaluateLayerOR( "RB23Fw"   , "RB23Bk" );
00094       bool rb23MF = this->evaluateLayerOR( "RB23Fw"   , "RB23M" );
00095       bool rb23MB = this->evaluateLayerOR( "RB23M"    , "RB23Bk" );
00096       
00097       status = rb23FB || rb23MF || rb23MB;
00098     
00099       m_layersignal[k].set( 3 , status );
00100       
00101     } else {
00102       
00103       status = this->evaluateLayerOR( "RB22Fw"   , "RB22Bk" );
00104       m_layersignal[k].set( 3 , status);
00105       
00106       bool rb23FB = this->evaluateLayerOR( "RB23Fw"   , "RB23Bk" );
00107       bool rb23MF = this->evaluateLayerOR( "RB23Fw"   , "RB23M" );
00108       bool rb23MB = this->evaluateLayerOR( "RB23M"    , "RB23Bk" );
00109       
00110       status = rb23FB || rb23MF || rb23MB;
00111     
00112       m_layersignal[k].set( 2 , status );
00113       
00114     }
00115     
00116     //.......
00117     
00118     status = this->evaluateLayerOR( "RB3Fw"    , "RB3Bk" );
00119     m_layersignal[k].set( 4 , status);
00120     
00121     status = this->evaluateLayerOR( "RB4Fw"    , "RB4Bk" );
00122     m_layersignal[k].set( 5 , status);
00123     
00124     reset();
00125     
00126     //... apply now majority level criteria:
00127     
00128     int _majority = int(m_layersignal[k].count());
00129     
00130     if ( _majority >= m_maxlevel) _decision[k] = true;
00131     else _decision[k] = false;
00132     
00133   }
00134 
00135   //...all done!
00136   
00137 }
00138 
00139 void RBCChamberORLogic::setBoardSpecs( const RBCBoardSpecs::RBCBoardConfig & specs )
00140 {
00141   
00142   m_maxlevel = specs.m_MayorityLevel;
00143     
00144 }
00145 
00146 void RBCChamberORLogic::copymap( const std::bitset<15> & _input ) 
00147 {
00148   
00149   m_chamber[m_rbname[0]]  = _input[0];
00150   m_chamber[m_rbname[1]]  = _input[1];
00151   m_chamber[m_rbname[2]]  = _input[2];
00152   m_chamber[m_rbname[3]]  = _input[3];
00153   m_chamber[m_rbname[4]]  = _input[4];
00154   m_chamber[m_rbname[5]]  = _input[5];
00155   m_chamber[m_rbname[6]]  = _input[6];
00156   m_chamber[m_rbname[7]]  = _input[7];
00157   m_chamber[m_rbname[8]]  = _input[8];
00158   m_chamber[m_rbname[9]]  = _input[9];
00159   m_chamber[m_rbname[10]] = _input[10];
00160   m_chamber[m_rbname[11]] = _input[11];
00161   m_chamber[m_rbname[12]] = _input[12];
00162   
00163 }
00164 
00165 void RBCChamberORLogic::createmap( const std::bitset<15> & _input ) 
00166 {
00167   
00168   m_chamber[m_rbname[0]]  = _input[3];
00169   m_chamber[m_rbname[1]]  = _input[4];
00170   m_chamber[m_rbname[2]]  = _input[5];
00171   m_chamber[m_rbname[3]]  = _input[8];
00172   m_chamber[m_rbname[4]]  = _input[7];
00173   m_chamber[m_rbname[5]]  = _input[11];
00174   m_chamber[m_rbname[6]]  = _input[12] || _input[14];
00175   m_chamber[m_rbname[7]]  = _input[0];
00176   m_chamber[m_rbname[8]]  = _input[1];
00177   m_chamber[m_rbname[9]]  = _input[2];
00178   m_chamber[m_rbname[10]] = _input[6];
00179   m_chamber[m_rbname[11]] = _input[9];
00180   m_chamber[m_rbname[12]] = _input[10] || _input[13];
00181   
00182 }
00183 
00184 void RBCChamberORLogic::reset() 
00185 {
00186   
00187   //... Reset map for next sector analysis
00188   m_chamber.clear();
00189   
00190   itr2names itr = m_rbname.begin();
00191   
00192   while ( itr != m_rbname.end() )
00193   {
00194     m_chamber.insert( make_pair( (*itr) , 0 ) );
00195     ++itr;
00196   }
00197   
00198   //m_layersignal[0].reset();
00199   //m_layersignal[1].reset();
00200   
00201 }
00202 
00203 bool RBCChamberORLogic::evaluateLayerOR(const char * _chA, const char *_chB )
00204 {
00205   
00206   itr2chambers ptr1 = m_chamber.find( std::string(_chA) );
00207   itr2chambers ptr2 = m_chamber.find( std::string(_chB) );
00208   
00209   if ( ptr1 == m_chamber.end() || ptr2 == m_chamber.end() ) {
00210     //handle error...
00211     std::cout << "RBCChamberORLogic> Cannot find a chamber name" << '\n';
00212     return false;
00213   }
00214   
00215   return ( ptr1->second || ptr2->second );
00216   
00217 }
00218