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
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:542
TrivialWeightEstimator.h
Clusterizer1DCommons
Definition: Clusterizer1DCommons.h:6
mps_fire.i
i
Definition: mps_fire.py:428
Cluster1D
Definition: Cluster1D.h:13
MultiClusterizer1D::~MultiClusterizer1D
~MultiClusterizer1D()
Definition: MultiClusterizer1D.h:55
createJobs.tmp
tmp
align.sh
Definition: createJobs.py:716
TrivialWeightEstimator
Definition: TrivialWeightEstimator.h:13
EcalTangentSkim_cfg.o
o
Definition: EcalTangentSkim_cfg.py:42
MultiClusterizer1D::MultiClusterizer1D
MultiClusterizer1D(const Clusterizer1D< T > &single, const WeightEstimator< T > &est=TrivialWeightEstimator< T >())
Definition: MultiClusterizer1D.h:51
Clusterizer1D.h
clone
TEveGeoShape * clone(const TEveElement *element, TEveElement *parent)
Definition: eve_macros.cc:135
WeightEstimator
Definition: WeightEstimator.h:12
MultiClusterizer1D::theEstimator
WeightEstimator< T > * theEstimator
Definition: MultiClusterizer1D.h:32
trackerHitRTTI::single
Definition: trackerHitRTTI.h:10
MultiClusterizer1D::operator()
std::pair< std::vector< Cluster1D< T > >, std::vector< const T * > > operator()(const std::vector< Cluster1D< T > > &) const
Definition: MultiClusterizer1D.h:66
dqmiodatasetharvest.ctr
ctr
Definition: dqmiodatasetharvest.py:191
MultiClusterizer1D::clone
virtual MultiClusterizer1D * clone() const
Definition: MultiClusterizer1D.h:61
MultiClusterizer1D::theSingle
Clusterizer1D< T > * theSingle
Definition: MultiClusterizer1D.h:33
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
res
Definition: Electron.h:6
Clusterizer1D
Definition: Clusterizer1D.h:16
MultiClusterizer1D
Definition: MultiClusterizer1D.h:20
Clustering1DException.h
FsmwClusterizer1D.h
Clusterizer1DCommons.h
Clustering1DException
Definition: Clustering1DException.h:10