test
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 22 of file L1TRate_Offline.cc.

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

22  {
23 
24  m_maxNbins = 2500; // Maximum LS for each run (for binning purposes)
25  m_parameters = ps;
26 
27  // Mapping parameter input variables
28  m_scalersSource_LSCollection = consumes<LumiScalersCollection> (m_parameters.getParameter<InputTag>("inputTagScalersResults"));
29  m_scalersSource_L1TSCollection = consumes<Level1TriggerScalersCollection>(m_parameters.getParameter<InputTag>("inputTagScalersResults"));
30  m_l1GtDataDaqInputTag = consumes<L1GlobalTriggerReadoutRecord> (m_parameters.getParameter<InputTag>("inputTagL1GtDataDaq"));
31  m_verbose = m_parameters.getUntrackedParameter<bool>("verbose",false);
32  m_refPrescaleSet = m_parameters.getParameter <int> ("refPrescaleSet");
33  m_lsShiftGTRates = m_parameters.getUntrackedParameter<int> ("lsShiftGTRates",0);
34 
35  // Getting which categories to monitor
36  ParameterSet Categories = ps.getParameter<ParameterSet>("categories");
37  m_inputCategories["Mu"] = Categories.getUntrackedParameter<bool>("Mu");
38  m_inputCategories["EG"] = Categories.getUntrackedParameter<bool>("EG");
39  m_inputCategories["IsoEG"] = Categories.getUntrackedParameter<bool>("IsoEG");
40  m_inputCategories["Jet"] = Categories.getUntrackedParameter<bool>("Jet");
41  m_inputCategories["CenJet"] = Categories.getUntrackedParameter<bool>("CenJet");
42  m_inputCategories["ForJet"] = Categories.getUntrackedParameter<bool>("ForJet");
43  m_inputCategories["TauJet"] = Categories.getUntrackedParameter<bool>("TauJet");
44  m_inputCategories["ETM"] = Categories.getUntrackedParameter<bool>("ETM");
45  m_inputCategories["ETT"] = Categories.getUntrackedParameter<bool>("ETT");
46  m_inputCategories["HTT"] = Categories.getUntrackedParameter<bool>("HTT");
47  m_inputCategories["HTM"] = Categories.getUntrackedParameter<bool>("HTM");
48 
49  // Initializing Variables
50  if (m_verbose) {
51  cout << "[L1TRate_Offline:] ____________ Storage initialization ____________ " << endl;
52  cout << "[L1TRate_Offline:] Setting up dbe folder: L1T/L1TRate" << endl;
53  }
54 
56  dbe->setVerbose(0);
57  dbe->setCurrentFolder("L1T/L1TRate");
58 
59  // Inicializing Variables
60  if (m_verbose) {cout << "[L1TRate_Offline:] Pointer for DQM Store: " << dbe << endl;}
61 }
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
void setVerbose(unsigned level)
Definition: DQMStore.cc:631
std::map< std::string, bool > m_inputCategories
edm::EDGetTokenT< LumiScalersCollection > m_scalersSource_LSCollection
tuple cout
Definition: gather_cfg.py:121
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
L1TRate_Offline::~L1TRate_Offline ( )
virtual

Definition at line 64 of file L1TRate_Offline.cc.

64 {}

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 391 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().

