TTree::Draw() and user namespace


I have a problem using an array defined in my own namespace with TTree::Draw() method.
For example, If I define the namespace like this:

namespace MyNameSpace {
  int A;
  int B[2];

and try to run this piece of code:

MyNameSpace::A = 1;
MyNameSpace::B[0] = 2;
MyNameSpace::B[1] = 3;

tree->Draw("MyMethod(MyNameSpace::A)");    // works
tree->Draw("MyMethod(MyNameSpace::B[0])"); // does not work

there is no problem using MyNameSpace::A as an argument of TTree::Draw(), but when I’m trying to use MyNameSpace::B[0], I get the following error:

Error in TTreeFormula::Compile: Bad numerical expression “MyNameSpace::B[0]” [/quote]
How do I solve this problem?
My ROOT version is 5.15/07

My LinkDef.h file contains this line:

#pragma link C++ namespace MyNameSpace+;


To work around this issue, create a function that takes an int and return the correct B valuenamespace MyNameSpace { int GetB(int i) { return B[i]; }


Yes, I understand that it is possible to create a function.
Actually, I would like to use construction like MyNameSpace::B[0].
So, I should have asked not “How do I solved this problem” but “Why it does not work?”.

[quote]So, I should have asked not “How do I solved this problem” but “Why it does not work?”[/quote]This is due to the TFormula/TTreeFormula parser which extract and treat separately the array arguments and does not use it at all for lookup global variable lookup.