CMS 3D CMS Logo

Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes

L1TSync Class Reference

#include <L1TSync.h>

Inheritance diagram for L1TSync:
edm::EDAnalyzer

List of all members.

Public Types

enum  BeamMode {
  NOMODE = 1, SETUP = 2, INJPILOT = 3, INJINTR = 4,
  INJNOMN = 5, PRERAMP = 6, RAMP = 7, FLATTOP = 8,
  QUEEZE = 9, ADJUST = 10, STABLE = 11, UNSTABLE = 12,
  BEAMDUMP = 13, RAMPDOWN = 14, RECOVERY = 15, INJDUMP = 16,
  CIRCDUMP = 17, ABORT = 18, CYCLING = 19, WBDUMP = 20,
  NOBEAM = 21
}
enum  Errors {
  UNKNOWN = 1, WARNING_DB_CONN_FAILED = 2, WARNING_DB_QUERY_FAILED = 3, WARNING_DB_INCORRECT_NBUNCHES = 4,
  ERROR_UNABLE_RETRIVE_PRODUCT = 5, ERROR_TRIGGERALIAS_NOTVALID = 6, ERROR_LSBLOCK_NOTVALID = 7
}

Public Member Functions

 L1TSync (const edm::ParameterSet &ps)
virtual ~L1TSync ()

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
void beginJob ()
virtual void beginLuminosityBlock (edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
void beginRun (const edm::Run &run, const edm::EventSetup &iSetup)
 BeginRun.
void endJob (void)
virtual void endLuminosityBlock (edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
void endRun (const edm::Run &run, const edm::EventSetup &iSetup)

Private Member Functions

void certifyLSBlock (std::string iTrigger, int iInitLs, int iEndLs, float iValue)
void doFractionInSync (bool iForce=false, bool iBad=false)
void getBeamConfOMDS ()

Private Attributes

DQMStoredbe
const std::vector< std::vector
< int > > * 
ListsPrescaleFactors
std::map< std::string, bool > m_algoAutoSelect
std::map< TString, int > m_algoBit
std::map< TString,
MonitorElement * > 
m_algoCertification
std::map< TString,
MonitorElement * > 
m_algoVsBunchStructure
BeamConfiguration m_beamConfig
std::map< TString, unsigned int > m_certFirstLS
std::map< TString, unsigned int > m_certLastLS
unsigned int m_currentLS
bool m_currentLSValid
MonitorElementm_ErrorMonitor
edm::InputTag m_l1GtDataDaqInputTag
edm::InputTag m_l1GtEvmSource
unsigned int m_lhcFill
std::string m_outputFile
edm::ParameterSet m_parameters
bool * m_processedLS
int m_refPrescaleSet
edm::InputTag m_scalersSource
std::map< std::string,
std::string > 
m_selectedTriggers
bool m_verbose

Detailed Description

Definition at line 41 of file L1TSync.h.


Member Enumeration Documentation

Enumerator:
NOMODE 
SETUP 
INJPILOT 
INJINTR 
INJNOMN 
PRERAMP 
RAMP 
FLATTOP 
QUEEZE 
ADJUST 
STABLE 
UNSTABLE 
BEAMDUMP 
RAMPDOWN 
RECOVERY 
INJDUMP 
CIRCDUMP 
ABORT 
CYCLING 
WBDUMP 
NOBEAM 

Definition at line 45 of file L1TSync.h.

                 {
      NOMODE=1,
      SETUP=2,
      INJPILOT=3,
      INJINTR=4,
      INJNOMN=5,
      PRERAMP=6,
      RAMP=7,
      FLATTOP=8,
      QUEEZE=9,
      ADJUST=10,
      STABLE=11,
      UNSTABLE=12,
      BEAMDUMP=13,
      RAMPDOWN=14,
      RECOVERY=15,
      INJDUMP=16,
      CIRCDUMP=17,
      ABORT=18,
      CYCLING=19,
      WBDUMP=20,
      NOBEAM=21
    };
Enumerator:
UNKNOWN 
WARNING_DB_CONN_FAILED 
WARNING_DB_QUERY_FAILED 
WARNING_DB_INCORRECT_NBUNCHES 
ERROR_UNABLE_RETRIVE_PRODUCT 
ERROR_TRIGGERALIAS_NOTVALID 
ERROR_LSBLOCK_NOTVALID 

Definition at line 69 of file L1TSync.h.


Constructor & Destructor Documentation

L1TSync::L1TSync ( const edm::ParameterSet ps)

Definition at line 45 of file L1TSync.cc.

References gather_cfg::cout, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), NULL, and cppFunctionSkipper::operator.

                                         {

  m_parameters = pset;
  
  // Mapping parameter input variables
  m_scalersSource       = pset.getParameter         <InputTag>("inputTagScalersResults");
  m_l1GtDataDaqInputTag = pset.getParameter         <InputTag>("inputTagL1GtDataDaq");
  m_l1GtEvmSource       = pset.getParameter         <InputTag>("inputTagtEvmSource");
  m_verbose             = pset.getUntrackedParameter<bool>    ("verbose",false);
  m_refPrescaleSet      = pset.getParameter         <int>     ("refPrescaleSet");  

  // Getting which categories to monitor
  ParameterSet Categories = pset.getParameter< ParameterSet >("Categories");

  bool forceGlobalParameters = Categories.getParameter<bool>("forceGlobalParameters");
  bool doGlobalAutoSelection = Categories.getParameter<bool>("doGlobalAutoSelection");

  ParameterSet CatBPTX    = Categories.getParameter<ParameterSet>("BPTX");
  ParameterSet CatMu      = Categories.getParameter<ParameterSet>("Mu");  
  ParameterSet CatEG      = Categories.getParameter<ParameterSet>("EG");  
  ParameterSet CatIsoEG   = Categories.getParameter<ParameterSet>("IsoEG");  
  ParameterSet CatJet     = Categories.getParameter<ParameterSet>("Jet");  
  ParameterSet CatCenJet  = Categories.getParameter<ParameterSet>("CenJet");  
  ParameterSet CatForJet  = Categories.getParameter<ParameterSet>("ForJet");  
  ParameterSet CatTauJet  = Categories.getParameter<ParameterSet>("TauJet");  
  ParameterSet CatETM     = Categories.getParameter<ParameterSet>("ETT");  
  ParameterSet CatETT     = Categories.getParameter<ParameterSet>("ETM");  
  ParameterSet CatHTT     = Categories.getParameter<ParameterSet>("HTT");  
  ParameterSet CatHTM     = Categories.getParameter<ParameterSet>("HTM");  

  // --> Setting parameters related to which algos to monitor
  // If global parameters are forced they take precedence over algo-by-algo parameters 
  if(forceGlobalParameters){

    // If global automatic selection if enable all categories set to be monitored will have
    // their algos auto selected (the lowest prescale algo will be selected) 
    if(doGlobalAutoSelection){
 
      if(CatMu    .getParameter<bool>("monitor")){m_algoAutoSelect["Mu"]     = true;}else{m_algoAutoSelect["Mu"]     = false;}
      if(CatEG    .getParameter<bool>("monitor")){m_algoAutoSelect["EG"]     = true;}else{m_algoAutoSelect["EG"]     = false;}
      if(CatIsoEG .getParameter<bool>("monitor")){m_algoAutoSelect["IsoEG"]  = true;}else{m_algoAutoSelect["IsoEG"]  = false;}
      if(CatJet   .getParameter<bool>("monitor")){m_algoAutoSelect["Jet"]    = true;}else{m_algoAutoSelect["Jet"]    = false;}
      if(CatCenJet.getParameter<bool>("monitor")){m_algoAutoSelect["CenJet"] = true;}else{m_algoAutoSelect["CenJet"] = false;}
      if(CatForJet.getParameter<bool>("monitor")){m_algoAutoSelect["ForJet"] = true;}else{m_algoAutoSelect["ForJet"] = false;}
      if(CatTauJet.getParameter<bool>("monitor")){m_algoAutoSelect["TauJet"] = true;}else{m_algoAutoSelect["TauJet"] = false;}
      if(CatETM   .getParameter<bool>("monitor")){m_algoAutoSelect["ETM"]    = true;}else{m_algoAutoSelect["ETM"]    = false;}
      if(CatETT   .getParameter<bool>("monitor")){m_algoAutoSelect["ETT"]    = true;}else{m_algoAutoSelect["ETT"]    = false;}
      if(CatHTM   .getParameter<bool>("monitor")){m_algoAutoSelect["HTM"]    = true;}else{m_algoAutoSelect["HTM"]    = false;}
      if(CatHTT   .getParameter<bool>("monitor")){m_algoAutoSelect["HTT"]    = true;}else{m_algoAutoSelect["HTT"]    = false;}

    // If global non-automatic selection is enable all categories set to be monitored will use
    // user defined algos
    }else{

      m_algoAutoSelect["Mu"]     = false;
      m_algoAutoSelect["EG"]     = false;
      m_algoAutoSelect["IsoEG"]  = false;
      m_algoAutoSelect["Jet"]    = false;
      m_algoAutoSelect["CenJet"] = false;
      m_algoAutoSelect["ForJet"] = false;
      m_algoAutoSelect["TauJet"] = false;
      m_algoAutoSelect["ETM"]    = false;
      m_algoAutoSelect["ETT"]    = false;
      m_algoAutoSelect["HTM"]    = false;
      m_algoAutoSelect["HTT"]    = false;   

      if(CatMu    .getParameter<bool>("monitor")){m_selectedTriggers["Mu"]        = CatMu    .getParameter<string>("algo");}
      if(CatEG    .getParameter<bool>("monitor")){m_selectedTriggers["EG"]        = CatEG    .getParameter<string>("algo");}
      if(CatIsoEG .getParameter<bool>("monitor")){m_selectedTriggers["IsoEG"]     = CatIsoEG .getParameter<string>("algo");}
      if(CatJet   .getParameter<bool>("monitor")){m_selectedTriggers["Jet"]       = CatJet   .getParameter<string>("algo");}
      if(CatCenJet.getParameter<bool>("monitor")){m_selectedTriggers["CenJet"]    = CatCenJet.getParameter<string>("algo");}
      if(CatForJet.getParameter<bool>("monitor")){m_selectedTriggers["CatForJet"] = CatForJet.getParameter<string>("algo");}
      if(CatTauJet.getParameter<bool>("monitor")){m_selectedTriggers["TauJet"]    = CatTauJet.getParameter<string>("algo");}
      if(CatETM   .getParameter<bool>("monitor")){m_selectedTriggers["ETM"]       = CatETM   .getParameter<string>("algo");}
      if(CatETT   .getParameter<bool>("monitor")){m_selectedTriggers["ETT"]       = CatETT   .getParameter<string>("algo");}
      if(CatHTM   .getParameter<bool>("monitor")){m_selectedTriggers["HTM"]       = CatHTM   .getParameter<string>("algo");}
      if(CatHTT   .getParameter<bool>("monitor")){m_selectedTriggers["HTT"]       = CatHTT   .getParameter<string>("algo");}

    }

  // If we are using algo-by-algo parametes we get them and set what is needed
  }else{

    if(CatBPTX.getParameter<bool>("monitor")){
      m_selectedTriggers["BPTX"] = CatBPTX.getParameter<string>("algo");
    }

    if(CatMu.getParameter<bool>("monitor")){
      m_algoAutoSelect["Mu"] = CatMu.getParameter<bool>("doAutoSelection");
      if(!m_algoAutoSelect["Mu"]){m_selectedTriggers["Mu"] = CatMu.getParameter<string>("algo");}
    }else{m_algoAutoSelect["Mu"] = false;}

    if(CatEG.getParameter<bool>("monitor")){
      m_algoAutoSelect["EG"] = CatEG.getParameter<bool>("doAutoSelection");
      if(!m_algoAutoSelect["EG"]){m_selectedTriggers["EG"] = CatEG.getParameter<string>("algo");}
    }else{m_algoAutoSelect["EG"] = false;}

    if(CatIsoEG.getParameter<bool>("monitor")){
      m_algoAutoSelect["IsoEG"] = CatIsoEG.getParameter<bool>("doAutoSelection");
      if(!m_algoAutoSelect["IsoEG"]){m_selectedTriggers["IsoEG"] = CatIsoEG.getParameter<string>("algo");}
    }else{m_algoAutoSelect["IsoEG"] = false;}

    if(CatJet.getParameter<bool>("monitor")){
      m_algoAutoSelect["Jet"] = CatJet.getParameter<bool>("doAutoSelection");
      if(!m_algoAutoSelect["Jet"]){m_selectedTriggers["Jet"] = CatJet.getParameter<string>("algo");}
    }else{m_algoAutoSelect["Jet"] = false;}

    if(CatCenJet.getParameter<bool>("monitor")){
      m_algoAutoSelect["CenJet"] = CatCenJet.getParameter<bool>("doAutoSelection");
      if(!m_algoAutoSelect["CenJet"]){m_selectedTriggers["CenJet"] = CatCenJet.getParameter<string>("algo");}
    }else{m_algoAutoSelect["CenJet"] = false;}

    if(CatForJet.getParameter<bool>("monitor")){
      m_algoAutoSelect["CatForJet"] = CatForJet.getParameter<bool>("doAutoSelection");
      if(!m_algoAutoSelect["CatForJet"]){m_selectedTriggers["CatForJet"] = CatForJet.getParameter<string>("algo");}
    }else{m_algoAutoSelect["CatForJet"] = false;}

    if(CatTauJet.getParameter<bool>("monitor")){
      m_algoAutoSelect["TauJet"] = CatTauJet.getParameter<bool>("doAutoSelection");
      if(!m_algoAutoSelect["TauJet"]){m_selectedTriggers["TauJet"] = CatTauJet.getParameter<string>("algo");}
    }else{m_algoAutoSelect["TauJet"] = false;}

    if(CatETM.getParameter<bool>("monitor")){
      m_algoAutoSelect["ETM"] = CatETM.getParameter<bool>("doAutoSelection");
      if(!m_algoAutoSelect["ETM"]){m_selectedTriggers["ETM"] = CatETM.getParameter<string>("algo");}
    }else{m_algoAutoSelect["ETM"] = false;}

    if(CatETT.getParameter<bool>("monitor")){
      m_algoAutoSelect["ETT"] = CatETT.getParameter<bool>("doAutoSelection");
      if(!m_algoAutoSelect["ETT"]){m_selectedTriggers["ETT"] = CatETT.getParameter<string>("algo");}
    }else{m_algoAutoSelect["ETT"] = false;}

    if(CatHTM.getParameter<bool>("monitor")){
      m_algoAutoSelect["HTM"] = CatHTM.getParameter<bool>("doAutoSelection");
      if(!m_algoAutoSelect["HTM"]){m_selectedTriggers["HTM"] = CatHTM.getParameter<string>("algo");}
    }else{m_algoAutoSelect["HTM"] = false;}

    if(CatHTT.getParameter<bool>("monitor")){
      m_algoAutoSelect["HTT"] = CatHTT.getParameter<bool>("doAutoSelection");
      if(!m_algoAutoSelect["HTT"]){m_selectedTriggers["HTT"] = CatHTT.getParameter<string>("algo");}
    }else{m_algoAutoSelect["HTT"] = false;}

  }


  if (pset.getUntrackedParameter < bool > ("dqmStore", false)) {
    dbe = Service < DQMStore > ().operator->();
    dbe->setVerbose(0);
  }

  m_outputFile = pset.getUntrackedParameter < std::string > ("outputFile","");

  if (m_outputFile.size() != 0) {
    std::cout << "L1T Monitoring histograms will be saved to " <<       m_outputFile.c_str() << std::endl;
  }

  bool disable = pset.getUntrackedParameter < bool > ("disableROOToutput", false);
  if (disable) {m_outputFile = "";}

  if (dbe != NULL) {dbe->setCurrentFolder("L1T/L1TSync");}

}
L1TSync::~L1TSync ( ) [virtual]

Definition at line 210 of file L1TSync.cc.

{}

Member Function Documentation

void L1TSync::analyze ( const edm::Event e,
const edm::EventSetup c 
) [protected, virtual]

Implements edm::EDAnalyzer.

Definition at line 435 of file L1TSync.cc.

References a, abs, L1GtfeExtWord::beamMode(), gather_cfg::cout, edm::Event::getByLabel(), i, edm::HandleBase::isValid(), and L1GtfeExtWord::lhcFillNumber().

                                                                        {
 
  if(m_verbose){cout << "[L1TSync] Called analyze." << endl;}

  // We only start analyzing if current LS is still valid
  if(m_currentLSValid){
  
    if(m_verbose){cout << "[L1TSync] -> m_currentLSValid=" << m_currentLSValid << endl;}
    
    // Retriving information from GT
    edm::Handle<L1GlobalTriggerEvmReadoutRecord> gtEvmReadoutRecord;
    iEvent.getByLabel(m_l1GtEvmSource, gtEvmReadoutRecord);

    // Determining beam mode and fill number
    if(gtEvmReadoutRecord.isValid()){

      const L1GtfeExtWord& gtfeEvmWord = gtEvmReadoutRecord->gtfeWord();
      unsigned int lhcBeamMode         = gtfeEvmWord.beamMode();          // Updating beam mode

      if(m_lhcFill == 0){
        m_lhcFill = gtfeEvmWord.lhcFillNumber(); // Getting LHC Fill Number from GT
        getBeamConfOMDS();                       // Getting Beam Configuration from OMDS
      }

      if(lhcBeamMode != STABLE){m_currentLSValid = false;} // If Beams are not stable we invalidate this LS

    }else{
      int eCount = m_ErrorMonitor->getTH1()->GetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT);
      eCount++;
      m_ErrorMonitor->getTH1()->SetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT,eCount);
    }
  }else{
    if(m_verbose){cout << "[L1TSync] -> m_currentLSValid=" << m_currentLSValid << endl;}
  }

  //------------------------------------------------------------------------------
  // If current LS is valid and Beam Configuration is Valid we analyse this event
  //------------------------------------------------------------------------------
  if(m_currentLSValid && m_beamConfig.isValid()){

    // Getting Final Decision Logic (FDL) Data from GT
    edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecordData;
    iEvent.getByLabel(m_l1GtDataDaqInputTag, gtReadoutRecordData);

    if(gtReadoutRecordData.isValid()){

      const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->gtFdlVector();

      // Running over selected triggers
      for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){

        string tTrigger = (*i).second;

        // Analyse only defined triggers
        if(tTrigger != "Undefined" && tTrigger != "Undefined (Wrong Name)"){

          bool beamSingleConfig = false; // Single beam configured for this event
          bool firedAlgo        = false; // Algo fired in this event
          int  eventBx          = -1;      

          // Running over FDL results to get which bits fired
          for(unsigned int a=0 ; a<gtFdlVectorData.size() ; a++){
   
            // Selecting the FDL that triggered
            if(gtFdlVectorData[a].bxInEvent() == 0){
              eventBx = gtFdlVectorData[a].localBxNr();
              if(gtFdlVectorData[a].gtDecisionWord()[ m_algoBit[tTrigger] ]){firedAlgo = true;}
            }
          }

          // Checking beam configuration
          if( m_beamConfig.beam1[eventBx] && !m_beamConfig.beam2[eventBx]){beamSingleConfig = true;}
          if(!m_beamConfig.beam1[eventBx] &&  m_beamConfig.beam2[eventBx]){beamSingleConfig = true;}

          // Analyse only if this trigger fired in this event
          // NOTE: Veto cases where a single beam is configured since
          //       for this cases this could be a real-satelite bunch collision
          // -> Calculate the minimum bx diference between this event and a configured bx
          if(firedAlgo && !beamSingleConfig){

            int DifAlgoVsBunchStructure = 9999; // Majorated

            for(unsigned int a=0 ; a<gtFdlVectorData.size() ; a++){

              int bxFDL     = gtFdlVectorData[a].localBxNr();
              int bxInEvent = gtFdlVectorData[a].bxInEvent();

              if(m_beamConfig.bxConfig(bxFDL) && abs(bxInEvent)<abs(DifAlgoVsBunchStructure)){
                DifAlgoVsBunchStructure = -1*bxInEvent;
              }
            }

            m_algoVsBunchStructure[tTrigger]->Fill(m_currentLS,DifAlgoVsBunchStructure);

          }
        }
      }
    }
    else{
      int eCount = m_ErrorMonitor->getTH1()->GetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT);
      eCount++;
      m_ErrorMonitor->getTH1()->SetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT,eCount);
    }

  }
}
void L1TSync::beginJob ( void  ) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 214 of file L1TSync.cc.

