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  int ncount = 0;
106  std::vector<Cluster1D<T> > partOfPTracks;
107  partOfPTracks.push_back(input.front());
108  for (typename std::vector<Cluster1D<T> >::const_iterator ic = (input.begin()) + 1; ic != input.end(); ic++) {
109  ncount++;
110  if (fabs((*ic).position().value() - (*(ic - 1)).position().value()) < (double)theZSeparation) {
111  partOfPTracks.push_back((*ic));
112  } else {
113  if (partOfPTracks.size() >= theNTkMin) {
114  std::vector<Cluster1D<T> > clusters = makeCluster1Ds(partOfPTracks, discardedTracks);
115  for (typename std::vector<Cluster1D<T> >::const_iterator iclus = clusters.begin(); iclus != clusters.end();
116  iclus++) {
117  finalCluster1Ds.push_back(*iclus);
118  }
119  insertTracks(discardedTracks, totDiscardedTracks);
120  } else {
121  insertTracks(partOfPTracks, totDiscardedTracks);
122  }
123  partOfPTracks.clear();
124  partOfPTracks.push_back((*ic));
125  }
126  }
127  if (partOfPTracks.size() >= theNTkMin) {
128  std::vector<Cluster1D<T> > clusters = makeCluster1Ds(partOfPTracks, discardedTracks);
129  for (typename std::vector<Cluster1D<T> >::const_iterator iclus = clusters.begin(); iclus != clusters.end();
130  iclus++) {
131  finalCluster1Ds.push_back(*iclus);
132  }
133  insertTracks(discardedTracks, totDiscardedTracks);
134  } else {
135  insertTracks(partOfPTracks, totDiscardedTracks);
136  }
137 
138  sort(finalCluster1Ds.begin(), finalCluster1Ds.end(), ComparePairs<T>());
139  // reverse(theCluster1Ds.begin(), theCluster1Ds.end());
140 
141  return;
142 }
static std::string const input
Definition: EdmProvDump.cc:47
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 184 of file DivisiveClusterizer1D.h.

References trackerHitRTTI::vector.

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

◆ 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 145 of file DivisiveClusterizer1D.h.

References bsc_activity_cfg::clusters.

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

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

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

◆ 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:47

◆ takeTracks()

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

Definition at line 205 of file DivisiveClusterizer1D.h.

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

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

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.