TSelector proxies and arrays

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 argument1’ 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

Hi,

I think you code would work fine if you used:double fun(const Double_t *v){ return v[0]; }

[quote]Also, is 3 the maximum number of dimensions a TArrayProxy can have or can it have any number of dimensions? [/quote]Currently, I think it is limited to 3 but could easily be extended.

Cheers,
Philippe

Hi Philippe,

Unfortunately const Double_t *v gives the same error message as
const Double_t v[5], namely

cannot convert ROOT::TArrayDoubleProxy' toconst Double_t*’ for argument 1' todouble fun(const Double_t*)’

It would be nice if a few more dimensions could be added to TArrayProxy.

Thank you,

Martin

[quote]Unfortunately const Double_t *v gives the same error message
[/quote]Humm … yes indeed … You can fix this by changing the call to: double val = fun(&(a[0]));

Cheers,
Philippe.

PS. [quote]It would be nice if a few more dimensions could be added to TArrayProxy. [/quote]We will try to extend it. Could you provide a sample file?