TParticle class extension proposal

I would like to propose that the TParticle class gets new methods (this should be fully backwards compatible so no need to change the class version): [code]public :
Double_t Ek() const { return fE-fCalcMass; }

Double_t PhiP(const TParticle &p) // the angle between mommenta of particles
{
Double_t v = P()p.P();
if (v == 0) v = 1; else v = (fPx
p.Px()+fPyp.Py()+fPzp.Pz())/v;
if (v > 1) v = 1; else if (v < -1) v = -1; // just a precaution
return TMath::ACos(v);
}

Double_t PhiX() const { return TMath::Pi()+TMath::ATan2(-fPy,-fPz); } // note that PhiX() returns an angle between 0 and 2pi
Double_t PhiY() const { return TMath::Pi()+TMath::ATan2(-fPz,-fPx); } // note that PhiY() returns an angle between 0 and 2pi
Double_t PhiZ() const { return Phi(); } // note that PhiZ() returns an angle between 0 and 2pi
Double_t ThetaX() const { return (fPx==0)?TMath::PiOver2():TMath::ACos(fPx/P()); }
Double_t ThetaY() const { return (fPy==0)?TMath::PiOver2():TMath::ACos(fPy/P()); }
Double_t ThetaZ() const { return Theta(); }

Double_t GetPolarTheta() const { return fPolarTheta; }
Double_t GetPolarPhi() const { return fPolarPhi; }
void GetPolarisation(Double_t &theta, Double_t &phi) const { theta = fPolarTheta; phi = fPolarPhi; }

void SetPolarTheta(Double_t theta) { fPolarTheta = theta; }
void SetPolarPhi(Double_t phi) { fPolarPhi = phi; }
void SetPolarisation(Double_t theta, Double_t phi) { fPolarTheta = theta; fPolarPhi = phi; }[/code]

I agree this sounds like small changes.
Do you want do submit a pull request so will properly acknowledged in the history ?
I guess you want also has those back ported to Root 5 ?

I improved my proposal a bit (I also needed to comment out three methods as ROOT 5 “libEG” is not linked against “libPhysics”).

Please take this code (I don’t think there is any need for a special pull request).

Attached is the new Particle.h with you changes.
Can you double check before I commit it ?
Thanks.
TParticle.h (11.5 KB)

Please find attached a slightly improved version (I was able to build ROOT 5 with it).
TParticle.h (11.5 KB)

I just pushed the new version of TParticle.h to the ROOT master. Thanks.

How about “v5-34-00-patches” :question: :wink:

done