391  {
392 
393  edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecordData;
396 
397  iEvent.getByToken(m_l1GtDataDaqInputTag , gtReadoutRecordData);
398  iEvent.getByToken(m_scalersSource_LSCollection , colLScal);
399  iEvent.getByToken(m_scalersSource_L1TSCollection , triggerScalers);
400 
401  // Integers
402  int EventRun = iEvent.id().run();
403  unsigned int eventLS = iEvent.id().luminosityBlock();
404 
405  // Getting the trigger trigger rates from GT and buffering it
406  if(triggerScalers.isValid() && triggerScalers->size()){
407 
408  Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
409  Level1TriggerRates trigRates(*itL1TScalers,EventRun);
410 
411  //Trying to retrieve GT DeadTime
412  //unsigned long long deadtime = itL1TScalers->deadtime();
413  //double deadtime = itL1TScalers->deadtime();
414  double deadtime = trigRates.deadtimePercent(); //correct DeadTime % to retrieve
415 
416  // Trying to get the trigger counts
417  const std::vector<unsigned int> gtAlgoCounts = itL1TScalers->gtAlgoCounts();
418 
419  // int lumisegment = (*itL1TScalers).lumiSegmentNr();
420 
421 // cout << "deadtime =" << deadtime << " --
422 // cout << "lumisegment = " << lumisegment << endl;
423 
424  int gtLS = (*itL1TScalers).lumiSegmentNr()+m_lsShiftGTRates;
425 
426  // If we haven't got the data from this LS yet get it
427  if(m_lsRates.find(gtLS)==m_lsRates.end()){
428 
429  map<TString,double> bufferCount;
430 
431  // Buffer the rate informations for all selected bits
432  for(map<string,string>::const_iterator i=m_selectedTriggers.begin(); i!=m_selectedTriggers.end() ; i++){
433 
434  string tTrigger = (*i).second;
435 
436  // If trigger name is defined we store the rate
437  if(tTrigger != "Undefined"){
438 
439  unsigned int trigBit = m_algoBit[tTrigger];
440  double trigCount = gtAlgoCounts[trigBit];
441 
442  bufferCount[tTrigger] = trigCount;
443 
444  }
445  }
446  m_lsRates[gtLS] = bufferCount;
447  m_lsDeadTime[gtLS] = deadtime;
448  }
449  }
450 
451 
452  // Getting from the SCAL the luminosity information and buffering it
453  if(colLScal.isValid() && colLScal->size()){
454 
455  LumiScalersCollection::const_iterator itLScal = colLScal->begin();
456  unsigned int scalLS = itLScal->sectionNumber();
457 
458  // If we haven't got the data from this SCAL LS yet get it
459  if(m_lsLuminosity.find(scalLS)==m_lsLuminosity.end()){
460 
461  if (m_verbose) {cout << "[L1TRate_Offline:] Buffering SCAL-HF Lumi for LS=" << scalLS << endl;}
462  double instLumi = itLScal->instantLumi(); // Getting Instant Lumi from HF (via SCAL) // <###### WE NEED TO STORE THIS
463  double deadTimeNormHF = itLScal->deadTimeNormalization(); // Getting Dead Time Normalization from HF (via SCAL)
464 
465 // double mylumiFill = itLScal->lumiFill(); // Integrated lumi since beginning of fill, delivered
466 // double mylumiRun = itLScal->lumiRun(); // Integrated lumi since beginning of run, delivered
467 // double myliveLumiFill = itLScal->liveLumiFill(); // Integrated lumi since beginning of fill, live
468 // double myliveLumiRun = itLScal->liveLumiRun(); // Integrated lumi since beginning of run, live
469 // double mysectionNumber = itLScal->sectionNumber(); // Lumi section number for this info
470 // double mynumOrbits = itLScal->numOrbits(); // Number of orbits that have passed this run
471 
472 // cout << "instantLumi = " << instLumi << endl;
473 // cout << "lumiFill = " << mylumiFill << endl;
474 // cout << "lumiRun = " << mylumiRun << endl;
475 // cout << "livelumiFill = " << myliveLumiFill << endl;
476 // cout << "livelumiRun = " << myliveLumiRun << endl;
477 // cout << "sectionNumber = " << mysectionNumber << endl;
478 // cout << "numOrbits = " << mynumOrbits << endl;
479 
480 
481  // If HF Dead Time Corrections is requested we apply it
482  // NOTE: By default this is assumed false since for now WbM fits do NOT assume this correction
483  if(m_parameters.getUntrackedParameter<bool>("useHFDeadTimeNormalization",false)){
484 
485  // Protecting for deadtime = 0
486  if(deadTimeNormHF==0){instLumi = 0;}
487  else {instLumi = instLumi/deadTimeNormHF;}
488  }
489  // Buffering the luminosity information
490  m_lsLuminosity[scalLS]=instLumi;
491  }
492  }
493 
494  // Getting the prescale index used when this event was triggered
495  if(gtReadoutRecordData.isValid()){
496 
497  // If we haven't got the data from this LS yet get it
498  if(m_lsPrescaleIndex.find(eventLS)==m_lsPrescaleIndex.end()){
499 
500  if (m_verbose) {cout << "[L1TRate_Offline:] Buffering Prescale Index for LS=" << eventLS << endl;}
501 
502  // Getting Final Decision Logic (FDL) Data from GT
503  const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->gtFdlVector();
504 
505  // Getting the index for the fdl data for this event
506  int indexFDL=0;
507  for(unsigned int i=0; i<gtFdlVectorData.size(); i++){
508  if(gtFdlVectorData[i].bxInEvent()==0){indexFDL=i; break;}
509  }
510 
511  int CurrentPrescalesIndex = gtFdlVectorData[indexFDL].gtPrescaleFactorIndexAlgo(); // <###### WE NEED TO STORE THIS
512  m_lsPrescaleIndex[eventLS] = CurrentPrescalesIndex;
513 
514  }
515 
516  }
517 
518 
519 }
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 67 of file L1TRate_Offline.cc.

