CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TGMTClient.cc
Go to the documentation of this file.
2 
8 
9 #include <sstream>
10 
12  parameters_ = ps;
13  initialize();
14 }
15 
17  LogDebug("TriggerDQM") << "[TriggerDQM]: ending... ";
18 }
19 
20 //--------------------------------------------------------
22 
23  // get back-end interface
25 
26  // base folder for the contents of this job
28  "monitorName", "");
29  LogDebug("TriggerDQM") << "Monitor name = " << monitorName_ << std::endl;
30 
31  output_dir_ = parameters_.getUntrackedParameter<std::string> ("output_dir",
32  "");
33  LogDebug("TriggerDQM") << "DQM output dir = " << output_dir_ << std::endl;
34 
35  input_dir_ = parameters_.getUntrackedParameter<std::string> ("input_dir",
36  "");
37  LogDebug("TriggerDQM") << "DQM input dir = " << input_dir_ << std::endl;
38 
40  "runInEventLoop", false);
41  m_runInEndLumi = parameters_.getUntrackedParameter<bool> ("runInEndLumi",
42  false);
43  m_runInEndRun = parameters_.getUntrackedParameter<bool> ("runInEndRun",
44  false);
45  m_runInEndJob = parameters_.getUntrackedParameter<bool> ("runInEndJob",
46  false);
47 
48 }
49 
50 //--------------------------------------------------------
52 
53  LogDebug("TriggerDQM") << "[TriggerDQM]: Begin Job";
54 
55 }
56 
57 //--------------------------------------------------------
58 void L1TGMTClient::beginRun(const edm::Run& r, const edm::EventSetup& evSetup) {
59 
60  // booking histograms in the output_dir_
61 
63 
64  eff_eta_dtcsc = bookClone1DVB("eff_eta_dtcsc", "efficiency DTCSC vs eta",
65  "eta_DTCSC_and_RPC");
66 
67  if (eff_eta_dtcsc != 0) {
68  eff_eta_dtcsc->setAxisTitle("eta", 1);
69  if (!eff_eta_dtcsc->getTH1F()->GetSumw2N())
70  eff_eta_dtcsc->getTH1F()->Sumw2();
71 
72  }
73 
74  eff_eta_rpc = bookClone1DVB("eff_eta_rpc", "efficiency RPC vs eta",
75  "eta_DTCSC_and_RPC");
76 
77  if (eff_eta_rpc != 0) {
78  eff_eta_rpc->setAxisTitle("eta", 1);
79  if (!eff_eta_rpc->getTH1F()->GetSumw2N())
80  eff_eta_rpc->getTH1F()->Sumw2();
81 
82  }
83 
84  eff_phi_dtcsc = bookClone1D("eff_phi_dtcsc", "efficiency DTCSC vs phi",
85  "phi_DTCSC_and_RPC");
86 
87  if (eff_phi_dtcsc != 0) {
88  eff_phi_dtcsc->setAxisTitle("phi (deg)", 1);
89  if (!eff_phi_dtcsc->getTH1F()->GetSumw2N())
90  eff_phi_dtcsc->getTH1F()->Sumw2();
91 
92  }
93 
94  eff_phi_rpc = bookClone1D("eff_phi_rpc", "efficiency RPC vs phi",
95  "phi_DTCSC_and_RPC");
96 
97  if (eff_phi_rpc != 0) {
98  eff_phi_rpc->setAxisTitle("phi (deg)", 1);
99  if (!eff_phi_rpc->getTH1F()->GetSumw2N())
100  eff_phi_rpc->getTH1F()->Sumw2();
101 
102  }
103 
104  eff_etaphi_dtcsc = bookClone2D("eff_etaphi_dtcsc",
105  "efficiency DTCSC vs eta and phi", "etaphi_DTCSC_and_RPC");
106 
107  if (eff_etaphi_dtcsc != 0) {
108  eff_etaphi_dtcsc->setAxisTitle("eta", 1);
109  eff_etaphi_dtcsc->setAxisTitle("phi (deg)", 2);
110  if (!eff_etaphi_dtcsc->getTH2F()->GetSumw2N())
111  eff_etaphi_dtcsc->getTH2F()->Sumw2();
112 
113  }
114 
115  eff_etaphi_rpc = bookClone2D("eff_etaphi_rpc",
116  "efficiency RPC vs eta and phi", "etaphi_DTCSC_and_RPC");
117 
118  if (eff_etaphi_rpc != 0) {
119  eff_etaphi_rpc->setAxisTitle("eta", 1);
120  eff_etaphi_rpc->setAxisTitle("phi (deg)", 2);
121  if (!eff_etaphi_rpc->getTH2F()->GetSumw2N())
122  eff_etaphi_rpc->getTH2F()->Sumw2();
123 
124  }
125 }
126 
127 //--------------------------------------------------------
129  const edm::EventSetup& evSetup) {
130 
131  // empty
132 
133 }
134 //--------------------------------------------------------
135 
137  const edm::EventSetup& evSetup) {
138 
139  if (m_runInEndLumi) {
140 
142  }
143 
144 }
145 
146 //--------------------------------------------------------
148  const edm::EventSetup& evSetup) {
149 
150  // there is no loop on events in the offline harvesting step
151  // code here will not be executed offline
152 
153  if (m_runInEventLoop) {
154 
156  }
157 
158 }
159 
160 //--------------------------------------------------------
162 
163  LogDebug("TriggerDQM") << "L1TGMTClient: processing..." << std::endl;
164 
165  makeEfficiency1D(eff_eta_dtcsc, "eta_DTCSC_and_RPC", "eta_RPC_only");
166  makeEfficiency1D(eff_eta_rpc, "eta_DTCSC_and_RPC", "eta_DTCSC_only");
167 
168  makeEfficiency1D(eff_phi_dtcsc, "phi_DTCSC_and_RPC", "phi_RPC_only");
169  makeEfficiency1D(eff_phi_rpc, "phi_DTCSC_and_RPC", "phi_DTCSC_only");
170 
171  makeEfficiency2D(eff_etaphi_dtcsc, "etaphi_DTCSC_and_RPC",
172  "etaphi_RPC_only");
173  makeEfficiency2D(eff_etaphi_rpc, "etaphi_DTCSC_and_RPC",
174  "etaphi_DTCSC_only");
175 
176 }
177 
178 //--------------------------------------------------------
179 void L1TGMTClient::endRun(const edm::Run& r, const edm::EventSetup& evSetup) {
180 
181  if (m_runInEndRun) {
182 
184  }
185 
186 }
187 
188 //--------------------------------------------------------
190 
191  if (m_runInEndJob) {
192 
194  }
195 
196 }
197 
199 void L1TGMTClient::makeRatio1D(MonitorElement* mer, std::string h1Name,
200  std::string h2Name) {
201 
203 
204  TH1F* h1 = get1DHisto(input_dir_ + "/" + h1Name, dbe_);
205  TH1F* h2 = get1DHisto(input_dir_ + "/" + h2Name, dbe_);
206 
207  if (mer == 0) {
208  LogDebug("TriggerDQM")
209  << "\nL1TGMTClient::makeRatio1D: monitoring element zero, not able to retrieve histogram"
210  << std::endl;
211  return;
212  }
213 
214  TH1F* hr = mer->getTH1F();
215 
216  if (hr && h1 && h2) {
217  hr->Divide(h1, h2, 1., 1., " ");
218  }
219 }
220 
222 void L1TGMTClient::makeEfficiency1D(MonitorElement* meeff, std::string heName,
223  std::string hiName) {
224 
226 
227  TH1F* he = get1DHisto(input_dir_ + "/" + heName, dbe_);
228  TH1F* hi = get1DHisto(input_dir_ + "/" + hiName, dbe_);
229 
230  if (meeff == 0) {
231  LogDebug("TriggerDQM")
232  << "L1TGMTClient::makeEfficiency1D: monitoring element zero, not able to retrieve histogram"
233  << std::endl;
234  return;
235  }
236 
237  TH1F* heff = meeff->getTH1F();
238 
239  if (heff && he && hi) {
240  TH1F* hall = (TH1F*) he->Clone("hall");
241  hall->Add(hi);
242  heff->Divide(he, hall, 1., 1., "B");
243  delete hall;
244  }
245 }
246 
248 void L1TGMTClient::makeEfficiency2D(MonitorElement* meeff, std::string heName,
249  std::string hiName) {
250 
252 
253  TH2F* he = get2DHisto(input_dir_ + "/" + heName, dbe_);
254  TH2F* hi = get2DHisto(input_dir_ + "/" + hiName, dbe_);
255 
256  if (meeff == 0) {
257  LogDebug("TriggerDQM")
258  << "\nL1TGMTClient::makeEfficiency2D: monitoring element zero, not able to retrieve histogram"
259  << std::endl;
260  return;
261  }
262 
263  TH2F* heff = meeff->getTH2F();
264 
265  if (heff && he && hi) {
266  TH2F* hall = (TH2F*) he->Clone("hall");
267  hall->Add(hi);
268  heff->Divide(he, hall, 1., 1., "B");
269  delete hall;
270  }
271 }
272 
274 TH1F* L1TGMTClient::get1DHisto(std::string meName, DQMStore* dbi) {
275 
276  MonitorElement * me_ = dbi->get(meName);
277 
278  if (!me_) {
279  LogDebug("TriggerDQM") << "\nL1TGMTClient: " << meName << " NOT FOUND.";
280  return 0;
281  }
282 
283  return me_->getTH1F();
284 }
285 
287 TH2F* L1TGMTClient::get2DHisto(std::string meName, DQMStore* dbi) {
288  MonitorElement * me_ = dbi->get(meName);
289 
290  if (!me_) {
291  LogDebug("TriggerDQM") << "\nL1TGMTClient: " << meName << " NOT FOUND.";
292  return 0;
293  }
294  return me_->getTH2F();
295 }
296 
299  const std::string& title, const std::string& hrefName) {
300 
301  MonitorElement* me;
302 
303  TH1F* href = get1DHisto(input_dir_ + "/" + hrefName, dbe_);
304 
305  if (href) {
306  LogDebug("TriggerDQM")
307  << "\nL1TGMTClient::bookClone1D: booking histogram "
308  << hrefName << std::endl;
309  const unsigned nbx = href->GetNbinsX();
310  const double xmin = href->GetXaxis()->GetXmin();
311  const double xmax = href->GetXaxis()->GetXmax();
312  me = dbe_->book1D(name, title, nbx, xmin, xmax);
313  } else {
314  LogDebug("TriggerDQM")
315  << "\nL1TGMTClient::bookClone1D: not able to clone histogram "
316  << hrefName << std::endl;
317  me = 0;
318  }
319 
320  return me;
321 }
322 
325  const std::string& title, const std::string& hrefName) {
326 
327  MonitorElement* me;
328 
329  TH1F* href = get1DHisto(input_dir_ + "/" + hrefName, dbe_);
330 
331  if (href) {
332  LogDebug("TriggerDQM")
333  << "\nL1TGMTClient::bookClone1DVB: booking histogram "
334  << hrefName << std::endl;
335  int nbx = href->GetNbinsX();
336  if (nbx > 99)
337  nbx = 99;
338  float xbins[100];
339  for (int i = 0; i < nbx; i++) {
340  xbins[i] = href->GetBinLowEdge(i + 1);
341  }
342  xbins[nbx] = href->GetXaxis()->GetXmax();
343 
345  me = dbe_->book1D(name, title, nbx, xbins);
346 
347  } else {
348  LogDebug("TriggerDQM")
349  << "\nL1TGMTClient::bookClone1DVB: not able to clone histogram "
350  << hrefName << std::endl;
351  me = 0;
352  }
353 
354  return me;
355 }
356 
359  const std::string& title, const std::string& hrefName) {
360 
361  MonitorElement* me;
362 
363  TH2F* href = get2DHisto(input_dir_ + "/" + hrefName, dbe_);
364 
365  if (href) {
366  LogDebug("TriggerDQM")
367  << "\nL1TGMTClient::bookClone2D: booking histogram "
368  << hrefName << std::endl;
369  const unsigned nbx = href->GetNbinsX();
370  const double xmin = href->GetXaxis()->GetXmin();
371  const double xmax = href->GetXaxis()->GetXmax();
372  const unsigned nby = href->GetNbinsY();
373  const double ymin = href->GetYaxis()->GetXmin();
374  const double ymax = href->GetYaxis()->GetXmax();
375  me = dbe_->book2D(name, title, nbx, xmin, xmax, nby, ymin, ymax);
376  } else {
377  LogDebug("TriggerDQM")
378  << "\nL1TGMTClient::bookClone2D: not able to clone histogram "
379  << hrefName << std::endl;
380  me = 0;
381  }
382 
383  return me;
384 }
385 
387 
388 
#define LogDebug(id)
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
std::string monitorName_
Definition: L1TGMTClient.h:68
void endJob()
Endjob.
void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
DQM Client Diagnostic.
MonitorElement * bookClone1DVB(const std::string &name, const std::string &title, const std::string &hrefName)
void beginRun(const edm::Run &, const edm::EventSetup &)
BeginRun.
Definition: L1TGMTClient.cc:58
const double xbins[]
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &)
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
MonitorElement * eff_eta_rpc
Definition: L1TGMTClient.h:79
bool m_runInEndJob
Definition: L1TGMTClient.h:75
MonitorElement * eff_etaphi_dtcsc
Definition: L1TGMTClient.h:82
DQMStore * dbe_
Definition: L1TGMTClient.h:67
virtual ~L1TGMTClient()
Destructor.
Definition: L1TGMTClient.cc:16
void initialize()
Definition: L1TGMTClient.cc:21
std::string input_dir_
Definition: L1TGMTClient.h:69
int iEvent
Definition: GenABIO.cc:243
bool m_runInEventLoop
Definition: L1TGMTClient.h:72
void analyze(const edm::Event &, const edm::EventSetup &)
Fake Analyze.
bool m_runInEndLumi
Definition: L1TGMTClient.h:73
MonitorElement * eff_etaphi_rpc
Definition: L1TGMTClient.h:83
void endRun(const edm::Run &, const edm::EventSetup &)
EndRun.
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1468
MonitorElement * eff_phi_rpc
Definition: L1TGMTClient.h:81
MonitorElement * eff_eta_dtcsc
Definition: L1TGMTClient.h:78
MonitorElement * eff_phi_dtcsc
Definition: L1TGMTClient.h:80
void makeEfficiency1D(MonitorElement *meeff, std::string heName, std::string hiName)
TH1F * getTH1F(void) const
bool m_runInEndRun
Definition: L1TGMTClient.h:74
L1TGMTClient(const edm::ParameterSet &)
Constructor.
Definition: L1TGMTClient.cc:11
MonitorElement * bookClone1D(const std::string &name, const std::string &title, const std::string &hrefName)
TH1F * get1DHisto(std::string meName, DQMStore *dbi)
void makeRatio1D(MonitorElement *mer, std::string h1Name, std::string h2Name)
void beginJob()
BeginJob.
Definition: L1TGMTClient.cc:51
MonitorElement * bookClone2D(const std::string &name, const std::string &title, const std::string &hrefName)
std::string output_dir_
Definition: L1TGMTClient.h:70
void makeEfficiency2D(MonitorElement *meeff, std::string heName, std::string hiName)
TH2F * get2DHisto(std::string meName, DQMStore *dbi)
void processHistograms()
TH2F * getTH2F(void) const
MonitorElement * book2D(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY)
Book 2D histogram.
Definition: DQMStore.cc:845
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
edm::ParameterSet parameters_
Definition: L1TGMTClient.h:66
Definition: Run.h:33