References gather_cfg::cout, cppFunctionSkipper::operator, DQMStore::rmdir(), and DQMStore::setCurrentFolder().

                          {

  if (m_verbose){cout << "[L1TSync] Called beginJob." << endl;}

  // get hold of back-end interface
  DQMStore *dbe = 0;
  dbe = Service < DQMStore > ().operator->();

  if (dbe) {
    dbe->setCurrentFolder("L1T/L1TSync");
    dbe->rmdir("L1T/L1TSync");
  }
 
}
void L1TSync::beginLuminosityBlock ( edm::LuminosityBlock const &  lumiBlock,
edm::EventSetup const &  c 
) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 321 of file L1TSync.cc.

References gather_cfg::cout, i, edm::LuminosityBlockBase::id(), and edm::LuminosityBlockID::luminosityBlock().

                                                                                        {

  if (m_verbose){cout << "[L1TSync] Called beginLuminosityBlock." << endl;}

  // If this LS is not the next to last one force closing of current LS blocks
  // for certification
  if(m_currentLS !=0 && m_currentLS+1 != lumiBlock.id().luminosityBlock()){

    if (m_verbose){
      cout << "[L1TSync] None consecutive: doFractionInSync() - LAST=" 
           << m_currentLS << " CURRENT=" << lumiBlock.id().luminosityBlock() << endl;
    }

    doFractionInSync(true,false);    

  }
    
  // Updating current LS number
  m_currentLS = lumiBlock.id().luminosityBlock();

  // If this is the fist valid LS update first LS for certification 
  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){

    string theTriggerAlias = (*i).second;
    if(m_certFirstLS[theTriggerAlias]==0){m_certFirstLS[theTriggerAlias] = m_currentLS;}

  }

  // A LS will be valid if:
  //   * BeamMode == STABLE for all events monitored
  m_currentLSValid = true; 

}
void L1TSync::beginRun ( const edm::Run run,
const edm::EventSetup iSetup 
) [protected, virtual]

BeginRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 245 of file L1TSync.cc.

References algo, gather_cfg::cout, edm::EventSetup::get(), L1TMenuHelper::getLUSOTrigger(), L1GtTriggerMenu::gtAlgorithmAliasMap(), i, edm::ESHandle< T >::product(), L1TMenuHelper::testAlgos(), and pat::UNKNOWN.

                                                                     {

  if (m_verbose){cout << "[L1TSync] Called beginRun." << endl;}

  // Initializing variables
  int maxNbins = 2501;

  // Reseting run dependent variables
  m_lhcFill     = 0; 
  m_currentLS   = 0;
  m_certFirstLS.clear();
  m_certLastLS .clear();
  
  // Getting Trigger menu from GT
  ESHandle<L1GtTriggerMenu> menuRcd;
  iSetup.get<L1GtTriggerMenuRcd>().get(menuRcd);
  const L1GtTriggerMenu* menu = menuRcd.product();

  // Filling Alias-Bit Map
  for (CItAlgo algo = menu->gtAlgorithmAliasMap().begin(); algo!=menu->gtAlgorithmAliasMap().end(); ++algo){
    m_algoBit[(algo->second).algoAlias()] = (algo->second).algoBitNumber();
  }

  // Getting fill number for this run
  //Handle<ConditionsInRunBlock> runConditions;
  //iRun.getByType(runConditions);
  //int lhcFillNumber = runConditions->lhcFillNumber;
  //
  //ESHandle<L1GtPrescaleFactors> l1GtPfAlgo;
  //iSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().get(l1GtPfAlgo);
  //const L1GtPrescaleFactors* m_l1GtPfAlgo = l1GtPfAlgo.product();

  L1TMenuHelper myMenuHelper = L1TMenuHelper(iSetup);  
         
  m_selectedTriggers = myMenuHelper.testAlgos(m_selectedTriggers);

  map<string,string> tAutoSelTrig = myMenuHelper.getLUSOTrigger(m_algoAutoSelect,m_refPrescaleSet);
  m_selectedTriggers.insert(tAutoSelTrig.begin(),tAutoSelTrig.end());

  // Initializing DQM Monitor Elements
  dbe->setCurrentFolder("L1T/L1TSync");
  m_ErrorMonitor = dbe->book1D("ErrorMonitor","ErrorMonitor",7,0,7);
  m_ErrorMonitor->setBinLabel(UNKNOWN                      ,"UNKNOWN");
  m_ErrorMonitor->setBinLabel(WARNING_DB_CONN_FAILED       ,"WARNING_DB_CONN_FAILED");        // Errors from L1TOMDSHelper
  m_ErrorMonitor->setBinLabel(WARNING_DB_QUERY_FAILED      ,"WARNING_DB_QUERY_FAILED");       // Errors from L1TOMDSHelper
  m_ErrorMonitor->setBinLabel(WARNING_DB_INCORRECT_NBUNCHES,"WARNING_DB_INCORRECT_NBUNCHES"); // Errors from L1TOMDSHelper
  m_ErrorMonitor->setBinLabel(ERROR_UNABLE_RETRIVE_PRODUCT ,"ERROR_UNABLE_RETRIVE_PRODUCT"); 
  m_ErrorMonitor->setBinLabel(ERROR_TRIGGERALIAS_NOTVALID  ,"ERROR_TRIGGERALIAS_NOTVALID"); 
  m_ErrorMonitor->setBinLabel(ERROR_LSBLOCK_NOTVALID       ,"ERROR_LSBLOCK_NOTVALID"); 

  // Looping over selected triggers
  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){

    string tCategory = (*i).first;
    string tTrigger  = (*i).second;

    // Initializing LS blocks for certification
    m_certFirstLS[(*i).second] = 0;
    m_certLastLS [(*i).second] = 0;

    // Initializing DQM Monitors 
    dbe->setCurrentFolder("L1T/L1TSync/AlgoVsBunchStructure/");
    m_algoVsBunchStructure[tTrigger] = dbe->book2D(tCategory,"min #Delta("+tTrigger+",Bunch)",maxNbins,-0.5,double(maxNbins)-0.5,5,-2.5,2.5);
    m_algoVsBunchStructure[tTrigger] ->setAxisTitle("Lumi Section" ,1);
    
    dbe->setCurrentFolder("L1T/L1TSync/Certification/");
    m_algoCertification[tTrigger] = dbe->book1D(tCategory, "fraction of in sync: "+tTrigger,maxNbins,-0.5,double(maxNbins)-0.5);
    m_algoCertification[tTrigger] ->setAxisTitle("Lumi Section" ,1);

 }   

}
void L1TSync::certifyLSBlock ( std::string  iTrigger,
int  iInitLs,
int  iEndLs,
float  iValue 
) [private]

