I was calculating beta from LorentzVector assuming that it returns 3 components of the beta (for each component of momentum) like this:
TVector3 beta = beam.Beta();
It compiles and run. It prints 3-components of the beta but it gives non-zero x-component although it supposed to give non-zero z-component. Then, I looked it the TLoretzVector function and found that Beta() supposed to return double value. So, the compiler should have shown error, but not. Is it related with compiler or some thing with root. I am using gcc version 4.1.2 with root 5.27.
I saw same thing even if I compile with ACLIC and run.
yikes, that’s unfortunate. There is a constructor TVector3::TVector3(Double_t x = 0.0, Double_t y = 0.0, Double_t z = 0.0) which gets picked, and x is set to the return value of Beta(). We would be better off having
TVector3::TVector3()
TVector3::TVector3(Double_t x, Double_t y, Double_t z)
but now it’s probably too late and this change would break some code. Anyway: now you know why your code was legal C++.