CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes
TTClusterAlgorithm_official< T > Class Template Reference

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

#include <TTClusterAlgorithm_official.h>

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

Public Member Functions

template<>
void Cluster (std::vector< std::vector< Ref_Phase2TrackerDigi_ > > &output, const std::vector< Ref_Phase2TrackerDigi_ > &input, bool isPS) const
 Clustering operations. More...
 
void Cluster (std::vector< std::vector< T > > &output, const std::vector< T > &input, bool isPS) const override
 Clustering operations. More...
 
template<>
void Cluster (std::vector< std::vector< Ref_Phase2TrackerDigi_ > > &output, const std::vector< Ref_Phase2TrackerDigi_ > &input, bool isPS) const
 Clustering operations. More...
 
 TTClusterAlgorithm_official (int aWidthCut)
 Constructor. More...
 
 ~TTClusterAlgorithm_official () 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) const
 Basic version common to all the algorithms but official. More...
 
 TTClusterAlgorithm (std::string fName)
 Constructors. More...
 
virtual ~TTClusterAlgorithm ()
 Destructor. More...
 

Private Member Functions

template<>
bool CompareClusters (const Ref_Phase2TrackerDigi_ &a, const Ref_Phase2TrackerDigi_ &b)
 Implementation of methods of TTClusterAlgorithm_official. More...
 
template<>
bool CompareClusters (const Ref_Phase2TrackerDigi_ &a, const Ref_Phase2TrackerDigi_ &b)
 Close class. More...
 

Static Private Member Functions

static bool CompareClusters (const T &a, const T &b)
 Cluster max width. More...
 

Private Attributes

int mWidthCut
 Data members. More...
 

Additional Inherited Members

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

Detailed Description

template<typename T>
class TTClusterAlgorithm_official< T >

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

2D clusters: make 1D and then attach them to each other if their pixels are close to each other, CW cut at the end 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
Nicola Pozzobon
Date
2013, Jul 12

Definition at line 32 of file TTClusterAlgorithm_official.h.

Constructor & Destructor Documentation

template<typename T>
TTClusterAlgorithm_official< T >::TTClusterAlgorithm_official ( int  aWidthCut)
inline

Constructor.

Definition at line 44 of file TTClusterAlgorithm_official.h.

45  : TTClusterAlgorithm< T >( __func__ )
46  {
47  mWidthCut = aWidthCut;
48  }
Base class for any algorithm to be used in TTClusterBuilder.
template<typename T>
TTClusterAlgorithm_official< T >::~TTClusterAlgorithm_official ( )
inlineoverride

Member Function Documentation

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

Clustering operations.

Prepare the output

Prepare a proper hit container

Map all the hits by column index

1D Clusters must be stored properly <column, first row index>

Loop over the mapped hits

Collect hits sharing column index and differing by 1 in row index

Loop over single column

Nested loop

Check col/row and add to the cluster

End of nested loop

Sort the vector elements by row index

Put the cluster in the map

End of loop over single column

End of loop over mapped hits

Cluster over the second dimension only in PS modules!

Add the hits

Loop over the other elements of the map

Skip same element

Skip non-contiguous column

Column is contiguous Update the "last column index" This should be safe as maps are sorted structures by construction

Check that the cluster is good to be clustered Get first row

Get the max row in the cluster

Check if they overlap

If so, add the hits to the cluster!

End of nested loop

Check output Sort the vector by row index

one should add 1 to use <=

End of isPS

Check output Sort the vector by row index

one should add 1 to use <=

End of non-PS case

End of loop over mapped 1D Clusters

Definition at line 21 of file TTClusterAlgorithm_official.cc.

References funct::abs(), convertSQLitetoXML_cfg::output, and groupFilesInBlocks::temp.

