CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
L1TBPTX Class Reference

#include <L1TBPTX.h>

Inheritance diagram for L1TBPTX:
edm::EDAnalyzer edm::EDConsumerBase

Public Types

enum  BeamMode {
  NOMODE =1, SETUP =2, INJPILOT =3, INJINTR =4,
  INJNOMN =5, PRERAMP =6, RAMP =7, FLATTOP =8,
  SQUEEZE =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 Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 

Public Member Functions

 L1TBPTX (const edm::ParameterSet &ps)
 
virtual ~L1TBPTX ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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. More...
 
void endJob (void)
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
 
void endRun (const edm::Run &run, const edm::EventSetup &iSetup)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

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
 
std::map< int, TString > m_algoBit_Alias
 
BeamConfiguration m_beamConfig
 
unsigned int m_currentGTLS
 
unsigned int m_currentLS
 
bool m_currentLSValid
 
int m_currentPrescalesIndex
 
std::map< TString, int > m_effDenominator
 
std::map< TString, int > m_effNumerator
 
MonitorElementm_ErrorMonitor
 
edm::EDGetTokenT
< L1GlobalTriggerReadoutRecord
m_l1GtDataDaqInputTag
 
edm::EDGetTokenT
< L1GlobalTriggerEvmReadoutRecord
m_l1GtEvmSource
 
std::map< std::pair< bool, int >
, double > 
m_l1Rate
 
unsigned int m_lhcFill
 
std::map< TString,
MonitorElement * > 
m_meAlgoEfficiency
 
std::map< TString,
MonitorElement * > 
m_meAlgoMissFire
 
std::map< std::pair< bool, int >
, MonitorElement * > 
m_meRate
 
std::map< TString,
MonitorElement * > 
m_meTechEfficiency
 
std::map< TString,
MonitorElement * > 
m_meTechMissFire
 
std::map< TString, int > m_missFireDenominator
 
std::map< TString, int > m_missFireNumerator
 
std::vector< edm::ParameterSetm_monitorBits
 
std::vector< edm::ParameterSetm_monitorRates
 
std::string m_outputFile
 
edm::ParameterSet m_parameters
 
const std::vector< std::vector
< int > > * 
m_prescaleFactorsAlgoTrig
 
const std::vector< std::vector
< int > > * 
m_prescaleFactorsTechTrig
 
bool * m_processedLS
 
int m_refPrescaleSet
 
edm::EDGetTokenT
< Level1TriggerScalersCollection
m_scalersSource
 
std::vector< std::pair< int,
int > > 
m_selAlgoBit
 
std::vector< std::pair< int,
int > > 
m_selTechBit
 
std::map< int, TString > m_techBit_Alias
 
bool m_verbose
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Detailed Description

Definition at line 70 of file L1TBPTX.h.

Member Enumeration Documentation

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

Definition at line 74 of file L1TBPTX.h.

74  {
75  NOMODE=1,
76  SETUP=2,
77  INJPILOT=3,
78  INJINTR=4,
79  INJNOMN=5,
80  PRERAMP=6,
81  RAMP=7,
82  FLATTOP=8,
83  SQUEEZE=9,
84  ADJUST=10,
85  STABLE=11,
86  UNSTABLE=12,
87  BEAMDUMP=13,
88  RAMPDOWN=14,
89  RECOVERY=15,
90  INJDUMP=16,
91  CIRCDUMP=17,
92  ABORT=18,
93  CYCLING=19,
94  WBDUMP=20,
95  NOBEAM=21
96  };
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 98 of file L1TBPTX.h.

Constructor & Destructor Documentation

L1TBPTX::L1TBPTX ( const edm::ParameterSet ps)

Definition at line 32 of file L1TBPTX.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), i, evf::evtn::offset(), and cppFunctionSkipper::operator.

32  {
33 
34  m_parameters = pset;
35 
36  // Mapping parameter input variables
37  m_scalersSource = consumes<Level1TriggerScalersCollection>(pset.getParameter <InputTag>("inputTagScalersResults"));
38  m_l1GtDataDaqInputTag = consumes<L1GlobalTriggerReadoutRecord>(pset.getParameter <InputTag>("inputTagL1GtDataDaq"));
39  m_l1GtEvmSource = consumes<L1GlobalTriggerEvmReadoutRecord>(pset.getParameter <InputTag>("inputTagtEvmSource"));
40  m_verbose = pset.getUntrackedParameter<bool> ("verbose",false);
41 // m_refPrescaleSet = pset.getParameter <int> ("refPrescaleSet");
42 
43  m_monitorBits = pset.getParameter< vector<ParameterSet> >("MonitorBits");
44 
45  for(unsigned i=0; i<m_monitorBits.size(); i++){
46 
47  // Algorithms
48  if(m_monitorBits[i].getParameter<bool>("bitType")){
49 
50  int bit = m_monitorBits[i].getParameter<int>("bitNumber");
51  int offset = m_monitorBits[i].getParameter<int>("bitOffset");
52  m_selAlgoBit.push_back( pair<int,int>(bit,offset) );
53  }
54  // Tech
55  else{
56  int bit = m_monitorBits[i].getParameter<int>("bitNumber");
57  int offset = m_monitorBits[i].getParameter<int>("bitOffset");
58  m_selTechBit.push_back( pair<int,int>(bit,offset) );
59  }
60  }
61 
62  m_monitorRates = pset.getParameter< vector<ParameterSet> >("MonitorRates");
63 
64  if (pset.getUntrackedParameter < bool > ("dqmStore", false)) {
66  dbe->setVerbose(0);
67  }
68 
69 }
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtDataDaqInputTag
Definition: L1TBPTX.h:189
std::vector< std::pair< int, int > > m_selAlgoBit
Definition: L1TBPTX.h:162
edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > m_l1GtEvmSource
Definition: L1TBPTX.h:188
std::vector< std::pair< int, int > > m_selTechBit
Definition: L1TBPTX.h:163
DQMStore * dbe
Definition: L1TBPTX.h:135
bool m_verbose
Definition: L1TBPTX.h:143
edm::ParameterSet m_parameters
Definition: L1TBPTX.h:137
unsigned int offset(bool)
std::vector< edm::ParameterSet > m_monitorRates
Definition: L1TBPTX.h:139
std::vector< edm::ParameterSet > m_monitorBits
Definition: L1TBPTX.h:138
edm::EDGetTokenT< Level1TriggerScalersCollection > m_scalersSource
Definition: L1TBPTX.h:187
L1TBPTX::~L1TBPTX ( )
virtual

