Behaviour of TTree::ReadFile()

First I would like to say, that imho TTrees are awesome and I would love to see more of my students start using TTrees right away. In my opinion TTree::ReadFile() is a great way to let beginners enjoy the awesome features of quick look data analysis via TTree:Draw() without the need to write lengthy code.

However, I have two issues with the baviour of TTree::ReadFile() I would like to bring up here.

Issue 1:

From the documentation of the method http://root.cern.ch/root/html/TTree.html#TTree:ReadFile:

One may get the impression, that a file like this (named “test.txt”)

# ignored
a/I:b/F:c/D
1 2.3 3.9
# ignored

4 2.3 1.234

can be parsed easily with these two lines of code on the ROOT cmd line

root [0] t = TTree()
(class TTree) [...]
root [1] r.ReadFile("test.txt")

But this is not the case, since the tree descriptor really needs to be the very first line of the file.
I wonder if this could be changed like:
The tree descriptor is the first valid line found in the file … .i.e the 2nd line in my example.

Issue2:

External programs might create textual data, which is either infinity or even not-a-number. Usually represented as text by “NaN”, “nan”, “inf”, “-inf” or the like. However ReadLine() is currently not able to correctly parse these representations. I once found a post here, which elaborated the reason for it, but I can’t find it anymore.
However I remember the reason to be the behaviour of the >> operator of std::ifstream. It simply can’t deal with “Nan” or the like.

There is a thread on Stack Overflow discussing this as well:
http://stackoverflow.com/questions/11420263/is-it-possible-to-read-infinity-or-nan-values-using-input-streams

And I believe one might solve this issue by doing something similar to this:
http://ideone.com/qIFVo.

I am not sure if one can consider any of these two issues as a bug, since it is like this since a long time now. However maybe one could still consider changing the behaviour of ReadLine() since it will most certainly not be a compatibility issue.

Thank you for your attention.

Re: your issue 1:

I already raised this a while ago, but it received no attention. Bug in TTree::ReadFile
I also filed an official bug about it: sft.its.cern.ch/jira/browse/ROOT-5471

Perhaps adding information/comments to the bug tracker will make it more interesting to work on.

Re: your issue 2:

The way ROOT deals with infinity or NaN values is not consistent. I have made two previous posts about it in different contexts:


Again, they didn’t get much attention.

Jean-François

Hi Jean-Francois,

thanks for your reply. I will create myself an account, so I can add some comments in that bug tracker.
(Not sure how to do that…yet)

However, now that I read your comment about how wierd Inf/Nan are treated by THn (would not have believed this) I am not sure if ReadFile() should be able to parse “Inf” and “Nan” … at least not before those values are treated correctly by THn …

Cheers
Dominik