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.

Cheers,
Stefanos

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,
V.Prasad

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) ;
data->write(“myfile.txt”);

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.

Wouter

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”);
h1->SetBranchAddress(“XResd”,&XResd_xresd_0);

Long64_t nentries = h1->GetEntries();
Long64_t nbytes = 0;
for (Long64_t i=0; i<nentries; i++) {
h1->GetEntry(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
command:
h1->Draw(“XResd.xred_0”);

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