CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

RBCProcessRPCSimDigis Class Reference

#include <interface/RBCProcessRPCSimDigis.h>

Inheritance diagram for RBCProcessRPCSimDigis:
ProcessInputSignal

List of all members.

Public Member Functions

void builddata ()
void configure ()
void initialize (std::vector< RPCData * > &)
int next ()
void print_output ()
 RBCProcessRPCSimDigis (const edm::ESHandle< RPCGeometry > &, const edm::Handle< edm::DetSetVector< RPCDigiSimLink > > &)
 RBCProcessRPCSimDigis ()
 Standard constructor.
void reset ()
RPCInputSignalretrievedata ()
void rewind ()
void showfirst ()
virtual ~RBCProcessRPCSimDigis ()
 Destructor.

Private Member Functions

int getBarrelLayer (const int &, const int &)
void setDigiAt (int, int)
void setInputBit (std::bitset< 15 > &, int)

Private Attributes

RPCDatam_block
std::map< int, RBCInput * > m_data
bool m_debug
edm::DetSet< RPCDigiSimLink >
::const_iterator 
m_digiItr
std::map< int, int > m_layermap
RPCInputSignalm_lbin
edm::DetSetVector
< RPCDigiSimLink >
::const_iterator 
m_linkItr
int m_maxBxWindow
const edm::Handle
< edm::DetSetVector
< RPCDigiSimLink > > * 
m_ptr_digiSimLink
const edm::ESHandle
< RPCGeometry > * 
m_ptr_rpcGeom
std::vector< int > m_sec1id
std::vector< int > m_sec2id
std::map< int, std::vector
< RPCData * > > 
m_vecDataperBx
std::vector< int > m_wheelid

Detailed Description

Author:
Andres Felipe Osorio Oliveros
Date:
2009-09-20

Definition at line 40 of file RBCProcessRPCSimDigis.h.


Constructor & Destructor Documentation

RBCProcessRPCSimDigis::RBCProcessRPCSimDigis ( )

Standard constructor.

RBCProcessRPCSimDigis::RBCProcessRPCSimDigis ( const edm::ESHandle< RPCGeometry > &  rpcGeom,
const edm::Handle< edm::DetSetVector< RPCDigiSimLink > > &  digiSimLink 
)

Definition at line 15 of file RBCProcessRPCSimDigis.cc.

References configure(), m_data, m_debug, m_lbin, m_ptr_digiSimLink, and m_ptr_rpcGeom.

{
  
  m_ptr_rpcGeom  = & rpcGeom;
  m_ptr_digiSimLink = & digiSimLink;
  
  m_lbin = dynamic_cast<RPCInputSignal*>( new RBCLinkBoardGLSignal( &m_data ) );
  
  m_debug = false;
  
  configure();
  
}
RBCProcessRPCSimDigis::~RBCProcessRPCSimDigis ( ) [virtual]

Destructor.

Definition at line 82 of file RBCProcessRPCSimDigis.cc.

References m_layermap, m_lbin, m_sec1id, m_sec2id, m_wheelid, and reset().

                                              {
  
  if ( m_lbin ) delete m_lbin;

  m_sec1id.clear();
  m_sec2id.clear();
  m_wheelid.clear();
  m_layermap.clear();

  reset();
  
} 

Member Function Documentation

void RBCProcessRPCSimDigis::builddata ( )

Definition at line 248 of file RBCProcessRPCSimDigis.cc.

References abs, gather_cfg::cout, gen::k, m_data, m_debug, m_vecDataperBx, and RBCInput::needmapping.

Referenced by next().

