Reading single leaf of vector<> type

From: Philip Rodrigues <p.rodrigues1_at_physics.ox.ac.uk>
Date: Tue, 19 Oct 2010 16:40:23 -0400


Hi roottalk,
I have a tree with a branch storing a class 'A' containing a vector data member:

class A : public TObject
{
public:
  A();
  double x;
  std::vector<double> v;

  ClassDef(A, 1);
};

I want to access items from the vector v without streaming the whole object off of disk. I can do this for the simple double member (x) via TLeaf, like this:

TLeaf* l_x=tree->FindLeaf("x");
l_x->GetBranch()->GetEntry(someEntry);
double value_read = l_x->GetValue();

but the corresponding code for the "v" branch always gives zero.

How can I access just the data from the v branch? (It must be possible, since TTree::Draw can do it, and I'm sure I've done it before with other files...)

I've attached a test file and macro to show exactly what I'm doing.

Thanks,
Philip

Received on Tue Oct 19 2010 - 22:40:30 CEST

This archive was generated by hypermail 2.2.0 : Mon Oct 25 2010 - 23:50:02 CEST