#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 #include #include const int nBins = 70; const Double_t MASS_HIST_FIT_MIN = 5100.; const Double_t MASS_HIST_FIT_MAX = 6000.; const char *B0_DECAY = "Hlt2RD_B0ToKpPimMuMu"; const char *Bu_DECAY = "Hlt2RD_BuToKpMuMu"; const char *TITLE = B0_DECAY; const char *X_AXIS = "m(K^{+}#pi^{-}#mu^{+}#mu^{-})"; void CreateRooFitAndDraw(TH1D *hist, int fitting_entries); int analysis_turbo() { TChain *data_chain = new TChain(TString::Format("%s/DecayTree", TITLE).Data()); data_chain->Add("/auto/data/pfeiffer/inclusive_detached_dilepton/data_samples/Collision23_Beam6800GeV-VeloClosed-MagDown-Excl-UT_RealData_SprucingPass23r1_94000000_RD.root"); Double_t B_M, Jpsi_M, B0_M, Kst_M; Bool_t Hlt1TrackMVADecision, Hlt1TwoTrackMVADecision; if (TITLE == B0_DECAY) { data_chain->SetBranchAddress("B0_M", &B0_M); data_chain->SetBranchAddress("Jpsi_M", &Jpsi_M); data_chain->SetBranchAddress("Kst0_M", &Kst_M); data_chain->SetBranchAddress("Hlt1TrackMVADecision", &Hlt1TrackMVADecision); data_chain->SetBranchAddress("Hlt1TwoTrackMVADecision", &Hlt1TwoTrackMVADecision); } else { data_chain->SetBranchAddress("B_M", &B_M); data_chain->SetBranchAddress("Jpsi_M", &Jpsi_M); data_chain->SetBranchAddress("Hlt1TrackMVADecision", &Hlt1TrackMVADecision); data_chain->SetBranchAddress("Hlt1TwoTrackMVADecision", &Hlt1TwoTrackMVADecision); } TH1D *h1_B_M = new TH1D("h1_B_M", TITLE, nBins, MASS_HIST_FIT_MIN, MASS_HIST_FIT_MAX); h1_B_M->GetXaxis()->SetTitle(X_AXIS); int fitting_entries = 0; unsigned int entries = data_chain->GetEntries(); for (unsigned int i = 0; i < entries; i++) { data_chain->GetEntry(i); if (TITLE == B0_DECAY) { if ((TMath::Abs(Jpsi_M - 3096.9) < 100) && (B0_M > 4500) && (B0_M < 6000) && (TMath::Abs(Kst_M - 895.55) < 50) && ((Hlt1TrackMVADecision) || (Hlt1TwoTrackMVADecision))) { h1_B_M->Fill(B0_M); if (MASS_HIST_FIT_MIN <= B0_M && B0_M <= MASS_HIST_FIT_MAX) { fitting_entries++; } } } else { if ((TMath::Abs(Jpsi_M - 3096.9) < 100.) && (B_M > 4500.) && (B_M < 6000.) && ((Hlt1TrackMVADecision) || (Hlt1TwoTrackMVADecision))) { h1_B_M->Fill(B_M); if (MASS_HIST_FIT_MIN <= B_M && B_M <= MASS_HIST_FIT_MAX) { fitting_entries++; } } } if (i % 10000 == 0) { std::cout << "[" << TITLE << "] Processed event: " << i << " (" << TString::Format("%.2f", ((double)i / (double)entries) * 100.) << "%)" << std::endl; } } TCanvas *c1 = new TCanvas("c1", "c1", 0, 0, 800, 600); h1_B_M->Draw(); c1->Draw(); c1->SaveAs(TString::Format("images/root_hist_%s_bmass.pdf", TITLE).Data()); CreateRooFitAndDraw(h1_B_M, fitting_entries); return 0; } void CreateRooFitAndDraw(TH1D *hist, int fitting_entries) { RooRealVar roo_var_mass("var_mass", "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); 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(TITLE)); roohist_B_M.plotOn(roo_frame_mass, RooFit::Binning(nBins), RooFit::Name("B Mass Distribution")); roo_frame_mass->GetXaxis()->SetTitle(X_AXIS); TCanvas *c = new TCanvas("roofit_c", "roofit_c", 0, 0, 800, 600); roo_frame_mass->Draw(); TLegend *leg1 = new TLegend(0.65, 0.7, 0.87, 0.8); leg1->SetFillColor(kWhite); leg1->SetLineColor(kBlack); leg1->AddEntry((TObject *)0, TString::Format("Entries: %d", fitting_entries), ""); leg1->Draw(); c->Draw(); c->SaveAs(TString::Format("images/roofit_hist_%s_bmass.pdf", TITLE).Data()); }