CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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:
edm::EDAnalyzer edm::EDConsumerBase

Public Types

enum  Errors { UNKNOWN = 1, WARNING_PY_MISSING_FIT = 2 }
 
- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 

Public Member Functions

 L1TRate_Offline (const edm::ParameterSet &ps)
 
virtual ~L1TRate_Offline ()
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Protected Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c)
 
void beginJob ()
 
virtual void beginLuminosityBlock (edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
 
void beginRun (const edm::Run &run, const edm::EventSetup &iSetup)
 
void endJob ()
 
virtual void endLuminosityBlock (edm::LuminosityBlock const &lumiBlock, edm::EventSetup const &c)
 
void endRun (const edm::Run &run, const edm::EventSetup &iSetup)
 
bool getXSexFitsPython (const edm::ParameterSet &ps)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Private Attributes

DQMStoredbe
 
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
< L1GlobalTriggerReadoutRecord
m_l1GtDataDaqInputTag
 
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
< Level1TriggerScalersCollection
m_scalersSource_L1TSCollection
 
edm::EDGetTokenT
< LumiScalersCollection
m_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
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Detailed Description

Definition at line 43 of file L1TRate_Offline.h.

Member Enumeration Documentation

Enumerator
UNKNOWN 
WARNING_PY_MISSING_FIT 

Definition at line 47 of file L1TRate_Offline.h.

Constructor & Destructor Documentation

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

Definition at line 21 of file L1TRate_Offline.cc.

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

21  {
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 
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 }
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
edm::EDGetTokenT< LumiScalersCollection > m_scalersSource_LSCollection
tuple cout
Definition: gather_cfg.py:121
L1TRate_Offline::~L1TRate_Offline ( )
virtual

Definition at line 63 of file L1TRate_Offline.cc.

63 {}

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 390 of file L1TRate_Offline.cc.

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

390  {
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 }
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
edm::EDGetTokenT< Level1TriggerScalersCollection > m_scalersSource_L1TSCollection
std::map< std::string, std::string > m_selectedTriggers
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtDataDaqInputTag
std::map< int, double > m_lsLuminosity
edm::ParameterSet m_parameters
int iEvent
Definition: GenABIO.cc:230
bool isValid() const
Definition: HandleBase.h:76
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
tuple cout
Definition: gather_cfg.py:121
void L1TRate_Offline::beginJob ( void  )
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 66 of file L1TRate_Offline.cc.

References gather_cfg::cout, AlcaSiStripGainsHarvester_cff::DQMStore, and cppFunctionSkipper::operator.

66  {
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 }
tuple cout
Definition: gather_cfg.py:121
void L1TRate_Offline::beginLuminosityBlock ( edm::LuminosityBlock const &  lumiBlock,
edm::EventSetup const &  c 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 254 of file L1TRate_Offline.cc.

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

254  {
255 
256  if (m_verbose) {cout << "[L1TRate_Offline:] Called beginLuminosityBlock at LS=" << lumiBlock.id().luminosityBlock() << endl;}
257 
258 }
tuple cout
Definition: gather_cfg.py:121
void L1TRate_Offline::beginRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 96 of file L1TRate_Offline.cc.

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

96  {
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);
123 
124  //-> Getting template fits for the algLo cross sections
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 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
MonitorElement * m_ErrorMonitor
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
std::map< TString, MonitorElement * > m_xSecObservedVsDelivLumi
unsigned int getQualityAlias(const TString &iCategory, const TString &iAlias)
std::map< TString, MonitorElement * > m_xSecObservedVsLS
std::map< TString, MonitorElement * > m_xSecObservedToExpected
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
std::map< std::string, bool > m_inputCategories
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:86
std::map< TString, MonitorElement * > m_CountsVsLS
const std::vector< std::vector< int > > * m_listsPrescaleFactors
const AlgorithmMap & gtAlgorithmMap() const
get / set the algorithm map (by name)
std::map< TString, int > m_algoBit
tuple cout
Definition: gather_cfg.py:121
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)
std::map< TString, TF1 * > m_algoFit
void L1TRate_Offline::endJob ( void  )
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 82 of file L1TRate_Offline.cc.

References gather_cfg::cout.

82  {
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 }
std::string m_outputFile
tuple cout
Definition: gather_cfg.py:121
void L1TRate_Offline::endLuminosityBlock ( edm::LuminosityBlock const &  lumiBlock,
edm::EventSetup const &  c 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 261 of file L1TRate_Offline.cc.

References gather_cfg::cout, i, edm::LuminosityBlockBase::id(), j, fjr2json::lumi, edm::LuminosityBlockID::luminosityBlock(), and python.multivaluedict::map().

261  {
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 }
int i
Definition: DBlmapReader.cc:9
std::map< std::string, std::string > m_selectedTriggers
tuple lumi
Definition: fjr2json.py:35
std::map< TString, MonitorElement * > m_RecorLumiVsLS
std::map< int, double > m_lsLuminosity
int j
Definition: DBlmapReader.cc:9
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
tuple cout
Definition: gather_cfg.py:121
std::map< TString, MonitorElement * > m_DelivLumiVsLS
std::map< TString, MonitorElement * > m_xSecObservedVsRecorLumi
std::map< TString, TF1 * > m_algoFit
void L1TRate_Offline::endRun ( const edm::Run run,
const edm::EventSetup iSetup 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 248 of file L1TRate_Offline.cc.

References gather_cfg::cout.

248  {
249 
250  if (m_verbose) {cout << "[L1TRate_Offline:] Called endRun." << endl;}
251 
252 }
tuple cout
Definition: gather_cfg.py:121
bool L1TRate_Offline::getXSexFitsPython ( const edm::ParameterSet ps)
protected

Definition at line 532 of file L1TRate_Offline.cc.

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

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

Member Data Documentation

DQMStore* L1TRate_Offline::dbe
private

Definition at line 132 of file L1TRate_Offline.h.

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

Definition at line 96 of file L1TRate_Offline.h.

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

Definition at line 97 of file L1TRate_Offline.h.

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

Definition at line 107 of file L1TRate_Offline.h.

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

Definition at line 113 of file L1TRate_Offline.h.

MonitorElement* L1TRate_Offline::m_ErrorMonitor
private

Definition at line 129 of file L1TRate_Offline.h.

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

Definition at line 98 of file L1TRate_Offline.h.

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

Definition at line 108 of file L1TRate_Offline.h.

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

Definition at line 123 of file L1TRate_Offline.h.

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

Definition at line 89 of file L1TRate_Offline.h.

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

Definition at line 118 of file L1TRate_Offline.h.

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

Definition at line 92 of file L1TRate_Offline.h.

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

Definition at line 94 of file L1TRate_Offline.h.

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

Definition at line 93 of file L1TRate_Offline.h.

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

Definition at line 95 of file L1TRate_Offline.h.

int L1TRate_Offline::m_lsShiftGTRates
private

Definition at line 83 of file L1TRate_Offline.h.

int L1TRate_Offline::m_maxNbins
private

Definition at line 82 of file L1TRate_Offline.h.

std::string L1TRate_Offline::m_outputFile
private

Definition at line 86 of file L1TRate_Offline.h.

edm::ParameterSet L1TRate_Offline::m_parameters
private

Definition at line 126 of file L1TRate_Offline.h.

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

Definition at line 109 of file L1TRate_Offline.h.

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

Definition at line 114 of file L1TRate_Offline.h.

int L1TRate_Offline::m_refPrescaleSet
private

Definition at line 81 of file L1TRate_Offline.h.

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

Definition at line 122 of file L1TRate_Offline.h.

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

Definition at line 121 of file L1TRate_Offline.h.

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

Definition at line 99 of file L1TRate_Offline.h.

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

Definition at line 116 of file L1TRate_Offline.h.

bool L1TRate_Offline::m_verbose
private

Definition at line 78 of file L1TRate_Offline.h.

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

Definition at line 100 of file L1TRate_Offline.h.

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

Definition at line 103 of file L1TRate_Offline.h.

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

Definition at line 112 of file L1TRate_Offline.h.

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

Definition at line 104 of file L1TRate_Offline.h.

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

Definition at line 101 of file L1TRate_Offline.h.