TTree not filled with object with TClonesArray* data member

Hello,

I’m experiencing some problems trying to fill a TTree with an object which has a pointer to a TClonesArray as a data member, using ROOT 5.34/02. I’ve tried to follow the $ROOTSYS/test example of Event class as much as possible.

The program crashes at run time with a message as the following:

libc++abi.dylib: terminate called throwing an exception
Abort trap: 6

The line where it crashes is where the tree is filled inside the loop:

for (int ev = 0; ev <100; ev++) { event->AddLightHit("whatever"); t.Fill(); event->Clear(); }

I’ve tried to use the ConstructedAt() method of TClonesArray class to add content to my TClonesArray, but that caused a crash. Thus, I passed to the older version, which works fine, until I try to fill a TTree.

I attach a .zip file where you can find the simple program I’m using and the library where the class Event lives. In order for the program to compile, the following environment variables need to be set (beyond the usual ROOT ones):

export MYLIB_BASEDIR= test/mylib
export MYLIB_INCDIR=$MYLIB_BASEDIR/include
export MYLIB_LIBDIR=$MYLIB_BASEDIR/lib

export PATH=$PATH:$MYLIB_BASEDIR/bin
export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:$MYLIB_LIBDIR

Thank you very much for any help.
test.zip (28.9 KB)

Hi again,

I’ve found the problem. Apparently, it was a wrong initialization of a data member of the class which fills the TClonesArray. In particular, it was a string that was set to 0, instead to a string value.
Now it works fine, and also the ConstructedAt() method does.

Thank you very much

Paola