Browse Source

status report plots, mass sub

pull/1/head
Marius Pfeiffer 10 months ago
parent
commit
628071a159
  1. 1
      .gitignore
  2. 185
      pre_selection_cuts.cpp
  3. 236
      status_report_plots.cpp
  4. 105
      subs_mass.cpp
  5. 66
      train_bdt.cpp

1
.gitignore

@ -1,3 +1,4 @@
*.root *.root
dataloader/** dataloader/**
status_report/**
branchnames.txt branchnames.txt

185
pre_selection_cuts.cpp

@ -23,14 +23,26 @@
#include "RooFitResult.h" #include "RooFitResult.h"
#include "RooProduct.h" #include "RooProduct.h"
#include "RooCrystalBall.h" #include "RooCrystalBall.h"
#include "RooBreitWigner.h"
#include <string> #include <string>
#include <iostream> #include <iostream>
#include <cmath> #include <cmath>
const int nBins = 150;
const int nBins = 70;
const Double_t MASS_HIST_MIN = 5100.;
const Double_t MASS_HIST_MAX = 6000.;
const Double_t J_PSI_MASS = 3096.916;
RooPlot *CreateRooFit(TH1D *hist);
std::vector<RooPlot*> CreateRooFit(TH1D *hist);
bool inRange(double value, double center, double low_intvl, double up_intvl) {
return center - low_intvl < value && value < center + up_intvl;
}
bool inRange(double value, double center, double intvl) {
return inRange(value, center, intvl, intvl);
}
int pre_selection_cuts() int pre_selection_cuts()
{ {
@ -67,9 +79,9 @@ int pre_selection_cuts()
// files to load // files to load
std::vector<std::string> mc_filenames = std::vector<std::string> mc_filenames =
{ {
"/auto/data/pfeiffer/inclusive_detached_dilepton/MC/BuToKpMuMu_rd_btoxll_simulation_12143001_MagDown_v0r0p6316987.root"};
"/auto/data/pfeiffer/inclusive_detached_dilepton/MC/BuToKpMuMu_rd_btoxll_simulation_12143001_MagDown_v0r0p6316365_FULLSTREAM.root"};
TChain *mc_chain = new TChain("BuToKpMuMu23_noPID/DecayTree");
TChain *mc_chain = new TChain("BuToKpMuMu_noPID/DecayTree");
for (unsigned int i = 0; i < mc_filenames.size(); i++) for (unsigned int i = 0; i < mc_filenames.size(); i++)
{ {
mc_chain->Add(mc_filenames.at(i).c_str()); mc_chain->Add(mc_filenames.at(i).c_str());
@ -81,6 +93,7 @@ int pre_selection_cuts()
Float_t Bplus_PT, // 0 -> 30 * 10^3 Float_t Bplus_PT, // 0 -> 30 * 10^3
Bplus_BPVFDCHI2, // 0 -> 7000 Bplus_BPVFDCHI2, // 0 -> 7000
Bplus_BPVIPCHI2,
Jpsi_BPVIPCHI2, // 0 -> 3 Jpsi_BPVIPCHI2, // 0 -> 3
Jpsi_PT, // 0 -> 26 * 10^3 Jpsi_PT, // 0 -> 26 * 10^3
Kplus_BPVIPCHI2, // 0 -> 7 Kplus_BPVIPCHI2, // 0 -> 7
@ -88,24 +101,47 @@ int pre_selection_cuts()
Double_t Bplus_M_mc, // 4400 -> 8200 Double_t Bplus_M_mc, // 4400 -> 8200
Jpsi_M_mc, // 200 -> 6600 Jpsi_M_mc, // 200 -> 6600
Kplus_M_mc; // 493.6769 -> 493.6779
Kplus_M_mc, // 493.6769 -> 493.6779
Kplus_PID_K; // -20 -> 20
Float_t Bplus_PT_mc, // 0 -> 30 * 10^3 Float_t Bplus_PT_mc, // 0 -> 30 * 10^3
Bplus_BPVFDCHI2_mc, // 0 -> 7000 Bplus_BPVFDCHI2_mc, // 0 -> 7000
Jpsi_BPVIPCHI2_mc, // 0 -> 3 Jpsi_BPVIPCHI2_mc, // 0 -> 3
Jpsi_PT_mc, // 0 -> 26 * 10^3 Jpsi_PT_mc, // 0 -> 26 * 10^3
Kplus_BPVIPCHI2_mc, // 0 -> 7 Kplus_BPVIPCHI2_mc, // 0 -> 7
Kplus_PT_mc; // 0 -> 11 * 10^3
Kplus_PT_mc, // 0 -> 11 * 10^3
Kplus_PID_K_mc;
Float_t muplus_PX, // 0 -> 30 * 10^3
muplus_PY, // 0 -> 7000
muplus_PZ, // 0 -> 3
muplus_ENERGY, // 0 -> 26 * 10^3
muminus_PX, // 0 -> 7
muminus_PY, // 0 -> 11 * 10^3
muminus_PZ, // 0 -> 7
muminus_ENERGY; // 0 -> 11 * 10^3
data_chain->SetBranchAddress("Bplus_M", &Bplus_M); data_chain->SetBranchAddress("Bplus_M", &Bplus_M);
data_chain->SetBranchAddress("Bplus_PT", &Bplus_PT); data_chain->SetBranchAddress("Bplus_PT", &Bplus_PT);
data_chain->SetBranchAddress("Bplus_BPVFDCHI2", &Bplus_BPVFDCHI2); data_chain->SetBranchAddress("Bplus_BPVFDCHI2", &Bplus_BPVFDCHI2);
data_chain->SetBranchAddress("Bplus_BPVIPCHI2", &Bplus_BPVIPCHI2);
data_chain->SetBranchAddress("Jpsi_M", &Jpsi_M); data_chain->SetBranchAddress("Jpsi_M", &Jpsi_M);
data_chain->SetBranchAddress("Jpsi_BPVIPCHI2", &Jpsi_BPVIPCHI2); data_chain->SetBranchAddress("Jpsi_BPVIPCHI2", &Jpsi_BPVIPCHI2);
data_chain->SetBranchAddress("Jpsi_PT", &Jpsi_PT); data_chain->SetBranchAddress("Jpsi_PT", &Jpsi_PT);
data_chain->SetBranchAddress("Kplus_M", &Kplus_M); data_chain->SetBranchAddress("Kplus_M", &Kplus_M);
data_chain->SetBranchAddress("Kplus_BPVIPCHI2", &Kplus_BPVIPCHI2); data_chain->SetBranchAddress("Kplus_BPVIPCHI2", &Kplus_BPVIPCHI2);
data_chain->SetBranchAddress("Kplus_PT", &Kplus_PT); data_chain->SetBranchAddress("Kplus_PT", &Kplus_PT);
data_chain->SetBranchAddress("Kplus_PID_K", &Kplus_PID_K);
data_chain->SetBranchAddress("muplus_PX", &muplus_PX);
data_chain->SetBranchAddress("muplus_PY", &muplus_PY);
data_chain->SetBranchAddress("muplus_PZ", &muplus_PZ);
data_chain->SetBranchAddress("muplus_ENERGY", &muplus_ENERGY);
data_chain->SetBranchAddress("muminus_PX", &muminus_PX);
data_chain->SetBranchAddress("muminus_PY", &muminus_PY);
data_chain->SetBranchAddress("muminus_PZ", &muminus_PZ);
data_chain->SetBranchAddress("muminus_ENERGY", &muminus_ENERGY);
mc_chain->SetBranchAddress("B_M", &Bplus_M_mc); mc_chain->SetBranchAddress("B_M", &Bplus_M_mc);
mc_chain->SetBranchAddress("B_PT", &Bplus_PT_mc); mc_chain->SetBranchAddress("B_PT", &Bplus_PT_mc);
@ -117,7 +153,7 @@ int pre_selection_cuts()
mc_chain->SetBranchAddress("K_BPVIPCHI2", &Kplus_BPVIPCHI2_mc); mc_chain->SetBranchAddress("K_BPVIPCHI2", &Kplus_BPVIPCHI2_mc);
mc_chain->SetBranchAddress("K_PT", &Kplus_PT_mc); mc_chain->SetBranchAddress("K_PT", &Kplus_PT_mc);
TH1D *h1_Bplus_M = new TH1D("h1_Bplus_M", "B+ Mass", nBins, 4500, 7500);
TH1D *h1_Bplus_M = new TH1D("h1_Bplus_M", "B+ Mass", nBins, MASS_HIST_MIN, MASS_HIST_MAX);
TH1D *h1_Bplus_PT = new TH1D("h1_Bplus_PT", "B+ P_{T}", nBins, 0, 15000); TH1D *h1_Bplus_PT = new TH1D("h1_Bplus_PT", "B+ P_{T}", nBins, 0, 15000);
TH1D *h1_Bplus_BPVFDCHI2 = new TH1D("h1_Bplus_BPVFDCHI2", "B+ FD #chi^{2}", nBins, 0, 1500); TH1D *h1_Bplus_BPVFDCHI2 = new TH1D("h1_Bplus_BPVFDCHI2", "B+ FD #chi^{2}", nBins, 0, 1500);
TH1D *h1_Jpsi_M = new TH1D("h1_Jpsi_M", "J/#psi Mass", nBins, 200, 6600); TH1D *h1_Jpsi_M = new TH1D("h1_Jpsi_M", "J/#psi Mass", nBins, 200, 6600);
@ -126,8 +162,9 @@ int pre_selection_cuts()
TH1D *h1_Kplus_M = new TH1D("h1_Kplus_M", "K^{+} Mass", nBins, 493.676999999, 493.677000001); TH1D *h1_Kplus_M = new TH1D("h1_Kplus_M", "K^{+} Mass", nBins, 493.676999999, 493.677000001);
TH1D *h1_Kplus_BPVIPCHI2 = new TH1D("h1_Kplus_BPVIPCHI2", "K^{+} IP #chi^{2}", nBins, 0, 100); TH1D *h1_Kplus_BPVIPCHI2 = new TH1D("h1_Kplus_BPVIPCHI2", "K^{+} IP #chi^{2}", nBins, 0, 100);
TH1D *h1_Kplus_PT = new TH1D("h1_Kplus_PT", "K^{+} P_{T}", nBins, 0, 6500); TH1D *h1_Kplus_PT = new TH1D("h1_Kplus_PT", "K^{+} P_{T}", nBins, 0, 6500);
TH1D *h1_Kplus_PID_K = new TH1D("h1_Kplus_PID_K", "K^{+} PID K", nBins, -5, 5);
TH1D *h1_bkg_Bplus_M = new TH1D("h1_bkg_Bplus_M", "B+ Mass", nBins, 4500, 7500);
TH1D *h1_bkg_Bplus_M = new TH1D("h1_bkg_Bplus_M", "B+ Mass", nBins, MASS_HIST_MIN, MASS_HIST_MAX);
TH1D *h1_bkg_Bplus_PT = new TH1D("h1_bkg_Bplus_PT", "B+ P_{T}", nBins, 0, 15000); TH1D *h1_bkg_Bplus_PT = new TH1D("h1_bkg_Bplus_PT", "B+ P_{T}", nBins, 0, 15000);
TH1D *h1_bkg_Bplus_BPVFDCHI2 = new TH1D("h1_bkg_Bplus_BPVFDCHI2", "B+ FD #chi^{2}", nBins, 0, 1500); TH1D *h1_bkg_Bplus_BPVFDCHI2 = new TH1D("h1_bkg_Bplus_BPVFDCHI2", "B+ FD #chi^{2}", nBins, 0, 1500);
TH1D *h1_bkg_Jpsi_M = new TH1D("h1_bkg_Jpsi_M", "J/#psi Mass", nBins, 200, 6600); TH1D *h1_bkg_Jpsi_M = new TH1D("h1_bkg_Jpsi_M", "J/#psi Mass", nBins, 200, 6600);
@ -136,36 +173,29 @@ int pre_selection_cuts()
TH1D *h1_bkg_Kplus_M = new TH1D("h1_bkg_Kplus_M", "K^{+} Mass", nBins, 493.676999999, 493.677000001); TH1D *h1_bkg_Kplus_M = new TH1D("h1_bkg_Kplus_M", "K^{+} Mass", nBins, 493.676999999, 493.677000001);
TH1D *h1_bkg_Kplus_BPVIPCHI2 = new TH1D("h1_bkg_Kplus_BPVIPCHI2", "K^{+} IP #chi^{2}", nBins, 0, 100); TH1D *h1_bkg_Kplus_BPVIPCHI2 = new TH1D("h1_bkg_Kplus_BPVIPCHI2", "K^{+} IP #chi^{2}", nBins, 0, 100);
TH1D *h1_bkg_Kplus_PT = new TH1D("h1_bkg_Kplus_PT", "K^{+} P_{T}", nBins, 0, 6500); TH1D *h1_bkg_Kplus_PT = new TH1D("h1_bkg_Kplus_PT", "K^{+} P_{T}", nBins, 0, 6500);
TH1D *h1_bkg_Kplus_PID_K = new TH1D("h1_bkg_Kplus_PID_K", "K^{+} PID K", nBins, -5, 5);
unsigned int entries = data_chain->GetEntries(); unsigned int entries = data_chain->GetEntries();
unsigned int nan_values = 0;
// loop over all entries in the tree // loop over all entries in the tree
for (unsigned int i = 0; i < entries; i++) for (unsigned int i = 0; i < entries; i++)
{ {
data_chain->GetEntry(i); data_chain->GetEntry(i);
const double JSPI_MASS = 3096.; const double JSPI_MASS = 3096.;
if (!std::isfinite(Jpsi_BPVIPCHI2) || !std::isfinite(Jpsi_M)) {
std::cout << "INF Value (" << i << ") Jpsi_BPVIPCHI2: " << Jpsi_BPVIPCHI2 << ", Jpsi_M: " << Jpsi_M << std::endl;
if (!std::isfinite(Jpsi_M)) {
nan_values++;
continue;
} }
/*
B+ PT > 1500.
B+ FDCHI2 > 100.
J/Psi IP > 0.05
J/Psi PT > 1000.
K+ IP > 0.2
K+ PT > 650.
eher auf IP CHI2 schneiden, statt IP. da eher signifikanz
*/
if (Bplus_PT > 1200. && Bplus_BPVFDCHI2 > 90. && /*Jpsi_IP_OWNPV > 0.05 && */
Jpsi_PT > 800. && Kplus_BPVIPCHI2 > 0.17 && Kplus_PT > 500. && (JSPI_MASS - 150. < Jpsi_M && Jpsi_M < JSPI_MASS + 150.))
TLorentzVector v4_muplus(muplus_PX, muplus_PY, muplus_PZ, muplus_ENERGY);
TLorentzVector v4_muminus(muminus_PX, muminus_PY, muminus_PZ, muminus_ENERGY);
Double_t mumu_inv_mass = (v4_muplus + v4_muminus).M();
if (inRange(mumu_inv_mass, J_PSI_MASS, 120.))
{ {
h1_Bplus_M->Fill(Bplus_M); h1_Bplus_M->Fill(Bplus_M);
} }
else
{
h1_bkg_Bplus_M->Fill(Bplus_M);
}
h1_bkg_Bplus_PT->Fill(Bplus_PT); h1_bkg_Bplus_PT->Fill(Bplus_PT);
h1_bkg_Bplus_BPVFDCHI2->Fill(Bplus_BPVFDCHI2); h1_bkg_Bplus_BPVFDCHI2->Fill(Bplus_BPVFDCHI2);
@ -175,8 +205,11 @@ int pre_selection_cuts()
h1_bkg_Kplus_M->Fill(Kplus_M); h1_bkg_Kplus_M->Fill(Kplus_M);
h1_bkg_Kplus_BPVIPCHI2->Fill(Kplus_BPVIPCHI2); h1_bkg_Kplus_BPVIPCHI2->Fill(Kplus_BPVIPCHI2);
h1_bkg_Kplus_PT->Fill(Kplus_PT); h1_bkg_Kplus_PT->Fill(Kplus_PT);
h1_bkg_Kplus_PID_K->Fill(Kplus_PID_K);
} }
std::cout << TString::Format("Skipped %d NaN Values.", nan_values) << std::endl;
unsigned int mc_entries = mc_chain->GetEntries(); unsigned int mc_entries = mc_chain->GetEntries();
for (size_t i = 0; i < mc_entries; i++) for (size_t i = 0; i < mc_entries; i++)
@ -190,78 +223,99 @@ int pre_selection_cuts()
h1_Kplus_M->Fill(Kplus_M); h1_Kplus_M->Fill(Kplus_M);
h1_Kplus_BPVIPCHI2->Fill(Kplus_BPVIPCHI2_mc); h1_Kplus_BPVIPCHI2->Fill(Kplus_BPVIPCHI2_mc);
h1_Kplus_PT->Fill(Kplus_PT_mc); h1_Kplus_PT->Fill(Kplus_PT_mc);
h1_Kplus_PID_K->Fill(Kplus_PID_K_mc);
} }
TCanvas *c1 = new TCanvas("c1", "Canvas 1", 0, 0, 800, 600); TCanvas *c1 = new TCanvas("c1", "Canvas 1", 0, 0, 800, 600);
h1_bkg_Bplus_M->SetLineColor(kRed);
h1_bkg_Bplus_M->Draw();
//h1_bkg_Bplus_M->SetLineColor(kRed);
//h1_bkg_Bplus_M->Draw();
h1_Bplus_M->Draw(); h1_Bplus_M->Draw();
c1->Draw(); c1->Draw();
std::vector<TH1 *> small_histos{h1_Bplus_PT, h1_Bplus_BPVFDCHI2, h1_Jpsi_M, h1_Jpsi_BPVIPCHI2, h1_Jpsi_PT, h1_Kplus_M, h1_Kplus_BPVIPCHI2, h1_Kplus_PT};
std::vector<TH1 *> small_bkg_histos{h1_bkg_Bplus_PT, h1_bkg_Bplus_BPVFDCHI2, h1_bkg_Jpsi_M, h1_bkg_Jpsi_BPVIPCHI2, h1_bkg_Jpsi_PT, h1_bkg_Kplus_M, h1_bkg_Kplus_BPVIPCHI2, h1_bkg_Kplus_PT};
std::vector<TH1 *> small_histos{h1_Bplus_PT, h1_Bplus_BPVFDCHI2, h1_Jpsi_M, h1_Jpsi_BPVIPCHI2, h1_Jpsi_PT, h1_Kplus_M, h1_Kplus_BPVIPCHI2, h1_Kplus_PT, h1_Kplus_PID_K};
std::vector<TH1 *> small_bkg_histos{h1_bkg_Bplus_PT, h1_bkg_Bplus_BPVFDCHI2, h1_bkg_Jpsi_M, h1_bkg_Jpsi_BPVIPCHI2, h1_bkg_Jpsi_PT, h1_bkg_Kplus_M, h1_bkg_Kplus_BPVIPCHI2, h1_bkg_Kplus_PT, h1_bkg_Kplus_PID_K};
TCanvas *c2 = new TCanvas("c2", "Canvas 2", 0, 0, 1200, 600); TCanvas *c2 = new TCanvas("c2", "Canvas 2", 0, 0, 1200, 600);
c2->Divide(4, 2);
c2->Divide(4, 3);
for (size_t i = 0; i < small_histos.size(); i++) for (size_t i = 0; i < small_histos.size(); i++)
{ {
c2->cd(i + 1); c2->cd(i + 1);
small_histos[i]->SetLineWidth(1);
small_histos[i]->SetMinimum(0);
small_histos[i]->SetLineColor(kRed);
small_histos[i]->SetFillColor(kRed);
small_histos[i]->SetFillStyle(3004);
small_histos[i]->Scale(1. / small_histos[i]->Integral(), "width");
// small_histos[i]->SetLineWidth(1);
// small_histos[i]->SetMinimum(0);
// small_histos[i]->SetLineColor(kRed);
// small_histos[i]->SetFillColor(kRed);
// small_histos[i]->SetFillStyle(3004);
// small_histos[i]->Scale(1. / small_histos[i]->Integral(), "width");
small_bkg_histos[i]->SetLineColor(kBlue); small_bkg_histos[i]->SetLineColor(kBlue);
small_bkg_histos[i]->SetLineWidth(2); small_bkg_histos[i]->SetLineWidth(2);
small_bkg_histos[i]->SetMinimum(0); small_bkg_histos[i]->SetMinimum(0);
small_bkg_histos[i]->Scale(1. / small_bkg_histos[i]->Integral(), "width");
if (small_histos[i]->GetMaximum() > small_bkg_histos[i]->GetMaximum())
{
small_histos[i]->Draw("HIST");
small_bkg_histos[i]->Draw("HIST SAME");
}
else
{
small_bkg_histos[i]->Draw("HIST");
small_histos[i]->Draw("HIST SAME");
}
// small_bkg_histos[i]->Scale(1. / small_bkg_histos[i]->Integral(), "width");
// if (small_histos[i]->GetMaximum() > small_bkg_histos[i]->GetMaximum())
// {
// small_histos[i]->Draw("HIST");
// small_bkg_histos[i]->Draw("HIST SAME");
// }
// else
// {
// small_bkg_histos[i]->Draw("HIST");
// small_histos[i]->Draw("HIST SAME");
// }
small_bkg_histos[i]->Draw("HIST");
} }
c2->Draw(); c2->Draw();
/*
TCanvas *c3 = new TCanvas("c3", "Canvas 3", 0, 0, 800, 600);
TCanvas *c3 = new TCanvas("c3", "Canvas 3", 0, 0, 1000, 700);
auto fittedPlots = CreateRooFit(h1_Bplus_M);
auto *p2 = new TPad("p2", "Pull", 0., 0., 1., 0.3);
p2->Draw();
p2->SetTopMargin(0.001);
p2->SetBottomMargin(0.3);
p2->SetGrid();
auto *p1 = new TPad("p1", "Fit", 0., 0.32, 1., 1.);
p1->Draw();
p1->SetBottomMargin(0.001);
p1->cd();
auto fitFrame = CreateRooFit(h1_Bplus_M);
fitFrame->Draw();
fittedPlots[0]->Draw();
p2->cd();
fittedPlots[1]->Draw();
c3->Draw(); c3->Draw();
*/
return 0; return 0;
} }
RooPlot *CreateRooFit(TH1D *hist)
std::vector<RooPlot*> CreateRooFit(TH1D *hist)
{ {
RooRealVar roo_var_mass("roo_var_mass", "B+ Mass Variable", 4500., 7500.);
roo_var_mass.setRange("fitting_range", 4700., 6500.);
RooRealVar roo_var_mass("roo_var_mass", "B+ Mass Variable", MASS_HIST_MIN, MASS_HIST_MAX);
roo_var_mass.setRange("fitting_range", 5100., 6000.);
TString hist_name = "roohist_bplus_M"; TString hist_name = "roohist_bplus_M";
RooDataHist roohist_bplus_M(hist_name, "B Plus Mass Histogram", roo_var_mass, RooFit::Import(*hist)); RooDataHist roohist_bplus_M(hist_name, "B Plus Mass Histogram", roo_var_mass, RooFit::Import(*hist));
RooRealVar roo_sig_gauss_mean("roo_sig_gauss_mean", "Mass Gauss Mean", 5250., 5100., 5400.);
RooRealVar roo_sig_gauss_sigma("roo_sig_gauss_sigma", "Mass Gauss Sigma", 60., 0., 150.);
RooRealVar roo_sig_bw_mean("roo_sig_bw_mean", "Mass BW Mean", 5250., 5100., 5400.);
RooRealVar roo_sig_bw_with("roo_sig_bw_with", "Mass BW Width", 20., 0., 50.);
RooGaussian roo_sig_gauss("roo_sig_gauss", "B+ Mass Signal Gaussian", roo_var_mass, roo_sig_gauss_mean, roo_sig_gauss_sigma);
RooBreitWigner roo_sig_bw("roo_sig_bw", "B+ Signal Breit Wigner", roo_var_mass, roo_sig_bw_mean, roo_sig_bw_with);
RooRealVar roo_bkg_exp_c("roo_bkg_exp_c", "Background C", -0.00117202, -0.003, -0.001);
RooRealVar roo_bkg_exp_c("roo_bkg_exp_c", "Background C", -0.001145, -0.00199, -0.00100);
RooExponential roo_bkg_exp("roo_bkg_exp", "B+ Mass Background Exp", roo_var_mass, roo_bkg_exp_c); RooExponential roo_bkg_exp("roo_bkg_exp", "B+ Mass Background Exp", roo_var_mass, roo_bkg_exp_c);
RooRealVar roo_var_mass_nsig("roo_var_mass_nsig", "B+ Mass N Signal", 0., hist->GetEntries()); RooRealVar roo_var_mass_nsig("roo_var_mass_nsig", "B+ Mass N Signal", 0., hist->GetEntries());
@ -269,7 +323,7 @@ RooPlot *CreateRooFit(TH1D *hist)
TString pdf_name = "roo_pdf_sig_plus_bkg"; TString pdf_name = "roo_pdf_sig_plus_bkg";
RooAddPdf roo_pdf_sig_plus_bkg(pdf_name, "Sig + Bkg PDF", RooAddPdf roo_pdf_sig_plus_bkg(pdf_name, "Sig + Bkg PDF",
RooArgList(roo_sig_gauss, roo_bkg_exp),
RooArgList(roo_sig_bw, roo_bkg_exp),
RooArgList(roo_var_mass_nsig, roo_var_mass_nbkg)); RooArgList(roo_var_mass_nsig, roo_var_mass_nbkg));
RooPlot *roo_frame_mass = roo_var_mass.frame(); RooPlot *roo_frame_mass = roo_var_mass.frame();
@ -281,8 +335,11 @@ RooPlot *CreateRooFit(TH1D *hist)
roo_pdf_sig_plus_bkg.plotOn(roo_frame_mass, RooFit::LineColor(kRed), RooFit::LineStyle(kSolid), RooFit::Range("fitting_range"), RooFit::Name(pdf_name)); roo_pdf_sig_plus_bkg.plotOn(roo_frame_mass, RooFit::LineColor(kRed), RooFit::LineStyle(kSolid), RooFit::Range("fitting_range"), RooFit::Name(pdf_name));
roo_pdf_sig_plus_bkg.plotOn(roo_frame_mass, RooFit::Components(RooArgSet(roo_bkg_exp)), RooFit::LineColor(kBlue), RooFit::LineStyle(kDashed), RooFit::Range("fitting_range")); roo_pdf_sig_plus_bkg.plotOn(roo_frame_mass, RooFit::Components(RooArgSet(roo_bkg_exp)), RooFit::LineColor(kBlue), RooFit::LineStyle(kDashed), RooFit::Range("fitting_range"));
roo_sig_gauss.paramOn(roo_frame_mass, RooFit::Layout(0.60, 0.99, 0.90));
roo_frame_mass->getAttText()->SetTextSize(0.027);
roo_pdf_sig_plus_bkg.paramOn(roo_frame_mass, RooFit::Layout(0.50, 0.99, 0.90));
roo_frame_mass->getAttText()->SetTextSize(0.025);
RooPlot *roo_frame_pull = roo_var_mass.frame(RooFit::Title("Pull Distribution"));
roo_frame_pull->addPlotable(roo_frame_mass->pullHist(hist_name, pdf_name), "P");
return roo_frame_mass;
return std::vector<RooPlot*> { roo_frame_mass, roo_frame_pull };
} }

