2024-02-27 15:43:32 +01:00
|
|
|
#include <string>
|
|
|
|
#include <iostream>
|
|
|
|
#include <cmath>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <filesystem>
|
|
|
|
#include <string_view>
|
|
|
|
|
|
|
|
#include "TH1D.h"
|
|
|
|
#include "TH2D.h"
|
|
|
|
#include "THStack.h"
|
|
|
|
#include "TGraph.h"
|
|
|
|
#include "TTree.h"
|
|
|
|
#include "TChain.h"
|
|
|
|
#include "TFile.h"
|
|
|
|
#include "TCanvas.h"
|
|
|
|
#include "TROOT.h"
|
|
|
|
#include "TStyle.h"
|
|
|
|
#include "TColor.h"
|
|
|
|
#include "TLorentzVector.h"
|
|
|
|
#include "TRandom3.h"
|
|
|
|
#include "TLegend.h"
|
|
|
|
|
|
|
|
#include "RooDataHist.h"
|
|
|
|
#include "RooRealVar.h"
|
|
|
|
#include "RooPlot.h"
|
|
|
|
#include "RooGaussian.h"
|
|
|
|
#include "RooExponential.h"
|
|
|
|
#include "RooRealConstant.h"
|
|
|
|
#include "RooAddPdf.h"
|
|
|
|
#include "RooFitResult.h"
|
|
|
|
#include "RooProduct.h"
|
|
|
|
#include "RooCrystalBall.h"
|
|
|
|
#include "RooBreitWigner.h"
|
|
|
|
#include "RooArgSet.h"
|
|
|
|
#include "RooFFTConvPdf.h"
|
|
|
|
#include "RooNovosibirsk.h"
|
|
|
|
|
|
|
|
#include "constants.h"
|
|
|
|
#include "basic_analysis.h"
|
|
|
|
#include "hlt1_decision_analysis.h"
|
|
|
|
#include "bdt_classification.h"
|
|
|
|
|
|
|
|
// %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Exclusive B0 To Kp Pim Mu Mu %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
|
|
|
|
|
|
|
int new_analysis_b02kppimmumu()
|
|
|
|
{
|
|
|
|
const char *analysis_name = "B0ToKpPimMuMu";
|
|
|
|
const char *data_tree_name = "Hlt2RD_B0ToKpPimMuMu";
|
|
|
|
const char *sim_tree_name = "B0ToKpPimMuMu_noPID";
|
|
|
|
const char *end_state_mass_literal = "m(K^{+}#pi^{-}#mu^{+}#mu^{-})";
|
|
|
|
const bool retrain_bdt = true;
|
|
|
|
|
|
|
|
TChain *data_chain = new TChain(TString::Format("%s/DecayTree", data_tree_name));
|
|
|
|
data_chain->Add("/auto/data/pfeiffer/inclusive_detached_dilepton/data_samples/Collision23_Beam6800GeV-VeloClosed-MagDown-Excl-UT_RealData_SprucingPass23r1_94000000_RD.root");
|
|
|
|
|
2024-02-29 15:54:28 +01:00
|
|
|
Int_t Hp_Q, Hm_Q;
|
|
|
|
|
2024-02-27 15:43:32 +01:00
|
|
|
FourVect *l14v_data = FourVect::Init(data_chain, "muplus");
|
|
|
|
FourVect *l24v_data = FourVect::Init(data_chain, "muminus");
|
|
|
|
FourVect *hp4v_data = FourVect::Init(data_chain, "Kplus");
|
|
|
|
FourVect *hm4v_data = FourVect::Init(data_chain, "piminus");
|
2024-02-29 15:54:28 +01:00
|
|
|
data_chain->SetBranchAddress("Kplus_Q", &Hp_Q);
|
|
|
|
data_chain->SetBranchAddress("piminus_Q", &Hm_Q);
|
2024-02-27 15:43:32 +01:00
|
|
|
|
|
|
|
TChain *sim_chain = new TChain(TString::Format("%s/DecayTree", sim_tree_name));
|
|
|
|
sim_chain->Add("/auto/data/pfeiffer/inclusive_detached_dilepton/MC/rd_btoxll_simulation_turbo_v0r0p6657752_B0ToKpPimMuMu_11144002_magdown.root");
|
|
|
|
|
|
|
|
FourVect *l14v_sim = FourVect::Init(sim_chain, "L1");
|
|
|
|
FourVect *l24v_sim = FourVect::Init(sim_chain, "L2");
|
|
|
|
FourVect *hp4v_sim = FourVect::Init(sim_chain, "K");
|
|
|
|
FourVect *hm4v_sim = FourVect::Init(sim_chain, "Pi");
|
|
|
|
|
|
|
|
Int_t B_BKGCAT, L1_TRUEID, L2_TRUEID, Hp_TRUEID, Hm_TRUEID;
|
|
|
|
|
|
|
|
sim_chain->SetBranchAddress("L1_TRUEID", &L1_TRUEID);
|
|
|
|
sim_chain->SetBranchAddress("L2_TRUEID", &L2_TRUEID);
|
|
|
|
sim_chain->SetBranchAddress("K_TRUEID", &Hp_TRUEID);
|
|
|
|
sim_chain->SetBranchAddress("Pi_TRUEID", &Hm_TRUEID);
|
|
|
|
sim_chain->SetBranchAddress("B0_BKGCAT", &B_BKGCAT);
|
|
|
|
|
2024-03-06 16:17:59 +01:00
|
|
|
Double_t B_Mass_jpsi_var, B_Mass_psi2s_var, B_Mass_sim_var;
|
|
|
|
TString B_Mass_jpsi_var_name = "B_Mass_jpsi_var";
|
|
|
|
TString B_Mass_psi2s_var_name = "B_Mass_psi2s_var";
|
|
|
|
TString B_Mass_sim_var_name = "B_Mass_sim_var";
|
|
|
|
|
|
|
|
TTree *tree_B_Mass_jpsi = new TTree("tree_B_Mass_jpsi", TString::Format("B Mass, J/#psi Mode (%s)", analysis_name));
|
|
|
|
TTree *tree_B_Mass_psi2s = new TTree("tree_B_Mass_psi2s", TString::Format("B Mass, #psi(2S) Mode (%s)", analysis_name));
|
|
|
|
TTree *tree_B_Mass_sim = new TTree("tree_B_Mass_sim", TString::Format("B Mass, Simualted (%s_noPID)", analysis_name));
|
|
|
|
|
|
|
|
tree_B_Mass_jpsi->Branch(B_Mass_jpsi_var_name, &B_Mass_jpsi_var);
|
|
|
|
tree_B_Mass_psi2s->Branch(B_Mass_psi2s_var_name, &B_Mass_psi2s_var);
|
|
|
|
tree_B_Mass_sim->Branch(B_Mass_sim_var_name, &B_Mass_sim_var);
|
|
|
|
|
|
|
|
TH1D *h1_B_Mass_unf = new TH1D("h1_B_Mass_unf", TString::Format("B Mass (%s), Unfiltered", data_tree_name), B_MASS_HIST_BINS, B_MASS_VAR_MIN, B_MASS_VAR_MAX);
|
|
|
|
TH1D *h1_B_Mass_sim_unf = new TH1D("h1_B_Mass_sim_unf", TString::Format("B Mass, Simualted (%s), Unfiltered", sim_tree_name), B_MASS_HIST_BINS, B_MASS_VAR_MIN, B_MASS_VAR_MAX);
|
|
|
|
|
2024-02-27 15:43:32 +01:00
|
|
|
TH2D *h2_Hlt1_flags_B_Mass = new TH2D("h2_Hlt1_flags_B_Mass", "Hlt1 Decision vs B Mass", 50, 5100, 5400, 13, 1., 14.);
|
|
|
|
TH2D *h2_Hlt1_flags_excl_B_Mass = new TH2D("h2_Hlt1_flags_excl_B_Mass", "Excl Hlt1 Decision vs B Mass", 50, 5100, 5400, 13, 1., 14.);
|
|
|
|
|
2024-03-06 16:17:59 +01:00
|
|
|
h1_B_Mass_unf->GetXaxis()->SetTitle(end_state_mass_literal);
|
|
|
|
h1_B_Mass_sim_unf->GetXaxis()->SetTitle(end_state_mass_literal);
|
2024-02-27 15:43:32 +01:00
|
|
|
h2_Hlt1_flags_B_Mass->GetXaxis()->SetTitle(end_state_mass_literal);
|
|
|
|
h2_Hlt1_flags_excl_B_Mass->GetXaxis()->SetTitle(end_state_mass_literal);
|
|
|
|
|
|
|
|
ConnectHlt1Decisions(data_chain, h2_Hlt1_flags_B_Mass, h2_Hlt1_flags_excl_B_Mass);
|
|
|
|
auto hlt1_decision_histos = CreateHlt1DecisionHistos(analysis_name);
|
|
|
|
std::map<std::string, int> exclusive_hits{};
|
|
|
|
|
|
|
|
unsigned int data_entries = data_chain->GetEntries();
|
|
|
|
unsigned int sim_entries = sim_chain->GetEntries();
|
|
|
|
|
|
|
|
for (unsigned int i = 0; i < sim_entries; i++)
|
|
|
|
{
|
|
|
|
sim_chain->GetEntry(i);
|
|
|
|
Double_t reconstructed_B_Mass = (hp4v_sim->LorentzVector() + hm4v_sim->LorentzVector() + l14v_sim->LorentzVector() + l24v_sim->LorentzVector()).M();
|
2024-03-06 16:17:59 +01:00
|
|
|
h1_B_Mass_sim_unf->Fill(reconstructed_B_Mass);
|
2024-02-27 15:43:32 +01:00
|
|
|
if (B_BKGCAT == 0 && TMath::Abs(L1_TRUEID) == PID_MUON && L2_TRUEID == -L1_TRUEID && TMath::Abs(Hp_TRUEID) == PID_KAON && TMath::Abs(Hm_TRUEID) == PID_PION)
|
|
|
|
{
|
2024-03-06 16:17:59 +01:00
|
|
|
B_Mass_sim_var = reconstructed_B_Mass;
|
|
|
|
tree_B_Mass_sim->Fill();
|
2024-02-27 15:43:32 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
PrintProgress(TString::Format("%s SIG Collection", analysis_name), sim_entries, 10000, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::cout << "# Starting evaluation of data." << std::endl;
|
|
|
|
|
2024-02-29 15:54:28 +01:00
|
|
|
int kplus = 0;
|
|
|
|
int kminus = 0;
|
|
|
|
int piplus = 0;
|
|
|
|
int piminus = 0;
|
|
|
|
|
2024-02-27 15:43:32 +01:00
|
|
|
for (unsigned int i = 0; i < data_entries; i++)
|
|
|
|
{
|
|
|
|
data_chain->GetEntry(i);
|
|
|
|
|
|
|
|
TLorentzVector dimuon = l14v_data->LorentzVector() + l24v_data->LorentzVector();
|
|
|
|
TLorentzVector reconstructed_Kstar = hp4v_data->LorentzVector() + hm4v_data->LorentzVector();
|
|
|
|
Double_t reconstructed_B_Mass = (reconstructed_Kstar + dimuon).M();
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
2024-03-06 16:17:59 +01:00
|
|
|
h1_B_Mass_unf->Fill(reconstructed_B_Mass);
|
|
|
|
if (TMath::Abs(reconstructed_Kstar.M() - KSTAR_MASS) < 100.)
|
2024-02-27 15:43:32 +01:00
|
|
|
{
|
2024-03-06 16:17:59 +01:00
|
|
|
if (TMath::Abs(dimuon.M() - JPSI_MASS) < 100.)
|
2024-02-27 15:43:32 +01:00
|
|
|
{
|
2024-03-06 16:17:59 +01:00
|
|
|
if (Hp_Q == 1)
|
2024-02-29 15:54:28 +01:00
|
|
|
{
|
2024-03-06 16:17:59 +01:00
|
|
|
kplus++;
|
2024-02-29 15:54:28 +01:00
|
|
|
}
|
2024-03-06 16:17:59 +01:00
|
|
|
else if (Hp_Q == -1)
|
|
|
|
{
|
|
|
|
kminus++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Hm_Q == 1)
|
2024-02-29 15:54:28 +01:00
|
|
|
{
|
2024-03-06 16:17:59 +01:00
|
|
|
piplus++;
|
2024-02-29 15:54:28 +01:00
|
|
|
}
|
2024-03-06 16:17:59 +01:00
|
|
|
else if (Hm_Q == -1)
|
|
|
|
{
|
|
|
|
piminus++;
|
|
|
|
}
|
|
|
|
|
|
|
|
B_Mass_jpsi_var = reconstructed_B_Mass;
|
|
|
|
tree_B_Mass_jpsi->Fill();
|
|
|
|
}
|
|
|
|
else if (TMath::Abs(dimuon.M() - PSI2S_MASS) < 100.)
|
|
|
|
{
|
|
|
|
B_Mass_psi2s_var = reconstructed_B_Mass;
|
|
|
|
tree_B_Mass_psi2s->Fill();
|
2024-02-27 15:43:32 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PrintProgress(TString::Format("%s Data Evaluation", analysis_name), data_entries, 10000, i);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::cout << "# Exclusive Hits" << std::endl;
|
|
|
|
for (const auto &[line, hits] : exclusive_hits)
|
|
|
|
{
|
|
|
|
std::cout << line << ": " << hits << std::endl;
|
|
|
|
}
|
|
|
|
|
2024-03-06 16:17:59 +01:00
|
|
|
DrawInDefaultCanvas(h2_Hlt1_flags_B_Mass, analysis_name, 0.16, "COLZ");
|
|
|
|
DrawInDefaultCanvas(h2_Hlt1_flags_excl_B_Mass, analysis_name, 0.16, "COLZ");
|
2024-02-29 15:54:28 +01:00
|
|
|
// DrawInDefaultCanvas(h1_B_Mass_jpsi, analysis_name, 0.1);
|
|
|
|
// DrawInDefaultCanvas(h1_B_Mass_psi2s, analysis_name, 0.1);
|
2024-02-27 15:43:32 +01:00
|
|
|
|
2024-03-06 16:17:59 +01:00
|
|
|
DrawInDefaultCanvas(h1_B_Mass_unf, analysis_name, 0.1);
|
|
|
|
DrawInDefaultCanvas(h1_B_Mass_sim_unf, analysis_name, 0.1);
|
|
|
|
|
|
|
|
auto roofit_hist_sim = CreateRooDataSetAndFitCB(tree_B_Mass_sim, B_Mass_sim_var_name, end_state_mass_literal, false, false, ShapeParamters{});
|
|
|
|
auto roofit_hist_jpsi_fitsum = CreateRooDataSetAndFitCB(tree_B_Mass_jpsi, B_Mass_jpsi_var_name, end_state_mass_literal, true, true, roofit_hist_sim.shape_parameters);
|
|
|
|
auto roofit_hist_psi2s_fitsum = CreateRooDataSetAndFitCB(tree_B_Mass_psi2s, B_Mass_psi2s_var_name, end_state_mass_literal, true, true, roofit_hist_sim.shape_parameters);
|
2024-02-27 15:43:32 +01:00
|
|
|
|
|
|
|
DrawInDefaultCanvas(roofit_hist_jpsi_fitsum, analysis_name);
|
|
|
|
DrawInDefaultCanvas(roofit_hist_psi2s_fitsum, analysis_name);
|
|
|
|
DrawInDefaultCanvas(roofit_hist_sim, analysis_name);
|
|
|
|
|
2024-02-29 15:54:28 +01:00
|
|
|
// DrawHlt1DecisionHistos(analysis_name, hlt1_decision_histos);
|
|
|
|
|
2024-03-06 16:17:59 +01:00
|
|
|
std::cout << "hist entries: " << tree_B_Mass_jpsi->GetEntries() << ", kplus: " << kplus << ", kminus: " << kminus << ", piplus: " << piplus << ", piminus: " << piminus << std::endl;
|
2024-02-27 15:43:32 +01:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|