{
  
  int bx(0);
  int code(0);
  int bxsign(1);
  std::vector<RPCData*>::iterator itr;
  std::map<int, std::vector<RPCData*> >::iterator itr2;
  
  itr2 = m_vecDataperBx.begin();
  if( itr2 == ( m_vecDataperBx.end() ) ) return;
  
  while ( itr2 != m_vecDataperBx.end() ) {
    
    bx = (*itr2).first;
    
    if ( bx != 0 ) bxsign = ( bx / abs(bx) );
    else bxsign = 1;
    
    for(itr = (*itr2).second.begin(); itr != (*itr2).second.end(); ++itr) {
      
      for(int k=0; k < 6; ++k) {
        
        code = bxsign * ( 1000000*abs(bx)
                          + 10000*(*itr)->wheelIdx()
                          + 100  *(*itr)->m_sec1[k]
                          + 1    *(*itr)->m_sec2[k] );

        
        RBCInput * signal = & (*itr)->m_orsignals[k];
        signal->needmapping = false;
        
        if ( signal->hasData )
          m_data.insert( std::make_pair( code , signal) );
        
      }
    }
    
    ++itr2;
    
  }
  
  if ( m_debug ) std::cout << "builddata: completed. size of data: " << m_data.size() << std::endl;
  
}
void RBCProcessRPCSimDigis::configure ( )

Definition at line 30 of file RBCProcessRPCSimDigis.cc.

References m_layermap, m_maxBxWindow, m_sec1id, m_sec2id, and m_wheelid.

Referenced by RBCProcessRPCSimDigis().

{
  
  m_wheelid.push_back(-2); //-2
  m_wheelid.push_back(-1); //-1
  m_wheelid.push_back(0);  // 0
  m_wheelid.push_back( 1); //+1
  m_wheelid.push_back( 2); //+2
  
  m_sec1id.push_back(12);
  m_sec2id.push_back(1);
  m_sec1id.push_back(2);
  m_sec2id.push_back(3);
  m_sec1id.push_back(4);
  m_sec2id.push_back(5);
  m_sec1id.push_back(6);
  m_sec2id.push_back(7);
  m_sec1id.push_back(8);
  m_sec2id.push_back(9);
  m_sec1id.push_back(10);
  m_sec2id.push_back(11);
  
  m_layermap[113]     = 0;  //RB1InFw
  m_layermap[123]     = 1;  //RB1OutFw
  
  m_layermap[20213]   = 2;  //RB22Fw
  m_layermap[20223]   = 2;  //RB22Fw
  m_layermap[30223]   = 3;  //RB23Fw
  m_layermap[30213]   = 3;  //RB23Fw
  m_layermap[30212]   = 4;  //RB23M
  m_layermap[30222]   = 4;  //RB23M
  
  m_layermap[313]     = 5;  //RB3Fw
  m_layermap[413]     = 6;  //RB4Fw
  m_layermap[111]     = 7;  //RB1InBk
  m_layermap[121]     = 8;  //RB1OutBk
  
  m_layermap[20211]   = 9;  //RB22Bw
  m_layermap[20221]   = 9;  //RB22Bw
  m_layermap[30211]   = 10; //RB23Bw
  m_layermap[30221]   = 10; //RB23Bw
  
  m_layermap[311]     = 11; //RB3Bk
  m_layermap[411]     = 12; //RB4Bk
  
  m_maxBxWindow = 3;
  
}
int RBCProcessRPCSimDigis::getBarrelLayer ( const int &  _layer,
const int &  _station 
) [private]

Definition at line 294 of file RBCProcessRPCSimDigis.cc.

Referenced by next().

{
  
  //... Calculates the generic Barrel Layer (1 to 6)
  int blayer(0);
  
  if ( _station < 3 ) {
    blayer = ( (_station-1) * 2 ) + _layer;
  }
  else {
    blayer = _station + 2;
  }
  
  return blayer;
  
}
void RBCProcessRPCSimDigis::initialize ( std::vector< RPCData * > &  dataVec)

Definition at line 217 of file RBCProcessRPCSimDigis.cc.

References gather_cfg::cout, RBCInput::hasData, i, RBCInput::input_sec, j, m_block, m_debug, RPCData::m_orsignals, RPCData::m_sec1, m_sec1id, RPCData::m_sec2, m_sec2id, RPCData::m_wheel, m_wheelid, and RBCInput::needmapping.

