CMS 3D CMS Logo

Public Member Functions | Private Attributes

MultiClusterizer1D< T > Class Template Reference

#include <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>() 
)

Definition at line 55 of file MultiClusterizer1D.h.

    : theEstimator ( est.clone() ), theSingle ( single.clone() )
{}
template<class T>
MultiClusterizer1D< T >::MultiClusterizer1D ( const MultiClusterizer1D< T > &  )
template<class T >
MultiClusterizer1D< T >::~MultiClusterizer1D ( )

Definition at line 61 of file MultiClusterizer1D.h.

{
    delete theEstimator;
    delete theSingle;
}

Member Function Documentation

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

Implements Clusterizer1D< T >.

Definition at line 68 of file MultiClusterizer1D.h.

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

Implements Clusterizer1D< T >.

Definition at line 75 of file MultiClusterizer1D.h.

References i, run_regression::ret, and tmp.

{
    using namespace Clusterizer1DCommons;
    // using namespace MultiClusterizer1DNameSpace;
    typedef Cluster1D<T> Cluster1D;
    std::vector < const T * > unusedtracks;
    switch ( ov.size() )
    {
    case 0:
       throw Clustering1DException("[MultiClusterizer1D] no values given" );
    case 1:
       std::pair < std::vector < Cluster1D >, std::vector < const T * > > ret ( ov, unusedtracks );
       return ret;
    };

    std::pair < std::vector< Cluster1D >, std::vector< const T * > > res;

    // works only with one track per cluster!!!
    std::map < const T *, Cluster1D > ass;
    std::vector < Cluster1D > cur;

    for ( typename std::vector< Cluster1D >::const_iterator i=ov.begin(); 
          i!=ov.end() ; ++i )
    {
      if ( i->tracks().size()==1 )
      {
        ass[ i->tracks()[0] ]=*i;
      }
      cur.push_back ( *i );
    }

    int ctr=0;
    try {
      while ( true )
      {
        std::pair < std::vector< Cluster1D >, std::vector< const T * > > tmp = (*theSingle)( cur );

        for ( typename std::vector< Cluster1D >::const_iterator i=tmp.first.begin(); 
              i!=tmp.first.end() ; ++i )
        {
          res.first.push_back ( *i );
        }
        res.second=tmp.second;

        cur.clear();

        for ( typename std::vector< const T * >::const_iterator 
              i=res.second.begin(); i!=res.second.end() ; ++i )
        {
          cur.push_back ( ass[*i] );
        }
        if ( ctr++ > 5 ) break;
        if ( cur.size() < 2 ) break;
      }
    } catch ( ... ) {};

    return res;
}

Member Data Documentation

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

Definition at line 35 of file MultiClusterizer1D.h.

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

Definition at line 36 of file MultiClusterizer1D.h.