Definition at line 715 of file L1TSync.cc.

References python::rootplot::utilities::ls().

                                                                                  {
  
  // Finding correct bins in the histogram for this block
  int binInit = m_algoCertification[iTrigger]->getTH1()->FindBin(iInitLs);
  int binEnd  = m_algoCertification[iTrigger]->getTH1()->FindBin(iEndLs);

  for(int ls=binInit ; ls<=binEnd ; ls++){
    m_algoCertification[iTrigger]->setBinContent(ls,iValue);
  }

}
void L1TSync::doFractionInSync ( bool  iForce = false,
bool  iBad = false 
) [private]

Definition at line 604 of file L1TSync.cc.

References a, gather_cfg::cout, edm::ParameterSet::getParameter(), i, and python::rootplot::utilities::ls().

                                                   {
  
  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){

    string theCategory     = (*i).first;
    string theTriggerAlias = (*i).second;

    // Caching frequently used values from maps
    unsigned int fLS = m_certFirstLS[theTriggerAlias];
    unsigned int lLS = m_certLastLS [theTriggerAlias];
    
    // Checking validity of the trigger alias and of the LS block
    bool triggerAlias_isValid = theTriggerAlias != "Undefined" && theTriggerAlias != "Undefined (Wrong Name)";
    bool lsBlock_exists       = !(fLS == 0 && lLS == 0);
    bool lsBlock_isValid      = fLS <= lLS && fLS > 0 && lLS > 0; 

    if(triggerAlias_isValid && lsBlock_exists && lsBlock_isValid){

      // If we are forced to close blocks and mark them bad
      if(iForce && iBad){
        certifyLSBlock(theTriggerAlias,fLS,lLS,-1);
        m_certFirstLS[theTriggerAlias] = 0;
        m_certLastLS [theTriggerAlias] = 0;
      }

      // If we are not forced to mark bad, we check if we have enough statistics
      else{

        // Getting events with 0 bx difference between BPTX and Algo for current LS
        double CountSync = 0;
        double CountAll  = 0;
  
        // Adding all entries for current LS block
        for(unsigned int ls=fLS ; ls<=lLS ; ls++){

          CountSync += m_algoVsBunchStructure[theTriggerAlias]->getBinContent(ls+1,3);
          for(int a=1 ; a<6 ; a++){
            CountAll  += m_algoVsBunchStructure[theTriggerAlias]->getBinContent(ls+1,a);
          }
        }

        if(m_verbose){
          cout << "Alias = " << theTriggerAlias 
               << " InitLS=" << fLS 
               << " EndLS=" <<  lLS 
               << " Events=" << CountAll ;
        } 

        if(iForce ||
           CountAll >= m_parameters.getParameter<ParameterSet>("Categories")
                                   .getParameter<ParameterSet>(theCategory)
                                   .getParameter<int>("CertMinEvents")){

          if(m_verbose){cout << " <--------------- Enough Statistics: ";}

        
          // Calculating fraction of in time 
          double fraction = 0;
          if(CountAll >0){fraction = CountSync/CountAll;}

          // This is to avoid having an entry equal to zero and thus
          // disregarded by the automatic tests
          if(fraction==0){fraction=0.000001;}
        
          certifyLSBlock(theTriggerAlias,fLS,lLS,fraction);
          m_certFirstLS[theTriggerAlias] = 0;
          m_certLastLS [theTriggerAlias] = 0;
        }

        if(m_verbose){cout << endl;}

      }
    }

    // A problem was found. We report it and set a not physical vale (-1) to the certification plot
    else{

      // If trigger alias is not valid report it to m_ErrorMonitor
      if(!triggerAlias_isValid){
        int eCount = m_ErrorMonitor->getTH1()->GetBinContent(ERROR_TRIGGERALIAS_NOTVALID);
        eCount++;
        m_ErrorMonitor->getTH1()->SetBinContent(ERROR_TRIGGERALIAS_NOTVALID,eCount);
        certifyLSBlock(theTriggerAlias,fLS,lLS,-1);
        m_certFirstLS[theTriggerAlias] = 0;
        m_certLastLS [theTriggerAlias] = 0;
      }

      // If LS Block is not valid report it to m_ErrorMonitor
      if(lsBlock_exists && !lsBlock_isValid){
        int eCount = m_ErrorMonitor->getTH1()->GetBinContent(ERROR_LSBLOCK_NOTVALID);
        eCount++;
        m_ErrorMonitor->getTH1()->SetBinContent(ERROR_LSBLOCK_NOTVALID,eCount);
        certifyLSBlock(theTriggerAlias,fLS,lLS,-1);
        m_certFirstLS[theTriggerAlias] = 0;
        m_certLastLS [theTriggerAlias] = 0;
      }

    }
  }

}
void L1TSync::endJob ( void  ) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 231 of file L1TSync.cc.