Definition at line 73 of file L1TBPTX.cc.

73 {}

Member Function Documentation

void L1TBPTX::analyze ( const edm::Event e,
const edm::EventSetup c 
)
protectedvirtual

Implements edm::EDAnalyzer.

Definition at line 348 of file L1TBPTX.cc.

References a, L1GtfeExtWord::beamMode(), gather_cfg::cout, edm::Event::getByToken(), Level1TriggerRates::gtAlgoCountsRate(), i, edm::EventBase::id(), edm::HandleBase::isValid(), L1GtfeExtWord::lhcFillNumber(), evf::evtn::offset(), and edm::EventID::run().

348  {
349 
350  if(m_verbose){cout << "[L1TBPTX] Called analyze." << endl;}
351 
352  // We only start analyzing if current LS is still valid
353  if(m_currentLSValid){
354 
355  if(m_verbose){cout << "[L1TBPTX] -> m_currentLSValid=" << m_currentLSValid << endl;}
356 
357  // Retriving information from GT
359  iEvent.getByToken(m_l1GtEvmSource, gtEvmReadoutRecord);
360 
361  // Determining beam mode and fill number
362  if(gtEvmReadoutRecord.isValid()){
363 
364  const L1GtfeExtWord& gtfeEvmWord = gtEvmReadoutRecord->gtfeWord();
365  unsigned int lhcBeamMode = gtfeEvmWord.beamMode(); // Updating beam mode
366 
367  if(m_verbose){cout << "[L1TBPTX] Beam mode: "<< lhcBeamMode << endl;}
368 
369  if(lhcBeamMode==RAMP || lhcBeamMode==FLATTOP || lhcBeamMode==SQUEEZE || lhcBeamMode==ADJUST || lhcBeamMode==STABLE){
370 
371  if(m_lhcFill==0){
372 
373  if(m_verbose){cout << "[L1TBPTX] No valid bunch structure yet retrived. Attemptting to retrive..." << endl;}
374 
375  m_lhcFill = gtfeEvmWord.lhcFillNumber(); // Getting LHC Fill Number from GT
376 
377  getBeamConfOMDS(); // Getting Beam Configuration from OMDS
378 
379  // We are between RAMP and STABLE so there should be some colliding bunches
380  // in the machine. If 0 colliding bunched are found might be due to a delay
381  // of the update of the database. So we declare this LS as invalid and try
382  // again on the next one.
384  m_lhcFill=0;
385  m_currentLSValid=false;
386  }
387  }
388  }
389  else{m_currentLSValid=false;}
390 
391  }else{
392  int eCount = m_ErrorMonitor->getTH1()->GetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT);
393  eCount++;
394  m_ErrorMonitor->getTH1()->SetBinContent(ERROR_UNABLE_RETRIVE_PRODUCT,eCount);
395  }
396  }
397 
398  //______________________________________________________________________________
399  // If current LS is valid and Beam Configuration is Valid we analyse this event
400  //______________________________________________________________________________
402 
403  if(m_verbose){cout << "Current event in valid LS and beam config" << endl;}
404 
405  // Getting Final Decision Logic (FDL) Data from GT
406  edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecordData;
407  iEvent.getByToken(m_l1GtDataDaqInputTag, gtReadoutRecordData);
408 
409  if(gtReadoutRecordData.isValid()){
410 
411  const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->gtFdlVector();
412 
413  // Getting the index for the fdl data for this event
414  int eventFDL=0;
415  for(unsigned int i=0; i<gtFdlVectorData.size(); i++){
416  if(gtFdlVectorData[i].bxInEvent()==0){eventFDL=i; break;}
417  }
418 
419  m_currentPrescalesIndex = gtFdlVectorData[eventFDL].gtPrescaleFactorIndexAlgo();
420 
421  for(unsigned i=0; i<m_monitorBits.size(); i++){
422 
423  TString triggerName = "";
424  bool isAlgo = m_monitorBits[i].getParameter<bool>("bitType");
425  int bit = m_monitorBits[i].getParameter<int> ("bitNumber");
426  int offset = m_monitorBits[i].getParameter<int> ("bitOffset");
427 
428  if(isAlgo){triggerName = "algo_"+bit;}
429  else {triggerName = "tech_"+bit;}
430 
431  int evBxStart = -2;
432  int evBxEnd = 2;
433 
434  if(offset<0){evBxStart+=-1*offset;}
435  if(offset>0){evBxEnd +=-1*offset;}
436 
437  for(unsigned a=0; a<gtFdlVectorData.size(); a++){
438 
439  int testBx = gtFdlVectorData[a].localBxNr()-offset;
440  bool lhcBxFilled = m_beamConfig.beam1[testBx] && m_beamConfig.beam2[testBx];
441  bool algoFired = false;
442 
443  if(isAlgo){
444  if(gtFdlVectorData[a].gtDecisionWord()[bit]){algoFired=true;}
445 
446  }
447  else{
448  if(gtFdlVectorData[a].gtTechnicalTriggerWord()[bit]){algoFired=true;}
449  }
450 
451  if(lhcBxFilled) {m_effDenominator[triggerName]++;}
452  if(lhcBxFilled && algoFired){m_effNumerator [triggerName]++;}
453 
454  if(algoFired) {m_missFireNumerator[triggerName]++;}
455  if(algoFired && !lhcBxFilled){m_missFireNumerator[triggerName]++;}
456 
457  }
458  }
459  }
460  }
461 
462  //______________________________________________________________________________
463  // Rate calculation
464  //______________________________________________________________________________
466  iEvent.getByToken(m_scalersSource,triggerScalers);
467 
468  if(triggerScalers.isValid()){
469 
470  Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
471  Level1TriggerRates trigRates(*itL1TScalers,iEvent.id().run());
472 
473  m_currentGTLS= (*itL1TScalers).lumiSegmentNr();
474 
475  for(unsigned i=0; i<m_monitorRates.size(); i++){
476 
477  bool isAlgo = m_monitorRates[i].getParameter<bool>("bitType");
478  int bit = m_monitorRates[i].getParameter<int> ("bitNumber");
479 
480  pair<bool,int> refTrig = pair<bool,int>(isAlgo,bit);
481 
482  if(isAlgo){m_l1Rate[refTrig] = trigRates.gtAlgoCountsRate()[bit];}
483  else {m_l1Rate[refTrig] = trigRates.gtTechCountsRate()[bit];}
484  }
485  }
486 
487 }
int i
Definition: DBlmapReader.cc:9
unsigned int m_lhcFill
Definition: L1TBPTX.h:158
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtDataDaqInputTag
Definition: L1TBPTX.h:189
edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > m_l1GtEvmSource
Definition: L1TBPTX.h:188
BeamConfiguration m_beamConfig
Definition: L1TBPTX.h:161
int iEvent
Definition: GenABIO.cc:230
bool m_verbose
Definition: L1TBPTX.h:143
std::map< TString, int > m_effDenominator
Definition: L1TBPTX.h:149
TH1 * getTH1(void) const
int m_currentPrescalesIndex
Definition: L1TBPTX.h:154
unsigned int offset(bool)
bool isValid() const
Definition: HandleBase.h:76
std::vector< edm::ParameterSet > m_monitorRates
Definition: L1TBPTX.h:139
bool m_currentLSValid
Definition: L1TBPTX.h:144
const cms_uint32_t lhcFillNumber() const
std::vector< edm::ParameterSet > m_monitorBits
Definition: L1TBPTX.h:138
unsigned int m_currentGTLS
Definition: L1TBPTX.h:156
std::map< TString, int > m_effNumerator
Definition: L1TBPTX.h:148
double a
Definition: hdecay.h:121
std::map< std::pair< bool, int >, double > m_l1Rate
Definition: L1TBPTX.h:181
std::vector< bool > beam2
Definition: L1TOMDSHelper.h:38
void getBeamConfOMDS()
Definition: L1TBPTX.cc:494
tuple cout
Definition: gather_cfg.py:121
std::vector< bool > beam1
Definition: L1TOMDSHelper.h:37
const cms_uint16_t beamMode() const
MonitorElement * m_ErrorMonitor
Definition: L1TBPTX.h:184
edm::EDGetTokenT< Level1TriggerScalersCollection > m_scalersSource
Definition: L1TBPTX.h:187
std::map< TString, int > m_missFireNumerator
Definition: L1TBPTX.h:150
void L1TBPTX::beginJob ( void  )
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 77 of file L1TBPTX.cc.

