CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Protected Member Functions | Private Attributes
L1TRate_Offline Class Reference

#include <L1TRate_Offline.h>

Inheritance diagram for L1TRate_Offline:
one::DQMEDAnalyzer< edm::one::WatchLuminosityBlocks > one::dqmimplementation::DQMBaseClass< T... >

Public Types

enum  Errors { UNKNOWN = 1, WARNING_PY_MISSING_FIT = 2 }
 

Public Member Functions

 L1TRate_Offline (const edm::ParameterSet &ps)
 
 ~L1TRate_Offline () override
 
- Public Member Functions inherited from one::DQMEDAnalyzer< edm::one::WatchLuminosityBlocks >
 DQMEDAnalyzer ()=default
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > const &)=delete
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > &&)=delete
 
 ~DQMEDAnalyzer () override=default
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
 
void bookHistograms (DQMStore::IBooker &ibooker, const edm::Run &run, const edm::EventSetup &iSetup) override
 
void dqmBeginRun (edm::Run const &, edm::EventSetup const &) override
 
void endLuminosityBlock (edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c) override
 
bool getXSexFitsPython (const edm::ParameterSet &ps)
 

Private Attributes

std::map< TString, int > m_algoBit
 
std::map< TString, TF1 * > m_algoFit
 
std::map< TString, MonitorElement * > m_CountsVsLS
 
std::map< TString, MonitorElement * > m_DelivLumiVsLS
 
MonitorElementm_ErrorMonitor
 
std::map< std::string, bool > m_inputCategories
 
std::map< TString, MonitorElement * > m_InstLumiVsLS
 
edm::EDGetTokenT< L1GlobalTriggerReadoutRecordm_l1GtDataDaqInputTag
 
L1GtUtils m_l1GtUtils
 
const std::vector< std::vector< int > > * m_listsPrescaleFactors
 
std::map< int, std::map< TString, double > > m_lsCounts
 
std::map< int, double > m_lsDeadTime
 
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
 
std::map< TString, MonitorElement * > m_PrescIndexVsLS
 
std::map< TString, MonitorElement * > m_RecorLumiVsLS
 
int m_refPrescaleSet
 
edm::EDGetTokenT< Level1TriggerScalersCollectionm_scalersSource_L1TSCollection
 
edm::EDGetTokenT< LumiScalersCollectionm_scalersSource_LSCollection
 
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_xSecObservedVsDelivLumi
 
std::map< TString, MonitorElement * > m_xSecObservedVsLS
 
std::map< TString, MonitorElement * > m_xSecObservedVsRecorLumi
 
std::map< TString, MonitorElement * > m_xSecVsInstLumi
 

Detailed Description

Definition at line 46 of file L1TRate_Offline.h.

Member Enumeration Documentation

Enumerator
UNKNOWN 
WARNING_PY_MISSING_FIT 

Definition at line 50 of file L1TRate_Offline.h.

Constructor & Destructor Documentation

L1TRate_Offline::L1TRate_Offline ( const edm::ParameterSet ps)

Definition at line 19 of file L1TRate_Offline.cc.

References TagProbeFitTreeAnalyzer_cfi::Categories, gather_cfg::cout, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), m_inputCategories, m_l1GtDataDaqInputTag, m_lsShiftGTRates, m_maxNbins, m_parameters, m_refPrescaleSet, m_scalersSource_L1TSCollection, m_scalersSource_LSCollection, and m_verbose.

19  :
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 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< Level1TriggerScalersCollection > m_scalersSource_L1TSCollection
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtDataDaqInputTag
edm::ParameterSet m_parameters
std::map< std::string, bool > m_inputCategories
L1GtUtils m_l1GtUtils
edm::EDGetTokenT< LumiScalersCollection > m_scalersSource_LSCollection
L1TRate_Offline::~L1TRate_Offline ( )
override

Definition at line 55 of file L1TRate_Offline.cc.

55 {}

Member Function Documentation

void L1TRate_Offline::analyze ( const edm::Event e,
const edm::EventSetup c 
)
overrideprotected

Definition at line 347 of file L1TRate_Offline.cc.

