Looping to create new Branches with different data

array('i', [0]) is a 2-bytes signed integer so you need "leafname/S"

array - Efficient arrays of numeric values

TTree → Add a column (“branch”) holding fundamental types and arrays thereof