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:
edm::EDAnalyzer edm::EDConsumerBase

Public Member Functions

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

Protected Member Functions

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

Private Member Functions

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

Private Attributes

DQMStoredbe
 
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::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Detailed Description

Definition at line 46 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(), edm::ParameterSet::getUntrackedParameter(), NULL, and cppFunctionSkipper::operator.

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  // Inicializing Variables
63  dbe = NULL;
64 
65  if (ps.getUntrackedParameter < bool > ("dqmStore", false)) {
67  dbe->setVerbose(0);
68  }
69 
70  // What to do if we want our output to be saved to a external file
71  m_outputFile = ps.getUntrackedParameter < string > ("outputFile", "");
72 
73  if (m_outputFile.size() != 0) {
74  cout << "L1T Monitoring histograms will be saved to " << m_outputFile.c_str() << endl;
75  }
76 
77  bool disable = ps.getUntrackedParameter < bool > ("disableROOToutput", false);
78  if (disable) {m_outputFile = "";}
79 
80  if (dbe != NULL) {dbe->setCurrentFolder("L1T/L1TRate");}
81 
82 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< LumiScalersCollection > m_scalersSource_colLScal
Definition: L1TRate.h:99
edm::EDGetTokenT< Level1TriggerScalersCollection > m_scalersSource_triggerScalers
Definition: L1TRate.h:100
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtDataDaqInputTag
Definition: L1TRate.h:101
edm::ParameterSet m_parameters
Definition: L1TRate.h:104
#define NULL
Definition: scimark2.h:8
bool m_verbose
Definition: L1TRate.h:74
int m_lsShiftGTRates
Definition: L1TRate.h:79
int m_maxNbins
Definition: L1TRate.h:78
int m_refPrescaleSet
Definition: L1TRate.h:77
void setVerbose(unsigned level)
Definition: DQMStore.cc:631
std::string m_outputFile
Definition: L1TRate.h:82
DQMStore * dbe
Definition: L1TRate.h:110
std::map< std::string, bool > m_inputCategories
Definition: L1TRate.h:92
tuple cout
Definition: gather_cfg.py:121
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
L1TRate::~L1TRate ( )
virtual

Definition at line 85 of file L1TRate.cc.

85 {}

Member Function Documentation

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

Implements edm::EDAnalyzer.

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

