Re: [ROOT] Repeatability of commands

From: Lindelöf David (David.Lindelof@cern.ch)
Date: Thu Oct 03 2002 - 15:40:09 MEST


At 18:38 02.10.2002 +0200, Rene Brun wrote:
>Note that you can alos delete the statement fFile->Close();
>The statement "delete fFile" will automatically close the file
>if it is not yet closed.
>
>Also replace:
>  THenaEvent *fRaw = new THenaEvent();
>by
>  THenaEvent *fRaw = 0;

I have followed your suggestions and my code now runs like this:

TFile *fFile = new TFile("somefilename");
TTree *fTree = (TTree*) fFile->Get("EventsTree");
TBranch *b_Events=fTree->GetBranch("Event");
THenaEvent *fRaw = 0;            //THenaEvent is a custom class written for 
holding data
b_Events->SetAddress(&fRaw);
b_Events->GetEntry(anything);
delete fFile;

And this works fine so far. However when I now try to read another file, 
after executing the above macro, by typing

fFile = new TFile("someotherfilename");
fFile = new TFile("somefilename");
b_Events=fTree->GetBranch("Event");
fRaw=0;
b_Events->SetAddress(&fRaw);

I have no problem calling

b_Events->GetEntries()

but calling

b_Events->GetEntry(42)

results again in a segmentation fault.

Any suggestions?


David Lindelof
EP-Division
CERN
1211 Geneva 23
Switzerland



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