References gather_cfg::cout, AlcaSiStripGainsHarvester_cff::DQMStore, and cppFunctionSkipper::operator.

77  {
78 
79  if (m_verbose){cout << "[L1TBPTX] Called beginJob." << endl;}
80 
81  // get hold of back-end interface
82  DQMStore *dbe = 0;
83  dbe = Service < DQMStore > ().operator->();
84 
85  if (dbe) {
86  dbe->setCurrentFolder("L1T/L1TBPTX");
87  dbe->rmdir("L1T/L1TBPTX");
88  }
89 
90 }
DQMStore * dbe
Definition: L1TBPTX.h:135
bool m_verbose
Definition: L1TBPTX.h:143
tuple cout
Definition: gather_cfg.py:121
void L1TBPTX::beginLuminosityBlock ( edm::LuminosityBlock const &  lumiBlock,
edm::EventSetup const &  c 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 232 of file L1TBPTX.cc.

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

232  {
233 
234  if (m_verbose){cout << "[L1TBPTX] Called beginLuminosityBlock." << endl;}
235 
236  // Updating current LS number
237  m_currentLS = lumiBlock.id().luminosityBlock();
238 
239  // A LS will be valid if BeamMode==STABLE for all events monitored
240  m_currentLSValid = true;
241 
242  for(unsigned i=0; i<m_monitorBits.size(); i++){
243 
244  TString triggerName = "";
245  if(m_monitorBits[i].getParameter<bool>("bitType")){
246  triggerName = "algo_"+m_monitorBits[i].getParameter<int>("bitNumber");
247  }else{
248  triggerName = "tech_"+m_monitorBits[i].getParameter<int>("bitNumber");
249  }
250 
251  m_effNumerator [triggerName] = 0;
252  m_effDenominator [triggerName] = 0;
253  m_missFireNumerator [triggerName] = 0;
254  m_missFireDenominator[triggerName] = 0;
255 
256  }
257 
258 }
int i
Definition: DBlmapReader.cc:9
unsigned int m_currentLS
Definition: L1TBPTX.h:155
bool m_verbose
Definition: L1TBPTX.h:143
std::map< TString, int > m_effDenominator
Definition: L1TBPTX.h:149
bool m_currentLSValid
Definition: L1TBPTX.h:144
std::map< TString, int > m_missFireDenominator
Definition: L1TBPTX.h:151
std::vector< edm::ParameterSet > m_monitorBits
Definition: L1TBPTX.h:138
std::map< TString, int > m_effNumerator
Definition: L1TBPTX.h:148
tuple cout
Definition: gather_cfg.py:121
std::map< TString, int > m_missFireNumerator
Definition: L1TBPTX.h:150
void L1TBPTX::beginRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
protectedvirtual

BeginRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 108 of file L1TBPTX.cc.

References gather_cfg::cout, edm::EventSetup::get(), L1GtTriggerMenu::gtAlgorithmAliasMap(), L1GtPrescaleFactors::gtPrescaleFactors(), L1GtTriggerMenu::gtTechnicalTriggerMap(), i, edm::ESHandleBase::isValid(), relval_steps::menu, edm::ESHandle< class >::product(), and pat::UNKNOWN.

108  {
109 
110  if (m_verbose){cout << "[L1TBPTX] Called beginRun." << endl;}
111 
112  // Initializing variables
113  int maxNbins = 2501;
114 
115  // Reseting run dependent variables
116  m_lhcFill = 0;
117  m_currentLS = 0;
118 
119  // Getting Trigger menu from GT
121  iSetup.get<L1GtTriggerMenuRcd>().get(menuRcd);
122  const L1GtTriggerMenu* menu = menuRcd.product();
123 
124  // Filling Alias-Bit Map
125  for (CItAlgo algo = menu->gtAlgorithmAliasMap().begin(); algo!=menu->gtAlgorithmAliasMap().end(); ++algo){
126  m_algoBit_Alias[(algo->second).algoBitNumber()] = (algo->second).algoAlias();
127  }
128 
129  for (CItAlgo algo = menu->gtTechnicalTriggerMap().begin(); algo!=menu->gtTechnicalTriggerMap().end(); ++algo){
130  m_techBit_Alias[(algo->second).algoBitNumber()] = (algo->second).algoName();
131  }
132 
133  // Initializing DQM Monitor Elements
134  dbe->setCurrentFolder("L1T/L1TBPTX");
135  m_ErrorMonitor = dbe->book1D("ErrorMonitor","ErrorMonitor",7,0,7);
136  m_ErrorMonitor->setBinLabel(UNKNOWN ,"UNKNOWN");
137  m_ErrorMonitor->setBinLabel(WARNING_DB_CONN_FAILED ,"WARNING_DB_CONN_FAILED"); // Errors from L1TOMDSHelper
138  m_ErrorMonitor->setBinLabel(WARNING_DB_QUERY_FAILED ,"WARNING_DB_QUERY_FAILED"); // Errors from L1TOMDSHelper
139  m_ErrorMonitor->setBinLabel(WARNING_DB_INCORRECT_NBUNCHES,"WARNING_DB_INCORRECT_NBUNCHES"); // Errors from L1TOMDSHelper
140  m_ErrorMonitor->setBinLabel(ERROR_UNABLE_RETRIVE_PRODUCT ,"ERROR_UNABLE_RETRIVE_PRODUCT");
141  m_ErrorMonitor->setBinLabel(ERROR_TRIGGERALIAS_NOTVALID ,"ERROR_TRIGGERALIAS_NOTVALID");
142  m_ErrorMonitor->setBinLabel(ERROR_LSBLOCK_NOTVALID ,"ERROR_LSBLOCK_NOTVALID");
143 
144  for(unsigned i=0; i<m_monitorBits.size(); i++){
145 
146  bool isAlgo = m_monitorBits[i].getParameter<bool> ("bitType");
147  TString testName = m_monitorBits[i].getParameter<string>("testName");
148  int bit = m_monitorBits[i].getParameter<int> ("bitNumber");
149 
150  TString meTitle = "";
151  dbe->setCurrentFolder("L1T/L1TBPTX/Efficiency/");
152  if(isAlgo){
153  meTitle="Algo ";meTitle+=bit; meTitle+=" - "; meTitle+=m_algoBit_Alias[bit]; meTitle+=" Efficiency";
154  m_meAlgoEfficiency[bit] = dbe->book1D(testName,meTitle,maxNbins,-0.5,double(maxNbins)-0.5);
155  m_meAlgoEfficiency[bit]->setAxisTitle("Lumi Section" ,1);
156  }
157  else{
158  meTitle="Tech "; meTitle+=bit; meTitle+=" - "; meTitle+=m_techBit_Alias[bit]; meTitle+=" Efficiency";
159  m_meTechEfficiency[bit] = dbe->book1D(testName,meTitle,maxNbins,-0.5,double(maxNbins)-0.5);
160  m_meTechEfficiency[bit]->setAxisTitle("Lumi Section" ,1);
161  }
162 
163  meTitle = "";
164  dbe->setCurrentFolder("L1T/L1TBPTX/MissFire/");
165  if(isAlgo){
166  meTitle="Algo "; meTitle+=bit; meTitle+=" - "; meTitle+=m_algoBit_Alias[bit]; meTitle+="(1 - Miss Fire Rate)";
167  m_meAlgoMissFire[bit] = dbe->book1D(testName,meTitle,maxNbins,-0.5,double(maxNbins)-0.5);
168  m_meAlgoMissFire[bit]->setAxisTitle("Lumi Section" ,1);
169  m_meAlgoMissFire[bit]->setAxisTitle("1 - Miss Fire Rate",2);
170  }
171  else{
172  meTitle="Tech "; meTitle+=bit; meTitle+=" - "; meTitle+=m_techBit_Alias[bit]; meTitle+="(1 - Miss Fire Rate)";
173  m_meTechMissFire[bit] = dbe->book1D(testName,meTitle,maxNbins,-0.5,double(maxNbins)-0.5);
174  m_meTechMissFire[bit]->setAxisTitle("Lumi Section" ,1);
175  m_meTechMissFire[bit]->setAxisTitle("1 - Miss Fire Rate",2);
176  }
177  }
178 
179  for(unsigned i=0; i<m_monitorRates.size(); i++){
180 
181  TString testName = m_monitorRates[i].getParameter<string>("testName");
182  bool isAlgo = m_monitorRates[i].getParameter<bool> ("bitType");
183  int bit = m_monitorRates[i].getParameter<int> ("bitNumber");
184 
185  pair<bool,int> refME = pair<bool,int>(isAlgo,bit);
186 
187  TString meTitle = "";
188  dbe->setCurrentFolder("L1T/L1TBPTX/Rate/");
189  if(isAlgo){
190  meTitle="Algo "+bit; meTitle+=" - "; meTitle+=m_algoBit_Alias[bit]; meTitle+=" Rate";
191  m_meRate[refME] = dbe->book1D(testName,meTitle,maxNbins,-0.5,double(maxNbins)-0.5);
192  m_meRate[refME]->setAxisTitle("Lumi Section" ,1);
193  m_meRate[refME]->setAxisTitle("Rate (unprescaled) [Hz]",2);
194  }
195  else{
196  meTitle="Tech "+bit; meTitle+=" - "; meTitle+=m_techBit_Alias[bit]; meTitle+=" Rate";
197  m_meRate[refME] = dbe->book1D(testName,meTitle,maxNbins,-0.5,double(maxNbins)-0.5);
198  m_meRate[refME]->setAxisTitle("Lumi Section" ,1);
199  m_meRate[refME]->setAxisTitle("Rate (unprescaled) [Hz]",2);
200  }
201  }
202 
203 
204 
205  //_____________________________________________________________________
206  // Getting the prescale columns definition for this run
209 
210  iSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().get(l1GtPfAlgo);
211  iSetup.get<L1GtPrescaleFactorsTechTrigRcd>().get(l1GtPfTech);
212 
213  if(l1GtPfAlgo.isValid()){
214  const L1GtPrescaleFactors* m_l1GtPfAlgo = l1GtPfAlgo.product();
215  m_prescaleFactorsAlgoTrig = &(m_l1GtPfAlgo->gtPrescaleFactors());
216  }else{
217  //TODO: Some error handling
218  }
219 
220  if(l1GtPfAlgo.isValid()){
221  const L1GtPrescaleFactors* m_l1GtPfTech = l1GtPfTech.product();
222  m_prescaleFactorsTechTrig = &(m_l1GtPfTech->gtPrescaleFactors());
223  }else{
224  //TODO: Some error handling
225  }
226 
227 }
std::map< TString, MonitorElement * > m_meTechEfficiency
Definition: L1TBPTX.h:176
int i
Definition: DBlmapReader.cc:9
unsigned int m_lhcFill
Definition: L1TBPTX.h:158
std::map< TString, MonitorElement * > m_meAlgoEfficiency
Definition: L1TBPTX.h:174
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
unsigned int m_currentLS
Definition: L1TBPTX.h:155
std::map< std::pair< bool, int >, MonitorElement * > m_meRate
Definition: L1TBPTX.h:180
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
DQMStore * dbe
Definition: L1TBPTX.h:135
std::map< TString, MonitorElement * > m_meAlgoMissFire
Definition: L1TBPTX.h:175
bool m_verbose
Definition: L1TBPTX.h:143
const std::vector< std::vector< int > > * m_prescaleFactorsTechTrig
Definition: L1TBPTX.h:167
std::vector< edm::ParameterSet > m_monitorRates
Definition: L1TBPTX.h:139
const std::vector< std::vector< int > > & gtPrescaleFactors() const
get the prescale factors by reference
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
std::map< int, TString > m_techBit_Alias
Definition: L1TBPTX.h:171
std::vector< edm::ParameterSet > m_monitorBits
Definition: L1TBPTX.h:138
std::map< TString, MonitorElement * > m_meTechMissFire
Definition: L1TBPTX.h:177
tuple cout
Definition: gather_cfg.py:121
const AlgorithmMap & gtTechnicalTriggerMap() const
get / set the technical trigger map
const AlgorithmMap & gtAlgorithmAliasMap() const
get / set the algorithm map (by alias)
std::map< int, TString > m_algoBit_Alias
Definition: L1TBPTX.h:170
bool isValid() const
Definition: ESHandle.h:47
MonitorElement * m_ErrorMonitor
Definition: L1TBPTX.h:184
const std::vector< std::vector< int > > * m_prescaleFactorsAlgoTrig
Definition: L1TBPTX.h:166
void L1TBPTX::certifyLSBlock ( std::string  iTrigger,
int  iInitLs,
int  iEndLs,
float  iValue 
)
private

Definition at line 578 of file L1TBPTX.cc.

578  {
579 
580 }
void L1TBPTX::doFractionInSync ( bool  iForce = false,
bool  iBad = false 
)
private

Definition at line 565 of file L1TBPTX.cc.

565  {
566 
567 }
void L1TBPTX::endJob ( void  )
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 94 of file L1TBPTX.cc.

References gather_cfg::cout.

94  {
95 
96  if (m_verbose){cout << "[L1TBPTX] Called endJob." << endl;}
97 
98  if (m_outputFile.size() != 0 && dbe)
99  dbe->save(m_outputFile);
100 
101  return;
102 
103 }
std::string m_outputFile
Definition: L1TBPTX.h:140
DQMStore * dbe
Definition: L1TBPTX.h:135
bool m_verbose
Definition: L1TBPTX.h:143
tuple cout
Definition: gather_cfg.py:121
void L1TBPTX::endLuminosityBlock ( edm::LuminosityBlock const &  lumiBlock,
edm::EventSetup const &  c 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 264 of file L1TBPTX.cc.

References newFWLiteAna::bin, gather_cfg::cout, and i.

264  {
265 
266  //______________________________________________________________________________
267  // Monitoring efficiencies
268  //______________________________________________________________________________
269  if(m_verbose){cout << "[L1TBPTX] Called endLuminosityBlock." << endl;}
270 
271  // If this LS is valid (i.e. all events recorded with stable beams)
273 
274  for(unsigned i=0; i<m_monitorBits.size(); i++){
275 
276  bool isAlgo = m_monitorBits[i].getParameter<bool> ("bitType");
277  TString testName = m_monitorBits[i].getParameter<string>("testName");
278  int bit = m_monitorBits[i].getParameter<int> ("bitNumber");
279 
280  TString triggerName;
281  if(isAlgo){triggerName = "algo_"+bit;}
282  else {triggerName = "tech_"+bit;}
283 
284  double valEff;
285  double valMiss;
286  if(m_effDenominator[triggerName]!=0) {valEff = (double)m_effNumerator[triggerName]/m_effDenominator[triggerName];}
287  else {valEff = 0;}
288  if(m_missFireDenominator[triggerName]!=0){valMiss = (double)m_missFireNumerator[triggerName]/m_missFireDenominator[triggerName];}
289  else {valMiss = 0;}
290 
291  if(isAlgo){
292  int bin = m_meAlgoEfficiency[bit]->getTH1()->FindBin(m_currentLS);
293  m_meAlgoEfficiency[bit]->setBinContent(bin,valEff);
294  m_meAlgoMissFire[bit] ->setBinContent(bin,1-valMiss);
295  }
296  else{
297  int bin = m_meTechEfficiency[bit]->getTH1()->FindBin(m_currentLS);
298  m_meTechEfficiency[bit]->setBinContent(bin,valEff);
299  m_meTechMissFire[bit] ->setBinContent(bin,1-valMiss);
300  }
301  }
302  }
303 
304  //______________________________________________________________________________
305  // Monitoring rates
306  //______________________________________________________________________________
307  // We are only interested in monitoring lumisections where the the LHC state is
308  // RAMP, FLATTOP, SQUEEZE, ADJUST or STABLE since the bunch configuration and
309  // therefore the BPTX rate will not change.
310 
311  if(m_currentLSValid){
312 
313  const vector<int>& currentPFAlgo = (*m_prescaleFactorsAlgoTrig).at(m_currentPrescalesIndex);
314  const vector<int>& currentPFTech = (*m_prescaleFactorsTechTrig).at(m_currentPrescalesIndex);
315 
316  for(unsigned i=0; i<m_monitorRates.size(); i++){
317 
318  bool isAlgo = m_monitorRates[i].getParameter<bool> ("bitType");
319  int bit = m_monitorRates[i].getParameter<int> ("bitNumber");
320 
321  pair<bool,int> refME = pair<bool,int>(isAlgo,bit);
322 
323  if(isAlgo){
324  int bin = m_meRate[refME]->getTH1()->FindBin(m_currentGTLS);
325  int trigPS = currentPFAlgo[bit];
326  double trigRate = (double) trigPS*m_l1Rate[refME];
327  m_meRate[refME]->setBinContent(bin,trigRate);
328 
329  }else{
330  int bin = m_meRate[refME]->getTH1()->FindBin(m_currentGTLS);
331  int trigPS = currentPFTech[bit];
332  double trigRate = (double) trigPS*m_l1Rate[refME];
333  m_meRate[refME]->setBinContent(bin,trigRate);
334  }
335  }
336  }
337 }
std::map< TString, MonitorElement * > m_meTechEfficiency
Definition: L1TBPTX.h:176
int i
Definition: DBlmapReader.cc:9
std::map< TString, MonitorElement * > m_meAlgoEfficiency
Definition: L1TBPTX.h:174
unsigned int m_currentLS
Definition: L1TBPTX.h:155
BeamConfiguration m_beamConfig
Definition: L1TBPTX.h:161
std::map< std::pair< bool, int >, MonitorElement * > m_meRate
Definition: L1TBPTX.h:180
std::map< TString, MonitorElement * > m_meAlgoMissFire
Definition: L1TBPTX.h:175
bool m_verbose
Definition: L1TBPTX.h:143
std::map< TString, int > m_effDenominator
Definition: L1TBPTX.h:149
int m_currentPrescalesIndex
Definition: L1TBPTX.h:154
std::vector< edm::ParameterSet > m_monitorRates
Definition: L1TBPTX.h:139
bool m_currentLSValid
Definition: L1TBPTX.h:144
std::map< TString, int > m_missFireDenominator
Definition: L1TBPTX.h:151
std::vector< edm::ParameterSet > m_monitorBits
Definition: L1TBPTX.h:138
unsigned int m_currentGTLS
Definition: L1TBPTX.h:156
std::map< TString, int > m_effNumerator
Definition: L1TBPTX.h:148
std::map< TString, MonitorElement * > m_meTechMissFire
Definition: L1TBPTX.h:177
std::map< std::pair< bool, int >, double > m_l1Rate
Definition: L1TBPTX.h:181
tuple cout
Definition: gather_cfg.py:121
std::map< TString, int > m_missFireNumerator
Definition: L1TBPTX.h:150
void L1TBPTX::endRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 340 of file L1TBPTX.cc.

References gather_cfg::cout.

340  {
341 
342  if(m_verbose){cout << "[L1TBPTX] Called endRun." << endl;}
343 
344 
345 }
bool m_verbose
Definition: L1TBPTX.h:143
tuple cout
Definition: gather_cfg.py:121
void L1TBPTX::getBeamConfOMDS ( )
private

Definition at line 494 of file L1TBPTX.cc.

References gather_cfg::cout, L1TOMDSHelper::NO_ERROR, pat::UNKNOWN, L1TOMDSHelper::WARNING_DB_CONN_FAILED, L1TOMDSHelper::WARNING_DB_INCORRECT_NBUNCHES, and L1TOMDSHelper::WARNING_DB_QUERY_FAILED.

494  {
495 
496  if(m_verbose){cout << "[L1TBPTX] Called getBeamConfOMDS()" << endl;}
497 
498  //Getting connection paremeters
499  string oracleDB = m_parameters.getParameter<string>("oracleDB");
500  string pathCondDB = m_parameters.getParameter<string>("pathCondDB");
501 
502  // Connecting to OMDS
503  L1TOMDSHelper myOMDSHelper = L1TOMDSHelper();
504  int conError;
505  myOMDSHelper.connect(oracleDB,pathCondDB,conError);
506 
507  if(conError == L1TOMDSHelper::NO_ERROR){
508 
509  if(m_verbose){cout << "[L1TBPTX] Connected to DB with no error." << endl;}
510 
511  int errorRetrive;
512  m_beamConfig = myOMDSHelper.getBeamConfiguration(m_lhcFill,errorRetrive);
513 
514  if(errorRetrive == L1TOMDSHelper::NO_ERROR){
515  if(m_verbose){
516  cout << "[L1TBPTX] Retriving LHC Bunch Structure: NO_ERROR" << endl;
517  cout << "[L1TSync] -> LHC Bunch Structure valid=" << m_beamConfig.m_valid << " nBunches=" << m_beamConfig.nCollidingBunches << endl;
518  }
519  }
520  else if(errorRetrive == L1TOMDSHelper::WARNING_DB_QUERY_FAILED){
521  if(m_verbose){cout << "[L1TBPTX] Retriving LHC Bunch Structure: WARNING_DB_QUERY_FAILED" << endl;}
522 
523  int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_QUERY_FAILED);
524  eCount++;
525  m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_QUERY_FAILED,eCount);
526  }
527  else if(errorRetrive == L1TOMDSHelper::WARNING_DB_INCORRECT_NBUNCHES){
528  if(m_verbose){cout << "[L1TBPTX] Retriving LHC Bunch Structure: WARNING_DB_INCORRECT_NBUNCHES" << endl;}
529 
530  int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_INCORRECT_NBUNCHES);
531  eCount++;
532  m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_INCORRECT_NBUNCHES,eCount);
533  }
534  else{
535  if(m_verbose){cout << "[L1TBPTX] Retriving LHC Bunch Structure: UNKNOWN" << endl;}
536  int eCount = m_ErrorMonitor->getTH1()->GetBinContent(UNKNOWN);
537  eCount++;
538  m_ErrorMonitor->getTH1()->SetBinContent(UNKNOWN,eCount);
539  }
540 
541  }
542  else if(conError == L1TOMDSHelper::WARNING_DB_CONN_FAILED){
543  if(m_verbose){cout << "[L1TBPTX] Connection to DB: WARNING_DB_CONN_FAILED" << endl;}
544  int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_DB_CONN_FAILED);
545  eCount++;
546  m_ErrorMonitor->getTH1()->SetBinContent(WARNING_DB_CONN_FAILED,eCount);
547  }
548  else{
549  if(m_verbose){cout << "[L1TBPTX] Connection to DB: UNKNOWN" << endl;}
550  int eCount = m_ErrorMonitor->getTH1()->GetBinContent(UNKNOWN);
551  eCount++;
552  m_ErrorMonitor->getTH1()->SetBinContent(UNKNOWN,eCount);
553  }
554 }
T getParameter(std::string const &) const
unsigned int m_lhcFill
Definition: L1TBPTX.h:158
BeamConfiguration m_beamConfig
Definition: L1TBPTX.h:161
bool m_verbose
Definition: L1TBPTX.h:143
edm::ParameterSet m_parameters
Definition: L1TBPTX.h:137
TH1 * getTH1(void) const
tuple cout
Definition: gather_cfg.py:121
MonitorElement * m_ErrorMonitor
Definition: L1TBPTX.h:184

