Multiple trees vs TChain

Hello,
I have currently a use-case that seems simple but every approach I try seems ill-behaved.
My usual setup is that I have multiple files with one tree each, I build a TChain out of them which is then fed to a code that is not under my control and where Draw is heavily used.
Now I want to give higher weights to some of the trees and I run into problems.

  • one option is to read out each tree, and fill at the same time a huge tree which is just a copy/chain with a modified weight branch, seems an absurdly large overhead.
  • if I want to use TTree::SetWeight instead, I need to read the trees first, set the weight and again merge them somehow

I’m surprise to see that there is no (or I couldn’t find) functionality for building a TChain-like object from a set of TTree. I realize that this only makes sense when the TTrees are in memory and thus spoils the benefits from a TChain but still it would be a nice option.

Any feedback on how to attack the problem is greatly welcome :slight_smile:

Cheers
Javier

Hi Javier,

what you can always do, given that you have many files with one tree in each of them, is to use the TTree::GetFile method (root.cern.ch/doc/master/classTC … da9ea4b9e5) to know on what you are concretely looping to assign an appropriate weight.

Cheers,
D