Processing exampleCanvas.C…
input_line_45:2:66: error: use of undeclared identifier ‘customFunction’
Double_t TFormula____id16614074293475595597(Double_t x){ return customFunction(x[0]) ; }
^
Error in TFormula::Eval: Can’t find TFormula____id16614074293475595597 function prototype with arguments Double_t
Error in TFormula::ProcessFormula: Could not find customFunction function with 1 argument(s)
Error in TFormula::ProcessFormula: Formula “customFunction(x)” is invalid !
Error in TFormula::Eval: Formula is invalid and not ready to execute
customFunction is unknown.
The only work around I can find is using the GetHistogram method of TF1, using that to draw and save the function instead. However, this does not look nice as the histogram drops to 0 at the end of the functions range.example.C (473 Bytes)
The attached macro demonstrates what I am trying to do: run the macro, then try to open the canvas saved as a .C file.
Could someone please explain what I should do?
Thanks in advance
ROOT Version: Not Provided Platform: Not Provided Compiler: Not Provided
I have the same issue. Calling TCanvas::SaveAs(“file.C”) when the plot contains a user defined function produces “file.C” that does not work in ROOT6. This process works in ROOT5 though. Is this a feature or a bug?
A workaround is to use TGraph::TGraph(TF1 *):
TGraph *g = new TGraph(myTF1);
g->Draw(“a,L”);
myCanvas->SaveAs(“exampleCanvas.C”);
Then
root exampleCanvas.C
works and reproduces the plot.
Ok, I have created a simplified version that illustrates what I was trying to do, it’s called example_modified.C (478 Bytes). Running
root -b -q example_modified.C produces two files:
exampleCanvas_does_not_work.C
exampleCanvas_works_fine.C
root exampleCanvas_works_fine.C produces a nice TGraph version of the function
root exampleCanvas_does_not_work.C , on the other hand, says
Error in TF1::TF1: No function found with the signature myTF1(Double_t,Double_t*)
and then it proceeds to say
Error in TClingCallFunc::IFacePtr(kind): Attempt to get interface while invalid.
Error in TClingCallFunc::ExecT: Called with no wrapper, not implemented!
…
~400 times
So my example is different from that of the OP in the sense that it’s implementing the custom function
as Double_t f(Double_t*, Double_t*), where the first argument is the coordinates and the second argument is the parameters. Then the canvas saves the plot using “TF1::SetSavedPoint” method. This used to work fine in ROOT5 but stopped working in ROOT6.
Thank you for providing this example. It is true this feature does not work anymore. It would be great if you could open a JIRA open issue for this and we will try to restore it as soon as possible