I was trying to get a TNamed object from gDirectory.
While looking for within the documentation I only found that the only requirement for an object to be retrievable is to inherit from TNamed:
But If I try something like
TNamed *nam = new TNamed(“myname”,“mytitle”);
- returns nothing and -
For reference Im using root v5.26 for SLC5 x86_64
[quote]While looking for within the documentation I only found that the only requirement for an object to be retrievable is to inherit from TNamed:[/quote]Well … the additional implicit requirement is that the object is ‘stored’ in the directory. In the example you show, you never ‘store’ the object in the directory (You would need to use gDirectory->Append for example or have gDirectory points to a TFile where you stored that object in a previous session).
PS. Please note that the TNamed this requirement is actually now obsolete and any object which has a dictionary can be stored and retrieved from a TDirectory.
I assumed that the object was appended to the default TDirectory, like some other classes that inherit from TNamed. Yes, the gDirectory->Append works well.