How one can add the freedom to a RooKeysPDF to move/shift in x-axis direction?

Dear experts!
I would like to add the option to a background model using a RooKeysPDF made from a histogram to shift in x-axis direction. I do need this for shifting a MC data distribution to improve the calibration wrt to the data. The shape of the background PDF is OK …

Thanks in advance and cheers, Arno

Hi,

If I have understood you well, I think you would need to pass as input to the RooKeysPdf not the RooRealVar representing x, but a RooAbsReal function describing x+shift.

Lorenzo

Hi Lorentzo!

Yep, I think so too. Unfortunately, I do not know how. :blush:

Cheers, Arno

Hi Arno,

I am facing the same problem at the moment - did you figure out how to do this in the end?

Cheers,
Emmy

Hi Emmy!

This question I had long time ago and I solved my problem in another way. Nowadays, I understand Lorenzo’s answer in the following way:

If you’d map an x to a whatever f(x) e.g. one has computed a RooKeysPDF. Then one could compute a shift by later using the same obtained f(x) but when asking for a value for e.g. a concrete x_0 with a shift, e.g. s_0 for the whole f(x) one can calculate f(x_0) using x_0 = x - s_0.

hth

Cheers, Arno

Hello to both of you,

If I understood it correctly, we are talking about something like this:

RooRealVar x("x", "x", 0, -100, 100);
RooRealVar shift("shift", "Shift for x", 0, -100, 100);
RooAddition xPrime("xPrime", "Shifted x", RooArgSet(x, shift));

And now, when you construct the KeysPdf, don’t give it x, give it xPrime as its variable.

Hi all,

thank you for your replies. I was trying a similar thing using RooFormulaVar instead of RooAddition. I believe these should be the same, but I tried implementing this using RooAddition as well.

However, I keep running into either a segfault (using RooFormulaVar), or a

teminate called after throwing an instance of 'std::bad_alloc'

when using RooAddition. It looks like some memory allocation is going wrong, and I am not sure why.
Here are the relevant lines in my code:

RooRealVar x("x", "x", 0, 300);
RooRealVar shiftval("shiftval", "shiftval", 0, -10, 10);
RooAddition shift("shift", "shift", RooArgSet(x, shiftval));
//RooFormulaVar shift("shift",  "x+shiftval", RooArgSet(x, shiftval));

RooKeysPdf feed("feed", "feed", shift, data, RooKeysPdf::NoMirror);

The break occurs when I try to create the RooKeysPdf.

std::bad_alloc might mean that you are running out of memory. Try to reduce the size of the dataset by a factor 100, and see if it works.

And yes, the two should do the same, only that the FormulaVar gets interpreted, while the Addition is compiled. Therefore, the addition should be a bit faster.

Hi Stephan,

The dataset I am fitting is ~100mb and the dataset I am converting to a RooKeysPDF I have reduced to ~50kb and I still get the same error. I am wondering whether constructing the RooKeysPDF in this way is too memory intensive even with very small samples…

edit –
I managed to solve this issue using a different approach:

  • Create a TH1 from the RooDataSet
  • Apply smoothing
  • Create a RooDataHist from the TH1
  • Create a RooHistPdf which can be parameterised using the approach given here: Fit an offset for RooHistPdf

Thanks for all the help!
Cheers,
Emmy

– second edit since I am not allowed to reply any more:
I have opened a bug report, as suggested by Stephan: https://sft.its.cern.ch/jira/browse/ROOT-10233

Hi Emmy,

that’s great. However, the memory error doesn’t seem to be that you are running out of memory if the dataset is only 50k.
If you have the time, would you open a bug report, and attach the dataset and the macro to run it so I can try to reproduce the error?

1 Like