RE: [ROOT] AddFriend of TChain

From: Philippe Canal (pcanal@fnal.gov)
Date: Fri Aug 15 2003 - 17:36:47 MEST


Hi Junichi,

Actually, the default name of the friend declared by
   root [2] TChain t2("CBNT/h3781");
   root [4] t1.AddFriend("CBNT/h3781");
is indeed 'CBNT/h3781".  However because of the slash, this is not a valid
identifier in TTree::Draw.
Instead you need to give an alias to the friend.
Do either:
	 t1.AddFriend("CBNT/h3781=h3781");
or better
	 t1.AddFriend(&t2,"h3781");
And then use h3781 as the prefix for the branches in the friend
        t1.Draw("h3781.aj_ncelllarem");

Cheers,
Philippe
-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of
Junichi.Tanaka@cern.ch
Sent: Thursday, August 14, 2003 4:15 PM
To: roottalk@pcroot.cern.ch
Cc: Junichi.Tanaka@cern.ch
Subject: RE: [ROOT] AddFriend of TChain


Hello,

From: "Philippe Canal" <pcanal@fnal.gov>
Date: Wed, 13 Aug 2003 17:15:27 -0500
>
> > root [13] t1.Draw("CBNT/h3780.aj_ncelllarem")
>
> Then default name of the friend is only the last part of the path.  Try:
>     t1.Draw("h3780.aj_ncelllarem")

I tried this way but I could not draw any plot as follows.
(A "tau.root" file is at /afs/cern.ch/user/j/jtanaka/public/tau.root.)
Is there any idea?

[lxplus076] ~/public > which root
/afs/cern.ch/sw/root/v3.05.07/rh73_gcc2952/root/bin/root
[lxplus076] ~/public > root -l
root [0] TChain t1("CBNT/h3780");
root [1] t1.Add("tau.root");
root [2] TChain t2("CBNT/h3781");
root [3] t2.Add("tau.root");
root [4] t1.AddFriend("CBNT/h3781");
root [5] t1.Draw("aj_ncelllarem");
<TCanvas::MakeDefCanvas>: created default TCanvas with name c1
root [6] t1.Draw("h3780.aj_ncelllarem");

*ERROR 26 :
 Unknown name : "h3780.aj_ncelllarem"
root [7] t1.Draw("h3781.aj_ncelllarem");

*ERROR 26 :
 Unknown name : "h3781.aj_ncelllarem"

Best Regards,
Junichi.Tanaka@cern.ch

> -----Original Message-----
> Sent: Tuesday, August 12, 2003 4:37 PM
> To: roottalk@pcroot.cern.ch
>
> Dear all,
>
> I have two questions about "AddFriend" of TChain.
> I'm using 3.05.05 and 3.05.07.
>
> In CBNT/h3780, there are two variables,
>    Int_t           aj_ncelllarem;
>    Float_t         aj_ce_etalarem[35000];   //[aj_ncelllarem]
> In CBNT/h3781, there are two variables,
>    Int_t           aj_ncelllarem;
>    Float_t         aj_ce_philarem[35000];   //[aj_ncelllarem]
> The root file, "tau.root", was converted from ntuple by using h2root.
>
> (1) I tried to turn on/off the status of all branches,
>     even if the branches are added by "AddFriend".
>     However I could get the status of branch "aj_ce_philarem"
>     but I could not set the status of this branch.
>     Is this correct? How should I do?
>
> root [0] TChain t1("CBNT/h3780");
> root [1] t1.Add("tau.root");
> root [2] TChain t2("CBNT/h3781");
> root [3] t2.Add("tau.root");
> root [4] t1.AddFriend("CBNT/h3781");
> root [5] t1.GetBranchStatus("aj_ce_etalarem")
> (const Bool_t)1
> root [6] t1.GetBranchStatus("aj_ce_philarem")
> (const Bool_t)1
> root [7] t1.SetBranchStatus("aj_ce_etalarem",0)
> root [8] t1.SetBranchStatus("aj_ce_philarem",0)
> Error in <TTree::SetBranchStatus>: unknown branch -> aj_ce_philarem
>
> (2) In the Users Guide, there is a statemate that
> we can access variables by "chainname.branchname.varname".
> But I could not do this in some cases. How should I do?
>
> root [9] t1.GetBranchStatus("CBNT/h3780.aj_ncelllarem")
> (const Bool_t)0
> root [10] t1.SetBranchStatus("CBNT/h3780.aj_ncelllarem",1)
> Error in <TTree::SetBranchStatus>: unknown branch ->
> CBNT/h3780.aj_ncelllarem
> root [11] t1.SetBranchStatus("aj_ncelllarem",1)
> root [12] t1.Draw("aj_ncelllarem")
> root [13] t1.Draw("CBNT/h3780.aj_ncelllarem")
>
> *ERROR 26 :
>  Unknown name : "CBNT"
>
> Best Regards,
> Junichi.Tanaka@cern.ch



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:14 MET