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 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:32
MonitorElement * h_ptRatio
Log< level::Error, false > LogError
~DQMExample_Step2() override
DQMExample_Step2(const edm::ParameterSet &ps)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
Log< level::Info, false > LogInfo
std::string denMonitorName_
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
virtual MonitorElement * get(std::string const &fullpath) const
Definition: DQMStore.cc:673
void beginJob() override
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
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)