CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
L1TRate Class Reference

#include <L1TRate.h>

Inheritance diagram for L1TRate:
DQMEDAnalyzer edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > > edm::stream::EDAnalyzerBase edm::EDConsumerBase

Public Member Functions

 L1TRate (const edm::ParameterSet &ps)
 
 ~L1TRate () override
 
- Public Member Functions inherited from DQMEDAnalyzer
virtual void beginRun (edm::Run const &, edm::EventSetup const &) final
 
virtual void beginStream (edm::StreamID id) final
 
virtual void bookHistograms (DQMStore::IBooker &i, edm::Run const &, edm::EventSetup const &)=0
 
 DQMEDAnalyzer (void)
 
virtual void endLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
virtual void endRunSummary (edm::Run const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
uint32_t streamId () const
 
- Public Member Functions inherited from edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::stream::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
virtual ~EDConsumerBase () noexcept(false)
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
 
void bookHistograms (DQMStore::IBooker &ibooker, const edm::Run &, const edm::EventSetup &) override
 
void dqmBeginRun (edm::Run const &, edm::EventSetup const &) override
 
void endLuminosityBlock (edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
 
- 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

bool getXSexFitsOMDS (const edm::ParameterSet &ps)
 
bool getXSexFitsPython (const edm::ParameterSet &ps)
 

Private Attributes

std::map< TString, int > m_algoBit
 
MonitorElementm_ErrorMonitor
 
std::map< std::string, bool > m_inputCategories
 
edm::EDGetTokenT< L1GlobalTriggerReadoutRecordm_l1GtDataDaqInputTag
 
L1GtUtils m_l1GtUtils
 
const std::vector< std::vector< int > > * m_listsPrescaleFactors
 
std::map< int, double > m_lsLuminosity
 
std::map< int, int > m_lsPrescaleIndex
 
std::map< int, std::map< TString, double > > m_lsRates
 
int m_lsShiftGTRates
 
int m_maxNbins
 
std::string m_outputFile
 
edm::ParameterSet m_parameters
 
int m_refPrescaleSet
 
edm::EDGetTokenT< LumiScalersCollectionm_scalersSource_colLScal
 
edm::EDGetTokenT< Level1TriggerScalersCollectionm_scalersSource_triggerScalers
 
std::map< std::string, std::string > m_selectedTriggers
 
std::map< TString, TF1 * > m_templateFunctions
 
bool m_verbose
 
std::map< TString, MonitorElement * > m_xSecObservedToExpected
 
std::map< TString, MonitorElement * > m_xSecVsInstLumi
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
typedef CacheContexts< T... > CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T... > HasAbility
 
typedef CacheTypes::LuminosityBlockCache LuminosityBlockCache
 
typedef LuminosityBlockContextT< LuminosityBlockCache, RunCache, GlobalCacheLuminosityBlockContext
 
typedef CacheTypes::LuminosityBlockSummaryCache LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache, GlobalCacheRunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDAnalyzerBase
typedef EDAnalyzerAdaptorBase ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static std::shared_ptr< dqmDetails::NoCacheglobalBeginLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
 
static std::shared_ptr< dqmDetails::NoCacheglobalBeginRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *)
 
static void globalEndLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *, dqmDetails::NoCache *)
 
static void globalEndRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *, dqmDetails::NoCache *)
 
- Static Public Member Functions inherited from edm::stream::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Detailed Description

Definition at line 49 of file L1TRate.h.

Constructor & Destructor Documentation

L1TRate::L1TRate ( const edm::ParameterSet ps)

Definition at line 33 of file L1TRate.cc.

References TagProbeFitTreeAnalyzer_cfi::Categories, gather_cfg::cout, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), m_inputCategories, m_l1GtDataDaqInputTag, m_lsShiftGTRates, m_maxNbins, m_outputFile, m_parameters, m_refPrescaleSet, m_scalersSource_colLScal, m_scalersSource_triggerScalers, and m_verbose.

