//#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 "TStyle.h" #include "RooAddPdf.h" #include "RooProdPdf.h" #include "RooFitResult.h" #include "RooGenericPdf.h" #include "RooLandau.h" #include "TChain.h" #include "TCanvas.h" #include "TAxis.h" #include "RooPlot.h" #include "RooCategory.h" #include "RooSuperCategory.h" #include "RooSimultaneous.h" #include "RooNLLVar.h" #include "TFile.h" #include "TLegend.h" #include "TLatex.h" #include "TROOT.h" #include "myRooPolBG.cpp" //#include "RooStats/HLFactory.h" #include "RooWorkspace.h" using namespace RooFit ; //using namespace RooStats; using namespace std; const int belle2_font = 133; const double belle2_tsize = 26; void ksks_fit_belle2_style() { TFile *f = new TFile("forfit_proc11_bucket9to12_bcs.root"); //TFile *f = new TFile("forfit_bucket9to12_bcs.root"); //TFile *f = new TFile(" forfit_proc11_bcs.root"); //TFile *f = new TFile("forfit_mc13b_proc11_large.root"); TTree *tree = (TTree*)f->Get("after_bcs"); cout << "Entries = " << tree->GetEntries() << endl; RooRealVar deltaM("deltaM_after_bcs","#it{#Deltam}", 0.139, 0.159, "GeV/#it{c}^{2}"); RooDataSet data("data","data", tree, RooArgSet(deltaM)); //signal RooRealVar mean("mean", "mean",0.1454, 0.14, 0.159); RooRealVar sigma("sigma", "sigma", 0.0002, 0, 10); RooGaussian sig("sig", "signal component", deltaM, mean, sigma); //background RooRealVar mpi("mpi", "nominal pion mass", 0.13957039); RooRealVar alpha("alpha", "alpha", 20, -100., 100.); RooRealVar beta("beta", "beta", 0.); myRooPolBG bkg("bkg","background component", deltaM, mpi, alpha, beta); //total 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)); //fit RooFitResult *fitresult = pdf.fitTo(data, Save(true), Strategy(2), Extended(true)); //plot TCanvas *c1 =new TCanvas ("c1", "", 600, 500); RooPlot* deltaMplot = deltaM.frame(); data.plotOn(deltaMplot); pdf.plotOn(deltaMplot); //pdf.paramOn(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(); //deltaMplot->SetMarkerStyle(20); //c1->SetFrameFillColor(kWhite); //c1->Update(); gROOT->SetStyle("Modern"); TStyle *belle2Style = new TStyle("BelleII","Belle II style"); // set the paper & margin sizes belle2Style->SetPaperSize(30,36); // set canvas, pads, etc. belle2Style->SetCanvasDefW(600); belle2Style->SetCanvasDefH(600); belle2Style->SetFillColor(1); belle2Style->SetFillStyle(1001); belle2Style->SetFrameFillColor(0); belle2Style->SetFrameBorderMode(0); belle2Style->SetPadBorderMode(0); belle2Style->SetPadColor(0); belle2Style->SetCanvasBorderMode(0); belle2Style->SetCanvasColor(0); belle2Style->SetStatColor(0); belle2Style->SetLegendBorderSize(0); // set margin sizes belle2Style->SetPadTopMargin(0.05); belle2Style->SetPadRightMargin(0.05); belle2Style->SetPadBottomMargin(0.16); belle2Style->SetPadLeftMargin(0.16); // use large fonts belle2Style->SetTextFont(belle2_font); belle2Style->SetTextSize(belle2_tsize); belle2Style->SetLabelFont(belle2_font,"x"); belle2Style->SetTitleFont(belle2_font,"x"); belle2Style->SetLabelFont(belle2_font,"y"); belle2Style->SetTitleFont(belle2_font,"y"); belle2Style->SetLabelFont(belle2_font,"z"); belle2Style->SetTitleFont(belle2_font,"z"); belle2Style->SetLabelSize(belle2_tsize,"x"); belle2Style->SetLabelSize(belle2_tsize,"y"); belle2Style->SetLabelSize(belle2_tsize,"z"); belle2Style->SetTitleSize(belle2_tsize,"x"); belle2Style->SetTitleSize(belle2_tsize,"y"); belle2Style->SetTitleSize(belle2_tsize,"z"); belle2Style->SetTitleOffset(1.5,"x"); belle2Style->SetTitleOffset(1.5,"y"); belle2Style->SetTitleOffset(1.5,"z"); belle2Style->SetLabelOffset(0.01,"x"); belle2Style->SetLabelOffset(0.01,"y"); belle2Style->SetLabelOffset(0.01,"z"); belle2Style->SetLegendFont(belle2_font); // use bold lines and markers belle2Style->SetMarkerStyle(20); belle2Style->SetMarkerSize(1.0); belle2Style->SetHistLineWidth(2); belle2Style->SetFrameLineWidth(2); belle2Style->SetLineWidth(2); belle2Style->SetFuncWidth(2); belle2Style->SetLineStyleString(2,"[12 12]");// postscript dashes // get rid of X error bars //belle2Style->SetErrorX(0.001); // get rid of error bar caps belle2Style->SetEndErrorSize(0.); // do not display any of the standard histogram decorations belle2Style->SetOptTitle(0); belle2Style->SetOptStat(0); belle2Style->SetOptFit(0); // put tick marks on top and RHS of plots belle2Style->SetPadTickX(1); belle2Style->SetPadTickY(1); // histogram divisions: only 5 in x to avoid label overlaps belle2Style->SetNdivisions(505,"x"); belle2Style->SetNdivisions(510,"y"); // function belle2Style->SetFuncColor(kBlue); belle2Style->SetFuncStyle(0); // legend belle2Style->SetLegendBorderSize(3); belle2Style->SetLegendFillColor(0); belle2Style->SetHistMinimumZero(); std::cout << "-------------------------" << std::endl; std::cout << "Set Belle II Style" << std::endl; std::cout << "-------------------------" << std::endl; gROOT->SetStyle("BelleII"); gROOT->ForceStyle(); //TAxis::SetMaxDigits(4); //auto logo = new TLatex(); TLatex *logo = new TLatex(); logo->SetNDC(); //logo->DrawLatex(0.55,0.80, "#bf{#it{Belle II}} preliminary"); //logo->DrawLatex(0.55,0.73, "#it{#scale[0.6]{#int} L dt} = 37.8 fb^{#minus1}"); //logo->DrawLatex(0.55,0.55,"#it{D}^{0}#rightarrow#it{K_{s}}^{0}#it{K_{s}}^{0}"); //logo->DrawLatex(0.55,0.49,"#it{N} = 177 #pm 14"); // auto leg = new TLegend(0.57,0.73,0.78,0.93); TLegend *leg = new TLegend(0.57,0.73,0.78,0.93); leg->SetBorderSize(0); // no border leg->SetFillStyle(0); leg->SetTextSize(belle2_tsize); //leg->AddEntry(&data,"Data","pe"); //leg->AddEntry(&pdf,"Fit","l"); //leg->AddEntry(&bkg,"Background","l"); leg->AddEntry("deltaM_after_bcs","Data","pe"); leg->AddEntry("pdf","Fit","l"); leg->AddEntry("bkg","Background","l"); //deltaMplot->Draw(); // //leg->AddEntry(&pdf,"Data","pe"); //leg->AddEntry(&sig,"Fit","l"); //leg->AddEntry(&bkg,"Background","l"); leg->Draw(); }