CMS 3D CMS Logo

List of all members | Public Member Functions
TTClusterAlgorithm_neighbor< T > Class Template Reference

Class for "neighbor" algorithm to be used in TTClusterBuilder. More...

#include <TTClusterAlgorithm_neighbor.h>

Inheritance diagram for TTClusterAlgorithm_neighbor< T >:
TTClusterAlgorithm< T >

Public Member Functions

void addNeighbors (std::vector< T > &cluster, const std::vector< T > &input, unsigned int start, std::vector< bool > &masked) const
 
template<>
void addNeighbors (std::vector< Ref_Phase2TrackerDigi_ > &cluster, const std::vector< Ref_Phase2TrackerDigi_ > &input, unsigned int startVal, std::vector< bool > &used) const
 
template<>
void addNeighbors (std::vector< Ref_Phase2TrackerDigi_ > &cluster, const std::vector< Ref_Phase2TrackerDigi_ > &input, unsigned int startVal, std::vector< bool > &used) const
 Add neighbours to the cluster. More...
 
template<>
void Cluster (std::vector< std::vector< Ref_Phase2TrackerDigi_ > > &output, const std::vector< Ref_Phase2TrackerDigi_ > &input) const
 Implementation of methods of TTClusterAlgorithm_neighbor. More...
 
void Cluster (std::vector< std::vector< T > > &output, const std::vector< T > &input) const override
 Clustering operations. More...
 
template<>
void Cluster (std::vector< std::vector< Ref_Phase2TrackerDigi_ > > &output, const std::vector< Ref_Phase2TrackerDigi_ > &input) const
 Close class. More...
 
template<>
bool isANeighbor (const Ref_Phase2TrackerDigi_ &center, const Ref_Phase2TrackerDigi_ &mayNeigh) const
 End of Clustering Operations. More...
 
bool isANeighbor (const T &center, const T &mayNeigh) const
 Needed for neighbours. More...
 
template<>
bool isANeighbor (const Ref_Phase2TrackerDigi_ &center, const Ref_Phase2TrackerDigi_ &mayNeigh) const
 Check if the hit is a neighbour. More...
 
 TTClusterAlgorithm_neighbor ()
 Constructor. More...
 
 ~TTClusterAlgorithm_neighbor () override
 Destructor. More...
 
- Public Member Functions inherited from TTClusterAlgorithm< T >
virtual std::string AlgorithmName () const
 Algorithm name. More...
 
virtual void Cluster (std::vector< std::vector< T > > &output, const std::vector< T > &input, bool module) const
 
 TTClusterAlgorithm (std::string fName)
 Constructors. More...
 
virtual ~TTClusterAlgorithm ()
 Destructor. More...
 

Additional Inherited Members

- Protected Attributes inherited from TTClusterAlgorithm< T >
std::string className_
 Data members. More...
 

Detailed Description

template<typename T>
class TTClusterAlgorithm_neighbor< T >

Class for "neighbor" algorithm to be used in TTClusterBuilder.

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. After moving from SimDataFormats to DataFormats, the template structure of the class was maintained in order to accomodate any types other than PixelDigis in case there is such a need in the future.

Author
Kristofer Henriksson
Date
2013, Jul 15

Definition at line 35 of file TTClusterAlgorithm_neighbor.h.

Constructor & Destructor Documentation

template<typename T>
TTClusterAlgorithm_neighbor< T >::TTClusterAlgorithm_neighbor ( )
inline

Constructor.

Data members Other stuff

Definition at line 43 of file TTClusterAlgorithm_neighbor.h.

44  : TTClusterAlgorithm< T >( __func__ ){}
Base class for any algorithm to be used in TTClusterBuilder.
template<typename T>
TTClusterAlgorithm_neighbor< T >::~TTClusterAlgorithm_neighbor ( )
inlineoverride

Member Function Documentation

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

Add neighbours to the cluster Specialize template for Phase2TrackerDigis

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 55 of file TTClusterAlgorithm_neighbor.cc.

References mps_fire::i.

