Limit on number of TNtuple arguments in pyROOT

In pyROOT, there is a limit of 15 arguments for TNtuple, while in regular ROOT, there’s no such limit. Is there a way to bypass this limit? Here is a simple code to reproduce the issue:

 import ROOT
 a = ROOT.std.vector('<float>')()
 a.push_back(1)
 a.push_back(2)
 a.push_back(3)
 a.push_back(4)
 a.push_back(5)
 a.push_back(6)
 a.push_back(7)
 a.push_back(8)
 a.push_back(9)
 a.push_back(10)
 a.push_back(11)
 a.push_back(12)
 a.push_back(13)
 a.push_back(14)
 a.push_back(15)
 a.push_back(16)

 nt = ROOT.TNtuple('nt', '', 'a1:a2:a3:a4:a5:a6:a7:a8:a9:a10:a11:a12:a13:a14:a15:a16')
 nt.Fill(*a)

The error message is:

TypeError: takes at most 15 arguments (16 given)
int TNtuple::Fill(const float* x) =>
TypeError: takes at most 1 arguments (16 given)

You can use a TTree instead of TNtuple. Search for the pyROOT example in the documentation to see how to have a vector or array branch.

Found a solution to bypass this limit. One can define the TNtuple in python but fill it in a c++ macro and that turns out working fine.

nt.Fill(a.data())

1 Like

nice. This is a way better solution than involving c++ macro. Thanks

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