CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes
DivisiveClusterizer1D< T > Class Template Reference

#include <DivisiveClusterizer1D.h>

Inheritance diagram for DivisiveClusterizer1D< T >:
Clusterizer1D< T >

Public Member Functions

virtual DivisiveClusterizer1Dclone () const
 
 DivisiveClusterizer1D (float zoffset=5., int ntkmin=5, bool useError=true, float zsep=0.05, bool wei=true)
 
std::pair< std::vector< Cluster1D< T > >, std::vector< const T * > > operator() (const std::vector< Cluster1D< T > > &) const
 
 ~DivisiveClusterizer1D ()
 
- Public Member Functions inherited from Clusterizer1D< T >
virtual ~Clusterizer1D ()
 

Private Member Functions

void findCandidates (const std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &) const
 
void insertTracks (std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &) const
 
std::vector< Cluster1D< T > > makeCluster1Ds (std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &) const
 
Cluster1D< TmergeCluster1Ds (std::vector< Cluster1D< T > > &) const
 
std::vector< const T * > takeTracks (const std::vector< Cluster1D< T > > &) const
 

Private Attributes

Cluster1DCleaner< T > * theCleaner
 
Cluster1DMerger< T > * theMerger
 
unsigned theNTkMin
 
bool theUseError
 
bool theWei
 
float theZOffSet
 
float theZSeparation
 

Detailed Description

template<class T>
class DivisiveClusterizer1D< T >

Find the modes with a simple divisive method.

Definition at line 14 of file DivisiveClusterizer1D.h.

Constructor & Destructor Documentation

◆ DivisiveClusterizer1D()

template<class T >
DivisiveClusterizer1D< T >::DivisiveClusterizer1D ( float  zoffset = 5.,
int  ntkmin = 5,
bool  useError = true,
float  zsep = 0.05,
bool  wei = true 
)
Parameters
zoffsetmaximum distance between track position and position of its cluster (depending on useError its either weighted or physical distance)
ntkminMinimum number of tracks required to form a cluster.
useErrorphysical distances or weighted distances.
zsepMaximum distance between two adjacent tracks that belong to the same initial cluster.
weiCompute the cluster "center" with an unweighted or a weighted average of the tracks. Weighted means weighted with the error of the data point.

Definition at line 62 of file DivisiveClusterizer1D.h.

References DivisiveClusterizer1D< T >::theCleaner, DivisiveClusterizer1D< T >::theMerger, DivisiveClusterizer1D< T >::theUseError, and DivisiveClusterizer1D< T >::theZOffSet.

63  : theZOffSet(zoffset), theZSeparation(zsep), theNTkMin(ntkmin), theWei(wei), theUseError(useError) {
64  // theDiscardedTracks.clear();
65  // theTotalDiscardedTracks.clear();
66  // theCluster1Ds.clear();
67  TrivialWeightEstimator<T> weightEstimator;
68  theMerger = new Cluster1DMerger<T>(weightEstimator);
70 }
Cluster1DCleaner< T > * theCleaner
Cluster1DMerger< T > * theMerger

◆ ~DivisiveClusterizer1D()

template<class T >
DivisiveClusterizer1D< T >::~DivisiveClusterizer1D ( )

Definition at line 73 of file DivisiveClusterizer1D.h.

73  {
74  delete theMerger;
75  delete theCleaner;
76 }
Cluster1DCleaner< T > * theCleaner
Cluster1DMerger< T > * theMerger

Member Function Documentation

◆ clone()

template<class T >
DivisiveClusterizer1D< T > * DivisiveClusterizer1D< T >::clone ( void  ) const
virtual

Implements Clusterizer1D< T >.

Definition at line 88 of file DivisiveClusterizer1D.h.

88  {
89  return new DivisiveClusterizer1D<T>(*this);
90 }

◆ findCandidates()

template<class T >
void DivisiveClusterizer1D< T >::findCandidates ( const std::vector< Cluster1D< T > > &  inputo,
std::vector< Cluster1D< T > > &  finalCluster1Ds,
std::vector< Cluster1D< T > > &  totDiscardedTracks 
) const
private

Definition at line 93 of file DivisiveClusterizer1D.h.

References bsc_activity_cfg::clusters, input, jetUpdater_cfi::sort, and trackerHitRTTI::vector.

