CMS 3D CMS Logo

MatchCandidateBenchmark.cc
Go to the documentation of this file.
2 
4 
5 #include <TFile.h>
6 #include <TH1.h>
7 #include <TH2.h>
8 #include <TProfile.h>
9 #include <TROOT.h>
10 
11 using namespace std;
12 
14  delta_et_Over_et_VS_et_ = nullptr;
15  delta_et_VS_et_ = nullptr;
16  delta_eta_VS_et_ = nullptr;
17  delta_phi_VS_et_ = nullptr;
18 
19  BRdelta_et_Over_et_VS_et_ = nullptr;
20  ERdelta_et_Over_et_VS_et_ = nullptr;
21  // pTRes are initialzied in the setup since ptBinsPS.size() is needed
22 
23  histogramBooked_ = false;
24 }
25 
27 
29  if (!histogramBooked_) {
30  PhaseSpace ptPS;
31  PhaseSpace dptOvptPS;
32  PhaseSpace dptPS;
33  PhaseSpace detaPS;
34  PhaseSpace dphiPS;
35  switch (mode_) {
36  case VALIDATION:
37  ptPS = PhaseSpace(100, 0, 1000);
38  dptOvptPS = PhaseSpace(200, -1, 1);
39  dphiPS = PhaseSpace(200, -1, 1);
40  detaPS = PhaseSpace(200, -1, 1);
41  dptPS = PhaseSpace(100, -100, 100);
42  break;
43  case DQMOFFLINE:
44  default:
45  ptPS = PhaseSpace(50, 0, 100);
46  dptOvptPS = PhaseSpace(50, -1, 1);
47  dphiPS = PhaseSpace(50, -1, 1);
48  detaPS = PhaseSpace(50, -1, 1);
49  dptPS = PhaseSpace(50, -50, 50);
50  break;
51  }
52  float ptBins[11] = {0, 1, 2, 5, 10, 20, 50, 100, 200, 400, 1000};
53  int size = sizeof(ptBins) / sizeof(*ptBins);
54 
56  "delta_et_Over_et_VS_et_",
57  ";E_{T, true} (GeV);#DeltaE_{T}/E_{T}",
58  size,
59  ptBins,
60  dptOvptPS.n,
61  dptOvptPS.m,
62  dptOvptPS.M);
63 
65  "BRdelta_et_Over_et_VS_et_",
66  ";E_{T, true} (GeV);#DeltaE_{T}/E_{T}",
67  size,
68  ptBins,
69  dptOvptPS.n,
70  dptOvptPS.m,
71  dptOvptPS.M);
73  "ERdelta_et_Over_et_VS_et_",
74  ";E_{T, true} (GeV);#DeltaE_{T}/E_{T}",
75  size,
76  ptBins,
77  dptOvptPS.n,
78  dptOvptPS.m,
79  dptOvptPS.M);
80 
82  book2D(b, "delta_et_VS_et_", ";E_{T, true} (GeV);#DeltaE_{T}", size, ptBins, dptPS.n, dptPS.m, dptPS.M);
83 
85  book2D(b, "delta_eta_VS_et_", ";#E_{T, true} (GeV);#Delta#eta", size, ptBins, detaPS.n, detaPS.m, detaPS.M);
86 
88  book2D(b, "delta_phi_VS_et_", ";E_{T, true} (GeV);#Delta#phi", size, ptBins, dphiPS.n, dphiPS.m, dphiPS.M);
89  pTRes_.resize(size);
90  BRpTRes_.resize(size);
91  ERpTRes_.resize(size);
92  for (size_t i = 0; i < pTRes_.size(); i++) {
93  pTRes_[i] = nullptr;
94  BRpTRes_[i] = nullptr;
95  ERpTRes_[i] = nullptr;
96  }
97 
98  histogramBooked_ = true;
99  }
100 }
101 
103  const std::vector<double> &ptBinsPS = ps.getParameter<std::vector<double> >("VariablePtBins");
104  if (ptBinsPS.size() > 1) {
105  ptBins_.reserve(ptBinsPS.size());
106  for (size_t i = 0; i < ptBinsPS.size(); i++)
107  ptBins_.push_back(ptBinsPS[i]);
108  } else {
109  Int_t nFixedBins = ptPS.getParameter<int32_t>("nBin");
110  ptBins_.reserve(nFixedBins + 1);
111  for (Int_t i = 0; i <= nFixedBins; i++)
112  ptBins_.push_back(ptPS.getParameter<double>("xMin") +
113  i * ((ptPS.getParameter<double>("xMax") - ptPS.getParameter<double>("xMin")) / nFixedBins));
114  }
115 }
117  if (!histogramBooked_) {
118  edm::ParameterSet ptPS = parameterSet.getParameter<edm::ParameterSet>("PtHistoParameter");
119  edm::ParameterSet dptPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPtHistoParameter");
120  edm::ParameterSet dptOvptPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPtOvPtHistoParameter");
121  edm::ParameterSet detaPS = parameterSet.getParameter<edm::ParameterSet>("DeltaEtaHistoParameter");
122  edm::ParameterSet dphiPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPhiHistoParameter");
124  pTRes_.resize(ptBins_.size() - 1);
125  BRpTRes_.resize(ptBins_.size() - 1);
126  ERpTRes_.resize(ptBins_.size() - 1);
127  if (!pTRes_.empty()) {
128  for (size_t i = 0; i < pTRes_.size(); i++) {
129  pTRes_[i] = nullptr;
130  BRpTRes_[i] = nullptr;
131  ERpTRes_[i] = nullptr;
132  }
133  }
134 
135  if (dptOvptPS.getParameter<bool>("switchOn")) {
137  "delta_et_Over_et_VS_et_",
138  ";E_{T, true} (GeV);#DeltaE_{T}/E_{T}",
139  ptBins_.size() - 1,
140  &(ptBins_.front()),
141  dptOvptPS.getParameter<int32_t>("nBin"),
142  dptOvptPS.getParameter<double>("xMin"),
143  dptOvptPS.getParameter<double>("xMax"));
144  }
145  if (dptOvptPS.getParameter<bool>("slicingOn")) {
146  for (size_t i = 0; i < pTRes_.size(); i++) {
147  pTRes_[i] = book1D(b,
148  TString::Format("Pt%d_%d", (int)ptBins_[i], (int)ptBins_[i + 1]),
149  ";#Deltap_{T}/p_{T};Entries",
150  dptOvptPS.getParameter<int32_t>("nBin"),
151  dptOvptPS.getParameter<double>("xMin"),
152  dptOvptPS.getParameter<double>("xMax"));
153  BRpTRes_[i] = book1D(b,
154  TString::Format("BRPt%d_%d", (int)ptBins_[i], (int)ptBins_[i + 1]),
155  ";#Deltap_{T}/p_{T};Entries",
156  dptOvptPS.getParameter<int32_t>("nBin"),
157  dptOvptPS.getParameter<double>("xMin"),
158  dptOvptPS.getParameter<double>("xMax"));
159  ERpTRes_[i] = book1D(b,
160  TString::Format("ERPt%d_%d", (int)ptBins_[i], (int)ptBins_[i + 1]),
161  ";#Deltap_{T}/p_{T};Entries",
162  dptOvptPS.getParameter<int32_t>("nBin"),
163  dptOvptPS.getParameter<double>("xMin"),
164  dptOvptPS.getParameter<double>("xMax"));
165  }
166  }
167  if (dptOvptPS.getParameter<bool>("BROn")) {
169  "BRdelta_et_Over_et_VS_et_",
170  ";E_{T, true} (GeV);#DeltaE_{T}/E_{T}",
171  ptBins_.size() - 1,
172  &(ptBins_.front()),
173  dptOvptPS.getParameter<int32_t>("nBin"),
174  dptOvptPS.getParameter<double>("xMin"),
175  dptOvptPS.getParameter<double>("xMax"));
176  }
177  if (dptOvptPS.getParameter<bool>("EROn")) {
179  "ERdelta_et_Over_et_VS_et_",
180  ";E_{T, true} (GeV);#DeltaE_{T}/E_{T}",
181  ptBins_.size() - 1,
182  &(ptBins_.front()),
183  dptOvptPS.getParameter<int32_t>("nBin"),
184  dptOvptPS.getParameter<double>("xMin"),
185  dptOvptPS.getParameter<double>("xMax"));
186  }
187 
188  if (dptPS.getParameter<bool>("switchOn")) {
190  "delta_et_VS_et_",
191  ";E_{T, true} (GeV);#DeltaE_{T}",
192  ptBins_.size() - 1,
193  &(ptBins_.front()),
194  dptPS.getParameter<int32_t>("nBin"),
195  dptPS.getParameter<double>("xMin"),
196  dptPS.getParameter<double>("xMax"));
197  }
198 
199  if (detaPS.getParameter<bool>("switchOn")) {
201  "delta_eta_VS_et_",
202  ";E_{T, true} (GeV);#Delta#eta",
203  ptBins_.size() - 1,
204  &(ptBins_.front()),
205  detaPS.getParameter<int32_t>("nBin"),
206  detaPS.getParameter<double>("xMin"),
207  detaPS.getParameter<double>("xMax"));
208  }
209 
210  if (dphiPS.getParameter<bool>("switchOn")) {
212  "delta_phi_VS_et_",
213  ";E_{T, true} (GeV);#Delta#phi",
214  ptBins_.size() - 1,
215  &(ptBins_.front()),
216  dphiPS.getParameter<int32_t>("nBin"),
217  dphiPS.getParameter<double>("xMin"),
218  dphiPS.getParameter<double>("xMax"));
219  }
220  eta_min_barrel_ = dptOvptPS.getParameter<double>("BREtaMin");
221  eta_max_barrel_ = dptOvptPS.getParameter<double>("BREtaMax");
222  eta_min_endcap_ = dptOvptPS.getParameter<double>("EREtaMin");
223  eta_max_endcap_ = dptOvptPS.getParameter<double>("EREtaMax");
224  histogramBooked_ = true;
225  }
226 }
227 
229  if (!isInRange(cand.pt(), cand.eta(), cand.phi()))
230  return;
231 
232  if (histogramBooked_) {
234  delta_et_Over_et_VS_et_->Fill(matchedCand.pt(), (cand.pt() - matchedCand.pt()) / matchedCand.pt());
235  if (fabs(cand.eta()) <= 1.4)
237  BRdelta_et_Over_et_VS_et_->Fill(matchedCand.pt(), (cand.pt() - matchedCand.pt()) / matchedCand.pt());
238  if (fabs(cand.eta()) >= 1.6 && fabs(cand.eta()) <= 2.4)
240  ERdelta_et_Over_et_VS_et_->Fill(matchedCand.pt(), (cand.pt() - matchedCand.pt()) / matchedCand.pt());
241  if (delta_et_VS_et_)
242  delta_et_VS_et_->Fill(matchedCand.pt(), cand.pt() - matchedCand.pt());
243  if (delta_eta_VS_et_)
244  delta_eta_VS_et_->Fill(matchedCand.pt(), cand.eta() - matchedCand.eta());
245  if (delta_phi_VS_et_)
246  delta_phi_VS_et_->Fill(matchedCand.pt(), cand.phi() - matchedCand.phi());
247  }
248 }
249 
250 bool MatchCandidateBenchmark::inEtaRange(double value, bool inBarrel) {
251  if (inBarrel) {
253  }
255 }
256 
258  const reco::Candidate &matchedCand,
260  if (!isInRange(cand.pt(), cand.eta(), cand.phi()))
261  return;
262 
263  if (histogramBooked_) {
264  edm::ParameterSet dptOvptPS = parameterSet.getParameter<edm::ParameterSet>("DeltaPtOvPtHistoParameter");
265 
266  if (matchedCand.pt() > ptBins_.at(0)) { // underflow problem
268  delta_et_Over_et_VS_et_->Fill(matchedCand.pt(), (cand.pt() - matchedCand.pt()) / matchedCand.pt());
269  if (BRdelta_et_Over_et_VS_et_ and inBarrelRange(matchedCand.eta()))
270  BRdelta_et_Over_et_VS_et_->Fill(matchedCand.pt(), (cand.pt() - matchedCand.pt()) / matchedCand.pt());
271  if (ERdelta_et_Over_et_VS_et_ and inEndcapRange(matchedCand.eta()))
272  ERdelta_et_Over_et_VS_et_->Fill(matchedCand.pt(), (cand.pt() - matchedCand.pt()) / matchedCand.pt());
273  if (delta_et_VS_et_)
274  delta_et_VS_et_->Fill(matchedCand.pt(), cand.pt() - matchedCand.pt());
275  if (delta_eta_VS_et_)
276  delta_eta_VS_et_->Fill(matchedCand.pt(), cand.eta() - matchedCand.eta());
277  if (delta_phi_VS_et_)
278  delta_phi_VS_et_->Fill(matchedCand.pt(), cand.phi() - matchedCand.phi());
279  }
280 
281  for (size_t i = 0; i < pTRes_.size(); i++) {
282  if (matchedCand.pt() >= ptBins_.at(i) && matchedCand.pt() < ptBins_.at(i + 1)) {
283  if (pTRes_[i])
284  pTRes_[i]->Fill((cand.pt() - matchedCand.pt()) / matchedCand.pt());
285  if (BRpTRes_[i])
286  BRpTRes_[i]->Fill((cand.pt() - matchedCand.pt()) / matchedCand.pt()); // Fill Barrel
287  if (ERpTRes_[i])
288  ERpTRes_[i]->Fill((cand.pt() - matchedCand.pt()) / matchedCand.pt()); // Fill Endcap
289  }
290  }
291  }
292 }
MatchCandidateBenchmark::inEndcapRange
bool inEndcapRange(double value)
Definition: MatchCandidateBenchmark.h:53
Benchmark
abstract base class
Definition: Benchmark.h:19
mps_fire.i
i
Definition: mps_fire.py:355
MatchCandidateBenchmark::ERpTRes_
std::vector< TH1F * > ERpTRes_
Definition: MatchCandidateBenchmark.h:40
MatchCandidateBenchmark::BRpTRes_
std::vector< TH1F * > BRpTRes_
Definition: MatchCandidateBenchmark.h:39
MatchCandidateBenchmark::computePtBins
void computePtBins(const edm::ParameterSet &, const edm::ParameterSet &)
Definition: MatchCandidateBenchmark.cc:102
MatchCandidateBenchmark::setup
void setup(DQMStore::IBooker &b)
book histograms
Definition: MatchCandidateBenchmark.cc:28
MatchCandidateBenchmark::~MatchCandidateBenchmark
~MatchCandidateBenchmark() override
Definition: MatchCandidateBenchmark.cc:26
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
MatchCandidateBenchmark::BRdelta_et_Over_et_VS_et_
TH2F * BRdelta_et_Over_et_VS_et_
Definition: MatchCandidateBenchmark.h:36
Benchmark::isInRange
bool isInRange(float pt, float eta, float phi) const
Definition: Benchmark.h:50
MatchCandidateBenchmark::delta_phi_VS_et_
TH2F * delta_phi_VS_et_
Definition: MatchCandidateBenchmark.h:34
reco::Candidate::eta
virtual double eta() const =0
momentum pseudorapidity
MatchCandidateBenchmark::eta_min_barrel_
double eta_min_barrel_
Definition: MatchCandidateBenchmark.h:44
Benchmark::PhaseSpace::n
int n
Definition: Benchmark.h:25
ALCARECOPromptCalibProdSiPixelAli0T_cff.mode
mode
Definition: ALCARECOPromptCalibProdSiPixelAli0T_cff.py:96
MatchCandidateBenchmark::inBarrelRange
bool inBarrelRange(double value)
Definition: MatchCandidateBenchmark.h:52
reco::Candidate::pt
virtual double pt() const =0
transverse momentum
MatchCandidateBenchmark::fillOne
void fillOne(const reco::Candidate &candidate, const reco::Candidate &matchedCandidate)
fill histograms with a given particle
Definition: MatchCandidateBenchmark.cc:228
MatchCandidateBenchmark::inEtaRange
bool inEtaRange(double, bool)
Definition: MatchCandidateBenchmark.cc:250
Benchmark::DQMOFFLINE
Definition: Benchmark.h:32
MatchCandidateBenchmark::MatchCandidateBenchmark
MatchCandidateBenchmark(Mode mode)
Definition: MatchCandidateBenchmark.cc:13
MatchCandidateBenchmark::delta_eta_VS_et_
TH2F * delta_eta_VS_et_
Definition: MatchCandidateBenchmark.h:33
Benchmark::PhaseSpace
Definition: Benchmark.h:23
MatchCandidateBenchmark::pTRes_
std::vector< TH1F * > pTRes_
Definition: MatchCandidateBenchmark.h:38
MatchCandidateBenchmark::eta_max_barrel_
double eta_max_barrel_
Definition: MatchCandidateBenchmark.h:45
MatchCandidateBenchmark.h
MatchCandidateBenchmark::eta_min_endcap_
double eta_min_endcap_
Definition: MatchCandidateBenchmark.h:46
Benchmark::mode_
Mode mode_
Definition: Benchmark.h:118
b
double b
Definition: hdecay.h:118
Benchmark::VALIDATION
Definition: Benchmark.h:32
edm::ParameterSet
Definition: ParameterSet.h:36
Benchmark::Mode
Mode
Definition: Benchmark.h:32
cand
Definition: decayParser.h:34
Benchmark::PhaseSpace::M
float M
Definition: Benchmark.h:27
value
Definition: value.py:1
Benchmark::PhaseSpace::m
float m
Definition: Benchmark.h:26
MatchCandidateBenchmark::histogramBooked_
bool histogramBooked_
Definition: MatchCandidateBenchmark.h:43
MatchCandidateBenchmark::ERdelta_et_Over_et_VS_et_
TH2F * ERdelta_et_Over_et_VS_et_
Definition: MatchCandidateBenchmark.h:37
reco::Candidate
Definition: Candidate.h:27
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
MatchCandidateBenchmark::eta_max_endcap_
double eta_max_endcap_
Definition: MatchCandidateBenchmark.h:47
std
Definition: JetResolutionObject.h:76
edm::parameterSet
ParameterSet const & parameterSet(Provenance const &provenance, ProcessHistory const &history)
Definition: Provenance.cc:11
dqm::implementation::IBooker
Definition: DQMStore.h:43
Candidate.h
MatchCandidateBenchmark::ptBins_
std::vector< float > ptBins_
Definition: MatchCandidateBenchmark.h:41
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
reco::Candidate::phi
virtual double phi() const =0
momentum azimuthal angle
MatchCandidateBenchmark::delta_et_Over_et_VS_et_
TH2F * delta_et_Over_et_VS_et_
Definition: MatchCandidateBenchmark.h:31
L1EGammaCrystalsEmulatorProducer_cfi.ptBins
ptBins
Definition: L1EGammaCrystalsEmulatorProducer_cfi.py:9
MatchCandidateBenchmark::delta_et_VS_et_
TH2F * delta_et_VS_et_
Definition: MatchCandidateBenchmark.h:32
findQualityFiles.size
size
Write out results.
Definition: findQualityFiles.py:443