33  :
34  m_l1GtUtils(ps, consumesCollector(), false, *this) {
35 
36  m_maxNbins = 2500; // Maximum LS for each run (for binning purposes)
37  m_parameters = ps;
38 
39  // Mapping parameter input variables
40  m_scalersSource_colLScal = consumes<LumiScalersCollection> (m_parameters.getParameter<InputTag>("inputTagScalersResults"));
41  m_scalersSource_triggerScalers = consumes<Level1TriggerScalersCollection> (m_parameters.getParameter<InputTag>("inputTagScalersResults"));
42  m_l1GtDataDaqInputTag = consumes<L1GlobalTriggerReadoutRecord> (m_parameters.getParameter<InputTag>("inputTagL1GtDataDaq"));
43  m_verbose = m_parameters.getUntrackedParameter<bool> ("verbose",false);
44  m_refPrescaleSet = m_parameters.getParameter <int> ("refPrescaleSet");
45  m_lsShiftGTRates = m_parameters.getUntrackedParameter<int> ("lsShiftGTRates",0);
46 
47  // Getting which categories to monitor
48  ParameterSet Categories = ps.getParameter<ParameterSet>("categories");
49  m_inputCategories["Mu"] = Categories.getUntrackedParameter<bool>("Mu");
50  m_inputCategories["EG"] = Categories.getUntrackedParameter<bool>("EG");
51  m_inputCategories["IsoEG"] = Categories.getUntrackedParameter<bool>("IsoEG");
52  m_inputCategories["Jet"] = Categories.getUntrackedParameter<bool>("Jet");
53  m_inputCategories["CenJet"] = Categories.getUntrackedParameter<bool>("CenJet");
54  m_inputCategories["ForJet"] = Categories.getUntrackedParameter<bool>("ForJet");
55  m_inputCategories["TauJet"] = Categories.getUntrackedParameter<bool>("TauJet");
56  m_inputCategories["ETM"] = Categories.getUntrackedParameter<bool>("ETM");
57  m_inputCategories["ETT"] = Categories.getUntrackedParameter<bool>("ETT");
58  m_inputCategories["HTT"] = Categories.getUntrackedParameter<bool>("HTT");
59  m_inputCategories["HTM"] = Categories.getUntrackedParameter<bool>("HTM");
60 
61 
62  // What to do if we want our output to be saved to a external file
63  m_outputFile = ps.getUntrackedParameter < string > ("outputFile", "");
64 
65  if (!m_outputFile.empty()) {
66  cout << "L1T Monitoring histograms will be saved to " << m_outputFile.c_str() << endl;
67  }
68 
69  bool disable = ps.getUntrackedParameter < bool > ("disableROOToutput", false);
70  if (disable) {m_outputFile = "";}
71 
72 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< LumiScalersCollection > m_scalersSource_colLScal
Definition: L1TRate.h:103
edm::EDGetTokenT< Level1TriggerScalersCollection > m_scalersSource_triggerScalers
Definition: L1TRate.h:104
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtDataDaqInputTag
Definition: L1TRate.h:105
edm::ParameterSet m_parameters
Definition: L1TRate.h:108
bool m_verbose
Definition: L1TRate.h:78
L1GtUtils m_l1GtUtils
Definition: L1TRate.h:116
int m_lsShiftGTRates
Definition: L1TRate.h:83
ConsumesCollector consumesCollector()
Use a ConsumesCollector to gather consumes information from helper functions.
int m_maxNbins
Definition: L1TRate.h:82
int m_refPrescaleSet
Definition: L1TRate.h:81
std::string m_outputFile
Definition: L1TRate.h:86
std::map< std::string, bool > m_inputCategories
Definition: L1TRate.h:96
L1TRate::~L1TRate ( )
override

Definition at line 75 of file L1TRate.cc.

75 {}

Member Function Documentation

void L1TRate::analyze ( const edm::Event e,
const edm::EventSetup c 
)
overrideprotected

Definition at line 291 of file L1TRate.cc.

References gather_cfg::cout, edm::Event::getByToken(), edm::ParameterSet::getUntrackedParameter(), Level1TriggerRates::gtAlgoCountsRate(), L1GlobalTriggerReadoutRecord::gtFdlVector(), mps_fire::i, edm::EventBase::id(), muonGEMDigis_cfi::instLumi, edm::HandleBase::isValid(), edm::EventID::luminosityBlock(), m_algoBit, m_l1GtDataDaqInputTag, m_lsLuminosity, m_lsPrescaleIndex, m_lsRates, m_lsShiftGTRates, m_parameters, m_scalersSource_colLScal, m_scalersSource_triggerScalers, m_selectedTriggers, m_verbose, and edm::EventID::run().

291  {
292 
293  edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecordData;
296 
297  iEvent.getByToken(m_l1GtDataDaqInputTag, gtReadoutRecordData);
298  iEvent.getByToken(m_scalersSource_colLScal, colLScal);
299  iEvent.getByToken(m_scalersSource_triggerScalers, triggerScalers);
300 
301  // Integers
302  int EventRun = iEvent.id().run();
303  unsigned int eventLS = iEvent.id().luminosityBlock();
304 
305  // Getting the trigger trigger rates from GT and buffering it
306  if(triggerScalers.isValid()){
307 
308  Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
309  Level1TriggerRates trigRates(*itL1TScalers,EventRun);
310 
311  int gtLS = (*itL1TScalers).lumiSegmentNr()+m_lsShiftGTRates;
312 
313  // If we haven't got the data from this LS yet get it
314  if(m_lsRates.find(gtLS)==m_lsRates.end()){
315 
316  if (m_verbose) {cout << "[L1TRate:] Buffering GT Rates for LS=" << gtLS << endl;}
317  map<TString,double> bufferRate;
318 
319  // Buffer the rate informations for all selected bits
320  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
321 
322  string tTrigger = (*i).second;
323 
324  // If trigger name is defined we store the rate
325  if(tTrigger != "Undefined"){
326 
327  unsigned int trigBit = m_algoBit[tTrigger];
328  double trigRate = trigRates.gtAlgoCountsRate()[trigBit];
329 
330  bufferRate[tTrigger] = trigRate;
331  }
332  }
333  m_lsRates[gtLS] = bufferRate;
334  }
335  }
336 
337  // Getting from the SCAL the luminosity information and buffering it
338  if(colLScal.isValid() && !colLScal->empty()){
339 
340  LumiScalersCollection::const_iterator itLScal = colLScal->begin();
341  unsigned int scalLS = itLScal->sectionNumber();
342 
343  // If we haven't got the data from this SCAL LS yet get it
344  if(m_lsLuminosity.find(scalLS)==m_lsLuminosity.end()){
345 
346  if (m_verbose) {cout << "[L1TRate:] Buffering SCAL-HF Lumi for LS=" << scalLS << endl;}
347  double instLumi = itLScal->instantLumi(); // Getting Instant Lumi from HF (via SCAL)
348  double deadTimeNormHF = itLScal->deadTimeNormalization(); // Getting Dead Time Normalization from HF (via SCAL)
349 
350  // If HF Dead Time Corrections is requested we apply it
351  // NOTE: By default this is assumed false since for now WbM fits do NOT assume this correction
352  if(m_parameters.getUntrackedParameter<bool>("useHFDeadTimeNormalization",false)){
353 
354  // Protecting for deadtime = 0
355  if(deadTimeNormHF==0){instLumi = 0;}
356  else {instLumi = instLumi/deadTimeNormHF;}
357  }
358  // Buffering the luminosity information
359  m_lsLuminosity[scalLS]=instLumi;
360  }
361  }
362 
363  // Getting the prescale index used when this event was triggered
364  if(gtReadoutRecordData.isValid()){
365 
366  // If we haven't got the data from this LS yet get it
367  if(m_lsPrescaleIndex.find(eventLS)==m_lsPrescaleIndex.end()){
368 
369  if (m_verbose) {cout << "[L1TRate:] Buffering Prescale Index for LS=" << eventLS << endl;}
370 
371  // Getting Final Decision Logic (FDL) Data from GT
372  const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->gtFdlVector();
373 
374  // Getting the index for the fdl data for this event
375  int indexFDL=0;
376  for(unsigned int i=0; i<gtFdlVectorData.size(); i++){
377  if(gtFdlVectorData[i].bxInEvent()==0){indexFDL=i; break;}
378  }
379 
380  int CurrentPrescalesIndex = gtFdlVectorData[indexFDL].gtPrescaleFactorIndexAlgo();
381  m_lsPrescaleIndex[eventLS] = CurrentPrescalesIndex;
382  }
383  }
384 }
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< LumiScalersCollection > m_scalersSource_colLScal
Definition: L1TRate.h:103
edm::EDGetTokenT< Level1TriggerScalersCollection > m_scalersSource_triggerScalers
Definition: L1TRate.h:104
std::map< int, std::map< TString, double > > m_lsRates
Definition: L1TRate.h:94
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtDataDaqInputTag
Definition: L1TRate.h:105
const std::vector< L1GtFdlWord > gtFdlVector() const
get the vector of L1GtFdlWord
edm::ParameterSet m_parameters
Definition: L1TRate.h:108
bool m_verbose
Definition: L1TRate.h:78
int m_lsShiftGTRates
Definition: L1TRate.h:83
int iEvent
Definition: GenABIO.cc:230
std::map< int, double > m_lsLuminosity
Definition: L1TRate.h:93
std::map< TString, int > m_algoBit
Definition: L1TRate.h:95
bool isValid() const
Definition: HandleBase.h:74
std::map< int, int > m_lsPrescaleIndex
Definition: L1TRate.h:92
std::map< std::string, std::string > m_selectedTriggers
Definition: L1TRate.h:97
void L1TRate::beginLuminosityBlock ( edm::LuminosityBlock const &  lumiBlock,
edm::EventSetup const &  c 
)
overrideprotectedvirtual

