RooFit fit function

Hi all.

I was wondering if there is a way to create a TH1 from a function used for fit with RooFit.


Dear Roofit users,
Suppose I have generates a dataset according to some function in this way:

RooDataSet *data = sum.generate(x,1000) ;

Now I am interested to save this generated dataset in an ASCII file. Can anybody
tell me how to do the same?

Thanks in advance.

with regards,

To Stefanos21
What I will do is :
RooDataSet *data = function.generate(x,1000) ;
than read this data and prepare histogram from it.

To VindyMishra
You can save the data in ascii format as
RooDataSet *data = function.generate(x,1000) ;

I hope this will serve the purpose…

Hi Stefano,

To make a TH1 from a RooAbsReal, or a RooAbsPdf, simply use createHistogram

TH1* hh = pdf->createHistogram(“observableName”) ;

By default it will sample 100 bins. If you want a different number, supply that as 2nd argument.


Many thanks Wouter!!

Hello Rooters
I have saved some branches in a TTree using the C- structure. Now I am trying to read this TTree file but I am getting "segmentation violation message. Can anybody
suggest me how to fix this problem?

My brief code snippet is given below:

Double_t XResd_xresd_0;
TFile f(“outFName.root”);

Long64_t nentries = h1->GetEntries();
Long64_t nbytes = 0;
for (Long64_t i=0; i<nentries; i++) {
cout << Resd_xresd_0 << endl;

Please also see the root file from the attachment. I can plot a leave of a branch using this

with regards,
V. Prasad
outFName.root (353 KB)