CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups 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  bool operator()(const PointAndDistance& p1, const PointAndDistance& p2) { return (p1.second < p2.second); };
13  };
14 } // namespace
15 
16 GlobalPoint SubsetHsmModeFinder3d::operator()(const std::vector<PointAndDistance>& values) const {
17  if (values.empty()) {
18  throw VertexException("SubsetHsmModeFinder3d: no value given.");
19  };
20 
21  std::vector<GlobalPoint> pts;
22  pts.reserve(values.size() - 1);
23  std::vector<PointAndDistance> sorted_values(values.size());
24  partial_sort_copy(values.begin(), values.end(), sorted_values.begin(), sorted_values.end(), compareByDistance());
25 
26  std::vector<PointAndDistance>::iterator end = sorted_values.end();
27  std::vector<PointAndDistance>::iterator begin = sorted_values.begin();
28 
29  float dmax = 0.004; // 40 microns, as a first try.
30 
31  // we want at least 30 values
32  unsigned int min_num = values.size() < 30 ? values.size() : 30;
33 
34  // we also want at least 50 % of all values
35  if (values.size() > 2 * min_num)
36  min_num = (int)values.size() / 2;
37 
38  while (pts.size() < min_num) {
39  // we cut at a dmax
40  std::vector<PointAndDistance>::iterator i;
41  for (i = begin; i != end && (i->second < dmax); ++i) {
42  pts.push_back(i->first);
43  };
44  dmax += 0.003; // add 30 microns with every iteration
45  begin = i;
46  };
47 
48  GlobalPoint ret = hsm_3d(pts);
49  return ret;
50 }
51 
tuple ret
prodAgent to be discontinued
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
const TString p2
Definition: fwPaths.cc:13
Common base class.
static const double pts[33]
Definition: Constants.h:30
GlobalPoint operator()(const std::vector< PointAndDistance > &values) const override
const TString p1
Definition: fwPaths.cc:12
SubsetHsmModeFinder3d * clone() const override
string end
Definition: dataset.py:937