I’m trying to construct a RooGenericPDF which is basically the sum of a large number of polynomials that cannot be further reduced. The idea is that I’m making all possible combinations of the multiplication of Legendre polynomials in three variables. I came up with two possible approaches: (1) Create a RooProd from the multiplication of the polynomials (e.g. P_k(x)*P_l(y)*P_m(z)) and then I multiply the corresponding coefficients using a RooGenericPDF; (2) Create similarly the multiplication of the polynomials as a RooGenericPDF and then
step by step adding each of these equations.
The first approach seems to be working fine when I consider Legendre Polynomials with “l” up 6 (scriptROOTForum.py). However, if I use higher orders it seems that it cannot perform such calculation. The basic message that I receive when I try to generate some data from the PDF for l < 7 is the usual:
[#0] ERROR:Eval -- RooAbsReal::logEvalError(CombLeg) evaluation error,
message : p.d.f value is less than zero (-0.000314), forcing value to zero
which is fine, since indeed sometimes this goes negative. However, when I use l > 6, the message became: “p.d.f value is Not-a-Number (nan), forcing value to zero”. My guess is that this is related to the number of operations allowed within the RooGenericPDF algorithm. Since the TFormula.SetMaxima() function seems to be deprecated in ROOT6, I tried with the older versions with this option and still didn’t make any difference. Any suggestion on how to solve this problem (if this is the cause)? Any other idea of why this is happening is very welcome!
Concerning the second script, the idea is to skip any issue with the TFormula limit (although this approach does not seems very efficient). However, for some reason the resulting PDF does not seems to preserve the appropriate coefficients of each of the polynomials. In other words, the generated data from this PDF seems to be basically the sum of polynomials with the same weight. Perhaps there is some intrinsic re-weight that I’m not aware of. So again any input is more than welcome!
To summarise: I’ve attached both scripts with the minimal version that I could think of. To run you just need to do something like:
python scriptROOTForum.py -p PTLegPol EtaLegPol nTracksLegPol -n 4
python scriptROOTForum_subPDF.py -p PTLegPol EtaLegPol nTracksLegPol -n 4
where the ‘-n’ option gives the degree of the Legendre polynomial to be consider (it will evaluate 0 up to n). Moreover, the coefficients that I use to multiply these equations were stored in a sqlite file that can be downloaded here (this is automatically accessed in the script):
Well, any of these options are fine by me, but I just need the possibility to calculate for higher order. Thanks a lot in advance for any help!