CMS 3D CMS Logo

Public Member Functions | Private Attributes

MtvClusterizer1D< T > Class Template Reference

#include <MtvClusterizer1D.h>

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

List of all members.

Public Member Functions

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

Private Attributes

float theErrorStretchFactor
WeightEstimator< T > * theEstimator

Detailed Description

template<class T>
class MtvClusterizer1D< T >

Hsm clusterizer in one dimension, originally designed for ApexPoint Finding

Definition at line 17 of file MtvClusterizer1D.h.


Constructor & Destructor Documentation

template<class T >
MtvClusterizer1D< T >::MtvClusterizer1D ( const WeightEstimator< T > &  est = TrivialWeightEstimator<T>())

Definition at line 46 of file MtvClusterizer1D.h.

                                     : theEstimator ( est.clone() )
{}
template<class T>
MtvClusterizer1D< T >::MtvClusterizer1D ( const MtvClusterizer1D< T > &  )
template<class T >
MtvClusterizer1D< T >::~MtvClusterizer1D ( )

Definition at line 52 of file MtvClusterizer1D.h.

{
    delete theEstimator;
}

Member Function Documentation

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

Implements Clusterizer1D< T >.

Definition at line 58 of file MtvClusterizer1D.h.

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

Implements Clusterizer1D< T >.

Definition at line 65 of file MtvClusterizer1D.h.

References Clusterizer1DCommons::add(), end, i, position, run_regression::ret, python::multivaluedict::sort(), mathSSE::sqrt(), Clusterizer1DCommons::square(), findQualityFiles::v, and histoStyle::weight.

{
    typedef Cluster1D<T> Cluster1D;
    using namespace Clusterizer1DCommons;
    std::vector < const T * > unusedtracks;
    switch ( ov.size() )
    {
    case 0:
        throw Clustering1DException("[MtvClusterizer1D] no values given" );
    case 1:
        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;
    std::vector < const T * > trks;

    typename std::vector< Cluster1D >::iterator cur = v.begin();
    typename std::vector< Cluster1D >::iterator   end = (v.end() - 1 );
    double cur_min = cur->weight() + ( cur+1 )->weight();

    for ( typename std::vector< Cluster1D >::iterator i=v.begin();
            i!=end ; ++i )
    {
        double cur_val = i->weight() + ( i+1 )->weight();
        if ( cur_val > cur_min )
        {
            cur_min = cur_val;
            cur = i;
        };
    };

    double weight = ( cur->weight() + (cur+1)->weight() );
    double est = ( cur->weight() * cur->position().value() +
                   (cur+1)->weight() * (cur+1)->position().value()) / weight;
    double sigma = sqrt ( square ( cur->position().value() - est ) +
                          square ( (cur+1)->position().value() - est ) );
    double err=0.;
    int inliers=0;

    for ( typename std::vector< Cluster1D >::iterator i=v.begin();
            i!=v.end() ; ++i )
    {
        if ( fabs ( i->position().value() - est ) < 3 * sigma )
        {
            // all within 3 sigma are 'in'
            add
                ( i->tracks(), trks );
            err+= square ( i->position().value() - est );
            inliers++;
        }
        else
        {
            add
                ( i->tracks(), unusedtracks );
        };
    };
    err /= ( inliers - 1 ); // the algo definitely produces 2 or more inliers
    err = sqrt ( err );

    sols.push_back ( Cluster1D ( Measurement1D ( est,err ), trks, weight ) );
    std::pair < std::vector < Cluster1D >, std::vector < const T * > > ret ( sols, unusedtracks );
    return ret;
}

Member Data Documentation

template<class T>
float MtvClusterizer1D< T >::theErrorStretchFactor [private]

Definition at line 31 of file MtvClusterizer1D.h.

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

Definition at line 30 of file MtvClusterizer1D.h.