Member Data Documentation

DQMStore* L1TBPTX::dbe
private

Definition at line 135 of file L1TBPTX.h.

std::map<int,TString> L1TBPTX::m_algoBit_Alias
private

Definition at line 170 of file L1TBPTX.h.

BeamConfiguration L1TBPTX::m_beamConfig
private

Definition at line 161 of file L1TBPTX.h.

unsigned int L1TBPTX::m_currentGTLS
private

Definition at line 156 of file L1TBPTX.h.

unsigned int L1TBPTX::m_currentLS
private

Definition at line 155 of file L1TBPTX.h.

bool L1TBPTX::m_currentLSValid
private

Definition at line 144 of file L1TBPTX.h.

int L1TBPTX::m_currentPrescalesIndex
private

Definition at line 154 of file L1TBPTX.h.

std::map<TString,int> L1TBPTX::m_effDenominator
private

Definition at line 149 of file L1TBPTX.h.

std::map<TString,int> L1TBPTX::m_effNumerator
private

Definition at line 148 of file L1TBPTX.h.

MonitorElement* L1TBPTX::m_ErrorMonitor
private

Definition at line 184 of file L1TBPTX.h.

edm::EDGetTokenT<L1GlobalTriggerReadoutRecord> L1TBPTX::m_l1GtDataDaqInputTag
private

