CMS 3D CMS Logo

DQMExample_Step2.cc
Go to the documentation of this file.
3 
4 #include <cmath>
5 #include <cstdio>
6 #include <iomanip>
7 #include <iostream>
8 #include <sstream>
9 #include <string>
10 
11 //
12 // -------------------------------------- Constructor
13 // --------------------------------------------
14 //
16  edm::LogInfo("DQMExample_Step2") << "Constructor DQMExample_Step2::DQMExample_Step2 " << std::endl;
17 
18  // Get parameters from configuration file
19  numMonitorName_ = ps.getParameter<std::string>("numMonitorName");
20  denMonitorName_ = ps.getParameter<std::string>("denMonitorName");
21 }
22 
23 //
24 // -- Destructor
25 //
27  edm::LogInfo("DQMExample_Step2") << "Destructor DQMExample_Step2::~DQMExample_Step2 " << std::endl;
28 }
29 
30 //
31 // -------------------------------------- beginJob
32 // --------------------------------------------
33 //
34 void DQMExample_Step2::beginJob() { edm::LogInfo("DQMExample_Step2") << "DQMExample_Step2::beginJob " << std::endl; }
35 //
36 // -------------------------------------- get and book in the endJob
37 // --------------------------------------------
38 //
40  // create and cd into new folder
41  ibooker_.setCurrentFolder("What_I_do_in_the_client/Ratio");
42 
43  // get available histograms
46 
47  if (!numerator || !denominator) {
48  edm::LogError("DQMExample_Step2") << "MEs not found!" << std::endl;
49  return;
50  }
51 
52  // book new histogram
53  h_ptRatio = ibooker_.book1D("ptRatio", "pt ratio pf matched objects", 50, 0., 100.);
54  h_ptRatio->setAxisTitle("pt [GeV]");
55 
56  for (int iBin = 1; iBin < numerator->getNbinsX(); ++iBin) {
57  if (denominator->getBinContent(iBin) == 0)
58  h_ptRatio->setBinContent(iBin, 0.);
59  else
60  h_ptRatio->setBinContent(iBin, numerator->getBinContent(iBin) / denominator->getBinContent(iBin));
61  }
62 }
63 
64 //
65 // -------------------------------------- get in the endLumi if needed
66 // --------------------------------------------
67 //
69  DQMStore::IGetter &igetter_,
70  edm::LuminosityBlock const &iLumi,
71  edm::EventSetup const &iSetup) {
72  edm::LogInfo("DQMExample_Step2") << "DQMExample_Step2::endLumi " << std::endl;
73 }
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX)
Definition: DQMStore.cc:239
T getParameter(std::string const &) const
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:418
MonitorElement * h_ptRatio
virtual int getNbinsX() const
get # of bins in X-axis
~DQMExample_Step2() override
DQMExample_Step2(const edm::ParameterSet &ps)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
virtual double getBinContent(int binx) const
get content of bin (1-D)
std::string denMonitorName_
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
void beginJob() override
MonitorElement * get(std::string const &path)
Definition: DQMStore.cc:437
std::string numMonitorName_
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)