CMS 3D CMS Logo

Public Member Functions

SubsetHsmModeFinder3d Class Reference

#include <SubsetHsmModeFinder3d.h>

Inheritance diagram for SubsetHsmModeFinder3d:
ModeFinder3d unary_function

List of all members.

Public Member Functions

virtual SubsetHsmModeFinder3dclone () const
virtual GlobalPoint operator() (const std::vector< PointAndDistance > &values) const

Detailed Description

Definition at line 14 of file SubsetHsmModeFinder3d.h.


Member Function Documentation

SubsetHsmModeFinder3d * SubsetHsmModeFinder3d::clone ( void  ) const [virtual]

Implements ModeFinder3d.

Definition at line 60 of file SubsetHsmModeFinder3d.cc.

{
  return new SubsetHsmModeFinder3d ( * this );
}
GlobalPoint SubsetHsmModeFinder3d::operator() ( const std::vector< PointAndDistance > &  values) const [virtual]

Implements ModeFinder3d.

Definition at line 20 of file SubsetHsmModeFinder3d.cc.

References begin, dmax, end, hsm_3d(), i, and runTheMatrix::ret.

{
  if ( values.size() == 0 )
  {
    throw VertexException ("SubsetHsmModeFinder3d: no value given.");
  };

  std::vector < GlobalPoint > pts; pts.reserve ( values.size()-1 );
  std::vector< PointAndDistance> sorted_values ( values.size() );
  partial_sort_copy ( values.begin(), values.end(),
      sorted_values.begin(), sorted_values.end(), compareByDistance() );

  std::vector< PointAndDistance>::iterator end = sorted_values.end();
  std::vector< PointAndDistance>::iterator begin = sorted_values.begin();

  float dmax = 0.004; // 40 microns, as a first try.

  // we want at least 30 values
  unsigned int min_num = values.size() < 30 ? values.size() : 30;

  // we also want at least 50 % of all values
  if ( values.size() > 2 * min_num ) min_num = (int) values.size() / 2;

  while ( pts.size() < min_num )
  {
    // we cut at a dmax
    std::vector< PointAndDistance>::iterator i;
    for ( i=begin; i!=end && ( i->second < dmax )  ; ++i )
    {
      pts.push_back ( i->first );
    };
    dmax +=0.003; // add 30 microns with every iteration
    begin=i;
  };

  GlobalPoint ret = hsm_3d ( pts );
  return ret;
}