CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

RPCTTUMonitor Class Reference

#include <RPCTTUMonitor.h>

Inheritance diagram for RPCTTUMonitor:
edm::EDAnalyzer

List of all members.

Public Member Functions

void discriminateDecision (bool, bool, int)
int discriminateGMT (const edm::Event &iEvent, const edm::EventSetup &iSetup)
 RPCTTUMonitor (const edm::ParameterSet &)
 ~RPCTTUMonitor ()

Private Member Functions

virtual void analyze (const edm::Event &, const edm::EventSetup &)
virtual void beginJob ()
virtual void beginRun (const edm::EventSetup &)
virtual void endJob ()

Private Attributes

DQMStoredbe
MonitorElementm_bxDistDiffDt [8]
MonitorElementm_bxDistDiffPac [8]
MonitorElementm_dataVsemulator [8]
std::vector< int > m_DTcandidatesBx
bool m_dtTrigger
std::vector< int > m_GMTcandidatesBx
edm::InputTag m_gmtReadoutLabel
edm::InputTag m_gtReadoutLabel
int m_maxttBits
std::vector< int > m_RPCcandidatesBx
edm::InputTag m_rpcDigiLabel
edm::InputTag m_rpcTechTrigEmu
bool m_rpcTrigger
std::vector< unsigned > m_ttBits
MonitorElementm_ttBitsDecisionData
MonitorElementm_ttBitsDecisionEmulator
std::string outputFile
std::string ttuFolder

Detailed Description

Definition at line 71 of file RPCTTUMonitor.h.


Constructor & Destructor Documentation

RPCTTUMonitor::RPCTTUMonitor ( const edm::ParameterSet iConfig) [explicit]

Definition at line 7 of file RPCTTUMonitor.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), m_gmtReadoutLabel, m_gtReadoutLabel, m_maxttBits, m_rpcTechTrigEmu, m_ttBits, outputFile, and ttuFolder.

                                                          {

  ttuFolder    = iConfig.getUntrackedParameter<std::string>("TTUFolder", "RPC/TTU");
  outputFile    = iConfig.getUntrackedParameter<std::string>("OutPutFile", ""); 
  m_gtReadoutLabel     = iConfig.getParameter<edm::InputTag>("GTReadoutRcd");
  m_gmtReadoutLabel    = iConfig.getParameter<edm::InputTag>("GMTReadoutRcd");
  m_rpcTechTrigEmu     = iConfig.getParameter<edm::InputTag>("L1TTEmuBitsLabel");
  m_ttBits             = iConfig.getParameter< std::vector<unsigned> >("BitNumbers");
  m_maxttBits          = m_ttBits.size();
  
}
RPCTTUMonitor::~RPCTTUMonitor ( )

Definition at line 19 of file RPCTTUMonitor.cc.

{
  
}

Member Function Documentation

void RPCTTUMonitor::analyze ( const edm::Event iEvent,
const edm::EventSetup iSetup 
) [private, virtual]

Implements edm::EDAnalyzer.

Definition at line 26 of file RPCTTUMonitor.cc.

References edm::EventBase::bunchCrossing(), discriminateDecision(), discriminateGMT(), MonitorElement::Fill(), edm::Event::getByLabel(), edm::HandleBase::isValid(), gen::k, m_bxDistDiffDt, m_bxDistDiffPac, m_DTcandidatesBx, m_dtTrigger, m_GMTcandidatesBx, m_gtReadoutLabel, m_maxttBits, m_rpcTechTrigEmu, m_rpcTrigger, m_ttBits, m_ttBitsDecisionData, and m_ttBitsDecisionEmulator.

