Re: Access to global TTrees

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Jun 05 1998 - 16:58:10 MEST


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



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:33 MET