# RooSumPdf and RecursiveFraction with a scale factor on one of sub-components

Dear all,
I have a question concerning the usage of RecursiveFraction for RooAddPdf.

I have a signal PDF which is made by 3 PDFs and each of the 3 sub-PDF by a sum of 3 PDfFs.

I.e
SignalModel = frac1 * PDF1 + frac2 * PDF2 + [%] * PDF3.

The frac1, frac2 are fix and constant values however inside PDF2 expands to

PDF2 = frac2_1 * PDF2_1 + frac2_2 * PDF2_2 + [%] * PDF3.

What i want to do in my fitter is to have

``````frac2_2 ---> scale * frac_2_2(original)
``````

I.e scale the fraction of one sub-pdf component by a factor and let still the internal PDF2_1 to be normalized to 1.

When i construct my fractions i compute the recursive “numbers” by myself but when i want to “scale” them i am not anymore sure if the scale parameter has to be propagated on the redefinition of the “other” non-scaled fractions or not.

I hope i have been clear on what i am trying to achieve.
Thanks in advance
Renato

Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided

Note that in all those cases i am creating the

``````PDF2 = frac2_1 * PDF2_1 + frac2_2 * PDF2_2 + [%] * PDF3.
``````

with recursiveFraction enabled, then i perform a fit to simulation , and to fit data i want to have a parameter which parameterise `frac2_2 * scale` so what i do is to take the PDF, copy it with the arg list and replace the current frac2_2 with a RooFormulaVar, however if i do so, i am not sure if the other" fractions" of that PDF are still valid or they need to be “roo-formula-vared” as well.

I apologize for the ill-defined question.
I realized my question is a bit ill-formed.
Let me try to simplify the use case:
I fit 3 MC samples :

• MC1 : is a sum of 3 gaussians : `RooAddPdf( ..., RooArgList( g11,g12,g13), RooArgList( f1_2, f2_2)) `
• MC2 : is a sum of 3 gaussians : `RooAddPdf( ..., RooArgList( g21,g22,g23), RooArgList( f2_1, f2_2)) `
• MC3 : is a sum of 3 gaussians : `RooAddPdf( ..., RooArgList( g31,g32,g33), RooArgList( f3_1, f3_2)) `
In MC1, MC2, MC3 i create and fit the PDFs enabling the recursive fraction.
Then i know that my data is given by
`nSignal* ( 0.2 * MC1 + 0.4 * MC2 + 0.4* MC3 ) `.
Also , I know that, for example MC2 has to morph itself so that one of the gaussian can reduce-increase his contribution.
I achieve this taking the fitted MC2 sub-components ( 3 gaussians ) and the already existing fractions from the MC fit. Then i fix the shape parameters of `g21,g22,g23`, fix `f2_1, f2_2` and recreate
``````f2_2_morph = FormulaVar( scale * f2_2)
MC2_Morphed = RooAddPdf( ..., RooArgList( g21,g22,g23), RooArgList( f2_1, f2_2_morph)) ```
``````

And my final fit is given by :
`nSignal* ( 0.2 * MC1 + 0.4 * MC2_Morphed + 0.4* MC3 ) `

The question i have is if creating a RooAddPdf with 3 pdfs and recursive flag enabled with

• 1 constant fraction
• 1 fraction rewritten as formula var
is somehow forcing the pdf to scale only the last component or if it internally make the fractions absorb the fact the first one is scaled.
Thanks

I think i solved the issue i have.
I had to manually make the code doing something like
First time i fit MC shapes :

``````f1Original = RooRealVar....;
f2Original = RooRealVar...
f2Original_Rec = RooFormulaVar( (1-f1Original)*f2Original);
f3Original_Rec = RooFormulaVar( (1-f1Original - f2Original_Rec);
//Construct the PDF so that
functionNotScaled = RooAddPdf( g1,g2,g3, {f1Original, f2Original_Rec, f3Original_Rec) );
``````

I fit the MC to get shape parameters :
when performing data fits i retrieve

``````//f1Original, f2Original values from ```functionNotScaled```
//And i make a full new PDF from scratch with :
f1Original_UP = RooFormulaVar( scale*f1Original);
f2Original_UP = RooFormulaVar( (1-f1Original_UP)*f2Original);
f3Original_UP = RooFormulaVar( (1-f1Original_UP - f2Original_UP ) );
``````

PDF update :

``````PDF_UP = RooAddPdf( g1, g2, g3, { f1Original_UP , f2Original_UP,f3Original_UP) );
``````

I then use

``````FULLPDF = RooAddPdf(  anotherPDF, PDF_UP, PDF_UP2, { constFrac1, constFrac2 } )
``````

Doing this i don’t see anymore erorrs on the normalization.
I think the way to achieve this is quite tricky since if one doesn’t “manually” enforce the recursivity and normalization to 1 of each component the constFrac1,2 knowkedge of sub-shapes could get lost and effectively bias the fit.

In all this machinery the caveat is that the “scaled” component has to always be the first one in the list to create the RooAddPdf to propagate the morphing to the others.
I hope with this pseudo code my problem is better explained. Any confirmation that what i did is correct is welcome.
Thanks

Many thanks for posting the solution! Perhaps @jonas can comment further.

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