I am using a simple python script to loop over large ROOT files (a total of around 20 GB) and store the weights. At some point the process is killed because of large memory consumption (I suppose!). Here’s the script:
Files = sorted(glob(os.path.join(os.getcwd() , "*.root")))
wtlist = []
for rootFile in Files:
chain = TChain("Delphes")
chain.Add(rootFile)
treeReader = ROOT.ExRootTreeReader(chain)
numberOfEntries = treeReader.GetEntries()
branchEvent = treeReader.UseBranch("Event")
for entry in range(0, numberOfEntries):
treeReader.ReadEntry(entry)
if branchEvent.GetEntries() > 0:
event = branchEvent.At(0)
wtlist.append(event.Weight)
I am using the ExRootTreeReader since I couldn’t find another way of reading the weights from the tree.
What could be causing the problem?
Thanks @pcanal
In this form, the list “wtlist” only contains the weights of one file (last ROOT file). I want to store the weights of all ROOT files in the directory.