Definition at line 189 of file L1TBPTX.h.

edm::EDGetTokenT<L1GlobalTriggerEvmReadoutRecord> L1TBPTX::m_l1GtEvmSource
private

Definition at line 188 of file L1TBPTX.h.

std::map<std::pair<bool,int>,double> L1TBPTX::m_l1Rate
private

Definition at line 181 of file L1TBPTX.h.

unsigned int L1TBPTX::m_lhcFill
private

Definition at line 158 of file L1TBPTX.h.

std::map<TString,MonitorElement*> L1TBPTX::m_meAlgoEfficiency
private

Definition at line 174 of file L1TBPTX.h.

std::map<TString,MonitorElement*> L1TBPTX::m_meAlgoMissFire
private

Definition at line 175 of file L1TBPTX.h.

std::map<std::pair<bool,int>,MonitorElement*> L1TBPTX::m_meRate
private

Definition at line 180 of file L1TBPTX.h.

std::map<TString,MonitorElement*> L1TBPTX::m_meTechEfficiency
private

Definition at line 176 of file L1TBPTX.h.

std::map<TString,MonitorElement*> L1TBPTX::m_meTechMissFire
private

Definition at line 177 of file L1TBPTX.h.

std::map<TString,int> L1TBPTX::m_missFireDenominator
private