References gather_cfg::cout, Level1TriggerRates::deadtimePercent(), edm::Event::getByToken(), edm::ParameterSet::getUntrackedParameter(), L1GlobalTriggerReadoutRecord::gtFdlVector(), mps_fire::i, edm::EventBase::id(), muonGEMDigis_cfi::instLumi, edm::HandleBase::isValid(), edm::EventID::luminosityBlock(), m_algoBit, m_l1GtDataDaqInputTag, m_lsDeadTime, m_lsLuminosity, m_lsPrescaleIndex, m_lsRates, m_lsShiftGTRates, m_parameters, m_scalersSource_L1TSCollection, m_scalersSource_LSCollection, m_selectedTriggers, m_verbose, and edm::EventID::run().

347  {
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 }
T getUntrackedParameter(std::string const &, T const &) const
edm::EDGetTokenT< Level1TriggerScalersCollection > m_scalersSource_L1TSCollection
std::map< std::string, std::string > m_selectedTriggers
const std::vector< L1GtFdlWord > gtFdlVector() const
get the vector of L1GtFdlWord
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtDataDaqInputTag
std::map< int, double > m_lsLuminosity
edm::ParameterSet m_parameters
int iEvent
Definition: GenABIO.cc:224
bool isValid() const
Definition: HandleBase.h:74
std::map< int, int > m_lsPrescaleIndex
std::map< int, double > m_lsDeadTime
edm::EDGetTokenT< LumiScalersCollection > m_scalersSource_LSCollection
std::map< int, std::map< TString, double > > m_lsRates
std::map< TString, int > m_algoBit
void L1TRate_Offline::beginLuminosityBlock ( edm::LuminosityBlock const &  lumiBlock,
edm::EventSetup const &  c 
)
overrideprotected

Definition at line 211 of file L1TRate_Offline.cc.

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

211  {
212 
213  if (m_verbose) {cout << "[L1TRate_Offline:] Called beginLuminosityBlock at LS=" << lumiBlock.id().luminosityBlock() << endl;}
214 
215 }
void L1TRate_Offline::bookHistograms ( DQMStore::IBooker ibooker,
const edm::Run run,
const edm::EventSetup iSetup 
)
overrideprotected

Definition at line 60 of file L1TRate_Offline.cc.

References patPFMETCorrections_cff::algo, DQMStore::IBooker::book1D(), DQMStore::IBooker::bookProfile(), gather_cfg::cout, edm::EventSetup::get(), L1TMenuHelper::getEtaRangeByAlias(), L1TMenuHelper::getLUSOTrigger(), edm::ParameterSet::getParameter(), L1TMenuHelper::getPrescaleByAlias(), L1TMenuHelper::getQualityAlias(), getXSexFitsPython(), L1GtTriggerMenu::gtAlgorithmMap(), L1GtPrescaleFactors::gtPrescaleFactors(), mps_fire::i, m_algoBit, m_algoFit, m_CountsVsLS, m_DelivLumiVsLS, m_ErrorMonitor, m_inputCategories, m_l1GtUtils, m_listsPrescaleFactors, m_maxNbins, m_parameters, m_RecorLumiVsLS, m_refPrescaleSet, m_selectedTriggers, m_templateFunctions, m_verbose, m_xSecObservedToExpected, m_xSecObservedVsDelivLumi, m_xSecObservedVsLS, m_xSecObservedVsRecorLumi, edm::ESHandle< T >::product(), L1GtUtils::retrieveL1EventSetup(), MonitorElement::setBinLabel(), DQMStore::IBooker::setCurrentFolder(), UNKNOWN, and WARNING_PY_MISSING_FIT.

60  {
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 }
T getParameter(std::string const &) const
MonitorElement * m_ErrorMonitor
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:113
std::map< std::string, std::string > m_selectedTriggers
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
bool getXSexFitsPython(const edm::ParameterSet &ps)
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
edm::ParameterSet m_parameters
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
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
const std::vector< std::vector< int > > & gtPrescaleFactors() const
get the prescale factors by reference
std::map< std::string, bool > m_inputCategories
L1GtUtils m_l1GtUtils
std::map< TString, MonitorElement * > m_CountsVsLS
const std::vector< std::vector< int > > * m_listsPrescaleFactors
T get() const
Definition: EventSetup.h:71
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
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
void L1TRate_Offline::dqmBeginRun ( edm::Run const &  ,
edm::EventSetup const &   
)
overrideprotected

Definition at line 207 of file L1TRate_Offline.cc.

207  {
208 
209 }
void L1TRate_Offline::endLuminosityBlock ( edm::LuminosityBlock const &  lumiBlock,
edm::EventSetup const &  c 
)
overrideprotected

Definition at line 218 of file L1TRate_Offline.cc.

References gather_cfg::cout, mps_fire::i, edm::LuminosityBlockBase::id(), edm::LuminosityBlockID::luminosityBlock(), m_algoBit, m_algoFit, m_CountsVsLS, m_DelivLumiVsLS, m_lsDeadTime, m_lsLuminosity, m_lsPrescaleIndex, m_lsRates, m_RecorLumiVsLS, m_selectedTriggers, m_verbose, m_xSecObservedToExpected, m_xSecObservedVsDelivLumi, m_xSecObservedVsLS, m_xSecObservedVsRecorLumi, genParticles_cff::map, and findQualityFiles::size.

218  {
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 }
size
Write out results.
std::map< std::string, std::string > m_selectedTriggers
std::map< TString, MonitorElement * > m_RecorLumiVsLS
std::map< int, double > m_lsLuminosity
std::map< TString, MonitorElement * > m_xSecObservedVsDelivLumi
std::map< TString, MonitorElement * > m_xSecObservedVsLS
std::map< TString, MonitorElement * > m_xSecObservedToExpected
std::map< int, int > m_lsPrescaleIndex
std::map< int, double > m_lsDeadTime
std::map< TString, MonitorElement * > m_CountsVsLS
std::map< int, std::map< TString, double > > m_lsRates
std::map< TString, int > m_algoBit
std::map< TString, MonitorElement * > m_DelivLumiVsLS
std::map< TString, MonitorElement * > m_xSecObservedVsRecorLumi
std::map< TString, TF1 * > m_algoFit
bool L1TRate_Offline::getXSexFitsPython ( const edm::ParameterSet ps)
protected

Definition at line 487 of file L1TRate_Offline.cc.

References a, b, DEFINE_FWK_MODULE, edm::ParameterSet::getParameter(), MonitorElement::getTH1(), m_ErrorMonitor, m_parameters, m_selectedTriggers, m_templateFunctions, and WARNING_PY_MISSING_FIT.

Referenced by bookHistograms().

487  {
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 }
T getParameter(std::string const &) const
MonitorElement * m_ErrorMonitor
std::map< std::string, std::string > m_selectedTriggers
TH1 * getTH1() const
std::map< TString, TF1 * > m_templateFunctions
edm::ParameterSet m_parameters
double b
Definition: hdecay.h:120
double a
Definition: hdecay.h:121

Member Data Documentation

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

Definition at line 97 of file L1TRate_Offline.h.

Referenced by analyze(), bookHistograms(), and endLuminosityBlock().

std::map<TString,TF1*> L1TRate_Offline::m_algoFit
private

Definition at line 98 of file L1TRate_Offline.h.

Referenced by bookHistograms(), and endLuminosityBlock().

std::map<TString,MonitorElement*> L1TRate_Offline::m_CountsVsLS
private

Definition at line 108 of file L1TRate_Offline.h.

Referenced by bookHistograms(), and endLuminosityBlock().

std::map<TString,MonitorElement*> L1TRate_Offline::m_DelivLumiVsLS
private

Definition at line 114 of file L1TRate_Offline.h.

Referenced by bookHistograms(), and endLuminosityBlock().

MonitorElement* L1TRate_Offline::m_ErrorMonitor
private

Definition at line 130 of file L1TRate_Offline.h.

Referenced by bookHistograms(), and getXSexFitsPython().

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

Definition at line 99 of file L1TRate_Offline.h.

Referenced by bookHistograms(), and L1TRate_Offline().

std::map<TString,MonitorElement*> L1TRate_Offline::m_InstLumiVsLS
private

