9 #include <tracking/modules/trackingPerformanceEvaluation/PerformanceEvaluationBaseClass.h>
11 #include <framework/logging/Logger.h>
13 #include <root/TAxis.h>
17 PerformanceEvaluationBaseClass:: PerformanceEvaluationBaseClass()
21 PerformanceEvaluationBaseClass::~ PerformanceEvaluationBaseClass()
27 Int_t nbins, Double_t min, Double_t max,
28 const char* xtitle, TList* histoList)
31 TH1F* h =
new TH1F(name, title, nbins, min, max);
33 h->GetXaxis()->SetTitle(xtitle);
42 Int_t nbins, Double_t* bins,
43 const char* xtitle, TList* histoList)
46 TH1F* h =
new TH1F(name, title, nbins, bins);
48 h->GetXaxis()->SetTitle(xtitle);
57 Int_t nbinsX, Double_t minX, Double_t maxX,
59 Int_t nbinsY, Double_t minY, Double_t maxY,
60 const char* titleY, TList* histoList)
63 TH2F* h =
new TH2F(name, title, nbinsX, minX, maxX, nbinsY, minY, maxY);
65 h->GetXaxis()->SetTitle(titleX);
66 h->GetYaxis()->SetTitle(titleY);
75 Int_t nbinsX, Double_t* binsX,
77 Int_t nbinsY, Double_t* binsY,
82 TH2F* h =
new TH2F(name, title, nbinsX, binsX, nbinsY, binsY);
84 h->GetXaxis()->SetTitle(titleX);
85 h->GetYaxis()->SetTitle(titleY);
94 Int_t nbinsX, Double_t minX, Double_t maxX,
96 Int_t nbinsY, Double_t minY, Double_t maxY,
98 Int_t nbinsZ, Double_t minZ, Double_t maxZ,
103 TH3F* h =
new TH3F(name, title, nbinsX, minX, maxX, nbinsY, minY, maxY, nbinsZ, minZ, maxZ);
105 h->GetXaxis()->SetTitle(titleX);
106 h->GetYaxis()->SetTitle(titleY);
107 h->GetZaxis()->SetTitle(titleZ);
116 Int_t nbinsX, Double_t* binsX,
118 Int_t nbinsY, Double_t* binsY,
120 Int_t nbinsZ, Double_t* binsZ,
125 TH3F* h =
new TH3F(name, title, nbinsX, binsX, nbinsY, binsY, nbinsZ, binsZ);
127 h->GetXaxis()->SetTitle(titleX);
128 h->GetYaxis()->SetTitle(titleY);
129 h->GetZaxis()->SetTitle(titleZ);
138 TH1* h, TList* histoList)
141 TH1F* h1 =
dynamic_cast<TH1F*
>(h);
142 TH2F* h2 =
dynamic_cast<TH2F*
>(h);
143 TH3F* h3 =
dynamic_cast<TH3F*
>(h);
148 newh =
new TH1F(*h1);
150 newh =
new TH2F(*h2);
152 newh =
new TH3F(*h3);
154 newh->SetName(newname);
155 newh->SetTitle(newtitle);
158 histoList->Add(newh);
165 TH1* hNum, TH1* hDen,
bool isEffPlot,
169 TH1F* h1den =
dynamic_cast<TH1F*
>(hDen);
170 TH1F* h1num =
dynamic_cast<TH1F*
>(hNum);
171 TH2F* h2den =
dynamic_cast<TH2F*
>(hDen);
172 TH2F* h2num =
dynamic_cast<TH2F*
>(hNum);
173 TH3F* h3den =
dynamic_cast<TH3F*
>(hDen);
174 TH3F* h3num =
dynamic_cast<TH3F*
>(hNum);
180 hden =
new TH1F(*h1den);
181 hnum =
new TH1F(*h1num);
184 hden =
new TH2F(*h2den);
185 hnum =
new TH2F(*h2num);
188 hden =
new TH3F(*h3den);
189 hnum =
new TH3F(*h3num);
197 the_axis = hden->GetXaxis();
198 the_other1 = hden->GetYaxis();
199 the_other2 = hden->GetZaxis();
200 }
else if (axisRef == 1) {
201 the_axis = hden->GetYaxis();
202 the_other1 = hden->GetXaxis();
203 the_other2 = hden->GetZaxis();
204 }
else if (axisRef == 2) {
205 the_axis = hden->GetZaxis();
206 the_other1 = hden->GetXaxis();
207 the_other2 = hden->GetYaxis();
213 if (the_axis->GetXbins()->GetSize())
214 h =
new TH1F(name, title, the_axis->GetNbins(), (the_axis->GetXbins())->GetArray());
216 h =
new TH1F(name, title, the_axis->GetNbins(), the_axis->GetXmin(), the_axis->GetXmax());
217 h->GetXaxis()->SetTitle(the_axis->GetTitle());
219 h->GetYaxis()->SetRangeUser(0.00001, 1);
224 for (
int the_bin = 1; the_bin < the_axis->GetNbins() + 1; the_bin++) {
229 for (
int other1_bin = 1; other1_bin < the_other1->GetNbins() + 1; other1_bin++)
230 for (
int other2_bin = 1; other2_bin < the_other2->GetNbins() + 1; other2_bin++) {
232 if (axisRef == 0) bin = hden->GetBin(the_bin, other1_bin, other2_bin);
233 else if (axisRef == 1) bin = hden->GetBin(other1_bin, the_bin, other2_bin);
234 else if (axisRef == 2) bin = hden->GetBin(other1_bin, other2_bin, the_bin);
236 if (hden->IsBinUnderflow(bin))
237 B2INFO(
" bin = " << bin <<
"(" << the_bin <<
"," << other1_bin <<
"," << other2_bin <<
"), UNDERFLOW");
238 if (hden->IsBinOverflow(bin))
239 B2INFO(
" bin = " << bin <<
"(" << the_bin <<
"," << other1_bin <<
"," << other2_bin <<
"), OVERFLOW");
241 num += hnum->GetBinContent(bin);
242 den += hden->GetBinContent(bin);
251 eff = (double)num / den;
252 err = sqrt(eff * (1 - eff)) / sqrt(den);
256 h->SetBinContent(the_bin, eff);
257 h->SetBinError(the_bin, err);
259 h->SetBinContent(the_bin, 1 - eff);
260 h->SetBinError(the_bin, err);
272 if ((h3_xPerMCParticle ==
nullptr) || (h3_MCParticle ==
nullptr))
276 TH1F* h_ineff_pt =
createHistogramsRatio(
"hineffpt",
"inefficiency VS pt, normalized to MCParticles", h3_xPerMCParticle,
277 h3_MCParticle,
false, 0);
278 histoList->Add(h_ineff_pt);
280 TH1F* h_ineff_theta =
createHistogramsRatio(
"hinefftheta",
"inefficiency VS #theta, normalized to MCParticles",
281 h3_xPerMCParticle, h3_MCParticle,
false, 1);
282 histoList->Add(h_ineff_theta);
284 TH1F* h_ineff_phi =
createHistogramsRatio(
"hineffphi",
"inefficiency VS #phi, normalized to MCParticles", h3_xPerMCParticle,
285 h3_MCParticle,
false, 2);
286 histoList->Add(h_ineff_phi);
292 if ((h3_xPerMCParticle ==
nullptr) || (h3_MCParticle ==
nullptr))
296 TH1F* h_eff_pt =
createHistogramsRatio(
"heffpt",
"efficiency VS pt, normalized to MCParticles", h3_xPerMCParticle,
297 h3_MCParticle,
true, 0);
298 histoList->Add(h_eff_pt);
300 TH1F* h_eff_theta =
createHistogramsRatio(
"hefftheta",
"efficiency VS #theta, normalized to MCParticles", h3_xPerMCParticle,
301 h3_MCParticle,
true, 1);
302 histoList->Add(h_eff_theta);
304 TH1F* h_eff_phi =
createHistogramsRatio(
"heffphi",
"efficiency VS #phi, normalized to MCParticles", h3_xPerMCParticle,
305 h3_MCParticle,
true, 2);
306 histoList->Add(h_eff_phi);
314 if ((h3_X ==
nullptr) || (h3_MCParticlesPerX ==
nullptr))
319 histoList->Add(h_pur_pt);
321 TH1F* h_pur_theta =
createHistogramsRatio(
"hpurtheta",
"purity VS #theta", h3_MCParticlesPerX, h3_X,
true, 1);
322 histoList->Add(h_pur_theta);
324 TH1F* h_pur_phi =
createHistogramsRatio(
"hpurphi",
"purity VS #phi", h3_MCParticlesPerX, h3_X,
true, 2);
325 histoList->Add(h_pur_phi);
330 bool geo_accettance, TList* histoList)
334 std::string trueTitle;
336 if (geo_accettance ==
false) {
337 std::string name1 =
"_noGeoAcc";
338 total = std::string(name) + name1;
339 trueTitle = std::string(title) + name1;
341 std::string name2 =
"_withGeoAcc";
342 total = std::string(name) + name2;
343 trueTitle = std::string(title) + name2;
346 TH1F* h = (TH1F*)
duplicateHistogram(total.c_str(), trueTitle.c_str(), h1_den, histoList);
347 h->GetYaxis()->SetRangeUser(0., 1);
349 for (
int bin = 0; bin < h->GetXaxis()->GetNbins(); bin++) {
350 float num = h1_num->GetBinContent(bin + 1);
351 float den = h1_den->GetBinContent(bin + 1);
356 eff = (double)num / den;
357 err = sqrt(eff * (1 - eff)) / sqrt(den);
359 h->SetBinContent(bin + 1, eff);
360 h->SetBinError(bin + 1, err);
371 const char* title, TList* histoList)
373 if (h1_Track ==
nullptr) B2INFO(
"h_Track missing");
375 std::string name1 =
"_noGeoAcc";
376 std::string name2 =
"_withGeoAcc";
378 std::string total1 = std::string(name) + name1;
379 std::string total2 = std::string(name) + name2;
381 std::string title1 = std::string(title) + name1;
382 std::string title2 = std::string(title) + name2;
386 h[0] = (TH1F*)
duplicateHistogram(total2.c_str(), title2.c_str(), h1_RecoTrack, histoList);
387 h[0]->GetYaxis()->SetRangeUser(0., 1);
389 for (
int bin = 0; bin < h[0]->GetXaxis()->GetNbins(); bin++) {
390 float num = h1_Track->GetBinContent(bin + 1);
391 float den = h1_RecoTrack->GetBinContent(bin + 1);
396 eff = (double)num / den;
397 err = sqrt(eff * (1 - eff)) / sqrt(den);
399 h[0]->SetBinContent(bin + 1, eff);
400 h[0]->SetBinError(bin + 1, err);
404 h[1]->GetYaxis()->SetRangeUser(0., 1);
406 for (
int bin = 0; bin < h[1]->GetXaxis()->GetNbins(); bin++) {
407 float num = h1_Track->GetBinContent(bin + 1);
408 float den = h1_MC->GetBinContent(bin + 1);
413 eff = (double)num / den;
414 err = sqrt(eff * (1 - eff)) / sqrt(den);
416 h[1]->SetBinContent(bin + 1, eff);
417 h[1]->SetBinError(bin + 1, err);
421 histoList->Add(h[0]);
422 histoList->Add(h[1]);
429 const char* name,
const char* title,
bool geo_accettance, TList* histoList)
431 std::string err_char =
"_error_";
432 std::string addTitle =
"Errors, ";
436 std::string trueTitle;
438 std::string titleErr = addTitle + std::string(title);
440 if (geo_accettance ==
false) {
441 std::string name1 =
"_noGeoAcc";
442 total = std::string(name) + name1;
443 trueTitle = std::string(title) + name1;
444 error = std::string(name) + err_char + std::string(name1);
446 std::string name2 =
"_withGeoAcc";
447 total = std::string(name) + name2;
448 trueTitle = std::string(title) + name2;
449 error = std::string(name) + err_char + std::string(name2);
453 h2[0] = (TH2F*)
duplicateHistogram(total.c_str(), trueTitle.c_str(), h2_den, histoList);
454 h2[1] = (TH2F*)
duplicateHistogram(error.c_str(), titleErr.c_str(), h2_den, histoList);
456 for (
int binX = 0; binX < h2[0]->GetXaxis()->GetNbins(); binX++) {
457 for (
int binY = 0; binY < h2[0]->GetYaxis()->GetNbins(); binY++) {
458 float num = h2_num->GetBinContent(binX + 1, binY + 1);
459 float den = h2_den->GetBinContent(binX + 1, binY + 1);
464 eff = (double)num / den;
465 err = sqrt(eff * (1 - eff)) / sqrt(den);
468 h2[0]->SetBinContent(binX + 1, binY + 1, eff);
469 h2[0]->SetBinError(binX + 1, binY + 1, err);
470 h2[1]->SetBinContent(binX + 1, binY + 1, err);
476 histoList->Add(h2[0]);
477 histoList->Add(h2[1]);
485 const char* title, TList* histoList)
487 if (h2_Track ==
nullptr) B2INFO(
"h_Track missing");
489 std::string name1 =
"_noGeoAcc";
490 std::string name2 =
"_withGeoAcc";
491 std::string err_char =
"_error_";
492 std::string addTitle =
"Errors, ";
494 std::string total1 = std::string(name) + name1;
495 std::string total2 = std::string(name) + name2;
497 std::string title1 = std::string(title) + name1;
498 std::string title2 = std::string(title) + name2;
500 std::string error1 = std::string(name) + err_char + name1;
501 std::string error2 = std::string(name) + err_char + name2;
502 std::string titleErr = addTitle + std::string(title);
506 h2[0] = (TH2F*)
duplicateHistogram(total2.c_str(), title2.c_str(), h2_RecoTrack, histoList);
507 h2[1] = (TH2F*)
duplicateHistogram(error2.c_str(), titleErr.c_str(), h2_RecoTrack, histoList);
509 for (
int binX = 0; binX < h2[0]->GetXaxis()->GetNbins(); binX++) {
510 for (
int binY = 0; binY < h2[0]->GetYaxis()->GetNbins(); binY++) {
511 float num = h2_Track->GetBinContent(binX + 1, binY + 1);
512 float den = h2_RecoTrack->GetBinContent(binX + 1, binY + 1);
518 err = sqrt(eff * (1 - eff)) / sqrt(den);
521 h2[0]->SetBinContent(binX + 1, binY + 1, eff);
522 h2[0]->SetBinError(binX + 1, binY + 1, err);
523 h2[1]->SetBinContent(binX + 1, binY + 1, err);
528 h2[3] = (TH2F*)
duplicateHistogram(error1.c_str(), titleErr.c_str(), h2_MC, histoList);
530 for (
int binX = 0; binX < h2[2]->GetXaxis()->GetNbins(); binX++) {
531 for (
int binY = 0; binY < h2[2]->GetYaxis()->GetNbins(); binY++) {
532 float num = h2_Track->GetBinContent(binX + 1, binY + 1);
533 float den = h2_MC->GetBinContent(binX + 1, binY + 1);
539 err = sqrt(eff * (1 - eff)) / sqrt(den);
542 h2[2]->SetBinContent(binX + 1, binY + 1, eff);
543 h2[2]->SetBinError(binX + 1, binY + 1, err);
544 h2[3]->SetBinContent(binX + 1, binY + 1, err);
549 histoList->Add(h2[0]);
550 histoList->Add(h2[1]);
551 histoList->Add(h2[2]);
552 histoList->Add(h2[3]);
561 h->GetYaxis()->SetRangeUser(0., 1);
563 for (
int bin = 0; bin < h->GetXaxis()->GetNbins(); bin++) {
564 float num = h1_num->GetBinContent(bin + 1);
565 float den = h1_den->GetBinContent(bin + 1);
570 eff = (double)num / den;
571 err = sqrt(eff * (1 - eff)) / sqrt(den);
573 h->SetBinContent(bin + 1, eff);
574 h->SetBinError(bin + 1, err);
584 const char* name,
const char* title, TList* histoList)
586 std::string err_char =
"_err";
587 std::string addTitle =
"Errors, ";
589 std::string error = std::string(name) + err_char;
590 std::string titleErr = addTitle + std::string(title);
594 h2[1] = (TH2F*)
duplicateHistogram(error.c_str(), titleErr.c_str(), h2_den, histoList);
596 for (
int binX = 0; binX < h2[0]->GetXaxis()->GetNbins(); binX++) {
597 for (
int binY = 0; binY < h2[0]->GetYaxis()->GetNbins(); binY++) {
598 float num = h2_num->GetBinContent(binX + 1, binY + 1);
599 float den = h2_den->GetBinContent(binX + 1, binY + 1);
604 eff = (double)num / den;
605 err = sqrt(eff * (1 - eff)) / sqrt(den);
607 h2[0]->SetBinContent(binX + 1, binY + 1, eff);
608 h2[0]->SetBinError(binX + 1, binY + 1, err);
609 h2[1]->SetBinContent(binX + 1, binY + 1, err);
614 histoList->Add(h2[0]);
615 histoList->Add(h2[1]);
623 const char* name,
const char* title, TList* histoList)
627 h->GetYaxis()->SetRangeUser(0., 1);
629 for (
int bin = 0; bin < h->GetXaxis()->GetNbins(); bin++) {
630 double dau0 = h1_dau0->GetBinContent(bin);
631 double dau1 = h1_dau1->GetBinContent(bin);
632 double Mother = h1_Mother->GetBinContent(bin);
633 double dau0Err = h1_dau0->GetBinError(bin);
634 double dau1Err = h1_dau1->GetBinError(bin);
635 double MotherErr = h1_Mother->GetBinError(bin);
637 double binCont = 1. * Mother / dau0 / dau1;
638 double binErr = binCont * sqrt((dau0Err / dau0) * (dau0Err / dau0) + (dau1Err / dau1) * (dau1Err / dau1) * (MotherErr / Mother) *
639 (MotherErr / Mother));
641 h->SetBinContent(bin, binCont);
642 h->SetBinError(bin, binErr);
Abstract base class for different kinds of events.