Reading several trees with different weights into a TChain


I need to create a chain (background) with several files, each one representing a different physics channel, with its own cross-section. I need to weight each channel with Luminosity, cross-section and the total number of generated events.

I found how to force TChain to plot the data with only one weight, but couldn’t find how to have diferent weights to each tree.

I tried to load the tree, assign a weight to it, then add it to the chain, but when making some histo, root simply exited, if I had issued a “.q” command.

I’m using ROOT 3.05/07 running on Linux RH 9.0


Luiz Mundim

Hi Luiz,

When looping on all Tree files of a TChain, ROOT reads the Tree header
from the corresponding file. Any previous SetWeight settings not saved in teh Tree file are lost.
You have two options

option 1

call tree.SetWeight(w) for each tree/file (open in Update mode)
and tree.AutoSave();

option 2

In your code looping on all events of the TChain, detect whenever you are starting a new Tree and call SetWeight