Problem using TTree::Draw command with data in TRefArray

Dear all,

I got an unexpected behaviour when I try to draw data which I stored in a TRefArray of an event class: The resulting histogram doesn’t show the stored data; instead it always shows a single peak at 0. Any help how I can correctly draw the stored data would be highly appreciated.
Please find below more information and a minimal working example.

I constructed my “Event” class following the example of test/Event.h provided by ROOT. My class owns a collection of “Tracks” and a collection of “Hits”. Each hit stores a references to its “parent track” in a TRef. Each track stores references to its “daughter hits” in a TRefArray. Please find attached a minimal working example to produce a ROOT file with random data stored in this event class.

I can successfully compile and run the minimal working example with ROOT 6.02.04 and GCC 4.8.2 with enabled C++11 support.
If I open the produced file test.root in ROOT, I can draw successfully the data of the parent track via:

.L libEvent.so tree->Draw(“event.Hits.ParentTrack.Data”)
When I try to draw the data of the daughter hits via:

.L libEvent.so tree->Draw(“event.Tracks.Hits.Data”)
I get a histogram with a single peak at 0. However, when I read the data of the daughter hits via the script printEvent.C:

.L libEvent.so .L printEvent.C printEvent()
I get non-zero values as expected. Therefore, I assume that the data are correctly stored in the ROOT file. So how can I draw them via TTree::Draw command?

Best regards,
Holger
minimalWorkingExample.tar.gz (3.82 KB)

Dear all,

A short update:
I was able to compile and run the minimal working example also under ROOT 5.34.25, with the same result: TTree->Draw(“event.Tracks.Hits.Data”) still doesn’t show the correct data.

That is also true for TTree->Scan(“event.Tracks.Hits.Data”) it shows no data at all.

An observation which may be useful: The number of instances matches #Tracks/event not (#Tracks*#Hits)/event. I guess for some reason the references to the hits per track is not read, only the tracks per event.

Best regards,
Holger