Re: Plotting a tree's current entry vs. its previous entry

From: Philippe Canal <pcanal_at_fnal.gov>
Date: Tue, 27 Sep 2011 14:24:50 -0500


Hi Brett,

> TF->BuildIndex("Event-1","0");
> The documentation says that an expression can be used for the
> "majorname" and/or "minorname" so I expected this should work.

The expected behavior is that this will connect the 2 entries in the main TTree and the friend TTree that have the same value for the expression ... So using this index can not achieve what you need.

The simplest solution is to do the following:

      TFile *offsetFile = TFile::Open("offset.root","RECREATE");
      TTree *offseter = tree->CloneTree( 1 ) ; // 1 is the offset
      offsetFile->Write();

      TChain *chain = new TChain(tree->GetName());
      chain->Add("offset.root");
      chain->Add(realfilename);

      chain->AddFriend(tree);

i.e. create a chain with a (spurrious) tree that provide the offset followed by the real TTree and the chain as the main tree ...

Cheers,
Philippe.

On 9/27/11 1:39 PM, Brett Viren wrote:
> Hi ROOT,
>
> I would like to be able to use TTree::Draw() to plot quantities in the
> current entry against quantities in the prior entry of my tree. I
> thought I could do this using a tree index and friendship but I am
> failing to make the two trees out-of-sync by one entry. It may be that
> I am not correctly understanding how TreeIndex/Friends work.
>
> Attached is a modified version of treefriend.C from the tutorial area
> that shows what I'm trying to do. My changes are near comments like
> "//bv". The pertinent line is:
>
> TF->BuildIndex("Event-1","0");
>
> The documentation says that an expression can be used for the
> "majorname" and/or "minorname" so I expected this should work. Runing
> the script like:
>
> root -l treefriend.C
>
> will produce a plot of the difference in Event numbers between the
> original and the copied/indexed/friended trees. I want it to produce a
> spike at +1 but it gives one at 0. This indicates to me (?) that the
> trees are not out of step by 1 entry as I want.
>
> Any ideas how to make this work?
>
> BTW, I have found I can do what I want by calling CopyTree("Event>0"),
> that is, not write out the first entry, but I'd like to find an
> index-based solution if there is one.
>
>
> Thanks,
> -Brett.
>
> PS: Version 5.26/00e on linuxx8664gcc, SL5.3
>
Received on Tue Sep 27 2011 - 21:25:01 CEST

This archive was generated by hypermail 2.2.0 : Tue Sep 27 2011 - 23:50:02 CEST