Issue when adding two TChains with one containing a subset of branches and using the Draw method

Dear ROOT experts,

I am using PyROOT with ROOT version 6.12.07 on Linux.

I wrote a script that adds two TChains containing ROOT files with TTrees which differ very slightly in their TBranch content, namely, one is a subset of the other. For explanation purposes, I will just consider the case where one of the chains has a branch missing respective to the other.

Now, when I use the Draw method on the combined chain and use a selection which uses this missing branch, this event appears to be ignored (selection evaluated to False), while the Draw command completes successfully. This is even if the selection contains an ‘OR’ of other True conditions. Is this the intended behaviour?

While I understand that is it dangerous to be adding chains with different branch contents, shouldn’t there be a warning or error that notifies us of this? I was initially not aware of the differing branch contents until I tried to understand the plots that were produced. I believe that this is a rather common situation when using data where triggers were added and removed in between run periods.

I can think of a quick fix where in an extra step I add the missing branches and fill them with zero, but is there a better solution?

Thank you very much for your help!

Best regards,

ROOT Version: 6.12.07
Platform: Linux
Compiler: slc6_amd64_gcc700

For better or worse this is the intended behavior. The rational is the filter is akin to “does the branch match this criteria” (for example is the value 12) and if the branch does not exist it can’t possible match the criteria and the selection is set to false. The down-side is, indeed, if the selection is ‘negative’ rather than ‘positive’ (for example “is the value not 12”) we still return ‘false’ for the case of missing branch with is ‘wrong’ …

To work around the issue you might be able to use the TTree::Draw special functions ‘Alt$’:

Alt$( sometimeMissingColumn, 0);


Hello @pcanal,

Thank you for your response.

Yes, the workaround does the trick!

I will still try to implement some improvements in the code to make sure that whenever chains are added, that the branches fully correspond. It can be quite dangerous and easily overlooked… Maybe indeed some warning would be called for? It would probably save some headaches in the future :slightly_smiling_face:


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