Note: this is a complete tangent to what we discussed today…
Looking at the code for PatForwardTool::fillStereoList, I see that the ‘temp' list of hits is sorted at some point:
std::sort( temp.begin(), temp.end(), Tf::increasingByProjection<PatForwardHit>() );
and a bitter further down in the code, there are then various loop like this (where itP is an iterator into temp, with itE > itP):
//== Add all hits inside the maximum spread. If not enough planes, restart while ( itE != temp.end() && spread > (*itE)->projection() - (*itP)->projection() ) ++itE;
which can (I’m pretty sure) be rewritten as:
itE = std::find_if( itE, temp.end(), [&](const PatFwdHit* h) { return h->projection() > (*itP)->projection() + spread ; } );
but then I started to think that the sorted-by-projection list is also sorted by the criteria in the above find_if, and hence the std::find_if can be replaced by std::binary_sort… and I suspect that in a few places here actually a std::equal_range is what is really going on. (then again, might be that the # of items skipped over in find_if may be less than log(N))
Anyway, this code really would benefit from someone transforming it into code using C++11 and generic STL algorithms, and by making it more readable so one can recognize what’s really going on…
-- Gerhard