Skip to content

[RF] RooAddPdf::fixCoefRange cache issue with createIntegral #10988

@tcuisset

Description

@tcuisset

Describe the bug

I am experiencing strange behaviour with RooAddPdf::fixCoefRange. When I call createIntegral on a RooAddPdf, then call fixCoefRange, then call createIntegral again, the same value is returned (whilst the change of definition of the coefficients should change the integral). It seems to me the cache does not get cleared when calling fixCoefRange, as the behaviour is correct when calling fixCoefRange before any integral computation.

To Reproduce

RooWorkspace w1;
w1.factory("x[3., 0., 10.]");
w1.var("x")->setRange("range_int", 0., 4.);
w1.factory("AddPdf::sum(Gaussian(x, mean1[1.], sigma1[2.]), Gaussian(x, mean2[5.], sigma2[10.]), coef[0.3])");
RooWorkspace w2(w1);

//Call createIntegral on workspace w1 only
cout << w1.pdf("sum")->createIntegral(RooArgSet(*w1.var("x")),RooFit::NormSet(RooArgSet(*w1.var("x"))), RooFit::Range("range_int"))->getVal() << endl;

w1.var("x")->setRange("fixCoefRange", 0.,  1.);
static_cast<RooAddPdf*>(w1.pdf("sum"))->fixCoefRange("fixCoefRange");

w2.var("x")->setRange("fixCoefRange", 0.,  1.);
static_cast<RooAddPdf*>(w2.pdf("sum"))->fixCoefRange("fixCoefRange");

cout << w1.pdf("sum")->createIntegral(RooArgSet(*w1.var("x")),RooFit::NormSet(RooArgSet(*w1.var("x"))), RooFit::Range("range_int"))->getVal() << endl;
cout << w2.pdf("sum")->createIntegral(RooArgSet(*w2.var("x")),RooFit::NormSet(RooArgSet(*w2.var("x"))), RooFit::Range("range_int"))->getVal() << endl;

This prints :

0.548209 //Before calling RooAddPdf::fixCoefRange
0.548209 //After calling RooAddPdf::fixCoefRange but with a previous call to createIntegral
0.463998 //After calling RooAddPdf::fixCoefRange without any previous call

whilst I would expect :

0.548209
0.463998
0.463998

Setup

ROOT 6.26/02

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions