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

From: Suvayu Ali <fatkasuvayu_at_gmail.com>
Date: Thu, 8 Oct 2009 19:59:38 -0700


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.

-- 
Suvayu

Open source is the future. It sets us free.
Received on Fri Oct 09 2009 - 04:59:49 CEST

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