CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SubsetHsmModeFinder3d.cc
Go to the documentation of this file.
3 
5 
6 #include <algorithm>
7 
8 typedef std::pair < GlobalPoint, float > PointAndDistance;
9 
10 namespace {
11  struct compareByDistance
12  {
13  bool operator() ( const PointAndDistance & p1,
14  const PointAndDistance & p2 ) {
15  return ( p1.second < p2.second );
16  };
17  };
18 }
19 
20 GlobalPoint SubsetHsmModeFinder3d::operator() ( const std::vector< PointAndDistance> & values )
21  const
22 {
23  if ( values.size() == 0 )
24  {
25  throw VertexException ("SubsetHsmModeFinder3d: no value given.");
26  };
27 
28  std::vector < GlobalPoint > pts; pts.reserve ( values.size()-1 );
29  std::vector< PointAndDistance> sorted_values ( values.size() );
30  partial_sort_copy ( values.begin(), values.end(),
31  sorted_values.begin(), sorted_values.end(), compareByDistance() );
32 
33  std::vector< PointAndDistance>::iterator end = sorted_values.end();
34  std::vector< PointAndDistance>::iterator begin = sorted_values.begin();
35 
36  float dmax = 0.004; // 40 microns, as a first try.
37 
38  // we want at least 30 values
39  unsigned int min_num = values.size() < 30 ? values.size() : 30;
40 
41  // we also want at least 50 % of all values
42  if ( values.size() > 2 * min_num ) min_num = (int) values.size() / 2;
43 
44  while ( pts.size() < min_num )
45  {
46  // we cut at a dmax
47  std::vector< PointAndDistance>::iterator i;
48  for ( i=begin; i!=end && ( i->second < dmax ) ; ++i )
49  {
50  pts.push_back ( i->first );
51  };
52  dmax +=0.003; // add 30 microns with every iteration
53  begin=i;
54  };
55 
56  GlobalPoint ret = hsm_3d ( pts );
57  return ret;
58 }
59 
61 {
62  return new SubsetHsmModeFinder3d ( * this );
63 }
int i
Definition: DBlmapReader.cc:9
std::pair< GlobalPoint, float > PointAndDistance
GlobalPoint hsm_3d(const std::vector< GlobalPoint > &values)
cordinate wise half sample mode in 3d
Definition: hsm_3d.cc:8
Common base class.
virtual SubsetHsmModeFinder3d * clone() const
static const double pts[33]
Definition: Constants.h:31
#define end
Definition: vmac.h:38
double p2[4]
Definition: TauolaWrapper.h:90
virtual GlobalPoint operator()(const std::vector< PointAndDistance > &values) const
#define begin
Definition: vmac.h:31
double p1[4]
Definition: TauolaWrapper.h:89
#define dmax(a, b)
Definition: mlp_lapack.h:164