Please read tips for efficient and successful posting and posting code
Please fill also the fields below. Note that root -b -q will tell you this info, and starting from 6.28/06 upwards, you can call .forum bug from the ROOT prompt to pre-populate a topic.
ROOT Version: 6.40.04
Platform: macosxarm64
Compiler: Apple clang version 21.0.0 (clang-2100.1.1.101) std202002
I am trying to use TF12 to create projections of a TF2, and it doesn’t seem to work as documented. I have made a very simple example which I have posted below. I have a simple 2D function with 2 parameters. I want to make one projection, change a parameter, and make another projection. The documentation says you have to use DrawCopy to accomplish this task. This doesn’t seem to work. Also the title of the graph says “x=2” even though it should say “y=2” but that is a minor annoyance. I don’t understand why I don’t see a second line in the canvas. Any help instructing me in the ways of TF12 will be appreciated!
To run the example: Load (.L) this code into root and then “plot_func()”.
double my_func(double *args, double *parms){
double x = args[0];
double y = args[1];
double a = parms[0];
double b = parms[1];
return a*x + b*y*y;
}
void plot_func(){
TF2 *my_tf2 = new TF2("my_tf2", my_func, 0., 2., 0., 4., 2);
my_tf2->SetParameter(0,1.0);
my_tf2->SetParameter(1,2.0);
TF12 *my_tf12_x = new TF12("my_tf12_x", my_tf2, 2., "x");
auto *can = new TCanvas();
my_tf12_x->SetLineColor(1);
my_tf12_x->DrawCopy("f");
my_tf2->SetParameter(0,0.5);
my_tf12_x->SetLineColor(3);
my_tf12_x->DrawCopy("same");
}
```