Re: want to mydir->Get("BF/B")

From: Christian Holm Christensen <>
Date: Wed, 23 Aug 2006 22:52:28 +0200

Hi John,

On Wed, 2006-08-23 at 13:17 -0500, Dr. John Krane wrote:
> OK, I have looked at the actual code of TDirectory, and I see the
> default behavior is to specifically look for the "/" character and
> interpret that as a directory. There is no way to override the default
> behavior, at least in my version of ROOT. This is also the case for the
> GetObject* methods.

Erhm, the best option by far, is for you to _replace_ the special character '/' with some other character, say '@'. For example

   TString name(GetTickerName());
   name.ReplaceAll("/", "@");
   TH1* h = new TH1D(name.Data(), name.Data(), ....);

> May I suggest that there should be a way to override this behavior?

I think that would be a really _really_ bad idea. '/' is a special reserved character for directory separators. The whole TDirectory concept is build around the assumption that '/' is a special reserved character - much like any other (reasonable) file system you can find in any (reasonable) OS.

I think you are better of understanding and using the specifications of TDirectory.

> Surely there are cases where people in HEP would like a histogram called
> "data/theory" or "xsec_630/1800" for instance. Perhaps a
> GetStrictName(name) method could be included that does not include the
> "/" interpretation as a directory, or a SetAutoDirectorySearch(false)
> method.

I think most HEP people appreciate the concept of a reserved character for directory separators - they are used to that from their OS. Hence, they don't get the idea to make names that wouldn't work. Instead, they'd make names like `data_over_theory', `data_vs_theory', `scaled_data' or something like that.


 ___  |  Christian Holm Christensen 
  |_| |  -------------------------------------------------------------
    | |  Address: Sankt Hansgade 23, 1. th.  Phone:  (+45) 35 35 96 91
     _|           DK-2200 Copenhagen N       Cell:   (+45) 24 61 85 91
    _|            Denmark                    Office: (+45) 353  25 404
 ____|   Email:               Web:
 | |
Received on Wed Aug 23 2006 - 22:52:43 MEST

This archive was generated by hypermail 2.2.0 : Mon Jan 01 2007 - 16:32:00 MET