Hi,
I am using a TSelector proxy with a tree that has array branches. The
selector calls a user defined function which takes the array as a parameter.
Depending on the use the array gets passed to the function by the proxy
as different types which makes the compilation of the proxy fail. Example:
// fun.h
double fun(const Double_t v[5]){
return v[0];
}
//calc.h
#include "fun.h"
//calc.C
double calc() {
double val = fun(a);
return val;
}
Then, interactively in root, do
TTree t;
Double_t a[5];
Double_t b[2][5];
t.Branch("b",b,"b[2][5]/D")
t.Branch("a",a,"a[5]/D");
t.Fill();
t.MakeProxy("calcSel","calc.C");
.L calcSel.h+O;
The error message will be
[quote]/afs/slac.stanford.edu/u/ec/kocian/calc.C: In member function double calcSel::calc()': /afs/slac.stanford.edu/u/ec/kocian/calc.C:2: cannot convert
ROOT::TArrayDoubleProxy’ to const Double_t*' for argument
1’ to `double
fun(const Double_t*)’[/quote]
This error goes away if I replace const Double_t[5] by ROOT::TArrayDoubleProxy in fun.h, but then if I call the function in a different way,
//calc.C
double calc() {
double val = fun(b[0]);
return val;
}
with the interactive code as before, the compiler will complain about the opposite, it wants const Double_t* back.
Is there a way to resolve this conflict short of having two versions of the function?
Also, is 3 the maximum number of dimensions a TArrayProxy can have or can it have any number of dimensions?
Thank you,
Martin