Hi!
I want to save a small subset of events with a certain branch from a series of rootfiles onto a single new rootfile.
file=0
chain = ROOT.TChain("cbmsim")
path="path/to/files/"
for inputFile in os.listdir(path):
file+=1
if file>3: break
chain.Add(inputFile)
nrOfEvents = chain.GetEntries()
newfile = ROOT.TFile("test.root", "recreate")
newtree = chain.CloneTree(0)
for i in range(nrOfEvents):
chain.GetEntry(i)
if hasattr(chain,"Digitised_Hits"):
newtree.Fill()
newfile.Write()
print('Done')
However, the above code gives me a segmentation fault when cloning the tree. How do I solve this?