CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FsmwModeFinder3d.cc
Go to the documentation of this file.
3 
4 #include <cmath>
5 #include <cassert>
6 
11  float cutoff, int no_w_a ) : theFraction ( fraction ),
12  theWeightExponent ( weightExp ), theCutoff(cutoff),
13  theNoWeightsAbove ( no_w_a )
14 {
15  assert ( theFraction > 0. && theFraction < 1. );
16 }
17 
19  const std::vector< PointAndDistance> & values ) const
20 {
21  typedef Cluster1D<void> SimpleCluster;
22  std::vector< SimpleCluster > vx, vy, vz;
23  vx.reserve ( values.size() - 1 );
24  vy.reserve ( values.size() - 1 );
25  vz.reserve ( values.size() - 1 );
26  std::vector < const void * > emptyvec;
27 
28  for ( std::vector< PointAndDistance >::const_iterator i = values.begin();
29  i != values.end(); ++i )
30  {
31  float weight = 1.;
32  if ( static_cast<int>( values.size() ) < theNoWeightsAbove )
33  {
34  // compute weights if we have fewer than theNoWeightsAbove
35  // data points
36  weight = pow ( theCutoff + 10000 * i->second, theWeightExponent );
37  };
38 
39  SimpleCluster tmp_x ( Measurement1D ( i->first.x(), 1.0 ),
40  emptyvec, weight );
41  SimpleCluster tmp_y ( Measurement1D ( i->first.y(), 1.0 ),
42  emptyvec, weight );
43  SimpleCluster tmp_z ( Measurement1D ( i->first.z(), 1.0 ),
44  emptyvec, weight );
45  vx.push_back ( tmp_x );
46  vy.push_back ( tmp_y );
47  vz.push_back ( tmp_z );
48  };
49 
51  std::vector < SimpleCluster > cresx = algo(vx).first;
52  std::vector < SimpleCluster > cresy = algo(vy).first;
53  std::vector < SimpleCluster > cresz = algo(vz).first;
54  assert ( cresx.size() && cresy.size() && cresz.size() );
55 
56  GlobalPoint ret ( cresx.begin()->position().value(),
57  cresy.begin()->position().value(),
58  cresz.begin()->position().value() );
59  return ret;
60 }
61 
63 {
64  return new FsmwModeFinder3d( *this );
65 }
66 
67 
int i
Definition: DBlmapReader.cc:9
assert(m_qm.get())
virtual FsmwModeFinder3d * clone() const
virtual GlobalPoint operator()(const std::vector< PointAndDistance > &) const
FsmwModeFinder3d(float fraction=.5, float weightExponent=-2., float cutoff=10, int no_weights_above=10)
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40