14 m_datapath(
datapath), m_treename(treename),
16 m_plotdir_truthVtx(m_plotdir+
"truthVtx/"),
17 m_plotdir_recoVtx(m_plotdir+
"recoVtx/"),
18 m_plotdir_recoVtxHits(m_plotdir_recoVtx+
"hits/"),
19 m_plotdir_vtxResiduals(m_plotdir+
"vtxResiduals/"),
20 m_plotdir_inputObjects(m_plotdir+
"inputObjects/"),
21 m_plotdir_vtxEfficiency(m_plotdir+
"vtxEfficiency/"),
22 m_plotdir_vtxFakeRate(m_plotdir+
"vtxFakeRate/")
64 gROOT->SetStyle(
"ATLAS");
65 TStyle* plotStyle = gROOT->GetStyle(
"ATLAS");
66 plotStyle->SetOptTitle(0);
67 plotStyle->SetHistLineWidth(1.);
88 for(
int i=0;
i<
m_tree->GetEntries(); ++
i){
113 m_c = std::make_unique<TCanvas>();
195 TString(
"objN_stack_b; Number of objects in the barrel; Events / bin"),
m_plotdir_inputObjects+
"objN_stack_b");
198 TString(
"objN_stack_e; Number of objects in the endcaps; Events / bin"),
m_plotdir_inputObjects+
"objN_stack_e");
201 TString(
"objEta_stack; Object #kern[-0.425]{#eta }; Events / bin"),
m_plotdir_inputObjects+
"objEta_stack");
204 TString(
"objPhi_stack_b; Object #kern[-0.09]{#phi in the barrel}; Events / bin"),
m_plotdir_inputObjects+
"objPhi_stack_b");
207 TString(
"objPhi_stack_e; Object #kern[-0.09]{#phi in the endcaps}; Events / bin"),
m_plotdir_inputObjects+
"objPhi_stack_e");
247 TString(
"stack_vtxeff_Lxy_b; Truth vertex L_{xy} [m]; Vertices / bin"),
m_plotdir_vtxEfficiency+
"num_denom_vtxeff_Lxy_b");
249 TString(
"vtxeff_Lxy_b; Truth vertex L_{xy} [m]; Efficiency: n_{truth}^{reco matched} / n_{truth}"),
m_plotdir_vtxEfficiency+
"vtxeff_Lxy_b");
254 TString(
"stack_vtxeff_z_e; Truth vertex |z| [m]; Vertices / bin"),
m_plotdir_vtxEfficiency+
"num_denom_vtxeff_z_e");
256 TString(
"vtxeff_z_e; Truth vertex |z| [m]; Efficiency: n_{truth}^{reco matched} / n_{truth}"),
m_plotdir_vtxEfficiency+
"vtxeff_z_e");
261 TString(
"stack_vtxeff_eta; Truth vertex #kern[-0.425]{#eta }; Vertices / bin"),
m_plotdir_vtxEfficiency+
"num_denom_vtxeff_eta");
263 TString(
"vtxeff_eta; Truth vertex #kern[-0.425]{#eta }; Efficiency: n_{truth}^{reco matched} / n_{truth}"),
m_plotdir_vtxEfficiency+
"vtxeff_eta");
268 TString(
"stack_vtxeff_r_b; Truth vertex |#bf{r}| [m]; Vertices / bin"),
m_plotdir_vtxEfficiency+
"num_denom_vtxeff_r_b");
270 TString(
"vtxeff_r_b; Truth vertex |#bf{r}| [m]; Efficiency: n_{truth}^{reco matched} / n_{truth}"),
m_plotdir_vtxEfficiency+
"vtxeff_r_b");
275 TString(
"stack_vtxeff_r_e; Truth vertex |#bf{r}| [m]; Vertices / bin"),
m_plotdir_vtxEfficiency+
"num_denom_vtxeff_r_e");
277 TString(
"vtxeff_r_e; Truth vertex |#bf{r}| [m]; Efficiency: n_{truth}^{reco matched} / n_{truth}"),
m_plotdir_vtxEfficiency+
"vtxeff_r_e");
285 TString(
"stack_vtxfrate_Lxy_b; Reco vertex L_{xy} [m]; Vertices / bin"),
m_plotdir_vtxFakeRate+
"num_denom_vtxfrate_Lxy_b");
287 TString(
"vtxfrate_Lxy_b; Reco vertex L_{xy} [m]; Fake rate: n_{reco}^{not truth matched} / n_{reco}"),
m_plotdir_vtxFakeRate+
"vtxfrate_Lxy_b");
292 TString(
"stack_vtxfrate_z_e; Reco vertex |z| [m]; Vertices / bin"),
m_plotdir_vtxFakeRate+
"num_denom_vtxfrate_z_e");
294 TString(
"vtxfrate_z_e; Reco vertex |z| [m]; Fake rate: n_{reco}^{not truth matched} / n_{reco}"),
m_plotdir_vtxFakeRate+
"vtxfrate_z_e");
300 TString(
"stack_vtxfrate_eta; Reco vertex #kern[-0.425]{#eta }; Vertices / bin"),
m_plotdir_vtxFakeRate+
"num_denom_vtxfrate_eta");
302 TString(
"vtxfrate_eta; Reco vertex #kern[-0.425]{#eta }; Fake rate: n_{reco}^{not truth matched} / n_{reco}"),
m_plotdir_vtxFakeRate+
"vtxfrate_eta");
308 TString(
"stack_vtxfrate_r_b; Reco vertex |#bf{r}| [m]; Vertices / bin"),
m_plotdir_vtxFakeRate+
"num_denom_vtxfrate_r_b");
310 TString(
"vtxfrate_r_b; Reco vertex |#bf{r}| [m]; Fake rate: n_{reco}^{not truth matched} / n_{reco}"),
m_plotdir_vtxFakeRate+
"vtxfrate_r_b");
316 TString(
"stack_vtxfrate_r_e; Reco vertex |#bf{r}| [m]; Vertices / bin"),
m_plotdir_vtxFakeRate+
"num_denom_vtxfrate_r_e");
318 TString(
"vtxfrate_r_e; Reco vertex |#bf{r}| [m]; Fake rate: n_{reco}^{not truth matched} / n_{reco}"),
m_plotdir_vtxFakeRate+
"vtxfrate_r_e");
380 m_zLxy_truth->SetTitle(
"zLxy_truth; Truth vertex z [m]; Truth vertex L_{xy} [m]");
385 m_etaphi_truth->SetTitle(
"etaphi_truth; Truth vertex #eta; Truth vertex #phi [rad]");
391 m_zLxy->SetTitle(
"zLxy; Reco vertex z [m]; Reco vertex L_{xy} [m]");
396 m_etaphi->SetTitle(
"etaphi; Reco vertex #eta; Reco vertex #phi [rad]");
421 int Nobj_count_b{0}, Nobj_count_e{0};
422 int NobjReco_count{0};
423 int NobjReco_count_b{0}, NobjReco_count_e{0};
425 for (
int i=0;
i<Nobj_count; ++
i){
426 double obj_phi = (*m_obj_phi)[
i];
427 double obj_eta = (*m_obj_eta)[
i];
428 bool used_in_reco = (*m_obj_vtxLink)[
i] != -1;
469 for (
unsigned int j=0; j<reco_vertices.size(); ++j){
498 double d_theta = vtx.theta() - truth_vtx.theta();
513 std::unique_ptr<EffInputTH1> &denomHists, std::unique_ptr<EffInputTH1> &numHists){
521 if (!
hasMatch(vtx, match_candidates))
continue;
546 graphs->etaphi_b->SetPoint(
graphs->etaphi_b->GetN(), vtx.eta(), vtx.phi());
550 graphs->etaphi_e->SetPoint(
graphs->etaphi_e->GetN(), vtx.eta(), vtx.phi());
554 graphs->etaphi_out->SetPoint(
graphs->etaphi_out->GetN(), vtx.eta(), vtx.phi());
569 hists->h_etaphi->Fill(vtx.eta(), vtx.phi());
581 hists->h_chi2prob->Fill( TMath::Prob(
chi2, NDoF-1));
590 if (consti.size() == 0)
return;
592 double dphi{-1}, deta{-1},
deltaR{-1};
593 double dphi_max{0}, deta_max{0}, dR_max{0};
597 deta = vtx.eta() -
c.eta();
600 if (std::abs(dphi) > std::abs(dphi_max)) dphi_max = dphi;
601 if (std::abs(deta) > std::abs(deta_max)) deta_max = deta;
605 hists->h_dphimax->Fill(dphi_max);
606 hists->h_detamax->Fill(deta_max);
607 hists->h_dRmax->Fill(dR_max);
616 if (total < 0)
return;
618 hists->h_total->Fill(total);
619 hists->h_I->Fill(inner);
620 hists->h_M->Fill(middle);
621 hists->h_O->Fill(outer);
622 hists->h_inwardsTotal->Fill(inwards/total);
623 if (middle > 0)
hists->h_IM->Fill(inner/middle);
624 if (outer > 0)
hists->h_IO->Fill(inner/outer);
625 if (outer > 0)
hists->h_MO->Fill(middle/outer);
634 hists->h_delta_R->Fill(dR);
635 hists->h_delta_theta->Fill(d_theta);
636 hists->h_delta_phi->Fill(d_phi);
637 hists->h_delta_Lxy->Fill(d_Lxy);
638 hists->h_delta_z->Fill(d_z);
639 hists->h_delta_phys->Fill(d_phys);
642 hists->h_delta_Lxy_posEta->Fill(d_Lxy);
643 hists->h_delta_z_posEta->Fill(d_z);
646 hists->h_delta_Lxy_negEta->Fill(d_Lxy);
647 hists->h_delta_z_negEta->Fill(d_z);
665 hists->h_eta->Fill(vtx.eta());
679 const TString
extra = plotdir.Contains(
"truth") ? TString(
"_truth") : TString(
"");
684 TH1* h_phi =
hists->h_etaphi->ProjectionY(
"phi"+
extra);
685 h_phi->GetXaxis()->SetRangeUser(-TMath::Pi(), TMath::Pi());
686 saveTH1(h_phi, plotdir+
"phi"+
extra,
"",
"Vertices / bin");
695 zLxy->Add(
graphs->zLxy_b,
"P");
696 zLxy->Add(
graphs->zLxy_e,
"P");
697 zLxy->Add(
graphs->zLxy_out,
"P");
698 zLxy->GetXaxis()->SetRangeUser(-16,16);
699 zLxy->GetYaxis()->SetRangeUser(-1,12);
702 TLegend* legend_zLxy =
makeLegend(0.16, 0.02, 0.65, 0.07, 0.05);
703 legend_zLxy->SetNColumns(3);
704 legend_zLxy->AddEntry(
graphs->zLxy_b,
"Barrel",
"p");
705 legend_zLxy->AddEntry(
graphs->zLxy_e,
"Endcaps",
"p");
706 legend_zLxy->AddEntry(
graphs->zLxy_out,
"Outside",
"p");
708 m_c->SaveAs(plotdir+
"map_zLxy.pdf");
711 etaphi->Add(
graphs->etaphi_b,
"P");
712 etaphi->Add(
graphs->etaphi_e,
"P");
713 etaphi->Add(
graphs->etaphi_out,
"P");
714 etaphi->GetXaxis()->SetRangeUser(-2.6,2.6);
715 etaphi->GetYaxis()->SetRangeUser(-TMath::Pi()-0.25,TMath::Pi()+1);
718 TLegend* legend_etaphi =
makeLegend(0.16, 0.02, 0.65, 0.07, 0.05);
719 legend_etaphi->SetNColumns(3);
720 legend_etaphi->AddEntry(
graphs->etaphi_b,
"Barrel",
"p");
721 legend_etaphi->AddEntry(
graphs->etaphi_e,
"Endcaps",
"p");
722 legend_etaphi->AddEntry(
graphs->etaphi_out,
"Outside",
"p");
723 legend_etaphi->Draw();
724 m_c->SaveAs(plotdir+
"map_etaphi.pdf");
736 double maxy_factor = 1.4;
739 h->Scale(1. /
h->Integral());
740 h->SetName(TString(
h->GetName())+
"_norm");
741 plotpath = plotpath.Insert(plotpath.Last(*
"."),
"_norm");
746 h->SetName(TString(
h->GetName())+
"_log");
747 plotpath = plotpath.Insert(plotpath.Last(*
"."),
"_log");
752 h->GetYaxis()->SetTitle(new_ylabel);
755 h->SetMaximum(
h->GetMaximum()*maxy_factor);
759 m_c->SaveAs(plotpath+
".pdf");
770 const TString &h1_legend,
const TString &h2_legend,
771 const TString &
title,
const TString &plotpath,
772 int color1,
int color2){
775 TObjArray *tx_stack =
title.Tokenize(
";");
776 auto name = ((TObjString*)(tx_stack->At(0)))->String();
777 THStack *h_stack =
new THStack(
name,
name);
778 h1->SetLineColor(color1);
779 h2->SetLineColor(color2);
783 double maxy = h2->GetMaximum()>
h1->GetMaximum() ? h2->GetMaximum() :
h1->GetMaximum();
784 h_stack->SetMaximum(1.4*maxy);
785 h_stack->Draw(
"nostack");
786 h_stack->GetXaxis()->SetTitle(((TObjString*)(tx_stack->At(1)))->String());
787 h_stack->GetYaxis()->SetTitle(((TObjString*)(tx_stack->At(2)))->String());
790 legend->AddEntry(
h1, h1_legend,
"l");
791 legend->AddEntry(h2, h2_legend,
"l");
796 m_c->SaveAs(plotpath+
".pdf");
804 const TString &
title,
const TString &plotpath){
807 TEfficiency* h_eff =
new TEfficiency(*h_num, *h_denom);
808 h_eff->SetTitle(
title);
809 TObjArray *tx_eff =
title.Tokenize(
";");
810 h_eff->SetName(((TObjString*)(tx_eff->At(0)))->String());
812 h_eff->SetLineColor(1);
813 h_eff->SetMarkerColor(1);
814 h_eff->SetMarkerSize(0.5);
815 h_eff->SetMarkerStyle(24);
819 TGraphAsymmErrors* g_eff = h_eff->GetPaintedGraph();
821 g_eff->GetYaxis()->SetRangeUser(0, 1.4*maxy);
822 g_eff->GetXaxis()->SetTitle(((TObjString*)(tx_eff->At(1)))->String());
823 g_eff->GetYaxis()->SetTitle(((TObjString*)(tx_eff->At(2)))->String());
831 m_c->SaveAs(plotpath+
".pdf");
840 gPad->SetRightMargin(0.15);
843 m_c->SaveAs(plotpath+
".pdf");
844 gPad->SetRightMargin(0.05);
858 Double_t
Red[] = {0.0, 0.0, 1.0, 1.0};
859 Double_t
Green[] = {1.0, 1.0, 1.0, 0.0};
860 Double_t Blue[] = {1.0, 0.0, 0.0, 0.0};
861 Double_t Length[] = {0.0, 0.33, 0.66, 1.0};
864 for (
unsigned int i=0;
i<
std::size(palette);
i++) palette[
i] = firstColorIdx+
i;
866 plotStyle->SetPalette(
std::size(palette), palette);
868 plotStyle->SetNumberContours(100);
876 TH1* h_unmatched = (TH1*)h_all->Clone(name_unmatched);
877 h_unmatched->Add(h_matched, -1);