Referenced by next().

{
  
  if ( m_debug ) std::cout << "initialize" << std::endl;
  
  int maxWheels = 5;
  int maxRbcBrds = 6;
  
  for(int i=0; i < maxWheels; ++i) {
    
    m_block = new RPCData();
    
    m_block->m_wheel = m_wheelid[i];
    
    for(int j=0; j < maxRbcBrds; ++j) {
      m_block->m_sec1[j] = m_sec1id[j];
      m_block->m_sec2[j] = m_sec2id[j];
      m_block->m_orsignals[j].input_sec[0].reset();
      m_block->m_orsignals[j].input_sec[1].reset();
      m_block->m_orsignals[j].needmapping = false;
      m_block->m_orsignals[j].hasData = false;
    }

    dataVec.push_back( m_block );
    
  }
  
  if ( m_debug ) std::cout << "initialize: completed" << std::endl;
  
}
int RBCProcessRPCSimDigis::next ( void  ) [virtual]

Implements ProcessInputSignal.

Definition at line 96 of file RBCProcessRPCSimDigis.cc.

References abs, edm::DetSetVector< T >::begin(), builddata(), gather_cfg::cout, cond::rpcobgas::detid, edm::DetSetVector< T >::end(), getBarrelLayer(), RPCRoll::id(), ExpressReco_HICollisions_FallBack::id, initialize(), RPCRoll::isForward(), RPCDetId::layer(), m_block, m_data, m_debug, m_digiItr, m_linkItr, m_maxBxWindow, m_vecDataperBx, print_output(), reset(), RPCDetId::ring(), RPCDetId::sector(), setDigiAt(), relativeConstraints::station, and RPCDetId::station().

                                {
  
  //...clean up previous data contents
  
  reset();
  
  int ndigis(0);

  for( m_linkItr = (*m_ptr_digiSimLink)->begin();
       m_linkItr != (*m_ptr_digiSimLink)->end();
       ++m_linkItr ) {
    
    for ( m_digiItr = m_linkItr->data.begin();
          m_digiItr != m_linkItr->data.end();
          ++m_digiItr ) {
      
      if ( m_debug ) std::cout << "looping over digis 1 ..." << std::endl;
      
      int bx = (*m_digiItr).getBx();
      
      if ( abs(bx) >= m_maxBxWindow ) {
        if ( m_debug )  std::cout << "RBCProcessRPCSimDigis> found a bx bigger than max allowed: "
                                  << bx << std::endl;
        continue;
      }
      
      uint32_t detid = m_digiItr->getDetUnitId();
      const RPCDetId id( detid );
      const RPCRoll * roll = dynamic_cast<const RPCRoll* >( (*m_ptr_rpcGeom)->roll(id));
      
      if((roll->isForward())) {
        if( m_debug ) std::cout << "RBCProcessRPCSimDigis: roll is forward" << std::endl;
        continue;
      }
      
      int wheel   = roll->id().ring();                    // -2,-1,0,+1,+2
      int sector  = roll->id().sector();                  // 1 to 12 
      int layer   = roll->id().layer();                   // 1,2
      int station = roll->id().station();                 // 1-4
      int blayer  = getBarrelLayer( layer, station );     // 1 to 6
      int rollid  = id.roll();
      
      int digipos = (station * 100) + (layer * 10) + rollid;
      
      if ( (wheel == -1 || wheel == 0 || wheel == 1) && station == 2 && layer == 1 )
        digipos = 30000 + digipos;
      if ( (wheel == -2 || wheel == 2) && station == 2 && layer == 2 )
        digipos = 30000 + digipos;
      
      if ( (wheel == -1 || wheel == 0 || wheel == 1) && station == 2 && layer == 2 )
        digipos = 20000 + digipos;
      if ( (wheel == -2 || wheel == 2) && station == 2 && layer == 1 )
        digipos = 20000 + digipos;
      
      if ( m_debug ) std::cout << "Bx: "      << bx      << '\t'
                               << "Wheel: "   << wheel   << '\t'
                               << "Sector: "  << sector  << '\t'
                               << "Station: " << station << '\t'
                               << "Layer: "   << layer   << '\t'
                               << "B-Layer: " << blayer  << '\t'
                               << "Roll id: " << rollid  << '\t'
                               << "Digi at: " << digipos << '\n';
      
      //... Construct the RBCinput objects
      std::map<int,std::vector<RPCData*> >::iterator itr;
      itr = m_vecDataperBx.find( bx );
      
      if ( itr == m_vecDataperBx.end() ) {
        if ( m_debug ) std::cout << "Found a new Bx: " << bx << std::endl;
        std::vector<RPCData*> wheelData;
        initialize(wheelData);
        m_vecDataperBx[bx] = wheelData; 
        this->m_block = wheelData[ (wheel + 2) ];
        setDigiAt( sector, digipos );
      }
      else{
        this->m_block = (*itr).second[ (wheel + 2) ];
        setDigiAt( sector, digipos );
      }
      
      if ( m_debug ) std::cout << "looping over digis 2 ..." << std::endl;
      
      ++ndigis;
      
    }
    
  }
  
  if ( m_debug ) std::cout << "size of data vectors: " << m_vecDataperBx.size() << std::endl;
  
  builddata();
  
  if ( m_debug ) {
    std::cout << "after reset" << std::endl;
    print_output();
  }
  
  if ( m_debug ) std::cout << "RBCProcessRPCSimDigis: DataSize: " << m_data.size() 
                           << " ndigis " << ndigis << std::endl;
  
  if ( m_data.size() <= 0 ) return 0;
  
  return 1;
  
}
void RBCProcessRPCSimDigis::print_output ( )