Reimplemented from edm::stream::EDAnalyzerBase.

Definition at line 201 of file L1TRate.cc.

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

201  {
202 
203  if (m_verbose) {cout << "[L1TRate:] Called beginLuminosityBlock at LS=" << lumiBlock.id().luminosityBlock() << endl;}
204 
205 }
bool m_verbose
Definition: L1TRate.h:78
void L1TRate::bookHistograms ( DQMStore::IBooker ibooker,
const edm::Run ,
const edm::EventSetup iSetup 
)
overrideprotected

Definition at line 80 of file L1TRate.cc.

References patPFMETCorrections_cff::algo, DQMStore::IBooker::book1D(), DQMStore::IBooker::bookProfile(), edm::EventSetup::get(), L1TMenuHelper::getEtaRangeByAlias(), L1TMenuHelper::getLUSOTrigger(), edm::ParameterSet::getParameter(), L1TMenuHelper::getPrescaleByAlias(), L1TMenuHelper::getQualityAlias(), getXSexFitsOMDS(), getXSexFitsPython(), L1GtTriggerMenu::gtAlgorithmMap(), L1GtPrescaleFactors::gtPrescaleFactors(), mps_fire::i, m_algoBit, m_ErrorMonitor, m_inputCategories, m_l1GtUtils, m_listsPrescaleFactors, m_maxNbins, m_parameters, m_refPrescaleSet, m_selectedTriggers, m_templateFunctions, m_xSecObservedToExpected, m_xSecVsInstLumi, edm::ESHandle< T >::product(), L1GtUtils::retrieveL1EventSetup(), MonitorElement::setBinLabel(), and DQMStore::IBooker::setCurrentFolder().

80  {
81 
82 
85 
86  iSetup.get<L1GtTriggerMenuRcd>() .get(menuRcd);
87  iSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().get(l1GtPfAlgo);
88 
89  const L1GtTriggerMenu* menu = menuRcd .product();
90  const L1GtPrescaleFactors* m_l1GtPfAlgo = l1GtPfAlgo.product();
91 
92  // Initializing DQM Monitor Elements
93  ibooker.setCurrentFolder("L1T/L1TRate");
94  m_ErrorMonitor = ibooker.book1D("ErrorMonitor", "ErrorMonitor",5,0,5);
95  m_ErrorMonitor->setBinLabel(1,"WARNING_DB_CONN_FAILED"); // Errors from L1TOMDSHelper
96  m_ErrorMonitor->setBinLabel(2,"WARNING_DB_QUERY_FAILED"); // Errors from L1TOMDSHelper
97  m_ErrorMonitor->setBinLabel(3,"WARNING_DB_INCORRECT_NBUNCHES"); // Errors from L1TOMDSHelper
98  m_ErrorMonitor->setBinLabel(4,"WARNING_PY_MISSING_FIT");
99  m_ErrorMonitor->setBinLabel(5,"UNKNOWN");
100 
101  // Retriving the list of prescale sets
102  m_listsPrescaleFactors = &(m_l1GtPfAlgo->gtPrescaleFactors());
103 
104  // Getting Lowest Prescale Single Object Triggers from the menu
105  L1TMenuHelper myMenuHelper = L1TMenuHelper(iSetup);
108 
109  //-> Getting template fits for the algLo cross sections
110  int srcAlgoXSecFit = m_parameters.getParameter<int>("srcAlgoXSecFit");
111  if (srcAlgoXSecFit == 0){getXSexFitsOMDS (m_parameters);}
112  else if(srcAlgoXSecFit == 1){getXSexFitsPython(m_parameters);}
113 
114  for (CItAlgo algo = menu->gtAlgorithmMap().begin(); algo!=menu->gtAlgorithmMap().end(); ++algo){
115  m_algoBit[(algo->second).algoAlias()] = (algo->second).algoBitNumber();
116  }
117 
118  double minInstantLuminosity = m_parameters.getParameter<double>("minInstantLuminosity");
119  double maxInstantLuminosity = m_parameters.getParameter<double>("maxInstantLuminosity");
120 
121  // Initializing DQM Monitor Elements
122  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
123 
124  TString tCategory = (*i).first;
125  TString tTrigger = (*i).second;
126 
127  TString tErrorMessage = "";
128  TF1* tTestFunction;
129 
130  if(tTrigger != "Undefined" && m_templateFunctions.find(tTrigger) != m_templateFunctions.end()){
131  tTestFunction = m_templateFunctions[tTrigger];
132  }
133  else if(tTrigger == "Undefined"){
134  TString tFunc = "-1";
135  tTestFunction = new TF1("FitParametrization_"+tTrigger,tFunc,0,double(m_maxNbins)-0.5);
136  }
137  else if(m_templateFunctions.find(tTrigger) == m_templateFunctions.end()){
138  TString tFunc = "-1";
139  tTestFunction = new TF1("FitParametrization_"+tTrigger,tFunc,0,double(m_maxNbins)-0.5);
140  tErrorMessage = " (Undefined Test Function)";
141  }
142  else{
143  TString tFunc = "-1";
144  tTestFunction = new TF1("FitParametrization_"+tTrigger,tFunc,0,double(m_maxNbins)-0.5);
145  }
146 
147  if(tTrigger != "Undefined"){
148 
149  if(myMenuHelper.getPrescaleByAlias(tCategory,tTrigger) != 1){
150  tErrorMessage += " WARNING: Default Prescale = ";
151  tErrorMessage += myMenuHelper.getPrescaleByAlias(tCategory,tTrigger);
152  }
153 
154  if (tCategory == "Mu" && myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger) != 4294967295){
155  tErrorMessage += " WARNING: Eta Range = ";
156  tErrorMessage += myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger);
157  }
158  else if(tCategory == "EG" && myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger) != 32639){
159  tErrorMessage += " WARNING: Eta Range = ";
160  tErrorMessage += myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger);
161  }
162  else if(tCategory == "IsoEG" && myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger) != 32639){
163  tErrorMessage += " WARNING: Eta Range = ";
164  tErrorMessage += myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger);
165  }
166 
167  if(tCategory == "Mu" && myMenuHelper.getQualityAlias(tCategory,tTrigger) != 240){
168  tErrorMessage += " WARNING: Quality = ";
169  tErrorMessage += myMenuHelper.getQualityAlias(tCategory,tTrigger);
170  }
171 
172  }
173 
174 
175 
176  ibooker.setCurrentFolder("L1T/L1TRate/TriggerCrossSections");
177  m_xSecVsInstLumi[tTrigger] = ibooker.bookProfile(tCategory,
178  "Cross Sec. vs Inst. Lumi Algo: "+tTrigger+tErrorMessage,
179  m_maxNbins,
180  minInstantLuminosity,
181  maxInstantLuminosity,0,500);
182  m_xSecVsInstLumi[tTrigger] ->setAxisTitle("Instantaneous Luminosity [10^{30}cm^{-2}s^{-1}]" ,1);
183  m_xSecVsInstLumi[tTrigger] ->setAxisTitle("Algorithm #sigma [#mu b]" ,2);
184  m_xSecVsInstLumi[tTrigger] ->getTProfile()->GetListOfFunctions()->Add(tTestFunction);
185  m_xSecVsInstLumi[tTrigger] ->getTProfile()->SetMarkerStyle(23);
186 
187  ibooker.setCurrentFolder("L1T/L1TRate/Certification");
188  m_xSecObservedToExpected[tTrigger] = ibooker.book1D(tCategory, "Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,double(m_maxNbins)-0.5);
189  m_xSecObservedToExpected[tTrigger] ->setAxisTitle("Lumi Section" ,1);
190  m_xSecObservedToExpected[tTrigger] ->setAxisTitle("#sigma_{obs} / #sigma_{exp}" ,2);
191 
192  }
193 
194 }
T getParameter(std::string const &) const
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
std::map< TString, MonitorElement * > m_xSecObservedToExpected
Definition: L1TRate.h:98
edm::ParameterSet m_parameters
Definition: L1TRate.h:108
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)
std::map< TString, TF1 * > m_templateFunctions
Definition: L1TRate.h:100
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
L1GtUtils m_l1GtUtils
Definition: L1TRate.h:116
bool getXSexFitsPython(const edm::ParameterSet &ps)
Definition: L1TRate.cc:470
int m_maxNbins
Definition: L1TRate.h:82
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
std::map< TString, int > m_algoBit
Definition: L1TRate.h:95
int m_refPrescaleSet
Definition: L1TRate.h:81
void retrieveL1EventSetup(const edm::EventSetup &)
retrieve all the relevant L1 trigger event setup records and cache them to improve the speed ...
Definition: L1GtUtils.cc:121
unsigned int getQualityAlias(const TString &iCategory, const TString &iAlias)
bool getXSexFitsOMDS(const edm::ParameterSet &ps)
Definition: L1TRate.cc:395
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
const std::vector< std::vector< int > > & gtPrescaleFactors() const
get the prescale factors by reference
const std::vector< std::vector< int > > * m_listsPrescaleFactors
Definition: L1TRate.h:89
const T & get() const
Definition: EventSetup.h:55
std::map< TString, MonitorElement * > m_xSecVsInstLumi
Definition: L1TRate.h:99
std::map< std::string, bool > m_inputCategories
Definition: L1TRate.h:96
MonitorElement * m_ErrorMonitor
Definition: L1TRate.h:111
const AlgorithmMap & gtAlgorithmMap() const
get / set the algorithm map (by name)
unsigned int getEtaRangeByAlias(const TString &iCategory, const TString &iAlias)
int getPrescaleByAlias(const TString &iCategory, const TString &iAlias)
T const * product() const
Definition: ESHandle.h:86
std::map< std::string, std::string > m_selectedTriggers
Definition: L1TRate.h:97
std::map< std::string, std::string > getLUSOTrigger(const std::map< std::string, bool > &iCategories, int IndexRefPrescaleFactors, L1GtUtils const &myUtils)
void L1TRate::dqmBeginRun ( edm::Run const &  ,
edm::EventSetup const &   
)
overrideprotectedvirtual

