Dear PyROOT,
I am trying to fill a TTree with a collection of values. I have done this in cplusplus with the code below and want to translate it into PyROOT
TTree* tree = new TTree("name", "title");
unsigned int n_tracks = 10;
vector<Double_t>* track_eta = new vector<Double_t>();
// Double_t eta[n_tracks];
tree->Branch("track_eta", &track_eta);
tree->Branch("n_tracks", &n_tracks);
for(unsigned int i=0; i<n_tracks; i++)
track_eta->push_back(1);
tree->Fill();
from what I have found on the forums I need to have something along the lines of
[code]gROOT.ProcessLine(‘struct MyStruct{Int_t n_tracks; vector<Double_t>* track_eta;};’)
tree = TTree(‘eta_bin_tree’, ‘eta_bin_tree’)
from ROOT import MyStruct
s = MyStruct()
tree.Branch(‘n_tracks’, AddressOf(s, ‘n_tracks’), ‘n_tracks/I’)
tree.Branch(‘track_eta’, AddressOf(s, ‘track_eta’), ‘track_eta/D’)
s.track_eta = [1, 1, 1][/code]
but I haven’t been able to get it to work. Can you help?
Regards