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