References gather_cfg::cout, cppFunctionSkipper::operator, DQMStore::rmdir(), and DQMStore::setCurrentFolder().

67  {
68 
69  if (m_verbose) {cout << "[L1TRate_Offline:] Called beginJob." << endl;}
70 
71  // get hold of back-end interface
72  DQMStore *dbe = 0;
73  dbe = Service < DQMStore > ().operator->();
74 
75  if (dbe) {
76  dbe->setCurrentFolder("L1T/L1TRate");
77  dbe->rmdir("L1T/L1TRate");
78  }
79 
80 }
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:3101
tuple cout
Definition: gather_cfg.py:121
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
void L1TRate_Offline::beginLuminosityBlock ( edm::LuminosityBlock const &  lumiBlock,
edm::EventSetup const &  c 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 255 of file L1TRate_Offline.cc.

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

255  {
256 
257  if (m_verbose) {cout << "[L1TRate_Offline:] Called beginLuminosityBlock at LS=" << lumiBlock.id().luminosityBlock() << endl;}
258 
259 }
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 97 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.

97  {
98 
99  if (m_verbose) {cout << "[L1TRate_Offline:] Called beginRun." << endl;}
100 
103 
104  iSetup.get<L1GtTriggerMenuRcd>() .get(menuRcd);
105  iSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().get(l1GtPfAlgo);
106 
107  const L1GtTriggerMenu* menu = menuRcd .product();
108  const L1GtPrescaleFactors* m_l1GtPfAlgo = l1GtPfAlgo.product();
109 
110  // Initializing DQM Monitor Elements
111  dbe->setCurrentFolder("L1T/L1TRate");
112  m_ErrorMonitor = dbe->book1D("ErrorMonitor", "ErrorMonitor",2,0,2);
113  m_ErrorMonitor->setBinLabel(UNKNOWN ,"UNKNOWN");
114  m_ErrorMonitor->setBinLabel(WARNING_PY_MISSING_FIT,"WARNING_PY_MISSING_FIT");
115 
116  cout << "[L1TRate_Offline:] m_ErrorMonitor: " << m_ErrorMonitor << endl;
117 
118  // Retriving the list of prescale sets
119  m_listsPrescaleFactors = &(m_l1GtPfAlgo->gtPrescaleFactors());
120 
121  // Getting Lowest Prescale Single Object Triggers from the menu
122  L1TMenuHelper myMenuHelper = L1TMenuHelper(iSetup);
124 
125  //-> Getting template fits for the algLo cross sections
127 
128  for (CItAlgo algo = menu->gtAlgorithmMap().begin(); algo!=menu->gtAlgorithmMap().end(); ++algo){
129  m_algoBit[(algo->second).algoAlias()] = (algo->second).algoBitNumber();
130  }
131 
132  double minInstantLuminosity = m_parameters.getParameter<double>("minInstantLuminosity");
133  double maxInstantLuminosity = m_parameters.getParameter<double>("maxInstantLuminosity");
134 
135  // Initializing DQM Monitor Elements
136  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
137 
138  TString tCategory = (*i).first;
139  TString tTrigger = (*i).second;
140 
141  TString tErrorMessage = "";
142  TF1* tTestFunction;
143 
144  if(tTrigger != "Undefined" && m_templateFunctions.find(tTrigger) != m_templateFunctions.end()){
145  tTestFunction = m_templateFunctions[tTrigger];
146  }
147  else if(tTrigger == "Undefined"){
148  TString tFunc = "-1";
149  tTestFunction = new TF1("FitParametrization_"+tTrigger,tFunc,0,double(m_maxNbins)-0.5);
150  }
151  else if(m_templateFunctions.find(tTrigger) == m_templateFunctions.end()){
152  TString tFunc = "-1";
153  tTestFunction = new TF1("FitParametrization_"+tTrigger,tFunc,0,double(m_maxNbins)-0.5);
154  tErrorMessage = " (Undefined Test Function)";
155  }
156  else{
157  TString tFunc = "-1";
158  tTestFunction = new TF1("FitParametrization_"+tTrigger,tFunc,0,double(m_maxNbins)-0.5);
159  }
160 
161  if(tTrigger != "Undefined"){
162 
163  if(myMenuHelper.getPrescaleByAlias(tCategory,tTrigger) != 1){
164  tErrorMessage += " WARNING: Default Prescale = ";
165  tErrorMessage += myMenuHelper.getPrescaleByAlias(tCategory,tTrigger);
166  }
167 
168  if (tCategory == "Mu" && myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger) != 4294967295){ //hexadecimal of the whole range
169  tErrorMessage += " WARNING: Eta Range = ";
170  tErrorMessage += myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger);
171  }
172  else if(tCategory == "EG" && myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger) != 32639){
173  tErrorMessage += " WARNING: Eta Range = ";
174  tErrorMessage += myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger);
175  }
176  else if(tCategory == "IsoEG" && myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger) != 32639){
177  tErrorMessage += " WARNING: Eta Range = ";
178  tErrorMessage += myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger);
179  }
180 
181  if(tCategory == "Mu" && myMenuHelper.getQualityAlias(tCategory,tTrigger) != 240){
182  tErrorMessage += " WARNING: Quality = ";
183  tErrorMessage += myMenuHelper.getQualityAlias(tCategory,tTrigger);
184  }
185 
186  }
187 
188  dbe->setCurrentFolder("L1T/L1TRate/xSecDelivLumi"); // trigger counts...
189  m_xSecObservedVsDelivLumi[tTrigger] = dbe->bookProfile(tCategory,
190  "Cross Sec. vs Deliv. Lumi: "+tTrigger+tErrorMessage,
191  m_maxNbins,
192  minInstantLuminosity,
193  maxInstantLuminosity,0,500);
194  m_xSecObservedVsDelivLumi[tTrigger] ->setAxisTitle("Delivered Luminosity [10^{30}cm^{-2}s^{-1}]" ,1);
195  m_xSecObservedVsDelivLumi[tTrigger] ->setAxisTitle("Algorithm #sigma [#mu b]" ,2);
196 
197  dbe->setCurrentFolder("L1T/L1TRate/xSecRecorLumi"); // trigger counts...
198  m_xSecObservedVsRecorLumi[tTrigger] = dbe->bookProfile(tCategory,
199  "Cross Sec. vs Recor. Lumi: "+tTrigger+tErrorMessage,
200  m_maxNbins,
201  minInstantLuminosity,
202  maxInstantLuminosity,0,500);
203  m_xSecObservedVsRecorLumi[tTrigger] ->setAxisTitle("Recorded Luminosity [10^{30}cm^{-2}s^{-1}]" ,1);
204  m_xSecObservedVsRecorLumi[tTrigger] ->setAxisTitle("Algorithm #sigma [#mu b]" ,2);
205 
206  dbe->setCurrentFolder("L1T/L1TRate/TriggerCounts"); // trigger counts...
207  m_CountsVsLS[tTrigger] = dbe->bookProfile(tCategory,
208  "Cross Sec. vs Inst. Lumi Algo: "+tTrigger+tErrorMessage,
209  m_maxNbins,
210  minInstantLuminosity,
211  maxInstantLuminosity,0,500);
212  m_CountsVsLS[tTrigger] ->setAxisTitle("Instantaneous Luminosity [10^{30}cm^{-2}s^{-1}]" ,1);
213  m_CountsVsLS[tTrigger] ->setAxisTitle("Algorithm #sigma [#mu b]" ,2);
214  m_CountsVsLS[tTrigger] ->getTProfile()->GetListOfFunctions()->Add(tTestFunction);
215  m_CountsVsLS[tTrigger] ->getTProfile()->SetMarkerStyle(23);
216 
217  m_algoFit[tTrigger] = (TF1*) tTestFunction->Clone("Fit_"+tTrigger); // NOTE: Workaround
218 
219  dbe->setCurrentFolder("L1T/L1TRate/xSecObs");
220  m_xSecObservedVsLS[tTrigger] = dbe->book1D(tCategory, "Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,double(m_maxNbins)-0.5);
221  m_xSecObservedVsLS[tTrigger] ->setAxisTitle("Lumi Section" ,1);
222  m_xSecObservedVsLS[tTrigger] ->setAxisTitle("#sigma_{obs}" ,2);
223 
224  dbe->setCurrentFolder("L1T/L1TRate/Delivered");
225  m_DelivLumiVsLS[tTrigger] = dbe->book1D(tCategory, "Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,double(m_maxNbins)-0.5);
226  m_DelivLumiVsLS[tTrigger] ->setAxisTitle("Lumi Section" ,1);
227  m_DelivLumiVsLS[tTrigger] ->setAxisTitle("Deliv. Lumi" ,2);
228 
229  dbe->setCurrentFolder("L1T/L1TRate/Recorded");
230  m_RecorLumiVsLS[tTrigger] = dbe->book1D(tCategory, "Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,double(m_maxNbins)-0.5);
231  m_RecorLumiVsLS[tTrigger] ->setAxisTitle("Lumi Section" ,1);
232  m_RecorLumiVsLS[tTrigger] ->setAxisTitle("Recor. Lumi" ,2);
233 
234  dbe->setCurrentFolder("L1T/L1TRate/Ratio");
235  m_xSecObservedToExpected[tTrigger] = dbe->book1D(tCategory, "Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,double(m_maxNbins)-0.5);
236  m_xSecObservedToExpected[tTrigger] ->setAxisTitle("Lumi Section" ,1);
237  m_xSecObservedToExpected[tTrigger] ->setAxisTitle("#sigma_{obs} / #sigma_{exp}" ,2);
238 
239 // dbe->setCurrentFolder("L1T/L1TRate/DeadTime");
240 // m_DeadTimeVsLS[tTrigger] = dbe->book1D(tCategory, "Dead Time: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,double(m_maxNbins)-0.5);
241 // m_DeadTimeVsLS[tTrigger] ->setAxisTitle("Lumi Section" ,1);
242 // m_DeadTimeVsLS[tTrigger] ->setAxisTitle("Dead Time" ,2);
243 
244  }
245 
246 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
MonitorElement * m_ErrorMonitor
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:954
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
std::map< std::string, std::string > getLUSOTrigger(const std::map< std::string, bool > &iCategories, int IndexRefPrescaleFactors)
edm::ParameterSet m_parameters
std::map< TString, MonitorElement * > m_xSecObservedVsDelivLumi
MonitorElement * bookProfile(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const char *option="s")
Definition: DQMStore.cc:1268
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
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
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)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:667
std::map< TString, TF1 * > m_algoFit
void L1TRate_Offline::endJob ( void  )
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 83 of file L1TRate_Offline.cc.

References gather_cfg::cout.

83  {
84 
85  if (m_verbose) {cout << "[L1TRate_Offline:] Called endJob." << endl;}
86 
87  if (m_outputFile.size() != 0 && dbe)
89 
90  return;
91 
92 }
std::string m_outputFile
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", const uint32_t run=0, const uint32_t lumi=0, SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE", const bool resetMEsAfterWriting=false)
Definition: DQMStore.cc:2540
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 262 of file L1TRate_Offline.cc.

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

262  {
263 
264  int eventLS = lumiBlock.id().luminosityBlock();
265  if (m_verbose) {cout << "[L1TRate_Offline:] Called endLuminosityBlock at LS=" << eventLS << endl;}
266 
267  // We can certify LS -1 since we should have available:
268  // gt rates: (current LS)-1
269  // prescale: current LS
270  // lumi : current LS
271  //eventLS--;
272 
273  // Checking if all necessary quantities are defined for our calculations
274  //bool isDefRate,isDefLumi,isDefPrescaleIndex;
275  bool isDefLumi,isDefPrescaleIndex;
276  //map<TString,double>* rates=0;
277  double lumi=0;
278  double deadtime=0;
279  int prescalesIndex=0;
280 
281  bool isDefCount;
282  map<TString,double>* counts=0;
283 
284  // Resetting MonitorElements so we can refill them
285  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
286  string tTrigger = (*i).second;
287  // m_DeadTimeVsLS [tTrigger]->getTH1()->Reset("ICE");
288  m_CountsVsLS [tTrigger]->getTH1()->Reset("ICE");
289  m_xSecObservedToExpected[tTrigger]->getTH1()->Reset("ICE");
290 
291  m_xSecObservedVsLS [tTrigger]->getTH1()->Reset("ICE");
292  m_DelivLumiVsLS [tTrigger]->getTH1()->Reset("ICE");
293  m_RecorLumiVsLS [tTrigger]->getTH1()->Reset("ICE");
294 
295  m_xSecObservedVsDelivLumi[tTrigger]->getTH1()->Reset("ICE");
296  m_xSecObservedVsRecorLumi[tTrigger]->getTH1()->Reset("ICE");
297 
298  }
299 
300  //Trying to do the same with Counts....
301  for(map<int,map<TString,double> >::iterator j=m_lsRates.begin() ; j!=m_lsRates.end() ; j++){
302 
303  unsigned int lsOffline = (*j).first;
304  counts = &(*j).second;
305  isDefCount=true;
306 
307  unsigned int lsPreInd;
308 
309  if(m_lsLuminosity.find(lsOffline)==m_lsLuminosity.end()){isDefLumi=false;}
310  else{
311  isDefLumi=true;
312  lumi=m_lsLuminosity[lsOffline];
313  deadtime=m_lsDeadTime[lsOffline];
314  }
315 
316  lsPreInd = lsOffline + 1; // NOTE: Workaround
317 
318  if(m_lsPrescaleIndex.find(lsPreInd)==m_lsPrescaleIndex.end()){isDefPrescaleIndex=false;}
319  else{
320  isDefPrescaleIndex=true;
321  prescalesIndex=m_lsPrescaleIndex[lsPreInd];
322  }
323 
324  if(isDefCount && isDefLumi && isDefPrescaleIndex){
325 
326  const vector<int>& currentPrescaleFactors = (*m_listsPrescaleFactors).at(prescalesIndex);
327 
328  for(map<string,string>::const_iterator j=m_selectedTriggers.begin() ; j!=m_selectedTriggers.end() ; j++){
329 
330  string tTrigger = (*j).second;
331  double trigCount = (*counts)[tTrigger];
332 
333  // TF1* tTestFunction = (TF1*) m_CountsVsLS[tTrigger]->getTProfile()->GetListOfFunctions()->First();
334  TF1* tTestFunction = m_algoFit[tTrigger]; // NOTE: Workaround....
335 
336 
337  // If trigger name is defined we get the rate fit parameters
338  if(tTrigger != "Undefined"){
339 
340  unsigned int trigBit = m_algoBit[tTrigger];
341  double trigPrescale = currentPrescaleFactors[trigBit];
342 
343  if(lumi!=0 && trigCount!=0 && trigPrescale!=0){
344 
345  double RecLumi = lumi*(1. - deadtime/100.);
346 
347  double AlgoXSec = (trigPrescale*trigCount)/RecLumi;
348  double TemplateFunctionValue = tTestFunction->Eval(lumi);
349 
350 
351  // Checking against Template function
352  // m_DeadTimeVsLS [tTrigger]->Fill(lumi,deadtime);
353 
354 
355  m_xSecObservedVsRecorLumi[tTrigger]->Fill(RecLumi,AlgoXSec);
356 
357  m_CountsVsLS [tTrigger]->Fill(lumi,AlgoXSec);
358 
359  int ibin = m_xSecObservedToExpected[tTrigger]->getTH1()->FindBin(lsOffline);
360  m_xSecObservedToExpected[tTrigger]->setBinContent(ibin,AlgoXSec/TemplateFunctionValue);
361 
362  m_DelivLumiVsLS[tTrigger]->setBinContent(ibin,lumi);
363  m_RecorLumiVsLS[tTrigger]->setBinContent(ibin,RecLumi);
364 
365  m_xSecObservedVsLS[tTrigger]->setBinContent(ibin,AlgoXSec);
366 
367  }
368  else {
369  // m_DeadTimeVsLS [tTrigger]->Fill(0.000001,0.000001);
370 
371  m_xSecObservedVsRecorLumi[tTrigger]->Fill(0.000001,0.000001);
372 
373  m_CountsVsLS [tTrigger]->Fill(0.000001,0.000001);
374 
375  int ibin = m_xSecObservedToExpected[tTrigger]->getTH1()->FindBin(lsOffline);
376  m_xSecObservedToExpected[tTrigger]->setBinContent(ibin,0.000001);
377 
378  m_DelivLumiVsLS[tTrigger]->setBinContent(ibin,0.000001);
379  m_RecorLumiVsLS[tTrigger]->setBinContent(ibin,0.000001);
380 
381  m_xSecObservedVsLS[tTrigger]->setBinContent(ibin,0.000001);
382  }
383  }
384  }
385  }
386  }
387 }
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 249 of file L1TRate_Offline.cc.

