Reading TTree branch: vector of vectors

Hello,

I have a TTree with the following branches:

HitData.wr_t – Long64_t
HitData.trace – std::vector<Float_t>

“wr_t” and “trace” are members of my own class, HitData, but I want to assume someone can read this tree without need of my software.
On an event-by-event analysis, for every event, there is actually a vector of this HitData class item.

I can access wr_t with: TTreeReaderArray<Long64_t> wr(reader, “HitData.wr_t”);

I try to access trace with: TTreeReaderArray<std::vector<Float_t>> trace(reader, “HitData.trace”);

When looping through the tree, if I print trace.GetSize(); this returns the correct value - the number of HitData items in the event. If I print trace[i].size(), this size is completely incorrect. It seems as if a completely random (large) value is printed.

Am I doing something incorrectly?

To be clear - if I source my software, then I can use TTreeReaderArray hit(reader, “HitData”); and then loop through “hit” on each event, and make use of the Getter methods in my software. But I don’t want to assume that someone will source this software.

TFile::MakeProject

Hm, I tried to make use of this…

void mp()
{
TFile* f = TFile::Open(“run.root”);
f->MakeProject(“traces”, “*”, “RECREATE”);
}

this simply results in the output:
MakeProject has generated 0 classes in traces

In your library, how did you generate the dictionary (what is the content of the linkdef files)?

I’m sorry, I don’t think I understand the question. The MakeProject did not generate the LinkDef file.

In the software used to generate the trees, the DataLinkDef.h looks something like this:

#pragma link C++ class HitData+;

Then something unexpected is going on. In particular MakeProject resulting in no output.

Can you provide first the ROOT file you are trying to look at?

Sure, access here: run_0075_test-merge.root - Google Drive

In this example the principle is as i described although some names changed; the tree is “evt”, the branches are part of a class “LisaCalData”, and I cannot extract trace_febex properly.

I used a macro pretty much identical to my earlier reply to try to generate the “project”.

Start ROOT, but make sure it will NOT load your own (shared) libraries:

root run_0075_test-merge.root

Then execute:

gFile->MakeProject("traces", "*", "recreate++");

Ah, this worked, thank you.