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)
 
virtual ~L1TRate ()
 
- 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
 
 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
 
virtual void beginLuminosityBlock (edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
 
virtual void bookHistograms (DQMStore::IBooker &ibooker, const edm::Run &, const edm::EventSetup &) override
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &) override
 
virtual 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 35 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.

35  :
36  m_l1GtUtils(ps, consumesCollector(), false, *this) {
37 
38  m_maxNbins = 2500; // Maximum LS for each run (for binning purposes)
39  m_parameters = ps;
40 
41  // Mapping parameter input variables
42  m_scalersSource_colLScal = consumes<LumiScalersCollection> (m_parameters.getParameter<InputTag>("inputTagScalersResults"));
43  m_scalersSource_triggerScalers = consumes<Level1TriggerScalersCollection> (m_parameters.getParameter<InputTag>("inputTagScalersResults"));
44  m_l1GtDataDaqInputTag = consumes<L1GlobalTriggerReadoutRecord> (m_parameters.getParameter<InputTag>("inputTagL1GtDataDaq"));
45  m_verbose = m_parameters.getUntrackedParameter<bool> ("verbose",false);
46  m_refPrescaleSet = m_parameters.getParameter <int> ("refPrescaleSet");
47  m_lsShiftGTRates = m_parameters.getUntrackedParameter<int> ("lsShiftGTRates",0);
48 
49  // Getting which categories to monitor
50  ParameterSet Categories = ps.getParameter<ParameterSet>("categories");
51  m_inputCategories["Mu"] = Categories.getUntrackedParameter<bool>("Mu");
52  m_inputCategories["EG"] = Categories.getUntrackedParameter<bool>("EG");
53  m_inputCategories["IsoEG"] = Categories.getUntrackedParameter<bool>("IsoEG");
54  m_inputCategories["Jet"] = Categories.getUntrackedParameter<bool>("Jet");
55  m_inputCategories["CenJet"] = Categories.getUntrackedParameter<bool>("CenJet");
56  m_inputCategories["ForJet"] = Categories.getUntrackedParameter<bool>("ForJet");
57  m_inputCategories["TauJet"] = Categories.getUntrackedParameter<bool>("TauJet");
58  m_inputCategories["ETM"] = Categories.getUntrackedParameter<bool>("ETM");
59  m_inputCategories["ETT"] = Categories.getUntrackedParameter<bool>("ETT");
60  m_inputCategories["HTT"] = Categories.getUntrackedParameter<bool>("HTT");
61  m_inputCategories["HTM"] = Categories.getUntrackedParameter<bool>("HTM");
62 
63 
64  // What to do if we want our output to be saved to a external file
65  m_outputFile = ps.getUntrackedParameter < string > ("outputFile", "");
66 
67  if (m_outputFile.size() != 0) {
68  cout << "L1T Monitoring histograms will be saved to " << m_outputFile.c_str() << endl;
69  }
70 
71  bool disable = ps.getUntrackedParameter < bool > ("disableROOToutput", false);
72  if (disable) {m_outputFile = "";}
73 
74 }
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 ( )
virtual

Definition at line 77 of file L1TRate.cc.

77 {}

Member Function Documentation

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

Definition at line 293 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().

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

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

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

Definition at line 82 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().

