#include "RooRealVar.h" #include "RooDataSet.h" #include "RooGaussian.h" #include "RooConstVar.h" #include "RooChebychev.h" #include "RooAddPdf.h" #include "RooSimultaneous.h" #include "RooCategory.h" #include "TCanvas.h" #include "TAxis.h" #include "RooPlot.h" using namespace RooFit; void Simple_Fit() { // Create observables RooRealVar MBC("MBC","Mbc [GeV/c^{2}]",5.23,5.29); // Construct signal pdf //--- Signal mbc ---// RooRealVar Sig_mean("Sig_mean","#mu_Mbc", 5.279787, 5.25, 5.29); RooRealVar Sig_sigma("Sig_sigma","#sigma_Mbc", 0.003, 0.0, 1.0); RooGaussian Sig("Sig", "Signal", MBC, Sig_mean, Sig_sigma); /* // Create a container to store data (dataset) RooDataSet *data = new RooDataSet("data", "data", MBC); // Create tree (tchain) object for treename = extree TChain *ch = new TChain("extree"); // Add root file ch->Add("Root_Files/Signal_Mbc.root"); // Save entries to dataset by looping over root file int nent = ch->GetEntries(); for(int ii=0; iiGetEntry(ii); double mbc = ch->GetLeaf("Mbc")->GetValue(); MBC.setVal(mbc); data->add(MBC); } */ // Generate a toy MC dataset RooDataSet* data = Sig.generate(MBC, 2000); // Perform extended ML fit to toy data: Sig.fitTo(*data); // Plot toy data and fit overlaid: RooPlot* xframe = MBC.frame(); data->plotOn(xframe); Sig.plotOn(xframe); //Sig.paramOn(xframe); xframe->Draw(); }