Bin contents of RooHistPdfs

Hello all,

When using a RooHistPdf, is it possible to return the value of the PDF for each bin?

I construct the RooHistPdf using a TH1F and a RooDataHist as follows:

TH1F *Hist = new TH1F("", “”, 5,-0.80,1.00);
Hist->Sumw2();
Hist->SetBinContent( 1, val_1); Hist->SetBinError( 1, err_1);

RooDataHist *DataHist = new RooDataHist("", “”, RooArgList(Var), Hist);

RooHistPdf *HistPdf = new RooHistPdf( “HistPdf” , “HistPdfF”, RooArgList(Var), *DataHist, 0);

Clearly, the values in the bins of the TH1F and the RooDataHist are the values that I enter (val_1, val_2,…). However, the RooHistPdf normalizes the distribution to 1. So, I need the normalized values in each bin.

Is there a simple way to write out the values of the bins in the RooHistPdf?

Thanks in advance,
Pablo

Hi Pablo,

You can request any RooAbsPdf to be sampled into a histogram,
so the following would do the job.

// Make empty clone of original
TH1F* clone = Hist->Clone(“clone”) ;
clone->Reset() ;

// Fill clone with normalized contents of HistPdf
HistPdf->fillHistogram(clone,Var) ;

I note that there is also a creatHistogram() method which will make the TH1F
for you (with any binning you like) in addition to filling it, but in your case fillHistogram
may prove more handy as you have a clear preference for the choice of binning
for a RooHistpdf.

Wouter