RE: TDirectory::Get...

From: Philippe Canal <>
Date: Mon, 18 Apr 2005 13:47:45 -0500

Hi Thomas,

Yes the object will still be valid __unless__ it is an histogram, tree or event list. Those 3 types of objects are by default owner by the file they are read from.


-----Original Message-----
From: [] On Behalf Of Thomas Bretz
Sent: Monday, April 18, 2005 10:12 AM
Subject: [ROOT] TDirectory::Get...


there is something which is not clear to me, maybe you can help: If I get an object using TDirectory::Get, is this object still valid when the file is closed?

Would the following work?

TObject *ReadObject(const char *filename, const char *objname)

    TFile f(filename, "READ");
    return f.Get(objname);

void main()

    TObject *o = ReadObject("myfile.root", "MyObject");     // Do something with it
    delete o;

Thomas. Received on Mon Apr 18 2005 - 20:47:23 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:07 MET