TChain and AddFriend : crash

From: Marc Escalier <escalier_at_lal.in2p3.fr>
Date: Thu, 17 Dec 2009 21:37:39 +0100


Dear roottalkers...

i have a problem with AddFriend and TChain

i find how to fix the problem, but i don't why

my question would be : "do you agree with the behaviour below, and is there a less painful solution that the one i found ?"

thanks

I) the configuration for which it crashes

Let's consider the we have 2 files, file1, file2, each including both
Tree1 that contains variable1
Tree2 that contains variable2
(this is the reason of doing a TChain, because actually i have about 100 files, but the behaviour that i say below is reproducible with only 1 file inside a TChain)

i wish to make a TChain of the 2 files, and to be able to access to both Tree1 and Tree2, using AddFriend
==>

TChain mychain("Tree1");
mychain.Add("file1");
mychain.Add("file2");

mychain.Scan("variable1")
==>it works

now i wish to add variable2 from Tree2 as a friend of mychain
==>

mychain.AddFriend("Tree2")
==>ok, it prints a pointer which says that it works (if i do a syntax
error in the name of the tree, root tells me that the tree does not exist)

but now when i wish to access the variable, it crashes : mychain.Scan("variable2")
==>core dump

same if i do the same procedure with mychain.Scan("variable1") =>core dump (after having redone the whole stuff from scratch of course)

i'm using root 5.24/00

(additive information just in case : Tree2 doesn't contains the same number of events as Tree1, could that be an influence on the crash that i see ?)

II) the configuration for which it works : the "painful" solution

TChain mychain_tree1("Tree1");
mychain_tree1.Add("file1");
mychain_tree1.Add("file2");

TChain mychain_tree2("Tree2");
mychain_tree2.Add("file1");
mychain_tree2.Add("file2");

mychain_tree1.AddFriend("Tree2")
then it works !
mychain_tree1.Scan("variable1")
ok
and mychain_tree1.Scan("variable2")
ok

==>

but it is a bit painful because when ones has 100 files, he needs to do mychain_tree1.Add("file_number_i")
==>100 times (that is normal)

and *in addition* to do mychain_tree2.Add("file_number_i"), 100 times...

would you have comments ?

thanks Received on Thu Dec 17 2009 - 21:37:50 CET

This archive was generated by hypermail 2.2.0 : Fri Dec 18 2009 - 05:50:10 CET