Unable to readback "simple" root file with nested vectors

My ROOT tree contains vectors that are obviously of bogus length when I look at things with TTree::Process. But when I double click on the same leaves in a TBrowser window everything appears as it should be. I’m using ROOT 6/10/2.

I’ve created a root file with a TTree in it that uses a genreflex dictionary to load some plane (and fairly simple C structures) into the TTree. Opening it in ROOT, I can examine the tree with TBrowser, and even look at the various leaves. In particular, “VMEBranch.tdc_readouts.tdc_tdc_hits.channel_number”. This works just fine - the histogram is plotted, and the expected data is present.

But the problem comes when I use MakeSelector. There, when I attempt to examine the same channel_number, I see a huge number for the number of TDC hits in each event (rather than one or 3 or similar).

These files apparently require a dictionary - the self describing format in root 6/10/2 doesn’t have good enough fidelity to deal with this (I get bad_alloc exceptions).

Attached is a root file with 10 events: run_0000000276.root (12.0 KB)

the attached file readout.hh contains the complete data structure description - the top level (written out) object is VMEReadout: readout.hh (2.6 KB)

The commands to build the .so that contains the dictionary from this header file is:
genreflex readout.hh mathusla2root/VMEReadoutFlat.h -s sel.xml -o readout_rflx.cxx --rootmap libMATHUSLAReadout.rootmap --rootmap-lib libMATHUSLAReadout
g++ -c -Wall -Wextra -DLINUX $(shell root-config --cflags) -std=c++17 -fPIC readout_rflx.cxx -o readout_rflx.o
g++ readout_rflx.o -shared -o libMATHUSLAReadout.so

The sel file - renamed as .txt so that it can be attached here (you’ve disabled the attachment of xml files): sel.txt (479 Bytes)

And finally, the MakeSelector I was using. Look at the cout for the “.size()” item. That is the one that gives an error: LookAtTDCHits.h (3.6 KB)
LookAtTDCHits.C (3.3 KB)

The output I see is:
root [0] gSystem->Load("bin/libMATHUSLAReadout.so")
(int) 0
root [1] TFile *f = TFile::Open("run_0000000276.root")
(TFile *) 0x2dc0d00
root [2] MATHUSLA_EventData->Process("LookAtTDCHits.C", "", 10)
 -> TDC Hit List (6148914691236517204)
 -> TDC Hit List (18446744073530594644)
 -> TDC Hit List (12297829382115120468)
 -> TDC Hit List (6148914690699646292)
 -> TDC Hit List (18446744072993723732)
 -> TDC Hit List (12297829381578249556)
 -> TDC Hit List (6148914690162775380)
 -> TDC Hit List (18446744072456852820)
 -> TDC Hit List (12297829381041378644)
 -> TDC Hit List (6148914689625904468)
(long long) 0
root [3] .q

Obviously, those numbers in paren are bogus. Many thanks in advance!

It looks like by marking each vector in my output object as do-not-split, it works fine. So something about the splitting is causing it to fail.

TTreeReaderArray has problems with nested collections :frowning: We need to warn about this - and fix it. I have created https://sft.its.cern.ch/jira/browse/ROOT-9250 to keep track. TDataFrame needs it, too - so this will happen in the coming months.

Thanks! I’ll mark this as the answer - but to see if the problem is fixed you’ll need to follow the bug report to see when it is closed!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.