Filling branches with STLcollection

David,

you don’t need a “MyStruct” and can set the vector directly. In the example code, the vector pointer of MyStruct should point to an actual vector, so if you want to use such a struct, use a vector object instead and compile rather than use CINT. Use push_back() to add elements to the vector. A vector of doubles is also not a double. List assignment won’t work, but is also not what you want, as it would normally replace the existing vector. Something like this:

[code]from ROOT import *
gROOT.ProcessLine(‘struct MyStruct{Int_t n_tracks; vector<Double_t>* track_eta;};’)
tree = TTree(‘eta_bin_tree’, ‘eta_bin_tree’)

s = MyStruct()
s.track_eta = std.vector(‘double’)()

tree.Branch(‘n_tracks’, AddressOf(s, ‘n_tracks’), ‘n_tracks/I’)
tree.Branch(‘track_eta’, s.track_eta)
for i in [1,1,1]:
s.track_eta.push_back(i)[/code]

Cheers,
Wim