Re: [ROOT] Problems with trees in functions

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Oct 15 2002 - 17:30:45 MEST


Hi Alexander,

REplace your line:
   TFile f("Event.root");
by
   TFile *f = new TFile("Event.root");

Rene Brun

On Tue, 15 Oct 2002, Alexander Dietz wrote:

> Hello Rooters,
> 
> I want to define a function which reads a TTree from a file, set some
> parameters and returns a pointer to this tree (see Code below).
> But this does not work!
> Does anybody have any idea how to get this work?
> 
> Cheers
> 
>      Alexander Dietz
> 
> // reading tree
> TTree* readTree(void)
> {
>   TFile f("Event.root");
> 
>   // making some changes
>   T->SetMarkerStyle(7);
>   T->SetMarkerColor(3);
> 
>   //  make a new copy from the tree 'T'
>   TTree* tree=new TTree(*T);
> 
>   // returning a pointer to my new tree
>   return tree;
> }
> 
> void test(void)
> {
>   // reading tree and making some parameter-changes
>   TTree* tree=readTree();
> 
>   // try to plot the tree
>   tree->Draw("fNvertex");
> }
> 
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:14 MET