AddFriend from the command line

Hello,
I am using ROOT 5.14/00b (not at CERN, but installed at Nevis Labs).

I load a root ntuple withe the following command
root -l a.root

The ntuple contains various trees:
If I type
.ls

I get

TFile** a.root
TFile* a.root
KEY: AttributeListLayout Schema;1
KEY: TDirectory TruthHistogram;1 TruthHistogram
KEY: TDirectory RecoHistogram;1 RecoHistogram
KEY: TTree CollectionTree;1 CollectionTree
KEY: TTree Trigger0;1 Trigger0
KEY: TTree Truth0;1 Truth0
KEY: TTree FullReco0;1 FullReco0
KEY: TTree FastSim0;1 FastSim0
KEY: TTree TruthAna0;1 TruthAna0
KEY: TTree FullRecoAna0;1 FullRecoAna0
KEY: TTree FastSimAna0;1 FastSimAna0
The two ntuples contain a variable with the same name (LepTop_N), but different content.
In fact if I scan:
FullRecoAna0->Scan(“LepTop_N”)
TruthAna0->Scan(“LepTop_N”)

I get two different non-zero series on fumbers.

I would like to scan them together or plot one against the other
FullRecoAna0.LepTop_N vs TruthAna0.LepTop_N

So I write:

FullRecoAna0->AddFriend(“TruthAna0”)
and I get
(class TFriendElement*)0xa12b5f8

then I try to do
FullRecoAna0->Scan(“TruthAna0.LepTop_N”)

and I get an empty list.


  • Row * TruthAna0 *

  •    0 *           *
    
  •    1 *           *
    
  •    2 *           *
    
  •    3 *           *
    
  •    4 *           *
    
  •    5 *           *
    
  •    6 *           *
    
  •    7 *           *
    
  •    8 *           *
    
  •    9 *           *
    
  •   10 *           *
    
  •   11 *           *
    
  •   12 *           *
    
  •   13 *           *
    
  •   14 *           *
    
  •   15 *           *
    
  •   16 *           *
    
  •   17 *           *
    
  •   18 *           *
    
  •   19 *           *
    
  •   20 *           *
    
  •   21 *           *
    
  •   22 *           *
    
  •   23 *           *
    
  •   24 *           *
    

while If I try to do:
FullRecoAna0->Scan(“LepTop_N”) I just get what i was getting before i.e. FullRecoAna0- sees its own variable (as expected).
I also tried FullRecoAna0->Draw(“TruthAna0.LepTop_N”) and the canvas is completely empty, in the sense that no acis or anything is drawn on it. i only see the gray background.

So what is wrong? Why am I not able to see the variable of the befriended tree?
Does anyone have an explanation?

Cheers,
Francesco

Hi,

This should a priori have worked. Could you please send me (give me access to) your file so that I can try to reproduce your problem?

Thanks,
Philippe

Hi,

The issues is that you created an index on the friend tree (TruthAna0) but there is no corresponding branch/leaf to link it to the main tree.

When a Friend is attached to a Tree and there is an index on the friend, instead of matching the row/entry by entry number, there are matched on the indices values. Usually, the indices are something like RunNumber, EventNumber which are columns/branch/leaf is both tree (and hence even if the events are not ordered and/or have gaps the match is done correctly).

In your case the friend tree is index on TruthAnaRunNumber and TruthAnaCounter … which of course are not matching your main tree.

To work around the problem (possibly incorrectly) by calling TruthAna0->SetTreeIndex(0); before the Scan.

Cheers,
Philippe

Thanks Philippe. It worked.
Cheers,
Francesco