{
  
  //..............................................................................................
  // Data .
  edm::Handle< L1GlobalTriggerReadoutRecord > gtRecord;
  iEvent.getByLabel( m_gtReadoutLabel, gtRecord);
  
  if ( !gtRecord.isValid() ) {
    edm::LogError("RPCTTUMonitor") << "can't find L1GlobalTriggerRecord with label: " 
                                    << m_gtReadoutLabel << '\n';
    return;
  }
  
  // Emulator .
  edm::Handle< L1GtTechnicalTriggerRecord > emuTTRecord;
  iEvent.getByLabel( m_rpcTechTrigEmu , emuTTRecord);
  
  if ( !emuTTRecord.isValid() ) {
    edm::LogError("RPCTTUMonitor") << "can't find L1GtTechnicalTriggerRecord (emulator) with label: " 
                                    << m_rpcTechTrigEmu << '\n';
    return;
  }
  
  //..............................................................................................
  //
  //Timing difference between RPC-PAT and DT
  
  int dGMT(0);
  dGMT = discriminateGMT( iEvent , iSetup );
  if ( dGMT < 0 ) return;
  
  std::map<int,bool> ttuDec;
  std::map<int,bool>::iterator decItr;
  
  int bxX = iEvent.bunchCrossing(); // ... 1 to 3564
  
  for( int k=0; k < m_maxttBits; ++k) {
    for( int iebx=0; iebx<=2; iebx++) {
      const TechnicalTriggerWord gtTTWord = gtRecord->technicalTriggerWord(iebx-1);
      ttuDec[iebx-1] = gtTTWord[ 24+k ];
    }
  
    //. RPC
    if ( m_rpcTrigger ) {
      
      int ndec(0);
      int bx1 = (bxX - m_GMTcandidatesBx[0]);
      for( decItr = ttuDec.begin(); decItr != ttuDec.end(); ++decItr ){
        if ( (*decItr).second ) {
          int bx2 = (*decItr).first;
          float bxdiffPacTT = 1.0*( bx1 - bx2);
          m_bxDistDiffPac[k]->Fill( bxdiffPacTT );
          ++ndec;
        }
      }
    }
    
    //.. DT
    if ( m_dtTrigger ) {
      
      int ndec(0);
      int bx1 = (bxX - m_DTcandidatesBx[0]);
      for( decItr = ttuDec.begin(); decItr != ttuDec.end(); ++decItr ){
        if ( (*decItr).second ) {
          int bx2 = (*decItr).first;
          float bxdiffDtTT = 1.0*( bx1 - bx2);
          m_bxDistDiffDt[k]->Fill( bxdiffDtTT );
          ++ndec;
        }
      }
    }
    ttuDec.clear();
  
  }

  m_GMTcandidatesBx.clear();
  m_DTcandidatesBx.clear();
    
  //..............................................................................................
  //
  //... For Data Emulator comparison

  const TechnicalTriggerWord gtTTWord = gtRecord->technicalTriggerWord();

  std::vector<L1GtTechnicalTrigger> ttVec = emuTTRecord->gtTechnicalTrigger();

  std::vector<unsigned>::iterator bitsItr;
  int k = 0;
  //int m_BxWindow = 0;
  bool hasDataTrigger = false;
  bool hasEmulatorTrigger = false;

  if ( ttVec.size() <= 0 ) return;
  
  for ( bitsItr = m_ttBits.begin(); bitsItr != m_ttBits.end(); ++bitsItr ) {
    
    hasDataTrigger = gtTTWord.at( (*bitsItr) );
    m_ttBitsDecisionData->Fill( (*bitsItr), (int)hasDataTrigger  );
    
    hasEmulatorTrigger = ttVec[k].gtTechnicalTriggerResult();
    m_ttBitsDecisionEmulator->Fill( ttVec[k].gtTechnicalTriggerBitNumber(), (int)hasEmulatorTrigger );
    
    discriminateDecision(hasDataTrigger ,hasEmulatorTrigger  , k );
        
    ++k;
    
  }
  

}
void RPCTTUMonitor::beginJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 242 of file RPCTTUMonitor.cc.