95  {
96  using namespace Clusterizer1DCommons;
97 
98  std::vector<Cluster1D<T> > input = inputo;
99  std::vector<Cluster1D<T> > discardedTracks;
100  if (input.size() < theNTkMin) {
101  insertTracks(input, totDiscardedTracks);
102  return;
103  }
104  sort(input.begin(), input.end(), ComparePairs<T>());
105  std::vector<Cluster1D<T> > partOfPTracks;
106  partOfPTracks.push_back(input.front());
107  for (typename std::vector<Cluster1D<T> >::const_iterator ic = (input.begin()) + 1; ic != input.end(); ic++) {
108  if (fabs((*ic).position().value() - (*(ic - 1)).position().value()) < (double)theZSeparation) {
109  partOfPTracks.push_back((*ic));
110  } else {
111  if (partOfPTracks.size() >= theNTkMin) {
112  std::vector<Cluster1D<T> > clusters = makeCluster1Ds(partOfPTracks, discardedTracks);
113  for (typename std::vector<Cluster1D<T> >::const_iterator iclus = clusters.begin(); iclus != clusters.end();
114  iclus++) {
115  finalCluster1Ds.push_back(*iclus);
116  }
117  insertTracks(discardedTracks, totDiscardedTracks);
118  } else {
119  insertTracks(partOfPTracks, totDiscardedTracks);
120  }
121  partOfPTracks.clear();
122  partOfPTracks.push_back((*ic));
123  }
124  }
125  if (partOfPTracks.size() >= theNTkMin) {
126  std::vector<Cluster1D<T> > clusters = makeCluster1Ds(partOfPTracks, discardedTracks);
127  for (typename std::vector<Cluster1D<T> >::const_iterator iclus = clusters.begin(); iclus != clusters.end();
128  iclus++) {
129  finalCluster1Ds.push_back(*iclus);
130  }
131  insertTracks(discardedTracks, totDiscardedTracks);
132  } else {
133  insertTracks(partOfPTracks, totDiscardedTracks);
134  }
135 
136  sort(finalCluster1Ds.begin(), finalCluster1Ds.end(), ComparePairs<T>());
137  // reverse(theCluster1Ds.begin(), theCluster1Ds.end());
138 
139  return;
140 }
static std::string const input
Definition: EdmProvDump.cc:50
std::vector< Cluster1D< T > > makeCluster1Ds(std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &) const
void insertTracks(std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &) const

◆ insertTracks()

template<class T >
void DivisiveClusterizer1D< T >::insertTracks ( std::vector< Cluster1D< T > > &  clusou,
std::vector< Cluster1D< T > > &  cludest 
) const
private

Definition at line 182 of file DivisiveClusterizer1D.h.

References trackerHitRTTI::vector.

183  {
184  if (clusou.empty())
185  return;
186  for (typename std::vector<Cluster1D<T> >::const_iterator iclu = clusou.begin(); iclu != clusou.end(); iclu++) {
187  cludest.push_back(*iclu);
188  }
189  /*
190  for ( typename std::vector< Cluster1D<T> >::const_iterator iclu = clu.begin();
191  iclu != clu.end(); iclu++){
192  if (total) {
193  theTotalDiscardedTracks.push_back(*iclu);
194  }else {
195  theDiscardedTracks.push_back(*iclu);
196  }
197  }
198  */
199  return;
200 }

◆ makeCluster1Ds()

template<class T >
std::vector< Cluster1D< T > > DivisiveClusterizer1D< T >::makeCluster1Ds ( std::vector< Cluster1D< T > > &  clusters,
std::vector< Cluster1D< T > > &  discardedTracks 
) const
private

Definition at line 143 of file DivisiveClusterizer1D.h.

References bsc_activity_cfg::clusters.