Definition at line 354 of file RBCProcessRPCSimDigis.cc.

References gather_cfg::cout, and m_data.

Referenced by next().

{

  std::cout << "RBCProcessRPCSimDigis> Output starts" << std::endl;
  
  std::map<int,RBCInput*>::const_iterator itr;
  for( itr = m_data.begin(); itr != m_data.end(); ++itr) {
    std::cout << (*itr).first << '\t' << (* (*itr).second ) << '\n';
  }

  std::cout << "RBCProcessRPCSimDigis> Output ends" << std::endl;
  
}
void RBCProcessRPCSimDigis::reset ( void  )

Definition at line 202 of file RBCProcessRPCSimDigis.cc.

References m_vecDataperBx.

Referenced by next(), and ~RBCProcessRPCSimDigis().

{
  
  std::map<int,std::vector<RPCData*> >::iterator itr1;
  for( itr1 = m_vecDataperBx.begin(); itr1 != m_vecDataperBx.end(); ++itr1) {
    std::vector<RPCData*>::iterator itr2;
    for(itr2 = (*itr1).second.begin(); itr2 != (*itr1).second.end();++itr2 )
      if ( (*itr2) ) delete *itr2;
    (*itr1).second.clear();
  }
  m_vecDataperBx.clear();
  
}
RPCInputSignal* RBCProcessRPCSimDigis::retrievedata ( ) [inline, virtual]

Implements ProcessInputSignal.

Definition at line 60 of file RBCProcessRPCSimDigis.h.

References m_lbin.

                                  {
    return  m_lbin;
  };
void RBCProcessRPCSimDigis::rewind ( ) [inline]

Definition at line 64 of file RBCProcessRPCSimDigis.h.

{};
void RBCProcessRPCSimDigis::setDigiAt ( int  sector,
int  digipos 
) [private]

Definition at line 312 of file RBCProcessRPCSimDigis.cc.

References gather_cfg::cout, spr::find(), RBCInput::hasData, RBCInput::input_sec, m_block, m_debug, RPCData::m_orsignals, RPCData::m_sec1, m_sec1id, m_sec2id, pos, and setInputBit().

