Dear Root Developers,
I am experiencing a weird problem with TTreeFormula; it seems to leave out some characters from the string that I input. It is root 5.34/12 on an ubuntu 12.04 LTS machine. root was installed from the source.
Take a simple example, if I execute a draw command in the root prompt like this:
GetChannelByID() is a member function in an event class and returns a pointer to a class “ChannalData”, which has a member “minimum”. The libraries have been loaded in root.
It may return an error message as below:
Error in TTreeFormula::DefinedVariable: inimum is not a datamember of ChannelData
Error in TTreeFormula::AnalyzeFunction: We thought we had a function but we dont (in GetChannelByID(-2).minimum)
Error in TTreeFormula::Compile: Bad numerical expression : “GetChannelByID(-2).minimum”
Note that the input string contains the name “minimum”, but TTreeFormula::DefinedVariable complains about “inimum” not existing, which leaves out the letter ‘m’ in the beginning. Meanwhile TTreeFormula::AnalyzeFunction and TTreeFormula::Compile know it is “minimum”.
If I add a random letter before “minimum”, like the letter 'm’
root runs okay, but the title of the histogram shows the extra ‘m’ before “minimum”.
This problem only happens when I call the channel number -2 by “GetChannelByID(-2)”, and I don’t get any problem with other channels. For example
runs perfectly okay. Personally I don’t think there is anything special about the channel number -2, and I can draw channel -2 data using an alternative way not calling the function GetChannelByID().
As more tests, I tried the commands on the channels that do not exist (my data don’t have channel 9 or channel 10)
In this case root complains about channel 9 doesn’t exist, which is as expected.
Surprisingly, root complains about “inimum” doesn’t exist again, exactly as channel -2.
So I conclude that when TTreeFormula interprets user defined functions, it may parse the character string wrong. In my case, something breaks when I have two digits/letters (-2 or 10) in the user defined function, but things are okay when there is only one digit (0, 1…).