Re: Compatibility b/w ROOT types and regular C++ types

From: Vito Di Benedetto <vito.dibenedetto_at_le.infn.it>
Date: Thu, 8 Oct 2009 22:13:44 -0500


  Hi Ali,
 I think you should use

TMath::Pi()

and not

TMath::Pi

in fact:

root [0] TMath::Pi
(const void*)0x1bdc60

root [1] TMath::Pi()
(Double_t)3.14159265358979312e+00

Cheers,

        Vito

Suvayu Ali wrote:
> Hi everyone,
>
> Today I ran into something rather odd. I wanted to use Pi in some ATHENA
> (rel 15.4.0.1 with ROOT 5.22) code, so I tried TMath::Pi.
>
> My code looked something like this,

>>    float delta_phi = fabs(muon_phi - muon_ID_phi);
>>    float delta_phi2 = fabs(2*TMath::Pi - delta_phi);

>
> But on compiling, it kept giving me an error like this,
>>     invalid operands of types `int' and `Double_t ()()' to binary
>> `operator*'

>
> I tried typecasting the TMath::Pi to double, tried putting it in a
> separate line declaring everything as double and still I would get a
> similar error, something like `double and Double_t' instead of `int and
> Double_t'.
>
> So finally I ended up making it work like this,
>>    float delta_phi = fabs(muon_phi - muon_ID_phi);
>>    double pi = acos(-1);
>>    float delta_phi2 = fabs(2*pi - delta_phi);

>
> This is an extremely convoluted way of writing it, and I am uneasy about
> it. So my question is, how should we be using the TMath::Pi? Was I doing
> something extremely stupid?
>
> Thanks for any pointers.
>
Received on Fri Oct 09 2009 - 05:13:49 CEST

This archive was generated by hypermail 2.2.0 : Fri Oct 09 2009 - 05:50:05 CEST