References gather_cfg::cout.

                        {

  if (m_verbose){cout << "[L1TSync] Called endJob." << endl;}

  if (m_outputFile.size() != 0 && dbe)
    dbe->save(m_outputFile);

  return;

}
void L1TSync::endLuminosityBlock ( edm::LuminosityBlock const &  lumiBlock,
edm::EventSetup const &  c 
) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 359 of file L1TSync.cc.

References gather_cfg::cout, and i.

                                                                                      {

  if(m_verbose){cout << "[L1TSync] Called endLuminosityBlock." << endl;}

  if(m_verbose){
    cout << "[L1TSync] m_currentLSValid      : " << m_currentLSValid       << endl;
    cout << "[L1TSync] m_beamConfig.isValid(): " << m_beamConfig.isValid() << endl;
  }  

  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){

    // Update last LS for certification      
    string theTriggerAlias = (*i).second;
    m_certLastLS[theTriggerAlias] = m_currentLS;

  }

  // If this LS is valid (i.e. all events recorded with stable beams)
  if(m_currentLSValid && m_beamConfig.isValid()){

    if(m_verbose){cout << "[L1TSync] Regular call: doFractionInSync()" << endl;}
    doFractionInSync(false,false);
    
  }
  // If this LS is not valid it can be in the following context:
  //  * We still hadn't stable beam (no need to certify nothing
  //  * Beam just got unstable or dumped (we may have a complete block of data do certify)  
  else{
    
    //-> First we close all blocks from certFirstLS[] to m_currentLS-1
    for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){

      string theTriggerAlias = (*i).second;
      
      int fLs = m_certFirstLS[theTriggerAlias];
      int lLS = m_certLastLS [theTriggerAlias];

      // If this is a single LS block we do nothing (in this step)
      if(fLs == lLS){
        m_certFirstLS[theTriggerAlias] = 0;
        m_certLastLS [theTriggerAlias] = 0;
      }
      // If block is multi LS then we remove the current LS 
      else{
        m_certLastLS [theTriggerAlias] = m_currentLS-1;
      }

    }
    doFractionInSync(true,false);

    //-> Second we mark this single LS bad for all triggers
    for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
      string theTriggerAlias = (*i).second;
      m_certFirstLS[theTriggerAlias] = m_currentLS;
      m_certLastLS [theTriggerAlias] = m_currentLS;
    }
    doFractionInSync(true,true);

    if(m_verbose){cout << "[L1TSync] Error call: doFractionInSync()" << endl;}  

  }

}
void L1TSync::endRun ( const edm::Run run,
const edm::EventSetup iSetup 
) [protected, virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 424 of file L1TSync.cc.

References gather_cfg::cout.

                                                                  {
  
  if(m_verbose){cout << "[L1TSync] Called endRun." << endl;}
  
  // When the run end for closing of the LS certification blocks and evaluation
  // of synchronization for that block
  doFractionInSync(true,false);    

}
void L1TSync::getBeamConfOMDS ( ) [private]

Definition at line 547 of file L1TSync.cc.

References L1TOMDSHelper::NO_ERROR, pat::UNKNOWN, L1TOMDSHelper::WARNING_DB_CONN_FAILED, and L1TOMDSHelper::WARNING_DB_QUERY_FAILED.

                             {

  //Getting connection paremeters
  string oracleDB   = m_parameters.getParameter<string>("oracleDB");
  string pathCondDB = m_parameters.getParameter<string>("pathCondDB");

  // Connecting to OMDS 
  L1TOMDSHelper myOMDSHelper = L1TOMDSHelper();
  int conError;
  myOMDSHelper.connect(oracleDB,pathCondDB,conError);

  if(conError == L1TOMDSHelper::NO_ERROR){

    int errorRetrive;
    m_beamConfig = myOMDSHelper.getBeamConfiguration(m_lhcFill,errorRetrive);

    if(conError == L1TOMDSHelper::WARNING_DB_CONN_FAILED){
      int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_INCORRECT_NBUNCHES);
      eCount++;
      m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_INCORRECT_NBUNCHES,eCount);
    }
    else if(conError == L1TOMDSHelper::WARNING_DB_QUERY_FAILED){
      int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_QUERY_FAILED);
      eCount++;
      m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_QUERY_FAILED,eCount);
    }
    else{
      int eCount = m_ErrorMonitor->getTH1()->GetBinContent(UNKNOWN);
      eCount++;
      m_ErrorMonitor->getTH1()->SetBinContent(UNKNOWN,eCount);
    }

  }else{

    if(conError == L1TOMDSHelper::WARNING_DB_CONN_FAILED){
      int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_CONN_FAILED);
      eCount++;
      m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_CONN_FAILED,eCount);
    }else{
      int eCount = m_ErrorMonitor->getTH1()->GetBinContent(UNKNOWN);
      eCount++;
      m_ErrorMonitor->getTH1()->SetBinContent(UNKNOWN,eCount);
    }

  }

}

