Functions | |
template<class T > | |
std::pair< typename std::vector< Cluster1D< T > >::const_iterator, typename std::vector< Cluster1D< T > >::const_iterator > | fsmw (const std::vector< Cluster1D< T > > &values, double fraction) |
std::pair< typename std::vector< Cluster1D<T> >::const_iterator,typename std::vector< Cluster1D<T> >::const_iterator > FsmwClusterizer1DNameSpace::fsmw | ( | const std::vector< Cluster1D< T > > & | values, |
double | fraction | ||
) |
Definition at line 53 of file FsmwClusterizer1D.h.
References begin, gather_cfg::cout, end, i, position, run_regression::ret, findQualityFiles::size, createBeamHaloJobs::stepsize, makeHLTPrescaleTable::values, and w().
Referenced by FsmwClusterizer1D< T >::operator()().
{ typedef Cluster1D<T> Cluster1D; typename std::vector< Cluster1D >::const_iterator begin = values.begin(); typename std::vector< Cluster1D >::const_iterator end = values.end()-1; while (1) { #ifdef FsmwClusterizer1DDebug cout << "Begin at " << begin->position().value() << endl; #endif const int size = (int) (end-begin); #ifdef FsmwClusterizer1DDebug cout << "Size " << size << endl; #endif int stepsize = (int) floor ( ( 1+ size ) * fraction ); if ( stepsize == 0 ) stepsize=1; #ifdef FsmwClusterizer1DDebug cout << "Old end at " << end->position().value() << endl; #endif end=begin+stepsize; typename std::vector< Cluster1D >::const_iterator new_begin = begin; typename std::vector< Cluster1D >::const_iterator new_end = end; #ifdef FsmwClusterizer1DDebug cout << "New end at " << end->position().value() << endl; cout << "stepsize " << stepsize << endl; #endif // Old version: used the weights of just the end points // double totalweight = begin->weight() + end->weight(); // new version: sums up the weights of all points involved // _including_ the "end" point double totalweight = end->weight(); for ( typename std::vector< Cluster1D >::const_iterator w=begin; w!=end ; ++w ) { totalweight+=w->weight(); }; double div=fabs ( end->position().value() - begin->position().value() ) / totalweight; #ifdef FsmwClusterizer1DDebug cout << "Div at " << begin->position().value() << ":" << (end)->position().value() << " = " << div << endl; #endif for ( typename std::vector< Cluster1D >::const_iterator i = (begin + 1); i!=(begin + size - stepsize + 1); ++i ) { // FIXME wrong // double tmpweight = i->weight() + (i+stepsize)->weight(); // // new version: sums up the weights of all points in the interval // _including_ the end point (i+stepsize) double tmpweight = 0.; for ( typename std::vector< Cluster1D >::const_iterator wt=i; wt!=(i+stepsize+1); ++wt ) { tmpweight+=wt->weight(); }; double tmpdiv = fabs( i->position().value() - (i+stepsize)->position().value() ) / tmpweight; #ifdef FsmwClusterizer1DDebug cout << "Div at " << i->position().value() << ":" << (i+stepsize)->position().value() << " = " << tmpdiv << endl; #endif if ( tmpdiv < div) { new_begin= i; new_end = i+stepsize; div= tmpdiv; }; }; #ifdef FsmwClusterizer1DDebug cout << "---- new interval: " << new_begin->position().value() << ":" << new_end->position().value() << endl; #endif begin = new_begin; end = new_end; if ( size < 4 ) break; }; std::pair < typename std::vector< Cluster1D >::const_iterator, typename std::vector< Cluster1D >::const_iterator > ret ( begin, end ); return ret; }