test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
MultiClusterizer1D< T > Class Template Reference

#include <MultiClusterizer1D.h>

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

Public Member Functions

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

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.

57  : theEstimator ( est.clone() ), theSingle ( single.clone() )
58 {}
WeightEstimator< T > * theEstimator
Clusterizer1D< T > * theSingle
virtual Clusterizer1D * clone() const =0
virtual WeightEstimator * clone() const =0
template<class T>
MultiClusterizer1D< T >::MultiClusterizer1D ( const MultiClusterizer1D< T > &  )
template<class T >
MultiClusterizer1D< T >::~MultiClusterizer1D ( )

Definition at line 61 of file MultiClusterizer1D.h.

62 {
63  delete theEstimator;
64  delete theSingle;
65 }
WeightEstimator< T > * theEstimator
Clusterizer1D< T > * 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.

69 {
70  return new MultiClusterizer1D<T>( *this );
71 }
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.

76 {
77  using namespace Clusterizer1DCommons;
78  // using namespace MultiClusterizer1DNameSpace;
79  typedef Cluster1D<T> Cluster1D;
80  std::vector < const T * > unusedtracks;
81  switch ( ov.size() )
82  {
83  case 0:
84  throw Clustering1DException("[MultiClusterizer1D] no values given" );
85  case 1:
86  std::pair < std::vector < Cluster1D >, std::vector < const T * > > ret ( ov, unusedtracks );
87  return ret;
88  };
89 
90  std::pair < std::vector< Cluster1D >, std::vector< const T * > > res;
91 
92  // works only with one track per cluster!!!
93  std::map < const T *, Cluster1D > ass;
94  std::vector < Cluster1D > cur;
95 
96  for ( typename std::vector< Cluster1D >::const_iterator i=ov.begin();
97  i!=ov.end() ; ++i )
98  {
99  if ( i->tracks().size()==1 )
100  {
101  ass[ i->tracks()[0] ]=*i;
102  }
103  cur.push_back ( *i );
104  }
105 
106  int ctr=0;
107  try {
108  while ( true )
109  {
110  std::pair < std::vector< Cluster1D >, std::vector< const T * > > tmp = (*theSingle)( cur );
111 
112  for ( typename std::vector< Cluster1D >::const_iterator i=tmp.first.begin();
113  i!=tmp.first.end() ; ++i )
114  {
115  res.first.push_back ( *i );
116  }
117  res.second=tmp.second;
118 
119  cur.clear();
120 
121  for ( typename std::vector< const T * >::const_iterator
122  i=res.second.begin(); i!=res.second.end() ; ++i )
123  {
124  cur.push_back ( ass[*i] );
125  }
126  if ( ctr++ > 5 ) break;
127  if ( cur.size() < 2 ) break;
128  }
129  } catch ( ... ) {};
130 
131  return res;
132 }
int i
Definition: DBlmapReader.cc:9
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100

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.