236
status_report_plots.cpp

@ -0,0 +1,236 @@
#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 <string>
#include <iostream>
#include <cmath>
const int nBins = 70;
const Double_t MASS_HIST_MIN = 4000.;
const Double_t MASS_HIST_MAX = 8500.;
const Double_t MASS_HIST_FIT_MIN = 5100.;
const Double_t MASS_HIST_FIT_MAX = 6000.;
const Double_t J_PSI_MASS = 3096.916;
const std::string SAVE_PATH = "/work/pfeiffer/inclusive_detached_dilepton/status_report";
struct AnalysisOutput {
std::string title;
std::string name;
std::string root_file;
std::string root_file_tree;
std::string B_name;
std::string paper_yield;
const std::string suf(std::string input) {
return TString::Format("%s_%s", input.c_str(), name.c_str()).Data();
}
const std::string title_suf(std::string input) {
return TString::Format("%s [%s]", input.c_str(), title.c_str()).Data();
}
};
std::vector<RooPlot*> CreateRooFit(TH1D *hist, AnalysisOutput ana);
bool inRange(double value, double center, double low_intvl, double up_intvl) {
return center - low_intvl < value && value < center + up_intvl;
}
bool inRange(double value, double center, double intvl) {
return inRange(value, center, intvl, intvl);
}
void savePDF(TObject* o, const char* decay, const char* name, Option_t* opt = "") {
auto cname = TString::Format("%s_%s", decay, name);
std::cout << " ----- " << cname.Data() << " - " << decay << " - " << name << std::endl;
auto c = new TCanvas(cname.Data(), cname.Data(), 0, 0, 800, 800);
o->Draw(opt);
c->SaveAs(TString::Format("%s/%s.jpg", SAVE_PATH.c_str(), cname.Data()));
// c->Draw();
}
void savePDF(TObject* o1, TObject* o2, const char* decay, const char* name) {
auto cname = TString::Format("%s_%s", decay, name);
std::cout << " ----- " << cname.Data() << " - " << decay << " - " << name << std::endl;
auto c = new TCanvas(cname.Data(), cname.Data(), 0, 0, 800, 800);
auto p2 = new TPad(TString::Format("%s_p2", name), "Lower Pad", 0., 0., 1., 0.3);
p2->Draw();
p2->SetTopMargin(0.001);
p2->SetBottomMargin(0.3);
p2->SetGrid();
auto *p1 = new TPad(TString::Format("%s_p1", name), "Upper Pad", 0., 0.32, 1., 1.);
p1->Draw();
p1->SetBottomMargin(0.001);
p1->cd();
o1->Draw();
p2->cd();
o2->Draw();
c->SaveAs(TString::Format("%s/%s.jpg", SAVE_PATH.c_str(), cname.Data()));
}
RooHelpers::LocalChangeMsgLevel changeMsgLvl(RooFit::WARNING);
int status_report_plots()
{
// gROOT->ProcessLine(".x /work/pfeiffer/lhcbStyle.C");
std::vector<AnalysisOutput> anas {
// AnalysisOutput{"SpruceRD_BuToHpMuMu", "BuToKpMuMu_incl", "/auto/data/pfeiffer/inclusive_detached_dilepton/data_samples/BuToKpMuMu_Collision23_Beam6800GeV-VeloClosed-MagDown-Excl-UT_RealData_Sprucing23r1_90000000_RD.root", "SpruceRD_BuToKpMuMu/DecayTree", "Bplus", ""},
// AnalysisOutput{"BuToKpMuMu Inclusive, AnaProd NTuple", "BuToKpMuMu_incl_ap", "/auto/data/pfeiffer/inclusive_detached_dilepton/data_samples/spruce_magdown_2023_v0r1_tuple_90000000_2023_v0r0p6288631.root", "BuToHpMuMu/DecayTree", "B", "1395.27 +/- 58"},
// AnalysisOutput{"Hlt2RD_BuToKpMuMu_2023", "BuToKpMuMu_excl", "/auto/data/pfeiffer/inclusive_detached_dilepton/data_samples/BuToKpMuMu_Collision23_Beam6800GeV-VeloClosed-MagDown-Excl-UT_RealData_SprucingPass23r1_94000000_RD.root", "Hlt2RD_BuToKpMuMu_2023/DecayTree", "Bplus", "803.769 +/- 34" },
// AnalysisOutput{"Hlt2RD_", "BuToKpMuMu_excl_ap23", "/auto/data/pfeiffer/inclusive_detached_dilepton/data_samples/turbopass_magdown_2023_v1_tuple_94000000_2023_v0r0p6201764.root", "BuToKpMuMu23/DecayTree", "B", "803.769 +/- 34"},
// AnalysisOutput{"SpruceRD_B0ToHpHmMuMu", "B0ToKpPimMuMu_incl", "/auto/data/pfeiffer/inclusive_detached_dilepton/data_samples/B0ToKpPimMuMu_Collision23_Beam6800GeV-VeloClosed-MagDown-Excl-UT_RealData_Sprucing23r1_90000000_RD.root", "SpruceRD_B0ToKpPimMuMu/DecayTree", "B0", "" },
// AnalysisOutput{"B0ToKpPimMuMu_ap", "/auto/data/pfeiffer/inclusive_detached_dilepton/data_samples/spruce_magdown_2023_v0r1_tuple_90000000_2023_v0r0p6288631.root", "B0ToHpHmMuMu/DecayTree", "B0", ""},
AnalysisOutput{"Hlt2RD_B0ToKpPimMuMu_2023", "B0ToKpPimMuMu_excl", "/auto/data/pfeiffer/inclusive_detached_dilepton/data_samples/B0ToKpPimMuMu_Collision23_Beam6800GeV-VeloClosed-MagDown-Excl-UT_RealData_SprucingPass23r1_94000000_RD.root", "Hlt2RD_B0ToKpPimMuMu_2023/DecayTree", "B0", "" },
AnalysisOutput{"Hlt2RD_B0ToKpPimMuMu_2023 AP", "B0ToKpPimMuMu_excl_ap23", "/auto/data/pfeiffer/inclusive_detached_dilepton/data_samples/turbopass_magdown_2023_v1_tuple_94000000_2023_v0r0p6201764.root", "B0ToKpPimMuMu23/DecayTree", "B0", ""},
// AnalysisOutput{"BuToJpsiKplus_det", "/auto/data/pfeiffer/inclusive_detached_dilepton/data_samples/BuToJpsiKplus_Detached_Collision23_Beam6800GeV-VeloClosed-MagDown-Excl-UT_RealData_SprucingPass23r1_94000000_B2CC.root", "Hlt2B2CC_BuToJpsiKplus_JpsiToMuMu_Detached/DecayTree", "Bplus", "unknown" },
};
for (size_t a = 0; a < anas.size(); a++)
{
auto ana = anas[a];
TChain *data_chain = new TChain(ana.root_file_tree.c_str());
data_chain->Add(ana.root_file.c_str());
Double_t B_M, // 4400 -> 8200
Jpsi_M; // 200 -> 6600
Float_t muplus_PX, // 0 -> 30 * 10^3
muplus_PY, // 0 -> 7000
muplus_PZ, // 0 -> 3
muplus_ENERGY, // 0 -> 26 * 10^3
muminus_PX, // 0 -> 7
muminus_PY, // 0 -> 11 * 10^3
muminus_PZ, // 0 -> 7
muminus_ENERGY; // 0 -> 11 * 10^3
data_chain->SetBranchAddress(TString::Format("%s_M", ana.B_name.c_str()).Data(), &B_M);
data_chain->SetBranchAddress("Jpsi_M", &Jpsi_M);
// data_chain->SetBranchAddress("muplus_PX", &muplus_PX);
// data_chain->SetBranchAddress("muplus_PY", &muplus_PY);
// data_chain->SetBranchAddress("muplus_PZ", &muplus_PZ);
// data_chain->SetBranchAddress("muplus_ENERGY", &muplus_ENERGY);
// data_chain->SetBranchAddress("muminus_PX", &muminus_PX);
// data_chain->SetBranchAddress("muminus_PY", &muminus_PY);
// data_chain->SetBranchAddress("muminus_PZ", &muminus_PZ);
// data_chain->SetBranchAddress("muminus_ENERGY", &muminus_ENERGY);
TH1D *h1_B_M = new TH1D(ana.suf("h1_B_M").c_str(), ana.title_suf("B Mass").c_str(), nBins, MASS_HIST_MIN, MASS_HIST_MAX);
TH1D *h1_B_M_JPsi_cut = new TH1D(ana.suf("h1_B_M_JPsi_cut").c_str(), ana.title_suf("B Mass").c_str(), nBins, MASS_HIST_FIT_MIN, MASS_HIST_FIT_MAX);
TH1D *h1_Jpsi_M = new TH1D(ana.suf("h1_Jpsi_M").c_str(), ana.title_suf("J/#psi Mass").c_str(), nBins, 200., 5500.);
TH2D *h2_B_M_Jpsi_M = new TH2D(ana.suf("h2_B_M_Jpsi_M").c_str(), ana.title_suf("B Mass vs. J/#psi Mass").c_str(), nBins, MASS_HIST_MIN, MASS_HIST_MAX, nBins, 200., 5500.);
unsigned int entries = data_chain->GetEntries();
for (unsigned int i = 0; i < entries; i++)
{
if (i % 10000 == 0)
{
std::cout << "[" << ana.name << "] Processing event: " << i << " (" << TString::Format("%.2f", ((double)i / (double)entries) * 100.) << "%)" << std::endl;
}
// TLorentzVector v4_muplus(muplus_PX, muplus_PY, muplus_PZ, muplus_ENERGY);
// TLorentzVector v4_muminus(muminus_PX, muminus_PY, muminus_PZ, muminus_ENERGY);
// Double_t mumu_inv_mass = (v4_muplus + v4_muminus).M();
data_chain->GetEntry(i);
h1_B_M->Fill(B_M);
h1_Jpsi_M->Fill(Jpsi_M);
h2_B_M_Jpsi_M->Fill(B_M, Jpsi_M);
// std::cout << mumu_inv_mass << "-" << Jpsi_M << "=" << TMath::Abs(mumu_inv_mass-Jpsi_M) << std::endl;
if (TMath::Abs(Jpsi_M - J_PSI_MASS) < 100.)
{
h1_B_M_JPsi_cut->Fill(B_M);
}
}
h1_B_M->SetMinimum(0);
h1_B_M_JPsi_cut->SetMinimum(0);
h1_Jpsi_M->SetMinimum(0);
h2_B_M_Jpsi_M->SetMinimum(0);
auto fitRes = CreateRooFit(h1_B_M_JPsi_cut, ana);
savePDF(h1_B_M, ana.name.c_str(), "B_M_uncut");
savePDF(h1_Jpsi_M, ana.name.c_str(), "JPsi_M_uncut");
savePDF(h1_B_M_JPsi_cut, ana.name.c_str(), "B_M_JPsi_cut");
savePDF(fitRes[0], fitRes[1], ana.name.c_str(), "B_mass_JPsi_cut_fit");
}
return 0;
}
std::vector<RooPlot*> CreateRooFit(TH1D *hist, AnalysisOutput ana)
{
RooRealVar roo_var_mass(ana.suf("roo_var_mass").c_str(), "B Mass Variable", MASS_HIST_FIT_MIN, MASS_HIST_FIT_MAX);
roo_var_mass.setRange("fitting_range", MASS_HIST_FIT_MIN, MASS_HIST_FIT_MAX);
std::string hist_name = ana.suf("roohist_B_M");
RooDataHist roohist_B_M(hist_name.c_str(), "B Mass Histogram", roo_var_mass, RooFit::Import(*hist));
RooRealVar roo_sig_bw_mean(ana.suf("roo_sig_bw_mean").c_str(), "Mass BW Mean", 5250., 5100., 5400.);
RooRealVar roo_sig_bw_with(ana.suf("roo_sig_bw_with").c_str(), "Mass BW Width", 20., 0., 50.);
RooBreitWigner roo_sig_bw(ana.suf("roo_sig_bw").c_str(), "B Signal Breit Wigner", roo_var_mass, roo_sig_bw_mean, roo_sig_bw_with);
RooRealVar roo_bkg_exp_c(ana.suf("roo_bkg_exp_c").c_str(), "Background C", -0.001145, -0.00199, -0.00100);
RooExponential roo_bkg_exp(ana.suf("roo_bkg_exp").c_str(), "B Mass Background Exp", roo_var_mass, roo_bkg_exp_c);
RooRealVar roo_var_mass_sig_yield(ana.suf("roo_var_mass_sig_yield").c_str(), "B Mass Sig Yield", 0., hist->GetEntries());
RooRealVar roo_var_mass_bkg_yield(ana.suf("roo_var_mass_bkg_yield").c_str(), "B Mass Bckg Yield", 0., hist->GetEntries());
std::string pdf_name = ana.suf("roo_pdf_sig_plus_bkg");
RooAddPdf roo_pdf_sig_plus_bkg(pdf_name.c_str(), "Sig + Bkg PDF",
RooArgList(roo_sig_bw, roo_bkg_exp),
RooArgList(roo_var_mass_sig_yield, roo_var_mass_bkg_yield));
RooPlot *roo_frame_mass = roo_var_mass.frame(RooFit::Title(TString::Format("%s [%s]", ana.name.c_str(), ana.title.c_str()).Data()));
roohist_B_M.plotOn(roo_frame_mass, RooFit::Binning(nBins), RooFit::Name(hist_name.c_str()));
RooFitResult *fitres = roo_pdf_sig_plus_bkg.fitTo(roohist_B_M, RooFit::Save(), RooFit::PrintLevel(1), RooFit::Range("fitting_range"));
roo_pdf_sig_plus_bkg.plotOn(roo_frame_mass, RooFit::LineColor(kRed), RooFit::LineStyle(kSolid), RooFit::Range("fitting_range"), RooFit::Name(pdf_name.c_str()));
roo_pdf_sig_plus_bkg.plotOn(roo_frame_mass, RooFit::Components(RooArgSet(roo_bkg_exp)), RooFit::LineColor(kBlue), RooFit::LineStyle(kDashed), RooFit::Range("fitting_range"));
roo_pdf_sig_plus_bkg.plotOn(roo_frame_mass, RooFit::Components(RooArgSet(roo_sig_bw)), RooFit::FillStyle(3244), RooFit::LineColor(kRed-7), RooFit::LineStyle(kDashed), RooFit::Range("fitting_range"));
roo_pdf_sig_plus_bkg.paramOn(roo_frame_mass, RooFit::Layout(0.40, 0.99, 0.90));
roo_frame_mass->getAttText()->SetTextSize(0.024);
RooPlot *roo_frame_pull = roo_var_mass.frame(RooFit::Title("Pull Distribution"));
roo_frame_pull->addPlotable(roo_frame_mass->pullHist(hist_name.c_str(), pdf_name.c_str()), "P");
return std::vector<RooPlot*> { roo_frame_mass, roo_frame_pull };
}