24 {
26  output.clear();
27 
29  std::map< unsigned int, std::vector< Ref_Phase2TrackerDigi_ > > mapHitsByColumn;
30 
32  typename std::vector< Ref_Phase2TrackerDigi_ >::const_iterator inputIterator;
33  inputIterator = input.begin();
34  while ( inputIterator != input.end() )
35  {
36  mapHitsByColumn[(**inputIterator).column()].push_back(*inputIterator);
37  ++inputIterator;
38  }
39 
41  std::map< std::pair< unsigned int, unsigned int >, std::vector< Ref_Phase2TrackerDigi_ > > map1DCluByColRow;
42 
44  typename std::map< unsigned int, std::vector< Ref_Phase2TrackerDigi_ > >::iterator mapIterHbC;
45  mapIterHbC = mapHitsByColumn.begin();
46  while ( mapIterHbC != mapHitsByColumn.end() )
47  {
50  typename std::vector< Ref_Phase2TrackerDigi_ >::iterator inputIterator;
51  inputIterator = mapIterHbC->second.begin();
52 
54  while( inputIterator != mapIterHbC->second.end() )
55  {
56  std::vector< Ref_Phase2TrackerDigi_ > temp;
57  temp.push_back(*inputIterator);
58  inputIterator = mapIterHbC->second.erase(inputIterator);
59  typename std::vector< Ref_Phase2TrackerDigi_ >::iterator inputIterator2;
60  inputIterator2 = inputIterator;
61 
63  while( inputIterator2 != mapIterHbC->second.end() )
64  {
66  if( (temp.back()->column() == (**inputIterator2).column()) &&
67  ((**inputIterator2).row() - temp.back()->row() == 1) )
68  {
69  temp.push_back(*inputIterator2);
70  inputIterator2 = mapIterHbC->second.erase(inputIterator2);
71  }
72  else
73  break;
74 
75  }
76 
78  std::sort( temp.begin(), temp.end(), CompareClusters );
79 
81  map1DCluByColRow.insert( std::make_pair( std::make_pair( mapIterHbC->first, temp.at(0)->row() ), temp ) );
82 
83  inputIterator = inputIterator2;
84 
85  }
86  ++mapIterHbC;
87 
88  }
89 
92  typename std::map< std::pair< unsigned int, unsigned int>, std::vector< Ref_Phase2TrackerDigi_ > >::iterator mapIter1DCbCR0;
93  typename std::map< std::pair< unsigned int, unsigned int>, std::vector< Ref_Phase2TrackerDigi_ > >::iterator mapIter1DCbCR1;
94  mapIter1DCbCR0 = map1DCluByColRow.begin();
95  unsigned int lastCol = mapIter1DCbCR0->first.first;
96 
97  while ( mapIter1DCbCR0 != map1DCluByColRow.end() )
98  {
100  std::vector< Ref_Phase2TrackerDigi_ > candCluster;
101  candCluster.insert( candCluster.end(), mapIter1DCbCR0->second.begin(), mapIter1DCbCR0->second.end() );
102 
103  if ( isPS )
104  {
106  mapIter1DCbCR1 = map1DCluByColRow.begin();
107 
108  while ( mapIter1DCbCR1 != map1DCluByColRow.end() )
109  {
111  if ( mapIter1DCbCR1 == mapIter1DCbCR0 )
112  {
113  ++mapIter1DCbCR1;
114  continue;
115  }
116 
118  if ( std::abs( (int)(mapIter1DCbCR1->first.first) - (int)lastCol ) != 1 )
119  {
120  ++mapIter1DCbCR1;
121  continue;
122  }
123 
127  lastCol = mapIter1DCbCR1->first.first;
128 
131  unsigned int iRow0 = mapIter1DCbCR0->first.second;
132  unsigned int iRow1 = mapIter1DCbCR1->first.second;
133 
135  unsigned int jRow0 = mapIter1DCbCR0->second.back()->row();
136  unsigned int jRow1 = mapIter1DCbCR1->second.back()->row();
137 
139  if ( ( iRow1 >= iRow0 && iRow1 <= jRow0 ) ||
140  ( jRow1 >= iRow0 && jRow1 <= jRow0 ) )
141  {
143  candCluster.insert( candCluster.end(), mapIter1DCbCR1->second.begin(), mapIter1DCbCR1->second.end() );
144  map1DCluByColRow.erase( mapIter1DCbCR1++ );
145  }
146  else
147  {
148  ++mapIter1DCbCR1;
149  }
150  }
151 
152  map1DCluByColRow.erase( mapIter1DCbCR0++ );
153 
156  std::sort( candCluster.begin(), candCluster.end(), CompareClusters );
157  /*
158  std::cout << candCluster.at(0)->row() - candCluster.back()->row() << " / "
159  << static_cast<int>(candCluster.at(0)->row() - candCluster.back()->row()) << " / "
160  << abs( candCluster.at(0)->row() - candCluster.back()->row() ) << " / "
161  << std::abs( candCluster.at(0)->row() - candCluster.back()->row() ) << " / "
162  << mWidthCut << std::endl;
163  */
164  if ( std::abs( static_cast<int>(candCluster.at(0)->row() - candCluster.back()->row()) ) < mWidthCut ||
165  mWidthCut < 1 )
166  {
167  output.push_back( candCluster );
168  }
169  }
170  else
171  {
172  map1DCluByColRow.erase( mapIter1DCbCR0++ );
173 
176  std::sort( candCluster.begin(), candCluster.end(), CompareClusters );
177 
178  if ( std::abs( static_cast<int>(candCluster.at(0)->row() - candCluster.back()->row()) ) < mWidthCut ||
179  mWidthCut < 1 )
180  {
181  output.push_back( candCluster );
182  }
183  }
184  }
185 }
static bool CompareClusters(const T &a, const T &b)
Cluster max width.
static std::string const input
Definition: EdmProvDump.cc:45
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
template<typename T>
void TTClusterAlgorithm_official< T >::Cluster ( std::vector< std::vector< T > > &  output,
const std::vector< T > &  input,
bool  isPS 
) const
overridevirtual

Clustering operations.

Reimplemented from TTClusterAlgorithm< T >.

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

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

Clustering operations.

template<>
bool TTClusterAlgorithm_official< Ref_Phase2TrackerDigi_ >::CompareClusters ( const Ref_Phase2TrackerDigi_ a,
const Ref_Phase2TrackerDigi_ b 
)
private

Implementation of methods of TTClusterAlgorithm_official.

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

Author
Nicola Pozzobon
Date
2013, Jul 12Function to compare clusters and sort them by row

Definition at line 14 of file TTClusterAlgorithm_official.cc.

References Phase2TrackerDigi::row().

15 {
16  return ( a->row() < b->row() );
17 }
unsigned int row() const
template<typename T>
static bool TTClusterAlgorithm_official< T >::CompareClusters ( const T a,
const T b 
)
staticprivate

Cluster max width.

Function to compare clusters and sort them by row

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

template<>
bool TTClusterAlgorithm_official< Ref_Phase2TrackerDigi_ >::CompareClusters ( const Ref_Phase2TrackerDigi_ a,
const Ref_Phase2TrackerDigi_ b 
)
private

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.Function to compare clusters and sort them by row

Member Data Documentation

template<typename T>
int TTClusterAlgorithm_official< T >::mWidthCut
private

Data members.

Definition at line 36 of file TTClusterAlgorithm_official.h.

Referenced by ES_TTClusterAlgorithm_official< T >::produce().