I am trying to add a branch of (vector of vectors) in an existing tree. I am using PyROOT. While the code runs fine, I do not see the branch properly saved in my updated tree. All values are 0 on the branch. This is the code snippet that I am trying to run:
import os, sys, time from ROOT import * def main(): inputFile = TFile("simpleFile.root","UPDATE") inTree = inputFile.Get("clusters") residualsX = std.vector(std.vector("float"))() residualsX_Br = inTree.Branch("residualsX", residualsX, "std.vector(std.vector('double'))([0)") for ev in inTree: residualsX.clear() for clus in range(ev.pixelIndex.size()): residualsX_Indiv = std.vector("double")() for partIdx in range(ev.particle_local_pos_x_mm[clus].size()): ### calculate residuals for each cluster resXCOG = ev.residual_x_um[clus][partIdx] residualsX_Indiv.push_back(resXCOG) residualsX.push_back(residualsX_Indiv) residualsX_Br.Fill() inTree.Write("", TObject.kOverwrite) inputFile.Write() if __name__ == "__main__": main()
Any lead on what I am doing wrong will be much appreciated.
Thank you very much,
_Compiler: Apple clang version 14.0.0