References gather_cfg::cout.

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

Definition at line 530 of file L1TRate_Offline.cc.

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

530  {
531 
532  // error meaning
533  bool noError = true;
534 
535  // Getting fit parameters
536  std::vector<edm::ParameterSet> m_fitParameters = ps.getParameter< vector<ParameterSet> >("fitParameters");
537 
538  double minInstantLuminosity = m_parameters.getParameter<double>("minInstantLuminosity");
539  double maxInstantLuminosity = m_parameters.getParameter<double>("maxInstantLuminosity");
540 
541  // Getting rate fit parameters for all input triggers
542  for(map<string,string>::const_iterator a=m_selectedTriggers.begin() ; a!=m_selectedTriggers.end() ; a++){
543 
544  string tTrigger = (*a).second;
545 
546  // If trigger name is defined we get the rate fit parameters
547  if(tTrigger != "Undefined"){
548 
549  bool foundFit = false;
550 
551  for(unsigned int b=0 ; b<m_fitParameters.size() ; b++){
552 
553  if(tTrigger == m_fitParameters[b].getParameter<string>("AlgoName")){
554 
555  TString tAlgoName = m_fitParameters[b].getParameter< string > ("AlgoName");
556  TString tTemplateFunction = m_fitParameters[b].getParameter< string > ("TemplateFunction");
557  vector<double> tParameters = m_fitParameters[b].getParameter< vector<double> >("Parameters");
558 
559  // Retriving and populating the m_templateFunctions array
560  m_templateFunctions[tTrigger] = new TF1("FitParametrization_"+tAlgoName,tTemplateFunction,
561  minInstantLuminosity,maxInstantLuminosity);
562  m_templateFunctions[tTrigger] ->SetParameters(&tParameters[0]);
563  m_templateFunctions[tTrigger] ->SetLineWidth(1);
564  m_templateFunctions[tTrigger] ->SetLineColor(kRed);
565 
566  foundFit = true;
567  break;
568  }
569 
570  if(!foundFit){
571 
572  noError = false;
573 
574  int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_PY_MISSING_FIT);
575  eCount++;
576  m_ErrorMonitor->getTH1()->SetBinContent(WARNING_PY_MISSING_FIT,eCount);
577 
578  }
579  }
580  }
581  }
582 
583  return noError;
584 
585 }
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.