CMS 3D CMS Logo

ScoutingAnalyzerBase.cc
Go to the documentation of this file.
7 #include <iostream>
8 #include <sstream>
9 
11  m_MEsPath = conf.getUntrackedParameter<std::string>("rootPath", "DataScouting");
12  m_modulePath = conf.getUntrackedParameter<std::string>("modulePath", "DataScouting");
13  m_verbosityLevel = conf.getUntrackedParameter<unsigned int>("verbosityLevel", 0);
14  if (!m_modulePath.empty()) {
15  m_MEsPath += "/" + m_modulePath;
16  }
17 }
18 
20 
22  // let's keep it in case we need massage
23  return name;
24 }
25 
27 
29  const std::string &name,
30  const std::string &title,
31  int nchX,
32  double lowX,
33  double highX,
34  const std::string &titleX,
35  const std::string &titleY,
36  Option_t *option) {
37  MonitorElement *me = iBooker.book1DD(newName(name), title, nchX, lowX, highX);
38  if (!titleX.empty()) {
39  me->getTH1()->GetXaxis()->SetTitle(titleX.c_str());
40  }
41  if (!titleY.empty()) {
42  me->getTH1()->GetYaxis()->SetTitle(titleY.c_str());
43  }
44  if (TString(option) != "") {
45  me->getTH1()->SetOption(option);
46  }
47  return me;
48 }
49 
51  const std::string &name,
52  const std::string &title,
53  int nchX,
54  double lowX,
55  double highX,
56  const std::string &titleX,
57  const std::string &titleY,
58  Option_t *option) {
59  std::cout << newName(name) << std::endl;
60  MonitorElement *me = iBooker.book1DD(newName(name), title, nchX, lowX, highX);
61  me->getTH1()->Sumw2();
62  if (!titleX.empty()) {
63  me->getTH1()->GetXaxis()->SetTitle(titleX.c_str());
64  }
65  if (!titleY.empty()) {
66  me->getTH1()->GetYaxis()->SetTitle(titleY.c_str());
67  }
68  if (TString(option) != "") {
69  me->getTH1()->SetOption(option);
70  }
71  return me;
72 }
73 
75  const std::string &name,
76  const std::string &title,
77  int nchX,
78  float *xbinsize,
79  const std::string &titleX,
80  const std::string &titleY,
81  Option_t *option) {
82  MonitorElement *me = iBooker.book1D(newName(name), title, nchX, xbinsize);
83  // book1DD not implemented in DQMServices/Core/src/DQMStore.cc
84  if (!titleX.empty()) {
85  me->getTH1()->GetXaxis()->SetTitle(titleX.c_str());
86  }
87  if (!titleY.empty()) {
88  me->getTH1()->GetYaxis()->SetTitle(titleY.c_str());
89  }
90  if (TString(option) != "") {
91  me->getTH1()->SetOption(option);
92  }
93  return me;
94 }
95 
97  const std::string &name,
98  const std::string &title,
99  int nchX,
100  float *xbinsize,
101  const std::string &titleX,
102  const std::string &titleY,
103  Option_t *option) {
104  std::cout << newName(name) << std::endl;
105  MonitorElement *me = iBooker.book1D(newName(name), title, nchX, xbinsize);
106  // book1DD not implemented in DQMServices/Core/src/DQMStore.cc
107  me->getTH1()->Sumw2();
108  if (!titleX.empty()) {
109  me->getTH1()->GetXaxis()->SetTitle(titleX.c_str());
110  }
111  if (!titleY.empty()) {
112  me->getTH1()->GetYaxis()->SetTitle(titleY.c_str());
113  }
114  if (TString(option) != "") {
115  me->getTH1()->SetOption(option);
116  }
117  return me;
118 }
119 
121  const std::string &name,
122  const std::string &title,
123  int nchX,
124  double lowX,
125  double highX,
126  int nchY,
127  double lowY,
128  double highY,
129  const std::string &titleX,
130  const std::string &titleY,
131  Option_t *option) {
132  MonitorElement *me = iBooker.book2DD(newName(name), title, nchX, lowX, highX, nchY, lowY, highY);
133  if (!titleX.empty()) {
134  me->getTH1()->GetXaxis()->SetTitle(titleX.c_str());
135  }
136  if (!titleY.empty()) {
137  me->getTH1()->GetYaxis()->SetTitle(titleY.c_str());
138  }
139  if (TString(option) != "") {
140  me->getTH1()->SetOption(option);
141  }
142  return me;
143 }
144 
146  const std::string &name,
147  const std::string &title,
148  int nchX,
149  double lowX,
150  double highX,
151  int nchY,
152  double lowY,
153  double highY,
154  const std::string &titleX,
155  const std::string &titleY,
156  Option_t *option) {
157  MonitorElement *me = iBooker.book2DD(newName(name), title, nchX, lowX, highX, nchY, lowY, highY);
158  me->getTH1()->Sumw2();
159  if (!titleX.empty()) {
160  me->getTH1()->GetXaxis()->SetTitle(titleX.c_str());
161  }
162  if (!titleY.empty()) {
163  me->getTH1()->GetYaxis()->SetTitle(titleY.c_str());
164  }
165  if (TString(option) != "") {
166  me->getTH1()->SetOption(option);
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) {
182  MonitorElement *me = iBooker.bookProfile(newName(name), title, nchX, lowX, highX, lowY, highY, " ");
183  if (!titleX.empty()) {
184  me->getTProfile()->GetXaxis()->SetTitle(titleX.c_str());
185  }
186  if (!titleY.empty()) {
187  me->getTProfile()->GetYaxis()->SetTitle(titleY.c_str());
188  }
189  if (TString(option) != "") {
190  me->getTProfile()->SetOption(option);
191  }
192  return me;
193 }
194 
196  const std::string &name,
198  MonitorElement *denom,
199  const std::string &titleX,
200  const std::string &titleY,
201  const std::string &title) {
202  std::string name2 = newName(name);
203  TH1D *h_temp = dynamic_cast<TH1D *>(num->getTH1()->Clone(name2.c_str()));
204  h_temp->Reset();
205  h_temp->Divide(num->getTH1(), denom->getTH1(), 1, 1, "b");
206  h_temp->GetXaxis()->SetTitle(titleX.c_str());
207  h_temp->GetYaxis()->SetTitle(titleY.c_str());
208  if (!title.empty()) {
209  h_temp->SetTitle(title.c_str());
210  }
211  if (m_verbosityLevel > 0) {
212  h_temp->Print();
213  }
214  MonitorElement *me = iBooker.book1DD(name2, h_temp);
215  delete h_temp;
216  return me;
217 }
218 
220  const std::string &name,
222  MonitorElement *denom,
223  const std::string &titleX,
224  const std::string &titleY,
225  const std::string &title) {
226  std::string name2 = newName(name);
227  TH2D *h_temp = dynamic_cast<TH2D *>(num->getTH1()->Clone(name2.c_str()));
228  h_temp->Reset();
229  h_temp->Divide(num->getTH1(), denom->getTH1(), 1, 1, "b");
230  h_temp->GetXaxis()->SetTitle(titleX.c_str());
231  h_temp->GetYaxis()->SetTitle(titleY.c_str());
232  if (!title.empty()) {
233  h_temp->SetTitle(title.c_str());
234  }
235  if (m_verbosityLevel > 0) {
236  h_temp->Print();
237  }
238  MonitorElement *me = iBooker.book2DD(name2, h_temp);
239  delete h_temp;
240  return me;
241 }
242 
244  MonitorElement *me2d,
245  const std::string &title,
246  const std::string &titleX,
247  const std::string &titleY,
248  Double_t minimum,
249  Double_t maximum) {
250  std::string name2 = me2d->getName() + "_pfx";
251  TProfile *p1_temp = me2d->getTH2D()->ProfileX();
252  if (!title.empty()) {
253  p1_temp->SetTitle(title.c_str());
254  }
255  if (!titleX.empty()) {
256  p1_temp->GetXaxis()->SetTitle(titleX.c_str());
257  }
258  if (!titleY.empty()) {
259  p1_temp->GetYaxis()->SetTitle(titleY.c_str());
260  }
261  if (minimum != -1111) {
262  p1_temp->SetMinimum(minimum);
263  }
264  if (maximum != -1111) {
265  p1_temp->SetMaximum(maximum);
266  }
267  MonitorElement *me = iBooker.bookProfile(name2, p1_temp);
268  delete p1_temp;
269  return me;
270 }
271 
273  MonitorElement *me2d,
274  const std::string &title,
275  const std::string &titleX,
276  const std::string &titleY,
277  Double_t minimum,
278  Double_t maximum) {
279  std::string name2 = me2d->getName() + "_pfy";
280  TProfile *p1_temp = me2d->getTH2D()->ProfileY();
281  if (!title.empty()) {
282  p1_temp->SetTitle(title.c_str());
283  }
284  if (!titleX.empty()) {
285  p1_temp->GetXaxis()->SetTitle(titleX.c_str());
286  }
287  if (!titleY.empty()) {
288  p1_temp->GetYaxis()->SetTitle(titleY.c_str());
289  }
290  if (minimum != -1111) {
291  p1_temp->SetMinimum(minimum);
292  }
293  if (maximum != -1111) {
294  p1_temp->SetMaximum(maximum);
295  }
296  MonitorElement *me = iBooker.bookProfile(name2, p1_temp);
297  delete p1_temp;
298  return me;
299 }
TProfile * getTProfile() const
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:113
void prepareBooking(DQMStore::IBooker &)
TH1 * getTH1() const
MonitorElement * bookH2andDivide(DQMStore::IBooker &, const std::string &name, MonitorElement *num, MonitorElement *denom, const std::string &titleX, const std::string &titleY, const std::string &title="")
const std::string & getName() const
get name of ME
MonitorElement * bookH1andDivide(DQMStore::IBooker &, const std::string &name, MonitorElement *num, MonitorElement *denom, const std::string &titleX, const std::string &titleY, const std::string &title="")
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")
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
std::string newName(const std::string &name)
TH2D * getTH2D() const
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
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")
MonitorElement * profileY(DQMStore::IBooker &, MonitorElement *me2d, const std::string &title="", const std::string &titleX="", const std::string &titleY="", Double_t minimum=-1111, Double_t maximum=-1111)
ScoutingAnalyzerBase(const edm::ParameterSet &conf)
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 * 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 * 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 * book2DD(Args &&...args)
Definition: DQMStore.h:111
MonitorElement * bookH1withSumw2BinArray(DQMStore::IBooker &, const std::string &name, const std::string &title, int nchX, float *xbinsize, const std::string &titleX="", const std::string &titleY="Events", Option_t *option="E1 P")
MonitorElement * profileX(DQMStore::IBooker &, MonitorElement *me2d, const std::string &title="", const std::string &titleX="", const std::string &titleY="", Double_t minimum=-1111, Double_t maximum=-1111)
MonitorElement * book1DD(Args &&...args)
Definition: DQMStore.h:108
MonitorElement * bookH1BinArray(DQMStore::IBooker &, const std::string &name, const std::string &title, int nchX, float *xbinsize, const std::string &titleX="", const std::string &titleY="Events", Option_t *option="E1 P")