Home | News | Documentation | Download

NumCPU option for RooKeys

Hi,
I’m using RooFit::NumCPU option when running fitTo to speed up the fit, and I’m really happy with that.
I’m wondering if such an option exists for RooKeysPdf as well.
From documentation it seems not, but maybe you know some way to do the same.
Thanks,
Fabio

1 Like

Hi,
The NumCPU option can be used to speed up a fit using whatever pdf, so including a RooKeysPdf.
If you want to just speed up the evaluation of the RooKeysPdf outside of fitting, then we don’t have such option.
However, if you post your problem, we can have a look and see what can be improved in term of performance efficiency

Best regards

Lorenzo

Hi @moneta ,
Thank you very much, this answers my question.
Indeed I wanted to know if there was an option to pass to RooKeysPdf builder to speed up the evaluation outside fitting, sorry for having been unclear.

I guess I don’t have a real problem then, the evaluation is just getting slower when the dataset size increases (~1 million events)
Actually I was testing this effect with this script

void test_RooKeys(){
  using namespace RooFit;

  Int_t to_gen = 1e5; //1e6;

  RooRealVar m("m","m",5000,5500);
  RooRealVar mean("mean", "mean", 5279);
  RooRealVar cc("cc", "cc", 0.1);
  RooRealVar pp("pp", "pp", 1.);
  RooArgusBG* gen_pdf = new RooArgusBG("argus", "argus", m, mean, cc, pp);
  RooDataSet* ds = (RooDataSet*) gen_pdf->generate(RooArgSet(m), to_gen);
  cout << "now fitting with RooKeys" << endl;
  RooKeysPdf *rookeys = new RooKeysPdf("rookeys", "rookeys", m, *ds, RooKeysPdf::MirrorBoth, 0.8);

  cout << "validation plot" << endl;

  RooPlot* myframe=m.frame(Bins(50),Name("M"),Title("M"));
  ds->plotOn(myframe,MarkerSize(0.9));
  rookeys->plotOn(myframe);

  TCanvas* mycanvas = new TCanvas ("mycanvas","Fit", 800, 550);
  myframe->Draw();
}

and this also gets really slow.

Is there any other trick to improve efficiency in the case of large datasets?

Cheers,
Fabio

Hi, I have also encountered this problem and would be interested in suggestions on improving the performance of the RooKeysPDF constructor. It is indeed annoying when preparing my PDFs for use in a fit with multiple background components is much slower than the fit itself. In my use case, I have 5 or more components which are described by RooKeysPDF, each fitted from its respective simulation sample of ~30000 events and it takes quite some waiting to prepare the PDFs.

Hi,
It is truly the RooKeysPdf is very slow. A workaround you can use now it to use the ROOT provided kde class, TKDE, which is having maybe different options and it is much faster to create and evaluate.
See ROOT: TKDE Class Reference
I attached the example code on how to use TKDE and wrapped it in a Roofit pdf.
test_RooKeys.C (1.6 KB)

Cheers

Lorenzo

1 Like

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