Best Candidate selection

Hi everyone,

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.

Any idea how to implement this feature?

Thanks,
Dmitriy

See section “How to obtain more info from TTree::Draw” at
root.cern.ch/root/htmldoc/TTree.html#TTree:Draw

Rene

Hi Rere,

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.

Dmitriy

Hi,

In ROOT 4.00/08 you can try to write a small script name getMass.cpp containing:

double getMass() { // write code to loop over the chi2prob and find the best one return bestone; }
and a file named getMassCut.cpp:

and dotree->Draw("getMass.cpp","getMassCut.cpp");

Cheers,
Philippe.

Thanks Philippe,

how can I access a vector of chi2prob in getMass() for current row/entry? It’s stored in a sepate branch.

Best Regards,
Dmitriy

Hi,

If chi2prob and nElements are (sub)branch names, you can literally use

double max = 0; int len = nElements; for(int i=0; i<len; ++i) { if ( ch2prob[i] > max ) max = ch2prob[i]; }
Cheers,
Philippe