SetBranchStatus or SetBranchAddress zeroing values from TTree

I’m trying to use data from a .root file in a macro. The file is organized as a TTree with all the leaves under one branch, like so:

-dstree
	-x
	-y
	-z

To use the data, I create a TChain and add the data in from the file:

TString mainfile = "outrun_v2.root";
TChain* events = new TChain("dstree");
events->Add(mainfile);

I then try to “link” variables actually defined in my macro to the ones in the .root file, like so:

events->SetBranchStatus("dstree.x", 1);
events->SetBranchAddress("dstree.x", &e.x);

events->SetBranchStatus("dstree.y", 1);
events->SetBranchAddress("dstree.y", &e.y);
    
events->SetBranchStatus("dstree.z", 1);
events->SetBranchAddress("dstree.z", &e.z);

After this I don’t change the values of x, y, or z in any way. However, when I try to access the values I get numbers that don’t actually match what is in the root file. What could cause this?

[quote=“Pepe Le Pew”]Create TH2F gamma-gamma matrix from TTree/TChain data
I’m not sure how this is relevant. The mentioned poster in that thread seemed to be able to extract the data from a TTree as necessary and had other problems.

Try the simplest:
events->MakeClass();
and then see the newly generated “dstree.h” and “dstree.C” files (if the “events” tree name is “dstree”).