329  {
330 
331  edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecordData;
334 
335  iEvent.getByToken(m_l1GtDataDaqInputTag, gtReadoutRecordData);
336  iEvent.getByToken(m_scalersSource_colLScal, colLScal);
337  iEvent.getByToken(m_scalersSource_triggerScalers, triggerScalers);
338 
339  // Integers
340  int EventRun = iEvent.id().run();
341  unsigned int eventLS = iEvent.id().luminosityBlock();
342 
343  // Getting the trigger trigger rates from GT and buffering it
344  if(triggerScalers.isValid()){
345 
346  Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
347  Level1TriggerRates trigRates(*itL1TScalers,EventRun);
348 
349  int gtLS = (*itL1TScalers).lumiSegmentNr()+m_lsShiftGTRates;
350 
351  // If we haven't got the data from this LS yet get it
352  if(m_lsRates.find(gtLS)==m_lsRates.end()){
353 
354  if (m_verbose) {cout << "[L1TRate:] Buffering GT Rates for LS=" << gtLS << endl;}
355  map<TString,double> bufferRate;
356 
357  // Buffer the rate informations for all selected bits
358  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
359 
360  string tTrigger = (*i).second;
361 
362  // If trigger name is defined we store the rate
363  if(tTrigger != "Undefined"){
364 
365  unsigned int trigBit = m_algoBit[tTrigger];
366  double trigRate = trigRates.gtAlgoCountsRate()[trigBit];
367 
368  bufferRate[tTrigger] = trigRate;
369  }
370  }
371  m_lsRates[gtLS] = bufferRate;
372  }
373  }
374 
375  // Getting from the SCAL the luminosity information and buffering it
376  if(colLScal.isValid() && colLScal->size()){
377 
378  LumiScalersCollection::const_iterator itLScal = colLScal->begin();
379  unsigned int scalLS = itLScal->sectionNumber();
380 
381  // If we haven't got the data from this SCAL LS yet get it
382  if(m_lsLuminosity.find(scalLS)==m_lsLuminosity.end()){
383 
384  if (m_verbose) {cout << "[L1TRate:] Buffering SCAL-HF Lumi for LS=" << scalLS << endl;}
385  double instLumi = itLScal->instantLumi(); // Getting Instant Lumi from HF (via SCAL)
386  double deadTimeNormHF = itLScal->deadTimeNormalization(); // Getting Dead Time Normalization from HF (via SCAL)
387 
388  // If HF Dead Time Corrections is requested we apply it
389  // NOTE: By default this is assumed false since for now WbM fits do NOT assume this correction
390  if(m_parameters.getUntrackedParameter<bool>("useHFDeadTimeNormalization",false)){
391 
392  // Protecting for deadtime = 0
393  if(deadTimeNormHF==0){instLumi = 0;}
394  else {instLumi = instLumi/deadTimeNormHF;}
395  }
396  // Buffering the luminosity information
397  m_lsLuminosity[scalLS]=instLumi;
398  }
399  }
400 
401  // Getting the prescale index used when this event was triggered
402  if(gtReadoutRecordData.isValid()){
403 
404  // If we haven't got the data from this LS yet get it
405  if(m_lsPrescaleIndex.find(eventLS)==m_lsPrescaleIndex.end()){
406 
407  if (m_verbose) {cout << "[L1TRate:] Buffering Prescale Index for LS=" << eventLS << endl;}
408 
409  // Getting Final Decision Logic (FDL) Data from GT
410  const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->gtFdlVector();
411 
412  // Getting the index for the fdl data for this event
413  int indexFDL=0;
414  for(unsigned int i=0; i<gtFdlVectorData.size(); i++){
415  if(gtFdlVectorData[i].bxInEvent()==0){indexFDL=i; break;}
416  }
417 
418  int CurrentPrescalesIndex = gtFdlVectorData[indexFDL].gtPrescaleFactorIndexAlgo();
419  m_lsPrescaleIndex[eventLS] = CurrentPrescalesIndex;
420  }
421  }
422 }
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< LumiScalersCollection > m_scalersSource_colLScal
Definition: L1TRate.h:99
edm::EDGetTokenT< Level1TriggerScalersCollection > m_scalersSource_triggerScalers
Definition: L1TRate.h:100
std::map< int, std::map< TString, double > > m_lsRates
Definition: L1TRate.h:90
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtDataDaqInputTag
Definition: L1TRate.h:101
edm::ParameterSet m_parameters
Definition: L1TRate.h:104
bool m_verbose
Definition: L1TRate.h:74
int m_lsShiftGTRates
Definition: L1TRate.h:79
int iEvent
Definition: GenABIO.cc:230
std::map< int, double > m_lsLuminosity
Definition: L1TRate.h:89
std::map< TString, int > m_algoBit
Definition: L1TRate.h:91
bool isValid() const
Definition: HandleBase.h:76
tuple cout
Definition: gather_cfg.py:121
std::map< int, int > m_lsPrescaleIndex
Definition: L1TRate.h:88
std::map< std::string, std::string > m_selectedTriggers
Definition: L1TRate.h:93
void L1TRate::beginJob ( void  )
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 88 of file L1TRate.cc.

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

