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
MtvClusterizer1D< T > Class Template Reference

#include <MtvClusterizer1D.h>

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

Public Member Functions

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

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

Definition at line 46 of file MtvClusterizer1D.h.

47  : theEstimator ( est.clone() )
48 {}
WeightEstimator< T > * theEstimator
virtual WeightEstimator * clone() const =0
template<class T>
MtvClusterizer1D< T >::MtvClusterizer1D ( const MtvClusterizer1D< T > &  )
template<class T >
MtvClusterizer1D< T >::~MtvClusterizer1D ( )

Definition at line 52 of file MtvClusterizer1D.h.

53 {
54  delete theEstimator;
55 }
WeightEstimator< T > * theEstimator

Member Function Documentation

template<class T >
MtvClusterizer1D< T > * MtvClusterizer1D< T >::clone ( void  ) const
virtual

Implements Clusterizer1D< T >.

Definition at line 58 of file MtvClusterizer1D.h.

59 {
60  return new MtvClusterizer1D<T> ( * this );
61 }
template<class T >
std::pair< std::vector< Cluster1D< T > >, std::vector< const T * > > MtvClusterizer1D< T >::operator() ( const std::vector< Cluster1D< T > > &  ov) const
virtual

Implements Clusterizer1D< T >.

Definition at line 65 of file MtvClusterizer1D.h.

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

66 {
67  typedef Cluster1D<T> Cluster1D;
68  using namespace Clusterizer1DCommons;
69  std::vector < const T * > unusedtracks;
70  switch ( ov.size() )
71  {
72  case 0:
73  throw Clustering1DException("[MtvClusterizer1D] no values given" );
74  case 1:
75  std::pair < std::vector < Cluster1D >, std::vector < const T * > > ret ( ov, unusedtracks );
76  return ret;
77  };
78  std::vector < Cluster1D > v = ov;
79  sort ( v.begin(), v.end(), ComparePairs<T>() );
80  std::vector < Cluster1D > sols;
81  std::vector < const T * > trks;
82 
83  typename std::vector< Cluster1D >::iterator cur = v.begin();
84  typename std::vector< Cluster1D >::iterator end = (v.end() - 1 );
85  double cur_min = cur->weight() + ( cur+1 )->weight();
86 
87  for ( typename std::vector< Cluster1D >::iterator i=v.begin();
88  i!=end ; ++i )
89  {
90  double cur_val = i->weight() + ( i+1 )->weight();
91  if ( cur_val > cur_min )
92  {
93  cur_min = cur_val;
94  cur = i;
95  };
96  };
97 
98  double weight = ( cur->weight() + (cur+1)->weight() );
99  double est = ( cur->weight() * cur->position().value() +
100  (cur+1)->weight() * (cur+1)->position().value()) / weight;
101  double sigma = sqrt ( square ( cur->position().value() - est ) +
102  square ( (cur+1)->position().value() - est ) );
103  double err=0.;
104  int inliers=0;
105 
106  for ( typename std::vector< Cluster1D >::iterator i=v.begin();
107  i!=v.end() ; ++i )
108  {
109  if ( fabs ( i->position().value() - est ) < 3 * sigma )
110  {
111  // all within 3 sigma are 'in'
112  add
113  ( i->tracks(), trks );
114  err+= square ( i->position().value() - est );
115  inliers++;
116  }
117  else
118  {
119  add
120  ( i->tracks(), unusedtracks );
121  };
122  };
123  err /= ( inliers - 1 ); // the algo definitely produces 2 or more inliers
124  err = sqrt ( err );
125 
126  sols.push_back ( Cluster1D ( Measurement1D ( est,err ), trks, weight ) );
127  std::pair < std::vector < Cluster1D >, std::vector < const T * > > ret ( sols, unusedtracks );
128  return ret;
129 }
int i
Definition: DBlmapReader.cc:9
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
static int position[TOTALCHAMBERS][3]
Definition: ReadPGInfo.cc:509
T sqrt(T t)
Definition: SSEVec.h:48
#define end
Definition: vmac.h:37
double square(const double a)
int weight
Definition: histoStyle.py:50

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.