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 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
 
typedef WorkerT< EDAnalyzerWorkerType
 

Public Member Functions

 L1TRate_Offline (const edm::ParameterSet &ps)
 
virtual ~L1TRate_Offline ()
 
- Public Member Functions inherited from edm::EDAnalyzer
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) 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)
 
- Protected Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- 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 Member Functions

bool getXSexFitsPython (const edm::ParameterSet &ps)
 

Private Attributes

DQMStoredbe
 
std::map< TString, int > m_algoBit
 
std::map< TString, TF1 * > m_algoFit
 
std::map< TString,
MonitorElement * > 
m_CountsVsLS
 
MonitorElementm_ErrorMonitor
 
std::map< std::string, bool > m_inputCategories
 
std::map< TString,
MonitorElement * > 
m_InstLumiVsLS
 
edm::InputTag m_l1GtDataDaqInputTag
 
const std::vector< std::vector
< int > > * 
m_listsPrescaleFactors
 
std::map< int, std::map
< TString, double > > 
m_lsCounts
 
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
 
int m_refPrescaleSet
 
edm::InputTag m_scalersSource
 
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_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 42 of file L1TRate_Offline.h.

Member Enumeration Documentation

Enumerator
UNKNOWN 
WARNING_PY_MISSING_FIT 

Definition at line 46 of file L1TRate_Offline.h.

Constructor & Destructor Documentation

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

Definition at line 41 of file L1TRate_Offline.cc.

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