82  {
83 
84 
87 
88  iSetup.get<L1GtTriggerMenuRcd>() .get(menuRcd);
89  iSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().get(l1GtPfAlgo);
90 
91  const L1GtTriggerMenu* menu = menuRcd .product();
92  const L1GtPrescaleFactors* m_l1GtPfAlgo = l1GtPfAlgo.product();
93 
94  // Initializing DQM Monitor Elements
95  ibooker.setCurrentFolder("L1T/L1TRate");
96  m_ErrorMonitor = ibooker.book1D("ErrorMonitor", "ErrorMonitor",5,0,5);
97  m_ErrorMonitor->setBinLabel(1,"WARNING_DB_CONN_FAILED"); // Errors from L1TOMDSHelper
98  m_ErrorMonitor->setBinLabel(2,"WARNING_DB_QUERY_FAILED"); // Errors from L1TOMDSHelper
99  m_ErrorMonitor->setBinLabel(3,"WARNING_DB_INCORRECT_NBUNCHES"); // Errors from L1TOMDSHelper
100  m_ErrorMonitor->setBinLabel(4,"WARNING_PY_MISSING_FIT");
101  m_ErrorMonitor->setBinLabel(5,"UNKNOWN");
102 
103  // Retriving the list of prescale sets
104  m_listsPrescaleFactors = &(m_l1GtPfAlgo->gtPrescaleFactors());
105 
106  // Getting Lowest Prescale Single Object Triggers from the menu
107  L1TMenuHelper myMenuHelper = L1TMenuHelper(iSetup);
110 
111  //-> Getting template fits for the algLo cross sections
112  int srcAlgoXSecFit = m_parameters.getParameter<int>("srcAlgoXSecFit");
113  if (srcAlgoXSecFit == 0){getXSexFitsOMDS (m_parameters);}
114  else if(srcAlgoXSecFit == 1){getXSexFitsPython(m_parameters);}
115 
116  for (CItAlgo algo = menu->gtAlgorithmMap().begin(); algo!=menu->gtAlgorithmMap().end(); ++algo){
117  m_algoBit[(algo->second).algoAlias()] = (algo->second).algoBitNumber();
118  }
119 
120  double minInstantLuminosity = m_parameters.getParameter<double>("minInstantLuminosity");
121  double maxInstantLuminosity = m_parameters.getParameter<double>("maxInstantLuminosity");
122 
123  // Initializing DQM Monitor Elements
124  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
125 
126  TString tCategory = (*i).first;
127  TString tTrigger = (*i).second;
128 
129  TString tErrorMessage = "";
130  TF1* tTestFunction;
131 
132  if(tTrigger != "Undefined" && m_templateFunctions.find(tTrigger) != m_templateFunctions.end()){
133  tTestFunction = m_templateFunctions[tTrigger];
134  }
135  else if(tTrigger == "Undefined"){
136  TString tFunc = "-1";
137  tTestFunction = new TF1("FitParametrization_"+tTrigger,tFunc,0,double(m_maxNbins)-0.5);
138  }
139  else if(m_templateFunctions.find(tTrigger) == m_templateFunctions.end()){
140  TString tFunc = "-1";
141  tTestFunction = new TF1("FitParametrization_"+tTrigger,tFunc,0,double(m_maxNbins)-0.5);
142  tErrorMessage = " (Undefined Test Function)";
143  }
144  else{
145  TString tFunc = "-1";
146  tTestFunction = new TF1("FitParametrization_"+tTrigger,tFunc,0,double(m_maxNbins)-0.5);
147  }
148 
149  if(tTrigger != "Undefined"){
150 
151  if(myMenuHelper.getPrescaleByAlias(tCategory,tTrigger) != 1){
152  tErrorMessage += " WARNING: Default Prescale = ";
153  tErrorMessage += myMenuHelper.getPrescaleByAlias(tCategory,tTrigger);
154  }
155 
156  if (tCategory == "Mu" && myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger) != 4294967295){
157  tErrorMessage += " WARNING: Eta Range = ";
158  tErrorMessage += myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger);
159  }
160  else if(tCategory == "EG" && myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger) != 32639){
161  tErrorMessage += " WARNING: Eta Range = ";
162  tErrorMessage += myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger);
163  }
164  else if(tCategory == "IsoEG" && myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger) != 32639){
165  tErrorMessage += " WARNING: Eta Range = ";
166  tErrorMessage += myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger);
167  }
168 
169  if(tCategory == "Mu" && myMenuHelper.getQualityAlias(tCategory,tTrigger) != 240){
170  tErrorMessage += " WARNING: Quality = ";
171  tErrorMessage += myMenuHelper.getQualityAlias(tCategory,tTrigger);
172  }
173 
174  }
175 
176 
177 
178  ibooker.setCurrentFolder("L1T/L1TRate/TriggerCrossSections");
179  m_xSecVsInstLumi[tTrigger] = ibooker.bookProfile(tCategory,
180  "Cross Sec. vs Inst. Lumi Algo: "+tTrigger+tErrorMessage,
181  m_maxNbins,
182  minInstantLuminosity,
183  maxInstantLuminosity,0,500);
184  m_xSecVsInstLumi[tTrigger] ->setAxisTitle("Instantaneous Luminosity [10^{30}cm^{-2}s^{-1}]" ,1);
185  m_xSecVsInstLumi[tTrigger] ->setAxisTitle("Algorithm #sigma [#mu b]" ,2);
186  m_xSecVsInstLumi[tTrigger] ->getTProfile()->GetListOfFunctions()->Add(tTestFunction);
187  m_xSecVsInstLumi[tTrigger] ->getTProfile()->SetMarkerStyle(23);
188 
189  ibooker.setCurrentFolder("L1T/L1TRate/Certification");
190  m_xSecObservedToExpected[tTrigger] = ibooker.book1D(tCategory, "Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,double(m_maxNbins)-0.5);
191  m_xSecObservedToExpected[tTrigger] ->setAxisTitle("Lumi Section" ,1);
192  m_xSecObservedToExpected[tTrigger] ->setAxisTitle("#sigma_{obs} / #sigma_{exp}" ,2);
193 
194  }
195 
196 }
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:472
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:397
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:56
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 198 of file L1TRate.cc.

References gather_cfg::cout, and m_verbose.

198  {
199  //
200  if (m_verbose) {cout << "[L1TRate:] Called beginRun." << endl;}
201 }
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 210 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.

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

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

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

Referenced by bookHistograms().

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