CMS 3D CMS Logo

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)
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 
58 
60 {
61  edm::LogInfo("DQMAnalyzeBase::bookHistograms") << std::endl;
62 
63 }
64 
66  ( DQMStore::IBooker & iBooker, const std::string & name, const std::string & title,
67  int nchX, double lowX, double highX,
68  const std::string & titleX, const std::string & titleY,
69  Option_t * option )
70  {
72  MonitorElement * me = iBooker.book1D(newName(name),title,nchX,lowX,highX) ;
73  if (!titleX.empty()) { me->getTH1F()->GetXaxis()->SetTitle(titleX.c_str()) ; }
74  if (!titleY.empty()) { me->getTH1F()->GetYaxis()->SetTitle(titleY.c_str()) ; }
75  if (TString(option)!="") { me->getTH1F()->SetOption(option) ; }
76  if (bookStatOverflowFlag_) {me->getTH1()->StatOverflows(kTRUE) ; }
77  return me ;
78  }
79 
81  ( DQMStore::IBooker & iBooker, const std::string & name, const std::string & title,
82  int nchX, double lowX, double highX,
83  const std::string & titleX, const std::string & titleY,
84  Option_t * option )
85  {
87  MonitorElement * me = iBooker.book1D(newName(name),title,nchX,lowX,highX) ;
88  if (me->getTH1F()->GetSumw2N() == 0) me->getTH1F()->Sumw2() ;
89  if (!titleX.empty()) { me->getTH1F()->GetXaxis()->SetTitle(titleX.c_str()) ; }
90  if (!titleY.empty()) { me->getTH1F()->GetYaxis()->SetTitle(titleY.c_str()) ; }
91  if (TString(option)!="") { me->getTH1F()->SetOption(option) ; }
92  if (bookStatOverflowFlag_) {me->getTH1()->StatOverflows(kTRUE) ; }
93  return me ;
94  }
95 
97  ( DQMStore::IBooker & iBooker, const std::string & name, const std::string & title,
98  int nchX, double lowX, double highX,
99  int nchY, double lowY, double highY,
100  const std::string & titleX, const std::string & titleY,
101  Option_t * option )
102  {
104  MonitorElement * me = iBooker.book2D(newName(name),title,nchX,lowX,highX,nchY,lowY,highY) ;
105  if (!titleX.empty()) { me->getTH2F()->GetXaxis()->SetTitle(titleX.c_str()) ; }
106  if (!titleY.empty()) { me->getTH2F()->GetYaxis()->SetTitle(titleY.c_str()) ; }
107  if (TString(option)!="") { me->getTH2F()->SetOption(option) ; }
108  if (bookStatOverflowFlag_) {me->getTH1()->StatOverflows(kTRUE) ; }
109  return me ;
110  }
111 
113  ( DQMStore::IBooker & iBooker, const std::string & name, const std::string & title,
114  int nchX, double lowX, double highX,
115  int nchY, double lowY, double highY,
116  const std::string & titleX, const std::string & titleY,
117  Option_t * option )
118  {
120  MonitorElement * me = iBooker.book2D(newName(name),title,nchX,lowX,highX,nchY,lowY,highY) ;
121  if (me->getTH2F()->GetSumw2N() == 0) me->getTH2F()->Sumw2() ;
122  if (!titleX.empty()) { me->getTH2F()->GetXaxis()->SetTitle(titleX.c_str()) ; }
123  if (!titleY.empty()) { me->getTH2F()->GetYaxis()->SetTitle(titleY.c_str()) ; }
124  if (TString(option)!="") { me->getTH2F()->SetOption(option) ; }
125  if (bookStatOverflowFlag_) {me->getTH1()->StatOverflows(kTRUE) ; }
126  return me ;
127  }
128 
130  ( DQMStore::IBooker & iBooker, const std::string & name, const std::string & title,
131  int nchX, double lowX, double highX,
132  double lowY, double highY,
133  const std::string & titleX, const std::string & titleY,
134  Option_t * option )
135  {
137  MonitorElement * me = iBooker.bookProfile(newName(name),title,nchX,lowX,highX,lowY,highY," ") ;
138  if (!titleX.empty()) { me->getTProfile()->GetXaxis()->SetTitle(titleX.c_str()) ; }
139  if (!titleY.empty()) { me->getTProfile()->GetYaxis()->SetTitle(titleY.c_str()) ; }
140  if (TString(option)!="") { me->getTProfile()->SetOption(option) ; }
141  if (bookStatOverflowFlag_) {me->getTH1()->StatOverflows(kTRUE) ; }
142  return me ;
143  }
144 
145 
146 
TProfile * getTProfile() const
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) 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:113
TH1F * getTH1F() const
TH1 * getTH1() 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")
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
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")
TH2F * getTH2F() const
void setBookEfficiencyFlag(const bool &)
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
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")
void setBookStatOverflowFlag(const bool &)
Definition: Run.h:45
std::string newName(const std::string &name)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override