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

Public Member Functions

 L1TRate (const edm::ParameterSet &ps)
 
virtual ~L1TRate ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 

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::EDAnalyzer
CurrentProcessingContext const * currentContext () const
 

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::InputTag 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::InputTag m_scalersSource
 
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
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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 42 of file L1TRate.h.

Constructor & Destructor Documentation

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

Definition at line 41 of file L1TRate.cc.

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

41  {
42 
43  m_maxNbins = 2500; // Maximum LS for each run (for binning purposes)
44  m_parameters = ps;
45 
46  // Mapping parameter input variables
47  m_scalersSource = m_parameters.getParameter <InputTag>("inputTagScalersResults");
48  m_l1GtDataDaqInputTag = m_parameters.getParameter <InputTag>("inputTagL1GtDataDaq");
49  m_verbose = m_parameters.getUntrackedParameter<bool> ("verbose",false);
50  m_refPrescaleSet = m_parameters.getParameter <int> ("refPrescaleSet");
51  m_lsShiftGTRates = m_parameters.getUntrackedParameter<int> ("lsShiftGTRates",0);
52 
53  // Getting which categories to monitor
54  ParameterSet Categories = ps.getParameter<ParameterSet>("categories");
55  m_inputCategories["Mu"] = Categories.getUntrackedParameter<bool>("Mu");
56  m_inputCategories["EG"] = Categories.getUntrackedParameter<bool>("EG");
57  m_inputCategories["IsoEG"] = Categories.getUntrackedParameter<bool>("IsoEG");
58  m_inputCategories["Jet"] = Categories.getUntrackedParameter<bool>("Jet");
59  m_inputCategories["CenJet"] = Categories.getUntrackedParameter<bool>("CenJet");
60  m_inputCategories["ForJet"] = Categories.getUntrackedParameter<bool>("ForJet");
61  m_inputCategories["TauJet"] = Categories.getUntrackedParameter<bool>("TauJet");
62  m_inputCategories["ETM"] = Categories.getUntrackedParameter<bool>("ETM");
63  m_inputCategories["ETT"] = Categories.getUntrackedParameter<bool>("ETT");
64  m_inputCategories["HTT"] = Categories.getUntrackedParameter<bool>("HTT");
65  m_inputCategories["HTM"] = Categories.getUntrackedParameter<bool>("HTM");
66 
67  // Inicializing Variables
68  dbe = NULL;
69 
70  if (ps.getUntrackedParameter < bool > ("dqmStore", false)) {
71  dbe = Service < DQMStore > ().operator->();
72  dbe->setVerbose(0);
73  }
74 
75  // What to do if we want our output to be saved to a external file
76  m_outputFile = ps.getUntrackedParameter < string > ("outputFile", "");
77 
78  if (m_outputFile.size() != 0) {
79  cout << "L1T Monitoring histograms will be saved to " << m_outputFile.c_str() << endl;
80  }
81 
82  bool disable = ps.getUntrackedParameter < bool > ("disableROOToutput", false);
83  if (disable) {m_outputFile = "";}
84 
85  if (dbe != NULL) {dbe->setCurrentFolder("L1T/L1TRate");}
86 
87 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag m_scalersSource
Definition: L1TRate.h:95
edm::ParameterSet m_parameters
Definition: L1TRate.h:99
#define NULL
Definition: scimark2.h:8
bool m_verbose
Definition: L1TRate.h:70
int m_lsShiftGTRates
Definition: L1TRate.h:75
edm::InputTag m_l1GtDataDaqInputTag
Definition: L1TRate.h:96
int m_maxNbins
Definition: L1TRate.h:74
int m_refPrescaleSet
Definition: L1TRate.h:73
std::string m_outputFile
Definition: L1TRate.h:78
DQMStore * dbe
Definition: L1TRate.h:105
std::map< std::string, bool > m_inputCategories
Definition: L1TRate.h:88
tuple cout
Definition: gather_cfg.py:121
L1TRate::~L1TRate ( )
virtual

Definition at line 90 of file L1TRate.cc.

90 {}

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 334 of file L1TRate.cc.

References gather_cfg::cout, edm::Event::getByLabel(), Level1TriggerRates::gtAlgoCountsRate(), i, edm::EventBase::id(), edm::HandleBase::isValid(), edm::EventID::luminosityBlock(), and edm::EventID::run().

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

Reimplemented from edm::EDAnalyzer.

Definition at line 93 of file L1TRate.cc.

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

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

Reimplemented from edm::EDAnalyzer.

Definition at line 244 of file L1TRate.cc.

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

244  {
245 
246  if (m_verbose) {cout << "[L1TRate:] Called beginLuminosityBlock at LS=" << lumiBlock.id().luminosityBlock() << endl;}
247 
248 }
bool m_verbose
Definition: L1TRate.h:70
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 122 of file L1TRate.cc.

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

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

Reimplemented from edm::EDAnalyzer.

Definition at line 109 of file L1TRate.cc.

References gather_cfg::cout.

109  {
110 
111  if (m_verbose) {cout << "[L1TRate:] Called endJob." << endl;}
112 
113  if (m_outputFile.size() != 0 && dbe)
115 
116  return;
117 }
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2113
bool m_verbose
Definition: L1TRate.h:70
std::string m_outputFile
Definition: L1TRate.h:78
DQMStore * dbe
Definition: L1TRate.h:105
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 251 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().

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

Reimplemented from edm::EDAnalyzer.

Definition at line 239 of file L1TRate.cc.

References gather_cfg::cout.

239  {
240  if (m_verbose) {cout << "[L1TRate:] Called endRun." << endl;}
241 }
bool m_verbose
Definition: L1TRate.h:70
tuple cout
Definition: gather_cfg.py:121
bool L1TRate::getXSexFitsOMDS ( const edm::ParameterSet ps)
private

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

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

Definition at line 513 of file L1TRate.cc.

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

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

Member Data Documentation

DQMStore* L1TRate::dbe
private

Definition at line 105 of file L1TRate.h.

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

Definition at line 87 of file L1TRate.h.

MonitorElement* L1TRate::m_ErrorMonitor
private

Definition at line 102 of file L1TRate.h.

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

Definition at line 88 of file L1TRate.h.

edm::InputTag L1TRate::m_l1GtDataDaqInputTag
private

Definition at line 96 of file L1TRate.h.

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

Definition at line 81 of file L1TRate.h.

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

Definition at line 85 of file L1TRate.h.

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

Definition at line 84 of file L1TRate.h.

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

Definition at line 86 of file L1TRate.h.

int L1TRate::m_lsShiftGTRates
private

Definition at line 75 of file L1TRate.h.

int L1TRate::m_maxNbins
private

Definition at line 74 of file L1TRate.h.

std::string L1TRate::m_outputFile
private

Definition at line 78 of file L1TRate.h.

edm::ParameterSet L1TRate::m_parameters
private

Definition at line 99 of file L1TRate.h.

int L1TRate::m_refPrescaleSet
private

Definition at line 73 of file L1TRate.h.

edm::InputTag L1TRate::m_scalersSource
private

Definition at line 95 of file L1TRate.h.

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

Definition at line 89 of file L1TRate.h.

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

Definition at line 92 of file L1TRate.h.

bool L1TRate::m_verbose
private

Definition at line 70 of file L1TRate.h.

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

Definition at line 90 of file L1TRate.h.

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

Definition at line 91 of file L1TRate.h.