CMS 3D CMS Logo

FsmwModeFinder3d.cc
Go to the documentation of this file.
3 
4 #include <cmath>
5 #include <cassert>
6 
10 FsmwModeFinder3d::FsmwModeFinder3d(float fraction, float weightExp, float cutoff, int no_w_a)
11  : theFraction(fraction), theWeightExponent(weightExp), theCutoff(cutoff), theNoWeightsAbove(no_w_a) {
12  assert(theFraction > 0. && theFraction < 1.);
13 }
14 
15 GlobalPoint FsmwModeFinder3d::operator()(const std::vector<PointAndDistance>& values) const {
16  typedef Cluster1D<void> SimpleCluster;
17  std::vector<SimpleCluster> vx, vy, vz;
18  vx.reserve(values.size() - 1);
19  vy.reserve(values.size() - 1);
20  vz.reserve(values.size() - 1);
21  std::vector<const void*> emptyvec;
22 
23  for (std::vector<PointAndDistance>::const_iterator i = values.begin(); i != values.end(); ++i) {
24  float weight = 1.;
25  if (static_cast<int>(values.size()) < theNoWeightsAbove) {
26  // compute weights if we have fewer than theNoWeightsAbove
27  // data points
28  weight = pow(theCutoff + 10000 * i->second, theWeightExponent);
29  };
30 
31  SimpleCluster tmp_x(Measurement1D(i->first.x(), 1.0), emptyvec, weight);
32  SimpleCluster tmp_y(Measurement1D(i->first.y(), 1.0), emptyvec, weight);
33  SimpleCluster tmp_z(Measurement1D(i->first.z(), 1.0), emptyvec, weight);
34  vx.push_back(tmp_x);
35  vy.push_back(tmp_y);
36  vz.push_back(tmp_z);
37  };
38 
40  std::vector<SimpleCluster> cresx = algo(vx).first;
41  std::vector<SimpleCluster> cresy = algo(vy).first;
42  std::vector<SimpleCluster> cresz = algo(vz).first;
43  assert(!cresx.empty() && !cresy.empty() && !cresz.empty());
44 
46  cresx.begin()->position().value(), cresy.begin()->position().value(), cresz.begin()->position().value());
47  return ret;
48 }
49 
FsmwModeFinder3d * clone() const override
ret
prodAgent to be discontinued
Definition: weight.py:1
GlobalPoint operator()(const std::vector< PointAndDistance > &) const override
assert(be >=bs)
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:29