Roofit evaluating components of a rooaddpdf

I added two rooexponentials to create a rooaddpdf and did an extended fit with some data which worked. I then plotted the fit and the components of the fit (the two exponentials) over my data which worked. I would now like to evaluate each component of the rooaddpdf at a certain point. I have done some searching and cannot find a way to do this. I have tried using the getVal() and the evaluate() commands and both attempts were unsuccessful. How can I do this?

Thanks

Hi,

You can use RooAddPdf::coefList to get the coefficients and RooAddPdf::pdfList to get the pdf’s.
After being sure that the fit parameter values are set in the RooAddPdf, you can evaluate the components
(coefficient * normalised pdf value) by doing:

   pdf.setVal(x.getVal() ); // set desired x value
   double component1 = pdf.coefList[0].getVal() * pdf.pdfList[0].getVal( x); // use getVal(x) for normalized pdf value
   double component2 = pdf.coefList[1].getVal() * pdf.pdfList[1].getVal( x); 

Best Regards

Lorenzo

Hi Lorenzo,
I am trying to do exactly what you suggested here, but run into a problem compiling:

massfit_bdkspi.C:613:31: error: invalid types ‘<unresolved overloaded function type>[int]’ for array subscript
     eval += LL_model.pdfList[0].getVal(*m);
                               ^

I would guess I am interpreting your suggestion too literally - do you know what is the actual code I should use?

Cheers!