Hi,
I have some classes which are derived from TNamed. The purpose of these class objects is to store the “simulation run related” info as the headers of the TTree (In UserInfo List). Now I have 2 problems in doing that :
-
Pointers initiated to NULL values in default constructor of class :
I know I can’t do that if I want to use ROOT I/O. But then can you suggest
me some workaround for these ? I can’t avoid having pointers as data
members of class or allocating them dynamically in the constructor. They
have to be set after reading a related info in form of text file provided by
user. So by default objects are created as invalid objects those should not
be used. -
Ownership of these objects by UserInfo list :
When there are multiple files opened, objects retrieved from UserInfo lists
of different files often tend to cause crashes due to TList::Delete() call
made at the time of file closing. Of course if one is careful in tracking
which object is owned by which File’s UserInfo list then there is no
problem. But it would be easier if I myself could manage creation/deletion
of these objects. So is there a way to do that.
Is it safe to do
"tree->GetUserInfo()->SetOwner(kFALSE)" ;
And then manage all the objects retrieved from these lists myself ?