Reimplemented from DQMEDAnalyzer.

Definition at line 196 of file L1TRate.cc.

References gather_cfg::cout, and m_verbose.

196  {
197  //
198  if (m_verbose) {cout << "[L1TRate:] Called beginRun." << endl;}
199 }
bool m_verbose
Definition: L1TRate.h:78
void L1TRate::endLuminosityBlock ( edm::LuminosityBlock const &  lumiBlock,
edm::EventSetup const &  c 
)
overrideprotectedvirtual

Reimplemented from edm::stream::EDAnalyzerBase.

Definition at line 208 of file L1TRate.cc.

References gather_cfg::cout, mps_fire::i, edm::LuminosityBlockBase::id(), eostools::ls(), edm::LuminosityBlockID::luminosityBlock(), m_algoBit, m_lsLuminosity, m_lsPrescaleIndex, m_lsRates, m_selectedTriggers, m_verbose, m_xSecObservedToExpected, m_xSecVsInstLumi, and genParticles_cff::map.

208  {
209 
210  int eventLS = lumiBlock.id().luminosityBlock();
211  if (m_verbose) {cout << "[L1TRate:] Called endLuminosityBlock at LS=" << eventLS << endl;}
212 
213  // We can certify LS -1 since we should have available:
214  // gt rates: (current LS)-1
215  // prescale: current LS
216  // lumi : current LS
217  //eventLS--;
218 
219  // Checking if all necessary quantities are defined for our calculations
220  bool isDefRate,isDefLumi,isDefPrescaleIndex;
221  map<TString,double>* rates=nullptr;
222  double lumi=0;
223  int prescalesIndex=0;
224 
225  // Reseting MonitorElements so we can refill them
226  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
227  string tTrigger = (*i).second;
228  m_xSecObservedToExpected[tTrigger]->getTH1()->Reset("ICE");
229  m_xSecVsInstLumi [tTrigger]->getTH1()->Reset("ICE");
230  }
231 
232  for(map<int,map<TString,double> >::iterator i=m_lsRates.begin() ; i!=m_lsRates.end() ; i++){
233 
234  unsigned int ls = (*i).first;
235  rates = &(*i).second;
236  isDefRate=true;
237 
238  if(m_lsLuminosity.find(ls)==m_lsLuminosity.end()){isDefLumi=false;}
239  else{
240  isDefLumi=true;
241  lumi=m_lsLuminosity[ls];
242  }
243 
244  if(m_lsPrescaleIndex.find(ls)==m_lsPrescaleIndex.end()){isDefPrescaleIndex=false;}
245  else{
246  isDefPrescaleIndex=true;
247  prescalesIndex=m_lsPrescaleIndex[ls];
248  }
249 
250  if(isDefRate && isDefLumi && isDefPrescaleIndex){
251 
252  const vector<int>& currentPrescaleFactors = (*m_listsPrescaleFactors).at(prescalesIndex);
253 
254  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
255 
256  string tTrigger = (*i).second;
257  TF1* tTestFunction = (TF1*) m_xSecVsInstLumi[tTrigger]->getTProfile()->GetListOfFunctions()->First();
258 
259  // If trigger name is defined we get the rate fit parameters
260  if(tTrigger != "Undefined"){
261 
262  unsigned int trigBit = m_algoBit[tTrigger];
263  double trigPrescale = currentPrescaleFactors[trigBit];
264  double trigRate = (*rates)[tTrigger];
265 
266  if(lumi!=0 && trigPrescale!=0 && trigRate!=0){
267 
268  double AlgoXSec = (trigPrescale*trigRate)/lumi;
269  double TemplateFunctionValue = tTestFunction->Eval(lumi);
270 
271  // Checking against Template function
272  int ibin = m_xSecObservedToExpected[tTrigger]->getTH1()->FindBin(ls);
273  m_xSecObservedToExpected[tTrigger]->setBinContent(ibin,AlgoXSec/TemplateFunctionValue);
274  m_xSecVsInstLumi [tTrigger]->Fill(lumi,AlgoXSec);
275 
276  if(m_verbose){cout<<"[L1TRate:] ls="<<ls<<" Algo="<<tTrigger<<" XSec="<<AlgoXSec<<" Test="<<AlgoXSec/TemplateFunctionValue<<endl;}
277 
278  }
279  else{
280  int ibin = m_xSecObservedToExpected[tTrigger]->getTH1()->FindBin(ls);
281  m_xSecObservedToExpected[tTrigger]->setBinContent(ibin,0.000001);
282  if(m_verbose){cout << "[L1TRate:] Algo="<< tTrigger<< " XSec=Failed" << endl;}
283  }
284  }
285  }
286  }
287  }
288 }
std::map< int, std::map< TString, double > > m_lsRates
Definition: L1TRate.h:94
std::map< TString, MonitorElement * > m_xSecObservedToExpected
Definition: L1TRate.h:98
bool m_verbose
Definition: L1TRate.h:78
std::map< int, double > m_lsLuminosity
Definition: L1TRate.h:93
std::map< TString, int > m_algoBit
Definition: L1TRate.h:95
def ls(path, rec=False)
Definition: eostools.py:348
std::map< TString, MonitorElement * > m_xSecVsInstLumi
Definition: L1TRate.h:99
std::map< int, int > m_lsPrescaleIndex
Definition: L1TRate.h:92
std::map< std::string, std::string > m_selectedTriggers
Definition: L1TRate.h:97
bool L1TRate::getXSexFitsOMDS ( const edm::ParameterSet ps)
private

