ROOT Classes in Python

Hey, all! I’ve been working in Python 3.x a lot and am in the process of reproducing many functions native to ROOT but in a numpy/pandas format. Most things I’m doing (going over StPico files for STAR analysis) are pretty straightforward, but one is eluding me: mass.

I’d like to get mass natively in Python, but I’m having trouble finding exactly how we get the mass parameter for a track in ROOT. Any idea where I can find this? I tried looking in the ROOT manual, but I was unsuccessful.

As an example, here’s how I get vertex positions for an event and then calculate v_r (where “data” is imported from a STAR pico file using upROOT):

    vX = np.hstack(np.asarray(data["Event"]["Event.mPrimaryVertexX"].array()))
    vY = np.hstack(np.asarray(data["Event"]["Event.mPrimaryVertexY"].array()))
    vZ = np.hstack(np.asarray(data["Event"]["Event.mPrimaryVertexZ"].array()))
    vR = np.power((np.power(vX, 2)+np.power(vY, 2)), (1/2))

Thanks!


ROOT Version: 6.14/02
Python Version: 3.7


Perhaps @Axel knows the answer (or knows who knows)?

I don’t understand the question. Are you asking “what is a lorentz vector”?

I’m asking where the code lives in ROOT that determines particle mass (or, even better, what that code is). I’m trying to duplicate its functionality in Python natively. Right now, I had something running like:

m_squared = np.divide(np.multiply(p_squared, g_squared), b_squared)

Where “p_squared” is the track momentum magnitude squared, “g_squared” is 1/gamma squared, and “b_squared” is beta squared.

It appears to be correct, but I’m trying to make sure I’m not doing something that’s different than what ROOT does to avoid inconsistencies.

There’s a module in upROOT called “vector” which works for these purposes; it’s new in uproot4 (running with awkward1.0). Anyone interested can check it out here. I’m marking this as solved.

Thanks!