TTree::Draw()/Scan() with deeply nested std::vectors

From: Stan Seibert <>
Date: Tue, 15 Nov 2005 09:25:43 -0600

I recently stumbled on a problem using TTree::Draw()/TTree::Scan() with a TTree that contains a branch of objects with deeply nested vectors.

For example, I have a branch in my TTree which contains C1 objects. Each C1 object contains a vector of C2 objects, and each C2 object contains a vector of C3 objects, and each C3 object contains a vector of C4 objects. If I try to Draw() or Scan() a member variable in C1, C2, or C3, I get the expected behavior. (That is, it iterates over all the nested lists down to the variable I have requested.)

However, if I try to Draw() or Scan() a member of C4, I receive the following error:

Error in <TTreeFormula::DefinedVariable>: foo4 is not a datamember of vector<C4>

*ERROR 30 :
Bad numerical expression : "c1.c2.c3.c4.foo4"

This is curious, since foo4 is a member of C4, but clearly not a member of vector<C4>. I can confirm this behavior on ROOT 4.04.02g and 5.06.00.

I have attached a simplified script which reproduces this error. Since it uses vectors of user-defined objects, you have to run it with ACLiC:

root nest.C+

Stan Seibert

  • application/octet-stream attachment: nest.C
Received on Tue Nov 15 2005 - 16:26:05 MET

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:13 MET