CMS 3D CMS Logo

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