Nested structure of custom classes

Dear all -

Thank you for your past help… as I progress, I get stuck on the next complexity level :slight_smile:

  1. Problem.
    I would like to record the following structure:
  • I have TMyEvent class that holds TCloneArrays of another class, TMySample
  • Each TMySample holds a certain number of TMyAxis objects, also as TClonesArray (suggestions welcome)
  • each of the TMyAxis holds some data, such as arrays of floats

So my goal is to have:

TMyEvent (nevent, nsample, TClonesArray *fSamples)
               |____ TMySample (sampleid, naxis, TClonesArray *fAxes)
                                            |____TMyAxis (axisid, nchannels, chdata [nchannels] )

You have helped me with the TMyAxis (axisid, nchannels, chdata [nchannels] ) portion and it works.
But now I just tried to do “monkey see / monkey do” approach and extend this to one more nested level with classes… and failing to do so.

I attach the example and the classes definition and the nestedclass.C
It creates the shared object but crashes when I try to add the first TMySample.

Please help me to make such storage structure.
I am not hell-bent on this solution, so if there is a different and more elegant way to achieve the nested structure, I would welcome all suggestions!
I could think this is something common (Event has Jets, each Jet has Tracks, track has particles in them…) I just did not find a good example that would define such structure.

Thank you, best -
nestedclass.h (2.8 KB)
nestedclass.C (2.5 KB)

ROOT Version: 6.20/02
Built for linuxx8664gcc on Mar 15 2020, 15:25:34
From tags/v6-20-02@v6-20-02
Platform:_ Debian 10

The topic is closed,
I did find a good example that I was able to use, by Rene Brun and his Jet class.

Hi Evgeny,
glad to hear that, and sorry for our slow response!