CMS 3D CMS Logo

ElectronDqmAnalyzerBase.cc
Go to the documentation of this file.
1 
3 //#include "DQMServices/Core/interface/DQMStore.h"
7 #include "TMath.h"
8 #include "TFile.h"
9 #include "TH1F.h"
10 #include "TH1I.h"
11 #include "TH2F.h"
12 #include "TProfile.h"
13 #include "TTree.h"
14 #include <iostream>
15 #include <algorithm>
16 #include <sstream>
17 
19  : bookPrefix_("ele"), bookIndex_(0), histoNamesReady(false) {
20  verbosity_ = conf.getUntrackedParameter<int>("Verbosity");
21  finalStep_ = conf.getParameter<std::string>("FinalStep");
22  inputFile_ = conf.getParameter<std::string>("InputFile");
23  outputFile_ = conf.getParameter<std::string>("OutputFile");
24  inputInternalPath_ = conf.getParameter<std::string>("InputFolderName");
25  outputInternalPath_ = conf.getParameter<std::string>("OutputFolderName");
26 }
27 
29 
31 
33 
34 void ElectronDqmAnalyzerBase::setBookEfficiencyFlag(const bool &eff_flag) { bookEfficiencyFlag_ = eff_flag; }
35 
36 void ElectronDqmAnalyzerBase::setBookStatOverflowFlag(const bool &statOverflow_flag) {
37  bookStatOverflowFlag_ = statOverflow_flag;
38 }
39 
41  if (bookPrefix_.empty()) {
42  return name;
43  }
44  std::ostringstream oss;
45  oss << bookPrefix_;
46  if (bookIndex_ >= 0) {
47  oss << bookIndex_++;
48  }
49  oss << "_" << name;
50  return oss.str();
51 }
52 
54  edm::LogInfo("DQMAnalyzeBase::bookHistograms") << std::endl;
55 }
56 
58  const std::string &name,
59  const std::string &title,
60  int nchX,
61  double lowX,
62  double highX,
63  const std::string &titleX,
64  const std::string &titleY,
65  Option_t *option) {
67  MonitorElement *me = iBooker.book1D(newName(name), title, nchX, lowX, highX);
68  if (!titleX.empty()) {
69  me->setAxisTitle(titleX);
70  }
71  if (!titleY.empty()) {
72  me->setAxisTitle(titleY, 2);
73  }
74  if (TString(option) != "") {
75  me->setOption(option);
76  }
78  me->setStatOverflows(kTRUE);
79  }
80  return me;
81 }
82 
84  const std::string &name,
85  const std::string &title,
86  int nchX,
87  double lowX,
88  double highX,
89  const std::string &titleX,
90  const std::string &titleY,
91  Option_t *option) {
93  MonitorElement *me = iBooker.book1D(newName(name), title, nchX, lowX, highX);
94  if (me->getTH1F()->GetSumw2N() == 0)
95  me->enableSumw2();
96  if (!titleX.empty()) {
97  me->setAxisTitle(titleX);
98  }
99  if (!titleY.empty()) {
100  me->setAxisTitle(titleY, 2);
101  }
102  if (TString(option) != "") {
103  me->setOption(option);
104  }
105  if (bookStatOverflowFlag_) {
106  me->setStatOverflows(kTRUE);
107  }
108  return me;
109 }
110 
112  const std::string &name,
113  const std::string &title,
114  int nchX,
115  double lowX,
116  double highX,
117  int nchY,
118  double lowY,
119  double highY,
120  const std::string &titleX,
121  const std::string &titleY,
122  Option_t *option) {
124  MonitorElement *me = iBooker.book2D(newName(name), title, nchX, lowX, highX, nchY, lowY, highY);
125  if (!titleX.empty()) {
126  me->setAxisTitle(titleX);
127  }
128  if (!titleY.empty()) {
129  me->setAxisTitle(titleY, 2);
130  }
131  if (TString(option) != "") {
132  me->setOption(option);
133  }
134  if (bookStatOverflowFlag_) {
135  me->setStatOverflows(kTRUE);
136  }
137  return me;
138 }
139 
141  const std::string &name,
142  const std::string &title,
143  int nchX,
144  double lowX,
145  double highX,
146  int nchY,
147  double lowY,
148  double highY,
149  const std::string &titleX,
150  const std::string &titleY,
151  Option_t *option) {
153  MonitorElement *me = iBooker.book2D(newName(name), title, nchX, lowX, highX, nchY, lowY, highY);
154  if (me->getTH2F()->GetSumw2N() == 0)
155  me->enableSumw2();
156  if (!titleX.empty()) {
157  me->setAxisTitle(titleX);
158  }
159  if (!titleY.empty()) {
160  me->setAxisTitle(titleY, 2);
161  }
162  if (TString(option) != "") {
163  me->setOption(option);
164  }
165  if (bookStatOverflowFlag_) {
166  me->setStatOverflows(kTRUE);
167  }
168  return me;
169 }
170 
172  const std::string &name,
173  const std::string &title,
174  int nchX,
175  double lowX,
176  double highX,
177  double lowY,
178  double highY,
179  const std::string &titleX,
180  const std::string &titleY,
181  Option_t *option) {
183  MonitorElement *me = iBooker.bookProfile(newName(name), title, nchX, lowX, highX, lowY, highY, " ");
184  if (!titleX.empty()) {
185  me->getTProfile()->GetXaxis()->SetTitle(titleX.c_str());
186  }
187  if (!titleY.empty()) {
188  me->setAxisTitle(titleY, 2);
189  }
190  if (TString(option) != "") {
191  me->getTProfile()->SetOption(option);
192  }
193  if (bookStatOverflowFlag_) {
194  me->setStatOverflows(kTRUE);
195  }
196  return me;
197 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
T getUntrackedParameter(std::string const &, T const &) 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")
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:399
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")
void setBookPrefix(const std::string &)
ElectronDqmAnalyzerBase(const edm::ParameterSet &conf)
void setBookEfficiencyFlag(const bool &)
Log< level::Info, false > LogInfo
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 * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
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")
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 * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
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