CMS 3D CMS Logo

Public Member Functions | Private Attributes

OutermostClusterizer1D< T > Class Template Reference

#include <OutermostClusterizer1D.h>

Inheritance diagram for OutermostClusterizer1D< T >:
Clusterizer1D< T >

List of all members.

Public Member Functions

virtual OutermostClusterizer1Dclone () const
std::pair< std::vector
< Cluster1D< T >
>, std::vector< const T * > > 
operator() (const std::vector< Cluster1D< T > > &) const
 OutermostClusterizer1D (const OutermostClusterizer1D &)
 OutermostClusterizer1D (const WeightEstimator< T > &est=TrivialWeightEstimator< T >())
 ~OutermostClusterizer1D ()

Private Attributes

WeightEstimator< T > * theEstimator

Detailed Description

template<class T>
class OutermostClusterizer1D< T >

Produces two clusters for each end of the 1d data points. It then puts 50 % of the points in each cluster.

Definition at line 20 of file OutermostClusterizer1D.h.


Constructor & Destructor Documentation

template<class T >
OutermostClusterizer1D< T >::OutermostClusterizer1D ( const WeightEstimator< T > &  est = TrivialWeightEstimator<T>())
Parameters:
fractionfraction of values that will be considered to be 'in'.

Definition at line 50 of file OutermostClusterizer1D.h.

                                     : theEstimator ( est.clone() )
{}
template<class T >
OutermostClusterizer1D< T >::~OutermostClusterizer1D ( )

Definition at line 55 of file OutermostClusterizer1D.h.

{
    delete theEstimator;
}

Member Function Documentation

template<class T >
OutermostClusterizer1D< T > * OutermostClusterizer1D< T >::clone ( void  ) const [virtual]

Implements Clusterizer1D< T >.

Definition at line 61 of file OutermostClusterizer1D.h.

{
    return new OutermostClusterizer1D<T>( *this );
}
template<class T >
std::pair< std::vector< Cluster1D< T > >, std::vector< const T * > > OutermostClusterizer1D< T >::operator() ( const std::vector< Cluster1D< T > > &  ov) const [virtual]

Implements Clusterizer1D< T >.

Definition at line 68 of file OutermostClusterizer1D.h.

References i, runTheMatrix::ret, python::multivaluedict::sort(), tmp, and v.

{
    using namespace Clusterizer1DCommons;
    typedef Cluster1D<T> Cluster1D;
    std::vector < const T * > unusedtracks;

    switch ( ov.size() )
    {
    case 0:
        throw Clustering1DException("[OutermostClusterizer1D] no values given" );
    case 1:
      {
        std::pair < std::vector < Cluster1D >, std::vector < const T * > > ret ( ov, unusedtracks );
        return ret;
      };
    case 2:
      {
        std::pair < std::vector < Cluster1D >, std::vector < const T * > > ret ( ov, unusedtracks );
        return ret;
      };
    };

    std::vector < Cluster1D > v = ov;
    sort ( v.begin(), v.end(), ComparePairs<T>() );
    std::vector < Cluster1D > sols;
    int sze=v.size()/2;
    Cluster1D tmp = v[0];
    Cluster1DMerger< T > merger ( *theEstimator );
    // merge the inner half to the primary cluster
    for ( typename std::vector< Cluster1D >::const_iterator i=v.begin()+1; i!=v.begin()+sze ; ++i )
    {
      tmp = merger ( tmp, *i );
    }
    sols.push_back ( tmp );
    tmp=v[sze];
    for ( typename std::vector< Cluster1D >::const_iterator i=v.begin()+sze+1; i!=v.end() ; ++i )
    {
      tmp = merger ( tmp, *i );
    }
    sols.push_back ( tmp );

    std::pair < std::vector < Cluster1D >, std::vector < const T * > > ret ( sols, unusedtracks );
    return ret;
}

Member Data Documentation

template<class T>
WeightEstimator<T>* OutermostClusterizer1D< T >::theEstimator [private]

Definition at line 36 of file OutermostClusterizer1D.h.