CMS 3D CMS Logo

Public Member Functions

ClusteringAlgorithm_neighbor< T > Class Template Reference

#include <ClusteringAlgorithm_neighbor.h>

Inheritance diagram for ClusteringAlgorithm_neighbor< T >:
ClusteringAlgorithm< T >

List of all members.

Public Member Functions

void addNeighbors (std::vector< T > &cluster, const std::vector< T > &input, unsigned int start, std::vector< bool > &masked) const
 Add neighbours to the cluster.
void Cluster (std::vector< std::vector< T > > &output, const std::vector< T > &input) const
 Clustering operations.
 ClusteringAlgorithm_neighbor (const StackedTrackerGeometry *aStackedTracker)
 Constructor.
bool isANeighbor (const T &center, const T &mayNeigh) const
 Needed for neighbours.
 ~ClusteringAlgorithm_neighbor ()
 Destructor.

Detailed Description

template<typename T>
class ClusteringAlgorithm_neighbor< T >

//////////////////////////////////////// Stacked Tracker Simulations /// / Kristofer Henriksson /// ////////////////////////////////////// //////////////////////////////////////// This is a greedy clustering to be /// used for diagnostic purposes, which /// will make clusters as large as /// possible by including all contiguous /// hits in a single cluster. /// ////////////////////////////////////// ************************ DECLARATION OF CLASS ************************

Definition at line 38 of file ClusteringAlgorithm_neighbor.h.


Constructor & Destructor Documentation

template<typename T>
ClusteringAlgorithm_neighbor< T >::ClusteringAlgorithm_neighbor ( const StackedTrackerGeometry aStackedTracker) [inline]

Constructor.

Data members Other stuff

Definition at line 46 of file ClusteringAlgorithm_neighbor.h.

        : ClusteringAlgorithm< T >( aStackedTracker,__func__ ) {}
template<typename T>
ClusteringAlgorithm_neighbor< T >::~ClusteringAlgorithm_neighbor ( ) [inline]

Destructor.

Definition at line 50 of file ClusteringAlgorithm_neighbor.h.

{}

Member Function Documentation

template<typename T >
void ClusteringAlgorithm_neighbor< T >::addNeighbors ( std::vector< T > &  cluster,
const std::vector< T > &  input,
unsigned int  start,
std::vector< bool > &  masked 
) const

Add neighbours to the cluster.

This following line is necessary to ensure the iterators afterward remain valid.

Loop over hits

Loop over candidate neighbours

Is it really a neighbour?

End of loop over candidate neighbours

End of loop over hits

Definition at line 102 of file ClusteringAlgorithm_neighbor.h.

References i.

  {
    cluster.reserve(input.size());
    typename std::vector< T >::iterator clusIter;
    typename std::vector< T >::iterator inIter;

    for ( clusIter = cluster.begin();
          clusIter < cluster.end();
          clusIter++ )
    {
      for ( unsigned int i=startVal; i<input.size(); i++) 
      {
        if ( isANeighbor(*clusIter, input[i]) )
          {
            cluster.push_back(input[i]);
            used[i]=true;
          }
      } 
    } 
  }
template<typename T >
void ClusteringAlgorithm_neighbor< T >::Cluster ( std::vector< std::vector< T > > &  output,
const std::vector< T > &  input 
) const [virtual]

Clustering operations.

Close class.

***************************** IMPLEMENTATION OF METHODS ***************************** Clustering operations

Prepare output

Loop over all input hits and delete them once clustered

End of iteration

Reimplemented from ClusteringAlgorithm< T >.

Definition at line 70 of file ClusteringAlgorithm_neighbor.h.

References i, and convertSQLitetoXML_cfg::output.

  {
    output.clear();
    std::vector<bool> used(input.size(),false);

    for ( unsigned int i=0; i<input.size(); i++) {
      if (used[i]) continue;
      std::vector<T> cluster;
      cluster.push_back(input[i]);
      used[i]=true;
      if (i<input.size()-1)
        addNeighbors( cluster, input, i+1, used );
      output.push_back(cluster);
    } 
  }
template<typename T >
bool ClusteringAlgorithm_neighbor< T >::isANeighbor ( const T center,
const T mayNeigh 
) const

Needed for neighbours.

Check if the hit is a neighbour.

Definition at line 92 of file ClusteringAlgorithm_neighbor.h.

References abs.

  {
    unsigned int rowdist = abs(center->row() - mayNeigh->row());
    unsigned int coldist = abs(center->column() - mayNeigh->column());
    return rowdist <= 1 && coldist <= 1;
  }