PandaRoot
pixelCluster Struct Reference

#include <PndLmdAlignStructs.h>

Public Member Functions

 pixelCluster ()
 
 pixelCluster (const pixelHit &hit)
 
 pixelCluster (const pixelCluster &copy)
 
bool isNeighbour (pixelCluster &other)
 
void merge (pixelCluster &other)
 
void calculateCenter ()
 
void printPixels ()
 
void printCenter ()
 

Public Attributes

int _sensorId
 
double centerCol
 
double centerRow
 
double clusterSize
 
vector< pixelHitpixelHits
 
bool clusterReady
 

Detailed Description

Definition at line 67 of file PndLmdAlignStructs.h.

Constructor & Destructor Documentation

◆ pixelCluster() [1/3]

pixelCluster::pixelCluster ( )
inline

Definition at line 74 of file PndLmdAlignStructs.h.

75  {
76  _sensorId = -1;
77  centerCol = -1;
78  centerRow = -1; // centerZ=-1;
79  clusterSize = -1;
80  clusterReady = false;
81  }

◆ pixelCluster() [2/3]

pixelCluster::pixelCluster ( const pixelHit hit)
inline

Definition at line 83 of file PndLmdAlignStructs.h.

References pixelHit::_sensorId.

84  {
85  _sensorId = hit._sensorId;
86  pixelHits.push_back(hit);
87 
88  centerCol = -1;
89  centerRow = -1; // centerZ=-1;
90  clusterSize = -1;
91  clusterReady = false;
92  }
vector< pixelHit > pixelHits

◆ pixelCluster() [3/3]

pixelCluster::pixelCluster ( const pixelCluster copy)
inline

Definition at line 94 of file PndLmdAlignStructs.h.

References _sensorId, i, and pixelHits.

95  {
96  _sensorId = copy._sensorId;
97  for (size_t i = 0; i < copy.pixelHits.size(); i++) {
98  pixelHits.push_back(copy.pixelHits[i]);
99  }
100 
101  centerCol = -1;
102  centerRow = -1; // centerZ=-1;
103  clusterSize = -1;
104  clusterReady = false;
105  }
unsigned int i
Definition: P4_F32vec4.h:33
vector< pixelHit > pixelHits

Member Function Documentation

◆ calculateCenter()

void pixelCluster::calculateCenter ( )
inline

Definition at line 140 of file PndLmdAlignStructs.h.

References i, max(), and sqrt().

141  {
142  centerCol = 0;
143  centerRow = 0;
144  for (size_t i = 0; i < pixelHits.size(); i++) {
145  centerCol += pixelHits[i]._col;
146  centerRow += pixelHits[i]._row;
147  }
148  centerCol /= pixelHits.size();
149  centerRow /= pixelHits.size();
150  double tempDistance;
151  // calculate size, go from corner to corner for clusters larger than 2 pixels
152  if (pixelHits.size() == 1) {
153  clusterSize = 1;
154  } else {
155  for (size_t i = 0; i < pixelHits.size(); i++) {
156  for (size_t j = i + 1; j < pixelHits.size(); j++) {
157  double deltax = (pixelHits[i]._col - pixelHits[j]._col);
158  if (deltax > 0) {
159  deltax = deltax + 1;
160  }
161  if (deltax < 0) {
162  deltax = deltax - 1;
163  }
164  double deltay = (pixelHits[i]._row - pixelHits[j]._row);
165  if (deltay > 0) {
166  deltay = deltay + 1;
167  }
168  if (deltay < 0) {
169  deltay = deltay - 1;
170  }
171  tempDistance = sqrt(deltax * deltax + deltay * deltay);
172  clusterSize = max(clusterSize, tempDistance);
173  }
174  }
175  }
176  clusterReady = true;
177  }
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:40
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:37
unsigned int i
Definition: P4_F32vec4.h:33
vector< pixelHit > pixelHits

◆ isNeighbour()

bool pixelCluster::isNeighbour ( pixelCluster other)
inline

Definition at line 110 of file PndLmdAlignStructs.h.

References _sensorId, i, and pixelHits.

111  {
112  // first, they must be on same sensor
113  if (_sensorId != other._sensorId) {
114  return false;
115  }
116  double _col1, _col2, _row1, _row2;
117  for (size_t i = 0; i < this->pixelHits.size(); i++) {
118  _col1 = this->pixelHits[i]._col;
119  _row1 = this->pixelHits[i]._row;
120  for (size_t j = 0; j < other.pixelHits.size(); j++) {
121  _col2 = other.pixelHits[j]._col;
122  _row2 = other.pixelHits[j]._row;
123  // check if neighboring, that means distance of pixels is smaller than 1.5 pixels
124  if ((_col2 - _col1) * (_col2 - _col1) + (_row2 - _row1) * (_row2 - _row1) < 2.25) {
125  return true;
126  }
127  }
128  }
129  return false;
130  }
unsigned int i
Definition: P4_F32vec4.h:33
vector< pixelHit > pixelHits

◆ merge()

void pixelCluster::merge ( pixelCluster other)
inline

Definition at line 133 of file PndLmdAlignStructs.h.

References i, and pixelHits.

134  {
135  for (size_t i = 0; i < other.pixelHits.size(); i++) {
136  pixelHits.push_back(other.pixelHits[i]);
137  }
138  }
unsigned int i
Definition: P4_F32vec4.h:33
vector< pixelHit > pixelHits

◆ printCenter()

void pixelCluster::printCenter ( )
inline

Definition at line 185 of file PndLmdAlignStructs.h.

186  {
187  cout << "clusterCenter x:" << centerCol << ", y:" << centerRow << " on sensor " << _sensorId << ", contains " << pixelHits.size() << " pixels and is " << clusterSize
188  << " pixels in diameter."
189  << "\n";
190  }
vector< pixelHit > pixelHits

◆ printPixels()

void pixelCluster::printPixels ( )
inline

Definition at line 179 of file PndLmdAlignStructs.h.

References i.

180  {
181  for (size_t i = 0; i < pixelHits.size(); i++) {
182  cout << "pixelHit x:" << pixelHits[i]._col << ", y:" << pixelHits[i]._row << " on sensor " << pixelHits[i]._sensorId << "\n";
183  }
184  }
unsigned int i
Definition: P4_F32vec4.h:33
vector< pixelHit > pixelHits

Member Data Documentation

◆ _sensorId

int pixelCluster::_sensorId

Definition at line 68 of file PndLmdAlignStructs.h.

Referenced by isNeighbour(), and pixelCluster().

◆ centerCol

double pixelCluster::centerCol

Definition at line 69 of file PndLmdAlignStructs.h.

◆ centerRow

double pixelCluster::centerRow

Definition at line 69 of file PndLmdAlignStructs.h.

◆ clusterReady

bool pixelCluster::clusterReady

Definition at line 72 of file PndLmdAlignStructs.h.

◆ clusterSize

double pixelCluster::clusterSize

Definition at line 70 of file PndLmdAlignStructs.h.

◆ pixelHits

vector<pixelHit> pixelCluster::pixelHits

Definition at line 71 of file PndLmdAlignStructs.h.

Referenced by isNeighbour(), merge(), and pixelCluster().


The documentation for this struct was generated from the following file: