Issues with RooHistFunc and RooRealSumPdf

test.zip (131.6 KB)

Dear experts,

I am trying to perform a 3D binned fit with roofit using s-weighted variables. Since I expect some weights to be negative and it is my understanding that RooHistPdf objects set to zero any bins with negative weights, I chose to use RooHistFunc objects and to build my pdf I’m using a RooRealSumPdf.
I am however having problems with this implementation. Attached you can find an out of the box working example of the issues I’m having.

Looking at the plots of the RooHistFunc components of the fit you can immediately see a difference with the RooDataHist components from which they are defined. Why is that? I believe this might be the reason why if I try to actually fit my data toy with this model I obtain nonsensical results.

Also, I’m not sure if the initialisation of the parameters is done correctly and the I took the lines 139-143 from another example in this forum How to handle negative pdf, even though I’m not sure if they are used correctly. Could you comment also on that?

Thanks a lot for your help!
Cheers,

Stefano

Hi Stefano,
Thank you for reporting this problem. I will investigate it, apologies if this will take some time
Lorenzo

Hi Lorenzo,

thanks a lot for looking into that. I’m looking forward to hearing from you.

Cheers,
Stefano

Hi,
Which ROOT version are you using ? For me your code seems to go in an infinite loop when generating the events. Does it work for you the code you have posted ?

Lorenzo

Hi Lorenzo,

I’m using ROOT 6.20/04. If I run the code as it is in the zip file I attached it runs, with some error messages that I believe are linked to the definition of the RooRealSumPdf, and produces plots.
On the other hand, if I uncomment line 148, the one that actually fit the toy with the model built below the code seems to get stuck in an infinite loop for me as well.

Cheers,
Stefano

Hi,
Something has changed in Roofit that I get infinite loop with the attached code in the current ROOT master version. It is caused when generating events an overflow in TRandom::Poisson(double mu) when the provided value mu is very large or a nan. This needs to be protected.
The nan they are probably caused by the negative pdf values.
If the histograms are negative, I am not sure how to fix this

Lorenzo

Hi Lorenzo,

thanks for the reply. I’m not sure how to proceed though. What do you recommend to do? Is there another way to perform 3D binned fit in roofit using s-weights (weights that can sometimes be negative)?

Cheers,
Stefano

Hi @moneta,

Sorry to bother you again, I just wanted to be sure you saw my latest reply since I forgot to directly tag you.

Cheers,
Stefano

Hi,
Sorry for my silence. There is no other way to perform a fit with something that can be negative. The only solution would be to make sure that when summing all weights the final pdf is not negative, i.e. in every bins where the total pdf is evaluated the result is positive, although some of the components can be negative.

I need to think about more on this and more about the s-weights. In your case, can you provide me with something explaining better your problem and what would you like to do. Why are you using s-weights ?

Best regards

Lorenzo

Hi @moneta,

Here’s a brief overview of what we are doing that, hopefully, justifies our choice of using sWeights.

We want to measure R(Ds*) which is defined as the ratio between the tauonic and muonic mode of this decay: Bs -> Ds* l nu, with Ds* -> Ds gamma. In order to reduce the large background due to photons coming from different sources other than of signal, we decided to extract the sWeights from a fit on the Ds* invariant mass.

Once we get our events with the sWeights the next step would be to put in place a fitter to extract signal and normalization yields from data. We are trying to perform a 3D binned fit, using the transverse 4-momentum squared, the missing mass squared and the muon energy as variables. Furthermore, toys production is required to validate the fitter.

So basically we have two problems:

  1. Generate toys that are true to the histograms they come from (impossible to do with RooHistPdf because all the negative bins are set to zero).
  2. Actually put in place a 3D binned fit. We thought the way to go would be to make the replacements RooHistPdf -> RooHistFunc and RooAddPdf -> RooRealSumPdf but, as you saw, this does not seem possible.

I hope I clarified enough what we want to accomplish. Please let me know if you need some more details.

Cheers,
Stefano

Thank you for the explanation. I understand now.
I have one question, after applying the s-Weights, you will have some bins in your pdf (RooHIstFunc) with negative bins correct ? Is this unavoidable in your analysis ?

Cheers

Lorenzo

Hi @moneta,

Yes, that’s exactly the point and unfortunately no, this is not avoidable.

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