Discussion:
getting the tree from a TChain
Lisa Gerhardt
2012-11-27 17:55:56 UTC
Permalink
Hello,
I'm working with root v5.34/01. I'm trying to use the TMVA routines with
a series of root files that are chained together. I'm having trouble
getting access to the tree. In the TMVA code, the line is:

factory->AddSignalTree ( (TTree*)my_chain_name->Get("my_tree_name") );

However, this doesn't work for chains. I tried my_chain_name->GetTree(),
but this returns "(const class TTree*)0x0". Is there some way to get
access to the Tree for multiple files chained together? Or do I have to
merge these files into a single big file?

Thanks,
Lisa
Escalier Marc
2012-11-27 18:02:32 UTC
Permalink
Hello,

did you try with "..... (TChain *) ..." ?

==================
Post by Lisa Gerhardt
Hello,
I'm working with root v5.34/01. I'm trying to use the TMVA routines with a
series of root files that are chained together. I'm having trouble getting
factory->AddSignalTree ( (TTree*)my_chain_name->Get("my_tree_name") );
However, this doesn't work for chains. I tried my_chain_name->GetTree(), but
this returns "(const class TTree*)0x0". Is there some way to get access to
the Tree for multiple files chained together? Or do I have to merge these
files into a single big file?
Thanks,
Lisa
Paul Seyfert
2012-11-27 18:03:06 UTC
Permalink
Hi Lisa,

A TChain basically is a TTree. Or more than a TTree. But anything that
you can do with a TTree can be done with a TChain w/o any work. I think
what you want to do is:

TChain* chain = new TChain("how_your_trees_in_the_files_are_called");
chain->Add("first_filename.root");
chain->Add("second_filename.root");

factory->AddSignalTree((TTree*)chain);
^ here I only call the conversion of the pointer
to the base class to help the compiler to
pick the right of the overloaded methods.

Cheers,
Paul
Post by Lisa Gerhardt
Hello,
I'm working with root v5.34/01. I'm trying to use the TMVA routines with
a series of root files that are chained together. I'm having trouble
factory->AddSignalTree ( (TTree*)my_chain_name->Get("my_tree_name") );
However, this doesn't work for chains. I tried my_chain_name->GetTree(),
but this returns "(const class TTree*)0x0". Is there some way to get
access to the Tree for multiple files chained together? Or do I have to
merge these files into a single big file?
Thanks,
Lisa
Lisa Gerhardt
2012-11-27 18:05:40 UTC
Permalink
Hi Paul,
That did it. Thanks to you and everyone for the help!

Lisa
Post by Paul Seyfert
Hi Lisa,
A TChain basically is a TTree. Or more than a TTree. But anything that
you can do with a TTree can be done with a TChain w/o any work. I think
TChain* chain = new TChain("how_your_trees_in_the_files_are_called");
chain->Add("first_filename.root");
chain->Add("second_filename.root");
factory->AddSignalTree((TTree*)chain);
^ here I only call the conversion of the pointer
to the base class to help the compiler to
pick the right of the overloaded methods.
Cheers,
Paul
Post by Lisa Gerhardt
Hello,
I'm working with root v5.34/01. I'm trying to use the TMVA routines with
a series of root files that are chained together. I'm having trouble
factory->AddSignalTree ( (TTree*)my_chain_name->Get("my_tree_name") );
However, this doesn't work for chains. I tried my_chain_name->GetTree(),
but this returns "(const class TTree*)0x0". Is there some way to get
access to the Tree for multiple files chained together? Or do I have to
merge these files into a single big file?
Thanks,
Lisa
Loading...