This may be a very naive question, but I’m trying to get the associated 1-D histograms from a given RooFormulaVar (which depends on some other functions - RooLegendre) and I can’t retrieve the projection in a given variable. The lines below indicate the idea in a very simplified way (in python):
These are the variables that I want to project later
x = RooRealVar(‘x’, ‘x’, -1.0, 1.0)
y = RooRealVar(‘y’, ‘y’, -1.0, 1.0)
Basic functions that use x,y
P_1_x = RooLegendre(‘P_1_x’, ‘P_1_x’, x, 1, 0)
P_1_y = RooLegendre(‘P_1_y’, ‘P_1_y’, y, 1, 0)
C_1_2 = RooRealVar(C_1_2, ‘C_1_2’, 2.0)
Main function that in theory is made of several combinations of Legendre polynomials
combLeg = RooFormulaVar(‘combLeg’,‘C_1_2P_1_xP_2_z’, ROOT.RooArgList(C_1_2, P_1_x, P_2_y))
Finally, I want to project either x/y results into a histogra, e.g.:
pdf = combLeg.createHistogram(‘pdf’, x, RooFit.Binning(80))
Clearly the issue is related to how I’m accessing the x/y, but I’m not sure any alternative for this. Any suggestions? Thanks!
Hi. Thanks for the question; we’ll try to help as soon as possible.
Your code seems to be not correct. I attached a correct C++ macro working for this example
LorenzorootForum_20899.C (824 Bytes)
Thanks for fixing the errors and for the proposal solution. The only point that I may be missing is related to the “sensible value” that you’ve fixed for ‘y’. My problem is that if my function is more complex, for instance if the Legendre polynomial for x and y have respectively l = 8 and 7 (just as an example), if I put y->setVal(0.5) and y->setVal( 0.8 ) they will give me totally different distributions (see attached plots). Am I missing something obvious here? Thanks again!
Fnc_y_0_5.pdf (14 KB)
Fnc_y_0_8.pdf (14 KB)
What you are doing is projecting a f(x,y) for fixed values di y. It is clear you will get completely different results for different y. I have just put a y value that did not make f(x,y) = 0 for every x.
Maybe you want instead to integrate f(x,y) in y ? This is something else
My actual purpose from this exercise is to verify the agreement of my 4-dimensional PDF in each of the variables. I’ve tried before in a simpler situation using a TF2, via hist = PDF.GetHistogram() and projecting in a given axis with hProj = hist.ProjectionX(). My understanding is that this evaluate ‘y’ from the first to the last binning, which I guess is essentially integrate over y. What could be the corresponding for my case? Thanks again for the help.
I’m still having issues with this point. Essentially, I’m trying to create a projection from the method “createProjection(RooArgSet(y))” and then creating a TH1 histogram from the resulting RooProjectedPdf. Although it doesn’t complain about anything when I use Legendre polynomials with l <= 3, the resulting distribution doesn’t seems to be correct. The reason why I’m not confident with this distribution is because I’ve plotted the same function using TF1 and indeed does not match. Probably I’m missing something really obvious here, but any help is really appreciate.
Another problem that I can see is related to when I move to higher orders. It looks like to me that the function can receive negative values, which obviously clashes with the procedure I’m using (e.g. “WARNING:Plotting – WARNING: Function evaluation error(s) at coordinates”). Since I’m only interested in the distribution, there is any simple way to fix this?
For simplicity I attached my full script and the database can be found in the link [url][/https://drive.google.com/file/d/0By22Lv-VZQQfWlo2VEJZZmVVT0k/view?usp=sharing]. The lines more relevant for this discussion start at line 150. To reproduce my issue is only necessary to run something like: “python validationExample.py -p PTLegPol EtaLegPol -n 3”. The last option just specify the order of the Legendre polynomial to be considered.
Thanks again in advance for the help!
ps. I decided to move from RooFormulaVar to RooAddPdf for simplicity, but the issue is still the same.
validationExample.py (5.68 KB)