Member Data Documentation

DQMStore* L1TSync::dbe [private]

Definition at line 107 of file L1TSync.h.

const std::vector< std::vector<int> >* L1TSync::ListsPrescaleFactors [private]

Definition at line 128 of file L1TSync.h.

std::map<std::string,bool> L1TSync::m_algoAutoSelect [private]

Definition at line 136 of file L1TSync.h.

std::map<TString,int> L1TSync::m_algoBit [private]

Definition at line 131 of file L1TSync.h.

std::map<TString,MonitorElement*> L1TSync::m_algoCertification [private]

Definition at line 134 of file L1TSync.h.

std::map<TString,MonitorElement*> L1TSync::m_algoVsBunchStructure [private]

Definition at line 135 of file L1TSync.h.

Definition at line 125 of file L1TSync.h.

std::map<TString,unsigned int> L1TSync::m_certFirstLS [private]

Definition at line 132 of file L1TSync.h.

std::map<TString,unsigned int> L1TSync::m_certLastLS [private]

Definition at line 133 of file L1TSync.h.

unsigned int L1TSync::m_currentLS [private]

Definition at line 120 of file L1TSync.h.

bool L1TSync::m_currentLSValid [private]

Definition at line 115 of file L1TSync.h.

Definition at line 140 of file L1TSync.h.

Definition at line 145 of file L1TSync.h.

Definition at line 144 of file L1TSync.h.

unsigned int L1TSync::m_lhcFill [private]

Definition at line 122 of file L1TSync.h.

std::string L1TSync::m_outputFile [private]

Definition at line 111 of file L1TSync.h.

Definition at line 109 of file L1TSync.h.

bool* L1TSync::m_processedLS [private]

Definition at line 116 of file L1TSync.h.

Definition at line 119 of file L1TSync.h.

Definition at line 143 of file L1TSync.h.

std::map<std::string,std::string> L1TSync::m_selectedTriggers [private]

Definition at line 137 of file L1TSync.h.

bool L1TSync::m_verbose [private]

Definition at line 114 of file L1TSync.h.