RooFit External/Internal Constraints Logic

Hi @Mindaugas_Sarpis,

What you do is correct! It’s equivalent to add your constraint as a factor to any RooProdPdf/PROD, or to pass it as ExternalConstraints().

You also don’t need the Constrain() argument, it is redundant and I would even like to discourage people from using it in the documentation at some point. Any parameters for which there is a pdf that doesn’t depend on the observed dataset is by definition a constrained parameter.

The only thing you need to still consider in addition to what you do is to pass the GlobalObservables() command argument. It represents the set of observables to normalize over when evaluating your constraint PDFs. By default, this normalization set are the constrained parameters, which are figured out automatically as I said before. For your Gaussian constraint it usually doesn’t matter what you normalize over, since the integral over x or mu is the same, but in your case it actually makes a difference! But in general, e.g. for Poisson/Gamma constraints, it can make a difference. So it’s a good habit to explicitly define the global observables, like it’s done also internally in HistFactory for example. In your case, it could look like this:

Gaussian::norm_constant_constraint(norm_constant_nominal[1,0,2],
                                   norm_constant[1, 0, 2],
                                   norm_constant_sigma[0.1]))

norm_constant_nominal needs to be set constant, and then you pass it together with the other eventual global observables to GlobalObservables() in fitTo().

Here is another nice forum post that explains what “global observables” mean:

Cheers,
Jonas

PS: I wrote more about this topic also in this forum post: