CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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

virtual FsmwClusterizer1Dclone () const
 
 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
 
 ~FsmwClusterizer1D ()
 
- 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 163 of file FsmwClusterizer1D.h.

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

Definition at line 169 of file FsmwClusterizer1D.h.

170 {
171  delete theEstimator;
172 }
WeightEstimator< T > * theEstimator

Member Function Documentation

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

Implements Clusterizer1D< T >.

Definition at line 175 of file FsmwClusterizer1D.h.

176 {
177  return new FsmwClusterizer1D<T>( *this );
178 }
template<class T >
std::pair< std::vector< Cluster1D< T > >, std::vector< const T * > > FsmwClusterizer1D< T >::operator() ( const std::vector< Cluster1D< T > > &  ov) const
virtual

Implements Clusterizer1D< T >.

Definition at line 182 of file FsmwClusterizer1D.h.

References Clusterizer1DCommons::add(), FsmwClusterizer1DNameSpace::fsmw(), i, runTheMatrix::ret, mathSSE::sqrt(), Clusterizer1DCommons::square(), findQualityFiles::v, and histoStyle::weight.

183 {
184  using namespace Clusterizer1DCommons;
185  using namespace FsmwClusterizer1DNameSpace;
186  typedef Cluster1D<T> Cluster1D;
187  std::vector < const T * > unusedtracks;
188 
189  switch ( ov.size() )
190  {
191  case 0:
192  throw Clustering1DException("[FsmwClusterizer1D] no values given" );
193  case 1:
194  std::pair < std::vector < Cluster1D >, std::vector < const T * > > ret ( ov, unusedtracks );
195  return ret;
196  };
197 
198  std::vector < Cluster1D > v = ov;
199  sort ( v.begin(), v.end(), ComparePairs<T>() );
200  std::vector < Cluster1D > sols;
201 
202  std::pair < typename std::vector< Cluster1D >::const_iterator,
203  typename std::vector< Cluster1D >::const_iterator > estors
204  = fsmw ( v, theFraction );
205 
206  double weight = estors.first->weight() + estors.second->weight();
207  double est = ( estors.first->weight() * estors.first->position().value() +
208  estors.second->weight() * estors.second->position().value() ) /
209  weight;
210  double err=0.;
211  double sigma = sqrt ( square ( estors.first->position().value() - est ) +
212  square ( estors.second->position().value() - est ));
213  /*
214  std::cout << "[FsmwClusterizer1D] first=" << estors.first->position().value()
215  << " second=" << estors.second->position().value()
216  << " est=" << est << std::endl;
217  double sigma = sqrt ( square ( estors.first->position().error() ) +
218  square ( estors.second->position().error() ) );
219  double sigma = estors.first->position().error();
220  */
221  std::vector < const T * > trks;
222  int inliers=0;
223 
224  for ( typename std::vector< Cluster1D >::iterator i=v.begin();
225  i!=v.end() ; ++i )
226  {
227  /*
228  std::cout << "[FsmwClusterizer1D] see if they're in: delta="
229  << 10000 * fabs ( i->position().value() - est )
230  << " sigma=" << 10000 * sigma << std::endl;
231  */
232  if ( fabs ( i->position().value() - est ) < theNSigmaIn * sigma )
233  {
234  // all within theNSigmaIn sigma are 'in'
235  add ( i->tracks(), trks );
236  err+= square ( i->position().value() - est );
237  inliers++;
238  } else {
239  add ( i->tracks(), unusedtracks );
240  };
241  };
242  err /= ( inliers - 1 ); // the algo definitely produces 2 or more inliers
243  err = sqrt ( err );
244 
245 
246  err=sqrt(err);
247  sols.push_back ( Cluster1D ( Measurement1D ( est, err ), trks, weight ) );
248 
249  std::pair < std::vector < Cluster1D >, std::vector < const T * > > ret ( sols, unusedtracks );
250  return ret;
251 }
int i
Definition: DBlmapReader.cc:9
tuple ret
prodAgent to be discontinued
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)
void add(const std::vector< const T * > &source, std::vector< const T * > &dest)
T sqrt(T t)
Definition: SSEVec.h:18
double square(const double a)
int weight
Definition: histoStyle.py:50

Member Data Documentation

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

Definition at line 33 of file FsmwClusterizer1D.h.

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

Definition at line 34 of file FsmwClusterizer1D.h.

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

Definition at line 35 of file FsmwClusterizer1D.h.