CMS 3D CMS Logo

PFMETMonitor.cc
Go to the documentation of this file.
4 
6 
7 #include <TFile.h>
8 #include <TH1.h>
9 #include <TH2.h>
10 #include <TROOT.h>
11 
12 #include <TProfile.h>
13 
14 //
15 // -- Constructor
16 //
18  setRange(0.0, 10e10, -10.0, 10.0, -3.14, 3.14);
19 
20  px_ = nullptr;
21  sumEt_ = nullptr;
22  delta_ex_ = nullptr;
23  delta_ex_VS_set_ = nullptr;
24  delta_set_VS_set_ = nullptr;
26 
27  profile_delta_ex_VS_set_ = nullptr;
28  profile_delta_set_VS_set_ = nullptr;
33 
35  histogramBooked_ = false;
36 }
37 
38 //
39 // -- Destructor
40 //
42 
43 //
44 // -- Set Parameters accessing them from ParameterSet
45 //
48  createMETSpecificHistos_ = parameterSet.getParameter<bool>("CreateMETSpecificHistos");
49  setRange(parameterSet.getParameter<double>("ptMin"),
50  parameterSet.getParameter<double>("ptMax"),
51  parameterSet.getParameter<double>("etaMin"),
52  parameterSet.getParameter<double>("etaMax"),
53  parameterSet.getParameter<double>("phiMin"),
54  parameterSet.getParameter<double>("phiMax"));
55 
58 }
59 
60 //
61 // -- Set Parameters
62 //
64  float ptmin,
65  float ptmax,
66  float etamin,
67  float etamax,
68  float phimin,
69  float phimax,
70  bool metSpHistos) {
71  mode_ = mode;
72  createMETSpecificHistos_ = metSpHistos;
73 
75 
78 }
79 
80 //
81 // -- Create histograms accessing parameters from ParameterSet
82 //
86 
88  edm::ParameterSet pxPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPxHistoParameter");
89  edm::ParameterSet dpxPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPxHistoParameter");
90  edm::ParameterSet dptPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPtHistoParameter");
91  edm::ParameterSet setPS = parameterSet.getParameter<edm::ParameterSet>("SumEtHistoParameter");
92  edm::ParameterSet dsetPS = parameterSet.getParameter<edm::ParameterSet>("DeltaSumEtHistoParameter");
93  edm::ParameterSet setOvsetPS = parameterSet.getParameter<edm::ParameterSet>("DeltaSumEtOvSumEtHistoParameter");
94 
95  if (pxPS.getParameter<bool>("switchOn")) {
96  px_ = book1D(b,
97  "px_",
98  "px_;p_{X} (GeV)",
99  pxPS.getParameter<int32_t>("nBin"),
100  pxPS.getParameter<double>("xMin"),
101  pxPS.getParameter<double>("xMax"));
102  }
103  if (setPS.getParameter<bool>("switchOn")) {
104  sumEt_ = book1D(b,
105  "sumEt_",
106  "sumEt_;#sumE_{T}",
107  setPS.getParameter<int32_t>("nBin"),
108  setPS.getParameter<double>("xMin"),
109  setPS.getParameter<double>("xMax"));
110  }
111  if (dpxPS.getParameter<bool>("switchOn")) {
112  delta_ex_ = book1D(b,
113  "delta_ex_",
114  "#DeltaME_{X}",
115  dpxPS.getParameter<int32_t>("nBin"),
116  dpxPS.getParameter<double>("xMin"),
117  dpxPS.getParameter<double>("xMax"));
118  }
119 
120  if (dpxPS.getParameter<bool>("switchOn")) {
122  "delta_ex_VS_set_",
123  ";SE_{T, true} (GeV);#DeltaE_{X}",
124  setPS.getParameter<int32_t>("nBin"),
125  setPS.getParameter<double>("xMin"),
126  setPS.getParameter<double>("xMax"),
127  dptPS.getParameter<int32_t>("nBin"),
128  dptPS.getParameter<double>("xMin"),
129  dptPS.getParameter<double>("xMax"));
130  }
131  if (dsetPS.getParameter<bool>("switchOn")) {
133  "delta_set_VS_set_",
134  ";SE_{T, true} (GeV);#DeltaSE_{T}",
135  setPS.getParameter<int32_t>("nBin"),
136  setPS.getParameter<double>("xMin"),
137  setPS.getParameter<double>("xMax"),
138  dsetPS.getParameter<int32_t>("nBin"),
139  dsetPS.getParameter<double>("xMin"),
140  dsetPS.getParameter<double>("xMax"));
141  }
142  if (setOvsetPS.getParameter<bool>("switchOn")) {
144  "delta_set_Over_set_VS_set_",
145  ";SE_{T, true} (GeV);#DeltaSE_{T}/SE_{T}",
146  setPS.getParameter<int32_t>("nBin"),
147  setPS.getParameter<double>("xMin"),
148  setPS.getParameter<double>("xMax"),
149  setOvsetPS.getParameter<int32_t>("nBin"),
150  setOvsetPS.getParameter<double>("xMin"),
151  setOvsetPS.getParameter<double>("xMax"));
152  }
153 
154  // TProfile
155  if (dpxPS.getParameter<bool>("switchOn")) {
157  "profile_delta_ex_VS_set_",
158  ";SE_{T, true} (GeV);#DeltaE_{X}",
159  setPS.getParameter<int32_t>("nBin"),
160  setPS.getParameter<double>("xMin"),
161  setPS.getParameter<double>("xMax"),
162  dptPS.getParameter<double>("xMin"),
163  dptPS.getParameter<double>("xMax"),
164  "");
166  "profileRMS_delta_ex_VS_set_",
167  ";SE_{T, true} (GeV);#DeltaE_{X}",
168  setPS.getParameter<int32_t>("nBin"),
169  setPS.getParameter<double>("xMin"),
170  setPS.getParameter<double>("xMax"),
171  dptPS.getParameter<double>("xMin"),
172  dptPS.getParameter<double>("xMax"),
173  "s");
174  }
175  if (dsetPS.getParameter<bool>("switchOn")) {
177  "profile_delta_set_VS_set_",
178  ";SE_{T, true} (GeV);#DeltaSE_{T}",
179  setPS.getParameter<int32_t>("nBin"),
180  setPS.getParameter<double>("xMin"),
181  setPS.getParameter<double>("xMax"),
182  dsetPS.getParameter<double>("xMin"),
183  dsetPS.getParameter<double>("xMax"),
184  "");
186  "profileRMS_delta_set_VS_set_",
187  ";SE_{T, true} (GeV);#DeltaSE_{T}",
188  setPS.getParameter<int32_t>("nBin"),
189  setPS.getParameter<double>("xMin"),
190  setPS.getParameter<double>("xMax"),
191  dsetPS.getParameter<double>("xMin"),
192  dsetPS.getParameter<double>("xMax"),
193  "s");
194  }
195  if (setOvsetPS.getParameter<bool>("switchOn")) {
197  "profile_delta_set_Over_set_VS_set_",
198  ";SE_{T, true} (GeV);#DeltaSE_{T}/SE_{T}",
199  setPS.getParameter<int32_t>("nBin"),
200  setPS.getParameter<double>("xMin"),
201  setPS.getParameter<double>("xMax"),
202  setOvsetPS.getParameter<double>("xMin"),
203  setOvsetPS.getParameter<double>("xMax"),
204  "");
206  "profileRMS_delta_set_Over_set_VS_set_",
207  ";SE_{T, true} (GeV);#DeltaSE_{T}/SE_{T}",
208  setPS.getParameter<int32_t>("nBin"),
209  setPS.getParameter<double>("xMin"),
210  setPS.getParameter<double>("xMax"),
211  setOvsetPS.getParameter<double>("xMin"),
212  setOvsetPS.getParameter<double>("xMax"),
213  "s");
214  }
215  histogramBooked_ = true;
216  }
217 }
218 
219 //
220 // -- Create histograms using local parameters
221 //
223  candBench_.setup(b);
225 
227  PhaseSpace pxPS = PhaseSpace(50, 0, 200);
228  PhaseSpace dpxPS = PhaseSpace(50, -500, 500);
229  PhaseSpace setPS = PhaseSpace(50, 0.0, 3000);
230  PhaseSpace dsetPS = PhaseSpace(50, -1000.0, 1000);
231  PhaseSpace setOvsetPS = PhaseSpace(100, 0., 2.);
232 
233  px_ = book1D(b, "px_", "px_;p_{X} (GeV)", pxPS.n, pxPS.m, pxPS.M);
234  sumEt_ = book1D(b, "sumEt_", "sumEt_;#sumE_{T}", setPS.n, setPS.m, setPS.M);
235  delta_ex_ = book1D(b, "delta_ex_", "#DeltaME_{X}", dpxPS.n, dpxPS.m, dpxPS.M);
237  b, "delta_ex_VS_set_", ";SE_{T, true} (GeV);#DeltaE_{X}", setPS.n, setPS.m, setPS.M, dpxPS.n, dpxPS.m, dpxPS.M);
239  "delta_set_VS_set_",
240  ";SE_{T, true} (GeV);#DeltaSE_{T}",
241  setPS.n,
242  setPS.m,
243  setPS.M,
244  dsetPS.n,
245  dsetPS.m,
246  dsetPS.M);
247 
249  "delta_set_Over_set_VS_set_",
250  ";SE_{T, true} (GeV);#DeltaSE_{T}/SE_{T}",
251  setPS.n,
252  setPS.m,
253  setPS.M,
254  setOvsetPS.n,
255  setOvsetPS.m,
256  setOvsetPS.M);
257 
258  // TProfile
260  "profile_delta_ex_VS_set_",
261  ";SE_{T, true} (GeV);#DeltaE_{X}",
262  setPS.n,
263  setPS.m,
264  setPS.M,
265  setOvsetPS.m,
266  setOvsetPS.M,
267  "");
268 
270  "profile_delta_set_VS_set_",
271  ";SE_{T, true} (GeV);#DeltaSE_{T}",
272  setPS.n,
273  setPS.m,
274  setPS.M,
275  setOvsetPS.m,
276  setOvsetPS.M,
277  "");
278 
280  "profile_delta_set_Over_set_VS_set_",
281  ";SE_{T, true} (GeV);#DeltaSE_{T}/SE_{T}",
282  setPS.n,
283  setPS.m,
284  setPS.M,
285  setOvsetPS.m,
286  setOvsetPS.M,
287  "");
288 
289  // TProfile RMS
291  "profileRMS_delta_ex_VS_set_",
292  ";SE_{T, true} (GeV);#DeltaE_{X}",
293  setPS.n,
294  setPS.m,
295  setPS.M,
296  setOvsetPS.m,
297  setOvsetPS.M,
298  "s");
299 
301  "profileRMS_delta_set_VS_set_",
302  ";SE_{T, true} (GeV);#DeltaSE_{T}",
303  setPS.n,
304  setPS.m,
305  setPS.M,
306  setOvsetPS.m,
307  setOvsetPS.M,
308  "s");
309 
311  "profileRMS_delta_set_Over_set_VS_set_",
312  ";SE_{T, true} (GeV);#DeltaSE_{T}/SE_{T}",
313  setPS.n,
314  setPS.m,
315  setPS.M,
316  setOvsetPS.m,
317  setOvsetPS.M,
318  "s");
319  histogramBooked_ = true;
320  }
321 }
322 
323 void PFMETMonitor::setDirectory(TDirectory *dir) {
325 
328 }
329 
330 void PFMETMonitor::fillOne(const reco::MET &met, const reco::MET &matchedMet, float &minVal, float &maxVal) {
331  candBench_.fillOne(met); // std::cout <<"\nfillone MET candBench" <<std::endl;
332  matchCandBench_.fillOne(met, matchedMet); // std::cout <<"\nfillone MET
333  // MatchCandBench done" <<std::endl;
334 
336  if (!isInRange(met.pt(), met.eta(), met.phi()))
337  return;
338 
339  if (px_)
340  px_->Fill(met.px());
341  if (delta_ex_) {
342  delta_ex_->Fill(met.px() - matchedMet.px());
343  delta_ex_->Fill(met.py() - matchedMet.py());
344  }
345  if (sumEt_)
346  sumEt_->Fill(met.sumEt());
347 
348  if (delta_ex_VS_set_) {
349  delta_ex_VS_set_->Fill(matchedMet.sumEt(), met.px() - matchedMet.px());
350  delta_ex_VS_set_->Fill(matchedMet.sumEt(), met.py() - matchedMet.py());
351  profile_delta_ex_VS_set_->Fill(matchedMet.sumEt(), met.px() - matchedMet.px());
352  profile_delta_ex_VS_set_->Fill(matchedMet.sumEt(), met.py() - matchedMet.py());
353  profileRMS_delta_ex_VS_set_->Fill(matchedMet.sumEt(), met.px() - matchedMet.px());
354  profileRMS_delta_ex_VS_set_->Fill(matchedMet.sumEt(), met.py() - matchedMet.py());
355  }
356  if (delta_set_VS_set_) {
357  delta_set_VS_set_->Fill(matchedMet.sumEt(), met.sumEt() - matchedMet.sumEt());
358  profile_delta_set_VS_set_->Fill(matchedMet.sumEt(), met.sumEt() - matchedMet.sumEt());
359  profileRMS_delta_set_VS_set_->Fill(matchedMet.sumEt(), met.sumEt() - matchedMet.sumEt());
360  }
361  if (delta_set_Over_set_VS_set_ && matchedMet.sumEt() > 0.001) {
362  float setRes = (met.sumEt() - matchedMet.sumEt()) / matchedMet.sumEt();
363  if (setRes > maxVal)
364  maxVal = setRes;
365  if (setRes < minVal)
366  minVal = setRes;
367  delta_set_Over_set_VS_set_->Fill(matchedMet.sumEt(), setRes);
368  profile_delta_set_Over_set_VS_set_->Fill(matchedMet.sumEt(), setRes);
369  profileRMS_delta_set_Over_set_VS_set_->Fill(matchedMet.sumEt(), setRes);
370  }
371  }
372 }
PFMETMonitor::delta_set_VS_set_
TH2F * delta_set_VS_set_
Definition: PFMETMonitor.h:50
Benchmark
abstract base class
Definition: Benchmark.h:19
PFMETMonitor::delta_ex_VS_set_
TH2F * delta_ex_VS_set_
Definition: PFMETMonitor.h:49
MatchCandidateBenchmark::setup
void setup(DQMStore::IBooker &b)
book histograms
Definition: MatchCandidateBenchmark.cc:28
Benchmark::book2D
TH2F * book2D(DQMStore::IBooker &b, const char *histname, const char *title, int nbinsx, float xmin, float xmax, int nbinsy, float ymin, float ymax)
book a 2D histogram, either with DQM or plain root depending if DQM_ has been initialized in a child ...
Definition: Benchmark.cc:22
Benchmark::isInRange
bool isInRange(float pt, float eta, float phi) const
Definition: Benchmark.h:50
phimin
float phimin
Definition: ReggeGribovPartonMCHadronizer.h:107
PFMETMonitor::delta_set_Over_set_VS_set_
TH2F * delta_set_Over_set_VS_set_
Definition: PFMETMonitor.h:51
Matchers.h
Benchmark::PhaseSpace::n
int n
Definition: Benchmark.h:25
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
PFMETMonitor::histogramBooked_
bool histogramBooked_
Definition: PFMETMonitor.h:65
reco::MET::sumEt
double sumEt() const
Definition: MET.h:56
PFMETMonitor::profileRMS_delta_set_VS_set_
TProfile * profileRMS_delta_set_VS_set_
Definition: PFMETMonitor.h:58
Benchmark::setParameters
void setParameters(Mode mode)
Definition: Benchmark.h:39
MatchCandidateBenchmark::fillOne
void fillOne(const reco::Candidate &candidate, const reco::Candidate &matchedCandidate)
fill histograms with a given particle
Definition: MatchCandidateBenchmark.cc:228
Benchmark::setRange
void setRange(float ptMin, float ptMax, float etaMin, float etaMax, float phiMin, float phiMax)
Definition: Benchmark.h:41
PFMETMonitor::createMETSpecificHistos_
bool createMETSpecificHistos_
Definition: PFMETMonitor.h:64
muonTiming_cfi.etamin
etamin
Definition: muonTiming_cfi.py:30
PFMETMonitor::candBench_
CandidateBenchmark candBench_
Definition: PFMETMonitor.h:61
CandidateBenchmark::setup
void setup(DQMStore::IBooker &b)
book histograms
Definition: CandidateBenchmark.cc:24
BTaggingMonitor_cfi.met
met
Definition: BTaggingMonitor_cfi.py:84
Benchmark::PhaseSpace
Definition: Benchmark.h:23
reco::MET
Definition: MET.h:41
reco::LeafCandidate::py
double py() const final
y coordinate of momentum vector
Definition: LeafCandidate.h:142
PFMETMonitor::profile_delta_set_VS_set_
TProfile * profile_delta_set_VS_set_
Definition: PFMETMonitor.h:54
PFMETMonitor::sumEt_
TH1F * sumEt_
Definition: PFMETMonitor.h:47
PFMETMonitor::fillOne
void fillOne(const reco::MET &met, const reco::MET &matchedMet, float &minVal, float &maxVal)
Definition: PFMETMonitor.cc:330
Benchmark::mode_
Mode mode_
Definition: Benchmark.h:118
b
double b
Definition: hdecay.h:118
PFMETMonitor::matchCandBench_
MatchCandidateBenchmark matchCandBench_
Definition: PFMETMonitor.h:62
PFMETMonitor::profile_delta_ex_VS_set_
TProfile * profile_delta_ex_VS_set_
Definition: PFMETMonitor.h:53
edm::ParameterSet
Definition: ParameterSet.h:36
PFMETMonitor::~PFMETMonitor
~PFMETMonitor() override
Definition: PFMETMonitor.cc:41
PFMETMonitor::profile_delta_set_Over_set_VS_set_
TProfile * profile_delta_set_Over_set_VS_set_
Definition: PFMETMonitor.h:55
Benchmark::Mode
Mode
Definition: Benchmark.h:32
Benchmark::PhaseSpace::M
float M
Definition: Benchmark.h:27
Benchmark::PhaseSpace::m
float m
Definition: Benchmark.h:26
Benchmark::bookProfile
TProfile * bookProfile(DQMStore::IBooker &b, const char *histname, const char *title, int nbinsx, float xmin, float xmax, float ymin, float ymax, const char *option)
book a TProfile histogram, either with DQM or plain root depending if DQM_ has been initialized in a ...
Definition: Benchmark.cc:58
CandidateBenchmark::fillOne
void fillOne(const reco::Candidate &candidate)
fill histograms with a given particle
Definition: CandidateBenchmark.cc:90
Benchmark::setDirectory
virtual void setDirectory(TDirectory *dir)
Definition: Benchmark.cc:13
PFMETMonitor::setParameters
void setParameters(Benchmark::Mode mode, float ptmin, float ptmax, float etamin, float etamax, float phimin, float phimax, bool metSpHistos)
set the parameters locally
Definition: PFMETMonitor.cc:63
phimax
float phimax
Definition: ReggeGribovPartonMCHadronizer.h:106
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
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
MET.h
PFMETMonitor::PFMETMonitor
PFMETMonitor(Benchmark::Mode mode=Benchmark::DEFAULT)
Definition: PFMETMonitor.cc:17
muonTiming_cfi.ptmax
ptmax
Definition: muonTiming_cfi.py:22
PFMETMonitor::delta_ex_
TH1F * delta_ex_
Definition: PFMETMonitor.h:48
PFMETMonitor.h
PFMETMonitor::profileRMS_delta_set_Over_set_VS_set_
TProfile * profileRMS_delta_set_Over_set_VS_set_
Definition: PFMETMonitor.h:59
muonTiming_cfi.etamax
etamax
Definition: muonTiming_cfi.py:23
edm::parameterSet
ParameterSet const & parameterSet(Provenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
ptmin
double ptmin
Definition: HydjetWrapper.h:84
PFMETMonitor::profileRMS_delta_ex_VS_set_
TProfile * profileRMS_delta_ex_VS_set_
Definition: PFMETMonitor.h:57
dqm::implementation::IBooker
Definition: DQMStore.h:43
PFMETMonitor::setup
void setup(DQMStore::IBooker &b)
book histograms
Definition: PFMETMonitor.cc:222
PFMETMonitor::px_
TH1F * px_
Definition: PFMETMonitor.h:46
PFMETMonitor::setDirectory
void setDirectory(TDirectory *dir) override
set directory (to use in ROOT)
Definition: PFMETMonitor.cc:323
ParameterSet.h
reco::LeafCandidate::px
double px() const final
x coordinate of momentum vector
Definition: LeafCandidate.h:140
DeadROC_duringRun.dir
dir
Definition: DeadROC_duringRun.py:23