[ROOT] TChain and AddFriend() problem

From: Ole Streicher (ole@ifh.de)
Date: Thu Sep 19 2002 - 12:47:47 MEST


Hi!

I have a problem using TChain and TTree::AddFriend together. ROOT
version is 3.03/09:

-----------------------------------------------------------------------------
// create the main tree:
TFile h("Run0001.Physics.Header.root");
TTree *t = (TTree *)h.Get("Physics");

t->Draw("Counter.Physics");                  // <--- Works

TChain *c = new TChain("Tracker");
c->Add("Run0001.Physics.Tracker.Raw*.root"); // <--- Adds 11 files, 1MB each

c->Draw("Unpacked.NChannels");               // <-- Works

t->AddFriend(c, "Tracker");
t->Draw("Tracker.Unpacked.NChannels"); //  *** Break *** segmentation violation
-----------------------------------------------------------------------------

The last line gives a segfault.

If I open just the first file of the chain (or put all events into one
file without chains), it works:

-----------------------------------------------------------------------------
TFile f("Run0001.Physics.Tracker.Raw.root");
TTree *c = (TTree*)f.Get("Tracker");
c->Draw("Unpacked.NChannels");               // <-- Works

t->AddFriend(c, "Tracker");
t->Draw("Tracker.Unpacked.NChannels");      //  <-- Works
-----------------------------------------------------------------------------

It also works if the chain uses only one file (removing the "*" in the
first code snippet). Adding the second file gives the error, but already at
the first event.

Is this a bug in ROOT or can't I just add TChains as friends to other
trees?

Ole



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:10 MET