CMS 3D CMS Logo

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

◆ MtvClusterizer1D() [1/2]

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

◆ MtvClusterizer1D() [2/2]

template<class T>
MtvClusterizer1D< T >::MtvClusterizer1D ( const MtvClusterizer1D< T > &  )

◆ ~MtvClusterizer1D()

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

◆ clone()

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 }

◆ operator()()

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(), submitPVResolutionJobs::err, mps_fire::i, position, runTheMatrix::ret, jetUpdater_cfi::sort, mathSSE::sqrt(), Clusterizer1DCommons::square(), hltEgammaHLTExtra_cfi::trks, findQualityFiles::v, and mps_merge::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 }
ret
prodAgent to be discontinued
Definition: weight.py:1
T sqrt(T t)
Definition: SSEVec.h:19
static double square(double x)
void add(std::map< std::string, TH1 *> &h, TH1 *hist)
static int position[264][3]
Definition: ReadPGInfo.cc:289

Member Data Documentation

◆ theErrorStretchFactor

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

Definition at line 29 of file MtvClusterizer1D.h.

◆ theEstimator

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

Definition at line 28 of file MtvClusterizer1D.h.