CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 //
17 PFMETMonitor::PFMETMonitor(Benchmark::Mode mode) : Benchmark(mode), candBench_(mode), matchCandBench_(mode) {
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 //
47  mode_ = (Benchmark::Mode)parameterSet.getParameter<int>("mode");
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 
74  setRange(ptmin, ptmax, etamin, etamax, phimin, phimax);
75 
78 }
79 
80 //
81 // -- Create histograms accessing parameters from ParameterSet
82 //
84  candBench_.setup(b, parameterSet);
85  matchCandBench_.setup(b, parameterSet);
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 }
TH1F * sumEt_
Definition: PFMETMonitor.h:47
TProfile * profile_delta_ex_VS_set_
Definition: PFMETMonitor.h:53
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
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
TProfile * profileRMS_delta_set_VS_set_
Definition: PFMETMonitor.h:58
TProfile * profile_delta_set_VS_set_
Definition: PFMETMonitor.h:54
void fillOne(const reco::Candidate &candidate, const reco::Candidate &matchedCandidate)
fill histograms with a given particle
double pt() const final
transverse momentum
TH2F * delta_ex_VS_set_
Definition: PFMETMonitor.h:49
TH2F * delta_set_VS_set_
Definition: PFMETMonitor.h:50
void fillOne(const reco::Candidate &candidate)
fill histograms with a given particle
abstract base class
Definition: Benchmark.h:19
void setup(DQMStore::IBooker &b)
book histograms
bool histogramBooked_
Definition: PFMETMonitor.h:65
TH1F * delta_ex_
Definition: PFMETMonitor.h:48
virtual void setDirectory(TDirectory *dir)
Definition: Benchmark.cc:13
TProfile * profileRMS_delta_set_Over_set_VS_set_
Definition: PFMETMonitor.h:59
TProfile * profileRMS_delta_ex_VS_set_
Definition: PFMETMonitor.h:57
~PFMETMonitor() override
Definition: PFMETMonitor.cc:41
void setDirectory(TDirectory *dir) override
set directory (to use in ROOT)
double px() const final
x coordinate of momentum vector
double sumEt() const
Definition: MET.h:56
Definition: MET.h:41
ParameterSet const & parameterSet(StableProvenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
PFMETMonitor(Benchmark::Mode mode=Benchmark::DEFAULT)
Definition: PFMETMonitor.cc:17
void setParameters(Mode mode)
Definition: Benchmark.h:39
double py() const final
y coordinate of momentum vector
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
CandidateBenchmark candBench_
Definition: PFMETMonitor.h:61
void fillOne(const reco::MET &met, const reco::MET &matchedMet, float &minVal, float &maxVal)
TH2F * delta_set_Over_set_VS_set_
Definition: PFMETMonitor.h:51
bool createMETSpecificHistos_
Definition: PFMETMonitor.h:64
void setRange(float ptMin, float ptMax, float etaMin, float etaMax, float phiMin, float phiMax)
Definition: Benchmark.h:41
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
double b
Definition: hdecay.h:118
TProfile * profile_delta_set_Over_set_VS_set_
Definition: PFMETMonitor.h:55
double ptmin
Definition: HydjetWrapper.h:84
Mode mode_
Definition: Benchmark.h:118
void setup(DQMStore::IBooker &b)
book histograms
void setup(DQMStore::IBooker &b)
book histograms
bool isInRange(float pt, float eta, float phi) const
Definition: Benchmark.h:50
double phi() const final
momentum azimuthal angle
MatchCandidateBenchmark matchCandBench_
Definition: PFMETMonitor.h:62
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
double eta() const final
momentum pseudorapidity