# TParticle class extension proposal

**URL:** <https://root-forum.cern.ch/t/tparticle-class-extension-proposal/23739>\
**Category:** Evolution Proposals, Apps & Ideas\
**Created:** [February 12, 2017, 6:10pm UTC](https://root-forum.cern.ch/t/tparticle-class-extension-proposal/23739 "2017-02-12T18:10:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [February 12, 2017, 6:10pm UTC](https://root-forum.cern.ch/t/tparticle-class-extension-proposal/23739/1 "2017-02-12T18:10:59Z")

</div>

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()+fPy_[p.Py](http://p.Py)()+fPz_p.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]

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [February 13, 2017, 3:59pm UTC](https://root-forum.cern.ch/t/tparticle-class-extension-proposal/23739/2 "2017-02-13T15:59:08Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [February 13, 2017, 8:57pm UTC](https://root-forum.cern.ch/t/tparticle-class-extension-proposal/23739/3 "2017-02-13T20:57:27Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [February 14, 2017, 8:13am UTC](https://root-forum.cern.ch/t/tparticle-class-extension-proposal/23739/4 "2017-02-14T08:13:26Z")

</div>

Attached is the new Particle.h with you changes.  
Can you double check before I commit it ?  
Thanks.  
[TParticle.h](https://root-forum.cern.ch/uploads/default/original/2X/b/b36882d578e96e8e8cf438a5d748e3423ed8fe4d.h) (11.5 KB)

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [February 14, 2017, 12:53pm UTC](https://root-forum.cern.ch/t/tparticle-class-extension-proposal/23739/5 "2017-02-14T12:53:27Z")

</div>

Please find attached a slightly improved version (I was able to build ROOT 5 with it).  
[TParticle.h](https://root-forum.cern.ch/uploads/default/original/2X/4/4f2f54c56bfe710735c2cc9f179e42e213b30f05.h) (11.5 KB)

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [February 14, 2017, 1:08pm UTC](https://root-forum.cern.ch/t/tparticle-class-extension-proposal/23739/6 "2017-02-14T13:08:31Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Pepe\_Le\_Pew](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/pepe_le_pew/32/12365_2.png) [@Pepe\_Le\_Pew](https://root-forum.cern.ch/u/Pepe_Le_Pew)\
**Post date:** [February 14, 2017, 1:48pm UTC](https://root-forum.cern.ch/t/tparticle-class-extension-proposal/23739/7 "2017-02-14T13:48:39Z")

</div>

How about “v5-34-00-patches” ❓😉

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [February 14, 2017, 1:52pm UTC](https://root-forum.cern.ch/t/tparticle-class-extension-proposal/23739/8 "2017-02-14T13:52:37Z")

</div>

done
