# Transverse mass calculaton with TLorentzVector gives wrong results

**URL:** <https://root-forum.cern.ch/t/transverse-mass-calculaton-with-tlorentzvector-gives-wrong-results/55048>\
**Category:** Newbie\
**Tags:** root\
**Created:** [May 26, 2023, 10:06am UTC](https://root-forum.cern.ch/t/transverse-mass-calculaton-with-tlorentzvector-gives-wrong-results/55048 "2023-05-26T10:06:08Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![helton](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/8797f3/32.png) [@helton](https://root-forum.cern.ch/u/helton)\
**Post date:** [May 26, 2023, 10:06am UTC](https://root-forum.cern.ch/t/transverse-mass-calculaton-with-tlorentzvector-gives-wrong-results/55048/1 "2023-05-26T10:06:09Z")

</div>

Hi all,  
I have the following question: Why does the .Mt() value from TLorentzVector give me a different result for the mass distribution of the W boson than the known short formula for 2 leptons? The formula gives me a peak at around 80 GeV which is correct, but the value from the TLorentzVector gives me a peak at around 130 GeV. This is the code I have:

```auto
   int n_el = el_pt.GetSize();
   for (int i=0; i < n_el; i++){
		if(el_pt[i]/1000 > 27 && *met_met/1000 > 30){	     
   		TLorentzVector P_elec;
		 TLorentzVector P_neut;
                 P_elec.SetPtEtaPhiM(el_pt[i]/1000, el_eta[i], el_phi[i], 0); //pt in GeV
      	         P_neut.SetPtEtaPhiM(*met_met/1000, 0, *met_phi, 0);  

                //Calculation of W_mT
                Double_t deltaPhi = TMath::Abs(el_phi[i] - *met_phi); 
                Double_t CosdeltaPhi = TMath::Cos(deltaPhi);

                 Double_t W_mT _1= TMath::Sqrt(2.0 * el_pt[i]/1000 * (*met_met)/1000 * (1.0 - CosdeltaPhi));  
		 Double_t W_mT_2 = (P_elec + P_neut).Mt();
      }
   }

```

Thanks!

---

<div class="post-metadata">

**Author:** ![vpadulan](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/vpadulan/32/25315_2.png) [@vpadulan](https://root-forum.cern.ch/u/vpadulan)\
**Post date:** [May 30, 2023, 8:47am UTC](https://root-forum.cern.ch/t/transverse-mass-calculaton-with-tlorentzvector-gives-wrong-results/55048/2 "2023-05-30T08:47:34Z")

</div>

Hi @helton ,

Maybe @moneta has a clue about this.

Cheers,  
Vincenzo

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [May 30, 2023, 3:39pm UTC](https://root-forum.cern.ch/t/transverse-mass-calculaton-with-tlorentzvector-gives-wrong-results/55048/3 "2023-05-30T15:39:36Z")

</div>

Hi,  
You are referring to 2 different definitions, see for example: [Transverse mass - Wikipedia](https://en.wikipedia.org/wiki/Transverse_mass)

`TLorentzVector` and the recomended to use `ROOT::Math::LorentzVector` returns as `Mt` the transverse mass of a particle defined as `sqrt(M2 + Pt2)`, and it is always greater than M, while the other formula computes the transverse mass of a 2 -particle system, which is a different definition as shown in the linked Wikipedia article.

Best regards,

Lorenzo

---

<div class="post-metadata">

**Author:** ![helton](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/8797f3/32.png) [@helton](https://root-forum.cern.ch/u/helton)\
**Post date:** [May 31, 2023, 9:37am UTC](https://root-forum.cern.ch/t/transverse-mass-calculaton-with-tlorentzvector-gives-wrong-results/55048/4 "2023-05-31T09:37:29Z")

</div>

Hi Lorenzo,

I see, thanks for the clarification. Since only the second formula gives me the “right” result (aka the right mass) I wonder; If I wanted to calculate the transverse mass where say a lepton, neutrino and a jet or so are involved, so in total 3 “particles”, I cant really analytically calculate a formula like in the 2 particle case. What do I do then?

Greetings

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [May 31, 2023, 10:05am UTC](https://root-forum.cern.ch/t/transverse-mass-calculaton-with-tlorentzvector-gives-wrong-results/55048/5 "2023-05-31T10:05:13Z")

</div>

The second formula is used when you have invisible decays (e.g. W decays) and you have then a quantity that is sensible to the mass of the original particle (W). I guess you can probably build a similar formula in case of a 3 body decays, but I don’t know the analytical form/

Best,

Lorenzo

---

<div class="post-metadata">

**Author:** ![helton](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/8797f3/32.png) [@helton](https://root-forum.cern.ch/u/helton)\
**Post date:** [May 31, 2023, 12:26pm UTC](https://root-forum.cern.ch/t/transverse-mass-calculaton-with-tlorentzvector-gives-wrong-results/55048/6 "2023-05-31T12:26:52Z")

</div>

When I try to use LorentzVector instead of TLorentzVector I get a weird error in the header files that it cant find for example #include \<Math/Vector4D.h\> or Math/GenVector/PxPyPzE4D.h’. Are these outdated headers?

I am using ROOT 6.24/08 on a analysis facility for ATLAS so it should be setup correctly

Greetings

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [May 31, 2023, 2:53pm UTC](https://root-forum.cern.ch/t/transverse-mass-calculaton-with-tlorentzvector-gives-wrong-results/55048/7 "2023-05-31T14:53:09Z")

</div>

HI,  
This is strange, the headers should be installed as the other ROOT headers. How are you building the code ?

Lorenzo

---

<div class="post-metadata">

**Author:** ![helton](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/8797f3/32.png) [@helton](https://root-forum.cern.ch/u/helton)\
**Post date:** [June 2, 2023, 9:35am UTC](https://root-forum.cern.ch/t/transverse-mass-calculaton-with-tlorentzvector-gives-wrong-results/55048/8 "2023-06-02T09:35:43Z")

</div>

Not sure if I understand the question. But I made a file with MakeSelector(). But doesnt matter if I add it in the .h or the .C file it doesnt seem to find it.

Greetings

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [June 2, 2023, 10:20am UTC](https://root-forum.cern.ch/t/transverse-mass-calculaton-with-tlorentzvector-gives-wrong-results/55048/9 "2023-06-02T10:20:50Z")

</div>

Nut how are you compiling the code made from MakeSelector() ? Or are you using the code directly from the ROOT prompt ? In this last case you don’t need to add any include files

Lorenzo

---

<div class="post-metadata">

**Author:** ![helton](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/8797f3/32.png) [@helton](https://root-forum.cern.ch/u/helton)\
**Post date:** [June 2, 2023, 11:41am UTC](https://root-forum.cern.ch/t/transverse-mass-calculaton-with-tlorentzvector-gives-wrong-results/55048/10 "2023-06-02T11:41:40Z")

</div>

I just save the .C file and run it with -\>Process(… .C) from the prompt

Greetings

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [June 2, 2023, 3:20pm UTC](https://root-forum.cern.ch/t/transverse-mass-calculaton-with-tlorentzvector-gives-wrong-results/55048/11 "2023-06-02T15:20:41Z")

</div>

Hi,  
Ah I see, this is an old way to process a TTree. But what is happening if you are just doing at the ROOT prompt:

```auto
root [1] #include "Math/Vector4D.h"

```

?

---

<div class="post-metadata">

**Author:** ![helton](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/8797f3/32.png) [@helton](https://root-forum.cern.ch/u/helton)\
**Post date:** [June 5, 2023, 9:08am UTC](https://root-forum.cern.ch/t/transverse-mass-calculaton-with-tlorentzvector-gives-wrong-results/55048/12 "2023-06-05T09:08:26Z")

</div>

Hi,

even when I do that it gives me: ROOT\_prompt\_3:1:10: fatal error: ‘Math/Vector4D.h’ file not found  
#include “Math/Vector4D.h”

---

<div class="post-metadata">

**Author:** ![moneta](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/moneta/32/19423_2.png) [@moneta](https://root-forum.cern.ch/u/moneta)\
**Post date:** [June 5, 2023, 9:33am UTC](https://root-forum.cern.ch/t/transverse-mass-calculaton-with-tlorentzvector-gives-wrong-results/55048/13 "2023-06-05T09:33:22Z")

</div>

Strange, which ROOT version are you using ?

---

<div class="post-metadata">

**Author:** ![helton](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/8797f3/32.png) [@helton](https://root-forum.cern.ch/u/helton)\
**Post date:** [June 7, 2023, 12:37pm UTC](https://root-forum.cern.ch/t/transverse-mass-calculaton-with-tlorentzvector-gives-wrong-results/55048/14 "2023-06-07T12:37:40Z")

</div>

I am using ROOT 6.24/08

---

<div class="post-metadata">

**Author:** ![cxclrfx](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/cxclrfx/32/38524_2.png) [@cxclrfx](https://root-forum.cern.ch/u/cxclrfx)\
**Post date:** [October 8, 2026, 5:23pm UTC](https://root-forum.cern.ch/t/transverse-mass-calculaton-with-tlorentzvector-gives-wrong-results/55048/15 "2026-10-08T17:23:03Z")

</div>

Hi,

I worked through the neutrino longitudinal-momentum reconstruction discussed in this thread and implemented a complete reproducible treatment of the problem.

For the decay

W \rightarrow \mu\nu,

the measured transverse missing momentum determines the transverse neutrino components,

p\_x^\nu=p\_T^\nu\cos\phi\_\nu, \qquad p\_y^\nu=p\_T^\nu\sin\phi\_\nu,

while the longitudinal component p\_z^\nu remains unknown.

Imposing the fixed-W-mass constraint

(p\_\mu+p\_\nu)^2=M\_W^2

reduces the problem to a quadratic equation for p\_z^\nu.

Define

A= \frac{M\_W^2-m\_\mu^2}{2} + \vec p\_T^{\,\mu}\cdot\vec p\_T^{\,\nu},

and

E\_{T\mu}^2=m\_\mu^2+(p\_T^\mu)^2.

Then the two longitudinal solutions are

p\_{z\nu}^{\pm} = \frac{ A\,p\_{z\mu} \pm E\_\mu \sqrt{ A^2-E\_{T\mu}^2(p\_T^\nu)^2 } }{ E\_{T\mu}^2 }.

The corresponding reduced discriminant is

D= A^2-E\_{T\mu}^2(p\_T^\nu)^2.

The useful part is that this discriminant can be factorized directly through the transverse mass:

D= \frac14 \left(M\_W^2-m\_T^2\right) \left[M\_W^2-m\_T^2+ 4E\_{T\mu}p\_T^\nu \right].

For the physical domain of the reconstruction, the second factor is positive, so the complete real-solution structure follows directly from m\_T:

m\_T\<M\_W \quad\Longrightarrow\quad D\>0 \quad\Longrightarrow\quad 2\ \text{real }p\_z^\nu\text{ solutions},

m\_T=M\_W \quad\Longrightarrow\quad D=0 \quad\Longrightarrow\quad 1\ \text{tangent/repeated solution},

m\_T\>M\_W \quad\Longrightarrow\quad D\<0 \quad\Longrightarrow\quad 0\ \text{real solutions under the exact fixed-mass constraint}.

An important implementation detail is that I retain both real longitudinal branches rather than silently selecting one of them.

Each returned solution is also checked against the original unsquared equation,

E\_\mu \sqrt{(p\_T^\nu)^2+(p\_z^\nu)^2} - p\_{z\mu}p\_z^\nu = A,

rather than validating the roots only against the squared quadratic equation.

This also gives a precise interpretation of the negative-discriminant case: D\<0 does not by itself mean that the recorded event is unphysical. It means that the measured transverse state is incompatible with the selected exact fixed-W-mass constraint for every real value of p\_z^\nu.

I tested the implementation over the complete 100,000-event CMS Open Data W\rightarrow\mu\nu sample.

Using M\_W=80.3625 GeV, the reconstruction classified:

- 88,243 events with two real longitudinal neutrino solutions;
- 0 events inside the numerical tangent band;
- 11,757 events with no real longitudinal solution under the exact fixed-mass constraint.

The implementation also includes regression tests, direct mass-shell checks, numerical treatment near the discriminant boundary, stable evaluation of the quadratic roots, and a separate high-precision verification.

The complete implementation and reproduction material are publicly available in my GitHub repository named:

[`Neutrino-Longitudinal-Momentum-Reconstruction`](https://github.com/cxclrfx/Neutrino-Longitudinal-Momentum-Reconstruction)

Independent technical review, reproduction, or criticism of the derivation and numerical treatment is welcome.
