# Walkthrough: Calculating our own variables **(10 minutes)** :::::{admonition} Transverse momentum :class: note There are other quantities that we may be interested in apart from the ones already present in the n-tuple. One such quantity is $p_{T}$ which is defined by: :::{math} p_{T} = \sqrt{ p_{x}^{2} + p_{x}^{2} } ::: This is the transverse momentum of the particle, that is, the component of the particle's momentum that's perpendicular to the *z*-axis. ::::: Let's calculate our own values in an analysis macro. Load a fresh copy of that script into your notebook: %load Analyze.py In the **Loop** section, put in the following line: pt = ROOT.TMath.Sqrt(px*px + py*py) :::{admonition} Did that not work? :class: note To get at the variables **`px`** and **`py`**, you have fetch them from the n-tuple with something like `mychain.px`. You also have to have either `import ROOT` or `from ROOT import TMath`. ROOT comes with a very complete set of math functions. You can browse them all by looking at the `TMath` class on the ROOT web site, or Chapter 13 in the [ROOT User's Guide](https://root.cern/root/htmldoc/guides/users-guide/ROOTUsersGuide.html). For now, it's enough to know that `ROOT.TMath.Sqrt()` computes the square root of the expression within the parenthesis "()".[^f95] ::: Test the script to make sure it runs. You won't see any output, so we'll fix that in the next exercise. :::{figure-md} location_sharing-fig :class: align-center xkcd location_sharing by Randall Munroe ::: [^f95]: To be fair, there are Python math packages as well. I could have asked you to do something like this: import math # ... fetch px and py pt = math.sqrt(px*px + py*py) The reason why I ask you to use ROOT's math packages is that I want you to get used to looking up and using ROOT's basic math functions (algebra, trig) in preparation for using its advanced routines (e.g., fourier transforms, multi-variant analysis).