Hi Martin,
When objects such as TH1, TTree are created, they are automatically
added to a list of objects in memory associated with the current
directory. You can also add your own objects to this list (in the object
constructor) with a statement like
   object->AppendDirectory();
You can access the list with
   TList *list = gDirectory->GetList();
   list->ls(); // or iterate over the list
In the piece of code below, I show how to iterate over this list
and write only objects derived from TH1 in the file.
   TIter next(list);
   TObject *obj;
   while((obj = (TObject*) next())) {
      if (obj->InheritsFrom(TH1::Class)) obj->Write();
   }
Rene Brun