Filling TNtuple with an array in pyroot

ROOT version 6.12.06

I am fairly new to root and I am using pyroot.
At the end of my calculations I would like to create a TNtuple filled with some of the calculated variables. So I define the TNtuple:

nt = ROOT.TNtuple("nt","nt","mass:ptsquare:nparticles:px:py:pz")

and the try to fill it:

nt.Fill(mass, ptsq, count, momx, momy, momz)

However, px, py and pz are arrays and when I try to run it, I get an error. I believe it is to do with the fact that those variables are arrays, since it tells me that a float is required.
Is there a way to Fill a TNtuple with arrays? Do I have do define them differently?

Thanks in advance!

Hi Naomi,
you cannot use TNtuple in that case: it is a data structure to represent “flat ntuples”.
A solution could be TDataFrame, more specifically this example.


1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.