Definition at line 151 of file L1TBPTX.h.

std::map<TString,int> L1TBPTX::m_missFireNumerator
private

Definition at line 150 of file L1TBPTX.h.

std::vector<edm::ParameterSet> L1TBPTX::m_monitorBits
private

Definition at line 138 of file L1TBPTX.h.

std::vector<edm::ParameterSet> L1TBPTX::m_monitorRates
private

Definition at line 139 of file L1TBPTX.h.

std::string L1TBPTX::m_outputFile
private

Definition at line 140 of file L1TBPTX.h.

edm::ParameterSet L1TBPTX::m_parameters
private

Definition at line 137 of file L1TBPTX.h.

const std::vector<std::vector<int> >* L1TBPTX::m_prescaleFactorsAlgoTrig
private

Definition at line 166 of file L1TBPTX.h.

const std::vector<std::vector<int> >* L1TBPTX::m_prescaleFactorsTechTrig
private

Definition at line 167 of file L1TBPTX.h.

bool* L1TBPTX::m_processedLS
private

Definition at line 145 of file L1TBPTX.h.

int L1TBPTX::m_refPrescaleSet
private

Definition at line 153 of file L1TBPTX.h.

edm::EDGetTokenT<Level1TriggerScalersCollection> L1TBPTX::m_scalersSource
private

Definition at line 187 of file L1TBPTX.h.

std::vector< std::pair<int,int> > L1TBPTX::m_selAlgoBit
private

Definition at line 162 of file L1TBPTX.h.

std::vector< std::pair<int,int> > L1TBPTX::m_selTechBit
private

Definition at line 163 of file L1TBPTX.h.

std::map<int,TString> L1TBPTX::m_techBit_Alias
private

Definition at line 171 of file L1TBPTX.h.

bool L1TBPTX::m_verbose
private

Definition at line 143 of file L1TBPTX.h.