88  {
89 
90  if (m_verbose) {cout << "[L1TRate:] Called beginJob." << endl;}
91 
92  // get hold of back-end interface
93  DQMStore *dbe = 0;
94  dbe = Service < DQMStore > ().operator->();
95 
96  if (dbe) {
97  dbe->setCurrentFolder("L1T/L1TRate");
98  dbe->rmdir("L1T/L1TRate");
99  }
100 
101 }
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:3101
bool m_verbose
Definition: L1TRate.h:74
DQMStore * dbe
Definition: L1TRate.h:110
tuple cout
Definition: gather_cfg.py:121
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
void L1TRate::beginLuminosityBlock ( edm::LuminosityBlock const &  lumiBlock,
edm::EventSetup const &  c 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 239 of file L1TRate.cc.

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

239  {
240 
241  if (m_verbose) {cout << "[L1TRate:] Called beginLuminosityBlock at LS=" << lumiBlock.id().luminosityBlock() << endl;}
242 
243 }
bool m_verbose
Definition: L1TRate.h:74
tuple cout
Definition: gather_cfg.py:121
void L1TRate::beginRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 117 of file L1TRate.cc.

References gather_cfg::cout, edm::EventSetup::get(), L1TMenuHelper::getEtaRangeByAlias(), L1TMenuHelper::getLUSOTrigger(), L1TMenuHelper::getPrescaleByAlias(), L1TMenuHelper::getQualityAlias(), L1GtTriggerMenu::gtAlgorithmMap(), L1GtPrescaleFactors::gtPrescaleFactors(), i, relval_steps::menu, and edm::ESHandle< class >::product().

117  {
118 
119  if (m_verbose) {cout << "[L1TRate:] Called beginRun." << endl;}
120 
123 
124  iSetup.get<L1GtTriggerMenuRcd>() .get(menuRcd);
125  iSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().get(l1GtPfAlgo);
126 
127  const L1GtTriggerMenu* menu = menuRcd .product();
128  const L1GtPrescaleFactors* m_l1GtPfAlgo = l1GtPfAlgo.product();
129 
130  // Initializing DQM Monitor Elements
131  dbe->setCurrentFolder("L1T/L1TRate");
132  m_ErrorMonitor = dbe->book1D("ErrorMonitor", "ErrorMonitor",5,0,5);
133  m_ErrorMonitor->setBinLabel(1,"WARNING_DB_CONN_FAILED"); // Errors from L1TOMDSHelper
134  m_ErrorMonitor->setBinLabel(2,"WARNING_DB_QUERY_FAILED"); // Errors from L1TOMDSHelper
135  m_ErrorMonitor->setBinLabel(3,"WARNING_DB_INCORRECT_NBUNCHES"); // Errors from L1TOMDSHelper
136  m_ErrorMonitor->setBinLabel(4,"WARNING_PY_MISSING_FIT");
137  m_ErrorMonitor->setBinLabel(5,"UNKNOWN");
138 
139  // Retriving the list of prescale sets
140  m_listsPrescaleFactors = &(m_l1GtPfAlgo->gtPrescaleFactors());
141 
142  // Getting Lowest Prescale Single Object Triggers from the menu
143  L1TMenuHelper myMenuHelper = L1TMenuHelper(iSetup);
145 
146  //-> Getting template fits for the algLo cross sections
147  int srcAlgoXSecFit = m_parameters.getParameter<int>("srcAlgoXSecFit");
148  if (srcAlgoXSecFit == 0){getXSexFitsOMDS (m_parameters);}
149  else if(srcAlgoXSecFit == 1){getXSexFitsPython(m_parameters);}
150 
151  for (CItAlgo algo = menu->gtAlgorithmMap().begin(); algo!=menu->gtAlgorithmMap().end(); ++algo){
152  m_algoBit[(algo->second).algoAlias()] = (algo->second).algoBitNumber();
153  }
154 
155  double minInstantLuminosity = m_parameters.getParameter<double>("minInstantLuminosity");
156  double maxInstantLuminosity = m_parameters.getParameter<double>("maxInstantLuminosity");
157 
158  // Initializing DQM Monitor Elements
159  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
160 
161  TString tCategory = (*i).first;
162  TString tTrigger = (*i).second;
163 
164  TString tErrorMessage = "";
165  TF1* tTestFunction;
166 
167  if(tTrigger != "Undefined" && m_templateFunctions.find(tTrigger) != m_templateFunctions.end()){
168  tTestFunction = m_templateFunctions[tTrigger];
169  }
170  else if(tTrigger == "Undefined"){
171  TString tFunc = "-1";
172  tTestFunction = new TF1("FitParametrization_"+tTrigger,tFunc,0,double(m_maxNbins)-0.5);
173  }
174  else if(m_templateFunctions.find(tTrigger) == m_templateFunctions.end()){
175  TString tFunc = "-1";
176  tTestFunction = new TF1("FitParametrization_"+tTrigger,tFunc,0,double(m_maxNbins)-0.5);
177  tErrorMessage = " (Undefined Test Function)";
178  }
179  else{
180  TString tFunc = "-1";
181  tTestFunction = new TF1("FitParametrization_"+tTrigger,tFunc,0,double(m_maxNbins)-0.5);
182  }
183 
184  if(tTrigger != "Undefined"){
185 
186  if(myMenuHelper.getPrescaleByAlias(tCategory,tTrigger) != 1){
187  tErrorMessage += " WARNING: Default Prescale = ";
188  tErrorMessage += myMenuHelper.getPrescaleByAlias(tCategory,tTrigger);
189  }
190 
191  if (tCategory == "Mu" && myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger) != 4294967295){
192  tErrorMessage += " WARNING: Eta Range = ";
193  tErrorMessage += myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger);
194  }
195  else if(tCategory == "EG" && myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger) != 32639){
196  tErrorMessage += " WARNING: Eta Range = ";
197  tErrorMessage += myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger);
198  }
199  else if(tCategory == "IsoEG" && myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger) != 32639){
200  tErrorMessage += " WARNING: Eta Range = ";
201  tErrorMessage += myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger);
202  }
203 
204  if(tCategory == "Mu" && myMenuHelper.getQualityAlias(tCategory,tTrigger) != 240){
205  tErrorMessage += " WARNING: Quality = ";
206  tErrorMessage += myMenuHelper.getQualityAlias(tCategory,tTrigger);
207  }
208 
209  }
210 
211 
212 
213  dbe->setCurrentFolder("L1T/L1TRate/TriggerCrossSections");
214  m_xSecVsInstLumi[tTrigger] = dbe->bookProfile(tCategory,
215  "Cross Sec. vs Inst. Lumi Algo: "+tTrigger+tErrorMessage,
216  m_maxNbins,
217  minInstantLuminosity,
218  maxInstantLuminosity,0,500);
219  m_xSecVsInstLumi[tTrigger] ->setAxisTitle("Instantaneous Luminosity [10^{30}cm^{-2}s^{-1}]" ,1);
220  m_xSecVsInstLumi[tTrigger] ->setAxisTitle("Algorithm #sigma [#mu b]" ,2);
221  m_xSecVsInstLumi[tTrigger] ->getTProfile()->GetListOfFunctions()->Add(tTestFunction);
222  m_xSecVsInstLumi[tTrigger] ->getTProfile()->SetMarkerStyle(23);
223 
224  dbe->setCurrentFolder("L1T/L1TRate/Certification");
225  m_xSecObservedToExpected[tTrigger] = dbe->book1D(tCategory, "Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,double(m_maxNbins)-0.5);
226  m_xSecObservedToExpected[tTrigger] ->setAxisTitle("Lumi Section" ,1);
227  m_xSecObservedToExpected[tTrigger] ->setAxisTitle("#sigma_{obs} / #sigma_{exp}" ,2);
228 
229  }
230 
231 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:954
std::map< TString, MonitorElement * > m_xSecObservedToExpected
Definition: L1TRate.h:94
edm::ParameterSet m_parameters
Definition: L1TRate.h:104
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:96
bool m_verbose
Definition: L1TRate.h:74
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
std::map< std::string, std::string > getLUSOTrigger(const std::map< std::string, bool > &iCategories, int IndexRefPrescaleFactors)
bool getXSexFitsPython(const edm::ParameterSet &ps)
Definition: L1TRate.cc:508
int m_maxNbins
Definition: L1TRate.h:78
std::map< TString, int > m_algoBit
Definition: L1TRate.h:91
int m_refPrescaleSet
Definition: L1TRate.h:77
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
Definition: DQMStore.cc:1268
unsigned int getQualityAlias(const TString &iCategory, const TString &iAlias)
bool getXSexFitsOMDS(const edm::ParameterSet &ps)
Definition: L1TRate.cc:433
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:85
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
DQMStore * dbe
Definition: L1TRate.h:110
std::map< TString, MonitorElement * > m_xSecVsInstLumi
Definition: L1TRate.h:95
std::map< std::string, bool > m_inputCategories
Definition: L1TRate.h:92
MonitorElement * m_ErrorMonitor
Definition: L1TRate.h:107
const AlgorithmMap & gtAlgorithmMap() const
get / set the algorithm map (by name)
tuple cout
Definition: gather_cfg.py:121
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:93
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
void L1TRate::endJob ( void  )
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 104 of file L1TRate.cc.

