CMS 3D CMS Logo

PFCandidateMonitor.cc
Go to the documentation of this file.
6 
7 #include <TFile.h>
8 #include <TH1.h>
9 #include <TH2.h>
10 #include <TROOT.h>
11 
12 //
13 // -- Constructor
14 //
16  : Benchmark(mode), candBench_(mode), matchCandBench_(mode), dRMax_(dRMax), matchCharge_(matchCharge) {
17  setRange(0.0, 10e10, -10.0, 10.0, -3.14, 3.14);
18 
19  pt_gen_ = nullptr;
20  eta_gen_ = nullptr;
21  phi_gen_ = nullptr;
22 
23  pt_ref_ = nullptr;
24  eta_ref_ = nullptr;
25  phi_ref_ = nullptr;
26 
27  deltaR_ = nullptr;
28 
29  createReferenceHistos_ = false;
30  histogramBooked_ = false;
31 }
32 
33 //
34 // -- Destructor
35 //
37 
38 //
39 // -- Set Parameters accessing them from ParameterSet
40 //
42  dRMax_ = parameterSet.getParameter<double>("deltaRMax");
43  matchCharge_ = parameterSet.getParameter<bool>("matchCharge");
45  createReferenceHistos_ = parameterSet.getParameter<bool>("CreateReferenceHistos");
46  createEfficiencyHistos_ = parameterSet.getParameter<bool>("CreateEfficiencyHistos");
47 
48  setRange(parameterSet.getParameter<double>("ptMin"),
49  parameterSet.getParameter<double>("ptMax"),
50  parameterSet.getParameter<double>("etaMin"),
51  parameterSet.getParameter<double>("etaMax"),
52  parameterSet.getParameter<double>("phiMin"),
53  parameterSet.getParameter<double>("phiMax"));
54 
57 }
58 
59 //
60 // -- Set Parameters
61 //
63  bool matchCharge,
65  float ptmin,
66  float ptmax,
67  float etamin,
68  float etamax,
69  float phimin,
70  float phimax,
71  bool refHistoFlag) {
72  dRMax_ = dRMax;
74  mode_ = mode;
75  createReferenceHistos_ = refHistoFlag;
76 
78 
81 }
82 
83 //
84 // -- Create histograms accessing parameters from ParameterSet
85 //
89 
92  edm::ParameterSet etaPS = parameterSet.getParameter<edm::ParameterSet>("EtaHistoParameter");
93  edm::ParameterSet phiPS = parameterSet.getParameter<edm::ParameterSet>("PhiHistoParameter");
94 
96 
97  if (ptPS.getParameter<bool>("switchOn")) {
98  pt_ref_ = book1D(b,
99  "pt_ref_",
100  "p_{T}_ref;p_{T} (GeV)",
101  ptPS.getParameter<int32_t>("nBin"),
102  ptPS.getParameter<double>("xMin"),
103  ptPS.getParameter<double>("xMax"));
105  pt_gen_ = book1D(b,
106  "pt_gen_",
107  "p_{T}_gen;p_{T} (GeV)",
108  ptPS.getParameter<int32_t>("nBin"),
109  ptPS.getParameter<double>("xMin"),
110  ptPS.getParameter<double>("xMax"));
111  }
112  }
113 
114  if (etaPS.getParameter<bool>("switchOn")) {
115  eta_ref_ = book1D(b,
116  "eta_ref_",
117  "#eta_ref;#eta",
118  etaPS.getParameter<int32_t>("nBin"),
119  etaPS.getParameter<double>("xMin"),
120  etaPS.getParameter<double>("xMax"));
122  eta_gen_ = book1D(b,
123  "eta_gen_",
124  "#eta_gen;#eta",
125  etaPS.getParameter<int32_t>("nBin"),
126  etaPS.getParameter<double>("xMin"),
127  etaPS.getParameter<double>("xMax"));
128  }
129  }
130 
131  if (phiPS.getParameter<bool>("switchOn")) {
132  phi_ref_ = book1D(b,
133  "phi_ref_",
134  "#phi_ref;#phi",
135  phiPS.getParameter<int32_t>("nBin"),
136  phiPS.getParameter<double>("xMin"),
137  phiPS.getParameter<double>("xMax"));
139  phi_gen_ = book1D(b,
140  "phi_gen_",
141  "#phi_gen;#phi",
142  phiPS.getParameter<int32_t>("nBin"),
143  phiPS.getParameter<double>("xMin"),
144  phiPS.getParameter<double>("xMax"));
145  }
146  }
147 
148  if (createEfficiencyHistos_ && dR.getParameter<bool>("switchOn")) {
149  deltaR_ = book1D(b,
150  "deltaR_",
151  "#DeltaR;#DeltaR",
152  dR.getParameter<int32_t>("nBin"),
153  dR.getParameter<double>("xMin"),
154  dR.getParameter<double>("xMax"));
155  }
156 
157  histogramBooked_ = true;
158  }
159 }
160 
161 //
162 // -- Create histograms using local parameters
163 //
165  candBench_.setup(b);
167 
169  PhaseSpace ptPS(100, 0, 100);
170  PhaseSpace phiPS(360, -3.1416, 3.1416);
171  PhaseSpace etaPS(100, -5, 5);
172 
173  pt_ref_ = book1D(b, "pt_ref_", "p_{T}_ref;p_{T} (GeV)", ptPS.n, ptPS.m, ptPS.M);
175  pt_gen_ = book1D(b, "pt_gen_", "p_{T}_gen;p_{T} (GeV)", ptPS.n, ptPS.m, ptPS.M);
176  }
177 
178  eta_ref_ = book1D(b, "eta_ref_", "#eta_ref;#eta", etaPS.n, etaPS.m, etaPS.M);
180  eta_gen_ = book1D(b, "eta_gen_", "#eta_gen;#eta", etaPS.n, etaPS.m, etaPS.M);
181  }
182 
183  phi_ref_ = book1D(b, "phi_ref_", "#phi_ref;#phi", phiPS.n, phiPS.m, phiPS.M);
185  phi_gen_ = book1D(b, "phi_gen_", "#phi_gen;#phi", phiPS.n, phiPS.m, phiPS.M);
186  }
187 
188  histogramBooked_ = true;
189  }
190 }
191 
192 //
193 // -- Set directory to book histograms using ROOT
194 //
197 
200 }
201 
202 //
203 // -- fill histograms for a single collection
204 //
206  if (matching_done_) {
208  if (pt_ref_)
209  pt_ref_->Fill(cand.pt());
210  if (eta_ref_)
211  eta_ref_->Fill(cand.eta());
212  if (phi_ref_)
213  phi_ref_->Fill(cand.phi());
214  }
216  if (pt_gen_)
217  pt_gen_->Fill(cand.pt());
218  if (eta_gen_)
219  eta_gen_->Fill(cand.eta());
220  if (phi_gen_)
221  phi_gen_->Fill(cand.phi());
222  }
223 }
Benchmark
abstract base class
Definition: Benchmark.h:19
PFCandidateMonitor::matchCharge_
bool matchCharge_
Definition: PFCandidateMonitor.h:77
MatchCandidateBenchmark::setup
void setup(DQMStore::IBooker &b)
book histograms
Definition: MatchCandidateBenchmark.cc:28
PFCandidateMonitor::createEfficiencyHistos_
bool createEfficiencyHistos_
Definition: PFCandidateMonitor.h:82
phimin
float phimin
Definition: ReggeGribovPartonMCHadronizer.h:107
Matchers.h
Benchmark::PhaseSpace::n
int n
Definition: Benchmark.h:25
PFJet.h
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
Jet.h
Benchmark::setParameters
void setParameters(Mode mode)
Definition: Benchmark.h:39
PFCandidateMonitor::phi_ref_
TH1F * phi_ref_
Definition: PFCandidateMonitor.h:73
Benchmark::setRange
void setRange(float ptMin, float ptMax, float etaMin, float etaMax, float phiMin, float phiMax)
Definition: Benchmark.h:41
PFCandidateMonitor::setParameters
void setParameters(float dRMax, bool matchCharge, Benchmark::Mode mode, float ptmin, float ptmax, float etamin, float etamax, float phimin, float phimax, bool refHistoFlag)
set the parameters locally
Definition: PFCandidateMonitor.cc:62
muonTiming_cfi.etamin
etamin
Definition: muonTiming_cfi.py:30
PFCandidateMonitor::candBench_
CandidateBenchmark candBench_
Definition: PFCandidateMonitor.h:64
CandidateBenchmark::setup
void setup(DQMStore::IBooker &b)
book histograms
Definition: CandidateBenchmark.cc:24
Benchmark::PhaseSpace
Definition: Benchmark.h:23
edm::parameterSet
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
pfCandidateManager_cfi.matchCharge
matchCharge
Definition: pfCandidateManager_cfi.py:15
PFCandidateMonitor::dRMax_
float dRMax_
Definition: PFCandidateMonitor.h:76
PFCandidateMonitor::createReferenceHistos_
bool createReferenceHistos_
Definition: PFCandidateMonitor.h:78
PFCandidateMonitor::pt_ref_
TH1F * pt_ref_
Definition: PFCandidateMonitor.h:71
PFCandidateMonitor::histogramBooked_
bool histogramBooked_
Definition: PFCandidateMonitor.h:79
Benchmark::mode_
Mode mode_
Definition: Benchmark.h:118
b
double b
Definition: hdecay.h:118
PFCandidateMonitor::pt_gen_
TH1F * pt_gen_
Definition: PFCandidateMonitor.h:67
PFCandidateMonitor::matchCandBench_
MatchCandidateBenchmark matchCandBench_
Definition: PFCandidateMonitor.h:65
PFCandidateMonitor::setDirectory
void setDirectory(TDirectory *dir) override
set directory (to use in ROOT)
Definition: PFCandidateMonitor.cc:195
edm::ParameterSet
Definition: ParameterSet.h:47
PFCandidateMonitor.h
Benchmark::Mode
Mode
Definition: Benchmark.h:32
PFCandidateMonitor::fillOne
void fillOne(const reco::Candidate &cand)
Definition: PFCandidateMonitor.cc:205
cand
Definition: decayParser.h:32
Benchmark::PhaseSpace::M
float M
Definition: Benchmark.h:27
Benchmark::PhaseSpace::m
float m
Definition: Benchmark.h:26
PFCandidateMonitor::setup
void setup(DQMStore::IBooker &b)
book histograms
Definition: PFCandidateMonitor.cc:164
PFCandidateMonitor::phi_gen_
TH1F * phi_gen_
Definition: PFCandidateMonitor.h:69
PFCandidateMonitor::PFCandidateMonitor
PFCandidateMonitor(float dRMax=0.3, bool matchCharge=true, Benchmark::Mode mode=Benchmark::DEFAULT)
Definition: PFCandidateMonitor.cc:15
reco::Candidate
Definition: Candidate.h:27
Benchmark::setDirectory
virtual void setDirectory(TDirectory *dir)
Definition: Benchmark.cc:13
phimax
float phimax
Definition: ReggeGribovPartonMCHadronizer.h:106
Benchmark::book1D
TH1F * book1D(DQMStore::IBooker &b, const char *histname, const char *title, int nbins, float xmin, float xmax)
book a 1D histogram, either with DQM or plain root depending if DQM_ has been initialized in a child ...
Definition: Benchmark.cc:15
metBenchmark_cfi.dRMax
dRMax
Definition: metBenchmark_cfi.py:18
muonTiming_cfi.ptmax
ptmax
Definition: muonTiming_cfi.py:22
muonTiming_cfi.etamax
etamax
Definition: muonTiming_cfi.py:23
PFCandidateMonitor::~PFCandidateMonitor
~PFCandidateMonitor() override
Definition: PFCandidateMonitor.cc:36
ptmin
double ptmin
Definition: HydjetWrapper.h:84
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
dqm::implementation::IBooker
Definition: DQMStore.h:43
PFCandidateMonitor::eta_gen_
TH1F * eta_gen_
Definition: PFCandidateMonitor.h:68
HGC3DClusterGenMatchSelector_cfi.dR
dR
Definition: HGC3DClusterGenMatchSelector_cfi.py:7
ParameterSet.h
PFCandidateMonitor::matching_done_
bool matching_done_
Definition: PFCandidateMonitor.h:81
PFCandidateMonitor::eta_ref_
TH1F * eta_ref_
Definition: PFCandidateMonitor.h:72
PFCandidateMonitor::deltaR_
TH1F * deltaR_
Definition: PFCandidateMonitor.h:75
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23