41  {
42 
43  m_maxNbins = 2500; // Maximum LS for each run (for binning purposes)
44  m_parameters = ps;
45 
46  // Mapping parameter input variables
47  m_scalersSource = m_parameters.getParameter <InputTag>("inputTagScalersResults");
48  m_l1GtDataDaqInputTag = m_parameters.getParameter <InputTag>("inputTagL1GtDataDaq");
49  m_verbose = m_parameters.getUntrackedParameter<bool> ("verbose",false);
50  m_refPrescaleSet = m_parameters.getParameter <int> ("refPrescaleSet");
51  m_lsShiftGTRates = m_parameters.getUntrackedParameter<int> ("lsShiftGTRates",0);
52 
53  // Getting which categories to monitor
54  ParameterSet Categories = ps.getParameter<ParameterSet>("categories");
55  m_inputCategories["Mu"] = Categories.getUntrackedParameter<bool>("Mu");
56  m_inputCategories["EG"] = Categories.getUntrackedParameter<bool>("EG");
57  m_inputCategories["IsoEG"] = Categories.getUntrackedParameter<bool>("IsoEG");
58  m_inputCategories["Jet"] = Categories.getUntrackedParameter<bool>("Jet");
59  m_inputCategories["CenJet"] = Categories.getUntrackedParameter<bool>("CenJet");
60  m_inputCategories["ForJet"] = Categories.getUntrackedParameter<bool>("ForJet");
61  m_inputCategories["TauJet"] = Categories.getUntrackedParameter<bool>("TauJet");
62  m_inputCategories["ETM"] = Categories.getUntrackedParameter<bool>("ETM");
63  m_inputCategories["ETT"] = Categories.getUntrackedParameter<bool>("ETT");
64  m_inputCategories["HTT"] = Categories.getUntrackedParameter<bool>("HTT");
65  m_inputCategories["HTM"] = Categories.getUntrackedParameter<bool>("HTM");
66 
67  // Inicializing Variables
68  if (m_verbose) {
69  cout << "[L1TRate_Offline:] ____________ Storage inicialization ____________ " << endl;
70  cout << "[L1TRate_Offline:] Setting up dbe folder: L1T/L1TRate_Offline" << endl;
71  }
72 
74  dbe->setVerbose(0);
75  dbe->setCurrentFolder("L1T/L1TRate_Offline");
76 
77  // Inicializing Variables
78  if (m_verbose) {cout << "[L1TRate_Offline:] Pointer for DQM Store: " << dbe << endl;}
79 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
edm::InputTag m_l1GtDataDaqInputTag
edm::ParameterSet m_parameters
void setVerbose(unsigned level)
Definition: DQMStore.cc:398
edm::InputTag m_scalersSource
std::map< std::string, bool > m_inputCategories
tuple cout
Definition: gather_cfg.py:121
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
L1TRate_Offline::~L1TRate_Offline ( )
virtual

Definition at line 82 of file L1TRate_Offline.cc.

82 {}

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 339 of file L1TRate_Offline.cc.

References gather_cfg::cout, edm::Event::getByLabel(), i, edm::EventBase::id(), edm::HandleBase::isValid(), and edm::EventID::luminosityBlock().

339  {
340 
341  edm::Handle<L1GlobalTriggerReadoutRecord> gtReadoutRecordData;
344 
345  iEvent.getByLabel(m_l1GtDataDaqInputTag, gtReadoutRecordData);
346  iEvent.getByLabel(m_scalersSource , colLScal);
347  iEvent.getByLabel(m_scalersSource , triggerScalers);
348 
349  // Integers
350  //int EventRun = iEvent.id().run();
351  unsigned int eventLS = iEvent.id().luminosityBlock();
352 
353  // Getting the trigger trigger rates from GT and buffering it
354  if(triggerScalers.isValid() && triggerScalers->size()){
355 
356  Level1TriggerScalersCollection::const_iterator itL1TScalers = triggerScalers->begin();
357  //Level1TriggerRates trigRates(*itL1TScalers,EventRun);
358 
359  // Trying to get the trigger counts
360  const std::vector<unsigned int> gtAlgoCounts = itL1TScalers->gtAlgoCounts();
361 
362  int gtLS = (*itL1TScalers).lumiSegmentNr()+m_lsShiftGTRates;
363 
364  // If we haven't got the data from this LS yet get it
365  if(m_lsRates.find(gtLS)==m_lsRates.end()){
366 
367  map<TString,double> bufferCount;
368 
369  // Buffer the rate informations for all selected bits
370  for(map<string,string>::const_iterator i=m_selectedTriggers.begin(); i!=m_selectedTriggers.end() ; i++){
371 
372  string tTrigger = (*i).second;
373 
374  // If trigger name is defined we store the rate
375  if(tTrigger != "Undefined"){
376 
377  unsigned int trigBit = m_algoBit[tTrigger];
378  double trigCount = gtAlgoCounts[trigBit];
379 
380  bufferCount[tTrigger] = trigCount;
381 
382  }
383  }
384  m_lsRates[gtLS] = bufferCount;
385  }
386  }
387 
388 
389  // Getting from the SCAL the luminosity information and buffering it
390  if(colLScal.isValid() && colLScal->size()){
391 
392  LumiScalersCollection::const_iterator itLScal = colLScal->begin();
393  unsigned int scalLS = itLScal->sectionNumber();
394 
395  // If we haven't got the data from this SCAL LS yet get it
396  if(m_lsLuminosity.find(scalLS)==m_lsLuminosity.end()){
397 
398  if (m_verbose) {cout << "[L1TRate_Offline:] Buffering SCAL-HF Lumi for LS=" << scalLS << endl;}
399  double instLumi = itLScal->instantLumi(); // Getting Instant Lumi from HF (via SCAL) // <###### WE NEED TO STORE THIS
400  double deadTimeNormHF = itLScal->deadTimeNormalization(); // Getting Dead Time Normalization from HF (via SCAL)
401 
402  // If HF Dead Time Corrections is requested we apply it
403  // NOTE: By default this is assumed false since for now WbM fits do NOT assume this correction
404  if(m_parameters.getUntrackedParameter<bool>("useHFDeadTimeNormalization",false)){
405 
406  // Protecting for deadtime = 0
407  if(deadTimeNormHF==0){instLumi = 0;}
408  else {instLumi = instLumi/deadTimeNormHF;}
409  }
410  // Buffering the luminosity information
411  m_lsLuminosity[scalLS]=instLumi;
412  }
413  }
414 
415  // Getting the prescale index used when this event was triggered
416  if(gtReadoutRecordData.isValid()){
417 
418  // If we haven't got the data from this LS yet get it
419  if(m_lsPrescaleIndex.find(eventLS)==m_lsPrescaleIndex.end()){
420 
421  if (m_verbose) {cout << "[L1TRate_Offline:] Buffering Prescale Index for LS=" << eventLS << endl;}
422 
423  // Getting Final Decision Logic (FDL) Data from GT
424  const vector<L1GtFdlWord>& gtFdlVectorData = gtReadoutRecordData->gtFdlVector();
425 
426  // Getting the index for the fdl data for this event
427  int indexFDL=0;
428  for(unsigned int i=0; i<gtFdlVectorData.size(); i++){
429  if(gtFdlVectorData[i].bxInEvent()==0){indexFDL=i; break;}
430  }
431 
432  int CurrentPrescalesIndex = gtFdlVectorData[indexFDL].gtPrescaleFactorIndexAlgo(); // <###### WE NEED TO STORE THIS
433  m_lsPrescaleIndex[eventLS] = CurrentPrescalesIndex;
434 
435  }
436 
437  }
438 
439 
440 }
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
edm::InputTag m_l1GtDataDaqInputTag
std::map< std::string, std::string > m_selectedTriggers
std::map< int, double > m_lsLuminosity
edm::ParameterSet m_parameters
int iEvent
Definition: GenABIO.cc:243
bool isValid() const
Definition: HandleBase.h:76
edm::InputTag m_scalersSource
std::map< int, int > m_lsPrescaleIndex
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 85 of file L1TRate_Offline.cc.

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

85  {
86 
87  if (m_verbose) {cout << "[L1TRate_Offline:] Called beginJob." << endl;}
88 
89  // get hold of back-end interface
90  DQMStore *dbe = 0;
91  dbe = Service < DQMStore > ().operator->();
92 
93  if (dbe) {
94  dbe->setCurrentFolder("L1T/L1TRate_Offline");
95  dbe->rmdir("L1T/L1TRate_Offline");
96  }
97 
98 }
void rmdir(const std::string &fullpath)
Definition: DQMStore.cc:2535
tuple cout
Definition: gather_cfg.py:121
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
void L1TRate_Offline::beginLuminosityBlock ( edm::LuminosityBlock const &  lumiBlock,
edm::EventSetup const &  c 
)
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 236 of file L1TRate_Offline.cc.

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

236  {
237 
238  if (m_verbose) {cout << "[L1TRate_Offline:] Called beginLuminosityBlock at LS=" << lumiBlock.id().luminosityBlock() << endl;}
239 
240 }
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 115 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.

115  {
116 
117  if (m_verbose) {cout << "[L1TRate_Offline:] Called beginRun." << endl;}
118 
121 
122  iSetup.get<L1GtTriggerMenuRcd>() .get(menuRcd);
123  iSetup.get<L1GtPrescaleFactorsAlgoTrigRcd>().get(l1GtPfAlgo);
124 
125  const L1GtTriggerMenu* menu = menuRcd .product();
126  const L1GtPrescaleFactors* m_l1GtPfAlgo = l1GtPfAlgo.product();
127 
128  // Initializing DQM Monitor Elements
129  dbe->setCurrentFolder("L1T/L1TRate_Offline");
130  m_ErrorMonitor = dbe->book1D("ErrorMonitor", "ErrorMonitor",2,0,2);
131  m_ErrorMonitor->setBinLabel(UNKNOWN ,"UNKNOWN");
132  m_ErrorMonitor->setBinLabel(WARNING_PY_MISSING_FIT,"WARNING_PY_MISSING_FIT");
133 
134  cout << "[L1TRate_Offline:] m_ErrorMonitor: " << m_ErrorMonitor << endl;
135 
136  // Retriving the list of prescale sets
137  m_listsPrescaleFactors = &(m_l1GtPfAlgo->gtPrescaleFactors());
138 
139  // Getting Lowest Prescale Single Object Triggers from the menu
140  L1TMenuHelper myMenuHelper = L1TMenuHelper(iSetup);
142 
143  //-> Getting template fits for the algLo cross sections
145 
146  for (CItAlgo algo = menu->gtAlgorithmMap().begin(); algo!=menu->gtAlgorithmMap().end(); ++algo){
147  m_algoBit[(algo->second).algoAlias()] = (algo->second).algoBitNumber();
148  }
149 
150  double minInstantLuminosity = m_parameters.getParameter<double>("minInstantLuminosity");
151  double maxInstantLuminosity = m_parameters.getParameter<double>("maxInstantLuminosity");
152 
153  // Initializing DQM Monitor Elements
154  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
155 
156  TString tCategory = (*i).first;
157  TString tTrigger = (*i).second;
158 
159  TString tErrorMessage = "";
160  TF1* tTestFunction;
161 
162  if(tTrigger != "Undefined" && m_templateFunctions.find(tTrigger) != m_templateFunctions.end()){
163  tTestFunction = m_templateFunctions[tTrigger];
164  }
165  else if(tTrigger == "Undefined"){
166  TString tFunc = "-1";
167  tTestFunction = new TF1("FitParametrization_"+tTrigger,tFunc,0,double(m_maxNbins)-0.5);
168  }
169  else if(m_templateFunctions.find(tTrigger) == m_templateFunctions.end()){
170  TString tFunc = "-1";
171  tTestFunction = new TF1("FitParametrization_"+tTrigger,tFunc,0,double(m_maxNbins)-0.5);
172  tErrorMessage = " (Undefined Test Function)";
173  }
174  else{
175  TString tFunc = "-1";
176  tTestFunction = new TF1("FitParametrization_"+tTrigger,tFunc,0,double(m_maxNbins)-0.5);
177  }
178 
179  if(tTrigger != "Undefined"){
180 
181  if(myMenuHelper.getPrescaleByAlias(tCategory,tTrigger) != 1){
182  tErrorMessage += " WARNING: Default Prescale = ";
183  tErrorMessage += myMenuHelper.getPrescaleByAlias(tCategory,tTrigger);
184  }
185 
186  if (tCategory == "Mu" && myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger) != 4294967295){ //hexadecimal of the whole range
187  tErrorMessage += " WARNING: Eta Range = ";
188  tErrorMessage += myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger);
189  }
190  else if(tCategory == "EG" && myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger) != 32639){
191  tErrorMessage += " WARNING: Eta Range = ";
192  tErrorMessage += myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger);
193  }
194  else if(tCategory == "IsoEG" && myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger) != 32639){
195  tErrorMessage += " WARNING: Eta Range = ";
196  tErrorMessage += myMenuHelper.getEtaRangeByAlias(tCategory,tTrigger);
197  }
198 
199  if(tCategory == "Mu" && myMenuHelper.getQualityAlias(tCategory,tTrigger) != 240){
200  tErrorMessage += " WARNING: Quality = ";
201  tErrorMessage += myMenuHelper.getQualityAlias(tCategory,tTrigger);
202  }
203 
204  }
205 
206  dbe->setCurrentFolder("L1T/L1TRate_Offline/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_Offline/Ratio");
220  m_xSecObservedToExpected[tTrigger] = dbe->book1D(tCategory, "Algo: "+tTrigger+tErrorMessage,m_maxNbins,-0.5,double(m_maxNbins)-0.5);
221  m_xSecObservedToExpected[tTrigger] ->setAxisTitle("Lumi Section" ,1);
222  m_xSecObservedToExpected[tTrigger] ->setAxisTitle("#sigma_{obs} / #sigma_{exp}" ,2);
223 
224 
225  }
226 
227 }
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:722
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, TF1 * > m_templateFunctions
int getPrescaleByAlias(TString iCategory, TString iAlias)
bool getXSexFitsPython(const edm::ParameterSet &ps)
unsigned int getQualityAlias(TString iCategory, TString iAlias)
AlgorithmMap::const_iterator CItAlgo
iterators through map containing the algorithms
edm::ParameterSet m_parameters
std::map< std::string, std::string > getLUSOTrigger(std::map< std::string, bool > iCategories, int IndexRefPrescaleFactors)
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:1036
std::map< TString, MonitorElement * > m_xSecObservedToExpected
unsigned int getEtaRangeByAlias(TString iCategory, TString iAlias)
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
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
std::map< TString, TF1 * > m_algoFit
void L1TRate_Offline::endJob ( void  )
protectedvirtual

