RE: Redirecting Branches in TTree

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Thu, 03 May 2007 12:05:01 -0500


> One disadvantage is that when attaching Tree2 to Tree1 as a friend and
> starting the viewer on Tree1 I only get access to the contents of Tree1.
> So no quick analysis possible... :(

Indeed, that why it still might be better to copy the full modified object to your 2nd file :)

Cheers,
Philippe

-----Original Message-----
From: Thomas Lauf [mailto:thl_at_hll.mpg.de] Sent: Thursday, May 03, 2007 11:37 AM
To: Philippe Canal; ROOT Talk
Subject: Re: [ROOT] Redirecting Branches in TTree

Philippe Canal wrote:
> Maybe the following would work better:
> Tree1->SetBranchAddress( "Obj", &Obj );
> Tree2->SetBranchAddress( "Obj", &Obj );
>
> Tree1->GetEntry( i );
> Tree2->GetBranch("obj.data2")->GetEntry( i );
>

Hi Philippe,

I found the following solution. Filling the first tree, excluding the non-used data array:

   Tree1.Branch( "Obj", "MyClass", &Obj );    Tree1.SetBranchStatus( "m_Array2", 0 );

Then, "calibrating" the data, e.g. calculating m_Array2 from m_Array1 and storing only this one in a second tree:

   Tree1->SetBranchAddress( "Obj", &Obj );

   Tree2.Branch( "Obj", "MyClass", &Obj );
   Tree2.SetBranchStatus( "*", 0 );
   Tree2.SetBranchStatus( "m_Array2", 1 );

   ...
   Tree1->GetEntry( i );
   Obj->Calibrate();
   Tree2.Fill();

Finally I can read my calibrated objects like this:

   Tree1->SetBranchAddress( "Obj", &Obj );    Tree2->SetBranchAddress( "Obj", &Obj );

   ...
   Tree1->GetEntry( i );
   Tree2->GetEntry( i );

This solution also works when I declare the member variables private.

One disadvantage is that when attaching Tree2 to Tree1 as a friend and starting the viewer on Tree1 I only get access to the contents of Tree1. So no quick analysis possible... :(

regards
Thomas

--
Thomas Lauf
MPE - Halbleiterlabor
E-Mail: thl_at_hll.mpg.de
Received on Thu May 03 2007 - 19:06:43 CEST

This archive was generated by hypermail 2.2.0 : Fri May 04 2007 - 11:50:01 CEST