References gather_cfg::cout.

104  {
105 
106  if (m_verbose) {cout << "[L1TRate:] Called endJob." << endl;}
107 
108  if (m_outputFile.size() != 0 && dbe)
110 
111  return;
112 }
bool m_verbose
Definition: L1TRate.h:74
std::string m_outputFile
Definition: L1TRate.h:82
DQMStore * dbe
Definition: L1TRate.h:110
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, const uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE", const bool resetMEsAfterWriting=false)
Definition: DQMStore.cc:2540
tuple cout
Definition: gather_cfg.py:121
void L1TRate::endLuminosityBlock ( edm::LuminosityBlock const &  lumiBlock,
edm::EventSetup const &  c 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 246 of file L1TRate.cc.

References gather_cfg::cout, getTProfile(), i, edm::LuminosityBlockBase::id(), python.rootplot.utilities::ls(), fjr2json::lumi, edm::LuminosityBlockID::luminosityBlock(), and python.multivaluedict::map().

246  {
247 
248  int eventLS = lumiBlock.id().luminosityBlock();
249  if (m_verbose) {cout << "[L1TRate:] Called endLuminosityBlock at LS=" << eventLS << endl;}
250 
251  // We can certify LS -1 since we should have available:
252  // gt rates: (current LS)-1
253  // prescale: current LS
254  // lumi : current LS
255  //eventLS--;
256 
257  // Checking if all necessary quantities are defined for our calculations
258  bool isDefRate,isDefLumi,isDefPrescaleIndex;
259  map<TString,double>* rates=0;
260  double lumi=0;
261  int prescalesIndex=0;
262 
263  // Reseting MonitorElements so we can refill them
264  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
265  string tTrigger = (*i).second;
266  m_xSecObservedToExpected[tTrigger]->getTH1()->Reset("ICE");
267  m_xSecVsInstLumi [tTrigger]->getTH1()->Reset("ICE");
268  }
269 
270  for(map<int,map<TString,double> >::iterator i=m_lsRates.begin() ; i!=m_lsRates.end() ; i++){
271 
272  unsigned int ls = (*i).first;
273  rates = &(*i).second;
274  isDefRate=true;
275 
276  if(m_lsLuminosity.find(ls)==m_lsLuminosity.end()){isDefLumi=false;}
277  else{
278  isDefLumi=true;
279  lumi=m_lsLuminosity[ls];
280  }
281 
282  if(m_lsPrescaleIndex.find(ls)==m_lsPrescaleIndex.end()){isDefPrescaleIndex=false;}
283  else{
284  isDefPrescaleIndex=true;
285  prescalesIndex=m_lsPrescaleIndex[ls];
286  }
287 
288  if(isDefRate && isDefLumi && isDefPrescaleIndex){
289 
290  const vector<int>& currentPrescaleFactors = (*m_listsPrescaleFactors).at(prescalesIndex);
291 
292  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
293 
294  string tTrigger = (*i).second;
295  TF1* tTestFunction = (TF1*) m_xSecVsInstLumi[tTrigger]->getTProfile()->GetListOfFunctions()->First();
296 
297  // If trigger name is defined we get the rate fit parameters
298  if(tTrigger != "Undefined"){
299 
300  unsigned int trigBit = m_algoBit[tTrigger];
301  double trigPrescale = currentPrescaleFactors[trigBit];
302  double trigRate = (*rates)[tTrigger];
303 
304  if(lumi!=0 && trigPrescale!=0 && trigRate!=0){
305 
306  double AlgoXSec = (trigPrescale*trigRate)/lumi;
307  double TemplateFunctionValue = tTestFunction->Eval(lumi);
308 
309  // Checking against Template function
310  int ibin = m_xSecObservedToExpected[tTrigger]->getTH1()->FindBin(ls);
311  m_xSecObservedToExpected[tTrigger]->setBinContent(ibin,AlgoXSec/TemplateFunctionValue);
312  m_xSecVsInstLumi [tTrigger]->Fill(lumi,AlgoXSec);
313 
314  if(m_verbose){cout<<"[L1TRate:] ls="<<ls<<" Algo="<<tTrigger<<" XSec="<<AlgoXSec<<" Test="<<AlgoXSec/TemplateFunctionValue<<endl;}
315 
316  }
317  else{
318  int ibin = m_xSecObservedToExpected[tTrigger]->getTH1()->FindBin(ls);
319  m_xSecObservedToExpected[tTrigger]->setBinContent(ibin,0.000001);
320  if(m_verbose){cout << "[L1TRate:] Algo="<< tTrigger<< " XSec=Failed" << endl;}
321  }
322  }
323  }
324  }
325  }
326 }
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:90
std::map< TString, MonitorElement * > m_xSecObservedToExpected
Definition: L1TRate.h:94
tuple lumi
Definition: fjr2json.py:35
bool m_verbose
Definition: L1TRate.h:74
std::map< int, double > m_lsLuminosity
Definition: L1TRate.h:89
std::map< TString, int > m_algoBit
Definition: L1TRate.h:91
std::map< TString, MonitorElement * > m_xSecVsInstLumi
Definition: L1TRate.h:95
tuple cout
Definition: gather_cfg.py:121
std::map< int, int > m_lsPrescaleIndex
Definition: L1TRate.h:88
std::map< std::string, std::string > m_selectedTriggers
Definition: L1TRate.h:93
void L1TRate::endRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 234 of file L1TRate.cc.

