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 MtvClusterizer1D &)
 
 MtvClusterizer1D (const WeightEstimator< T > &est=TrivialWeightEstimator< T >())
 
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()) {}

◆ 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 }

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.

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 }

References Clusterizer1DCommons::add(), mps_fire::end, submitPVResolutionJobs::err, mps_fire::i, position, runTheMatrix::ret, jetUpdater_cfi::sort, mathSSE::sqrt(), Clusterizer1DCommons::square(), hltEgammaHLTExtra_cfi::trks, findQualityFiles::v, and mps_merge::weight.

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.

runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:542
Clusterizer1DCommons
Definition: Clusterizer1DCommons.h:6
Measurement1D
Definition: Measurement1D.h:11
mps_fire.i
i
Definition: mps_fire.py:428
Cluster1D
Definition: Cluster1D.h:13
mps_merge.weight
weight
Definition: mps_merge.py:88
findQualityFiles.v
v
Definition: findQualityFiles.py:179
MtvClusterizer1D::theEstimator
WeightEstimator< T > * theEstimator
Definition: MtvClusterizer1D.h:28
Clusterizer1DCommons::ComparePairs
Definition: Clusterizer1DCommons.h:11
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
mps_fire.end
end
Definition: mps_fire.py:242
WeightEstimator::clone
virtual WeightEstimator * clone() const =0
PVValHelper::add
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
Definition: PVValidationHelpers.cc:12
jetUpdater_cfi.sort
sort
Definition: jetUpdater_cfi.py:29
square
static double square(double x)
Definition: DDCutTubsFromPoints.cc:100
position
static int position[264][3]
Definition: ReadPGInfo.cc:289
submitPVResolutionJobs.err
err
Definition: submitPVResolutionJobs.py:85
hltEgammaHLTExtra_cfi.trks
trks
Definition: hltEgammaHLTExtra_cfi.py:43
Clustering1DException
Definition: Clustering1DException.h:10
weight
Definition: weight.py:1
MtvClusterizer1D
Definition: MtvClusterizer1D.h:17