CMS 3D CMS Logo

L1TRate_Offline.cc
Go to the documentation of this file.
1 // L1TMonitor includes
4 
12 
13 #include "TList.h"
14 
15 using namespace edm;
16 using namespace std;
17 
18 //_____________________________________________________________________
20  m_l1GtUtils(ps, consumesCollector(), false, *this) {
21 
22  m_maxNbins = 2500; // Maximum LS for each run (for binning purposes)
23  m_parameters = ps;
24 
25  // Mapping parameter input variables
26  m_scalersSource_LSCollection = consumes<LumiScalersCollection> (m_parameters.getParameter<InputTag>("inputTagScalersResults"));
27  m_scalersSource_L1TSCollection = consumes<Level1TriggerScalersCollection>(m_parameters.getParameter<InputTag>("inputTagScalersResults"));
28  m_l1GtDataDaqInputTag = consumes<L1GlobalTriggerReadoutRecord> (m_parameters.getParameter<InputTag>("inputTagL1GtDataDaq"));
29  m_verbose = m_parameters.getUntrackedParameter<bool>("verbose",false);
30  m_refPrescaleSet = m_parameters.getParameter <int> ("refPrescaleSet");
31  m_lsShiftGTRates = m_parameters.getUntrackedParameter<int> ("lsShiftGTRates",0);
32 
33  // Getting which categories to monitor
35  m_inputCategories["Mu"] = Categories.getUntrackedParameter<bool>("Mu");
36  m_inputCategories["EG"] = Categories.getUntrackedParameter<bool>("EG");
37  m_inputCategories["IsoEG"] = Categories.getUntrackedParameter<bool>("IsoEG");
38  m_inputCategories["Jet"] = Categories.getUntrackedParameter<bool>("Jet");
39  m_inputCategories["CenJet"] = Categories.getUntrackedParameter<bool>("CenJet");
40  m_inputCategories["ForJet"] = Categories.getUntrackedParameter<bool>("ForJet");
41  m_inputCategories["TauJet"] = Categories.getUntrackedParameter<bool>("TauJet");
42  m_inputCategories["ETM"] = Categories.getUntrackedParameter<bool>("ETM");
43  m_inputCategories["ETT"] = Categories.getUntrackedParameter<bool>("ETT");
44  m_inputCategories["HTT"] = Categories.getUntrackedParameter<bool>("HTT");
45  m_inputCategories["HTM"] = Categories.getUntrackedParameter<bool>("HTM");
46 
47  // Initializing Variables
48  if (m_verbose) {
49  cout << "[L1TRate_Offline:] ____________ Storage initialization ____________ " << endl;
50  cout << "[L1TRate_Offline:] Setting up dbe folder: L1T/L1TRate" << endl;
51  }
52 }
53 
54 //_____________________________________________________________________
56 
57 //_____________________________________________________________________
58 // BeginRun: as input you get filtered events...
59 //_____________________________________________________________________
61 
62  if (m_verbose) {cout << "[L1TRate_Offline:] Called beginRun." << endl;}
63 
66 
67  iSetup.get<L1GtTriggerMenuRcd>() .get(menuRcd);
68  iSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().get(l1GtPfAlgo);
69 
70  const L1GtTriggerMenu* menu = menuRcd .product();
71  const L1GtPrescaleFactors* m_l1GtPfAlgo = l1GtPfAlgo.product();
72 
73  // Initializing DQM Monitor Elements
74  ibooker.setCurrentFolder("L1T/L1TRate");
75  m_ErrorMonitor = ibooker.book1D("ErrorMonitor", "ErrorMonitor",2,0,2);
76  m_ErrorMonitor->setBinLabel(UNKNOWN ,"UNKNOWN");
77  m_ErrorMonitor->setBinLabel(WARNING_PY_MISSING_FIT,"WARNING_PY_MISSING_FIT");
78 
79  if (m_verbose) {cout << "[L1TRate_Offline:] m_ErrorMonitor: " << m_ErrorMonitor << endl;}
80 
81  // Retriving the list of prescale sets
82  m_listsPrescaleFactors = &(m_l1GtPfAlgo->gtPrescaleFactors());
83 
84  // Getting Lowest Prescale Single Object Triggers from the menu
85  L1TMenuHelper myMenuHelper = L1TMenuHelper(iSetup);
88 
89  //-> Getting template fits for the algLo cross sections
91 
92  for (CItAlgo algo = menu->gtAlgorithmMap().begin(); algo!=menu->gtAlgorithmMap().end(); ++algo){
93  m_algoBit[(algo->second).algoAlias()] = (algo->second).algoBitNumber();
94  }
95 
96  double minInstantLuminosity = m_parameters.getParameter<double>("minInstantLuminosity");
97  double maxInstantLuminosity = m_parameters.getParameter<double>("maxInstantLuminosity");
98 
99  // Initializing DQM Monitor Elements
100  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
101 
102  TString tCategory = (*i).first;
103  TString tTrigger = (*i).second;
104 
105  TString tErrorMessage = "";
106  TF1* tTestFunction;
107 
108  if(tTrigger != "Undefined" && m_templateFunctions.find(tTrigger) != m_templateFunctions.end()){
109  tTestFunction = m_templateFunctions[tTrigger];
110  }
111  else if(tTrigger == "Undefined"){
112  TString tFunc = "-1";
113  tTestFunction = new TF1("FitParametrization_"+tTrigger,tFunc,0,double(m_maxNbins)-0.5);
114  }
115  else if(m_templateFunctions.find(tTrigger) == m_templateFunctions.end()){
116  TString tFunc = "-1";
117  tTestFunction = new TF1("FitParametrization_"+tTrigger,tFunc,0,double(m_maxNbins)-0.5);
118  tErrorMessage = " (Undefined Test Function)";
119  }
120  else{
121  TString tFunc = "-1";
122  tTestFunction = new TF1("FitParametrization_"+tTrigger,tFunc,0,double(m_maxNbins)-0.5);
123  }
124 
125  if(tTrigger != "Undefined"){
126 
127  if(myMenuHelper.getPrescaleByAlias(tCategory,tTrigger) != 1){
128  tErrorMessage += " WARNING: Default Prescale = ";
129  tErrorMessage += myMenuHelper.getPrescaleByAlias(tCategory,tTrigger);
130  }
131 
132  if (tCategory == "Mu" && myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger) != 4294967295){ //hexadecimal of the whole range
133  tErrorMessage += " WARNING: Eta Range = ";
134  tErrorMessage += myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger);
135  }
136  else if(tCategory == "EG" && myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger) != 32639){
137  tErrorMessage += " WARNING: Eta Range = ";
138  tErrorMessage += myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger);
139  }
140  else if(tCategory == "IsoEG" && myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger) != 32639){
141  tErrorMessage += " WARNING: Eta Range = ";
142  tErrorMessage += myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger);
143  }
144 
145  if(tCategory == "Mu" && myMenuHelper.getQualityAlias(tCategory,tTrigger) != 240){
146  tErrorMessage += " WARNING: Quality = ";
147  tErrorMessage += myMenuHelper.getQualityAlias(tCategory,tTrigger);
148  }
149 
150  }
151 
152  ibooker.setCurrentFolder("L1T/L1TRate/xSecDelivLumi"); // trigger counts...
153  m_xSecObservedVsDelivLumi[tTrigger] = ibooker.bookProfile(tCategory,
154  "Cross Sec. vs Deliv. Lumi: "+tTrigger+tErrorMessage,
155  m_maxNbins,
156  minInstantLuminosity,
157  maxInstantLuminosity,0,500);
158  m_xSecObservedVsDelivLumi[tTrigger] ->setAxisTitle("Delivered Luminosity [10^{30}cm^{-2}s^{-1}]" ,1);
159  m_xSecObservedVsDelivLumi[tTrigger] ->setAxisTitle("Algorithm #sigma [#mu b]" ,2);
160 
161  ibooker.setCurrentFolder("L1T/L1TRate/xSecRecorLumi"); // trigger counts...
162  m_xSecObservedVsRecorLumi[tTrigger] = ibooker.bookProfile(tCategory,
163  "Cross Sec. vs Recor. Lumi: "+tTrigger+tErrorMessage,
164  m_maxNbins,
165  minInstantLuminosity,
166  maxInstantLuminosity,0,500);
167  m_xSecObservedVsRecorLumi[tTrigger] ->setAxisTitle("Recorded Luminosity [10^{30}cm^{-2}s^{-1}]" ,1);
168  m_xSecObservedVsRecorLumi[tTrigger] ->setAxisTitle("Algorithm #sigma [#mu b]" ,2);
169 
170  ibooker.setCurrentFolder("L1T/L1TRate/TriggerCounts"); // trigger counts...
171  m_CountsVsLS[tTrigger] = ibooker.bookProfile(tCategory,
172  "Cross Sec. vs Inst. Lumi Algo: "+tTrigger+tErrorMessage,
173  m_maxNbins,
174  minInstantLuminosity,
175  maxInstantLuminosity,0,500);
176  m_CountsVsLS[tTrigger] ->setAxisTitle("Instantaneous Luminosity [10^{30}cm^{-2}s^{-1}]" ,1);
177  m_CountsVsLS[tTrigger] ->setAxisTitle("Algorithm #sigma [#mu b]" ,2);
178  m_CountsVsLS[tTrigger] ->getTProfile()->GetListOfFunctions()->Add(tTestFunction);
179  m_CountsVsLS[tTrigger] ->getTProfile()->SetMarkerStyle(23);
180 
181  m_algoFit[tTrigger] = (TF1*) tTestFunction->Clone("Fit_"+tTrigger); // NOTE: Workaround
182 
183  ibooker.setCurrentFolder("L1T/L1TRate/xSecObs");
184  m_xSecObservedVsLS[tTrigger] = ibooker.book1D(tCategory, "Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,double(m_maxNbins)-0.5);
185  m_xSecObservedVsLS[tTrigger] ->setAxisTitle("Lumi Section" ,1);
186  m_xSecObservedVsLS[tTrigger] ->setAxisTitle("#sigma_{obs}" ,2);
187 
188  ibooker.setCurrentFolder("L1T/L1TRate/Delivered");
189  m_DelivLumiVsLS[tTrigger] = ibooker.book1D(tCategory, "Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,double(m_maxNbins)-0.5);
190  m_DelivLumiVsLS[tTrigger] ->setAxisTitle("Lumi Section" ,1);
191  m_DelivLumiVsLS[tTrigger] ->setAxisTitle("Deliv. Lumi" ,2);
192 
193  ibooker.setCurrentFolder("L1T/L1TRate/Recorded");
194  m_RecorLumiVsLS[tTrigger] = ibooker.book1D(tCategory, "Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,double(m_maxNbins)-0.5);
195  m_RecorLumiVsLS[tTrigger] ->setAxisTitle("Lumi Section" ,1);
196  m_RecorLumiVsLS[tTrigger] ->setAxisTitle("Recor. Lumi" ,2);
197 
198  ibooker.setCurrentFolder("L1T/L1TRate/Ratio");
199  m_xSecObservedToExpected[tTrigger] = ibooker.book1D(tCategory, "Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,double(m_maxNbins)-0.5);
200  m_xSecObservedToExpected[tTrigger] ->setAxisTitle("Lumi Section" ,1);
201  m_xSecObservedToExpected[tTrigger] ->setAxisTitle("#sigma_{obs} / #sigma_{exp}" ,2);
202  }
203 }
204 
205 //_____________________________________________________________________
206 
208 
209 }
210 //_____________________________________________________________________
212 
213  if (m_verbose) {cout << "[L1TRate_Offline:] Called beginLuminosityBlock at LS=" << lumiBlock.id().luminosityBlock() << endl;}
214 
215 }
216 
217 //_____________________________________________________________________
219 
220  int eventLS = lumiBlock.id().luminosityBlock();
221  if (m_verbose) {cout << "[L1TRate_Offline:] Called endLuminosityBlock at LS=" << eventLS << endl;}
222 
223  // We can certify LS -1 since we should have available:
224  // gt rates: (current LS)-1
225  // prescale: current LS
226  // lumi : current LS
227  //eventLS--;
228 
229  // Checking if all necessary quantities are defined for our calculations
230  //bool isDefRate,isDefLumi,isDefPrescaleIndex;
231  bool isDefLumi,isDefPrescaleIndex;
232  //map<TString,double>* rates=0;
233  double lumi=0;
234  double deadtime=0;
235  unsigned int prescalesIndex=0;
236 
237  bool isDefCount;
238  map<TString,double>* counts=nullptr;
239 
240  // Resetting MonitorElements so we can refill them
241  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
242  string tTrigger = (*i).second;
243  // m_DeadTimeVsLS [tTrigger]->getTH1()->Reset("ICE");
244  m_CountsVsLS [tTrigger]->getTH1()->Reset("ICE");
245  m_xSecObservedToExpected[tTrigger]->getTH1()->Reset("ICE");
246 
247  m_xSecObservedVsLS [tTrigger]->getTH1()->Reset("ICE");
248  m_DelivLumiVsLS [tTrigger]->getTH1()->Reset("ICE");
249  m_RecorLumiVsLS [tTrigger]->getTH1()->Reset("ICE");
250 
251  m_xSecObservedVsDelivLumi[tTrigger]->getTH1()->Reset("ICE");
252  m_xSecObservedVsRecorLumi[tTrigger]->getTH1()->Reset("ICE");
253 
254  }
255 
256  //Trying to do the same with Counts....
257  for(map<int,map<TString,double> >::iterator j=m_lsRates.begin() ; j!=m_lsRates.end() ; j++){
258 
259  unsigned int lsOffline = (*j).first;
260  counts = &(*j).second;
261  isDefCount=true;
262 
263  unsigned int lsPreInd;
264 
265  if(m_lsLuminosity.find(lsOffline)==m_lsLuminosity.end()){isDefLumi=false;}
266  else{
267  isDefLumi=true;
268  lumi=m_lsLuminosity[lsOffline];
269  deadtime=m_lsDeadTime[lsOffline];
270  }
271 
272  lsPreInd = lsOffline + 1; // NOTE: Workaround
273 
274  if(m_lsPrescaleIndex.find(lsPreInd)==m_lsPrescaleIndex.end()){isDefPrescaleIndex=false;}
275  else{
276  isDefPrescaleIndex=true;
277  prescalesIndex=m_lsPrescaleIndex[lsPreInd];
278  }
279 
280  if(isDefCount && isDefLumi && isDefPrescaleIndex && (prescalesIndex < m_listsPrescaleFactors->size())){
281 
282  const vector<int>& currentPrescaleFactors = (*m_listsPrescaleFactors).at(prescalesIndex);
283 
284  for(map<string,string>::const_iterator j=m_selectedTriggers.begin() ; j!=m_selectedTriggers.end() ; j++){
285 
286  string tTrigger = (*j).second;
287  double trigCount = (*counts)[tTrigger];
288 
289  // TF1* tTestFunction = (TF1*) m_CountsVsLS[tTrigger]->getTProfile()->GetListOfFunctions()->First();
290  TF1* tTestFunction = m_algoFit[tTrigger]; // NOTE: Workaround....
291 
292 
293  // If trigger name is defined we get the rate fit parameters
294  if(tTrigger != "Undefined"){
295 
296  unsigned int trigBit = m_algoBit[tTrigger];
297  double trigPrescale = currentPrescaleFactors[trigBit];
298 
299  if(lumi!=0 && trigCount!=0 && trigPrescale!=0){
300 
301  double RecLumi = lumi*(1. - deadtime/100.);
302 
303  double AlgoXSec = (trigPrescale*trigCount)/RecLumi;
304  double TemplateFunctionValue = tTestFunction->Eval(lumi);
305 
306 
307  // Checking against Template function
308  // m_DeadTimeVsLS [tTrigger]->Fill(lumi,deadtime);
309 
310 
311  m_xSecObservedVsRecorLumi[tTrigger]->Fill(RecLumi,AlgoXSec);
312 
313  m_CountsVsLS [tTrigger]->Fill(lumi,AlgoXSec);
314 
315  int ibin = m_xSecObservedToExpected[tTrigger]->getTH1()->FindBin(lsOffline);
316  m_xSecObservedToExpected[tTrigger]->setBinContent(ibin,AlgoXSec/TemplateFunctionValue);
317 
318  m_DelivLumiVsLS[tTrigger]->setBinContent(ibin,lumi);
319  m_RecorLumiVsLS[tTrigger]->setBinContent(ibin,RecLumi);
320 
321  m_xSecObservedVsLS[tTrigger]->setBinContent(ibin,AlgoXSec);
322 
323  }
324  else {
325  // m_DeadTimeVsLS [tTrigger]->Fill(0.000001,0.000001);
326 
327  m_xSecObservedVsRecorLumi[tTrigger]->Fill(0.000001,0.000001);
328 
329  m_CountsVsLS [tTrigger]->Fill(0.000001,0.000001);
330 
331  int ibin = m_xSecObservedToExpected[tTrigger]->getTH1()->FindBin(lsOffline);
332  m_xSecObservedToExpected[tTrigger]->setBinContent(ibin,0.000001);
333 
334  m_DelivLumiVsLS[tTrigger]->setBinContent(ibin,0.000001);
335  m_RecorLumiVsLS[tTrigger]->setBinContent(ibin,0.000001);
336 
337  m_xSecObservedVsLS[tTrigger]->setBinContent(ibin,0.000001);
338  }
339  }
340  }
341  }
342  }
343 }
344 
345 
346 //_____________________________________________________________________
347 void L1TRate_Offline::analyze(const Event & iEvent, const EventSetup & eventSetup){
348 
349  edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecordData;
352 
353  iEvent.getByToken(m_l1GtDataDaqInputTag , gtReadoutRecordData);
354  iEvent.getByToken(m_scalersSource_LSCollection , colLScal);
355  iEvent.getByToken(m_scalersSource_L1TSCollection , triggerScalers);
356 
357  // Integers
358  int EventRun = iEvent.id().run();
359  unsigned int eventLS = iEvent.id().luminosityBlock();
360 
361  // Getting the trigger trigger rates from GT and buffering it
362  if(triggerScalers.isValid() && !triggerScalers->empty()){
363 
364  Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
365  Level1TriggerRates trigRates(*itL1TScalers,EventRun);
366 
367  //Trying to retrieve GT DeadTime
368  //unsigned long long deadtime = itL1TScalers->deadtime();
369  //double deadtime = itL1TScalers->deadtime();
370  double deadtime = trigRates.deadtimePercent(); //correct DeadTime % to retrieve
371 
372  // Trying to get the trigger counts
373  const std::vector<unsigned int> gtAlgoCounts = itL1TScalers->gtAlgoCounts();
374 
375  // int lumisegment = (*itL1TScalers).lumiSegmentNr();
376 
377 // cout << "deadtime =" << deadtime << " --
378 // cout << "lumisegment = " << lumisegment << endl;
379 
380  int gtLS = (*itL1TScalers).lumiSegmentNr()+m_lsShiftGTRates;
381 
382  // If we haven't got the data from this LS yet get it
383  if(m_lsRates.find(gtLS)==m_lsRates.end()){
384 
385  map<TString,double> bufferCount;
386 
387  // Buffer the rate informations for all selected bits
388  for(map<string,string>::const_iterator i=m_selectedTriggers.begin(); i!=m_selectedTriggers.end() ; i++){
389 
390  string tTrigger = (*i).second;
391 
392  // If trigger name is defined we store the rate
393  if(tTrigger != "Undefined"){
394 
395  unsigned int trigBit = m_algoBit[tTrigger];
396  double trigCount = gtAlgoCounts[trigBit];
397 
398  bufferCount[tTrigger] = trigCount;
399 
400  }
401  }
402  m_lsRates[gtLS] = bufferCount;
403  m_lsDeadTime[gtLS] = deadtime;
404  }
405  }
406 
407 
408  // Getting from the SCAL the luminosity information and buffering it
409  if(colLScal.isValid() && !colLScal->empty()){
410 
411  LumiScalersCollection::const_iterator itLScal = colLScal->begin();
412  unsigned int scalLS = itLScal->sectionNumber();
413 
414  // If we haven't got the data from this SCAL LS yet get it
415  if(m_lsLuminosity.find(scalLS)==m_lsLuminosity.end()){
416 
417  if (m_verbose) {cout << "[L1TRate_Offline:] Buffering SCAL-HF Lumi for LS=" << scalLS << endl;}
418  double instLumi = itLScal->instantLumi(); // Getting Instant Lumi from HF (via SCAL) // <###### WE NEED TO STORE THIS
419  double deadTimeNormHF = itLScal->deadTimeNormalization(); // Getting Dead Time Normalization from HF (via SCAL)
420 
421 // double mylumiFill = itLScal->lumiFill(); // Integrated lumi since beginning of fill, delivered
422 // double mylumiRun = itLScal->lumiRun(); // Integrated lumi since beginning of run, delivered
423 // double myliveLumiFill = itLScal->liveLumiFill(); // Integrated lumi since beginning of fill, live
424 // double myliveLumiRun = itLScal->liveLumiRun(); // Integrated lumi since beginning of run, live
425 // double mysectionNumber = itLScal->sectionNumber(); // Lumi section number for this info
426 // double mynumOrbits = itLScal->numOrbits(); // Number of orbits that have passed this run
427 
428 // cout << "instantLumi = " << instLumi << endl;
429 // cout << "lumiFill = " << mylumiFill << endl;
430 // cout << "lumiRun = " << mylumiRun << endl;
431 // cout << "livelumiFill = " << myliveLumiFill << endl;
432 // cout << "livelumiRun = " << myliveLumiRun << endl;
433 // cout << "sectionNumber = " << mysectionNumber << endl;
434 // cout << "numOrbits = " << mynumOrbits << endl;
435 
436 
437  // If HF Dead Time Corrections is requested we apply it
438  // NOTE: By default this is assumed false since for now WbM fits do NOT assume this correction
439  if(m_parameters.getUntrackedParameter<bool>("useHFDeadTimeNormalization",false)){
440 
441  // Protecting for deadtime = 0
442  if(deadTimeNormHF==0){instLumi = 0;}
443  else {instLumi = instLumi/deadTimeNormHF;}
444  }
445  // Buffering the luminosity information
446  m_lsLuminosity[scalLS]=instLumi;
447  }
448  }
449 
450  // Getting the prescale index used when this event was triggered
451  if(gtReadoutRecordData.isValid()){
452 
453  // If we haven't got the data from this LS yet get it
454  if(m_lsPrescaleIndex.find(eventLS)==m_lsPrescaleIndex.end()){
455 
456  if (m_verbose) {cout << "[L1TRate_Offline:] Buffering Prescale Index for LS=" << eventLS << endl;}
457 
458  // Getting Final Decision Logic (FDL) Data from GT
459  const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->gtFdlVector();
460 
461  // Getting the index for the fdl data for this event
462  int indexFDL=0;
463  for(unsigned int i=0; i<gtFdlVectorData.size(); i++){
464  if(gtFdlVectorData[i].bxInEvent()==0){indexFDL=i; break;}
465  }
466 
467  if(!gtFdlVectorData.empty())
468  {
469  int CurrentPrescalesIndex = gtFdlVectorData[indexFDL].gtPrescaleFactorIndexAlgo(); // <###### WE NEED TO STORE THIS
470  m_lsPrescaleIndex[eventLS] = CurrentPrescalesIndex;
471  }
472 
473  }
474 
475  }
476 }
477 
478 //_____________________________________________________________________
479 // function: getXSexFitsPython
480 // Imputs:
481 // * const edm::ParameterSet& ps = ParameterSet contaning the fit
482 // functions and parameters for the selected triggers
483 // Outputs:
484 // * int error = Number of algos where you did not find a
485 // corresponding fit
486 //_____________________________________________________________________
488 
489  // error meaning
490  bool noError = true;
491 
492  // Getting fit parameters
493  std::vector<edm::ParameterSet> m_fitParameters = ps.getParameter< vector<ParameterSet> >("fitParameters");
494 
495  double minInstantLuminosity = m_parameters.getParameter<double>("minInstantLuminosity");
496  double maxInstantLuminosity = m_parameters.getParameter<double>("maxInstantLuminosity");
497 
498  // Getting rate fit parameters for all input triggers
499  for(map<string,string>::const_iterator a=m_selectedTriggers.begin() ; a!=m_selectedTriggers.end() ; a++){
500 
501  string tTrigger = (*a).second;
502 
503  // If trigger name is defined we get the rate fit parameters
504  if(tTrigger != "Undefined"){
505 
506  bool foundFit = false;
507 
508  for(unsigned int b=0 ; b<m_fitParameters.size() ; b++){
509 
510  if(tTrigger == m_fitParameters[b].getParameter<string>("AlgoName")){
511 
512  TString tAlgoName = m_fitParameters[b].getParameter< string > ("AlgoName");
513  TString tTemplateFunction = m_fitParameters[b].getParameter< string > ("TemplateFunction");
514  vector<double> tParameters = m_fitParameters[b].getParameter< vector<double> >("Parameters");
515 
516  // Retriving and populating the m_templateFunctions array
517  m_templateFunctions[tTrigger] = new TF1("FitParametrization_"+tAlgoName,tTemplateFunction,
518  minInstantLuminosity,maxInstantLuminosity);
519  m_templateFunctions[tTrigger] ->SetParameters(&tParameters[0]);
520  m_templateFunctions[tTrigger] ->SetLineWidth(1);
521  m_templateFunctions[tTrigger] ->SetLineColor(kRed);
522 
523  foundFit = true;
524  break;
525  }
526 
527  if(!foundFit){
528 
529  noError = false;
530 
531  int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_PY_MISSING_FIT);
532  eCount++;
533  m_ErrorMonitor->getTH1()->SetBinContent(WARNING_PY_MISSING_FIT,eCount);
534 
535  }
536  }
537  }
538  }
539 
540  return noError;
541 
542 }
543 
544 
545 //define this as a plug-in
RunNumber_t run() const
Definition: EventID.h:39
size
Write out results.
LuminosityBlockID id() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void dqmBeginRun(edm::Run const &, edm::EventSetup const &) override
edm::EDGetTokenT< Level1TriggerScalersCollection > m_scalersSource_L1TSCollection
MonitorElement * m_ErrorMonitor
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:160
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:519
std::map< std::string, std::string > m_selectedTriggers
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
const std::vector< L1GtFdlWord > gtFdlVector() const
get the vector of L1GtFdlWord
TH1 * getTH1() const
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, MonitorElement * > m_RecorLumiVsLS
std::map< TString, TF1 * > m_templateFunctions
LuminosityBlockNumber_t luminosityBlock() const
Definition: EventID.h:40
bool getXSexFitsPython(const edm::ParameterSet &ps)
void beginLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
void endLuminosityBlock(edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtDataDaqInputTag
std::map< int, double > m_lsLuminosity
edm::ParameterSet m_parameters
int iEvent
Definition: GenABIO.cc:230
L1TRate_Offline(const edm::ParameterSet &ps)
~L1TRate_Offline() override
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
std::map< TString, MonitorElement * > m_xSecObservedVsDelivLumi
void retrieveL1EventSetup(const edm::EventSetup &)
retrieve all the relevant L1 trigger event setup records and cache them to improve the speed ...
Definition: L1GtUtils.cc:121
unsigned int getQualityAlias(const TString &iCategory, const TString &iAlias)
std::map< TString, MonitorElement * > m_xSecObservedVsLS
std::map< TString, MonitorElement * > m_xSecObservedToExpected
bool isValid() const
Definition: HandleBase.h:74
void analyze(const edm::Event &e, const edm::EventSetup &c) override
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:279
std::map< int, int > m_lsPrescaleIndex
const std::vector< std::vector< int > > & gtPrescaleFactors() const
get the prescale factors by reference
std::map< std::string, bool > m_inputCategories
L1GtUtils m_l1GtUtils
const T & get() const
Definition: EventSetup.h:58
double b
Definition: hdecay.h:120
LuminosityBlockNumber_t luminosityBlock() const
std::map< int, double > m_lsDeadTime
double deadtimePercent() const
std::map< TString, MonitorElement * > m_CountsVsLS
void bookHistograms(DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &iSetup) override
edm::EventID id() const
Definition: EventBase.h:60
const std::vector< std::vector< int > > * m_listsPrescaleFactors
HLT enums.
edm::EDGetTokenT< LumiScalersCollection > m_scalersSource_LSCollection
double a
Definition: hdecay.h:121
std::map< int, std::map< TString, double > > m_lsRates
const AlgorithmMap & gtAlgorithmMap() const
get / set the algorithm map (by name)
std::map< TString, int > m_algoBit
std::map< TString, MonitorElement * > m_DelivLumiVsLS
unsigned int getEtaRangeByAlias(const TString &iCategory, const TString &iAlias)
std::map< TString, MonitorElement * > m_xSecObservedVsRecorLumi
int getPrescaleByAlias(const TString &iCategory, const TString &iAlias)
T const * product() const
Definition: ESHandle.h:86
Definition: Run.h:43
std::map< std::string, std::string > getLUSOTrigger(const std::map< std::string, bool > &iCategories, int IndexRefPrescaleFactors, L1GtUtils const &myUtils)
std::map< TString, TF1 * > m_algoFit