144  {
145  std::vector<Cluster1D<T> > finalCluster1Ds;
146  discardedTracks.clear();
147  std::vector<Cluster1D<T> > pvClu0 = clusters;
148  std::vector<Cluster1D<T> > pvCluNew = pvClu0;
149  bool stop = false;
150  while (!stop) {
151  int nDiscardedAtIteration = 100;
152  while (nDiscardedAtIteration != 0) {
153  pvCluNew = theCleaner->clusters(pvClu0);
154  std::vector<Cluster1D<T> > tracksAtIteration = theCleaner->discardedCluster1Ds();
155  nDiscardedAtIteration = tracksAtIteration.size();
156  if (nDiscardedAtIteration != 0) {
157  insertTracks(tracksAtIteration, discardedTracks);
158  pvClu0 = pvCluNew;
159  }
160  } // while nDiscardedAtIteration
161  unsigned ntkclus = pvCluNew.size();
162  unsigned ndiscard = discardedTracks.size();
163 
164  if (ntkclus >= theNTkMin) {
165  //save the cluster
166  finalCluster1Ds.push_back(mergeCluster1Ds(pvCluNew));
167  if (ndiscard >= theNTkMin) { //make a new cluster and reset
168  pvClu0 = discardedTracks;
169  discardedTracks.clear();
170  } else { //out of loop
171  stop = true;
172  }
173  } else {
174  insertTracks(pvCluNew, discardedTracks);
175  stop = true;
176  }
177  } // while stop
178  return finalCluster1Ds;
179 }
Cluster1DCleaner< T > * theCleaner
void insertTracks(std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &) const
Cluster1D< T > mergeCluster1Ds(std::vector< Cluster1D< T > > &) const

◆ mergeCluster1Ds()

template<class T >
Cluster1D< T > DivisiveClusterizer1D< T >::mergeCluster1Ds ( std::vector< Cluster1D< T > > &  clusters) const
private

Definition at line 215 of file DivisiveClusterizer1D.h.

References bsc_activity_cfg::clusters, mps_fire::result, and trackerHitRTTI::vector.

215  {
216  Cluster1D<T> result = clusters.front();
217  for (typename std::vector<Cluster1D<T> >::iterator iclu = (clusters.begin()) + 1; iclu != clusters.end(); iclu++) {
218  Cluster1D<T> old = result;
219  result = (*theMerger)(old, *iclu);
220  }
221  return result;
222 }

◆ operator()()

template<class T >
std::pair< std::vector< Cluster1D< T > >, std::vector< const T * > > DivisiveClusterizer1D< T >::operator() ( const std::vector< Cluster1D< T > > &  input) const
virtual

Implements Clusterizer1D< T >.

Definition at line 79 of file DivisiveClusterizer1D.h.

References input, and convertSQLitetoXML_cfg::output.

80  {
81  std::vector<Cluster1D<T> > discardedCluster1Ds;
82  std::vector<Cluster1D<T> > output;
83  findCandidates(input, output, discardedCluster1Ds);
84  return std::pair<std::vector<Cluster1D<T> >, std::vector<const T*> >(output, takeTracks(discardedCluster1Ds));
85 }
std::vector< const T * > takeTracks(const std::vector< Cluster1D< T > > &) const
void findCandidates(const std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &, std::vector< Cluster1D< T > > &) const
static std::string const input
Definition: EdmProvDump.cc:50

◆ takeTracks()

template<class T >
std::vector< const T * > DivisiveClusterizer1D< T >::takeTracks ( const std::vector< Cluster1D< T > > &  clu) const
private

Definition at line 203 of file DivisiveClusterizer1D.h.

References mps_fire::i, pwdgSkimBPark_cfi::tracks, and trackerHitRTTI::vector.

203  {
204  std::vector<const T*> tracks;
205  for (typename std::vector<Cluster1D<T> >::const_iterator iclu = clu.begin(); iclu != clu.end(); iclu++) {
206  std::vector<const T*> clutks = iclu->tracks();
207  for (typename std::vector<const T*>::const_iterator i = clutks.begin(); i != clutks.end(); ++i) {
208  tracks.push_back(*i);
209  }
210  }
211  return tracks;
212 }

Member Data Documentation

◆ theCleaner

template<class T>
Cluster1DCleaner<T>* DivisiveClusterizer1D< T >::theCleaner
private

◆ theMerger

template<class T>
Cluster1DMerger<T>* DivisiveClusterizer1D< T >::theMerger
private

◆ theNTkMin

template<class T>
unsigned DivisiveClusterizer1D< T >::theNTkMin
private

Definition at line 51 of file DivisiveClusterizer1D.h.

◆ theUseError

template<class T>
bool DivisiveClusterizer1D< T >::theUseError
private

◆ theWei

template<class T>
bool DivisiveClusterizer1D< T >::theWei
private

Definition at line 52 of file DivisiveClusterizer1D.h.

◆ theZOffSet

template<class T>
float DivisiveClusterizer1D< T >::theZOffSet
private

◆ theZSeparation

template<class T>
float DivisiveClusterizer1D< T >::theZSeparation
private

Definition at line 50 of file DivisiveClusterizer1D.h.