Reimplemented from edm::EDAnalyzer.

Definition at line 101 of file L1TRate_Offline.cc.

References gather_cfg::cout.

101  {
102 
103  if (m_verbose) {cout << "[L1TRate_Offline:] Called endJob." << endl;}
104 
105  if (m_outputFile.size() != 0 && dbe)
107 
108  return;
109 
110 }
void save(const std::string &filename, const std::string &path="", const std::string &pattern="", const std::string &rewrite="", SaveReferenceTag ref=SaveWithReference, int minStatus=dqm::qstatus::STATUS_OK, const std::string &fileupdate="RECREATE")
Definition: DQMStore.cc:2118
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 243 of file L1TRate_Offline.cc.

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

243  {
244 
245  int eventLS = lumiBlock.id().luminosityBlock();
246  if (m_verbose) {cout << "[L1TRate_Offline:] Called endLuminosityBlock at LS=" << eventLS << endl;}
247 
248  // We can certify LS -1 since we should have available:
249  // gt rates: (current LS)-1
250  // prescale: current LS
251  // lumi : current LS
252  //eventLS--;
253 
254  // Checking if all necessary quantities are defined for our calculations
255  //bool isDefRate,isDefLumi,isDefPrescaleIndex;
256  bool isDefLumi,isDefPrescaleIndex;
257  //map<TString,double>* rates=0;
258  double lumi=0;
259  int prescalesIndex=0;
260 
261  bool isDefCount;
262  map<TString,double>* counts=0;
263 
264  // Resetting MonitorElements so we can refill them
265  for(map<string,string>::const_iterator i=m_selectedTriggers.begin() ; i!=m_selectedTriggers.end() ; i++){
266  string tTrigger = (*i).second;
267  m_CountsVsLS [tTrigger]->getTH1()->Reset("ICE");
268  m_xSecObservedToExpected[tTrigger]->getTH1()->Reset("ICE");
269 
270  }
271 
272  //Trying to do the same with Counts....
273  for(map<int,map<TString,double> >::iterator j=m_lsRates.begin() ; j!=m_lsRates.end() ; j++){
274 
275  unsigned int lsOffline = (*j).first;
276  counts = &(*j).second;
277  isDefCount=true;
278 
279  unsigned int lsPreInd;
280 
281  if(m_lsLuminosity.find(lsOffline)==m_lsLuminosity.end()){isDefLumi=false;}
282  else{
283  isDefLumi=true;
284  lumi=m_lsLuminosity[lsOffline];
285  }
286 
287  lsPreInd = lsOffline + 1; // NOTE: Workaround
288 
289  if(m_lsPrescaleIndex.find(lsPreInd)==m_lsPrescaleIndex.end()){isDefPrescaleIndex=false;}
290  else{
291  isDefPrescaleIndex=true;
292  prescalesIndex=m_lsPrescaleIndex[lsPreInd];
293  }
294 
295  if(isDefCount && isDefLumi && isDefPrescaleIndex){
296 
297  //const vector<int>& currentPrescaleFactors = (*m_listsPrescaleFactors).at(prescalesIndex);
298 
299  for(map<string,string>::const_iterator j=m_selectedTriggers.begin() ; j!=m_selectedTriggers.end() ; j++){
300 
301  string tTrigger = (*j).second;
302  double trigCount = (*counts)[tTrigger];
303 
304  // TF1* tTestFunction = (TF1*) m_CountsVsLS[tTrigger]->getTProfile()->GetListOfFunctions()->First();
305  TF1* tTestFunction = m_algoFit[tTrigger]; // NOTE: Workaround....
306 
307 
308  // If trigger name is defined we get the rate fit parameters
309  if(tTrigger != "Undefined"){
310 
311 
312  if(lumi!=0 && trigCount!=0 && prescalesIndex!=0){
313 
314  double AlgoXSec = (prescalesIndex*trigCount)/lumi;
315  double TemplateFunctionValue = tTestFunction->Eval(lumi);
316 
317  // Checking against Template function
318  m_CountsVsLS [tTrigger]->Fill(lumi,AlgoXSec);
319 
320  int ibin = m_xSecObservedToExpected[tTrigger]->getTH1()->FindBin(lsOffline);
321  m_xSecObservedToExpected[tTrigger]->setBinContent(ibin,AlgoXSec/TemplateFunctionValue);
322 
323 
324  }
325  else {
326  m_CountsVsLS [tTrigger]->Fill(0.000001,0.000001);
327 
328  int ibin = m_xSecObservedToExpected[tTrigger]->getTH1()->FindBin(lsOffline);
329  m_xSecObservedToExpected[tTrigger]->setBinContent(ibin,0.000001);
330  }
331  }
332  }
333  }
334  }
335 }
int i
Definition: DBlmapReader.cc:9
std::map< std::string, std::string > m_selectedTriggers
tuple lumi
Definition: fjr2json.py:35
dictionary map
Definition: Association.py:205
std::map< int, double > m_lsLuminosity
int j
Definition: DBlmapReader.cc:9
std::map< TString, MonitorElement * > m_xSecObservedToExpected
std::map< int, int > m_lsPrescaleIndex
std::map< TString, MonitorElement * > m_CountsVsLS
std::map< int, std::map< TString, double > > m_lsRates
tuple cout
Definition: gather_cfg.py:121
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 230 of file L1TRate_Offline.cc.

