Read TVectorD from TTree

Hi,

I know that this probably a really stupid question, but how can I read back in compiled macro a TVectorD from a TTree. I produced the tree with the TTreeSRedirector (variable: fpcstream),

TVectorD dcaTrack(3); TVectorD pTTrack(3);
… // filling of the dcaTrack(3) and pTTrack(3)

if (fpcstream){ (*fpcstream)<<"Vertices" << "dcaTrack.=" << &dcaTrack << "pTTrack.="<< &pTTrack << "\n"; }

This worked fine. Now I would like to read this tree, however I somehow screw it up and it doesn’t work:

   TTree *Vertices = (TTree*)gDirectory->Get("Vertices");
   TVectorT<double> 		dcaTrack;
   TVectorT<double>	 	pTTrack;

   Vertices->SetBranchAddress("dcaTrack.",&dcaTrack);
   Vertices->SetBranchAddress("pTTrack.",&pTTrack);

This code piece was mainly generated by Vertices->MakeCode(). What am I doing wrong?

Regards,
Fredi

Hi Fredi,

MakeCode (and MakeClass) set the TTree in mode that prevents reading object. To read the object, you need to comment out of the line fChain->SetMakeClass(1).

Cheers,
Philippe.