Hi Hamlet, Splitting the STL vector is not yet supported. The current code is broken in a few ways, including the one you point out. We are working on a new implementation. In your case you should use a TClonesArray but make sure that the TClonesArray is at the top level of your hierarchy of classes (i.e. only have one TClonesArray). For example the following set of classes should be split as you expect: #include "TClonesArray.h" class Particle { int t[2]; // index of tracks int pnumber; // some other stuff }; class Reconstruction : public TObject{ Particle p[3]; int rnumber; // some other stuff ClassDef(Reconstruction,1); }; class AllReconstructions { // Reconstruction r[90]; TClonesArray clones; public: AllReconstructions() : clones("Reconstruction",90) {}; }; Cheers, Philippe -----Original Message----- From: owner-roottalk@pcroot.cern.ch [mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Hamlet Sent: Sunday, August 31, 2003 7:09 PM To: roottalk@pcroot.cern.ch Subject: [ROOT] Nestes arrays in trees Hello! I'm trying to create a tree with a branch "AllReconstructions" of this style: class AllReconstructions { Reconstruction r[90] }; class Reconstruction { Particle p[3]; // some other stuff }; class Particle { int t[2]; // index of tracks // some other stuff }; I need to have in a TTree a branch like r.p.t (well, I suppose I'll have to choose smarter names). I've tried many ways. Placing all data of all three objects as simple arrays (like the above), TTree does not unroll classes and I have a lone "r" branch. Placing them directly as TClonesArray (after made them derived from TObject, used macros ClassImp/Def, and using a directive "#pragma link C++ class name;" for each as input for rootcint) and initting them in constructor, like: class Reconstruction: public TObject { TClonesArray p; Reconastruction(): p(Particle::Class(), 3) { /* ... */ } // some other stuff }; the program crashes as I try to allocate the object (new AllReconstructions), it could be a problem of initialization of virtual table (I'm using gcc 3.2.0). Trying to place them as pointers to TClonesArray, the program crashes when unrolling p (it does something with pointers until it calls GetClass() from a null TClonesArray). Using std::vector<> the branches are not unrolled... maybe this is a bug: the constructor TBranchElement(char*, TStreamerInfo *, ...) takes what is between angled brackets as the name of the class in the vector, then asks gROOT if it knows that class; since vector has more template parameters, the name is something as "vector<Particle,allocator<Particle>>", so the resulting name is "Particle,allocator<Particle". Maybe you should make it check for comma too as a terminator, beside ">". Which is the correct combination of containers / place-where-initialize-them / classes-from-which-derive to use to get that branch r.p.t ? is there one? Thanks a lot. -- Hamlet
This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:15 MET