References gather_cfg::cout.

230  {
231 
232  if (m_verbose) {cout << "[L1TRate_Offline:] Called endRun." << endl;}
233 }
tuple cout
Definition: gather_cfg.py:121
bool L1TRate_Offline::getXSexFitsPython ( const edm::ParameterSet ps)
private

Definition at line 451 of file L1TRate_Offline.cc.

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

451  {
452 
453  // error meaning
454  bool noError = true;
455 
456  // Getting fit parameters
457  std::vector<edm::ParameterSet> m_fitParameters = ps.getParameter< vector<ParameterSet> >("fitParameters");
458 
459  double minInstantLuminosity = m_parameters.getParameter<double>("minInstantLuminosity");
460  double maxInstantLuminosity = m_parameters.getParameter<double>("maxInstantLuminosity");
461 
462  // Getting rate fit parameters for all input triggers
463  for(map<string,string>::const_iterator a=m_selectedTriggers.begin() ; a!=m_selectedTriggers.end() ; a++){
464 
465  string tTrigger = (*a).second;
466 
467  // If trigger name is defined we get the rate fit parameters
468  if(tTrigger != "Undefined"){
469 
470  bool foundFit = false;
471 
472  for(unsigned int b=0 ; b<m_fitParameters.size() ; b++){
473 
474  if(tTrigger == m_fitParameters[b].getParameter<string>("AlgoName")){
475 
476  TString tAlgoName = m_fitParameters[b].getParameter< string > ("AlgoName");
477  TString tTemplateFunction = m_fitParameters[b].getParameter< string > ("TemplateFunction");
478  vector<double> tParameters = m_fitParameters[b].getParameter< vector<double> >("Parameters");
479 
480  // Retriving and populating the m_templateFunctions array
481  m_templateFunctions[tTrigger] = new TF1("FitParametrization_"+tAlgoName,tTemplateFunction,
482  minInstantLuminosity,maxInstantLuminosity);
483  m_templateFunctions[tTrigger] ->SetParameters(&tParameters[0]);
484  m_templateFunctions[tTrigger] ->SetLineWidth(1);
485  m_templateFunctions[tTrigger] ->SetLineColor(kRed);
486 
487  foundFit = true;
488  break;
489  }
490 
491  if(!foundFit){
492 
493  noError = false;
494 
495  int eCount = m_ErrorMonitor->getTH1()->GetBinContent(WARNING_PY_MISSING_FIT);
496  eCount++;
497  m_ErrorMonitor->getTH1()->SetBinContent(WARNING_PY_MISSING_FIT,eCount);
498 
499  }
500  }
501  }
502  }
503 
504  return noError;
505 
506 }
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 120 of file L1TRate_Offline.h.

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