Definition at line 395 of file L1TRate.cc.

References a, WbMTriggerXSecFit::bitName, L1TOMDSHelper::connect(), MonitorElement::Fill(), WbMTriggerXSecFit::fitFunction, edm::ParameterSet::getParameter(), m_ErrorMonitor, m_parameters, m_selectedTriggers, m_templateFunctions, L1TOMDSHelper::NO_ERROR, WbMTriggerXSecFit::p0, WbMTriggerXSecFit::p1, WbMTriggerXSecFit::p2, and WbMTriggerXSecFit::pm1.

Referenced by bookHistograms().

395  {
396 
397  bool noError = true;
398 
399  string oracleDB = ps.getParameter<string>("oracleDB");
400  string pathCondDB = ps.getParameter<string>("pathCondDB");
401 
402  L1TOMDSHelper myOMDSHelper;
403  int conError;
404  myOMDSHelper.connect(oracleDB,pathCondDB,conError);
405 
406  map<string,WbMTriggerXSecFit> wbmFits;
407 
408  if(conError == L1TOMDSHelper::NO_ERROR){
409  int errorRetrive;
410  wbmFits = myOMDSHelper.getWbMAlgoXsecFits(errorRetrive);
411 
412  // Filling errors if they exist
413  if(errorRetrive != L1TOMDSHelper::NO_ERROR){
414  noError = false;
415  string eName = myOMDSHelper.enumToStringError(errorRetrive);
416  m_ErrorMonitor->Fill(eName);
417  }
418  }else{
419  noError = false;
420  string eName = myOMDSHelper.enumToStringError(conError);
421  m_ErrorMonitor->Fill(eName);
422  }
423 
424  double minInstantLuminosity = m_parameters.getParameter<double>("minInstantLuminosity");
425  double maxInstantLuminosity = m_parameters.getParameter<double>("maxInstantLuminosity");
426 
427  // Getting rate fit parameters for all input triggers
428  for(map<string,string>::const_iterator a=m_selectedTriggers.begin() ; a!=m_selectedTriggers.end() ; a++){
429 
430  string tTrigger = (*a).second;
431 
432  // If trigger name is defined we get the rate fit parameters
433  if(tTrigger != "Undefined"){
434 
435  if(wbmFits.find(tTrigger) != wbmFits.end()){
436 
437  WbMTriggerXSecFit tWbMParameters = wbmFits[tTrigger];
438 
439  vector<double> tParameters;
440  tParameters.push_back(tWbMParameters.pm1);
441  tParameters.push_back(tWbMParameters.p0);
442  tParameters.push_back(tWbMParameters.p1);
443  tParameters.push_back(tWbMParameters.p2);
444 
445  // Retriving and populating the m_templateFunctions array
446  m_templateFunctions[tTrigger] = new TF1("FitParametrization_"+tWbMParameters.bitName,
447  tWbMParameters.fitFunction,
448  minInstantLuminosity,maxInstantLuminosity);
449  m_templateFunctions[tTrigger] ->SetParameters(&tParameters[0]);
450  m_templateFunctions[tTrigger] ->SetLineWidth(1);
451  m_templateFunctions[tTrigger] ->SetLineColor(kRed);
452 
453  }else{noError = false;}
454  }
455  }
456 
457  return noError;
458 
459 }
T getParameter(std::string const &) const
bool connect(std::string iOracleDB, std::string iPathCondDB, int &error)
edm::ParameterSet m_parameters
Definition: L1TRate.h:108
std::map< TString, TF1 * > m_templateFunctions
Definition: L1TRate.h:100
void Fill(long long x)
double a
Definition: hdecay.h:121
MonitorElement * m_ErrorMonitor
Definition: L1TRate.h:111
std::map< std::string, std::string > m_selectedTriggers
Definition: L1TRate.h:97
bool L1TRate::getXSexFitsPython ( const edm::ParameterSet ps)
private

