Pyroot fill ttree

Hello,

Here is my code to fill a tree in pyroot

get_var = ROOT.vector(‘float’)(0)
subtree = ROOT.TTree(“subtree”,“subtree”)
subtree.Branch(“var”, “std::vector< float >”, get_var)
for iev in chain:
get_var.push_back(iev.var_value)
subtree.Fill()
subtree.Write()

This works but I want to separate the values in events, meaning I can read the subtree with TChain and loop over events, what should I change here in this case?

Cheers!

Instead of creating a branch of type std::vector<float>, you’d create a branch of type float. You’d then loop over all the values and call Fill() for each and everyone.

Thanks a lot Jakob!