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 (const FsmwClusterizer1D &)
 
 FsmwClusterizer1D (double fraction=.05, double n_sigma_in=3., const WeightEstimator< T > &est=TrivialWeightEstimator< T >())
 
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

◆ FsmwClusterizer1D() [1/2]

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.

148  : theEstimator(est.clone()), theFraction(fraction), theNSigmaIn(nsig) {}

◆ FsmwClusterizer1D() [2/2]

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

◆ ~FsmwClusterizer1D()

template<class T >
FsmwClusterizer1D< T >::~FsmwClusterizer1D ( )
override

Definition at line 151 of file FsmwClusterizer1D.h.

151  {
152  delete theEstimator;
153 }

Member Function Documentation

◆ clone()

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 }

◆ operator()()

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.

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 }

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

Member Data Documentation

◆ theEstimator

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

Definition at line 33 of file FsmwClusterizer1D.h.

◆ theFraction

template<class T>
double FsmwClusterizer1D< T >::theFraction
private

Definition at line 34 of file FsmwClusterizer1D.h.

◆ theNSigmaIn

template<class T>
double FsmwClusterizer1D< T >::theNSigmaIn
private

Definition at line 35 of file FsmwClusterizer1D.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
FsmwClusterizer1D::theEstimator
WeightEstimator< T > * theEstimator
Definition: FsmwClusterizer1D.h:33
findQualityFiles.v
v
Definition: findQualityFiles.py:179
FsmwClusterizer1DNameSpace
Definition: FsmwClusterizer1D.h:43
FsmwClusterizer1D::theFraction
double theFraction
Definition: FsmwClusterizer1D.h:34
Clusterizer1DCommons::ComparePairs
Definition: Clusterizer1DCommons.h:11
HLT_FULL_cff.fraction
fraction
Definition: HLT_FULL_cff.py:52806
mathSSE::sqrt
T sqrt(T t)
Definition: SSEVec.h:19
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
FsmwClusterizer1D
Definition: FsmwClusterizer1D.h:17
submitPVResolutionJobs.err
err
Definition: submitPVResolutionJobs.py:85
FsmwClusterizer1D::theNSigmaIn
double theNSigmaIn
Definition: FsmwClusterizer1D.h:35
FsmwClusterizer1DNameSpace::fsmw
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)
Definition: FsmwClusterizer1D.h:51
hltEgammaHLTExtra_cfi.trks
trks
Definition: hltEgammaHLTExtra_cfi.py:43
Clustering1DException
Definition: Clustering1DException.h:10
weight
Definition: weight.py:1