CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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
 
template<>
void Cluster (std::vector< std::vector< Ref_Phase2TrackerDigi_ > > &output, const std::vector< Ref_Phase2TrackerDigi_ > &input) const
 
void Cluster (std::vector< std::vector< T > > &output, const std::vector< T > &input) const
 Clustering operations. More...
 
template<>
void Cluster (std::vector< std::vector< Ref_Phase2TrackerDigi_ > > &output, const std::vector< Ref_Phase2TrackerDigi_ > &input) const
 
template<>
bool isANeighbor (const Ref_Phase2TrackerDigi_ &center, const Ref_Phase2TrackerDigi_ &mayNeigh) const
 
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
 
 TTClusterAlgorithm_neighbor ()
 Constructor. More...
 
 ~TTClusterAlgorithm_neighbor ()
 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 ( )
inline

Destructor.

Definition at line 47 of file TTClusterAlgorithm_neighbor.h.

47 {}

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 i.

59 {
62  cluster.reserve( input.size() );
63  typename std::vector< Ref_Phase2TrackerDigi_ >::iterator clusIter;
64  typename std::vector< Ref_Phase2TrackerDigi_ >::iterator inIter;
65 
67  for ( clusIter = cluster.begin();
68  clusIter < cluster.end();
69  clusIter++ )
70  {
72  for ( unsigned int i=startVal; i<input.size(); i++)
73  {
75  if ( isANeighbor(*clusIter, input[i]) )
76  {
77  cluster.push_back(input[i]);
78  used[i]=true;
79  }
80  }
81  }
82 }
bool isANeighbor(const T &center, const T &mayNeigh) const
Needed for neighbours.
int i
Definition: DBlmapReader.cc:9
static std::string const input
Definition: EdmProvDump.cc:44
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
template<>
void TTClusterAlgorithm_neighbor< Ref_Phase2TrackerDigi_ >::Cluster ( std::vector< std::vector< Ref_Phase2TrackerDigi_ > > &  output,
const std::vector< Ref_Phase2TrackerDigi_ > &  input 
) const

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 edm::false, 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 }
int i
Definition: DBlmapReader.cc:9
static std::string const input
Definition: EdmProvDump.cc:44
void addNeighbors(std::vector< T > &cluster, const std::vector< T > &input, unsigned int start, std::vector< bool > &masked) const
volatile std::atomic< bool > shutdown_flag false
template<typename T>
void TTClusterAlgorithm_neighbor< T >::Cluster ( std::vector< std::vector< T > > &  output,
const std::vector< T > &  input 
) const
virtual

Clustering operations.

Reimplemented from TTClusterAlgorithm< T >.

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

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

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

Needed for neighbours.

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