59 {
62  cluster.reserve( input.size() );
63  typename std::vector< Ref_Phase2TrackerDigi_ >::iterator clusIter;
64 
66  for ( clusIter = cluster.begin();
67  clusIter < cluster.end();
68  clusIter++ )
69  {
71  for ( unsigned int i=startVal; i<input.size(); i++)
72  {
74  if ( isANeighbor(*clusIter, input[i]) )
75  {
76  cluster.push_back(input[i]);
77  used[i]=true;
78  }
79  }
80  }
81 }
bool isANeighbor(const T &center, const T &mayNeigh) const
Needed for neighbours.
static std::string const input
Definition: EdmProvDump.cc:48
template<>
void TTClusterAlgorithm_neighbor< Ref_Phase2TrackerDigi_ >::addNeighbors ( std::vector< Ref_Phase2TrackerDigi_ > &  cluster,
const std::vector< Ref_Phase2TrackerDigi_ > &  input,
unsigned int  startVal,
std::vector< bool > &  used 
) const

Add neighbours to the cluster.

template<>
void TTClusterAlgorithm_neighbor< Ref_Phase2TrackerDigi_ >::Cluster ( std::vector< std::vector< Ref_Phase2TrackerDigi_ > > &  output,
const std::vector< Ref_Phase2TrackerDigi_ > &  input 
) const

Implementation of methods of TTClusterAlgorithm_neighbor.

Here, in the source file, the methods which do depend on the specific type <T> that can fit the template.

Author
Kristofer Henriksson
Date
2013, Jul 15Clustering operations Specialize template for Phase2TrackerDigis

Prepare output

Loop over all input hits and delete them once clustered

End of iteration

Definition at line 15 of file TTClusterAlgorithm_neighbor.cc.

References funct::false, mps_fire::i, and convertSQLitetoXML_cfg::output.

17 {
19  output.clear();
20 
23  std::vector< bool > used( input.size(), false );
24 
25  for ( unsigned int i = 0; i < input.size(); i++ )
26  {
27  if ( used[i] )
28  continue;
29 
30  std::vector< Ref_Phase2TrackerDigi_ > cluster;
31  cluster.push_back(input[i]);
32  used[i] = true;
33  if ( i < input.size()-1 )
34  {
35  addNeighbors( cluster, input, i+1, used );
36  }
37  output.push_back( cluster );
38  }
39 }
static std::string const input
Definition: EdmProvDump.cc:48
void addNeighbors(std::vector< T > &cluster, const std::vector< T > &input, unsigned int start, std::vector< bool > &masked) const
template<typename T>
void TTClusterAlgorithm_neighbor< T >::Cluster ( std::vector< std::vector< T > > &  output,
const std::vector< T > &  input 
) const
overridevirtual

Clustering operations.

Reimplemented from TTClusterAlgorithm< T >.

Referenced by TTClusterAlgorithm_neighbor< T >::~TTClusterAlgorithm_neighbor().

template<>
void TTClusterAlgorithm_neighbor< Ref_Phase2TrackerDigi_ >::Cluster ( std::vector< std::vector< Ref_Phase2TrackerDigi_ > > &  output,
const std::vector< Ref_Phase2TrackerDigi_ > &  input 
) const

Close class.

Implementation of methods

Here, in the header file, the methods which do not depend on the specific type <T> that can fit the template. Other methods, with type-specific features, are implemented in the source file.Clustering operations

template<>
bool TTClusterAlgorithm_neighbor< Ref_Phase2TrackerDigi_ >::isANeighbor ( const Ref_Phase2TrackerDigi_ center,
const Ref_Phase2TrackerDigi_ mayNeigh 
) const

End of Clustering Operations.

Check if the hit is a neighbour Specialize template for Phase2TrackerDigis

Definition at line 44 of file TTClusterAlgorithm_neighbor.cc.

References funct::abs().

46 {
47  unsigned int rowdist = std::abs((int)(center->row()) - (int)(mayNeigh->row()));
48  unsigned int coldist = std::abs((int)(center->column()) - (int)(mayNeigh->column()));
49  return rowdist <= 1 && coldist <= 1;
50 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
template<typename T>
bool TTClusterAlgorithm_neighbor< T >::isANeighbor ( const T center,
const T mayNeigh 
) const
template<>
bool TTClusterAlgorithm_neighbor< Ref_Phase2TrackerDigi_ >::isANeighbor ( const Ref_Phase2TrackerDigi_ center,
const Ref_Phase2TrackerDigi_ mayNeigh 
) const

Check if the hit is a neighbour.