References gather_cfg::cout.

234  {
235  if (m_verbose) {cout << "[L1TRate:] Called endRun." << endl;}
236 }
bool m_verbose
Definition: L1TRate.h:74
tuple cout
Definition: gather_cfg.py:121
bool L1TRate::getXSexFitsOMDS ( const edm::ParameterSet ps)
private

Definition at line 433 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.

433  {
434 
435  bool noError = true;
436 
437  string oracleDB = ps.getParameter<string>("oracleDB");
438  string pathCondDB = ps.getParameter<string>("pathCondDB");
439 
440  L1TOMDSHelper myOMDSHelper;
441  int conError;
442  myOMDSHelper.connect(oracleDB,pathCondDB,conError);
443 
444  map<string,WbMTriggerXSecFit> wbmFits;
445 
446  if(conError == L1TOMDSHelper::NO_ERROR){
447  int errorRetrive;
448  wbmFits = myOMDSHelper.getWbMAlgoXsecFits(errorRetrive);
449 
450  // Filling errors if they exist
451  if(errorRetrive != L1TOMDSHelper::NO_ERROR){
452  noError = false;
453  string eName = myOMDSHelper.enumToStringError(errorRetrive);
454  m_ErrorMonitor->Fill(eName);
455  }
456  }else{
457  noError = false;
458  string eName = myOMDSHelper.enumToStringError(conError);
459  m_ErrorMonitor->Fill(eName);
460  }
461 
462  double minInstantLuminosity = m_parameters.getParameter<double>("minInstantLuminosity");
463  double maxInstantLuminosity = m_parameters.getParameter<double>("maxInstantLuminosity");
464 
465  // Getting rate fit parameters for all input triggers
466  for(map<string,string>::const_iterator a=m_selectedTriggers.begin() ; a!=m_selectedTriggers.end() ; a++){
467 
468  string tTrigger = (*a).second;
469 
470  // If trigger name is defined we get the rate fit parameters
471  if(tTrigger != "Undefined"){
472 
473  if(wbmFits.find(tTrigger) != wbmFits.end()){
474 
475  WbMTriggerXSecFit tWbMParameters = wbmFits[tTrigger];
476 
477  vector<double> tParameters;
478  tParameters.push_back(tWbMParameters.pm1);
479  tParameters.push_back(tWbMParameters.p0);
480  tParameters.push_back(tWbMParameters.p1);
481  tParameters.push_back(tWbMParameters.p2);
482 
483  // Retriving and populating the m_templateFunctions array
484  m_templateFunctions[tTrigger] = new TF1("FitParametrization_"+tWbMParameters.bitName,
485  tWbMParameters.fitFunction,
486  minInstantLuminosity,maxInstantLuminosity);
487  m_templateFunctions[tTrigger] ->SetParameters(&tParameters[0]);
488  m_templateFunctions[tTrigger] ->SetLineWidth(1);
489  m_templateFunctions[tTrigger] ->SetLineColor(kRed);
490 
491  }else{noError = false;}
492  }
493  }
494 
495  return noError;
496 
497 }
T getParameter(std::string const &) const
bool connect(std::string iOracleDB, std::string iPathCondDB, int &error)
edm::ParameterSet m_parameters
Definition: L1TRate.h:104
std::map< TString, TF1 * > m_templateFunctions
Definition: L1TRate.h:96
void Fill(long long x)
double a
Definition: hdecay.h:121
MonitorElement * m_ErrorMonitor
Definition: L1TRate.h:107
std::map< std::string, std::string > m_selectedTriggers
Definition: L1TRate.h:93
bool L1TRate::getXSexFitsPython ( const edm::ParameterSet ps)
private