Referenced by next().

{
  
  int pos   = 0;
  int isAoB = 0;

  if ( m_debug ) std::cout << "setDigiAt" << std::endl;
  
  std::vector<int>::const_iterator itr;
  itr = std::find( m_sec1id.begin(), m_sec1id.end(), sector );
  
  if ( itr == m_sec1id.end()) {
    itr = std::find( m_sec2id.begin(), m_sec2id.end(), sector );
    isAoB = 1;
  } 
  
  for ( pos = 0; pos < 6; ++pos ) {
    if (this->m_block->m_sec1[pos] == sector || this->m_block->m_sec2[pos] == sector )
      break;
  }
  
  if ( m_debug ) std::cout << this->m_block->m_orsignals[pos];
  
  setInputBit( this->m_block->m_orsignals[pos].input_sec[ isAoB ] , digipos );
  
  this->m_block->m_orsignals[pos].hasData = true;
  
  if ( m_debug ) std::cout << this->m_block->m_orsignals[pos];
  
  if ( m_debug ) std::cout << "setDigiAt completed" << std::endl;
  
}
void RBCProcessRPCSimDigis::setInputBit ( std::bitset< 15 > &  signals,
int  digipos 
) [private]

Definition at line 345 of file RBCProcessRPCSimDigis.cc.

References gather_cfg::cout, m_debug, and m_layermap.

Referenced by setDigiAt().

{
  
  int bitpos = m_layermap[digipos];
  if( m_debug ) std::cout << "Bitpos: " << bitpos << std::endl;
  signals.set( bitpos , 1 );
  
}
void RBCProcessRPCSimDigis::showfirst ( ) [inline]

Definition at line 65 of file RBCProcessRPCSimDigis.h.

{};

Member Data Documentation

Definition at line 85 of file RBCProcessRPCSimDigis.h.

Referenced by initialize(), next(), and setDigiAt().

std::map<int, RBCInput*> RBCProcessRPCSimDigis::m_data [private]

Definition at line 91 of file RBCProcessRPCSimDigis.h.

Referenced by builddata(), next(), print_output(), and RBCProcessRPCSimDigis().

Definition at line 83 of file RBCProcessRPCSimDigis.h.

Referenced by next().

std::map<int, int> RBCProcessRPCSimDigis::m_layermap [private]

Definition at line 89 of file RBCProcessRPCSimDigis.h.

Referenced by configure(), setInputBit(), and ~RBCProcessRPCSimDigis().

Definition at line 82 of file RBCProcessRPCSimDigis.h.

Referenced by next().

Definition at line 96 of file RBCProcessRPCSimDigis.h.

Referenced by configure(), and next().

Definition at line 80 of file RBCProcessRPCSimDigis.h.

Referenced by RBCProcessRPCSimDigis().

Definition at line 79 of file RBCProcessRPCSimDigis.h.

Referenced by RBCProcessRPCSimDigis().

std::vector<int> RBCProcessRPCSimDigis::m_sec1id [private]

Definition at line 99 of file RBCProcessRPCSimDigis.h.

Referenced by configure(), initialize(), setDigiAt(), and ~RBCProcessRPCSimDigis().

std::vector<int> RBCProcessRPCSimDigis::m_sec2id [private]

Definition at line 100 of file RBCProcessRPCSimDigis.h.

Referenced by configure(), initialize(), setDigiAt(), and ~RBCProcessRPCSimDigis().

std::map<int, std::vector<RPCData*> > RBCProcessRPCSimDigis::m_vecDataperBx [private]

Definition at line 93 of file RBCProcessRPCSimDigis.h.

Referenced by builddata(), next(), and reset().

std::vector<int> RBCProcessRPCSimDigis::m_wheelid [private]

Definition at line 98 of file RBCProcessRPCSimDigis.h.

Referenced by configure(), initialize(), and ~RBCProcessRPCSimDigis().