Hi
I can’t access the value of pi in root though many tutorials/examples show its active use. I have also tried using TMath::pi
Please read tips for efficient and successful posting and posting code
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided
Dilicus
November 27, 2019, 6:46am
2
Hi,
in root you should use TMath::Pi()
,
Cheers,
Stefano
1 Like
I saw in many examples which used the constant simply by writing ‘pi’. Can you explain that in case?
yus
November 28, 2019, 12:43pm
4
In that screenshot of yours you do not seem to be in a ROOT session, it looks more like a cmd.exe
session.
Can you maybe point us to such example?
yes I had accidentally uploaded the wrong pic, I have corrected it now
couet
November 29, 2019, 8:22am
6
Can you point one of this example ? In such examples the variable pi
should defined somewhere. Have a close look at the code.
The same point is discussed in documentation of Formula that how some names have their const values defined and can not be changed
couet
November 29, 2019, 8:37am
8
Again can you point one of the examples where “pi” is used ? thanks.
This is a snip from the same as mentioned
Please mind the last line
However I cannot yet find the use of pi in any of the examples.
yus
November 29, 2019, 8:59am
10
This was apparently taken from
https://root.cern.ch/doc/master/classTFormula.html
, and it says the following below:
Formula may contain constants, eg:
, where by “Formula” the authors mean “a TFormula
class object”. However, if you simply right pi
in the ROOT prompt, this is not considered a TFormula
class object.
yeah, apparently that would mean that TFormula:: pi would give us the value, right?
I should mention that one way of doing your work is define
auto pi = TMath::Pi(), but that is a different matter altogether.
yus
November 29, 2019, 9:19am
12
No, the pi
is not a member function of TFormula
.
Then how does the page suggest we use it?
There are no clear examples
yus
November 29, 2019, 9:36am
14
You can e.g. construct a TF1
object using operations/functions (including the pi
) defined in TFormula
, for example:
root [0] TF1 *f1 = new TF1("f1", "x*pi" , 0, 5) // pi comes from TFormula
root [1] f1->Draw()
couet
November 29, 2019, 9:37am
15
root [0] auto f1 = new TF2("f2", "2*pi*sqrt(x/y)", 1, 5, 1, 5);
root [1] f2->Draw("surf2")
system
Closed
December 13, 2019, 9:37am
16
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.