GetBranch from all Files in a TChain

Hello,

Sorry if this is an obvious question, but I’m new to PyROOT. Our experiment has it’s data in a relatively large number of identically structured files. From what I’ve read, this is exactly what the TChain is for. I created a TChain with a subset of the data.

filelist = ['Workspace/data/all/cf/calib_Prodv5-3_lite_011208a_cf.root',
              'Workspace/data/all/cf/calib_Prodv5-3_011307a_cf.root',
              'Workspace/data/all/cf/calib_Prodv5-3_011301a_cf.root',
              'Workspace/data/all/cf/calib_Prodv5-3_011204a_cf.root']

dataChain = TChain('rrqDir/calibzip1')
for fName in filelist:
    dataChain.Add(fName)

I would like to read out a single branch for all files in the TChain, but whenever I grab a branch from the chain it just grabs from the first file. For example below: I can get the total number of entries in the chain, but I only get the entries from a single file when I run GetBranch(). How do I access the same branch from each of the rest of the files in the TChain?


In [35]: dataChain.GetEntries()
Out[35]: 1733321L

In [36]: dataChain.GetBranch('ytNF').GetEntries()
Out[36]: 166631L

Try:
dataChain.MakeClass(‘MyDataChain’)
then have a look at the “Loop()” method in the generated “MyDataChain.C” file.
Inside you will find explanations which show how to “read only this branch” (note the difference between “ientry” and “jentry”).

That example code showed me exactly what I needed. Thanks.