Definition at line 470 of file L1TRate.cc.

References a, b, MonitorElement::Fill(), edm::ParameterSet::getParameter(), m_ErrorMonitor, m_parameters, m_selectedTriggers, and m_templateFunctions.

Referenced by bookHistograms().

470  {
471 
472  // error meaning
473  bool noError = true;
474 
475  // Getting fit parameters
476  std::vector<edm::ParameterSet> m_fitParameters = ps.getParameter< vector<ParameterSet> >("fitParameters");
477 
478  double minInstantLuminosity = m_parameters.getParameter<double>("minInstantLuminosity");
479  double maxInstantLuminosity = m_parameters.getParameter<double>("maxInstantLuminosity");
480 
481  // Getting rate fit parameters for all input triggers
482  for(map<string,string>::const_iterator a=m_selectedTriggers.begin() ; a!=m_selectedTriggers.end() ; a++){
483 
484  string tTrigger = (*a).second;
485 
486  // If trigger name is defined we get the rate fit parameters
487  if(tTrigger != "Undefined"){
488 
489  bool foundFit = false;
490 
491  for(unsigned int b=0 ; b<m_fitParameters.size() ; b++){
492 
493  if(tTrigger == m_fitParameters[b].getParameter<string>("AlgoName")){
494 
495  TString tAlgoName = m_fitParameters[b].getParameter< string > ("AlgoName");
496  TString tTemplateFunction = m_fitParameters[b].getParameter< string > ("TemplateFunction");
497  vector<double> tParameters = m_fitParameters[b].getParameter< vector<double> >("Parameters");
498 
499  // Retriving and populating the m_templateFunctions array
500  m_templateFunctions[tTrigger] = new TF1("FitParametrization_"+tAlgoName,tTemplateFunction,
501  minInstantLuminosity,maxInstantLuminosity);
502  m_templateFunctions[tTrigger] ->SetParameters(&tParameters[0]);
503  m_templateFunctions[tTrigger] ->SetLineWidth(1);
504  m_templateFunctions[tTrigger] ->SetLineColor(kRed);
505 
506  foundFit = true;
507  break;
508  }
509 
510  if(!foundFit){
511  noError = false;
512  string eName = "WARNING_PY_MISSING_FIT";
513  m_ErrorMonitor->Fill(eName);
514  }
515  }
516  }
517  }
518 
519  return noError;
520 
521 }
T getParameter(std::string const &) const
edm::ParameterSet m_parameters
Definition: L1TRate.h:108
std::map< TString, TF1 * > m_templateFunctions
Definition: L1TRate.h:100
void Fill(long long x)
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
MonitorElement * m_ErrorMonitor
Definition: L1TRate.h:111
std::map< std::string, std::string > m_selectedTriggers
Definition: L1TRate.h:97

