283 lines
7.0 KiB
C++
283 lines
7.0 KiB
C++
#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 <string>
|
|
#include <iostream>
|
|
|
|
const int nBins = 200;
|
|
|
|
template <typename TVar>
|
|
class DrawVar
|
|
{
|
|
private:
|
|
std::string _identifier;
|
|
TVar _min;
|
|
TVar _max;
|
|
TVar _value = TVar{};
|
|
TVar _cutAt = 0;
|
|
bool _applyCut = false;
|
|
TH1 *_histogram = nullptr;
|
|
TH1 *_bkgHistogram = nullptr;
|
|
|
|
public:
|
|
DrawVar(std::string identifier, TVar min, TVar max)
|
|
: _identifier{identifier}, _min{min}, _max{max}
|
|
{
|
|
}
|
|
|
|
DrawVar(std::string identifier, TVar min, TVar max, TVar cutAt)
|
|
: DrawVar(identifier, min, max)
|
|
{
|
|
_cutAt = cutAt;
|
|
_applyCut = true;
|
|
}
|
|
|
|
std::string getId()
|
|
{
|
|
return _identifier;
|
|
}
|
|
|
|
const char *getIdStr()
|
|
{
|
|
return _identifier.c_str();
|
|
}
|
|
|
|
TVar getMin()
|
|
{
|
|
return _min;
|
|
}
|
|
|
|
TVar getMax()
|
|
{
|
|
return _max;
|
|
}
|
|
|
|
TVar *getValuePointer()
|
|
{
|
|
return &_value;
|
|
}
|
|
|
|
TVar getValue()
|
|
{
|
|
return _value;
|
|
}
|
|
|
|
bool cutAccepted()
|
|
{
|
|
if (!_applyCut)
|
|
{
|
|
return true;
|
|
}
|
|
return _value > _cutAt;
|
|
}
|
|
|
|
void initHistograms()
|
|
{
|
|
_histogram = new TH1D(TString::Format("h1_%s", this->getIdStr()).Data(), this->getIdStr(), nBins, _min, _max);
|
|
_bkgHistogram = new TH1D(TString::Format("h1_bkg_%s", this->getIdStr()).Data(), this->getIdStr(), nBins, _min, _max);
|
|
_bkgHistogram->SetLineColor(kRed);
|
|
}
|
|
|
|
TH1 *getHist()
|
|
{
|
|
return _histogram;
|
|
}
|
|
|
|
TH1 *getBkgHist()
|
|
{
|
|
return _bkgHistogram;
|
|
}
|
|
};
|
|
|
|
int general_cuts()
|
|
{
|
|
// just some plotting options
|
|
gROOT->SetStyle("Plain");
|
|
TPad foo;
|
|
const int NRGBs = 5;
|
|
const int NCont = 250;
|
|
double stops[NRGBs] = {0.00, 0.34, 0.61, 0.84, 1.00};
|
|
double red[NRGBs] = {0.00, 0.00, 0.87, 1.00, 0.51};
|
|
double green[NRGBs] = {0.00, 0.81, 1.00, 0.20, 0.00};
|
|
double blue[NRGBs] = {0.51, 1.00, 0.12, 0.00, 0.00};
|
|
TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
|
|
gStyle->SetNumberContours(NCont);
|
|
gStyle->SetLabelFont(132, "xyz");
|
|
gStyle->SetTitleFont(132, "xyz");
|
|
gStyle->SetLegendFont(132);
|
|
gStyle->SetStatFont(132);
|
|
gStyle->SetEndErrorSize(10.0);
|
|
gStyle->SetOptStat(0);
|
|
gStyle->SetOptFit(0);
|
|
|
|
// Selectoin
|
|
// Pre-Selection Cut-Based
|
|
// IP Tochter, PT Tochter, FDCHI2 B, PT B
|
|
// PID isMuon, PID K
|
|
|
|
std::vector<DrawVar<Float_t>> float_vars{
|
|
DrawVar<Float_t>("B0_PT", 0., 7000.),
|
|
DrawVar<Float_t>("B0_FDCHI2_OWNPV", 0., 500., 15.),
|
|
DrawVar<Float_t>("JPsi_PT", 0., 6000.),
|
|
DrawVar<Float_t>("JPsi_IP_OWNPV", 0., 2., 0.15),
|
|
DrawVar<Float_t>("Kstar0_PT", 0., 3500.),
|
|
DrawVar<Float_t>("Kstar0_IP_OWNPV", 0., 3., 0.15),
|
|
DrawVar<Float_t>("Kplus_PT", 0., 2000., 400.),
|
|
DrawVar<Float_t>("Kplus_IP_OWNPV", 0., 3., 0.15),
|
|
DrawVar<Float_t>("piminus_PT", 0., 2000., 200.),
|
|
DrawVar<Float_t>("piminus_IP_OWNPV", 0., 3., 0.15)};
|
|
std::vector<DrawVar<Double_t>> double_vars{
|
|
DrawVar<Double_t>("JPsi_M", 400., 5000.)
|
|
};
|
|
|
|
// files to load
|
|
std::vector<std::string> filenames =
|
|
{
|
|
"./B0ToKpPimMuMu_Collision23_Beam6800GeV-VeloClosed-MagDown-Excl-UT_RealData_Sprucing23r1_90000000_RD.root"};
|
|
|
|
TChain *chain = new TChain("SpruceRD_B0ToKpPimMuMu/DecayTree");
|
|
for (unsigned int i = 0; i < filenames.size(); i++)
|
|
{
|
|
chain->Add(filenames.at(i).c_str());
|
|
}
|
|
|
|
Double_t B0_M;
|
|
chain->SetBranchAddress("B0_M", &B0_M);
|
|
TH1D *h1_B0_M = new TH1D("h1_B0_M", "B+ Mass", nBins, 4500, 7500);
|
|
TH1D *h1_bkg_B0_M = new TH1D("h1_bkg_B0_M", "B+ Mass Bkg", nBins, 4500, 7500);
|
|
|
|
for (size_t i = 0; i < float_vars.size(); i++)
|
|
{
|
|
chain->SetBranchAddress(float_vars[i].getIdStr(), float_vars[i].getValuePointer());
|
|
float_vars[i].initHistograms();
|
|
}
|
|
|
|
for (size_t i = 0; i < double_vars.size(); i++)
|
|
{
|
|
chain->SetBranchAddress(double_vars[i].getIdStr(), double_vars[i].getValuePointer());
|
|
double_vars[i].initHistograms();
|
|
}
|
|
|
|
unsigned int entries = chain->GetEntries();
|
|
// loop over all entries in the tree
|
|
for (unsigned int i = 0; i < entries; i++)
|
|
{
|
|
chain->GetEntry(i);
|
|
|
|
bool cutAccepted = true;
|
|
for (size_t i = 0; i < float_vars.size(); i++)
|
|
{
|
|
cutAccepted = cutAccepted && float_vars[i].cutAccepted();
|
|
}
|
|
|
|
for (size_t i = 0; i < double_vars.size(); i++)
|
|
{
|
|
cutAccepted = cutAccepted && double_vars[i].cutAccepted();
|
|
}
|
|
|
|
if (cutAccepted)
|
|
{
|
|
h1_B0_M->Fill(B0_M);
|
|
}
|
|
else
|
|
{
|
|
h1_bkg_B0_M->Fill(B0_M);
|
|
}
|
|
|
|
if (B0_M > 5500.)
|
|
{
|
|
for (size_t i = 0; i < float_vars.size(); i++)
|
|
{
|
|
float_vars[i].getBkgHist()->Fill(float_vars[i].getValue());
|
|
}
|
|
|
|
for (size_t i = 0; i < double_vars.size(); i++)
|
|
{
|
|
double_vars[i].getBkgHist()->Fill(double_vars[i].getValue());
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (size_t i = 0; i < float_vars.size(); i++)
|
|
{
|
|
float_vars[i].getHist()->Fill(float_vars[i].getValue());
|
|
}
|
|
|
|
for (size_t i = 0; i < double_vars.size(); i++)
|
|
{
|
|
double_vars[i].getHist()->Fill(double_vars[i].getValue());
|
|
}
|
|
}
|
|
}
|
|
|
|
TCanvas *c1 = new TCanvas("c1", "Canvas 1", 0, 0, 800, 600);
|
|
|
|
h1_bkg_B0_M->SetLineColor(kRed);
|
|
if (h1_bkg_B0_M->GetMaximum() >= h1_B0_M->GetMaximum())
|
|
{
|
|
h1_bkg_B0_M->Draw();
|
|
h1_B0_M->Draw("SAME");
|
|
}
|
|
else
|
|
{
|
|
h1_B0_M->Draw();
|
|
h1_bkg_B0_M->Draw("SAME");
|
|
}
|
|
|
|
c1->Draw();
|
|
|
|
if (float_vars.size() > 0)
|
|
{
|
|
TCanvas *c2 = new TCanvas("c2", "Canvas 2", 0, 0, 1200, 600);
|
|
c2->Divide(4, 3);
|
|
|
|
for (size_t i = 0; i < float_vars.size(); i++)
|
|
{
|
|
c2->cd(i + 1);
|
|
float_vars[i].getHist()->Draw();
|
|
float_vars[i].getBkgHist()->Draw("SAME");
|
|
}
|
|
|
|
c2->Draw();
|
|
}
|
|
|
|
if (double_vars.size() > 0)
|
|
{
|
|
TCanvas *c3 = new TCanvas("c3", "Canvas 3", 0, 0, 1200, 600);
|
|
c3->Divide(4, 3);
|
|
|
|
for (size_t i = 0; i < double_vars.size(); i++)
|
|
{
|
|
c3->cd(i + 1);
|
|
double_vars[i].getHist()->Draw();
|
|
double_vars[i].getBkgHist()->Draw("SAME");
|
|
}
|
|
|
|
c3->Draw();
|
|
}
|
|
|
|
return 0;
|
|
} |