Addressing branch in TTree


In the data file I’m processing, I have a tree with several branches. As I load the root file and give the ls() command, this is what I get:

root [0] 
Attaching file Work/ISS_Data/s-903_amp.root as _file0...
root [1] _file0->ls()
TFile**		Work/ISS_Data/s-903_amp.root	ISS file
 TFile*		Work/ISS_Data/s-903_amp.root	ISS file
  KEY: TTree	P;172	Particles Tree
  KEY: TTree	P;171	Particles Tree
  KEY: TTree	E;3	Errors Tree
  KEY: TTree	E;2	Errors Tree
  KEY: TTree	H;3	Housekeeping Tree
  KEY: TTree	H;2	Housekeeping Tree
  KEY: TTree	XOA;1	Orbital Tree
  KEY: TTree	OA;1	Orbital Tree
  KEY: TTree	C;1	Calibration Tree
  KEY: TTree	D;1	Dead time Tree
  KEY: TTree	J;1	Joystick Tree
  KEY: TTree	O;1	Orbital Tree

As you can see, branches “P”, “E”, and “H” exists twice. Now, lets focus on branch P.

In my analysis I create a TChain to access the data in P like this:

TChain* P;
P = new TChain("P");
P->Add(rawDataPath.c_str());  //<-- rawDataPath is a string address
P->SetBranchAddress("RawEvent", &re);

When I apply the P->GetEntries() I get a return value of 6130622. If I open a TBrowser and “Dump” both P;172 and P;171 I see that the value comes from P;172.

Now If I loop over all entries according to:

for(int i = 0; i<P->GetEntries(); i++)
   // Do some analysis stuff

What will happen?
Will it only loop over the entries in “P;172”? It looks like it.

But, will it access P;171 as well, some how?
If I want to access both, how do I do?
If I want to access only P;171, how do I do that?
If I want to create a new root-file with only one TTree named “P”, what should I do? Which is the best way?

Grateful for any answer.


I can guess this is not the best hierarchy of a root file, but this is not my design, I only have to work with it.