CMS 3D CMS Logo

MtvClusterizer1D< T > Class Template Reference

Hsm clusterizer in one dimension, originally designed for ApexPoint Finding. More...

#include <CommonTools/Clustering1D/interface/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>()  )  [inline]

Definition at line 46 of file MtvClusterizer1D.h.

00047                                      : theEstimator ( est.clone() )
00048 {}

template<class T>
MtvClusterizer1D< T >::MtvClusterizer1D ( const MtvClusterizer1D< T > &  o  )  [inline]

Definition at line 40 of file MtvClusterizer1D.h.

00041                                     : theEstimator ( o.theEstimator->clone() )
00042 {}

template<class T>
MtvClusterizer1D< T >::~MtvClusterizer1D (  )  [inline]

Definition at line 52 of file MtvClusterizer1D.h.

References MtvClusterizer1D< T >::theEstimator.

00053 {
00054     delete theEstimator;
00055 }


Member Function Documentation

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

Implements Clusterizer1D< T >.

Definition at line 58 of file MtvClusterizer1D.h.

00059 {
00060     return new MtvClusterizer1D<T> ( * this );
00061 }

template<class T>
std::pair< std::vector< Cluster1D< T > >, std::vector< const T * > > MtvClusterizer1D< T >::operator() ( const std::vector< Cluster1D< T > > &  ov  )  const [inline, virtual]

Implements Clusterizer1D< T >.

Definition at line 65 of file MtvClusterizer1D.h.

References end, err, i, python::multivaluedict::sort(), funct::sqrt(), square(), v, and weight.

00066 {
00067     typedef Cluster1D<T> Cluster1D;
00068     using namespace Clusterizer1DCommons;
00069     std::vector < const T * > unusedtracks;
00070     switch ( ov.size() )
00071     {
00072     case 0:
00073         throw Clustering1DException("[MtvClusterizer1D] no values given" );
00074     case 1:
00075         std::pair < std::vector < Cluster1D >, std::vector < const T * > > ret ( ov, unusedtracks );
00076         return ret;
00077     };
00078     std::vector < Cluster1D > v = ov;
00079     sort ( v.begin(), v.end(), ComparePairs<T>() );
00080     std::vector < Cluster1D > sols;
00081     std::vector < const T * > trks;
00082 
00083     typename std::vector< Cluster1D >::iterator cur = v.begin();
00084     typename std::vector< Cluster1D >::iterator   end = (v.end() - 1 );
00085     double cur_min = cur->weight() + ( cur+1 )->weight();
00086 
00087     for ( typename std::vector< Cluster1D >::iterator i=v.begin();
00088             i!=end ; ++i )
00089     {
00090         double cur_val = i->weight() + ( i+1 )->weight();
00091         if ( cur_val > cur_min )
00092         {
00093             cur_min = cur_val;
00094             cur = i;
00095         };
00096     };
00097 
00098     double weight = ( cur->weight() + (cur+1)->weight() );
00099     double est = ( cur->weight() * cur->position().value() +
00100                    (cur+1)->weight() * (cur+1)->position().value()) / weight;
00101     double sigma = sqrt ( square ( cur->position().value() - est ) +
00102                           square ( (cur+1)->position().value() - est ) );
00103     double err=0.;
00104     int inliers=0;
00105 
00106     for ( typename std::vector< Cluster1D >::iterator i=v.begin();
00107             i!=v.end() ; ++i )
00108     {
00109         if ( fabs ( i->position().value() - est ) < 3 * sigma )
00110         {
00111             // all within 3 sigma are 'in'
00112             add
00113                 ( i->tracks(), trks );
00114             err+= square ( i->position().value() - est );
00115             inliers++;
00116         }
00117         else
00118         {
00119             add
00120                 ( i->tracks(), unusedtracks );
00121         };
00122     };
00123     err /= ( inliers - 1 ); // the algo definitely produces 2 or more inliers
00124     err = sqrt ( err );
00125 
00126     sols.push_back ( Cluster1D ( Measurement1D ( est,err ), trks, weight ) );
00127     std::pair < std::vector < Cluster1D >, std::vector < const T * > > ret ( sols, unusedtracks );
00128     return ret;
00129 }


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.

Referenced by MtvClusterizer1D< T >::~MtvClusterizer1D().


The documentation for this class was generated from the following file:
Generated on Tue Jun 9 18:28:25 2009 for CMSSW by  doxygen 1.5.4