CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ElectronDqmAnalyzerBase.cc
Go to the documentation of this file.
1 
3 //#include "DQMServices/Core/interface/DQMStore.h"
8 #include "TMath.h"
9 #include "TFile.h"
10 #include "TH1F.h"
11 #include "TH1I.h"
12 #include "TH2F.h"
13 #include "TProfile.h"
14 #include "TTree.h"
15 #include <iostream>
16 #include <algorithm>
17 #include <sstream>
18 
20  : bookPrefix_("ele"), bookIndex_(0), histoNamesReady(false), finalDone_(false)
21  {
22  verbosity_ = conf.getUntrackedParameter<int>("Verbosity") ;
23  finalStep_ = conf.getParameter<std::string>("FinalStep") ;
24  inputFile_ = conf.getParameter<std::string>("InputFile") ;
25  outputFile_ = conf.getParameter<std::string>("OutputFile") ;
26  inputInternalPath_ = conf.getParameter<std::string>("InputFolderName") ;
27  outputInternalPath_ = conf.getParameter<std::string>("OutputFolderName") ;
28 
29  }
30 
32  {}
33 
35  { bookPrefix_ = prefix ; }
36 
38  { bookIndex_ = index ; }
39 
41  { bookEfficiencyFlag_ = eff_flag ;}
42 
43 void ElectronDqmAnalyzerBase::setBookStatOverflowFlag( const bool & statOverflow_flag )
44  { bookStatOverflowFlag_ = statOverflow_flag ;}
45 
47  {
48  if (bookPrefix_.empty())
49  { return name ; }
50  std::ostringstream oss ;
51  oss<<bookPrefix_ ;
52  if (bookIndex_>=0)
53  { oss<<bookIndex_++ ; }
54  oss<<"_"<<name ;
55  return oss.str() ;
56  }
57 
59  {
60  }
61 
63  {
64  if (finalStep_=="AtRunEnd")
65  {
66  if (finalDone_)
67  { edm::LogWarning("ElectronDqmAnalyzerBase::endRun")<<"finalize() already called" ; }
68  finalDone_ = true ;
69 
70  // --- transfert from endJob()
71  if (outputFile_!="")
72  {
73 // edm::LogWarning("ElectronDqmAnalyzerBase::endRun")<<"finalize() already called" ;
74  }
75  }
76  }
77 
79  {
80  if (finalStep_=="AtLumiEnd")
81  {
82  if (finalDone_)
83  { edm::LogWarning("ElectronDqmAnalyzerBase::endLuminosityBlock")<<"finalize() already called" ; }
84  finalDone_ = true ;
85  }
86  }
87 
89 {
90  edm::LogInfo("DQMAnalyzeBase::bookHistograms") << std::endl;
91 
92 }
93 
95  ( DQMStore::IBooker & iBooker, const std::string & name, const std::string & title,
96  int nchX, double lowX, double highX,
97  const std::string & titleX, const std::string & titleY,
98  Option_t * option )
99  {
100  iBooker.setCurrentFolder(outputInternalPath_);
101  MonitorElement * me = iBooker.book1D(newName(name),title,nchX,lowX,highX) ;
102  if (titleX!="") { me->getTH1F()->GetXaxis()->SetTitle(titleX.c_str()) ; }
103  if (titleY!="") { me->getTH1F()->GetYaxis()->SetTitle(titleY.c_str()) ; }
104  if (TString(option)!="") { me->getTH1F()->SetOption(option) ; }
105  if (bookStatOverflowFlag_) {me->getTH1()->StatOverflows(kTRUE) ; }
106  return me ;
107  }
108 
110  ( DQMStore::IBooker & iBooker, const std::string & name, const std::string & title,
111  int nchX, double lowX, double highX,
112  const std::string & titleX, const std::string & titleY,
113  Option_t * option )
114  {
115  iBooker.setCurrentFolder(outputInternalPath_);
116  MonitorElement * me = iBooker.book1D(newName(name),title,nchX,lowX,highX) ;
117  if (me->getTH1F()->GetSumw2N() == 0) me->getTH1F()->Sumw2() ;
118  if (titleX!="") { me->getTH1F()->GetXaxis()->SetTitle(titleX.c_str()) ; }
119  if (titleY!="") { me->getTH1F()->GetYaxis()->SetTitle(titleY.c_str()) ; }
120  if (TString(option)!="") { me->getTH1F()->SetOption(option) ; }
121  if (bookStatOverflowFlag_) {me->getTH1()->StatOverflows(kTRUE) ; }
122  return me ;
123  }
124 
126  ( DQMStore::IBooker & iBooker, const std::string & name, const std::string & title,
127  int nchX, double lowX, double highX,
128  int nchY, double lowY, double highY,
129  const std::string & titleX, const std::string & titleY,
130  Option_t * option )
131  {
132  iBooker.setCurrentFolder(outputInternalPath_);
133  MonitorElement * me = iBooker.book2D(newName(name),title,nchX,lowX,highX,nchY,lowY,highY) ;
134  if (titleX!="") { me->getTH2F()->GetXaxis()->SetTitle(titleX.c_str()) ; }
135  if (titleY!="") { me->getTH2F()->GetYaxis()->SetTitle(titleY.c_str()) ; }
136  if (TString(option)!="") { me->getTH2F()->SetOption(option) ; }
137  if (bookStatOverflowFlag_) {me->getTH1()->StatOverflows(kTRUE) ; }
138  return me ;
139  }
140 
142  ( DQMStore::IBooker & iBooker, const std::string & name, const std::string & title,
143  int nchX, double lowX, double highX,
144  int nchY, double lowY, double highY,
145  const std::string & titleX, const std::string & titleY,
146  Option_t * option )
147  {
148  iBooker.setCurrentFolder(outputInternalPath_);
149  MonitorElement * me = iBooker.book2D(newName(name),title,nchX,lowX,highX,nchY,lowY,highY) ;
150  if (me->getTH2F()->GetSumw2N() == 0) me->getTH2F()->Sumw2() ;
151  if (titleX!="") { me->getTH2F()->GetXaxis()->SetTitle(titleX.c_str()) ; }
152  if (titleY!="") { me->getTH2F()->GetYaxis()->SetTitle(titleY.c_str()) ; }
153  if (TString(option)!="") { me->getTH2F()->SetOption(option) ; }
154  if (bookStatOverflowFlag_) {me->getTH1()->StatOverflows(kTRUE) ; }
155  return me ;
156  }
157 
159  ( DQMStore::IBooker & iBooker, const std::string & name, const std::string & title,
160  int nchX, double lowX, double highX,
161  double lowY, double highY,
162  const std::string & titleX, const std::string & titleY,
163  Option_t * option )
164  {
165  iBooker.setCurrentFolder(outputInternalPath_);
166  MonitorElement * me = iBooker.bookProfile(newName(name),title,nchX,lowX,highX,lowY,highY," ") ;
167  if (titleX!="") { me->getTProfile()->GetXaxis()->SetTitle(titleX.c_str()) ; }
168  if (titleY!="") { me->getTProfile()->GetYaxis()->SetTitle(titleY.c_str()) ; }
169  if (TString(option)!="") { me->getTProfile()->SetOption(option) ; }
170  if (bookStatOverflowFlag_) {me->getTH1()->StatOverflows(kTRUE) ; }
171  return me ;
172  }
173 
174 
175 
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
virtual void dqmBeginRun(edm::Run const &, edm::EventSetup const &)
MonitorElement * bookH2withSumw2(DQMStore::IBooker &, const std::string &name, const std::string &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const std::string &titleX="", const std::string &titleY="", Option_t *option="COLZ")
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:157
virtual void endRun(edm::Run const &, edm::EventSetup const &)
MonitorElement * bookH1withSumw2(DQMStore::IBooker &, const std::string &name, const std::string &title, int nchX, double lowX, double highX, const std::string &titleX="", const std::string &titleY="Events", Option_t *option="E1 P")
MonitorElement * bookH2(DQMStore::IBooker &, const std::string &name, const std::string &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, const std::string &titleX="", const std::string &titleY="", Option_t *option="COLZ")
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
TH1 * getTH1(void) const
void setBookPrefix(const std::string &)
ElectronDqmAnalyzerBase(const edm::ParameterSet &conf)
MonitorElement * bookP1(DQMStore::IBooker &, const std::string &name, const std::string &title, int nchX, double lowX, double highX, double lowY, double highY, const std::string &titleX="", const std::string &titleY="", Option_t *option="E1 P")
tuple conf
Definition: dbtoconf.py:185
void setBookEfficiencyFlag(const bool &)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:133
TH1F * getTH1F(void) const
TProfile * getTProfile(void) const
MonitorElement * bookH1(DQMStore::IBooker &, const std::string &name, const std::string &title, int nchX, double lowX, double highX, const std::string &titleX="", const std::string &titleY="Events", Option_t *option="E1 P")
volatile std::atomic< bool > shutdown_flag false
TH2F * getTH2F(void) const
void setBookStatOverflowFlag(const bool &)
Definition: Run.h:43
std::string newName(const std::string &name)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override