CMS 3D CMS Logo

MultiClusterizer1D.h
Go to the documentation of this file.
1 #ifndef _MultiClusterizer1D_H_
2 #define _MultiClusterizer1D_H_
3 
9 
10 #include <vector>
11 #include <map>
12 #include <cmath>
13 #include <algorithm>
14 
19 template <class T>
20 class MultiClusterizer1D : public Clusterizer1D<T> {
21 public:
22  // typedef Cluster1D<T> Cluster1D;
26 
27  std::pair<std::vector<Cluster1D<T> >, std::vector<const T *> > operator()(const std::vector<Cluster1D<T> > &) const;
28 
29  virtual MultiClusterizer1D *clone() const;
30 
31 private:
34 };
35 
36 /*
37  * --- implementation ---
38  *
39  */
40 
41 /*
42 namespace MultiClusterizer1DNameSpace
43 {
44 }*/
45 
46 template <class T>
48  : theEstimator(o.theEstimator->clone()), theSingle(o.theSingle->clone()) {}
49 
50 template <class T>
52  : theEstimator(est.clone()), theSingle(single.clone()) {}
53 
54 template <class T>
56  delete theEstimator;
57  delete theSingle;
58 }
59 
60 template <class T>
62  return new MultiClusterizer1D<T>(*this);
63 }
64 
65 template <class T>
66 std::pair<std::vector<Cluster1D<T> >, std::vector<const T *> > MultiClusterizer1D<T>::operator()(
67  const std::vector<Cluster1D<T> > &ov) const {
68  using namespace Clusterizer1DCommons;
69  // using namespace MultiClusterizer1DNameSpace;
70  typedef Cluster1D<T> Cluster1D;
71  std::vector<const T *> unusedtracks;
72  switch (ov.size()) {
73  case 0:
74  throw Clustering1DException("[MultiClusterizer1D] no values given");
75  case 1:
76  std::pair<std::vector<Cluster1D>, std::vector<const T *> > ret(ov, unusedtracks);
77  return ret;
78  };
79 
80  std::pair<std::vector<Cluster1D>, std::vector<const T *> > res;
81 
82  // works only with one track per cluster!!!
83  std::map<const T *, Cluster1D> ass;
84  std::vector<Cluster1D> cur;
85 
86  for (typename std::vector<Cluster1D>::const_iterator i = ov.begin(); i != ov.end(); ++i) {
87  if (i->tracks().size() == 1) {
88  ass[i->tracks()[0]] = *i;
89  }
90  cur.push_back(*i);
91  }
92 
93  int ctr = 0;
94  try {
95  while (true) {
96  std::pair<std::vector<Cluster1D>, std::vector<const T *> > tmp = (*theSingle)(cur);
97 
98  for (typename std::vector<Cluster1D>::const_iterator i = tmp.first.begin(); i != tmp.first.end(); ++i) {
99  res.first.push_back(*i);
100  }
101  res.second = tmp.second;
102 
103  cur.clear();
104 
105  for (typename std::vector<const T *>::const_iterator i = res.second.begin(); i != res.second.end(); ++i) {
106  cur.push_back(ass[*i]);
107  }
108  if (ctr++ > 5)
109  break;
110  if (cur.size() < 2)
111  break;
112  }
113  } catch (...) {
114  };
115 
116  return res;
117 }
118 
119 #endif
ret
prodAgent to be discontinued
WeightEstimator< T > * theEstimator
MultiClusterizer1D(const Clusterizer1D< T > &single, const WeightEstimator< T > &est=TrivialWeightEstimator< T >())
Definition: Electron.h:6
std::pair< std::vector< Cluster1D< T > >, std::vector< const T * > > operator()(const std::vector< Cluster1D< T > > &) const
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
Clusterizer1D< T > * theSingle
tmp
align.sh
Definition: createJobs.py:716
virtual MultiClusterizer1D * clone() const