CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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 41 of file MtvClusterizer1D.h.

41 : theEstimator(est.clone()) {}
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 44 of file MtvClusterizer1D.h.

44  {
45  delete theEstimator;
46 }
WeightEstimator< T > * theEstimator

Member Function Documentation

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

Implements Clusterizer1D< T >.

Definition at line 49 of file MtvClusterizer1D.h.

49  {
50  return new MtvClusterizer1D<T>(*this);
51 }
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 54 of file MtvClusterizer1D.h.

References Clusterizer1DCommons::add(), dataset::end, submitPVValidationJobs::err, mps_fire::i, position, runTheMatrix::ret, mathSSE::sqrt(), Clusterizer1DCommons::square(), findQualityFiles::v, and histoStyle::weight.

55  {
56  typedef Cluster1D<T> Cluster1D;
57  using namespace Clusterizer1DCommons;
58  std::vector<const T*> unusedtracks;
59  switch (ov.size()) {
60  case 0:
61  throw Clustering1DException("[MtvClusterizer1D] no values given");
62  case 1:
63  std::pair<std::vector<Cluster1D>, std::vector<const T*> > ret(ov, unusedtracks);
64  return ret;
65  };
66  std::vector<Cluster1D> v = ov;
67  sort(v.begin(), v.end(), ComparePairs<T>());
68  std::vector<Cluster1D> sols;
69  std::vector<const T*> trks;
70 
71  typename std::vector<Cluster1D>::iterator cur = v.begin();
72  typename std::vector<Cluster1D>::iterator end = (v.end() - 1);
73  double cur_min = cur->weight() + (cur + 1)->weight();
74 
75  for (typename std::vector<Cluster1D>::iterator i = v.begin(); i != end; ++i) {
76  double cur_val = i->weight() + (i + 1)->weight();
77  if (cur_val > cur_min) {
78  cur_min = cur_val;
79  cur = i;
80  };
81  };
82 
83  double weight = (cur->weight() + (cur + 1)->weight());
84  double est = (cur->weight() * cur->position().value() + (cur + 1)->weight() * (cur + 1)->position().value()) / weight;
85  double sigma = sqrt(square(cur->position().value() - est) + square((cur + 1)->position().value() - est));
86  double err = 0.;
87  int inliers = 0;
88 
89  for (typename std::vector<Cluster1D>::iterator i = v.begin(); i != v.end(); ++i) {
90  if (fabs(i->position().value() - est) < 3 * sigma) {
91  // all within 3 sigma are 'in'
92  add(i->tracks(), trks);
93  err += square(i->position().value() - est);
94  inliers++;
95  } else {
96  add(i->tracks(), unusedtracks);
97  };
98  };
99  err /= (inliers - 1); // the algo definitely produces 2 or more inliers
100  err = sqrt(err);
101 
102  sols.push_back(Cluster1D(Measurement1D(est, err), trks, weight));
103  std::pair<std::vector<Cluster1D>, std::vector<const T*> > ret(sols, unusedtracks);
104  return ret;
105 }
tuple ret
prodAgent to be discontinued
T sqrt(T t)
Definition: SSEVec.h:19
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
static double square(double x)
static int position[264][3]
Definition: ReadPGInfo.cc:289
string end
Definition: dataset.py:937
int weight
Definition: histoStyle.py:51

Member Data Documentation

template<class T>
float MtvClusterizer1D< T >::theErrorStretchFactor
private

Definition at line 29 of file MtvClusterizer1D.h.

template<class T>
WeightEstimator<T>* MtvClusterizer1D< T >::theEstimator
private

Definition at line 28 of file MtvClusterizer1D.h.