Unable to use a fit function in RooFit

Dear Rooters,

I am a newbie to RooFit. I’ve been trying to follow the user’s manual p. 9
and 10:

ftp://root.cern.ch/root/doc/RooFit_User … .91-33.pdf

Basically, I am trying to fit a Gaussian to an ntuple variable myhisto:

TTree* tree = (TTree*) gDirectory->Get("myhisto") ; RooRealVar x(“x”,”x”,-10,10) ; RooDataSet data(“data”,”dataset with x”,tree,x) ;

When I try to gauss.fitTo(data), I get this error:

Error: Symbol gauss is not defined in current scope (tmpfile):1: Error: Failed to evaluate gauss.fitTo(data)
It seems that some library isn’t loaded correctly, but I may be wrong.
This is what I do at the start of ROOT session:

gSystem->Load("libRooFit") ; using namespace RooFit ;

Thanks in advance for your help,
Daniel

Hi Daniel,

I’m not the RooFit expert, but you probably have to define the RooGaussian PDF “gauss”. See page Page 7 of the manual (Building a model, Example 2 – Construct a Gaussian probability density function). And look also to the many examples in $ROOTSYS/tutorials/roofit.

Cheers, Bertrand.

Thanks much, Bertrand! Apparently I did miss page 7… :wink: Defining a Gaussian as described there solved my problem.

Thanks again,
-Daniel