Re: Access to global TTrees

Rene Brun (Rene.Brun@cern.ch)
Fri, 05 Jun 1998 16:58:10 +0200


Norbert Danneberg wrote:
>
> HI ,
> how can I get access from within a macro function to a TTree which was
> loaded interactively from an hbook converted file?
>
> root[21] Int_t BGOList[3] = {1,2,3};
> root[22] f1 = new TFile("MyFile.root");
> root[23] .L GainHV.C;
>
> root [24] f1.ls();
> TFile** bt416_05_eve.root
> TFile* bt416_05_eve.root
> KEY: TTree h10;1 event
> root [25] GainHV(&BGOList, 3)
>
> Error: No symbol h10.Print() in current scope
> FILE:/data/norbert/proc/root/macros/
> GainHV.C LINE:62
> *** Interpreter error recovered ***
>

You can pass the pointer to the Tree to your function GainHV.
Change it to be
void GainHV(&BGOList, int, TTree *tree)
then in your macro, you have
file = new TFile("MyFile.root")
TTree *h10 = (TTree*)file->Get("h10");
GainHV(&BGOList,3,h10);

Rene Brun