Dear ROOT experts,
I want to divide two probability density functions obtained with TKDE but I cannot call the functions by name. Here I post some C++ code but I have the same problem with pyROOT.
Consider the following snippet:
TKDE *kde1 = new TKDE(n, &data1[0], xmin, xmax);
TKDE *kde2 = new TKDE(n, &data2[0], xmin, xmax);
TF1 *fKde1 = kde1->GetFunction(100, xmin, xmax);
TF1 *fKde2 = kde2->GetFunction(100, xmin, xmax);
fKde1->SetName("f1");
fKde2->SetName("f2");
TF1 *f1f2 = new TF1("f1f2", "f1/f2", xmin, xmax);
f1f2->Draw();
This gives the error
input_line_10:2:56: error: use of undeclared identifier 'f1'
Double_t TFormula____id13717184231236088683(){ return {f1}/{f2} ; }
^
input_line_11:2:56: error: use of undeclared identifier 'f1'
Double_t TFormula____id13717184231236088683(){ return {f1}/{f2} ; }
^
Error in <prepareMethod>: Can't compile function TFormula____id13717184231236088683 prototype with arguments
Error in <TFormula::InputFormulaIntoCling>: Error compiling formula expression in Cling
Error in <TFormula::ProcessFormula>: "f1" has not been matched in the formula expression
Error in <TFormula::ProcessFormula>: "f2" has not been matched in the formula expression
Error in <TFormula::ProcessFormula>: Formula "f1/f2" is invalid !
However,
TF1 *g1 = new TF1("g1", "x*x+1", 0, 10);
TF1 *g2 = new TF1("g2", "x*x+2", 0, 10);
TF1 *g1g2 = new TF1("g1g2", "g1/g2", 0, 10);
g1g2->Draw();
works as expected.
I noticed that in the TF1 returned by the TKDE class there is no TFormula (f1->GetFormula()
is 0), is this related to my problem?
Thanks in advance,
Daniel
ROOT Version: 6.24/06
Platform: ubuntu 20.04
Compiler: gcc 10.2.0