make hlt1 overview cooler

This commit is contained in:
Marius Pfeiffer 2024-02-23 14:46:29 +01:00
parent bd9c7b5f8f
commit f05bfc4c61

View File

@ -134,27 +134,36 @@ std::vector<Hlt1Decision> Hlt1Decisions{
Hlt1Decision{"TwoTrackMVA", 13}, Hlt1Decision{"TwoTrackMVA", 13},
}; };
const std::vector<std::set<std::string>> Hlt1DecisionSets{ struct Hlt1DecisionPlot
std::set<std::string>{ {
"TwoTrackMVA", "TrackMuonMVA", "TrackMVA"}, std::string name;
bool exclusive;
std::set<std::string> lines;
};
std::set<std::string>{ const std::vector<Hlt1DecisionPlot>
"TwoTrackMVA", "TrackMuonMVA", "TrackMVA", "LowPtMuon", "LowPtDiMuon", "DisplacedLeptons"}, Hlt1DecisionSets{
Hlt1DecisionPlot{"mva_excl", true, std::set<std::string>{"TwoTrackMVA", "TrackMuonMVA", "TrackMVA"}},
std::set<std::string>{ Hlt1DecisionPlot{"mva_incl", false, std::set<std::string>{"TwoTrackMVA", "TrackMuonMVA", "TrackMVA"}},
"TwoTrackMVA", "TrackMuonMVA", "TrackMVA", "DiMuonNoIP", "DiMuonLowMass", "DiMuonHighMass"},
std::set<std::string>{ Hlt1DecisionPlot{"pt_excl", true, std::set<std::string>{"LowPtMuon", "LowPtDiMuon", "DisplacedLeptons"}},
"TwoTrackMVA", "TrackMuonMVA", "TrackMVA", "LowPtMuon", "LowPtDiMuon", "DisplacedLeptons", "DiMuonNoIP", "DiMuonLowMass", "DiMuonHighMass"},
std::set<std::string>{ Hlt1DecisionPlot{"pt_incl", false, std::set<std::string>{"LowPtMuon", "LowPtDiMuon", "DisplacedLeptons"}},
"LowPtMuon", "LowPtDiMuon", "DisplacedLeptons"},
std::set<std::string>{ Hlt1DecisionPlot{"dimu_excl", true, std::set<std::string>{"DiMuonNoIP", "DiMuonLowMass", "DiMuonHighMass"}},
"LowPtMuon", "LowPtDiMuon", "DisplacedLeptons", "DiMuonNoIP", "DiMuonLowMass", "DiMuonHighMass"},
std::set<std::string>{ Hlt1DecisionPlot{"dimu_incl", false, std::set<std::string>{"DiMuonNoIP", "DiMuonLowMass", "DiMuonHighMass"}},
"DiMuonNoIP", "DiMuonLowMass", "DiMuonHighMass"}};
Hlt1DecisionPlot{"mvapt_incl", false, std::set<std::string>{"TwoTrackMVA", "TrackMuonMVA", "TrackMVA", "LowPtMuon", "LowPtDiMuon", "DisplacedLeptons"}},
Hlt1DecisionPlot{"mvadimu_incl", false, std::set<std::string>{"TwoTrackMVA", "TrackMuonMVA", "TrackMVA", "DiMuonNoIP", "DiMuonLowMass", "DiMuonHighMass"}},
Hlt1DecisionPlot{"mvadimupt_incl", false, std::set<std::string>{"TwoTrackMVA", "TrackMuonMVA", "TrackMVA", "LowPtMuon", "LowPtDiMuon", "DisplacedLeptons", "DiMuonNoIP", "DiMuonLowMass", "DiMuonHighMass"}},
Hlt1DecisionPlot{"ptdimu_incl", false, std::set<std::string>{"LowPtMuon", "LowPtDiMuon", "DisplacedLeptons", "DiMuonNoIP", "DiMuonLowMass", "DiMuonHighMass"}},
};
bool CutHlt1DecisionsAnd(const std::set<std::string> &decision_list) bool CutHlt1DecisionsAnd(const std::set<std::string> &decision_list)
{ {
@ -196,7 +205,7 @@ bool CutHlt1DecisionsOrOnly(const std::set<std::string> &decision_list)
if (var.value) if (var.value)
{ {
okay = false; okay = false;
continue; break;
} }
} }
} }
@ -252,7 +261,7 @@ RooPlot *CreateRooFitHistogram(TH1D *hist)
RooDataHist roohist_B_M("roohist_B_M", "B Mass Histogram", roo_var_mass, RooFit::Import(*hist)); RooDataHist roohist_B_M("roohist_B_M", "B Mass Histogram", roo_var_mass, RooFit::Import(*hist));
RooPlot *roo_frame_mass = roo_var_mass.frame(RooFit::Title(hist->GetTitle())); RooPlot *roo_frame_mass = roo_var_mass.frame(RooFit::Title(hist->GetTitle()), RooFit::Name(TString::Format("%s_rplt", hist->GetName())));
roohist_B_M.plotOn(roo_frame_mass, RooFit::Binning(B_MASS_HIST_BINS), RooFit::Name("B Mass Distribution")); roohist_B_M.plotOn(roo_frame_mass, RooFit::Binning(B_MASS_HIST_BINS), RooFit::Name("B Mass Distribution"));
roo_frame_mass->GetXaxis()->SetTitle(hist->GetXaxis()->GetTitle()); roo_frame_mass->GetXaxis()->SetTitle(hist->GetXaxis()->GetTitle());
@ -301,25 +310,33 @@ void CheckHlt1Decisioins(TH2D *incl_hist, TH2D *excl_hist, std::map<std::string,
std::vector<TH1D *> CreateHlt1DecisionHistos(const char *analysis_name) std::vector<TH1D *> CreateHlt1DecisionHistos(const char *analysis_name)
{ {
TH1D *h1_B_Mass_hlt1_1 = new TH1D("h1_B_Mass_hlt1_1", TString::Format("B Mass (1), J/#psi Mode (%s)", analysis_name), B_MASS_HIST_BINS, B_MASS_VAR_MIN, B_MASS_VAR_MAX); std::vector<TH1D *> histos{};
TH1D *h1_B_Mass_hlt1_12 = new TH1D("h1_B_Mass_hlt1_12", TString::Format("B Mass (12), J/#psi Mode (%s)", analysis_name), B_MASS_HIST_BINS, B_MASS_VAR_MIN, B_MASS_VAR_MAX); for (int i = 0; i < Hlt1DecisionSets.size(); i++)
TH1D *h1_B_Mass_hlt1_13 = new TH1D("h1_B_Mass_hlt1_13", TString::Format("B Mass (13), J/#psi Mode (%s)", analysis_name), B_MASS_HIST_BINS, B_MASS_VAR_MIN, B_MASS_VAR_MAX); {
TH1D *h1_B_Mass_hlt1_123 = new TH1D("h1_B_Mass_hlt1_123", TString::Format("B Mass (123), J/#psi Mode (%s)", analysis_name), B_MASS_HIST_BINS, B_MASS_VAR_MIN, B_MASS_VAR_MAX); TH1D *h1_B_Mass_hlt1 = new TH1D(TString::Format("h1_B_Mass_hlt1_%s", Hlt1DecisionSets[i].name.c_str()), TString::Format("(%s) (%s)", Hlt1DecisionSets[i].name.c_str(), analysis_name), B_MASS_HIST_BINS, B_MASS_VAR_MIN, B_MASS_VAR_MAX);
TH1D *h1_B_Mass_hlt1_2 = new TH1D("h1_B_Mass_hlt1_2", TString::Format("B Mass (2), J/#psi Mode (%s)", analysis_name), B_MASS_HIST_BINS, B_MASS_VAR_MIN, B_MASS_VAR_MAX); histos.push_back(h1_B_Mass_hlt1);
TH1D *h1_B_Mass_hlt1_23 = new TH1D("h1_B_Mass_hlt1_23", TString::Format("B Mass (23), J/#psi Mode (%s)", analysis_name), B_MASS_HIST_BINS, B_MASS_VAR_MIN, B_MASS_VAR_MAX); }
TH1D *h1_B_Mass_hlt1_3 = new TH1D("h1_B_Mass_hlt1_3", TString::Format("B Mass (3), J/#psi Mode (%s)", analysis_name), B_MASS_HIST_BINS, B_MASS_VAR_MIN, B_MASS_VAR_MAX);
return {h1_B_Mass_hlt1_1, h1_B_Mass_hlt1_12, h1_B_Mass_hlt1_13, h1_B_Mass_hlt1_123, h1_B_Mass_hlt1_2, h1_B_Mass_hlt1_23, h1_B_Mass_hlt1_3}; return histos;
} }
void FillHlt1DecisionHistos(std::vector<TH1D *> histos, double reco_mass) void FillHlt1DecisionHistos(std::vector<TH1D *> histos, double reco_mass)
{ {
for (int i = 0; i < Hlt1DecisionSets.size(); i++) for (int i = 0; i < Hlt1DecisionSets.size(); i++)
{ {
if (CutHlt1DecisionsOrOnly(Hlt1DecisionSets[i])) if (Hlt1DecisionSets[i].exclusive)
{ {
histos[i]->Fill(reco_mass); if (CutHlt1DecisionsOrOnly(Hlt1DecisionSets[i].lines))
// std::cout << " ### Filled " << histos[indx]->GetName() << ". Now: " << histos[indx]->GetEntries() << "." << std::endl; {
histos[i]->Fill(reco_mass);
}
}
else
{
if (CutHlt1DecisionsOr(Hlt1DecisionSets[i].lines))
{
histos[i]->Fill(reco_mass);
}
} }
} }
} }
@ -329,19 +346,25 @@ void DrawHlt1DecisionHistos(const char *folder, std::vector<TH1D *> histos)
std::filesystem::create_directory(TString::Format("output_files/analysis/%s", folder).Data()); std::filesystem::create_directory(TString::Format("output_files/analysis/%s", folder).Data());
TString name = TString::Format("%s_canvas", "hlt1_decisions"); TString name = TString::Format("%s_canvas", "hlt1_decisions");
TCanvas *c = new TCanvas(name, "HLT 1 Decisions", 0, 0, 1200, 700); TCanvas *c = new TCanvas(name, "HLT 1 Decisions", 0, 0, 1200, 700);
c->Divide(4, 2); c->Divide(4, 3);
for (int i = 0; i < histos.size(); i++) for (int i = 0; i < histos.size(); i++)
{ {
c->cd(i + 1); c->cd(i + 1);
histos[i]->SetStats(0); histos[i]->SetStats(0);
histos[i]->Draw(); histos[i]->Draw();
TLegend *leg1 = new TLegend(0.58, 0.89 - (0.05 * (Hlt1DecisionSets[i].size() + 1)), 0.88, 0.89); TLegend *leg1 = new TLegend(0.58, 0.89 - (0.05 * (Hlt1DecisionSets[i].lines.size() + (int)(Hlt1DecisionSets[i].lines.size() / 3))), 0.88, 0.89);
leg1->SetFillColor(kWhite); leg1->SetFillStyle(0);
leg1->SetLineColor(kBlack); leg1->SetLineStyle(0);
leg1->SetMargin(0.1); leg1->SetMargin(0.1);
std::for_each(Hlt1DecisionSets[i].begin(), Hlt1DecisionSets[i].end(), [leg1](std::string s) int index = 1;
{ leg1->AddEntry((TObject *)0, s.c_str(), ""); }); std::for_each(Hlt1DecisionSets[i].lines.begin(), Hlt1DecisionSets[i].lines.end(), [leg1, i, &index](std::string s)
{
leg1->AddEntry((TObject *)0, s.c_str(), "");
if (index != Hlt1DecisionSets[i].lines.size() && index % 3 == 0) {
leg1->AddEntry((TObject *)0, "", "");
}
index++; });
leg1->AddEntry((TObject *)0, TString::Format("# Entries: %d", (int)histos[i]->GetEntries()), ""); leg1->AddEntry((TObject *)0, TString::Format("# Entries: %d", (int)histos[i]->GetEntries()), "");
leg1->Draw(); leg1->Draw();
} }
@ -479,6 +502,8 @@ int analyze_bu2hpmumu_simulation()
} }
} }
auto hlt1_decision_histos = CreateHlt1DecisionHistos(analysis_name);
std::map<std::string, int> exclusive_hits{}; std::map<std::string, int> exclusive_hits{};
unsigned int entries = sim_chain->GetEntries(); unsigned int entries = sim_chain->GetEntries();
@ -495,6 +520,7 @@ int analyze_bu2hpmumu_simulation()
if (TMath::Abs(dimuon.M() - JPSI_MASS) < 100.) if (TMath::Abs(dimuon.M() - JPSI_MASS) < 100.)
{ {
CheckHlt1Decisioins(h2_Hlt1_flags_B_Mass, h2_Hlt1_flags_excl_B_Mass, exclusive_hits, reconstructed_B_Mass); CheckHlt1Decisioins(h2_Hlt1_flags_B_Mass, h2_Hlt1_flags_excl_B_Mass, exclusive_hits, reconstructed_B_Mass);
FillHlt1DecisionHistos(hlt1_decision_histos, reconstructed_B_Mass);
} }
if (CutHlt1DecisionsOr({"TwoTrackMuonMVA", "DiMuonHighMass"})) if (CutHlt1DecisionsOr({"TwoTrackMuonMVA", "DiMuonHighMass"}))
@ -529,6 +555,8 @@ int analyze_bu2hpmumu_simulation()
DrawInDefaultCanvas(roofit_hist_jpsi, analysis_name, 0.1); DrawInDefaultCanvas(roofit_hist_jpsi, analysis_name, 0.1);
DrawInDefaultCanvas(roofit_hist_psi2s, analysis_name, 0.1); DrawInDefaultCanvas(roofit_hist_psi2s, analysis_name, 0.1);
DrawHlt1DecisionHistos(analysis_name, hlt1_decision_histos);
return 0; return 0;
} }
@ -573,6 +601,8 @@ int analyze_b02hphmmumu()
h2_Hlt1_flags_excl_B_Mass->Fill(0., var.name.c_str(), 0.); h2_Hlt1_flags_excl_B_Mass->Fill(0., var.name.c_str(), 0.);
} }
auto hlt1_decision_histos = CreateHlt1DecisionHistos(analysis_name);
std::map<std::string, int> exclusive_hits{}; std::map<std::string, int> exclusive_hits{};
unsigned int entries = data_chain->GetEntries(); unsigned int entries = data_chain->GetEntries();
@ -607,6 +637,7 @@ int analyze_b02hphmmumu()
if (TMath::Abs(dimuon.M() - JPSI_MASS) < 100.) if (TMath::Abs(dimuon.M() - JPSI_MASS) < 100.)
{ {
CheckHlt1Decisioins(h2_Hlt1_flags_B_Mass, h2_Hlt1_flags_excl_B_Mass, exclusive_hits, reconstructed_B_Mass); CheckHlt1Decisioins(h2_Hlt1_flags_B_Mass, h2_Hlt1_flags_excl_B_Mass, exclusive_hits, reconstructed_B_Mass);
FillHlt1DecisionHistos(hlt1_decision_histos, reconstructed_B_Mass);
} }
if (CutHlt1DecisionsOr({"TwoTrackMuonMVA", "DiMuonHighMass"})) if (CutHlt1DecisionsOr({"TwoTrackMuonMVA", "DiMuonHighMass"}))
@ -643,6 +674,8 @@ int analyze_b02hphmmumu()
DrawInDefaultCanvas(roofit_hist_jpsi, analysis_name, 0.1); DrawInDefaultCanvas(roofit_hist_jpsi, analysis_name, 0.1);
DrawInDefaultCanvas(roofit_hist_psi2s, analysis_name, 0.1); DrawInDefaultCanvas(roofit_hist_psi2s, analysis_name, 0.1);
DrawHlt1DecisionHistos(analysis_name, hlt1_decision_histos);
return 0; return 0;
} }
@ -678,6 +711,8 @@ int analyze_Hlt2RD_BuToKpMuMu()
h2_Hlt1_flags_excl_B_Mass->Fill(0., var.name.c_str(), 0.); h2_Hlt1_flags_excl_B_Mass->Fill(0., var.name.c_str(), 0.);
} }
auto hlt1_decision_histos = CreateHlt1DecisionHistos(analysis_name);
std::map<std::string, int> exclusive_hits{}; std::map<std::string, int> exclusive_hits{};
unsigned int entries = data_chain->GetEntries(); unsigned int entries = data_chain->GetEntries();
@ -694,6 +729,7 @@ int analyze_Hlt2RD_BuToKpMuMu()
if (TMath::Abs(dimuon.M() - JPSI_MASS) < 100.) if (TMath::Abs(dimuon.M() - JPSI_MASS) < 100.)
{ {
CheckHlt1Decisioins(h2_Hlt1_flags_B_Mass, h2_Hlt1_flags_excl_B_Mass, exclusive_hits, reconstructed_B_Mass); CheckHlt1Decisioins(h2_Hlt1_flags_B_Mass, h2_Hlt1_flags_excl_B_Mass, exclusive_hits, reconstructed_B_Mass);
FillHlt1DecisionHistos(hlt1_decision_histos, reconstructed_B_Mass);
} }
if (CutHlt1DecisionsOr({"TwoTrackMuonMVA", "DiMuonHighMass"})) if (CutHlt1DecisionsOr({"TwoTrackMuonMVA", "DiMuonHighMass"}))
@ -727,6 +763,8 @@ int analyze_Hlt2RD_BuToKpMuMu()
DrawInDefaultCanvas(roofit_hist_jpsi, analysis_name, 0.1); DrawInDefaultCanvas(roofit_hist_jpsi, analysis_name, 0.1);
DrawInDefaultCanvas(roofit_hist_psi2s, analysis_name, 0.1); DrawInDefaultCanvas(roofit_hist_psi2s, analysis_name, 0.1);
DrawHlt1DecisionHistos(analysis_name, hlt1_decision_histos);
return 0; return 0;
} }
@ -763,6 +801,8 @@ int analyze_Hlt2RD_B0ToKpPimMuMu()
h2_Hlt1_flags_excl_B_Mass->Fill(0., var.name.c_str(), 0.); h2_Hlt1_flags_excl_B_Mass->Fill(0., var.name.c_str(), 0.);
} }
auto hlt1_decision_histos = CreateHlt1DecisionHistos(analysis_name);
std::map<std::string, int> exclusive_hits{}; std::map<std::string, int> exclusive_hits{};
unsigned int entries = data_chain->GetEntries(); unsigned int entries = data_chain->GetEntries();
@ -781,6 +821,7 @@ int analyze_Hlt2RD_B0ToKpPimMuMu()
if (TMath::Abs(dimuon.M() - JPSI_MASS) < 100.) if (TMath::Abs(dimuon.M() - JPSI_MASS) < 100.)
{ {
CheckHlt1Decisioins(h2_Hlt1_flags_B_Mass, h2_Hlt1_flags_excl_B_Mass, exclusive_hits, reconstructed_B_Mass); CheckHlt1Decisioins(h2_Hlt1_flags_B_Mass, h2_Hlt1_flags_excl_B_Mass, exclusive_hits, reconstructed_B_Mass);
FillHlt1DecisionHistos(hlt1_decision_histos, reconstructed_B_Mass);
} }
if (CutHlt1DecisionsOr({"TwoTrackMuonMVA", "DiMuonHighMass"})) if (CutHlt1DecisionsOr({"TwoTrackMuonMVA", "DiMuonHighMass"}))
@ -817,6 +858,8 @@ int analyze_Hlt2RD_B0ToKpPimMuMu()
DrawInDefaultCanvas(roofit_hist_jpsi, analysis_name, 0.1); DrawInDefaultCanvas(roofit_hist_jpsi, analysis_name, 0.1);
DrawInDefaultCanvas(roofit_hist_psi2s, analysis_name, 0.1); DrawInDefaultCanvas(roofit_hist_psi2s, analysis_name, 0.1);
DrawHlt1DecisionHistos(analysis_name, hlt1_decision_histos);
return 0; return 0;
} }