Is it possible to draw the sum of elements of an array with TTree->Draw() ?
Suppose we have a branch with a simple array of variable size, does something like this exists :
tree->Draw(“sum(arr)”)
where sum(arr) = arr[0]+arr[1]+…+arr[size(arr)-1].
A possibly connected question : is there a variable a bit like Iteration$, let say Ntrue$, which is the number of time the expression in the selection was evaluated as true for one event ?
For exemple :
tree->Draw(“Ntrue$”,“arr>5”);
Which would fill an histo with one entry by event this entry being the number of element of arr greater than 5.
From my understanding of the Draw() function, I fear it may not be possible…
But is there any way to do such things ?
The proxy mechanism is very usefull. But I need to write a file for each variable I want to plot , is this correct ?
Would it be a good idea to suggest implementation of such an Ntrue$ variable or a sum mechanism (or other simple manipulation like product or other) ?
If yes and if there is an official way to ask for new features I’m willing to do it !
[quote]If yes and if there is an official way to ask for new features I’m willing to do it ! [/quote]You just did
About Ntrue$ does not really fit in the general flow of TTreeFormula (it would requires to keep a state from a previous implementation) but it could be implemented in term of Sum$:
tree->Draw(“Sum$(arr<2)”);
I will think about implementing Sum$.
// Sum$(formula): return the sum of the value of the elements of the formula given
// as a parameter. For eaxmple the mean for all the elements n
// one entry can be calculated with:
// Sum$(formula)/Length$(formula)
is the new TTreeFormual special function. It will be upload in CVS shortly.