CMS 3D CMS Logo

OutermostClusterizer1D.h
Go to the documentation of this file.
1 #ifndef _OutermostClusterizer1D_H_
2 #define _OutermostClusterizer1D_H_
3 
9 
10 #include <vector>
11 #include <cmath>
12 #include <algorithm>
13 
19 template <class T>
21 public:
26  ~OutermostClusterizer1D() override;
27 
28  std::pair<std::vector<Cluster1D<T> >, std::vector<const T*> > operator()(
29  const std::vector<Cluster1D<T> >&) const override;
30 
31  OutermostClusterizer1D* clone() const override;
32 
33 private:
35 };
36 
37 /*
38  * --- implementation ---
39  *
40  */
41 
42 template <class T>
44  : theEstimator(o.theEstimator->clone()) {}
45 
46 template <class T>
48 
49 template <class T>
51  delete theEstimator;
52 }
53 
54 template <class T>
56  return new OutermostClusterizer1D<T>(*this);
57 }
58 
59 template <class T>
60 std::pair<std::vector<Cluster1D<T> >, std::vector<const T*> > OutermostClusterizer1D<T>::operator()(
61  const std::vector<Cluster1D<T> >& ov) const {
62  using namespace Clusterizer1DCommons;
63  typedef Cluster1D<T> Cluster1D;
64  std::vector<const T*> unusedtracks;
65 
66  switch (ov.size()) {
67  case 0:
68  throw Clustering1DException("[OutermostClusterizer1D] no values given");
69  case 1: {
70  std::pair<std::vector<Cluster1D>, std::vector<const T*> > ret(ov, unusedtracks);
71  return ret;
72  };
73  case 2: {
74  std::pair<std::vector<Cluster1D>, std::vector<const T*> > ret(ov, unusedtracks);
75  return ret;
76  };
77  };
78 
79  std::vector<Cluster1D> v = ov;
80  sort(v.begin(), v.end(), ComparePairs<T>());
81  std::vector<Cluster1D> sols;
82  int sze = v.size() / 2;
83  Cluster1D tmp = v[0];
84  Cluster1DMerger<T> merger(*theEstimator);
85  // merge the inner half to the primary cluster
86  for (typename std::vector<Cluster1D>::const_iterator i = v.begin() + 1; i != v.begin() + sze; ++i) {
87  tmp = merger(tmp, *i);
88  }
89  sols.push_back(tmp);
90  tmp = v[sze];
91  for (typename std::vector<Cluster1D>::const_iterator i = v.begin() + sze + 1; i != v.end(); ++i) {
92  tmp = merger(tmp, *i);
93  }
94  sols.push_back(tmp);
95 
96  std::pair<std::vector<Cluster1D>, std::vector<const T*> > ret(sols, unusedtracks);
97  return ret;
98 }
99 
100 #endif
ret
prodAgent to be discontinued
WeightEstimator< T > * theEstimator
OutermostClusterizer1D * clone() const override
OutermostClusterizer1D(const WeightEstimator< T > &est=TrivialWeightEstimator< T >())
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
std::pair< std::vector< Cluster1D< T > >, std::vector< const T * > > operator()(const std::vector< Cluster1D< T > > &) const override
tmp
align.sh
Definition: createJobs.py:716