diff --git a/new_analysis.cpp b/new_analysis.cpp index 0b552d1..ed05062 100644 --- a/new_analysis.cpp +++ b/new_analysis.cpp @@ -134,27 +134,36 @@ std::vector Hlt1Decisions{ Hlt1Decision{"TwoTrackMVA", 13}, }; -const std::vector> Hlt1DecisionSets{ - std::set{ - "TwoTrackMVA", "TrackMuonMVA", "TrackMVA"}, +struct Hlt1DecisionPlot +{ + std::string name; + bool exclusive; + std::set lines; +}; - std::set{ - "TwoTrackMVA", "TrackMuonMVA", "TrackMVA", "LowPtMuon", "LowPtDiMuon", "DisplacedLeptons"}, +const std::vector + Hlt1DecisionSets{ + Hlt1DecisionPlot{"mva_excl", true, std::set{"TwoTrackMVA", "TrackMuonMVA", "TrackMVA"}}, - std::set{ - "TwoTrackMVA", "TrackMuonMVA", "TrackMVA", "DiMuonNoIP", "DiMuonLowMass", "DiMuonHighMass"}, + Hlt1DecisionPlot{"mva_incl", false, std::set{"TwoTrackMVA", "TrackMuonMVA", "TrackMVA"}}, - std::set{ - "TwoTrackMVA", "TrackMuonMVA", "TrackMVA", "LowPtMuon", "LowPtDiMuon", "DisplacedLeptons", "DiMuonNoIP", "DiMuonLowMass", "DiMuonHighMass"}, + Hlt1DecisionPlot{"pt_excl", true, std::set{"LowPtMuon", "LowPtDiMuon", "DisplacedLeptons"}}, - std::set{ - "LowPtMuon", "LowPtDiMuon", "DisplacedLeptons"}, + Hlt1DecisionPlot{"pt_incl", false, std::set{"LowPtMuon", "LowPtDiMuon", "DisplacedLeptons"}}, - std::set{ - "LowPtMuon", "LowPtDiMuon", "DisplacedLeptons", "DiMuonNoIP", "DiMuonLowMass", "DiMuonHighMass"}, + Hlt1DecisionPlot{"dimu_excl", true, std::set{"DiMuonNoIP", "DiMuonLowMass", "DiMuonHighMass"}}, - std::set{ - "DiMuonNoIP", "DiMuonLowMass", "DiMuonHighMass"}}; + Hlt1DecisionPlot{"dimu_incl", false, std::set{"DiMuonNoIP", "DiMuonLowMass", "DiMuonHighMass"}}, + + Hlt1DecisionPlot{"mvapt_incl", false, std::set{"TwoTrackMVA", "TrackMuonMVA", "TrackMVA", "LowPtMuon", "LowPtDiMuon", "DisplacedLeptons"}}, + + Hlt1DecisionPlot{"mvadimu_incl", false, std::set{"TwoTrackMVA", "TrackMuonMVA", "TrackMVA", "DiMuonNoIP", "DiMuonLowMass", "DiMuonHighMass"}}, + + Hlt1DecisionPlot{"mvadimupt_incl", false, std::set{"TwoTrackMVA", "TrackMuonMVA", "TrackMVA", "LowPtMuon", "LowPtDiMuon", "DisplacedLeptons", "DiMuonNoIP", "DiMuonLowMass", "DiMuonHighMass"}}, + + Hlt1DecisionPlot{"ptdimu_incl", false, std::set{"LowPtMuon", "LowPtDiMuon", "DisplacedLeptons", "DiMuonNoIP", "DiMuonLowMass", "DiMuonHighMass"}}, + + }; bool CutHlt1DecisionsAnd(const std::set &decision_list) { @@ -196,7 +205,7 @@ bool CutHlt1DecisionsOrOnly(const std::set &decision_list) if (var.value) { 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)); - 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")); roo_frame_mass->GetXaxis()->SetTitle(hist->GetXaxis()->GetTitle()); @@ -301,25 +310,33 @@ void CheckHlt1Decisioins(TH2D *incl_hist, TH2D *excl_hist, std::map 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); - 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); - 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_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); - 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); + std::vector histos{}; + for (int i = 0; i < Hlt1DecisionSets.size(); i++) + { + 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); + histos.push_back(h1_B_Mass_hlt1); + } - 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 histos, double reco_mass) { for (int i = 0; i < Hlt1DecisionSets.size(); i++) { - if (CutHlt1DecisionsOrOnly(Hlt1DecisionSets[i])) + if (Hlt1DecisionSets[i].exclusive) { - histos[i]->Fill(reco_mass); - // std::cout << " ### Filled " << histos[indx]->GetName() << ". Now: " << histos[indx]->GetEntries() << "." << std::endl; + if (CutHlt1DecisionsOrOnly(Hlt1DecisionSets[i].lines)) + { + 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 histos) std::filesystem::create_directory(TString::Format("output_files/analysis/%s", folder).Data()); TString name = TString::Format("%s_canvas", "hlt1_decisions"); 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++) { c->cd(i + 1); histos[i]->SetStats(0); histos[i]->Draw(); - TLegend *leg1 = new TLegend(0.58, 0.89 - (0.05 * (Hlt1DecisionSets[i].size() + 1)), 0.88, 0.89); - leg1->SetFillColor(kWhite); - leg1->SetLineColor(kBlack); + 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->SetFillStyle(0); + leg1->SetLineStyle(0); leg1->SetMargin(0.1); - std::for_each(Hlt1DecisionSets[i].begin(), Hlt1DecisionSets[i].end(), [leg1](std::string s) - { leg1->AddEntry((TObject *)0, s.c_str(), ""); }); + int index = 1; + 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->Draw(); } @@ -479,6 +502,8 @@ int analyze_bu2hpmumu_simulation() } } + auto hlt1_decision_histos = CreateHlt1DecisionHistos(analysis_name); + std::map exclusive_hits{}; unsigned int entries = sim_chain->GetEntries(); @@ -495,6 +520,7 @@ int analyze_bu2hpmumu_simulation() 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); + FillHlt1DecisionHistos(hlt1_decision_histos, reconstructed_B_Mass); } if (CutHlt1DecisionsOr({"TwoTrackMuonMVA", "DiMuonHighMass"})) @@ -529,6 +555,8 @@ int analyze_bu2hpmumu_simulation() DrawInDefaultCanvas(roofit_hist_jpsi, analysis_name, 0.1); DrawInDefaultCanvas(roofit_hist_psi2s, analysis_name, 0.1); + DrawHlt1DecisionHistos(analysis_name, hlt1_decision_histos); + return 0; } @@ -573,6 +601,8 @@ int analyze_b02hphmmumu() h2_Hlt1_flags_excl_B_Mass->Fill(0., var.name.c_str(), 0.); } + auto hlt1_decision_histos = CreateHlt1DecisionHistos(analysis_name); + std::map exclusive_hits{}; unsigned int entries = data_chain->GetEntries(); @@ -607,6 +637,7 @@ int analyze_b02hphmmumu() 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); + FillHlt1DecisionHistos(hlt1_decision_histos, reconstructed_B_Mass); } if (CutHlt1DecisionsOr({"TwoTrackMuonMVA", "DiMuonHighMass"})) @@ -643,6 +674,8 @@ int analyze_b02hphmmumu() DrawInDefaultCanvas(roofit_hist_jpsi, analysis_name, 0.1); DrawInDefaultCanvas(roofit_hist_psi2s, analysis_name, 0.1); + DrawHlt1DecisionHistos(analysis_name, hlt1_decision_histos); + return 0; } @@ -678,6 +711,8 @@ int analyze_Hlt2RD_BuToKpMuMu() h2_Hlt1_flags_excl_B_Mass->Fill(0., var.name.c_str(), 0.); } + auto hlt1_decision_histos = CreateHlt1DecisionHistos(analysis_name); + std::map exclusive_hits{}; unsigned int entries = data_chain->GetEntries(); @@ -694,6 +729,7 @@ int analyze_Hlt2RD_BuToKpMuMu() 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); + FillHlt1DecisionHistos(hlt1_decision_histos, reconstructed_B_Mass); } if (CutHlt1DecisionsOr({"TwoTrackMuonMVA", "DiMuonHighMass"})) @@ -727,6 +763,8 @@ int analyze_Hlt2RD_BuToKpMuMu() DrawInDefaultCanvas(roofit_hist_jpsi, analysis_name, 0.1); DrawInDefaultCanvas(roofit_hist_psi2s, analysis_name, 0.1); + DrawHlt1DecisionHistos(analysis_name, hlt1_decision_histos); + return 0; } @@ -763,6 +801,8 @@ int analyze_Hlt2RD_B0ToKpPimMuMu() h2_Hlt1_flags_excl_B_Mass->Fill(0., var.name.c_str(), 0.); } + auto hlt1_decision_histos = CreateHlt1DecisionHistos(analysis_name); + std::map exclusive_hits{}; unsigned int entries = data_chain->GetEntries(); @@ -781,6 +821,7 @@ int analyze_Hlt2RD_B0ToKpPimMuMu() 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); + FillHlt1DecisionHistos(hlt1_decision_histos, reconstructed_B_Mass); } if (CutHlt1DecisionsOr({"TwoTrackMuonMVA", "DiMuonHighMass"})) @@ -817,6 +858,8 @@ int analyze_Hlt2RD_B0ToKpPimMuMu() DrawInDefaultCanvas(roofit_hist_jpsi, analysis_name, 0.1); DrawInDefaultCanvas(roofit_hist_psi2s, analysis_name, 0.1); + DrawHlt1DecisionHistos(analysis_name, hlt1_decision_histos); + return 0; }