Custom PDF’s normalization issues

Dear Roofit experts,

I’ve embedded a C++ function into my Roofit project creating a class that extends the RooAbsPdf.

The function is a black box with a method evaluatePDF(&pdf_val, &pdf_norm, observables…, parameters…).

Once called the pdf_val and pdf_nor are initialized with the result of the evaluation.

I’ve implemented the evaluate as follow:

Double_t MyPDF::evaluate() const {
	double pdf_val;
	double pdf_norm;

	evaluatePDF(&pdf_norm, &pdf_val,x,a,b,c,high,low,e….);

	return pdf_val;
} 

high and low are the boundaries of the observable x.

and the getAnalyticalIntegral and analyticalIntegral as follow:

Int_t MyPDF::getAnalyticalIntegral(RooArgSet &allVars, RooArgSet &analVars, const char  rangeName) const{

	if(matchArgs(allVars, analVars, x)) return 1;
	return 0;

} 

Double_t MyPDF::analyticalIntegral(Int_t code, const char *rangeName) const{

	if(code !=0) {
		double pdf_norm;
		double pdf_val;
		evaluatePDF(&pdf_norm, &pdf_val,x,a,b,c,high,low,e….);		
		 return pdf_norm;
	}
	return 0;
}

I’m finding several issues in normalization as plots are completely wrong, especially when using it inside a RooSimultaneous.

My concern is that I’m doing some mistakes in this analyticalIntegral implementation.

I did several checks and trials in order to find exactly the issue. In one of these checks I printed the integral of the simultaneous in the x variable in this way:

self.model =  ROOT.RooSimultaneous(
    ”simultaneous”,
    ”simultaneous”,
    mix_unmix_cat)

self.model.addPdf(mypdf1, MIX)
self.model.addPdf(mypdf2, UNMIX)

mix_unmix_cat.setLabel(MIX)
igx = self.model.createIntegral(RooArgSet(x))
print(”MIX gx_Int[dt] = %f”% (igx.getVal()))

mix_unmix_cat.setLabel(UNMIX)
igx = self.model.createIntegral(RooArgSet(x))
print(”UNMIX gx_Int[dt] = %f”% (igx.getVal()))

I printed first igx.getVal() when using the analyticalIntegral. The result was
not correct because I found :

UNMIXED gx_Int[dt] = 1.0000
MIX gx_Int[dt] = 1.0000

Then I forced the getAnalyticalIntegral to return always 0 in order to use the numerical integration and I got the correct result.

UNMIXED gx_Int[dt] = 0.816937
MIX gx_Int[dt] = 0.183063 

Can you suggest me how to correctly implement the normalization when using the simultaneous pdf?
I think there are no issues without simultaneous in the normalization.

I think @moneta can help you.

Thanks @couet.

Just to add other information. I did the plots with the numerical integral and the results are fine.

Hi @chiara!

Yes, you must have implemented something incorrectly if the numerical and analytical integrals do not agree.

How exactly are pdf_val and pdf_norm defined? Is pdf_norm the integral of pdf_val over the observable x in the range low to high? That would be the correct implementation of the analytical integral.

Looking forward to follow up on this issue,
Jonas

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.