I have a tree that contains an array of candidates for each entry. I want to be able to use simple Tree::Draw and Tree::Scan with cuts. The default behaviour is to return all elements of the array that pass a selection cut, but I’d like to replace this with a selection of unique element that satisfies some selection criteria - for example best candidate selection, e.i. element with highest Chi^2 probability.
Clearly all this can be done by explicit looping over all entries, but I’d like to avoid this, because this leads to extra complication. In principle this can be easily implemented with a user defined function that take as input a pointer to array and it’s length and returns index number, like this:
tree->Draw(“mass[best_cand(chi2prob,nElements)]”,“energy>1.0”)
Unfortunately this doesn’t work since I cannot get the whole array of elements to my function whatever I do. I’m also not sure that the array
contains only elements that passed the cut.
thanks for your reply. As far as I can see this example shows how I can access all selected raws and elements as one long array. It makes the problem a bit complicated since I need to select only at most one element of a raw. If I have one big array (or few of them) I have to to figure out the original 2D structure raws X elements to get a raws X 1 element.
I hoped that I can somehow change the way this final big array is created by replacing loop on elements within one raw with user defined function. Is it possible.