Belle II Software  release-05-02-19
ClusterProjection.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Martin Ritter *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #ifndef PXD_ClusterProjection_H
12 #define PXD_ClusterProjection_H
13 
14 namespace Belle2 {
20  namespace PXD {
21 
29  class ClusterProjection {
30  public:
32  ClusterProjection(): m_pos(0), m_min(-1), m_max(0), m_minCharge(0),
33  m_maxCharge(0), m_minPos(0), m_maxPos(0), m_error(0), m_charge(0),
34  m_size(0) {}
35 
44  void add(unsigned int cell, float position, float charge);
46  void finalize()
47  {
48  m_pos /= m_charge;
49  m_size = m_max - m_min + 1;
50  }
51 
53  double getPos() const { return m_pos; }
55  double getError() const { return m_error; }
57  unsigned int getSize() const { return m_size; }
59  unsigned int getMinCell() const { return m_min; }
61  unsigned int getMaxCell() const { return m_max; }
63  double getCharge() const { return m_charge; }
65  double getMinCharge() const { return m_minCharge; }
67  double getMaxCharge() const { return m_maxCharge; }
69  double getCenterCharge() const { return m_charge - m_minCharge - m_maxCharge; }
71  double getMinPos() const { return m_minPos; }
73  double getMaxPos() const { return m_maxPos; }
74 
76  void setPos(double pos) { m_pos = pos; }
78  void setError(double error) { m_error = error; }
79 
80  private:
81 
83  double m_pos;
85  unsigned int m_min;
87  unsigned int m_max;
89  double m_minCharge;
91  double m_maxCharge;
93  double m_minPos;
95  double m_maxPos;
97  double m_error;
99  double m_charge;
101  unsigned int m_size;
102  };
103 
104  inline void ClusterProjection::add(unsigned int cell, float position, float charge)
105  {
106  //If the new cell is smaller than the last minimum cell than change that
107  if (cell < m_min) {
108  m_min = cell;
109  m_minCharge = charge;
110  m_minPos = position;
111  } else if (cell == m_min) {
112  //But if it is equal to the last known minimum cell sum up the charge
113  m_minCharge += charge;
114  }
115  //Same as above for maximum cell.
116  if (cell > m_max || m_max == 0) {
117  m_max = cell;
118  m_maxCharge = charge;
119  m_maxPos = position;
120  } else if (cell == m_max) {
121  m_maxCharge += charge;
122  }
123  //Add weighted positions for center of gravity
124  m_pos += charge * position;
125  m_charge += charge;
126  }
127 
128  } // PXD namespace
129 
131 } // Belle2 namespace
132 
133 #endif //PXD_ClusterProjection_H
Belle2::PXD::ClusterProjection::m_max
unsigned int m_max
Maximum row or column of the cluster.
Definition: ClusterProjection.h:95
Belle2::PXD::ClusterProjection::getMaxCell
unsigned int getMaxCell() const
Return the maximum cell part of the cluster.
Definition: ClusterProjection.h:69
Belle2::PXD::ClusterProjection::m_size
unsigned int m_size
Projected size of the cluster.
Definition: ClusterProjection.h:109
Belle2::PXD::ClusterProjection::getMinPos
double getMinPos() const
Return the position of the minimum cell of the cluster.
Definition: ClusterProjection.h:79
Belle2::PXD::ClusterProjection::getMinCharge
double getMinCharge() const
Return the charge in the minimum cell of the cluster.
Definition: ClusterProjection.h:73
Belle2::PXD::ClusterProjection::m_maxCharge
double m_maxCharge
Charge collected in the maximum row/column.
Definition: ClusterProjection.h:99
Belle2::PXD::ClusterProjection::getMaxCharge
double getMaxCharge() const
Return the charge in the maximum cell of the cluster.
Definition: ClusterProjection.h:75
Belle2::PXD::ClusterProjection::getMinCell
unsigned int getMinCell() const
Return the minimum cell part of the cluster.
Definition: ClusterProjection.h:67
Belle2::PXD::ClusterProjection::m_minCharge
double m_minCharge
Charge collected in the minimum row/column.
Definition: ClusterProjection.h:97
Belle2::PXD::ClusterProjection::setError
void setError(double error)
Set the error of the cluster.
Definition: ClusterProjection.h:86
Belle2::PXD::ClusterProjection::getSize
unsigned int getSize() const
Return the projected size of the cluster.
Definition: ClusterProjection.h:65
Belle2::PXD::ClusterProjection::getCenterCharge
double getCenterCharge() const
Return the center charge of the cluster, that is total charge minus minimum and maximum cell charge.
Definition: ClusterProjection.h:77
Belle2::PXD::ClusterProjection::add
void add(unsigned int cell, float position, float charge)
Add Pixel information to the projection.
Definition: ClusterProjection.h:112
Belle2::PXD::ClusterProjection::getPos
double getPos() const
Return the projected position of the cluster.
Definition: ClusterProjection.h:61
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::PXD::ClusterProjection::m_min
unsigned int m_min
Minimum row or column of the cluster.
Definition: ClusterProjection.h:93
Belle2::PXD::ClusterProjection::getMaxPos
double getMaxPos() const
Return the position of the maximum cell of the cluster.
Definition: ClusterProjection.h:81
Belle2::PXD::ClusterProjection::m_error
double m_error
Position error of the cluster.
Definition: ClusterProjection.h:105
Belle2::PXD::ClusterProjection::ClusterProjection
ClusterProjection()
Constructor.
Definition: ClusterProjection.h:40
Belle2::PXD::ClusterProjection::getError
double getError() const
Return the error of the cluster.
Definition: ClusterProjection.h:63
Belle2::PXD::ClusterProjection::m_maxPos
double m_maxPos
Position of the maximum row/column.
Definition: ClusterProjection.h:103
Belle2::PXD::ClusterProjection::finalize
void finalize()
Finish calculation of center of gravity and set correct cluster size.
Definition: ClusterProjection.h:54
Belle2::PXD::ClusterProjection::m_pos
double m_pos
Center of gravity of the cluster.
Definition: ClusterProjection.h:91
Belle2::PXD::ClusterProjection::setPos
void setPos(double pos)
Set the position of the cluster.
Definition: ClusterProjection.h:84
Belle2::PXD::ClusterProjection::getCharge
double getCharge() const
Return the total charge of the cluster.
Definition: ClusterProjection.h:71
Belle2::PXD::ClusterProjection::m_charge
double m_charge
Charge of the full cluster.
Definition: ClusterProjection.h:107
Belle2::PXD::ClusterProjection::m_minPos
double m_minPos
Position of the minimum row/column.
Definition: ClusterProjection.h:101