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 55 of file PndLmdAlignStructs.h.

Constructor & Destructor Documentation

◆ pixelCluster() [1/3]

pixelCluster::pixelCluster ( )
inline

Definition at line 62 of file PndLmdAlignStructs.h.

63  {
64  _sensorId = -1;
65  centerCol = -1;
66  centerRow = -1; // centerZ=-1;
67  clusterSize = -1;
68  clusterReady = false;
69  }

◆ pixelCluster() [2/3]

pixelCluster::pixelCluster ( const pixelHit hit)
inline

Definition at line 71 of file PndLmdAlignStructs.h.

References pixelHit::_sensorId.

72  {
73  _sensorId = hit._sensorId;
74  pixelHits.push_back(hit);
75 
76  centerCol = -1;
77  centerRow = -1; // centerZ=-1;
78  clusterSize = -1;
79  clusterReady = false;
80  }
vector< pixelHit > pixelHits

◆ pixelCluster() [3/3]

pixelCluster::pixelCluster ( const pixelCluster copy)
inline

Definition at line 82 of file PndLmdAlignStructs.h.

References _sensorId, i, and pixelHits.

83  {
84  _sensorId = copy._sensorId;
85  for (size_t i = 0; i < copy.pixelHits.size(); i++) {
86  pixelHits.push_back(copy.pixelHits[i]);
87  }
88 
89  centerCol = -1;
90  centerRow = -1; // centerZ=-1;
91  clusterSize = -1;
92  clusterReady = false;
93  }
unsigned int i
Definition: P4_F32vec4.h:21
vector< pixelHit > pixelHits

Member Function Documentation

◆ calculateCenter()

void pixelCluster::calculateCenter ( )
inline

Definition at line 128 of file PndLmdAlignStructs.h.

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

129  {
130  centerCol = 0;
131  centerRow = 0;
132  for (size_t i = 0; i < pixelHits.size(); i++) {
133  centerCol += pixelHits[i]._col;
134  centerRow += pixelHits[i]._row;
135  }
136  centerCol /= pixelHits.size();
137  centerRow /= pixelHits.size();
138  double tempDistance;
139  // calculate size, go from corner to corner for clusters larger than 2 pixels
140  if (pixelHits.size() == 1) {
141  clusterSize = 1;
142  } else {
143  for (size_t i = 0; i < pixelHits.size(); i++) {
144  for (size_t j = i + 1; j < pixelHits.size(); j++) {
145  double deltax = (pixelHits[i]._col - pixelHits[j]._col);
146  if (deltax > 0) {
147  deltax = deltax + 1;
148  }
149  if (deltax < 0) {
150  deltax = deltax - 1;
151  }
152  double deltay = (pixelHits[i]._row - pixelHits[j]._row);
153  if (deltay > 0) {
154  deltay = deltay + 1;
155  }
156  if (deltay < 0) {
157  deltay = deltay - 1;
158  }
159  tempDistance = sqrt(deltax * deltax + deltay * deltay);
160  clusterSize = max(clusterSize, tempDistance);
161  }
162  }
163  }
164  clusterReady = true;
165  }
friend F32vec4 sqrt(const F32vec4 &a)
Definition: P4_F32vec4.h:28
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition: P4_F32vec4.h:25
unsigned int i
Definition: P4_F32vec4.h:21
vector< pixelHit > pixelHits

◆ isNeighbour()

bool pixelCluster::isNeighbour ( pixelCluster other)
inline

Definition at line 98 of file PndLmdAlignStructs.h.

References _sensorId, i, and pixelHits.

99  {
100  // first, they must be on same sensor
101  if (_sensorId != other._sensorId) {
102  return false;
103  }
104  double _col1, _col2, _row1, _row2;
105  for (size_t i = 0; i < this->pixelHits.size(); i++) {
106  _col1 = this->pixelHits[i]._col;
107  _row1 = this->pixelHits[i]._row;
108  for (size_t j = 0; j < other.pixelHits.size(); j++) {
109  _col2 = other.pixelHits[j]._col;
110  _row2 = other.pixelHits[j]._row;
111  // check if neighboring, that means distance of pixels is smaller than 1.5 pixels
112  if ((_col2 - _col1) * (_col2 - _col1) + (_row2 - _row1) * (_row2 - _row1) < 2.25) {
113  return true;
114  }
115  }
116  }
117  return false;
118  }
unsigned int i
Definition: P4_F32vec4.h:21
vector< pixelHit > pixelHits

◆ merge()

void pixelCluster::merge ( pixelCluster other)
inline

Definition at line 121 of file PndLmdAlignStructs.h.

References i, and pixelHits.

122  {
123  for (size_t i = 0; i < other.pixelHits.size(); i++) {
124  pixelHits.push_back(other.pixelHits[i]);
125  }
126  }
unsigned int i
Definition: P4_F32vec4.h:21
vector< pixelHit > pixelHits

◆ printCenter()

void pixelCluster::printCenter ( )
inline

Definition at line 173 of file PndLmdAlignStructs.h.

174  {
175  cout << "clusterCenter x:" << centerCol << ", y:" << centerRow << " on sensor " << _sensorId << ", contains " << pixelHits.size() << " pixels and is " << clusterSize
176  << " pixels in diameter."
177  << "\n";
178  }
vector< pixelHit > pixelHits

◆ printPixels()

void pixelCluster::printPixels ( )
inline

Definition at line 167 of file PndLmdAlignStructs.h.

References i.

168  {
169  for (size_t i = 0; i < pixelHits.size(); i++) {
170  cout << "pixelHit x:" << pixelHits[i]._col << ", y:" << pixelHits[i]._row << " on sensor " << pixelHits[i]._sensorId << "\n";
171  }
172  }
unsigned int i
Definition: P4_F32vec4.h:21
vector< pixelHit > pixelHits

Member Data Documentation

◆ _sensorId

int pixelCluster::_sensorId

Definition at line 56 of file PndLmdAlignStructs.h.

Referenced by isNeighbour(), and pixelCluster().

◆ centerCol

double pixelCluster::centerCol

Definition at line 57 of file PndLmdAlignStructs.h.

◆ centerRow

double pixelCluster::centerRow

Definition at line 57 of file PndLmdAlignStructs.h.

◆ clusterReady

bool pixelCluster::clusterReady

Definition at line 60 of file PndLmdAlignStructs.h.

◆ clusterSize

double pixelCluster::clusterSize

Definition at line 58 of file PndLmdAlignStructs.h.

◆ pixelHits

vector<pixelHit> pixelCluster::pixelHits

Definition at line 59 of file PndLmdAlignStructs.h.

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


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