Error in <TBranchElement::Fill> when merging TTrees with TTree::Merge()

Dear experts,

I am trying to merge multiple TTrees for different datasets and apply a global tree weight to each merged tree (the script computes the weight by reading metadata stored in an external text file). I am on version 6.02.12-x86_64-slc6-gcc48-opt

In order to do this, I am using a PyROOT script (not written by me) that - for a given dataset type - basically works like this for the merging part:

  1. call TTree::Clone() for the tree in the first file processed, and store the cloned object in a cache

  2. for the following files, take the TTree object and merge it to the cached tree via a call to TTree::Merge()
    However, I am getting the following error message for every entry in the tree under question

Error in <TBranchElement::Fill>: attempt to fill branch muon_isTight while addresss is not set

both when cloning the first tree and when calling Merge() subsequently. Just fyi, ‘muon_isTight’ is a vector branch.

I guess that Clone() and Merge internally call TBranchElement::Fill(), but I couldn’t find where this call is nested. Do you have an idea of where the problem might stem from?

Despite this, the script seems to eventually succeed at merging the trees, and that branch looks fine in the merged tree. I am however concerned about potential losses of events during the merging which could get out of my control.

I have tried also a simple hadd (which however does not suit my needs as I have to apply a weight to the merged tree as well), and I do not get that error.

Any help at debugging this would be much appreciated!



PS please find my pyROOT macro in attachment (8.93 KB)


Rather than ‘TTree::Clone()’ you should be used ‘TTree::CloneTree()’ … which seems to be the case in your actual code.

I am not quite sure where the error message comes from (most likely a missing dictionary) but since you do not update the content of each entries, you should be able to get rid of the message and speed up your merging by using: