CMS 3D CMS Logo

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 
49  return ret;
50 }
51 
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:355
mps_fire.i
i
Definition: mps_fire.py:355
VertexException
Common base class.
Definition: VertexException.h:12
SubsetHsmModeFinder3d.h
end
#define end
Definition: vmac.h:39
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
p2
double p2[4]
Definition: TauolaWrapper.h:90
Point3DBase< float, GlobalTag >
hsm_3d.h
SubsetHsmModeFinder3d::operator()
GlobalPoint operator()(const std::vector< PointAndDistance > &values) const override
Definition: SubsetHsmModeFinder3d.cc:16
PointAndDistance
std::pair< GlobalPoint, float > PointAndDistance
Definition: SubsetHsmModeFinder3d.cc:8
SubsetHsmModeFinder3d
Definition: SubsetHsmModeFinder3d.h:14
p1
double p1[4]
Definition: TauolaWrapper.h:89
RPCpg::pts
static const double pts[33]
Definition: Constants.h:30
PointAndDistance
std::pair< GlobalPoint, float > PointAndDistance
Definition: CrossingPtBasedLinearizationPointFinder.cc:129
VertexException.h
SubsetHsmModeFinder3d::clone
SubsetHsmModeFinder3d * clone() const override
Definition: SubsetHsmModeFinder3d.cc:52
begin
#define begin
Definition: vmac.h:32
hsm_3d
GlobalPoint hsm_3d(const std::vector< GlobalPoint > &values)
cordinate wise half sample mode in 3d
Definition: hsm_3d.cc:8