CMS 3D CMS Logo

List of all members | Public Member Functions | Private Attributes
FsmwClusterizer1D< T > Class Template Reference

#include <FsmwClusterizer1D.h>

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

Public Member Functions

FsmwClusterizer1Dclone () const override
 
 FsmwClusterizer1D (double fraction=.05, double n_sigma_in=3., const WeightEstimator< T > &est=TrivialWeightEstimator< T >())
 
 FsmwClusterizer1D (const FsmwClusterizer1D &)
 
std::pair< std::vector< Cluster1D< T > >, std::vector< const T * > > operator() (const std::vector< Cluster1D< T > > &) const override
 
 ~FsmwClusterizer1D () override
 
- Public Member Functions inherited from Clusterizer1D< T >
virtual ~Clusterizer1D ()
 

Private Attributes

WeightEstimator< T > * theEstimator
 
double theFraction
 
double theNSigmaIn
 

Detailed Description

template<class T>
class FsmwClusterizer1D< T >

Fraction-of sample mode with weights clustering

Definition at line 17 of file FsmwClusterizer1D.h.

Constructor & Destructor Documentation

template<class T >
FsmwClusterizer1D< T >::FsmwClusterizer1D ( double  fraction = .05,
double  n_sigma_in = 3.,
const WeightEstimator< T > &  est = TrivialWeightEstimator<T>() 
)
Parameters
fractionfraction of values that will be considered to be 'in'.

Definition at line 147 of file FsmwClusterizer1D.h.

Referenced by FsmwClusterizer1DNameSpace::fsmw().

148  : theEstimator(est.clone()), theFraction(fraction), theNSigmaIn(nsig) {}
WeightEstimator< T > * theEstimator
virtual WeightEstimator * clone() const =0
template<class T>
FsmwClusterizer1D< T >::FsmwClusterizer1D ( const FsmwClusterizer1D< T > &  )
template<class T >
FsmwClusterizer1D< T >::~FsmwClusterizer1D ( )
override

Definition at line 151 of file FsmwClusterizer1D.h.

References FsmwClusterizer1D< T >::theEstimator.

151  {
152  delete theEstimator;
153 }
WeightEstimator< T > * theEstimator

Member Function Documentation

template<class T >
FsmwClusterizer1D< T > * FsmwClusterizer1D< T >::clone ( void  ) const
overridevirtual

Implements Clusterizer1D< T >.

Definition at line 156 of file FsmwClusterizer1D.h.

156  {
157  return new FsmwClusterizer1D<T>(*this);
158 }
template<class T >
std::pair< std::vector< Cluster1D< T > >, std::vector< const T * > > FsmwClusterizer1D< T >::operator() ( const std::vector< Cluster1D< T > > &  ov) const
overridevirtual

Implements Clusterizer1D< T >.

Definition at line 161 of file FsmwClusterizer1D.h.

References PVValHelper::add(), runTheMatrix::err, FsmwClusterizer1DNameSpace::fsmw(), mps_fire::i, runTheMatrix::ret, mathSSE::sqrt(), square(), FsmwClusterizer1D< T >::theFraction, FsmwClusterizer1D< T >::theNSigmaIn, and findQualityFiles::v.

162  {
163  using namespace Clusterizer1DCommons;
164  using namespace FsmwClusterizer1DNameSpace;
165  typedef Cluster1D<T> Cluster1D;
166  std::vector<const T*> unusedtracks;
167 
168  switch (ov.size()) {
169  case 0:
170  throw Clustering1DException("[FsmwClusterizer1D] no values given");
171  case 1:
172  std::pair<std::vector<Cluster1D>, std::vector<const T*> > ret(ov, unusedtracks);
173  return ret;
174  };
175 
176  std::vector<Cluster1D> v = ov;
177  sort(v.begin(), v.end(), ComparePairs<T>());
178  std::vector<Cluster1D> sols;
179 
180  std::pair<typename std::vector<Cluster1D>::const_iterator, typename std::vector<Cluster1D>::const_iterator> estors =
181  fsmw(v, theFraction);
182 
183  double weight = estors.first->weight() + estors.second->weight();
184  double est = (estors.first->weight() * estors.first->position().value() +
185  estors.second->weight() * estors.second->position().value()) /
186  weight;
187  double err = 0.;
188  double sigma = sqrt(square(estors.first->position().value() - est) + square(estors.second->position().value() - est));
189  /*
190  std::cout << "[FsmwClusterizer1D] first=" << estors.first->position().value()
191  << " second=" << estors.second->position().value()
192  << " est=" << est << std::endl;
193  double sigma = sqrt ( square ( estors.first->position().error() ) +
194  square ( estors.second->position().error() ) );
195  double sigma = estors.first->position().error();
196  */
197  std::vector<const T*> trks;
198  int inliers = 0;
199 
200  for (typename std::vector<Cluster1D>::iterator i = v.begin(); i != v.end(); ++i) {
201  /*
202  std::cout << "[FsmwClusterizer1D] see if they're in: delta="
203  << 10000 * fabs ( i->position().value() - est )
204  << " sigma=" << 10000 * sigma << std::endl;
205  */
206  if (fabs(i->position().value() - est) < theNSigmaIn * sigma) {
207  // all within theNSigmaIn sigma are 'in'
208  add(i->tracks(), trks);
209  err += square(i->position().value() - est);
210  inliers++;
211  } else {
212  add(i->tracks(), unusedtracks);
213  };
214  };
215  err /= (inliers - 1); // the algo definitely produces 2 or more inliers
216  err = sqrt(err);
217 
218  err = sqrt(err);
219  sols.push_back(Cluster1D(Measurement1D(est, err), trks, weight));
220 
221  std::pair<std::vector<Cluster1D>, std::vector<const T*> > ret(sols, unusedtracks);
222  return ret;
223 }
ret
prodAgent to be discontinued
Definition: weight.py:1
T sqrt(T t)
Definition: SSEVec.h:19
void add(std::map< std::string, TH1 * > &h, TH1 *hist)
std::pair< typename std::vector< Cluster1D< T > >::const_iterator, typename std::vector< Cluster1D< T > >::const_iterator > fsmw(const std::vector< Cluster1D< T > > &values, double fraction)
static double square(double x)

Member Data Documentation

template<class T>
WeightEstimator<T>* FsmwClusterizer1D< T >::theEstimator
private
template<class T>
double FsmwClusterizer1D< T >::theFraction
private
template<class T>
double FsmwClusterizer1D< T >::theNSigmaIn
private