Trouble reading back TVector3 from tree

Dear Experts,

I have saved a TVector3 with pt, eta, and phi components to a TTree. I am trying to read back and use the pt and phi components in a macro, but all I get in the output are zeros. The original root file that I am reading the vector branch from has meaningful information for the vector components, however. My method is

ntupleToRead->SetBranchStatus("pTmissID",1); TVector3 pTmissID; ntupleToRead->SetBranchAddress("pTmissID",&pTmissID); float ptMissID = -9999.; ptMissID = pTmissID.Pt();


Use:TVector3 *pTmissID = 0; ntupleToRead->SetBranchAddress("pTmissID",&pTmissID);


If I instead save the individual pt and phi components for the resultant vector obtained from summing over all track vectors, which method will give me the correct pt and phi :

  1. Looping over all tracks, and for each track, create a TLorentzVector, call trkVector.Pt(), trkVector.Phi(), and calculate a running sum of Pt and Phi
  2. For each track, call trkVector.SetPtEtaPhiM(trkPt,trkEta,trkPhi,trkM), keep a running sum of the track vectors, then after exiting the track loop, call sumOfTrkVectors.Pt(), sumOfTrkVectors.Phi()

The 2 methods are not equivalent (I checked). I just don’t know which one is correct. I’m favoring the latter.

Hi Thomas,

I am not sure either … What is the semantic/intend of doing the sum?


Hi Philippe,

I am attempting to find the missing pT in an event by calculating the vectorial sum of the track pT.