# Invariant mass reconstruction

**URL:** <https://root-forum.cern.ch/t/invariant-mass-reconstruction/56848>\
**Category:** Newbie\
**Tags:** root\
**Created:** [October 25, 2023, 10:18am UTC](https://root-forum.cern.ch/t/invariant-mass-reconstruction/56848 "2023-10-25T10:18:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manisha\_Rana](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/manisha_rana/32/34574_2.png) [@Manisha\_Rana](https://root-forum.cern.ch/u/Manisha_Rana)\
**Post date:** [October 25, 2023, 10:18am UTC](https://root-forum.cern.ch/t/invariant-mass-reconstruction/56848/1 "2023-10-25T10:18:08Z")

</div>

i have created 1000 events for each event there are produced particles and i have set Px , Py, Pz for all those with the help of poisson distribution. and mass with then help of grandom now i want to reconstruct mass of dimuon using lorentz vector, how i can do?

---

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [October 25, 2023, 11:53am UTC](https://root-forum.cern.ch/t/invariant-mass-reconstruction/56848/2 "2023-10-25T11:53:00Z")

</div>

Hi, welcome to the ROOT forum!

You can take a look at this RDataFrame tutorial for an example analysis with invariant masses:  
[https://root.cern.ch/doc/master/df106\_\_HiggsToFourLeptons\_8py.html](https://root.cern.ch/doc/master/df106__HiggsToFourLeptons_8py.html)

The key part is this one:

```c++
    ROOT::Math::PtEtaPhiEVector p1(pt[0], eta[0], phi[0], e[0]);
    ROOT::Math::PtEtaPhiEVector p2(pt[1], eta[1], phi[1], e[1]);
    ROOT::Math::PtEtaPhiEVector p3(pt[2], eta[2], phi[2], e[2]);
    ROOT::Math::PtEtaPhiEVector p4(pt[3], eta[3], phi[3], e[3]);
    return (p1 + p2 + p3 + p4).M() / 1000;

```

So you use your kinematic variables to build Lorentz vectors, which you sum and then you get the invariant mass with `.M()`.

Note that since, you have Px, Py, Pz, you need to use the `ROOT::Math::PxPyPzMVector` instead (I presume that you either have the mass available too, or you’re going to assume that the particles are massless).

---

<div class="post-metadata">

**Author:** ![Manisha\_Rana](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/manisha_rana/32/34574_2.png) [@Manisha\_Rana](https://root-forum.cern.ch/u/Manisha_Rana)\
**Post date:** [October 26, 2023, 5:59am UTC](https://root-forum.cern.ch/t/invariant-mass-reconstruction/56848/3 "2023-10-26T05:59:15Z")

</div>

How i can choose these p1, p2 vector among all of available vector that i have constructed?

---

<div class="post-metadata">

**Author:** ![jonas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/jonas/32/24756_2.png) [@jonas](https://root-forum.cern.ch/u/jonas)\
**Post date:** [October 26, 2023, 10:42am UTC](https://root-forum.cern.ch/t/invariant-mass-reconstruction/56848/4 "2023-10-26T10:42:01Z")

</div>

That depends, how did you construct the vectors, and how do you want to select them? Are you using RDataFrame?

Your question is a bit too vague to be answered, maybe it helps if you explain again more concisely and attach your code so we understand better what you mean?