Definition at line 94 of file L1TRate_Offline.h.

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

Definition at line 95 of file L1TRate_Offline.h.

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

Definition at line 101 of file L1TRate_Offline.h.

MonitorElement* L1TRate_Offline::m_ErrorMonitor
private

Definition at line 117 of file L1TRate_Offline.h.

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

Definition at line 96 of file L1TRate_Offline.h.

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

Definition at line 102 of file L1TRate_Offline.h.

edm::InputTag L1TRate_Offline::m_l1GtDataDaqInputTag
private

Definition at line 111 of file L1TRate_Offline.h.

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

Definition at line 88 of file L1TRate_Offline.h.

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

Definition at line 107 of file L1TRate_Offline.h.

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

Definition at line 92 of file L1TRate_Offline.h.

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

Definition at line 91 of file L1TRate_Offline.h.

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

Definition at line 93 of file L1TRate_Offline.h.

int L1TRate_Offline::m_lsShiftGTRates
private

Definition at line 82 of file L1TRate_Offline.h.

int L1TRate_Offline::m_maxNbins
private

Definition at line 81 of file L1TRate_Offline.h.

std::string L1TRate_Offline::m_outputFile
private

Definition at line 85 of file L1TRate_Offline.h.

edm::ParameterSet L1TRate_Offline::m_parameters
private

Definition at line 114 of file L1TRate_Offline.h.

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

Definition at line 103 of file L1TRate_Offline.h.

int L1TRate_Offline::m_refPrescaleSet
private

Definition at line 80 of file L1TRate_Offline.h.

edm::InputTag L1TRate_Offline::m_scalersSource
private

Definition at line 110 of file L1TRate_Offline.h.

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

Definition at line 97 of file L1TRate_Offline.h.

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

Definition at line 105 of file L1TRate_Offline.h.

bool L1TRate_Offline::m_verbose
private

Definition at line 77 of file L1TRate_Offline.h.

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

Definition at line 98 of file L1TRate_Offline.h.

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

Definition at line 99 of file L1TRate_Offline.h.