# Different methods for sum of Pt from two particles

**URL:** <https://root-forum.cern.ch/t/different-methods-for-sum-of-pt-from-two-particles/60647>\
**Category:** Newbie\
**Created:** [August 29, 2024, 10:51am UTC](https://root-forum.cern.ch/t/different-methods-for-sum-of-pt-from-two-particles/60647 "2024-08-29T10:51:46Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![4lplusMatt](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/4/b9bd4f/32.png) [@4lplusMatt](https://root-forum.cern.ch/u/4lplusMatt)\
**Post date:** [August 29, 2024, 10:51am UTC](https://root-forum.cern.ch/t/different-methods-for-sum-of-pt-from-two-particles/60647/1 "2024-08-29T10:51:47Z")

</div>

Hello, I’m trying to get the total transverse momentum of a lepton pair and I have two methods giving slightly different answers.

The two methods are:

1. Create vectors for each lepton, combine them and use .Pt()
2. Directly sum the pt values  
The leptons can be electrons or muons, e.g. for muons:

```auto
   //Find pt, eta, phi, energy for muon 1 and 2 (u1 and u2)
   pT_u1 = childl1 -> pt(); pT_u2 = childl2 -> pt();
   eta_u1 = childl1 -> eta(); eta_u2 = childl2 -> eta();
   phi_u1 = childl1 -> phi(); phi_u2 = childl2 -> phi();
   e_u1 = childl1 -> e(); e_u2 = childl2 -> e();

   //Define vectors
   vec_u1 = get_PtEtaPhiEVector(pT_u1, eta_u1, phi_u1, e_u1);
   vec_u2 = get_PtEtaPhiEVector(pT_u2, eta_u2, phi_u2, e_u2);
   vec_l1l2 = vec_u1 + vec_u2;

   //Two methods for the total pt
   pT_l1l2_m1 = vec_l1l2.Pt(); //method 1
   pT_l1l2_m2 = pT_u1 + pT_u2; //method 2

```

The difference between values from the two methods is usually small (\<1%) but can be up to 10%, which seems larger than just a difference in rounding.

Which method is correct?  
Perhaps I am misunderstanding how two transverse momenta should be added, or maybe .Pt() does not do what I expect?  
Any help is appreciated!

All variables are initialized earlier in the code and get\_PtEtaPhiEVector refers to the function:

```auto
// Create PtEtaPhiEVector from doubles
ROOT::Math::PtEtaPhiEVector get_PtEtaPhiEVector(double pT, double eta, double phi, double e){
    ROOT::Math::PtEtaPhiEVector particle_vector(pT, eta, phi, e);
    return particle_vector;
}

```

The documentation for [LorentzVector](https://root.cern.ch/doc/master/classROOT_1_1Math_1_1LorentzVector.html#aa46c0178712b8d34ba30c9823be9c5d2)  
explains .Pt() as “return the transverse spatial component sqrt ( X^2 + Y^2 )”, which seems like it refers to (Px, Py, Pz, E) vectors (apologies if this is something clear from a conversion a different coordinate system)

Cheers,  
Matt

* * *

_ROOT Version:_ 6.28/10  
_Platform:_ lxplus  
_Compiler:_ g++ (GCC) 13.1.0

* * *

---

<div class="post-metadata">

**Author:** ![mdessole](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mdessole/32/34021_2.png) [@mdessole](https://root-forum.cern.ch/u/mdessole)\
**Post date:** [August 29, 2024, 12:11pm UTC](https://root-forum.cern.ch/t/different-methods-for-sum-of-pt-from-two-particles/60647/2 "2024-08-29T12:11:03Z")

</div>

Hello @4lplusMatt,  
welcome on the ROOT forum!  
What computing precision are you using? Can you provide the values of two vectors for which you notice a large difference in the result?  
Cheers,  
Monica

---

<div class="post-metadata">

**Author:** ![4lplusMatt](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/4/b9bd4f/32.png) [@4lplusMatt](https://root-forum.cern.ch/u/4lplusMatt)\
**Post date:** [August 29, 2024, 1:13pm UTC](https://root-forum.cern.ch/t/different-methods-for-sum-of-pt-from-two-particles/60647/3 "2024-08-29T13:13:09Z")

</div>

Hello @mdessole,

Thank you!

I think it is in double since that’s what the LorentzVector class uses. Is there a way I can check?

Here are a couple examples (units are MeV):  
u3u4: Method 1: **15289.7** | Method 2: **17080.1**  
u3u4: Difference: 1790.39 | **%% difference: 10.4823**

e3e4: Method 1: **28563.8** | Method 2: **32903.3**  
e3e4: Difference: 4339.53 | **%% difference: 13.1888**

I also attached the analysis code file and the printed output.  
The calculations take place in lines 317-382 of the analysis file.  
The above examples are lines 44-45 and 386-387 in the output file.

[event-analysis.cxx](https://root-forum.cern.ch/uploads/short-url/rG6px47Y84YRiEsFuuiob0rcbGF.cxx) (28.7 KB)  
[out.txt](https://root-forum.cern.ch/uploads/short-url/1FF2Je0tI3z7j27gvwbj7wo4DYf.txt) (24.2 KB)

Cheers, Matt

---

<div class="post-metadata">

**Author:** ![mdessole](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mdessole/32/34021_2.png) [@mdessole](https://root-forum.cern.ch/u/mdessole)\
**Post date:** [August 29, 2024, 2:15pm UTC](https://root-forum.cern.ch/t/different-methods-for-sum-of-pt-from-two-particles/60647/4 "2024-08-29T14:15:34Z")

</div>

The first method is correct, i.e. `pT_l1l2_m1 = vec_l1l2.Pt()`.

Using `pt, eta, phi, E` coordinates you can’t add vectors like you would do in cartesian coordinates, you have to take into account these relations `x = pt*cos(phi)` and `y = pt*sin(phi)`

---

<div class="post-metadata">

**Author:** ![4lplusMatt](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/4/b9bd4f/32.png) [@4lplusMatt](https://root-forum.cern.ch/u/4lplusMatt)\
**Post date:** [August 30, 2024, 2:39am UTC](https://root-forum.cern.ch/t/different-methods-for-sum-of-pt-from-two-particles/60647/5 "2024-08-30T02:39:01Z")

</div>

Yes here they are:

_1st example_  
**u3 (Pt, Eta, Phi, E): (14128.4, -1.35277, -1.05362, 29151.7,)**  
**u4 (Pt, Eta, Phi, E): (2951.73, 0.959817, -2.31431, 4420.27,)**  
**u3u4 (Pt, Eta, Phi, E): (15289.7, -1.1682, -1.23851, 33571.9,)**  
u3u4: Method 1: 15289.7 | Method 2: 17080.1  
u3u4: Difference: 1790.39 | %% difference: 10.4823

_2nd example_  
**e3 (Pt, Eta, Phi, E): (22339.4, 1.83381, 0.512155, 71681.2,)**  
**e4 (Pt, Eta, Phi, E): (10563.9, 1.09899, -0.608764, 17611.9,)**  
**e3e4 (Pt, Eta, Phi, E): (28563.8, 1.77911, 0.172631, 89293.1)**  
e3e4: Method 1: 28563.8 | Method 2: 32903.3  
e3e4: Difference: 4339.53 | %% difference: 13.1888

---

<div class="post-metadata">

**Author:** ![mdessole](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/mdessole/32/34021_2.png) [@mdessole](https://root-forum.cern.ch/u/mdessole)\
**Post date:** [August 30, 2024, 6:20am UTC](https://root-forum.cern.ch/t/different-methods-for-sum-of-pt-from-two-particles/60647/6 "2024-08-30T06:20:48Z")

</div>

As reported above, you should use the `Pt()` method after summing your vectors, this will work regardless of the coordinate system

---

<div class="post-metadata">

**Author:** ![4lplusMatt](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/4/b9bd4f/32.png) [@4lplusMatt](https://root-forum.cern.ch/u/4lplusMatt)\
**Post date:** [August 30, 2024, 6:37am UTC](https://root-forum.cern.ch/t/different-methods-for-sum-of-pt-from-two-particles/60647/7 "2024-08-30T06:37:23Z")

</div>

Ah ok so the naïve sum was incorrect.

Thank you very much!

Kind regards, Matt
