I would like to use the hyperbolic sine function in ROOT. TMath.h has the function ASinH defined, but I can’t seem to get it (or any other functions defined in TMath.h) to work. The error is always that the function is out of scope. What am I doing wrong?
If you look closely in the TMath.h header, you will notice that most of the declarations are in the namespace TMath. So, you either need to call with an explicit namespace qualification:
or, after you have #include’d TMath.h, you need to bring the function signature into scope with a using declaration:
or a using directive:
using namespace TMath;
The former only makes the function ASinH accessible, while the latter brings all identifiers in namespace TMath in to scope. To avoid name clashes down the line, particularly in header files you write, it is generally considered better practice to minimize the number of names you drag in with using directives, and use explicit qualification or using declarations when possible. Exception is sometimes implicitly given for the std namespace, since the identifiers there are “well known” and unlikely to be accidentally reused by authors of other code.
Hope that helps!