TArrayD in TTreeReaderValue

Hello,

I am interested in reading a TTree composed of objects of type TArray using a TTreeReader and corresponding TTreeReaderValues; however, when I construct a TTreeReader to access the TArray type objects using a TTreeReaderValue every things seems to work until I ask the TTreeReaderValue to “Get()” the TArrayD. On executing function “Get()” the TTreeReaderValue indicates:

Error in <TTreeReaderValueBase::GetBranchDataType()>: Unknown type and class combination: -1, TArrayD
Error in <TTreeReaderValueBase::CreateProxy()>: The branch energy contains data of type {UNDETERMINED TYPE}, which does not have a dictionary.
(TTreeReader::EEntryStatus) (TTreeReader::EEntryStatus::kEntryDictionaryError) : (unsigned int) 6

I’m guessing this is mostly a variable handling issue on my part. Here is a bit of code that I use in the interpreter before the error:

data = new TFile("media_v4/20110727_rmt50457_7200sec_on_face-0003-0x0101_1.00usVetoed.root")
tree = (TTree*)data->Get("eventData")
TTreeReader fReader
fReader.SetTree(tree)
TTreeReaderValue<TArrayD> fEnergy(fReader, "energy")
fReader.SetEntry(10)
fEnergy.Get()

I’m back at work on Wednesday and will look into it soon after!

Axel

For now, I’ve defaulted to using std::vectors in-place of TArray.

Indeed - TTreeReaderArray doesn’t work here. But TTreeReaderValue does (with the quirk that you need to dereference the reader first to get the array, i.e. use (*fReader)[i] or fReader->GetAt(i)). And I now have a test for accessing a TArrayD through a TTreeReaderValue<TArrayD> so this will continue to work :slight_smile:

Given that vector is a superior version of TArrayD please use that, just as you suggested. (I.e. I don’t plan to retrofit support of TArrayD to TTreeReaderArray.)

Thanks!

Axel.

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