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  //DQMStore
21 
22  // Get parameters from configuration file
23  numMonitorName_ = ps.getParameter<std::string>("numMonitorName");
24  denMonitorName_ = ps.getParameter<std::string>("denMonitorName");
25 
26 }
27 
28 //
29 // -- Destructor
30 //
32 {
33  edm::LogInfo("DQMExample_Step2") << "Destructor DQMExample_Step2::~DQMExample_Step2 " << std::endl;
34 }
35 
36 //
37 // -------------------------------------- beginJob --------------------------------------------
38 //
40 {
41  edm::LogInfo("DQMExample_Step2") << "DQMExample_Step2::beginJob " << std::endl;
42 }
43 //
44 // -------------------------------------- beginRun --------------------------------------------
45 //
47 {
48  edm::LogInfo("DQMExample_Step2") << "DQMExample_Step2::beginRun" << std::endl;
49 
50  //book at beginRun
51 }
52 //
53 // -------------------------------------- beginLuminosityBlock --------------------------------------------
54 //
56  edm::EventSetup const& context)
57 {
58  edm::LogInfo("DQMExample_Step2") << "DQMExample_Step2::beginLuminosityBlock" << std::endl;
59 }
60 
61 
62 //
63 // -------------------------------------- Analyze --------------------------------------------
64 //
66 {
67  edm::LogInfo("DQMExample_Step2") << "DQMExample_Step2::analyze" << std::endl;
68 
69 
70 
71 }
72 //
73 // -------------------------------------- endLuminosityBlock --------------------------------------------
74 //
76 {
77  edm::LogInfo("DQMExample_Step2") << "DQMExample_Step2::endLuminosityBlock" << std::endl;
78 }
79 
80 
81 //
82 // -------------------------------------- endRun --------------------------------------------
83 //
85 {
86  edm::LogInfo("DQMExample_Step2") << "DQMExample_Step2::endRun" << std::endl;
87 
88  // create and cd into new folder
89  dbe_->setCurrentFolder("What_I_do_in_the_client/Ratio");
90 
91  //get available histograms
94 
95  if (!numerator || !denominator)
96  {
97  edm::LogError("DQMExample_Step2") << "MEs not found!" << std::endl;
98  return;
99  }
100 
101 
102  //book new histogram
103  h_ptRatio = dbe_->book1D("ptRatio","pt ratio pf matched objects",50,0.,100.);
104  h_ptRatio->setAxisTitle("pt [GeV]");
105 
106  for (int iBin=1; iBin<numerator->getNbinsX(); ++iBin)
107  {
108  if(denominator->getBinContent(iBin) == 0)
109  h_ptRatio->setBinContent(iBin, 0.);
110  else
111  h_ptRatio->setBinContent(iBin, numerator->getBinContent(iBin) / denominator->getBinContent(iBin));
112  }
113 }
114 
115 //
116 // -------------------------------------- endJob --------------------------------------------
117 //
119 {
120  edm::LogInfo("DQMExample_Step2") << "DQMExample_Step2::endJob" << std::endl;
121 }
122 
123 
T getParameter(std::string const &) const
void setBinContent(int binx, double content)
set content of bin (1-D)
list numerator
Definition: cuy.py:483
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:873
virtual ~DQMExample_Step2()
MonitorElement * h_ptRatio
void beginRun(edm::Run const &run, edm::EventSetup const &eSetup)
void endRun(edm::Run const &run, edm::EventSetup const &eSetup)
void endLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup)
void analyze(edm::Event const &e, edm::EventSetup const &eSetup)
list denominator
Definition: cuy.py:484
DQMExample_Step2(const edm::ParameterSet &ps)
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. &quot;my/long/dir/my_histo&quot;)
Definition: DQMStore.cc:1624
std::string denMonitorName_
double getBinContent(int binx) const
get content of bin (1-D)
void beginLuminosityBlock(edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup)
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 setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:585
Definition: Run.h:41