sPlot with ExternalConstraints in PDF

Dear experts,

I want to sweight some distribution with a pdf that contains Gaussian-constraints in the model, so in my nominal fit (independent of the sWeight calculation) I have an

RooFit::ExternalConstraints( *gaussconstr )

in my fitTo-function. As I see in the sPlot class, there, the pdf is just fitted back without the external constraints, so the fit function will find different yields (and indeed, the sum of sWeights is not equal to the number of signal events I find in my nominal fit).

Is it somehow possible to add these ExternalConstraints to the fitting in the sPlot class? As a quick workaround I thought about just adding this argument to the fitTo-function by myself. Would this be an option, or will I run into problems doing this?

Thanks a lot for your help already!
Sophie

@StephanH can you please take a look?

Thanks,
Oksana.

Hallo Sophie,

it’s certainly a hack that you can apply to achieve what you need.

One other option could be to use internal constraints, i.e., to multiply the fit model explicitly with Gaussians or other constraint functions. See e.g. here:
https://root.cern/doc/master/rf604__constraints_8C.html

Hi Sephan,
thanks a lot.

I also thought about using internal constraints, but don’t I then also need to modify the fitTo?
As in the tutorial about constraints:

   // M E T H O D   1   -   A d d   i n t e r n a l   c o n s t r a i n t   t o   m o d e l
   // -------------------------------------------------------------------------------------
   // Multiply constraint term with regular p.d.f using RooProdPdf
   // Specify in fitTo() that internal constraints on parameter f should be used

with

RooFitResult *r2 = modelc.fitTo(*d, Constrain(f), Save());

Or am I missing something? Indeed, it would be easier to do something without the hack I thought about, so I would be happy about a different solution.

Thanks a lot already!

Yes, you need to add the Constrain argument.

But did you see that you can pass arguments to the fitting step? I updated the documentation a while ago, so see here:
https://root.cern.ch/doc/master/classRooStats_1_1SPlot.html#a6ebcfda69a443286687f79c67b511062

and here:
https://root.cern.ch/doc/master/classRooStats_1_1SPlot.html#a15044d3df8199eff3fc2d4ac722b229d

EDIT:
Oh, I see that this update will only be released in ROOT 6.20. It’s coming very soon, but in the mean time, you can use ROOT’s development version from here:
https://root.cern/nightlies

Thanks a lot for the useful advice!

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