Feldamn-Cousins calculator memory leak?

Dear experts,
what can be a reason for large memory use in FeldmanCousins calculator?
While using a simple combined (5 channels Poisson+Gauss) model it goes up to >2.5g!
(this is sad, preventing use of grid nodes)
Im using adaptive sampling with 100 bins.

thanking in advance,
Valery

HI,
can you send us your macro reproducing this problem and also the workspace ? Are you using the latest version , 5.28 ? Some memory leaks have been fixed for this version.

Best Regards
Lorenzo

Dear Lorenzo,
I tried both 27 and 28 (actually 27 consume even slightly less)
Eg below. Tried with single channel (nch=1) and 5 channels, when it goes up to 1g.
It seems the profiling memory is not realized.?

Regards, Valery

{
using namespace RooFit;
using namespace RooStats;
double cls=0.95;
int nch=1;
//nch=5;
double no_=5./nch;
double nb_=5./nch;
double seff_=1./nch;
double sigb_=0.5;
sigb_=nb_;
double srng=5.
(no_+nb_);

RooWorkspace* w = new RooWorkspace(“combsys10”);
RooRealVar s(“s”,“s”,0,0,srng);
w->import(s);
char* name=new char[1000];
for(int ich=0; ich<nch;ich++) {
sprintf(name,“n_%d”,ich);cout<<name<<endl;
RooRealVar n(name,name,no_,0,1000);
sprintf(name,“b_%d”,ich);cout<<name<<endl;
RooConstVar b(name,name,nb_);
sprintf(name,“db_%d”,ich);cout<<name<<endl;
RooRealVar db(name,name,0,0.001,5.*sigb_);
sprintf(name,“sigmab_%d”,ich);cout<<name<<endl;
RooConstVar sigmab(name,name,sigb_);
sprintf(name,“seff_%d”,ich);cout<<name<<endl;
RooConstVar seff(name,name,seff_);
w->import(b);
w->import(n);
w->import(seff);
w->import(sigmab);
w->import(db);
sprintf(name,“prod::s_%d(s,seff_%d)”,ich, ich);cout<<name<<endl;
w->factory(name);
sprintf(name,“sum::spb_%d(s_%d,db_%d)”,ich, ich,ich);cout<<name<<endl;
w->factory(name);
sprintf(name,“Gaussian::bsig_%d(db_%d,b_%d,sigmab_%d)”,ich, ich,ich,ich);cout<<name<<endl;
w->factory(name);
sprintf(name,“Poisson::signal_%d(n_%d,spb_%d)”,ich, ich,ich);cout<<name<<endl;
w->factory(name);
sprintf(name,“PROD::modelsb_%d(signal_%d,bsig_%d)”,ich, ich,ich);cout<<name<<endl;
w->factory(name);

} //ich

if(nch==1) {
w->defineSet(“obs”,“n_0”);
w->defineSet(“nuis”,“db_0”);
w->factory(“Uniform::prior_nuis({db_0})”);
w->factory(“PROD::modelsb(modelsb_0)”);
}
if(nch==5) {
w->defineSet(“obs”,“n_0,n_1,n_2,n_3,n_4”);
w->defineSet(“nuis”,“db_0,db_1,db_2,db_3,db_4”);
w->factory(“Uniform::prior_nuis({db_0,db_1,db_2,db_3,db_4})”);
w->factory(“PROD::modelsb(modelsb_0,modelsb_1,modelsb_2,modelsb_3,modelsb_4)”);
}

w->defineSet(“poi”,“s”);
w->factory(“Uniform::prior_poi({s})”);
w->factory(“PROD::prior(prior_poi,prior_nuis)”);

RooDataSet *data=new RooDataSet(“data”,“data”,*w->set(“obs”));
data->add(*w->set(“obs”));
w->import(data);
w->Print();
ModelConfig
smodel = new ModelConfig(“smodel”);
smodel->SetWorkspace(*w);
smodel->SetPdf(*w->pdf(“modelsb”));
smodel->SetPriorPdf(*w->pdf(“prior”));
smodel->SetParametersOfInterest(*w->set(“poi”));
smodel->SetNuisanceParameters(*w->set(“nuis”));
smodel->SetObservables(*w->set(“obs”));
w->var(“s”)->setVal(0.0);
w->import(*smodel);
smodel->SetSnapshot(*w->set(“poi”));

FeldmanCousins fc(data, smodel);
fc.SetConfidenceLevel(cls);
fc.FluctuateNumDataEntries(false);
fc.UseAdaptiveSampling(true);
fc.SetNBins(100);
PointSetInterval
fcInt = NULL;
fcInt = (PointSetInterval
) fc.GetInterval();
//
double fc_L= fcInt->LowerLimit( *w->var(“s”));
double fc_U= fcInt->UpperLimit( *w->var(“s”));

cout << “----------Feldman Cousins interval on s = [” <<
fc_L << ", " <<
fc_U << “]” << endl;

}

Hi,

This may not have any affect on anything, but: What happens when you compile the macro (".L macro.C+") instead of running it interactively? In general, I would strongly suggest compiling statistical code instead of running it interactively…

Cheers,
Charles

Hi,

Thank you for the example macro. I will investigate it. INcreasing the number of bins in the FC calculator, I could see clearly the memory increasing to GB levels.
In this case the leaks happens inside compile code (inside the FeldmanCousins class) so compiling the code or running in CINT will not make a difference

Cheers,

Lorenzo