TTree : Read TLeaf filled std::vector


I’m sorry to post this but I’ve been searching in roottalk for more than 3 hours a solution and what i found never worked for me.
I’d like to access data stored in a TTree, without makeclass, or makeselector, by reading interesting leaves.
I’ve easily found the way to do it for leaf filled with int or double, but the ones filled with vector are still resisting…

the solution propose here :

didn’t make it in my case.
I’m joining a dummy example of what i’d like to get (C-macro and root file)
I’ve tried many things : cast leaf to leafElement to use TBranchElement’s method, use the address of leaves… The lastest solution actually works as shown in the dummy example, but i’d like to know whether there might be a cleaner way to do so.

toto.root (224 KB)
TheReader.C (803 Bytes)


In your simple case, the best is to do:

[code]gROOT->ProcessLine("#include "); // Make sure the dictionary for vector<Float_t> is loaded

vector<Float_t> *values = 0;
physics->SetBranchAddress(“el_pt”,&values);[/code]and use the std::vector interface to look at the content of the vector pointed to by ‘values’.