test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DQMExample_Step2.cc
Go to the documentation of this file.
3 
4 
5 #include <iostream>
6 #include <iomanip>
7 #include <stdio.h>
8 #include <string>
9 #include <sstream>
10 #include <math.h>
11 
12 //
13 // -------------------------------------- Constructor --------------------------------------------
14 //
16 {
17  edm::LogInfo("DQMExample_Step2") << "Constructor DQMExample_Step2::DQMExample_Step2 " << std::endl;
18 
19  // Get parameters from configuration file
20  numMonitorName_ = ps.getParameter<std::string>("numMonitorName");
21  denMonitorName_ = ps.getParameter<std::string>("denMonitorName");
22 
23 }
24 
25 //
26 // -- Destructor
27 //
29 {
30  edm::LogInfo("DQMExample_Step2") << "Destructor DQMExample_Step2::~DQMExample_Step2 " << std::endl;
31 }
32 
33 //
34 // -------------------------------------- beginJob --------------------------------------------
35 //
37 {
38  edm::LogInfo("DQMExample_Step2") << "DQMExample_Step2::beginJob " << std::endl;
39 }
40 //
41 // -------------------------------------- get and book in the endJob --------------------------------------------
42 //
44 {
45  // create and cd into new folder
46  ibooker_.setCurrentFolder("What_I_do_in_the_client/Ratio");
47 
48  //get available histograms
51 
52  if (!numerator || !denominator)
53  {
54  edm::LogError("DQMExample_Step2") << "MEs not found!" << std::endl;
55  return;
56  }
57 
58 
59  //book new histogram
60  h_ptRatio = ibooker_.book1D("ptRatio","pt ratio pf matched objects",50,0.,100.);
61  h_ptRatio->setAxisTitle("pt [GeV]");
62 
63  for (int iBin=1; iBin<numerator->getNbinsX(); ++iBin)
64  {
65  if(denominator->getBinContent(iBin) == 0)
66  h_ptRatio->setBinContent(iBin, 0.);
67  else
68  h_ptRatio->setBinContent(iBin, numerator->getBinContent(iBin) / denominator->getBinContent(iBin));
69  }
70 }
71 
72 //
73 // -------------------------------------- get in the endLumi if needed --------------------------------------------
74 //
76 {
77  edm::LogInfo("DQMExample_Step2") << "DQMExample_Step2::endLumi " << std::endl;
78 }
T getParameter(std::string const &) const
void setBinContent(int binx, double content)
set content of bin (1-D)
list numerator
Definition: cuy.py:483
virtual ~DQMExample_Step2()
MonitorElement * get(const std::string &path)
Definition: DQMStore.cc:305
MonitorElement * h_ptRatio
list denominator
Definition: cuy.py:484
DQMExample_Step2(const edm::ParameterSet &ps)
void dqmEndJob(DQMStore::IBooker &, DQMStore::IGetter &) override
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:277
std::string denMonitorName_
double getBinContent(int binx) const
get content of bin (1-D)
void beginJob() override
int getNbinsX(void) const
get # of bins in X-axis
std::string numMonitorName_
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void dqmEndLuminosityBlock(DQMStore::IBooker &, DQMStore::IGetter &, edm::LuminosityBlock const &, edm::EventSetup const &) override