CMS 3D CMS Logo

MultiClusterizer1D< T > Class Template Reference

A clusterizer that uses a "single" clusterizer iteratively . More...

#include <CommonTools/Clustering1D/interface/MultiClusterizer1D.h>

Inheritance diagram for MultiClusterizer1D< T >:

Clusterizer1D< T >

List of all members.

Public Member Functions

virtual MultiClusterizer1Dclone () const
 MultiClusterizer1D (const MultiClusterizer1D &)
 MultiClusterizer1D (const Clusterizer1D< T > &single, const WeightEstimator< T > &est=TrivialWeightEstimator< T >())
std::pair< std::vector
< Cluster1D< T > >,
std::vector< const T * > > 
operator() (const std::vector< Cluster1D< T > > &) const
 ~MultiClusterizer1D ()

Private Attributes

WeightEstimator< T > * theEstimator
Clusterizer1D< T > * theSingle


Detailed Description

template<class T>
class MultiClusterizer1D< T >

A clusterizer that uses a "single" clusterizer iteratively .

..

Definition at line 20 of file MultiClusterizer1D.h.


Constructor & Destructor Documentation

template<class T>
MultiClusterizer1D< T >::MultiClusterizer1D ( const Clusterizer1D< T > &  single,
const WeightEstimator< T > &  est = TrivialWeightEstimator<T>() 
) [inline]

Definition at line 55 of file MultiClusterizer1D.h.

00057     : theEstimator ( est.clone() ), theSingle ( single.clone() )
00058 {}

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

Definition at line 50 of file MultiClusterizer1D.h.

00051     : theEstimator( o.theEstimator->clone() ), theSingle ( o.theSingle->clone() )
00052 {}

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

Definition at line 61 of file MultiClusterizer1D.h.

References MultiClusterizer1D< T >::theEstimator, and MultiClusterizer1D< T >::theSingle.

00062 {
00063     delete theEstimator;
00064     delete theSingle;
00065 }


Member Function Documentation

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

Implements Clusterizer1D< T >.

Definition at line 68 of file MultiClusterizer1D.h.

00069 {
00070     return new MultiClusterizer1D<T>( *this );
00071 }

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

Implements Clusterizer1D< T >.

Definition at line 75 of file MultiClusterizer1D.h.

References i, res, and tmp.

00076 {
00077     using namespace Clusterizer1DCommons;
00078     // using namespace MultiClusterizer1DNameSpace;
00079     typedef Cluster1D<T> Cluster1D;
00080     std::vector < const T * > unusedtracks;
00081     switch ( ov.size() )
00082     {
00083     case 0:
00084        throw Clustering1DException("[MultiClusterizer1D] no values given" );
00085     case 1:
00086        std::pair < std::vector < Cluster1D >, std::vector < const T * > > ret ( ov, unusedtracks );
00087        return ret;
00088     };
00089 
00090     std::pair < std::vector< Cluster1D >, std::vector< const T * > > res;
00091 
00092     // works only with one track per cluster!!!
00093     std::map < const T *, Cluster1D > ass;
00094     std::vector < Cluster1D > cur;
00095 
00096     for ( typename std::vector< Cluster1D >::const_iterator i=ov.begin(); 
00097           i!=ov.end() ; ++i )
00098     {
00099       if ( i->tracks().size()==1 )
00100       {
00101         ass[ i->tracks()[0] ]=*i;
00102       }
00103       cur.push_back ( *i );
00104     }
00105 
00106     int ctr=0;
00107     try {
00108       while ( true )
00109       {
00110         std::pair < std::vector< Cluster1D >, std::vector< const T * > > tmp = (*theSingle)( cur );
00111 
00112         for ( typename std::vector< Cluster1D >::const_iterator i=tmp.first.begin(); 
00113               i!=tmp.first.end() ; ++i )
00114         {
00115           res.first.push_back ( *i );
00116         }
00117         res.second=tmp.second;
00118 
00119         cur.clear();
00120 
00121         for ( typename std::vector< const T * >::const_iterator 
00122               i=res.second.begin(); i!=res.second.end() ; ++i )
00123         {
00124           cur.push_back ( ass[*i] );
00125         }
00126         if ( ctr++ > 5 ) break;
00127         if ( cur.size() < 2 ) break;
00128       }
00129     } catch ( ... ) {};
00130 
00131     return res;
00132 }


Member Data Documentation

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

Definition at line 35 of file MultiClusterizer1D.h.

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

template<class T>
Clusterizer1D<T>* MultiClusterizer1D< T >::theSingle [private]

Definition at line 36 of file MultiClusterizer1D.h.

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


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