CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
 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
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 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
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) 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)
 
virtual void beginLuminosityBlock (edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
 
virtual void bookHistograms (DQMStore::IBooker &ibooker, const edm::Run &, const edm::EventSetup &) override
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
 
- Protected Member Functions inherited from edm::stream::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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
< L1GlobalTriggerReadoutRecord
m_l1GtDataDaqInputTag
 
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
< LumiScalersCollection
m_scalersSource_colLScal
 
edm::EDGetTokenT
< Level1TriggerScalersCollection
m_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, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDAnalyzerBase
typedef EDAnalyzerAdaptorBase ModuleType
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static std::shared_ptr
< dqmDetails::NoCache
globalBeginLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
 
static std::shared_ptr
< dqmDetails::NoCache
globalBeginRunSummary (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 47 of file L1TRate.h.

Constructor & Destructor Documentation

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

Definition at line 35 of file L1TRate.cc.

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

35  {
36 
37  m_maxNbins = 2500; // Maximum LS for each run (for binning purposes)
38  m_parameters = ps;
39 
40  // Mapping parameter input variables
41  m_scalersSource_colLScal = consumes<LumiScalersCollection> (m_parameters.getParameter<InputTag>("inputTagScalersResults"));
42  m_scalersSource_triggerScalers = consumes<Level1TriggerScalersCollection> (m_parameters.getParameter<InputTag>("inputTagScalersResults"));
43  m_l1GtDataDaqInputTag = consumes<L1GlobalTriggerReadoutRecord> (m_parameters.getParameter<InputTag>("inputTagL1GtDataDaq"));
44  m_verbose = m_parameters.getUntrackedParameter<bool> ("verbose",false);
45  m_refPrescaleSet = m_parameters.getParameter <int> ("refPrescaleSet");
46  m_lsShiftGTRates = m_parameters.getUntrackedParameter<int> ("lsShiftGTRates",0);
47 
48  // Getting which categories to monitor
49  ParameterSet Categories = ps.getParameter<ParameterSet>("categories");
50  m_inputCategories["Mu"] = Categories.getUntrackedParameter<bool>("Mu");
51  m_inputCategories["EG"] = Categories.getUntrackedParameter<bool>("EG");
52  m_inputCategories["IsoEG"] = Categories.getUntrackedParameter<bool>("IsoEG");
53  m_inputCategories["Jet"] = Categories.getUntrackedParameter<bool>("Jet");
54  m_inputCategories["CenJet"] = Categories.getUntrackedParameter<bool>("CenJet");
55  m_inputCategories["ForJet"] = Categories.getUntrackedParameter<bool>("ForJet");
56  m_inputCategories["TauJet"] = Categories.getUntrackedParameter<bool>("TauJet");
57  m_inputCategories["ETM"] = Categories.getUntrackedParameter<bool>("ETM");
58  m_inputCategories["ETT"] = Categories.getUntrackedParameter<bool>("ETT");
59  m_inputCategories["HTT"] = Categories.getUntrackedParameter<bool>("HTT");
60  m_inputCategories["HTM"] = Categories.getUntrackedParameter<bool>("HTM");
61 
62 
63  // What to do if we want our output to be saved to a external file
64  m_outputFile = ps.getUntrackedParameter < string > ("outputFile", "");
65 
66  if (m_outputFile.size() != 0) {
67  cout << "L1T Monitoring histograms will be saved to " << m_outputFile.c_str() << endl;
68  }
69 
70  bool disable = ps.getUntrackedParameter < bool > ("disableROOToutput", false);
71  if (disable) {m_outputFile = "";}
72 
73 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< LumiScalersCollection > m_scalersSource_colLScal
Definition: L1TRate.h:101
edm::EDGetTokenT< Level1TriggerScalersCollection > m_scalersSource_triggerScalers
Definition: L1TRate.h:102
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtDataDaqInputTag
Definition: L1TRate.h:103
edm::ParameterSet m_parameters
Definition: L1TRate.h:106
bool m_verbose
Definition: L1TRate.h:76
int m_lsShiftGTRates
Definition: L1TRate.h:81
int m_maxNbins
Definition: L1TRate.h:80
int m_refPrescaleSet
Definition: L1TRate.h:79
std::string m_outputFile
Definition: L1TRate.h:84
std::map< std::string, bool > m_inputCategories
Definition: L1TRate.h:94
tuple cout
Definition: gather_cfg.py:121
L1TRate::~L1TRate ( )
virtual

Definition at line 76 of file L1TRate.cc.

76 {}

Member Function Documentation

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

Implements edm::stream::EDAnalyzerBase.

Definition at line 291 of file L1TRate.cc.

References gather_cfg::cout, edm::Event::getByToken(), Level1TriggerRates::gtAlgoCountsRate(), i, edm::EventBase::id(), edm::HandleBase::isValid(), edm::EventID::luminosityBlock(), 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->size()){
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
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< LumiScalersCollection > m_scalersSource_colLScal
Definition: L1TRate.h:101
edm::EDGetTokenT< Level1TriggerScalersCollection > m_scalersSource_triggerScalers
Definition: L1TRate.h:102
std::map< int, std::map< TString, double > > m_lsRates
Definition: L1TRate.h:92
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtDataDaqInputTag
Definition: L1TRate.h:103
edm::ParameterSet m_parameters
Definition: L1TRate.h:106
bool m_verbose
Definition: L1TRate.h:76
int m_lsShiftGTRates
Definition: L1TRate.h:81
int iEvent
Definition: GenABIO.cc:230
std::map< int, double > m_lsLuminosity
Definition: L1TRate.h:91
std::map< TString, int > m_algoBit
Definition: L1TRate.h:93
bool isValid() const
Definition: HandleBase.h:75
tuple cout
Definition: gather_cfg.py:121
std::map< int, int > m_lsPrescaleIndex
Definition: L1TRate.h:90
std::map< std::string, std::string > m_selectedTriggers
Definition: L1TRate.h:95
void L1TRate::beginLuminosityBlock ( edm::LuminosityBlock const &  lumiBlock,
edm::EventSetup const &  c 
)
protectedvirtual

Reimplemented from edm::stream::EDAnalyzerBase.

Definition at line 201 of file L1TRate.cc.

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

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

Implements DQMEDAnalyzer.

Definition at line 81 of file L1TRate.cc.

References ecalcalib_dqm_sourceclient-live_cfg::algo, DQMStore::IBooker::book1D(), DQMStore::IBooker::bookProfile(), edm::EventSetup::get(), L1TMenuHelper::getEtaRangeByAlias(), L1TMenuHelper::getLUSOTrigger(), L1TMenuHelper::getPrescaleByAlias(), L1TMenuHelper::getQualityAlias(), L1GtTriggerMenu::gtAlgorithmMap(), L1GtPrescaleFactors::gtPrescaleFactors(), i, relval_steps::menu, edm::ESHandle< class >::product(), MonitorElement::setAxisTitle(), MonitorElement::setBinLabel(), and DQMStore::IBooker::setCurrentFolder().

81  {
82 
83 
86 
87  iSetup.get<L1GtTriggerMenuRcd>() .get(menuRcd);
88  iSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().get(l1GtPfAlgo);
89 
90  const L1GtTriggerMenu* menu = menuRcd .product();
91  const L1GtPrescaleFactors* m_l1GtPfAlgo = l1GtPfAlgo.product();
92 
93  // Initializing DQM Monitor Elements
94  ibooker.setCurrentFolder("L1T/L1TRate");
95  m_ErrorMonitor = ibooker.book1D("ErrorMonitor", "ErrorMonitor",5,0,5);
96  m_ErrorMonitor->setBinLabel(1,"WARNING_DB_CONN_FAILED"); // Errors from L1TOMDSHelper
97  m_ErrorMonitor->setBinLabel(2,"WARNING_DB_QUERY_FAILED"); // Errors from L1TOMDSHelper
98  m_ErrorMonitor->setBinLabel(3,"WARNING_DB_INCORRECT_NBUNCHES"); // Errors from L1TOMDSHelper
99  m_ErrorMonitor->setBinLabel(4,"WARNING_PY_MISSING_FIT");
100  m_ErrorMonitor->setBinLabel(5,"UNKNOWN");
101 
102  // Retriving the list of prescale sets
103  m_listsPrescaleFactors = &(m_l1GtPfAlgo->gtPrescaleFactors());
104 
105  // Getting Lowest Prescale Single Object Triggers from the menu
106  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
int i
Definition: DBlmapReader.cc:9
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
std::map< TString, MonitorElement * > m_xSecObservedToExpected
Definition: L1TRate.h:96
edm::ParameterSet m_parameters
Definition: L1TRate.h:106
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:98
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
bool getXSexFitsPython(const edm::ParameterSet &ps)
Definition: L1TRate.cc:470
int m_maxNbins
Definition: L1TRate.h:80
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
std::map< TString, int > m_algoBit
Definition: L1TRate.h:93
int m_refPrescaleSet
Definition: L1TRate.h:79
unsigned int getQualityAlias(const TString &iCategory, const TString &iAlias)
bool getXSexFitsOMDS(const edm::ParameterSet &ps)
Definition: L1TRate.cc:395
std::map< std::string, std::string > getLUSOTrigger(const std::map< std::string, bool > &iCategories, int IndexRefPrescaleFactors)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
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:87
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
std::map< TString, MonitorElement * > m_xSecVsInstLumi
Definition: L1TRate.h:97
std::map< std::string, bool > m_inputCategories
Definition: L1TRate.h:94
MonitorElement * m_ErrorMonitor
Definition: L1TRate.h:109
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)
std::map< std::string, std::string > m_selectedTriggers
Definition: L1TRate.h:95
void L1TRate::dqmBeginRun ( edm::Run const &  ,
edm::EventSetup const &   
)
protectedvirtual

Reimplemented from DQMEDAnalyzer.

Definition at line 196 of file L1TRate.cc.

References gather_cfg::cout.

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

Reimplemented from edm::stream::EDAnalyzerBase.

Definition at line 208 of file L1TRate.cc.

References gather_cfg::cout, getTProfile(), i, edm::LuminosityBlockBase::id(), eostools::ls(), fjr2json::lumi, edm::LuminosityBlockID::luminosityBlock(), and python.multivaluedict::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=0;
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 }
int i
Definition: DBlmapReader.cc:9
TProfile * getTProfile(std::string name, std::string process, std::string rootfolder, DQMStore *dbe_, bool verb, bool clone)
std::map< int, std::map< TString, double > > m_lsRates
Definition: L1TRate.h:92
std::map< TString, MonitorElement * > m_xSecObservedToExpected
Definition: L1TRate.h:96
tuple lumi
Definition: fjr2json.py:35
def ls
Definition: eostools.py:346
bool m_verbose
Definition: L1TRate.h:76
std::map< int, double > m_lsLuminosity
Definition: L1TRate.h:91
std::map< TString, int > m_algoBit
Definition: L1TRate.h:93
std::map< TString, MonitorElement * > m_xSecVsInstLumi
Definition: L1TRate.h:97
tuple cout
Definition: gather_cfg.py:121
std::map< int, int > m_lsPrescaleIndex
Definition: L1TRate.h:90
std::map< std::string, std::string > m_selectedTriggers
Definition: L1TRate.h:95
bool L1TRate::getXSexFitsOMDS ( const edm::ParameterSet ps)
private

Definition at line 395 of file L1TRate.cc.

References a, WbMTriggerXSecFit::bitName, L1TOMDSHelper::connect(), WbMTriggerXSecFit::fitFunction, edm::ParameterSet::getParameter(), L1TOMDSHelper::NO_ERROR, WbMTriggerXSecFit::p0, WbMTriggerXSecFit::p1, WbMTriggerXSecFit::p2, and WbMTriggerXSecFit::pm1.

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:106
std::map< TString, TF1 * > m_templateFunctions
Definition: L1TRate.h:98
void Fill(long long x)
double a
Definition: hdecay.h:121
MonitorElement * m_ErrorMonitor
Definition: L1TRate.h:109
std::map< std::string, std::string > m_selectedTriggers
Definition: L1TRate.h:95
bool L1TRate::getXSexFitsPython ( const edm::ParameterSet ps)
private

Definition at line 470 of file L1TRate.cc.

References a, b, and edm::ParameterSet::getParameter().

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:106
std::map< TString, TF1 * > m_templateFunctions
Definition: L1TRate.h:98
void Fill(long long x)
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
MonitorElement * m_ErrorMonitor
Definition: L1TRate.h:109
std::map< std::string, std::string > m_selectedTriggers
Definition: L1TRate.h:95

Member Data Documentation

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

Definition at line 93 of file L1TRate.h.

MonitorElement* L1TRate::m_ErrorMonitor
private

Definition at line 109 of file L1TRate.h.

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

Definition at line 94 of file L1TRate.h.

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

Definition at line 103 of file L1TRate.h.

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

Definition at line 87 of file L1TRate.h.

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

Definition at line 91 of file L1TRate.h.

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

Definition at line 90 of file L1TRate.h.

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

Definition at line 92 of file L1TRate.h.

int L1TRate::m_lsShiftGTRates
private

Definition at line 81 of file L1TRate.h.

int L1TRate::m_maxNbins
private

Definition at line 80 of file L1TRate.h.

std::string L1TRate::m_outputFile
private

Definition at line 84 of file L1TRate.h.

edm::ParameterSet L1TRate::m_parameters
private

Definition at line 106 of file L1TRate.h.

int L1TRate::m_refPrescaleSet
private

Definition at line 79 of file L1TRate.h.

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

Definition at line 101 of file L1TRate.h.

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

Definition at line 102 of file L1TRate.h.

std::map<std::string,std::string> L1TRate::m_selectedTriggers
private

Definition at line 95 of file L1TRate.h.

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

Definition at line 98 of file L1TRate.h.

bool L1TRate::m_verbose
private

Definition at line 76 of file L1TRate.h.

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

Definition at line 96 of file L1TRate.h.

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

Definition at line 97 of file L1TRate.h.