Hi,
This is currently not possible. Only function taking numerical arguments
and returning numerical values are usable in TTree::Draw. (In particular,
you can not pass an array). Those functions will be called for each
elements
of the array in an entry (which are selected).
Currently, you need to generate a skeleton of code (eg MakeSelector or
MakeClass), to implement such behavior.
We are planning on releasing later this year, a new interface that will
allow you to run a function in scope such that the branch name give
access to their content. When you have this, you will be able to
run
//file w.C
Float_t w(){
Float_t tmp=0;
for(Int_t i=0; i<50; i++)
tmp+=peUZa[i];
return tmp;
}
Then I did:
TFile f("test.root");
tree->Draw("w.C+");
Cheers,
Philippe
-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Tingjun Yang
Sent: Friday, April 02, 2004 8:17 PM
To: roottalk@pcroot.cern.ch
Subject: [ROOT] Function on array
Hi rooters,
I have a tree file which has an array branch:
*...........................................................................
*
*Br 13 :peUZa : peUZa[50]/F
*
*Entries : 10 : Total Size= 2574 bytes One basket in memory
*
*Baskets : 0 : Basket Size= 32000 bytes Compression= 1.00
*
*...........................................................................
*
I wonder if I can define a function on that array and make a cut on
it. I tried the following way:
//file w.C
Float_t w(Float_t *x){
Float_t tmp=0;
for(Int_t i=0; i<50; i++)
tmp+=x[i];
return tmp;
}
Then I did:
.L w.C++;
TFile f("test.root");
tree->Draw("w(peUZa)");
But it doesn't work. Did I make any mistakes? I'm using the cvs version
on rh9. Thank you.
Regards,
T.J.
This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:07 MET