2024-01-22 16:45:48 +01:00
|
|
|
#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 "TLorentzVector.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 <string>
|
|
|
|
#include <iostream>
|
|
|
|
#include <cmath>
|
|
|
|
#include <filesystem>
|
|
|
|
|
2024-01-23 16:36:19 +01:00
|
|
|
const int nBins = 170;//70;
|
2024-01-22 16:45:48 +01:00
|
|
|
|
2024-01-23 16:36:19 +01:00
|
|
|
const Double_t MASS_HIST_MIN = 2000.;
|
2024-01-22 16:45:48 +01:00
|
|
|
const Double_t MASS_HIST_MAX = 6000.;
|
2024-01-23 16:36:19 +01:00
|
|
|
const Double_t MASS_HIST_FIT_MIN = 2000.;
|
2024-01-22 16:45:48 +01:00
|
|
|
const Double_t MASS_HIST_FIT_MAX = 6000.;
|
|
|
|
|
|
|
|
const Double_t K_MASS = 493.677;
|
|
|
|
|
|
|
|
int simulation()
|
|
|
|
{
|
2024-01-23 16:36:19 +01:00
|
|
|
const char *name = "BuToHpMuMu_Fullstream";
|
2024-01-22 16:45:48 +01:00
|
|
|
const bool use_hyp_replace = true;
|
|
|
|
const char *b_name = "B";
|
|
|
|
|
2024-01-23 16:36:19 +01:00
|
|
|
auto quickformat_name = [name](const char *format)
|
|
|
|
{
|
2024-01-22 16:45:48 +01:00
|
|
|
return TString::Format(format, name);
|
|
|
|
};
|
|
|
|
|
2024-01-23 16:36:19 +01:00
|
|
|
TChain *data_chain = new TChain("BuToHpMuMu_noPID/DecayTree");
|
2024-01-22 16:45:48 +01:00
|
|
|
data_chain->Add("/auto/data/pfeiffer/inclusive_detached_dilepton/MC/rd_btoxll_simulation_fullstream_v0r0p6671378_BuToKpMuMu_12143001_magdown.root");
|
|
|
|
|
2024-01-23 16:36:19 +01:00
|
|
|
// TRUE ID: Muon sind Muons, Hadronen sind K, pi
|
2024-01-22 16:45:48 +01:00
|
|
|
/*
|
|
|
|
rd_btoxll_simulation_fullstream_v0r0p6671378_B0ToKpPimMuMu_11144002_magdown.root
|
|
|
|
rd_btoxll_simulation_fullstream_v0r0p6671378_BuToKpMuMu_12143001_magdown.root
|
|
|
|
rd_btoxll_simulation_turbo_v0r0p6657752_B0ToKpPimMuMu_11144002_magdown.root
|
|
|
|
rd_btoxll_simulation_turbo_v0r0p6657752_BuToKpMuMu_12143001_magdown.root
|
|
|
|
*/
|
|
|
|
|
|
|
|
Int_t B_BKGCAT;
|
|
|
|
data_chain->SetBranchAddress(TString::Format("%s_BKGCAT", b_name).Data(), &B_BKGCAT);
|
|
|
|
|
2024-01-23 16:36:19 +01:00
|
|
|
Float_t L1_PX, L1_PY, L1_PZ, L1_ENERGY,
|
|
|
|
L2_PX, L2_PY, L2_PZ, L2_ENERGY,
|
|
|
|
Hp_PX, Hp_PY, Hp_PZ, Hp_ENERGY;
|
2024-01-22 16:45:48 +01:00
|
|
|
Double_t B_M;
|
|
|
|
|
2024-01-23 16:36:19 +01:00
|
|
|
Int_t L1_TRUEID, L2_TRUEID, Hp_TRUEID;
|
|
|
|
|
|
|
|
data_chain->SetBranchAddress("L1_TRUEID", &L1_TRUEID);
|
|
|
|
data_chain->SetBranchAddress("L2_TRUEID", &L2_TRUEID);
|
|
|
|
data_chain->SetBranchAddress("Hp_TRUEID", &Hp_TRUEID);
|
|
|
|
|
2024-01-22 16:45:48 +01:00
|
|
|
if (use_hyp_replace)
|
|
|
|
{
|
|
|
|
data_chain->SetBranchAddress("L1_PX", &L1_PX);
|
|
|
|
data_chain->SetBranchAddress("L1_PY", &L1_PY);
|
|
|
|
data_chain->SetBranchAddress("L1_PZ", &L1_PZ);
|
|
|
|
data_chain->SetBranchAddress("L1_ENERGY", &L1_ENERGY);
|
|
|
|
data_chain->SetBranchAddress("L2_PX", &L2_PX);
|
|
|
|
data_chain->SetBranchAddress("L2_PY", &L2_PY);
|
|
|
|
data_chain->SetBranchAddress("L2_PZ", &L2_PZ);
|
|
|
|
data_chain->SetBranchAddress("L2_ENERGY", &L2_ENERGY);
|
|
|
|
data_chain->SetBranchAddress("Hp_PX", &Hp_PX);
|
|
|
|
data_chain->SetBranchAddress("Hp_PY", &Hp_PY);
|
|
|
|
data_chain->SetBranchAddress("Hp_PZ", &Hp_PZ);
|
|
|
|
data_chain->SetBranchAddress("Hp_ENERGY", &Hp_ENERGY);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
data_chain->SetBranchAddress(TString::Format("%s_M", b_name).Data(), &B_M);
|
|
|
|
}
|
|
|
|
|
|
|
|
TH1D *h1_B_M = new TH1D("h1_B_M", "B Mass", nBins, MASS_HIST_MIN, MASS_HIST_MAX);
|
2024-01-23 16:36:19 +01:00
|
|
|
TH1D *h1_B_M_trueid = new TH1D("h1_B_M_trueid", "B Mass, TrueID matched", nBins, MASS_HIST_MIN, MASS_HIST_MAX);
|
2024-01-22 16:45:48 +01:00
|
|
|
TH1I *h1_B_BKGCAT = new TH1I("h1_B_BKGCAT", "B Background Category", nBins, 0, 120);
|
|
|
|
TH2D *h2_B_M_vs_B_BKGCAT = new TH2D("h2_B_M_vs_B_BKGCAT", "B Mass vs Background Category", nBins, MASS_HIST_MIN, MASS_HIST_MAX, nBins, 0, 120);
|
|
|
|
|
|
|
|
unsigned int entries = data_chain->GetEntries();
|
|
|
|
for (size_t i = 0; i < entries; i++)
|
|
|
|
{
|
|
|
|
data_chain->GetEntry(i);
|
|
|
|
// std::cout << B_BKGCAT << std::endl;
|
|
|
|
|
|
|
|
Double_t reconstructed_B_Mass = 0;
|
|
|
|
|
|
|
|
if (use_hyp_replace)
|
|
|
|
{
|
|
|
|
TVector3 K_momentum(Hp_PX, Hp_PY, Hp_PZ);
|
2024-01-23 16:36:19 +01:00
|
|
|
|
2024-01-22 16:45:48 +01:00
|
|
|
double K_energy = TMath::Sqrt(TMath::Sq(K_MASS) + K_momentum.Mag2());
|
|
|
|
TLorentzVector K_4v(K_momentum, K_energy);
|
|
|
|
TLorentzVector l1_4v(L1_PX, L1_PY, L1_PZ, L1_ENERGY);
|
|
|
|
TLorentzVector l2_4v(L2_PX, L2_PY, L2_PZ, L2_ENERGY);
|
2024-01-23 16:36:19 +01:00
|
|
|
reconstructed_B_Mass = (K_4v + l1_4v + l2_4v).M();
|
2024-01-22 16:45:48 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
reconstructed_B_Mass = B_M;
|
|
|
|
}
|
|
|
|
|
2024-01-23 16:36:19 +01:00
|
|
|
if (TMath::Abs(L1_TRUEID) == 13 && L2_TRUEID == -L1_TRUEID && TMath::Abs(Hp_TRUEID) == 321)
|
2024-01-22 16:45:48 +01:00
|
|
|
{
|
2024-01-23 16:36:19 +01:00
|
|
|
std::cout << "L1: " << L1_TRUEID << ", L2: " << L2_TRUEID << ", Hp: " << Hp_TRUEID << std::endl;
|
|
|
|
std::cout << "Mass: " << reconstructed_B_Mass << std::endl;
|
|
|
|
h1_B_M_trueid->Fill(reconstructed_B_Mass);
|
2024-01-22 16:45:48 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
h1_B_M->Fill(reconstructed_B_Mass);
|
|
|
|
h1_B_BKGCAT->Fill(B_BKGCAT);
|
|
|
|
h2_B_M_vs_B_BKGCAT->Fill(reconstructed_B_Mass, B_BKGCAT);
|
|
|
|
|
|
|
|
if (i % 10000 == 0)
|
|
|
|
{
|
|
|
|
std::cout << "["
|
|
|
|
<< name
|
|
|
|
<< "] Processed event: " << i << " (" << TString::Format("%.2f", ((double)i / (double)entries) * 100.) << "%)" << std::endl;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
h1_B_M->SetLineColor(kBlue);
|
2024-01-23 16:36:19 +01:00
|
|
|
h1_B_M_trueid->SetLineColor(kMagenta + 2);
|
|
|
|
h1_B_M_trueid->SetFillColor(kMagenta + 2);
|
|
|
|
h1_B_M_trueid->SetFillStyle(3244);
|
2024-01-22 16:45:48 +01:00
|
|
|
|
|
|
|
h1_B_BKGCAT->SetLineColor(kBlue);
|
|
|
|
h1_B_BKGCAT->SetFillColor(kBlue);
|
|
|
|
h1_B_BKGCAT->SetFillStyle(3351);
|
|
|
|
|
|
|
|
std::filesystem::create_directory(TString::Format("images/sim/%s", name).Data());
|
|
|
|
|
|
|
|
TCanvas *c1 = new TCanvas("c1", "c1", 0, 0, 800, 600);
|
|
|
|
h1_B_M->SetStats(0);
|
2024-01-23 16:36:19 +01:00
|
|
|
h1_B_M_trueid->SetStats(0);
|
2024-01-22 16:45:48 +01:00
|
|
|
h1_B_M->Draw();
|
2024-01-23 16:36:19 +01:00
|
|
|
h1_B_M_trueid->Draw("SAME");
|
2024-01-22 16:45:48 +01:00
|
|
|
c1->BuildLegend(0.58, 0.65, 0.85, 0.87);
|
|
|
|
c1->Draw();
|
|
|
|
c1->SaveAs(quickformat_name("images/sim/%s/h1_B_M.pdf"));
|
|
|
|
|
|
|
|
TCanvas *c2 = new TCanvas("c2", "c2", 0, 0, 800, 600);
|
|
|
|
h1_B_BKGCAT->SetStats(0);
|
|
|
|
h1_B_BKGCAT->Draw();
|
|
|
|
c2->BuildLegend(0.58, 0.77, 0.85, 0.87);
|
|
|
|
c2->Draw();
|
|
|
|
c2->SaveAs(quickformat_name("images/sim/%s/h1_B_BKGCAT.pdf"));
|
|
|
|
|
|
|
|
TCanvas *c3 = new TCanvas("c3", "c3", 0, 0, 800, 600);
|
|
|
|
h2_B_M_vs_B_BKGCAT->SetStats(0);
|
|
|
|
h2_B_M_vs_B_BKGCAT->Draw("COLZ");
|
|
|
|
c3->Draw();
|
|
|
|
c3->SaveAs(quickformat_name("images/sim/%s/h2_B_M_vs_B_BKGCAT.pdf"));
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|