Belle II Software development
ClusterProjection.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11namespace Belle2 {
17 namespace PXD {
18
27 public:
30 m_maxCharge(0), m_minPos(0), m_maxPos(0), m_error(0), m_charge(0),
31 m_size(0) {}
32
41 void add(unsigned int cell, float position, float charge);
43 void finalize()
44 {
45 m_pos /= m_charge;
46 m_size = m_max - m_min + 1;
47 }
48
50 double getPos() const { return m_pos; }
52 double getError() const { return m_error; }
54 unsigned int getSize() const { return m_size; }
56 unsigned int getMinCell() const { return m_min; }
58 unsigned int getMaxCell() const { return m_max; }
60 double getCharge() const { return m_charge; }
62 double getMinCharge() const { return m_minCharge; }
64 double getMaxCharge() const { return m_maxCharge; }
66 double getCenterCharge() const { return m_charge - m_minCharge - m_maxCharge; }
68 double getMinPos() const { return m_minPos; }
70 double getMaxPos() const { return m_maxPos; }
71
73 void setPos(double pos) { m_pos = pos; }
75 void setError(double error) { m_error = error; }
76
77 private:
78
80 double m_pos;
82 unsigned int m_min;
84 unsigned int m_max;
90 double m_minPos;
92 double m_maxPos;
94 double m_error;
96 double m_charge;
98 unsigned int m_size;
99 };
100
101 inline void ClusterProjection::add(unsigned int cell, float position, float charge)
102 {
103 //If the new cell is smaller than the last minimum cell than change that
104 if (cell < m_min) {
105 m_min = cell;
106 m_minCharge = charge;
107 m_minPos = position;
108 } else if (cell == m_min) {
109 //But if it is equal to the last known minimum cell sum up the charge
110 m_minCharge += charge;
111 }
112 //Same as above for maximum cell.
113 if (cell > m_max || m_max == 0) {
114 m_max = cell;
115 m_maxCharge = charge;
116 m_maxPos = position;
117 } else if (cell == m_max) {
118 m_maxCharge += charge;
119 }
120 //Add weighted positions for center of gravity
121 m_pos += charge * position;
122 m_charge += charge;
123 }
124
125 } // PXD namespace
126
128} // Belle2 namespace
Helper struct to collect information about the 1D projection of a Pixel cluster.
double m_maxCharge
Charge collected in the maximum row/column.
double getMinPos() const
Return the position of the minimum cell of the cluster.
double m_pos
Center of gravity of the cluster.
void add(unsigned int cell, float position, float charge)
Add Pixel information to the projection.
double getMaxCharge() const
Return the charge in the maximum cell of the cluster.
void finalize()
Finish calculation of center of gravity and set correct cluster size.
unsigned int getMinCell() const
Return the minimum cell part of the cluster.
unsigned int m_min
Minimum row or column of the cluster.
double getCharge() const
Return the total charge of the cluster.
unsigned int getMaxCell() const
Return the maximum cell part of the cluster.
void setPos(double pos)
Set the position of the cluster.
double m_minPos
Position of the minimum row/column.
double getMinCharge() const
Return the charge in the minimum cell of the cluster.
unsigned int m_max
Maximum row or column of the cluster.
void setError(double error)
Set the error of the cluster.
double getError() const
Return the error of the cluster.
double m_minCharge
Charge collected in the minimum row/column.
double m_charge
Charge of the full cluster.
double m_error
Position error of the cluster.
double getMaxPos() const
Return the position of the maximum cell of the cluster.
double getPos() const
Return the projected position of the cluster.
double m_maxPos
Position of the maximum row/column.
unsigned int m_size
Projected size of the cluster.
double getCenterCharge() const
Return the center charge of the cluster, that is total charge minus minimum and maximum cell charge.
unsigned int getSize() const
Return the projected size of the cluster.
Abstract base class for different kinds of events.