Re: Consolidating different TTrees into one

From: Rene Brun <Rene.Brun_at_cern.ch>
Date: Tue, 2 Nov 2010 11:48:45 +0100


You can set a weight for each of your Trees via TTree::SetWeight(). For example, suppose that you have 3 files f1.root, f2.root, f3.root, each containing a Tree "T".
You can make persistent the weight for each Tree by doing something like

    TFile f1("f1.root","update");
    T.SetWeight(3.14);
    T.AutoSave();
and same for f2.root, f3.root.
Now in an interactive session, you can do

     TChain ch("T");
     ch.Add("f1.root");
     ch.Add("f2.root");
     ch.Add("f3.root");
     ch.Draw("myvar");

you will get the histogram for "myvar" with the weight for each entry corresponding to each tree weight.

Rene Brun

Suvayu Ali wrote:
> Hi ROOTers,
>
> I'm in bit of a predicament. I have several different TNtuples in a ROOT
> file with the exact same branches but different number of events. I want
> to add all these TNtuples into one consolidated TNtuple with a different
> weight for each TNtuple.
>
> At first I thought of friending them but then I realised that won't
> work, as that will treat those "identical" branches as different
> branches. Is their any way do this other than an event by event copy?
> Even if I go with that, how do I use weights?
>
> Any clues would be helpful. Thanks in advance for your thoughts.
>
Received on Tue Nov 02 2010 - 11:48:49 CET

This archive was generated by hypermail 2.2.0 : Tue Nov 02 2010 - 23:50:01 CET