//#ifndef __CINT__ #include "RooGlobalFunc.h" //#endif #include "RooRealVar.h" #include "RooArgList.h" #include "RooFormulaVar.h" #include "RooDataSet.h" #include "RooGaussian.h" #include "RooChebychev.h" #include "RooExponential.h" #include "RooBifurGauss.h" #include "RooAddModel.h" #include "RooProdPdf.h" #include "TCanvas.h" #include "RooPlot.h" #include "RooHist.h" #include "RooCBShape.h" #include "RooPolynomial.h" #include "RooBinning.h" #include "TH1.h" #include "TH2.h" #include "RooAddPdf.h" #include "RooProdPdf.h" #include "RooFitResult.h" #include "RooGenericPdf.h" #include "RooLandau.h" #include "TChain.h" #include #include "TCanvas.h" #include "TAxis.h" #include "RooPlot.h" #include "RooCategory.h" #include "RooSuperCategory.h" #include "RooSimultaneous.h" #include "RooNLLVar.h" #include "TLorentzVector.h" #include "TVector3.h" using namespace RooFit ; using namespace std; void ksks_fit_trial(){ RooRealVar deltaM("deltaM","#DeltaM", 0.14, 0.159); TFile *f = new TFile("forfit_proc11_bucket9to12_bcs.root"); TTree *tree = (TTree*)f->Get("after_bcs"); Double_t deltaM_after_bcs; tree->SetBranchAddress("deltaM_after_bcs",&deltaM_after_bcs); RooDataSet data("data","data", tree, RooArgSet(deltaM)); cout << "Entries = " << tree->GetEntries() << endl; //signal RooRealVar mean("mean", "mean_of_the_dist",0.1454, 0.14, 0.159, "GeV/c^{2}"); RooRealVar sigma("sigma", "sigma_of_the_dist", 0.0006, 0, 10); RooGaussian sig("sig", "signal component",deltaM, mean, sigma); //background RooRealVar alpha("alpha", "co_efficient", 20,-100,100); RooRealVar mpi("mpi", "pion nominal mass", 0.1396, "GeV/c^{2}"); RooFormulaVar diff("diff","deltaM-mpi", RooArgList(deltaM,mpi)); RooFormulaVar first_part("first_part", "pow(diff,1/2)", RooArgList(diff)); RooFormulaVar second_part("second_part", "alpha*pow(diff,3/2)", RooArgList(alpha, diff)); RooGenericPdf bkg("bkg","first_part + second_part", RooArgList(first_part, second_part)); //RooGenericPdf bkg("bkg","pow((deltaM-mpi),1/2) + alpha*pow((deltaM-mpi),3/2)", RooArgList(deltaM, mpi, alpha)); RooRealVar n_sig("n_sig", "n_{s}", 2000, 0, 10000); RooRealVar n_bkg("n_bkg", "n_{b}", 100, 0, 10000); RooAddPdf pdf("pdf", "two component model",RooArgList(sig, bkg), RooArgList(n_sig, n_bkg)); RooFitResult *fitresult = pdf.fitTo(data, Extended(true)); TCanvas *c1 =new TCanvas ("c1", "", 600, 500); RooPlot* deltaMplot = deltaM.frame(); data.plotOn(deltaMplot); pdf.plotOn(deltaMplot); cout << "chi^2 = " << deltaMplot->chiSquare() << endl; pdf.plotOn(deltaMplot,Components(RooArgSet(sig)),LineColor(kRed),LineStyle(kDashed)); pdf.plotOn(deltaMplot,Components(RooArgSet(bkg)),LineColor(kBlue),LineStyle(kDashed)); deltaMplot->Draw(); c1->SetFrameFillColor(kWhite); c1->Update(); }