I’ve got a “TF3 *MyTF3 = new TF3(“MyTF3”, …);” (0 parameters, just 3 variables - “x”, “y”, “z”).
How can I draw a “slice” of “MyTF3” for a specific “x” (or “y” or “z”) using the “surf2” option?
Another stupid question is … why do these fail? …
TF2 *f = new TF2(“f”, “MyTF3(x, y, 0)”, -1, 1, -1, 1);
TF2 *f = new TF2(“f”, “MyTF3->Eval(x, y, 0)”, -1, 1, -1, 1);
Muchas gracias de antemano.
To do this you have two options. You pass through a TH3 and then perform the projection on the histogram.
You can create the TH3 using TH3::CreateHistogram(). The number of bins and range will be the ones defined in the function (you can change using TF3::SetNpx(…) or TF3::SetRange ).
Unfortunately there is no method now available to fill the histogram for the TF3, you need to do yourself, by looping on the bins and calling f3(x).
The option is to create a TF2 from the TF3 object, using one of the coordinate as parameter. You need to create s small functor class implemented using the TF3 and use this for creating the TF2.
See root.cern.ch/root/htmldoc/TF1.html#F4 for creating a TFx object using a functor
Thanks for your reply.
There remain the question … why can’t I use my previously defined TF3 when creating another new function?
And another question.
I tried the “TH3” solution - I fill the histogram myself, but then when I try to draw it, I get:
- no points at all if I try ‘MyTH3F->Draw("");’
- black “solid” brick if I try ‘MyTH3F->Draw(“box”);’
- useless grey surface if I try ‘MyTH3F->Draw"(“iso”);’
None of these plots is sensitive to ‘MyTH3F->SetMinimum(…);’ nor ‘MyTH3F->SetMaximum(…);’.
Basically, I would like to draw a surface at “bin contents” equal to “some magic number”, but I haven’t found any “draw option” for something like this.
So, I thought I could simply create a “3D implicit function”:
TF3 *MyTF3 = new TF3(“MyTF3”, “MyTH3F->GetBinContent(MyTH3F->FindBin(x, y, z)) - MyMagicNumber”, 0, 1, 0, 1, 0, 1);
but again, it seems that I can’t use my previously defined TH3F when creating a new function. Why?
The TFormula parser is not a full fledge parser and does not know about object and classes and does not not know about any external variable. In order to do what you are looking for you will need to go via an intermediary C++ function.