Definition at line 508 of file L1TRate.cc.

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

508  {
509 
510  // error meaning
511  bool noError = true;
512 
513  // Getting fit parameters
514  std::vector<edm::ParameterSet> m_fitParameters = ps.getParameter< vector<ParameterSet> >("fitParameters");
515 
516  double minInstantLuminosity = m_parameters.getParameter<double>("minInstantLuminosity");
517  double maxInstantLuminosity = m_parameters.getParameter<double>("maxInstantLuminosity");
518 
519  // Getting rate fit parameters for all input triggers
520  for(map<string,string>::const_iterator a=m_selectedTriggers.begin() ; a!=m_selectedTriggers.end() ; a++){
521 
522  string tTrigger = (*a).second;
523 
524  // If trigger name is defined we get the rate fit parameters
525  if(tTrigger != "Undefined"){
526 
527  bool foundFit = false;
528 
529  for(unsigned int b=0 ; b<m_fitParameters.size() ; b++){
530 
531  if(tTrigger == m_fitParameters[b].getParameter<string>("AlgoName")){
532 
533  TString tAlgoName = m_fitParameters[b].getParameter< string > ("AlgoName");
534  TString tTemplateFunction = m_fitParameters[b].getParameter< string > ("TemplateFunction");
535  vector<double> tParameters = m_fitParameters[b].getParameter< vector<double> >("Parameters");
536 
537  // Retriving and populating the m_templateFunctions array
538  m_templateFunctions[tTrigger] = new TF1("FitParametrization_"+tAlgoName,tTemplateFunction,
539  minInstantLuminosity,maxInstantLuminosity);
540  m_templateFunctions[tTrigger] ->SetParameters(&tParameters[0]);
541  m_templateFunctions[tTrigger] ->SetLineWidth(1);
542  m_templateFunctions[tTrigger] ->SetLineColor(kRed);
543 
544  foundFit = true;
545  break;
546  }
547 
548  if(!foundFit){
549  noError = false;
550  string eName = "WARNING_PY_MISSING_FIT";
551  m_ErrorMonitor->Fill(eName);
552  }
553  }
554  }
555  }
556 
557  return noError;
558 
559 }
T getParameter(std::string const &) const
edm::ParameterSet m_parameters
Definition: L1TRate.h:104
std::map< TString, TF1 * > m_templateFunctions
Definition: L1TRate.h:96
void Fill(long long x)
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121
MonitorElement * m_ErrorMonitor
Definition: L1TRate.h:107
std::map< std::string, std::string > m_selectedTriggers
Definition: L1TRate.h:93

