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

template<>
void addNeighbors (std::vector< Ref_Phase2TrackerDigi_ > &cluster, const std::vector< Ref_Phase2TrackerDigi_ > &input, unsigned int startVal, std::vector< bool > &used) const
 
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
 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

◆ TTClusterAlgorithm_neighbor()

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

Constructor.

Data members Other stuff

Definition at line 42 of file TTClusterAlgorithm_neighbor.h.

42 : TTClusterAlgorithm<T>(__func__) {}
Base class for any algorithm to be used in TTClusterBuilder.

◆ ~TTClusterAlgorithm_neighbor()

template<typename T >
TTClusterAlgorithm_neighbor< T >::~TTClusterAlgorithm_neighbor ( )
inlineoverride

Destructor.

Definition at line 45 of file TTClusterAlgorithm_neighbor.h.

45 {}

Member Function Documentation

◆ addNeighbors() [1/3]

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

References mps_fire::i, and input.

54  {
57  cluster.reserve(input.size());
58  typename std::vector<Ref_Phase2TrackerDigi_>::iterator clusIter;
59 
61  for (clusIter = cluster.begin(); clusIter < cluster.end(); clusIter++) {
63  for (unsigned int i = startVal; i < input.size(); i++) {
65  if (isANeighbor(*clusIter, input[i])) {
66  cluster.push_back(input[i]);
67  used[i] = true;
68  }
69  }
70  }
71 }
bool isANeighbor(const T &center, const T &mayNeigh) const
Needed for neighbours.
static std::string const input
Definition: EdmProvDump.cc:50

◆ addNeighbors() [2/3]

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

◆ addNeighbors() [3/3]

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.

◆ Cluster() [1/3]

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 mps_fire::i, input, and convertSQLitetoXML_cfg::output.

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

◆ Cluster() [2/3]

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

◆ Cluster() [3/3]

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

◆ isANeighbor() [1/3]

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

References funct::abs().

42  {
43  unsigned int rowdist = std::abs((int)(center->row()) - (int)(mayNeigh->row()));
44  unsigned int coldist = std::abs((int)(center->column()) - (int)(mayNeigh->column()));
45  return rowdist <= 1 && coldist <= 1;
46 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22

◆ isANeighbor() [2/3]

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

Needed for neighbours.

◆ isANeighbor() [3/3]

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

Check if the hit is a neighbour.