Dear *,
I probably have a strange or crazy problems. But I try to extend my understanding
Entering the following in cint directly is successful:
TF1 f(“myf”,“x*exp(-x)”,0.10);
TF1 g(“g”,“myf(x)*TMath::BesselJ0(x)”,0,10);
TF1 hTF1(“h”,“g.Integral(0.,x)”,0,10);
TCanvas c(“c”,“c”,800,600);
h.Draw();
c.SaveAs(“func.pdf”);
Doing the same thing as ROOT macro, script, or compiled code fails with
input_line_15:2:118: error: member reference type ‘double’ is not a pointer
Double_t TFormula____id14289597942108301067(Double_t *x){ return ((x[0])*TMath::Exp(-(x[0]))*TMath::BesselJ0(x[0])).Integral(0.,x[0]) ; }
[…]
I mean I understand from the error that TFormula translates the string in direct C/C++ code. And this evaluates to the return value (double), which is not TF1 object, and thus has no Integrate() class member function. And you are fully right: There are dozens of alternatives (which I all tested and find them acceptable, too).
But more interesting for me is, why does it work under cint? Would be there a way that his can be done also as script/binary executable?
If this would work, convolutions like the following would be two lines!
TF1 glcore(“glcore”,"[0]*TMath::Landau(x,[1],[2],true)*TMath::Gaus(x,[3],[4],true)",0,512.);
TF1 gl(“gl”,"[&](double x, double p){glcore.SetParameters([0],[1],[2],x,[3]); return glcore.Integral(x-5[3],x+5[3]);}",0,512.,4);
That would be really cool!
Is there such a way?
Many thanks in advance! (And sorry, if that question already appeared and was answered somewhere else. A link to there would be very kind from you, then! My internet researches where rather successless so far.)
Cheers, Martin
Please read tips for efficient and successful posting and posting code
_ROOT Version:6.18
_Platform:Debian Buster
_Compiler:GCC 8.3