Hi Alberto,
You can always attach any object inheriting from TObject to a TDirectory by calling
mydir->Append( myobj );
Since ROOT v5.20, you can also add the "automatic adding to current
directory"
behavior to your class [hierarchy].
For that simply add a new member function with the signature:
void DirectoryAutoAdd(TDirectory *dir)
This function should execute the Append and can also propagate this
information
to your object. For example TH1::DirectoryAutoAdd does (indirectly):
if (fDirectory == dir) return; // We are already in this directory, we have nothing to do
if (fDirectory) fDirectory->Remove(this); // Get out of old directory fDirectory = dir; // Record new location if any if (fDirectory) fDirectory->Append(this); // Register with the directory.
Cheers,
Philippe.
-----Original Message-----
From: owner-roottalk_at_root.cern.ch [mailto:owner-roottalk_at_root.cern.ch] On
Behalf Of Alberto Pulvirenti
Sent: Wednesday, July 30, 2008 8:36 AM
To: Root
Subject: [ROOT] Writing an object in the directory
Dear all,
I have made a class which inherits from TNamed. I expected that, when I create an object of this class, I would then see it in the gDirectory using gDirectory->ls(). Instead, I don't see it after I created it. What else should one do in order to be able to see an object implemented this way in the gDirectory?
Thanks, cheers
Alberto Received on Wed Jul 30 2008 - 18:07:30 CEST
This archive was generated by hypermail 2.2.0 : Wed Jul 30 2008 - 23:50:02 CEST