Member Data Documentation

std::map<TString,int> L1TRate::m_algoBit
private

Definition at line 95 of file L1TRate.h.

Referenced by analyze(), bookHistograms(), and endLuminosityBlock().

MonitorElement* L1TRate::m_ErrorMonitor
private

Definition at line 111 of file L1TRate.h.

Referenced by bookHistograms(), getXSexFitsOMDS(), and getXSexFitsPython().

std::map<std::string,bool> L1TRate::m_inputCategories
private

Definition at line 96 of file L1TRate.h.

Referenced by bookHistograms(), and L1TRate().

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

Definition at line 105 of file L1TRate.h.

Referenced by analyze(), and L1TRate().

L1GtUtils L1TRate::m_l1GtUtils
private

Definition at line 116 of file L1TRate.h.

Referenced by bookHistograms().

const std::vector< std::vector<int> >* L1TRate::m_listsPrescaleFactors
private

Definition at line 89 of file L1TRate.h.

Referenced by bookHistograms().

std::map<int,double> L1TRate::m_lsLuminosity
private

Definition at line 93 of file L1TRate.h.

Referenced by analyze(), and endLuminosityBlock().

std::map<int,int> L1TRate::m_lsPrescaleIndex
private

Definition at line 92 of file L1TRate.h.

Referenced by analyze(), and endLuminosityBlock().

std::map<int,std::map<TString,double> > L1TRate::m_lsRates
private

Definition at line 94 of file L1TRate.h.

Referenced by analyze(), and endLuminosityBlock().

int L1TRate::m_lsShiftGTRates
private

Definition at line 83 of file L1TRate.h.

Referenced by analyze(), and L1TRate().

int L1TRate::m_maxNbins
private

Definition at line 82 of file L1TRate.h.

Referenced by bookHistograms(), and L1TRate().

std::string L1TRate::m_outputFile
private

Definition at line 86 of file L1TRate.h.

Referenced by L1TRate().

edm::ParameterSet L1TRate::m_parameters
private

Definition at line 108 of file L1TRate.h.

Referenced by analyze(), bookHistograms(), getXSexFitsOMDS(), getXSexFitsPython(), and L1TRate().

int L1TRate::m_refPrescaleSet
private

Definition at line 81 of file L1TRate.h.

Referenced by bookHistograms(), and L1TRate().

edm::EDGetTokenT<LumiScalersCollection> L1TRate::m_scalersSource_colLScal
private

Definition at line 103 of file L1TRate.h.

Referenced by analyze(), and L1TRate().

edm::EDGetTokenT<Level1TriggerScalersCollection> L1TRate::m_scalersSource_triggerScalers
private

Definition at line 104 of file L1TRate.h.

Referenced by analyze(), and L1TRate().

std::map<std::string,std::string> L1TRate::m_selectedTriggers
private
std::map<TString,TF1*> L1TRate::m_templateFunctions
private

Definition at line 100 of file L1TRate.h.

Referenced by bookHistograms(), getXSexFitsOMDS(), and getXSexFitsPython().

bool L1TRate::m_verbose
private

Definition at line 78 of file L1TRate.h.

Referenced by analyze(), beginLuminosityBlock(), dqmBeginRun(), endLuminosityBlock(), and L1TRate().

std::map<TString,MonitorElement*> L1TRate::m_xSecObservedToExpected
private

Definition at line 98 of file L1TRate.h.

Referenced by bookHistograms(), and endLuminosityBlock().

std::map<TString,MonitorElement*> L1TRate::m_xSecVsInstLumi
private

Definition at line 99 of file L1TRate.h.

Referenced by bookHistograms(), and endLuminosityBlock().