Member Data Documentation

DQMStore* L1TRate::dbe
private

Definition at line 110 of file L1TRate.h.

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

Definition at line 91 of file L1TRate.h.

MonitorElement* L1TRate::m_ErrorMonitor
private

Definition at line 107 of file L1TRate.h.

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

Definition at line 92 of file L1TRate.h.

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

Definition at line 101 of file L1TRate.h.

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

Definition at line 85 of file L1TRate.h.

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

Definition at line 89 of file L1TRate.h.

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

Definition at line 88 of file L1TRate.h.

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

Definition at line 90 of file L1TRate.h.

int L1TRate::m_lsShiftGTRates
private

Definition at line 79 of file L1TRate.h.

int L1TRate::m_maxNbins
private

Definition at line 78 of file L1TRate.h.

std::string L1TRate::m_outputFile
private

Definition at line 82 of file L1TRate.h.

edm::ParameterSet L1TRate::m_parameters
private

Definition at line 104 of file L1TRate.h.

int L1TRate::m_refPrescaleSet
private

Definition at line 77 of file L1TRate.h.

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

Definition at line 99 of file L1TRate.h.

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

Definition at line 100 of file L1TRate.h.

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

Definition at line 93 of file L1TRate.h.

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

Definition at line 96 of file L1TRate.h.

bool L1TRate::m_verbose
private

Definition at line 74 of file L1TRate.h.

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

Definition at line 94 of file L1TRate.h.

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

Definition at line 95 of file L1TRate.h.