Definition at line 109 of file L1TRate_Offline.h.

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

Definition at line 124 of file L1TRate_Offline.h.

Referenced by analyze(), and L1TRate_Offline().

L1GtUtils L1TRate_Offline::m_l1GtUtils
private

Definition at line 132 of file L1TRate_Offline.h.

Referenced by bookHistograms().

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

Definition at line 90 of file L1TRate_Offline.h.

Referenced by bookHistograms().

std::map<int,std::map<TString,double> > L1TRate_Offline::m_lsCounts
private

Definition at line 119 of file L1TRate_Offline.h.

std::map<int,double> L1TRate_Offline::m_lsDeadTime
private

Definition at line 93 of file L1TRate_Offline.h.

Referenced by analyze(), and endLuminosityBlock().

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

Definition at line 95 of file L1TRate_Offline.h.

Referenced by analyze(), and endLuminosityBlock().

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

Definition at line 94 of file L1TRate_Offline.h.

Referenced by analyze(), and endLuminosityBlock().

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

Definition at line 96 of file L1TRate_Offline.h.

Referenced by analyze(), and endLuminosityBlock().

int L1TRate_Offline::m_lsShiftGTRates
private

Definition at line 84 of file L1TRate_Offline.h.

Referenced by analyze(), and L1TRate_Offline().

int L1TRate_Offline::m_maxNbins
private

Definition at line 83 of file L1TRate_Offline.h.

Referenced by bookHistograms(), and L1TRate_Offline().

std::string L1TRate_Offline::m_outputFile
private

Definition at line 87 of file L1TRate_Offline.h.

edm::ParameterSet L1TRate_Offline::m_parameters
private

Definition at line 127 of file L1TRate_Offline.h.

Referenced by analyze(), bookHistograms(), getXSexFitsPython(), and L1TRate_Offline().

std::map<TString,MonitorElement*> L1TRate_Offline::m_PrescIndexVsLS
private

Definition at line 110 of file L1TRate_Offline.h.

std::map<TString,MonitorElement*> L1TRate_Offline::m_RecorLumiVsLS
private

Definition at line 115 of file L1TRate_Offline.h.

Referenced by bookHistograms(), and endLuminosityBlock().

int L1TRate_Offline::m_refPrescaleSet
private

Definition at line 82 of file L1TRate_Offline.h.

Referenced by bookHistograms(), and L1TRate_Offline().

edm::EDGetTokenT<Level1TriggerScalersCollection> L1TRate_Offline::m_scalersSource_L1TSCollection
private

Definition at line 123 of file L1TRate_Offline.h.

Referenced by analyze(), and L1TRate_Offline().

edm::EDGetTokenT<LumiScalersCollection> L1TRate_Offline::m_scalersSource_LSCollection
private

Definition at line 122 of file L1TRate_Offline.h.

Referenced by analyze(), and L1TRate_Offline().

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

Definition at line 100 of file L1TRate_Offline.h.

Referenced by analyze(), bookHistograms(), endLuminosityBlock(), and getXSexFitsPython().

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

Definition at line 117 of file L1TRate_Offline.h.

Referenced by bookHistograms(), and getXSexFitsPython().

bool L1TRate_Offline::m_verbose
private
std::map<TString,MonitorElement*> L1TRate_Offline::m_xSecObservedToExpected
private

Definition at line 101 of file L1TRate_Offline.h.

Referenced by bookHistograms(), and endLuminosityBlock().

std::map<TString,MonitorElement*> L1TRate_Offline::m_xSecObservedVsDelivLumi
private

Definition at line 104 of file L1TRate_Offline.h.

Referenced by bookHistograms(), and endLuminosityBlock().

std::map<TString,MonitorElement*> L1TRate_Offline::m_xSecObservedVsLS
private

Definition at line 113 of file L1TRate_Offline.h.

Referenced by bookHistograms(), and endLuminosityBlock().

std::map<TString,MonitorElement*> L1TRate_Offline::m_xSecObservedVsRecorLumi
private

Definition at line 105 of file L1TRate_Offline.h.

Referenced by bookHistograms(), and endLuminosityBlock().

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

Definition at line 102 of file L1TRate_Offline.h.