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

From: Dr. John Krane <jkrane_at_netzero.com>
Date: Thu, 24 Aug 2006 09:40:58 -0500


Hello Christian,

Just when thought I had forgotten how condescending physicists could be, here comes your email!

As I originally explained, I have already made tree branches and histograms with BF/B as part of the name and everything works great. FindObjectAny works, but the Get method has this shortcut hardwired into it.

Although I could replace the character as you suggest I do not think this is the best option for me. BF/B is the ticker symbol for Brown Forman class B shares as used in my other software, so I prefer to keep it, and other symbols like it, the same.

Instead I have modified my version of TDirectory in the way I outlined below to have a switch that defaults to the official behavior. Now *everything* works great for me, including the Get method, nothing is broken, and I have theoretical backward compatibility with any Get("mydir/mysubdir/myhisto") commands that might be sitting around (of which I have none, but it is good policy). I do not make subdirectories with a / in them, so the TDirectory "concept" is not affected (and never was). If and when I update to a newer version of ROOT I will just relink my more flexible TDirectory again.

Erhm, thanks for your email. The ReplaceAll method looks very nice, and I am happy to have my attention drawn to it for a future use.

Christian Holm Christensen wrote:

>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.
>
>Yours,
>
>
>

-- 

Dr. John Krane
http://jkrane.home.comcast.net

Quantitative Financial Analyst
Received on Thu Aug 24 2006 - 16:41:09 MEST

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