References DQMStore::book1D(), dbe, gen::k, m_bxDistDiffDt, m_bxDistDiffPac, m_dataVsemulator, m_maxttBits, m_ttBits, m_ttBitsDecisionData, m_ttBitsDecisionEmulator, cmsCodeRules::cppFunctionSkipper::operator, DQMStore::setCurrentFolder(), DQMStore::showDirStructure(), and ttuFolder.

                             {

  dbe = edm::Service<DQMStore>().operator->();
  dbe->showDirStructure();

  
  dbe->setCurrentFolder(ttuFolder);

  
  m_ttBitsDecisionData = dbe->book1D("TechTrigger.Bits.Data",
                                             "Technical Trigger bits : Summary",
                                              10, 23, 33 );

  m_ttBitsDecisionEmulator =  dbe->book1D("TechTrigger.Bits.Emulator",
                                                 "Technical Trigger bits : Summary",
                                                 10, 23, 33 );
 for( int k=0; k < m_maxttBits; ++k) {
    
   std::ostringstream hname;
   
   hname << "BX.diff.PAC-TTU.bit." << m_ttBits[k];
   
   m_bxDistDiffPac[k] =  dbe->book1D(hname.str().c_str(),
                                             "Timing difference between PAC and TTU",
                                             7, -3, 3);
   
   hname.str("");
   
   hname << "BX.diff.DT-TTU.bit." << m_ttBits[k];
   
   m_bxDistDiffDt[k] =  dbe->book1D(hname.str().c_str(),
                                            "Timing difference between DT and TTU",
                                            7, -3, 3);
   
   hname.str("");
   
   hname << "Emu.Ttu.Compare.bit." << m_ttBits[k];
   
   m_dataVsemulator[k] =  dbe->book1D(hname.str().c_str(),
                                              "Comparison between emulator and TT decisions", 
                                              10, 0, 10 );
   
   hname.str("");
   
 }
}
void RPCTTUMonitor::beginRun ( const edm::EventSetup iSetup) [private, virtual]

Definition at line 289 of file RPCTTUMonitor.cc.

                                                       {
  
}
void RPCTTUMonitor::discriminateDecision ( bool  data,
bool  emu,
int  indx 
)

Definition at line 221 of file RPCTTUMonitor.cc.

References MonitorElement::Fill(), and m_dataVsemulator.

Referenced by analyze().

{
 
  if ( data == 1 && emu == 1 )
    m_dataVsemulator[indx]->Fill( 1 );
  
  if ( data == 1 && emu == 0 )
    m_dataVsemulator[indx]->Fill( 3 );
  
  if ( data == 0 && emu == 1 )
    m_dataVsemulator[indx]->Fill( 5 );
  
  if ( data == 0 && emu == 0 )
    m_dataVsemulator[indx]->Fill( 7 );
  
  
}
int RPCTTUMonitor::discriminateGMT ( const edm::Event iEvent,
const edm::EventSetup iSetup 
)

Definition at line 138 of file RPCTTUMonitor.cc.

References edm::Event::getByLabel(), L1MuGMTReadoutCollection::getRecords(), edm::HandleBase::isValid(), m_DTcandidatesBx, m_dtTrigger, m_GMTcandidatesBx, m_gmtReadoutLabel, m_rpcTrigger, and edm::Handle< T >::product().

Referenced by analyze().

