# Relating/constraining the sum of a set of parameters before fitting

Dear all,

Hopefully this is my last question regarding this project… thanks to all for their help and advice.

I have successfully generated a set of RooRealVars using the RooSimPdfBuilder class:

``````  Plot label is "simPdf"
--- RooAbsPdf ---
Cached value = 0
1) 0x46e4aa0 RooRealVar:: a_a_param_a1 = 0.5  L(0 - 1)  "a_a_param (a1)"
2) 0x46e6f20 RooRealVar:: a_a_param_a2 = 0.5  L(0 - 1)  "a_a_param (a2)"
3) 0x46e3d80 RooRealVar:: a_d_param_a1 = 0.5  L(0 - 1)  "a_d_param (a1)"
4) 0x46fb020 RooRealVar:: a_d_param_a2 = 0.5  L(0 - 1)  "a_d_param (a2)"
5) 0x7fff9465a020 RooRealVar::        gamma = 0.5  L(0 - 1)  "gamma"
6) 0x46ef570 RooRealVar:: h_a_param_h1 = 0.5  L(0 - 1)  "h_a_param (h1)"
7) 0x4704bc0 RooRealVar:: h_a_param_h2 = 0.5  L(0 - 1)  "h_a_param (h2)"
8) 0x46fc120 RooRealVar:: h_d_param_h1 = 0.5  L(0 - 1)  "h_d_param (h1)"
9) 0x47176d0 RooRealVar:: h_d_param_h2 = 0.5  L(0 - 1)  "h_d_param (h2)"``````

I now need to apply a condition to these parameters such that:

(sum over a_a_param_a(i)) = n i.e. a1 + a2 + a3 + … + an = n

This reduces the free parameters of my subsequent fit by 1 and will help everything converge happily.

I’d usually do this using a RooForumuIaVar, but I can’t see a way to do this using the RooRealVars that have been automatically generated by the RooSimPdfBuilder class.

Can anyone see a work around?

Best,

S

Hi,
You cannot apply a constraint like this when fitting.you meed to change the model to define one less parameter and the remaining one has a funcion of the others, using for example a Rooformulavar

Lorenzo

Yep - sadly I can’t do this using RooSimPdfBuilder and I’m going to have to do things manually. I’m just not sure how to do that when I have so many subdatasets…

S

Hi,

You can probably do this not writing a single lie for each dataset, but using code, or maybe easier, using a Python script and PyROOT.

Lorenzo

Hi Lorenzo,

I have no experience with pyROOT, but I can code in python, so I am happy to try.

Could you post some example code/an example tutorial similar to what I am trying to do so I can get my head around what you mean?

Best and thanks again,

S

Hi,

You can look at the tutorial tutorials/roofit/rf501_simultaneouspdf.C.
Unfortunately we don’t have the python version, but it is straightforward.
You can also look at example of building sim pdf, using for example the workspace factory in the quick start up user guide, paragraph 1.8.2