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

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Thu, 8 Oct 2009 22:16:15 -0500


Hi,

TMath::Pi is a function. Use:

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

Cheers,
Philippe.

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:16:25 CEST

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