Hello I am trying to import a leaf from a root file I created. With the leaf, which is an unbinned histogram (I am assuming) I am then trying to fit a Gaussian plus a line to it. When I attempt the fit I get the following error: ERROR:InputArguments – RooDataSet::moment(dh) WARNING: empty dataset
So obviously something is going wrong with the importing of the unbinned data set. Here is my code
#ifndef __CINT__
#include "RooGlobalFunc.h"
#endif
#include "RooRealVar.h"
#include "RooDataSet.h"
#include "RooDataHist.h"
#include "RooGaussian.h"
#include "TCanvas.h"
#include "RooPlot.h"
#include "TTree.h"
#include "TH1D.h"
#include "TRandom.h"
using namespace RooFit ;
TH1F* makeTH1F() ;
TTree* makeTTree() ;
void rf102_dataimport()
{
// Import TTree
TFile *file = new TFile("PS_Decay_Full_Set4.13.2016.root");
TTree* tree = (TTree*)file->Get("BsCanidatesTree/miT_Bs_min_chiSquared_mass");
// Declare observable x
RooRealVar x("x","x",4000,6500) ;
// Create a binned dataset that imports contents of TH1 and associates its contents to observable 'x'
RooDataSet dh("dh","dh",RooArgSet(x),Import(*tree)) ;
// Make plot of binned dataset showing Poisson error bars (RooFit default)
RooPlot* frame = x.frame(Title("Imported TH1 with Poisson error bars")) ;
dh.plotOn(frame) ;
// Fit a Gaussian p.d.f to the data
RooRealVar mean("mean","mean",5366.77,4000,6500) ;
RooRealVar sigma1("sigma1","sigma1",1.5) ;
RooRealVar slope("slope","slope",15.0);
RooRealVar intercept("intercept","intercept",15000);
RooGenericPdf dbgauss("dbgauss","Bs mass","exp(-0.5*(x-mean)*(x-mean)/sigma1)+slope*x+intercept",RooArgSet(x,mean,sigma1,slope,intercept));
mean.setConstant(kTRUE);
sigma1.setConstant(kFALSE);
slope.setConstant(kFALSE);
intercept.setConstant(kFALSE);
dbgauss.fitTo(dh) ;
dbgauss.plotOn(frame) ;
dbgauss.paramOn(frame);
dh.statOn(frame);
sigma1.Print();
mean.Print();
TCanvas* c = new TCanvas("rf102_dataimport","rf102_dataimport",800,800) ;
frame->GetYaxis()->SetTitleOffset(1.4) ;
frame->Draw() ;
}
Any help would be great.
Thanks,
Neil McFadden