TChain LoadTree() not giving a proper entry in pyROOT 5.34

Please provide the following information:
ROOT Version (e.g. 6.12/02): 5.34.35
Platform, compiler (e.g. CentOS 7.3, gcc6.2): Fedora 27, python 2.7.14

Dear All,

My code is big, so difficult to provide a working example, but maybe you will give me a clue. I have a TChain and methods of my class operating on it. The problem is, that TChain::LoadTree() does not seem to always give a proper entry. When I simply loop through the TChain entries from 0 to the last, the return value should get “reset” to 0 when the LoadTree() changes the tree. Still, it does so only in special cases.

This is my test method:

def	get_pdm_lightcurve(self, moment=0, sum=False, xaxis=0):

	for av2 in xrange(0, self.frame_cnt):
		brentry = self.tree_chain.LoadTree(av2)

		trentry = self.get_pdm_array(av2)
		# trentry = self.get_tree_entry_from_chain(av2)

		print av2, brentry, trentry
		# print self.cur_chain, self.cur_chain.GetFile().GetName(), self.cur_chain.GetTree().GetName(), self.cur_chain.GetTree().GetEntriesFast(), self.cur_chain.GetTree()

	return 0

def get_pdm_array(self, frame=-1, ccb=0, pdm=0, use_mask=None, use_subtr=None, use_calib=None, use_eff=None, use_deadtime=None, zero_bad_pixels=True, use_crosstalk=None):

	brentry1 = self.cur_chain.LoadTree(frame)
	return brentry1

Entries in single trees go up to 3199. So the correct print output is:


3198 3198 3198
3199 3199 3199
3200 0 0
3201 1 1


However, it is:


3198 3198 3198
3199 3199 3199
3200 3200 3200
3201 3201 3201

unless I call get_pdm_array() somewhere earlier in the code and store its return value (!) even though I don’t use this value later. If I do so, TChain::LoadEntry starts to give a proper entry in get_pdm_array(), but keeps giving a bad entry in get_pdm_lightcurve() that calls it:


3198 3198 3198
3199 3199 3199
3200 3200 0
3201 3201 1
3202 3202 2


You see an other commented out printout. I checked that the current TTree is the same in both functions, addresses are the same… So I am not sure how this behaviour is possible.

Do you think you could give me a clue to what may be wrong without a working example?

That is the intended behavior. The return value of LoadTree is the entry number within the ‘current’ tree from the request chain entry number. The value returned by LoadTree is intended to be use when calling GetEntry on one the branch objects, because they are local to each TTree.

The value returned by LoadTree should also be equal to cur_chain.GetTree().GetReadEntry()

Yes, perhaps I was not clear. In my case, LoadTree() returns numbers higher that the available number of entries in TTree.

This was an internal bug of my code related to mixing of chains. Sorry for the mess and thanks for helping.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.