#include <DivisiveClusterizer1D.h>
Public Member Functions | |
virtual DivisiveClusterizer1D * | clone () 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 () | |
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< T > | mergeCluster1Ds (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 |
Find the modes with a simple divisive method.
Definition at line 14 of file DivisiveClusterizer1D.h.
DivisiveClusterizer1D< T >::DivisiveClusterizer1D | ( | float | zoffset = 5. , |
int | ntkmin = 5 , |
||
bool | useError = true , |
||
float | zsep = 0.05 , |
||
bool | wei = true |
||
) |
zoffset | maximum distance between track position and position of its cluster (depending on useError its either weighted or physical distance) |
ntkmin | Minimum number of tracks required to form a cluster. |
useError | physical distances or weighted distances. |
zsep | Maximum distance between two adjacent tracks that belong to the same initial cluster. |
wei | Compute 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 67 of file DivisiveClusterizer1D.h.
References DivisiveClusterizer1D< T >::theCleaner, DivisiveClusterizer1D< T >::theMerger, DivisiveClusterizer1D< T >::theUseError, and DivisiveClusterizer1D< T >::theZOffSet.
:theZOffSet(zoffset), theZSeparation(zsep), theNTkMin(ntkmin), theWei(wei), theUseError(useError) { // theDiscardedTracks.clear(); // theTotalDiscardedTracks.clear(); // theCluster1Ds.clear(); TrivialWeightEstimator<T> weightEstimator; theMerger = new Cluster1DMerger<T>( weightEstimator ); theCleaner = new Cluster1DCleaner<T>(theZOffSet,theUseError); }
DivisiveClusterizer1D< T >::~DivisiveClusterizer1D | ( | ) |
Definition at line 83 of file DivisiveClusterizer1D.h.
{ delete theMerger; delete theCleaner; }
DivisiveClusterizer1D< T > * DivisiveClusterizer1D< T >::clone | ( | void | ) | const [virtual] |
Implements Clusterizer1D< T >.
Definition at line 102 of file DivisiveClusterizer1D.h.
{ return new DivisiveClusterizer1D<T> ( * this ); }
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 109 of file DivisiveClusterizer1D.h.
References collect_tpl::input, and python::multivaluedict::sort().
{ using namespace Clusterizer1DCommons; std::vector < Cluster1D<T> > input = inputo; std::vector < Cluster1D<T> > discardedTracks; if ( input.size() < theNTkMin) { insertTracks( input, totDiscardedTracks); return; } sort( input.begin(), input.end(), ComparePairs<T>()); int ncount =0; std::vector < Cluster1D<T> > partOfPTracks; partOfPTracks.push_back(input.front()); for( typename std::vector < Cluster1D<T> >::const_iterator ic=(input.begin())+1; ic != input.end(); ic++) { ncount++; if ( fabs( (*ic).position().value()-(*(ic-1)).position().value() ) < (double) theZSeparation ) { partOfPTracks.push_back((*ic)); } else { if(partOfPTracks.size() >= theNTkMin) { std::vector< Cluster1D<T> > clusters = makeCluster1Ds(partOfPTracks, discardedTracks); for (typename std::vector< Cluster1D<T> >::const_iterator iclus=clusters.begin(); iclus != clusters.end(); iclus++) { finalCluster1Ds.push_back(*iclus); } insertTracks(discardedTracks,totDiscardedTracks); } else { insertTracks(partOfPTracks,totDiscardedTracks); } partOfPTracks.clear(); partOfPTracks.push_back((*ic)); } } if (partOfPTracks.size() >= theNTkMin) { std::vector < Cluster1D<T> > clusters = makeCluster1Ds(partOfPTracks, discardedTracks); for (typename std::vector< Cluster1D<T> >::const_iterator iclus = clusters.begin(); iclus != clusters.end(); iclus++) { finalCluster1Ds.push_back(*iclus); } insertTracks(discardedTracks,totDiscardedTracks); } else { insertTracks(partOfPTracks,totDiscardedTracks); } sort(finalCluster1Ds.begin(), finalCluster1Ds.end(), ComparePairs<T>() ); // reverse(theCluster1Ds.begin(), theCluster1Ds.end()); return; }
void DivisiveClusterizer1D< T >::insertTracks | ( | std::vector< Cluster1D< T > > & | clusou, |
std::vector< Cluster1D< T > > & | cludest | ||
) | const [private] |
Definition at line 233 of file DivisiveClusterizer1D.h.
{ if (clusou.size() == 0) return; for ( typename std::vector< Cluster1D<T> >::const_iterator iclu = clusou.begin(); iclu != clusou.end(); iclu++) { cludest.push_back(*iclu); } /* for ( typename std::vector< Cluster1D<T> >::const_iterator iclu = clu.begin(); iclu != clu.end(); iclu++){ if (total) { theTotalDiscardedTracks.push_back(*iclu); }else { theDiscardedTracks.push_back(*iclu); } } */ return; }
std::vector< Cluster1D< T > > DivisiveClusterizer1D< T >::makeCluster1Ds | ( | std::vector< Cluster1D< T > > & | clusters, |
std::vector< Cluster1D< T > > & | discardedTracks | ||
) | const [private] |
Definition at line 181 of file DivisiveClusterizer1D.h.
{ std::vector < Cluster1D<T> > finalCluster1Ds; discardedTracks.clear(); std::vector<Cluster1D<T> > pvClu0 = clusters; std::vector<Cluster1D<T> > pvCluNew = pvClu0; bool stop = false; while (!stop) { int nDiscardedAtIteration = 100; while ( nDiscardedAtIteration !=0 ) { pvCluNew = theCleaner->clusters(pvClu0); std::vector<Cluster1D<T> > tracksAtIteration = theCleaner->discardedCluster1Ds(); nDiscardedAtIteration = tracksAtIteration.size(); if ( nDiscardedAtIteration!=0 ) { insertTracks(tracksAtIteration,discardedTracks); pvClu0 = pvCluNew; } } // while nDiscardedAtIteration unsigned ntkclus = pvCluNew.size(); unsigned ndiscard = discardedTracks.size(); if ( ntkclus >= theNTkMin ) { //save the cluster finalCluster1Ds.push_back( mergeCluster1Ds(pvCluNew) ); if ( ndiscard >= theNTkMin ) { //make a new cluster and reset pvClu0 = discardedTracks; discardedTracks.clear(); } else { //out of loop stop = true; } } else { insertTracks(pvCluNew, discardedTracks); stop = true; } }// while stop return finalCluster1Ds; }
Cluster1D< T > DivisiveClusterizer1D< T >::mergeCluster1Ds | ( | std::vector< Cluster1D< T > > & | clusters | ) | const [private] |
Definition at line 276 of file DivisiveClusterizer1D.h.
References query::result.
{ Cluster1D<T> result = clusters.front(); for ( typename std::vector< Cluster1D<T> >::iterator iclu = (clusters.begin())+1; iclu != clusters.end(); iclu++) { Cluster1D<T> old = result; result = (*theMerger)( old , *iclu ); } return result; }
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 92 of file DivisiveClusterizer1D.h.
References collect_tpl::input, and convertSQLitetoXML_cfg::output.
{ std::vector < Cluster1D<T> > discardedCluster1Ds; std::vector < Cluster1D<T> > output; findCandidates ( input, output, discardedCluster1Ds ); return std::pair < std::vector < Cluster1D<T> >, std::vector < const T * > > ( output, takeTracks(discardedCluster1Ds) ); }
std::vector< const T * > DivisiveClusterizer1D< T >::takeTracks | ( | const std::vector< Cluster1D< T > > & | clu | ) | const [private] |
Definition at line 258 of file DivisiveClusterizer1D.h.
References i, and testEve_cfg::tracks.
{ std::vector<const T* > tracks; for ( typename std::vector< Cluster1D<T> >::const_iterator iclu = clu.begin(); iclu != clu.end(); iclu++) { std::vector < const T * > clutks = iclu->tracks(); for ( typename std::vector< const T * >::const_iterator i=clutks.begin(); i!=clutks.end() ; ++i ) { tracks.push_back ( *i ); } } return tracks; }
Cluster1DCleaner<T>* DivisiveClusterizer1D< T >::theCleaner [private] |
Definition at line 53 of file DivisiveClusterizer1D.h.
Referenced by DivisiveClusterizer1D< T >::DivisiveClusterizer1D().
Cluster1DMerger<T>* DivisiveClusterizer1D< T >::theMerger [private] |
Definition at line 52 of file DivisiveClusterizer1D.h.
Referenced by DivisiveClusterizer1D< T >::DivisiveClusterizer1D().
unsigned DivisiveClusterizer1D< T >::theNTkMin [private] |
Definition at line 56 of file DivisiveClusterizer1D.h.
bool DivisiveClusterizer1D< T >::theUseError [private] |
Definition at line 58 of file DivisiveClusterizer1D.h.
Referenced by DivisiveClusterizer1D< T >::DivisiveClusterizer1D().
bool DivisiveClusterizer1D< T >::theWei [private] |
Definition at line 57 of file DivisiveClusterizer1D.h.
float DivisiveClusterizer1D< T >::theZOffSet [private] |
Definition at line 54 of file DivisiveClusterizer1D.h.
Referenced by DivisiveClusterizer1D< T >::DivisiveClusterizer1D().
float DivisiveClusterizer1D< T >::theZSeparation [private] |
Definition at line 55 of file DivisiveClusterizer1D.h.