CMS 3D CMS Logo

Public Member Functions | Private Attributes

FsmwClusterizer1D< T > Class Template Reference

#include <FsmwClusterizer1D.h>

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

List of all members.

Public Member Functions

virtual FsmwClusterizer1Dclone () const
 FsmwClusterizer1D (const FsmwClusterizer1D &)
 FsmwClusterizer1D (double fraction=.05, double n_sigma_in=3., const WeightEstimator< T > &est=TrivialWeightEstimator< T >())
std::pair< std::vector
< Cluster1D< T >
>, std::vector< const T * > > 
operator() (const std::vector< Cluster1D< T > > &) const
 ~FsmwClusterizer1D ()

Private Attributes

WeightEstimator< T > * theEstimator
double theFraction
double theNSigmaIn

Detailed Description

template<class T>
class FsmwClusterizer1D< T >

Fraction-of sample mode with weights clustering

Definition at line 17 of file FsmwClusterizer1D.h.


Constructor & Destructor Documentation

template<class T >
FsmwClusterizer1D< T >::FsmwClusterizer1D ( double  fraction = .05,
double  n_sigma_in = 3.,
const WeightEstimator< T > &  est = TrivialWeightEstimator<T>() 
)
Parameters:
fractionfraction of values that will be considered to be 'in'.

Definition at line 163 of file FsmwClusterizer1D.h.

    : theEstimator ( est.clone() ), theFraction ( fraction ), theNSigmaIn ( nsig )
{}
template<class T>
FsmwClusterizer1D< T >::FsmwClusterizer1D ( const FsmwClusterizer1D< T > &  )
template<class T >
FsmwClusterizer1D< T >::~FsmwClusterizer1D ( )

Definition at line 169 of file FsmwClusterizer1D.h.

{
    delete theEstimator;
}

Member Function Documentation

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

Implements Clusterizer1D< T >.

Definition at line 175 of file FsmwClusterizer1D.h.

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

Implements Clusterizer1D< T >.

Definition at line 182 of file FsmwClusterizer1D.h.

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

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

    switch ( ov.size() )
    {
    case 0:
        throw Clustering1DException("[FsmwClusterizer1D] 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::pair < typename std::vector< Cluster1D >::const_iterator,
    typename std::vector< Cluster1D >::const_iterator > estors
    = fsmw ( v, theFraction );

    double weight = estors.first->weight() + estors.second->weight();
    double est = ( estors.first->weight() * estors.first->position().value() +
                   estors.second->weight() * estors.second->position().value() ) /
                 weight;
    double err=0.;
    double sigma = sqrt ( square ( estors.first->position().value() - est ) +
                          square ( estors.second->position().value() - est ));
    /*
    std::cout << "[FsmwClusterizer1D] first=" << estors.first->position().value()
              << " second=" << estors.second->position().value()
              << " est=" << est << std::endl;
    double sigma = sqrt ( square ( estors.first->position().error() ) +
                          square ( estors.second->position().error() ) );
    double sigma = estors.first->position().error();
                          */
    std::vector < const T * > trks;
    int inliers=0;

    for ( typename std::vector< Cluster1D >::iterator i=v.begin();
            i!=v.end() ; ++i )
    {
        /*
        std::cout << "[FsmwClusterizer1D] see if they're in: delta="
                  << 10000 * fabs ( i->position().value() - est )
                  << " sigma=" << 10000 * sigma << std::endl;
         */
        if ( fabs ( i->position().value() - est ) < theNSigmaIn * sigma )
        {
            // all within theNSigmaIn 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 );


    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>
WeightEstimator<T>* FsmwClusterizer1D< T >::theEstimator [private]

Definition at line 33 of file FsmwClusterizer1D.h.

template<class T>
double FsmwClusterizer1D< T >::theFraction [private]

Definition at line 34 of file FsmwClusterizer1D.h.

template<class T>
double FsmwClusterizer1D< T >::theNSigmaIn [private]

Definition at line 35 of file FsmwClusterizer1D.h.