{
  
  //.............................................................................................
  
  edm::Handle<L1MuGMTReadoutCollection> pCollection;
  iEvent.getByLabel(m_gmtReadoutLabel,pCollection);
  
  if ( ! pCollection.isValid() ) {
    edm::LogError("discriminateGMT") << "can't find L1MuGMTReadoutCollection with label "
                                     << m_gmtReadoutLabel ;
    return -1; 
  }
  
  //.............................................................................................
  
  int gmtDec(0);
  
  bool rpcBar_l1a  = false;
  bool dtBar_l1a   = false;
  
  m_dtTrigger  = false;
  m_rpcTrigger = false;
  
  // get GMT readout collection
  const L1MuGMTReadoutCollection * gmtRC = pCollection.product();
  
  // get record vector
  std::vector<L1MuGMTReadoutRecord>::const_iterator RRItr;
  std::vector<L1MuGMTReadoutRecord> gmt_records = gmtRC->getRecords();
  
  edm::LogInfo("DiscriminateGMT") << "nRecords: " << gmt_records.size() << '\n';
  
  for( RRItr = gmt_records.begin(); RRItr != gmt_records.end(); ++RRItr ) {
    
    int BxInEvent = RRItr->getBxInEvent();
    int BxInEventNew = RRItr->getBxNr();
    
    // RPC barrel muon candidates
    int nrpcB = 0;
    int ndtB  = 0;
    
    std::vector<L1MuRegionalCand> BrlRpcCands = RRItr->getBrlRPCCands();
    std::vector<L1MuRegionalCand> BrlDtCands  = RRItr->getDTBXCands ();
    
    std::vector<L1MuRegionalCand>::const_iterator RCItr;
    
    for( RCItr = BrlRpcCands.begin(); RCItr !=BrlRpcCands.end(); ++RCItr) {
      if ( !(*RCItr).empty() ) {
        
        m_GMTcandidatesBx.push_back( BxInEventNew );
        
        nrpcB++;
      }
    }
    
    for( RCItr = BrlDtCands.begin(); RCItr !=BrlDtCands.end(); ++RCItr) {
      if ( !(*RCItr).empty() ) {
        m_DTcandidatesBx.push_back( BxInEventNew );
        ndtB++;
      }
    }
    
    if( BxInEvent == 0 && nrpcB > 0) rpcBar_l1a = true;
    if( BxInEvent == 0 && ndtB > 0) dtBar_l1a = true;
    
  }
  
  if( rpcBar_l1a ) { 
    gmtDec = 1;
    m_rpcTrigger = true;
    
  }
  
  if( dtBar_l1a ) { 
    gmtDec = 2;
    m_dtTrigger = true;
  }
  
  return gmtDec;
  
}
void RPCTTUMonitor::endJob ( void  ) [private, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 295 of file RPCTTUMonitor.cc.

References dbe, outputFile, and DQMStore::save().

                      {

  if(outputFile != "")
    dbe->save(outputFile);

  dbe=0;  
}

Member Data Documentation

Definition at line 93 of file RPCTTUMonitor.h.

Referenced by beginJob(), and endJob().

Definition at line 90 of file RPCTTUMonitor.h.

Referenced by analyze(), and beginJob().

Definition at line 89 of file RPCTTUMonitor.h.

Referenced by analyze(), and beginJob().

Definition at line 91 of file RPCTTUMonitor.h.

Referenced by beginJob(), and discriminateDecision().

std::vector<int> RPCTTUMonitor::m_DTcandidatesBx [private]

Definition at line 104 of file RPCTTUMonitor.h.

Referenced by analyze(), and discriminateGMT().

Definition at line 100 of file RPCTTUMonitor.h.

Referenced by analyze(), and discriminateGMT().

std::vector<int> RPCTTUMonitor::m_GMTcandidatesBx [private]

Definition at line 103 of file RPCTTUMonitor.h.

Referenced by analyze(), and discriminateGMT().

Definition at line 109 of file RPCTTUMonitor.h.

Referenced by discriminateGMT(), and RPCTTUMonitor().

Definition at line 108 of file RPCTTUMonitor.h.

Referenced by analyze(), and RPCTTUMonitor().

Definition at line 97 of file RPCTTUMonitor.h.

Referenced by analyze(), beginJob(), and RPCTTUMonitor().

std::vector<int> RPCTTUMonitor::m_RPCcandidatesBx [private]

Definition at line 105 of file RPCTTUMonitor.h.

Definition at line 107 of file RPCTTUMonitor.h.

Definition at line 110 of file RPCTTUMonitor.h.

Referenced by analyze(), and RPCTTUMonitor().

Definition at line 101 of file RPCTTUMonitor.h.

Referenced by analyze(), and discriminateGMT().

std::vector<unsigned> RPCTTUMonitor::m_ttBits [private]

Definition at line 98 of file RPCTTUMonitor.h.

Referenced by analyze(), beginJob(), and RPCTTUMonitor().

Definition at line 87 of file RPCTTUMonitor.h.

Referenced by analyze(), and beginJob().

Definition at line 88 of file RPCTTUMonitor.h.

Referenced by analyze(), and beginJob().

std::string RPCTTUMonitor::outputFile [private]

Definition at line 95 of file RPCTTUMonitor.h.

Referenced by endJob(), and RPCTTUMonitor().

std::string RPCTTUMonitor::ttuFolder [private]

Definition at line 94 of file RPCTTUMonitor.h.

Referenced by beginJob(), and RPCTTUMonitor().