TTreeReaderValue & Objects

Dear ROOTers,

I started playing around with TTreeReader, TTreeReaderValue classes and, doing so, I hit a problem when the branch type is an object (no problem with simple data types).

My TTreeReader complains while reading the first event from the tree with the following message

I had a look into the branch and the branch type is -1 indeed, which TTreeReaderValueBase::GetBranchDataType doesn’t seem to like when reading data in.
Is this somehow expected? Or, most likely, have I done something wrong while building my test tree?

I’ve attached my dummy tree maker and the TTreeReader test code. I compiled it against ROOT 6.02/04

Thanks in advance!
-a
readerTest.cxx (2.82 KB)
makeATree.cxx (1.14 KB)

After some more digging into the code it turns out that TTReaderValue doesn’t play well (yet) with some good ole ROOT classes, like TVector3, that have a custom streamer. No problem observed with other, newer objects

I assume the use of TVector3 objects in TTreeReader was solved already, but I am not able to access them correctly. Access to simple float and integer variables in the root tree works fine.

Below are the relevant snippets of code and the error message.

TTreeReaderValue<TVector3*> TrackP3(reader, "TrackP3");
 cout << " TrackP3 after definition" << endl;

while (reader.Next()) {

cout << " TrackP3 before dump" << endl;
// Retrieve momentum vector information
cout << “TrackP3 status " << TrackP3.GetReadStatus() << " pointer " << TrackP3.Get() << std::endl;
// cout << " Track momentum=” << TrackP3->Mag() << endl;

}

This gives the following output/errors:

Opening root file: /cache/halld/RunPeriod-2016-02/recon/ver01/tree_bcal_hadronic_eff/011658/tree_bcal_hadronic_eff_011658.root
TrackP3 after definition
Error in <CreateProxy()>: The template argument type T of T accessing branch TrackP3 (which contains data of type TVector3) is not known to ROOT. You will need to create a dictionary for it.

If I try to access the methods of the TVector3 object, as in the commented TrackP3->Mag(), it claims the
/Read_bcal_hadronic_eff.C:312:44: error: member reference base type ‘TVector3 *’ is not a structure or union
cout << " Track momentum=" << TrackP3->Mag() << endl;

For now I have reverted to the TTree::Process() methods that work fine, but it would be nice to be able to move the new TTreeReader.

[quote]Error in <CreateProxy()>: The template argument type T of T accessing branch TrackP3 (which contains data of type TVector3) is not known to ROOT. You will need to create a dictionary for it.[/quote]This is strange. Can you try adding -lPhysics to your link line?

Cheers,
Philippe.