Dear ROOT experts,
I created a code that aims to assign the specified value when entry number = -1 to each branch of TTree.
Following this code.
import ROOT as R
from array import array
def TreeClone(input_name, output_name, tree_name, enlist):
fin = R.TFile.Open(input_name)
intree = fin.Get(tree_name)
fout = R.TFile(output_name,'recreate')
run0 = array('i', [0])
intree.SetBranchAddress('run',run0)
outtree = intree.CloneTree(0)
### Set defalut values for branch ###
for i in enlist:
intree.GetEntry(i)
if i>=0:
outtree.Fill()
if i <0:
run0 = -1
outtree.Fill()
fout.Write()
fout.Close()
However, This code requires SetBrachAddress to be performed one branch at a time.
What ideas do you have to make sure that for every branch, a specific value corresponding to the type of the branch is assigned? (e.g. empty vector for vector, -1 for int)
Best regards,
Kosuke Kinoshita