105
subs_mass.cpp

@ -0,0 +1,105 @@
#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 <string>
#include <iostream>
#include <cmath>
const int nBins = 70;
const Double_t MASS_HIST_MIN = 4000.;
const Double_t MASS_HIST_MAX = 8500.;
const Double_t J_PSI_MASS = 3096.916;
const Double_t K_MASS = 493.677;
std::vector<RooPlot*> CreateRooFit(TH1D *hist);
bool inRange(double value, double center, double low_intvl, double up_intvl) {
return center - low_intvl < value && value < center + up_intvl;
}
bool inRange(double value, double center, double intvl) {
return inRange(value, center, intvl, intvl);
}
int subs_mass()
{
// files to load
std::vector<std::string> data_filenames =
{
"/auto/data/pfeiffer/inclusive_detached_dilepton/data_samples/spruce_magdown_2023_v0r1_tuple_90000000_2023_v0r0p6288631.root"};
TChain *data_chain = new TChain("BuToHpMuMu/DecayTree");
for (unsigned int i = 0; i < data_filenames.size(); i++)
{
data_chain->Add(data_filenames.at(i).c_str());
}
Double_t Jpsi_M, L1_M, L2_M, Hp_M;
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;
data_chain->SetBranchAddress("Jpsi_M", &Jpsi_M);
data_chain->SetBranchAddress("L1_M", &L1_M);
data_chain->SetBranchAddress("L2_M", &L2_M);
data_chain->SetBranchAddress("Hp_M", &Hp_M);
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);
unsigned int entries = data_chain->GetEntries();
TH1D *h1_B_M = new TH1D("h1_B_M", "m(#pi_{K} #mu^{+} #mu^{-})", nBins, MASS_HIST_MIN, MASS_HIST_MAX);
for (unsigned int i = 0; i < entries; i++)
{
data_chain->GetEntry(i);
TVector3 K_momentum(Hp_PX, Hp_PY, Hp_PZ);
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);
Double_t reconstructed_B_Mass = (K_4v + l1_4v + l2_4v).M();
h1_B_M->Fill(reconstructed_B_Mass);
}
TCanvas* c1 = new TCanvas("c1", "c1", 0, 0, 900, 850);
h1_B_M->Draw();
c1->Draw();
c1->SaveAs("BuToKpMuMu_incl_ap_B_M_uncut_subid.jpg");
return 0;
}

66
train_bdt.cpp

@ -26,6 +26,7 @@
#include "RooFitResult.h" #include "RooFitResult.h"
#include "RooProduct.h" #include "RooProduct.h"
#include "RooCrystalBall.h" #include "RooCrystalBall.h"
#include "RooBreitWigner.h"
#include <string> #include <string>
#include <iostream> #include <iostream>
@ -34,11 +35,14 @@
const bool TRAIN_TMVA = false; const bool TRAIN_TMVA = false;
const bool EVALUATE_TMVA = true; const bool EVALUATE_TMVA = true;
const int N_BINS = 130;
const int N_BINS = 100;
const double B_PLUS_MASS = 5279.; const double B_PLUS_MASS = 5279.;
const double J_PSI_MASS = 3096.; const double J_PSI_MASS = 3096.;
const Double_t MASS_HIST_MIN = 5100.;
const Double_t MASS_HIST_MAX = 6000.;
RooPlot *CreateRooFit(TH1D *hist); RooPlot *CreateRooFit(TH1D *hist);
bool inRange(double value, double center, double low_intvl, double up_intvl) { bool inRange(double value, double center, double low_intvl, double up_intvl) {
@ -274,7 +278,7 @@ int train_bdt()
TV::Float("Bplus_BPVFDCHI2", "B_BPVFDCHI2"), TV::Float("Bplus_BPVFDCHI2", "B_BPVFDCHI2"),
TV::Float("Bplus_BPVDIRA", "B_BPVDIRA"), TV::Float("Bplus_BPVDIRA", "B_BPVDIRA"),
TV::Float("Jpsi_BPVIPCHI2", "Jpsi_BPVIPCHI2"), TV::Float("Jpsi_BPVIPCHI2", "Jpsi_BPVIPCHI2"),
TV::Float("Jpsi_BPVDIRA", "Jpsi_BPVDIRA"),
// TV::Float("Jpsi_BPVDIRA", "Jpsi_BPVDIRA"),
TV::Float("Jpsi_PT", "Jpsi_PT"), TV::Float("Jpsi_PT", "Jpsi_PT"),
TV::Float("Kplus_BPVIPCHI2", "K_BPVIPCHI2"), TV::Float("Kplus_BPVIPCHI2", "K_BPVIPCHI2"),
TV::Float("Kplus_PT", "K_PT"), TV::Float("Kplus_PT", "K_PT"),
@ -446,7 +450,7 @@ int train_bdt()
reader->BookMVA("BDT", "./dataloader/weights/tmva_butokpmumu_BDT.weights.xml"); reader->BookMVA("BDT", "./dataloader/weights/tmva_butokpmumu_BDT.weights.xml");
TH1D *h1_probs = new TH1D("h1_probs", "BDT Probabilities", N_BINS, -1, 1); TH1D *h1_probs = new TH1D("h1_probs", "BDT Probabilities", N_BINS, -1, 1);
TH1D *h1_Bplus_M = new TH1D("h1_Bplus_M", "B^{+} Mass", N_BINS, 4700., 6500.);
TH1D *h1_Bplus_M = new TH1D("h1_Bplus_M", "B^{+} Mass", N_BINS, MASS_HIST_MIN, MASS_HIST_MAX);
for (unsigned int i = 0; i < data_entries; i++) for (unsigned int i = 0; i < data_entries; i++)
{ {
@ -479,7 +483,7 @@ int train_bdt()
double mva_response = reader->EvaluateMVA("BDT"); double mva_response = reader->EvaluateMVA("BDT");
h1_probs->Fill(mva_response); h1_probs->Fill(mva_response);
const double mva_cut_value = 0.09; // -0.02;
const double mva_cut_value = 0; // 0.09; // -0.02;
if (mva_response > mva_cut_value) if (mva_response > mva_cut_value)
{ {
@ -515,44 +519,17 @@ int train_bdt()
RooPlot *CreateRooFit(TH1D *hist) RooPlot *CreateRooFit(TH1D *hist)
{ {
RooRealVar roo_var_mass("roo_var_mass", "B+ Mass Variable", 4700., 6500.);
roo_var_mass.setRange("fitting_range", 4800., 5800.);
roo_var_mass.setRange("plot_range", 4700., 6500.);
RooRealVar roo_var_mass("roo_var_mass", "B+ Mass Variable", MASS_HIST_MIN, MASS_HIST_MAX);
roo_var_mass.setRange("fitting_range", MASS_HIST_MIN, MASS_HIST_MAX);
roo_var_mass.setRange("plot_range", MASS_HIST_MIN, MASS_HIST_MAX);
TString hist_name = "roohist_bplus_M"; TString hist_name = "roohist_bplus_M";
RooDataHist roohist_bplus_M(hist_name, "B Plus Mass Histogram", roo_var_mass, RooFit::Import(*hist)); RooDataHist roohist_bplus_M(hist_name, "B Plus Mass Histogram", roo_var_mass, RooFit::Import(*hist));
RooRealVar roo_sig_gauss_mean("roo_sig_gauss_mean", "Mass Gauss Mean", 5250., 5100., 5400.);
RooRealVar roo_sig_gauss_sigma("roo_sig_gauss_sigma", "Mass Gauss Sigma", 30., 20., 40.);
RooGaussian roo_sig_gauss("roo_sig_gauss", "B+ Mass Signal Gaussian", roo_var_mass, roo_sig_gauss_mean, roo_sig_gauss_sigma);
// Crystal Ball for Signal
// RooRealVar roo_sig_cb_x0("roo_sig_cry_x0", "Location", B_PLUS_MASS, 5100., 5400.);
// RooRealVar roo_sig_cb_sigmaL("roo_sig_cry_sigmaL", "Sigma L", 30., 0., 60.);
// RooRealVar roo_sig_cb_sigmaR("roo_sig_cry_sigmaR", "Sigma R", 30., 0., 60.);
// RooRealVar roo_sig_cb_alphaL("roo_sig_cry_alphaL", "Alpha L", 15., 0., 30.);
// RooRealVar roo_sig_cb_nL("roo_sig_cry_nL", "Exponent L", 0., -40., 40.);
// RooRealVar roo_sig_cb_alphaR("roo_sig_cry_alphaR", "Alpha R", 15., 0., 30.);
// RooRealVar roo_sig_cb_nR("roo_sig_cry_nR", "Exponent R", 0., -40., 40.);
// RooCrystalBall roo_sig_cb("roo_sig_cb", "Signal Crystal Ball", roo_var_mass, roo_sig_cb_x0, roo_sig_cb_sigmaL, roo_sig_cb_sigmaR, roo_sig_cb_alphaL, roo_sig_cb_nL, roo_sig_cb_alphaR, roo_sig_cb_nR);
RooRealVar roo_sig_bw_mean("roo_sig_bw_mean", "Mass BW Mean", 5250., 5100., 5400.);
RooRealVar roo_sig_bw_with("roo_sig_bw_with", "Mass BW Width", 20., 0., 50.);
// Double Gauss Signal
// RooRealVar roo_sig_gauss1_mean("roo_sig_gauss1_mean", "Mass Gauss 1 Mean", 5250., 5200., 5300.);
// RooRealVar roo_sig_gauss1_sigma("roo_sig_gauss1_sigma", "Mass Gauss 1 Sigma", 60., 0., 150.);
// RooGaussian roo_sig_gauss1("roo_sig_gauss1", "B+ Mass Signal 1 Gaussian", roo_var_mass, roo_sig_gauss1_mean, roo_sig_gauss1_sigma);
// RooRealVar roo_sig_gauss2_mean("roo_sig_gauss2_mean", "Mass Gauss 2 Mean", 5250., 5200., 5300.);
// RooRealVar roo_sig_gauss2_sigma("roo_sig_gauss2_sigma", "Mass Gauss 2 Sigma", 60., 0., 150.);
// RooGaussian roo_sig_gauss2("roo_sig_gauss2", "B+ Mass Signal 2 Gaussian", roo_var_mass, roo_sig_gauss2_mean, roo_sig_gauss2_sigma);
// RooRealVar roo_sig_double_gauss_frac("roo_sig_double_gauss_frac", "B+ Mass Signal Double Gauss Frac", 0.5);
// RooAddPdf roo_sig_double_gauss("roo_sig_double_gauss", "B+ Mass Signal Double Gauss", roo_sig_gauss1, roo_sig_gauss2, roo_sig_double_gauss_frac);
RooBreitWigner roo_sig_bw("roo_sig_bw", "B+ Signal Breit Wigner", roo_var_mass, roo_sig_bw_mean, roo_sig_bw_with);
RooRealVar roo_bkg_exp_c("roo_bkg_exp_c", "Background C", -0.000693147, -0.002, 0.); RooRealVar roo_bkg_exp_c("roo_bkg_exp_c", "Background C", -0.000693147, -0.002, 0.);
RooExponential roo_bkg_exp("roo_bkg_exp", "B+ Mass Background Exp", roo_var_mass, roo_bkg_exp_c); RooExponential roo_bkg_exp("roo_bkg_exp", "B+ Mass Background Exp", roo_var_mass, roo_bkg_exp_c);
@ -562,7 +539,7 @@ RooPlot *CreateRooFit(TH1D *hist)
TString pdf_name = "roo_pdf_sig_plus_bkg"; TString pdf_name = "roo_pdf_sig_plus_bkg";
RooAddPdf roo_pdf_sig_plus_bkg(pdf_name, "Sig + Bkg PDF", RooAddPdf roo_pdf_sig_plus_bkg(pdf_name, "Sig + Bkg PDF",
RooArgList(roo_sig_gauss, roo_bkg_exp),
RooArgList(roo_sig_bw, roo_bkg_exp),
RooArgList(roo_var_mass_nsig, roo_var_mass_nbkg)); RooArgList(roo_var_mass_nsig, roo_var_mass_nbkg));
RooPlot *roo_frame_mass = roo_var_mass.frame(); RooPlot *roo_frame_mass = roo_var_mass.frame();
@ -577,19 +554,8 @@ RooPlot *CreateRooFit(TH1D *hist)
// roo_sig_cb.plotOn(roo_frame_mass, RooFit::LineColor(kAlpine), RooFit::LineStyle(kDashed), RooFit::Range("fitting_range")); // roo_sig_cb.plotOn(roo_frame_mass, RooFit::LineColor(kAlpine), RooFit::LineStyle(kDashed), RooFit::Range("fitting_range"));
// roo_bkg_exp.plotOn(roo_frame_mass, RooFit::LineColor(kOrange), RooFit::LineStyle(kDashed), RooFit::Range("fitting_range")); // roo_bkg_exp.plotOn(roo_frame_mass, RooFit::LineColor(kOrange), RooFit::LineStyle(kDashed), RooFit::Range("fitting_range"));
roo_sig_gauss.paramOn(roo_frame_mass, RooFit::Layout(0.60, 0.99, 0.90));
roo_pdf_sig_plus_bkg.paramOn(roo_frame_mass, RooFit::Layout(0.50, 0.99, 0.90));
roo_frame_mass->getAttText()->SetTextSize(0.027); roo_frame_mass->getAttText()->SetTextSize(0.027);
double ymax = roo_frame_mass->GetMaximum();
TText *txt_n_sig = new TText(5800., ymax * 0.22, TString::Format("Signal Yield: %.2f +/- %.2f (Paper: %s)", roo_var_mass_nsig.getVal(), roo_var_mass_nsig.getError(), ""));
txt_n_sig->SetTextSize(0.027);
txt_n_sig->SetTextColor(kBlue + 4);
TText *txt_n_bkg = new TText(5800., ymax * 0.18, TString::Format("Background Yield: %.2f +/- %.2f", roo_var_mass_nbkg.getVal(), roo_var_mass_nbkg.getError()));
txt_n_bkg->SetTextSize(0.027);
txt_n_bkg->SetTextColor(kBlue + 4);
roo_frame_mass->addObject(txt_n_sig);
roo_frame_mass->addObject(txt_n_bkg);
return roo_frame_mass; return roo_frame_mass;
} }
Loading…
Cancel
Save