Turning a RooHisPdf into RooAbsPdf

I built a RooHistPdf object :

RooHistPdf*   pdf = new RooHistPdf ( "pdf", "", RooArgSet( mES, deltaE  ), datasetForPdf, 3 );

and want to turn it into an Extended pdf with RooExtendPdf by using

RooRealVar n ( "n", "", 300., 0., 20000. );
RooExtendPdf pdf_ext ( "pdf_ext", "", pdf, n, "" );

But the problem is the constructor of RooExtendPdf only accepts
RooAbsPdf, and despite RooHistPdf belongs to RooAbsPdf I could’nt make
it work.
I tried to turn “pdf” into a RooAbsPdf using

RooAbsPdf pdf_abs ("pdf_abs","",RooArgSet(*pdf) );

or

RooAbsPdf pdf2 = *pdf;

But that failed too.

Does anyone has an idea ?

Thanks,

Xavier

Hi Xavier,

Sorry for the late reply, I was on vacation.

I think you have a C++ problem in your examples below:

This

RooAbsPdf pdf_abs (“pdf_abs”,“”,RooArgSet(*pdf) );

nor this

RooAbsPdf pdf2 = *pdf;

is not possible because RooAbsPdf is an abstract base class
(as the name suggests)

In fact

RooRealVar n ( “n”, “”, 300., 0., 20000. );
RooExtendPdf pdf_ext ( “pdf_ext”, “”, *pdf, n, “” );

should work just fine (note the * in front of pdf)

The following example works fine fore me:

RooRealVar x(“x”,“x”,-100,100) ;
RooGaussian g(“g”,“g”,x,RooConst(0),RooConst(30))
RooDataSet* d = g.generate(x,1000) ;
RooDataHist dh(“dh”,“dh”,x,*d)
RooHistPdf hp(“hp”,“hp”,x,dh)
RooRealVar n(“n”,“n”,100,0,1000) ;
RooExtendPdf ehp(“ehp”,“ehp”,hp,n)

Wouter