Belle II Software development
MCVXDPurityInfo.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#pragma once
9
10// stl:
11#include <array>
12#include <utility> // std::pair
13#include <numeric> // std::accumulate
14#include <sstream>
15#include <string>
16
17namespace Belle2 {
28 protected:
30 int m_iD;
31
35 std::array<unsigned int, 3> m_nTotalClusters;
36
38 std::array<unsigned int, 3> m_nFoundClusters;
39
40 public:
41
44 m_iD(-1),
45 m_nTotalClusters{0, 0, 0},
46 m_nFoundClusters{0, 0, 0} {}
47
59 unsigned int nPXDClustersTotal,
60 unsigned int nSVDUClustersTotal,
61 unsigned int nSVDVClustersTotal,
62 unsigned int nPXDClusters,
63 unsigned int nSVDUClusters,
64 unsigned int nSVDVClusters) :
65 m_iD(iD),
66 m_nTotalClusters({ {nPXDClustersTotal, nSVDUClustersTotal, nSVDVClustersTotal} }),
67 m_nFoundClusters({ {nPXDClusters, nSVDUClusters, nSVDVClusters} }) {}
68
75 MCVXDPurityInfo(int iD, std::array<unsigned int, 3> nClustersTotal, std::array<unsigned int, 3> nMCClusters) :
76 m_iD(iD), m_nTotalClusters(nClustersTotal), m_nFoundClusters(nMCClusters) { }
77
83 inline bool operator > (const MCVXDPurityInfo& b) const
84 {
85 return getPurity().second > b.getPurity().second;
86 }
87
88
94 inline bool operator < (const MCVXDPurityInfo& b) const
95 {
96 return getPurity().second < b.getPurity().second;
97 }
98
99
104 std::pair<int, float> getPurity() const
105 {
106 unsigned int nTotal = std::accumulate(m_nTotalClusters.begin() + 1, m_nTotalClusters.end(), 0) + 2 * m_nTotalClusters[0];
107 unsigned int nFound = std::accumulate(m_nFoundClusters.begin() + 1, m_nFoundClusters.end(), 0) + 2 * m_nFoundClusters[0];
108 return {m_iD, (nTotal == 0 ? 0.f : float(nFound) / float(nTotal)) };
109 }
110
111
113 std::pair<int, float> getPurityPXD() const
114 {
115 return {m_iD, (m_nTotalClusters[0] == 0 ? 0.f : float(m_nFoundClusters[0]) / float(m_nTotalClusters[0])) };
116 }
117
118
120 std::pair<int, float> getPuritySVD() const
121 {
122 unsigned int nTotal = std::accumulate(m_nTotalClusters.begin() + 1, m_nTotalClusters.end(), 0);
123 unsigned int nFound = std::accumulate(m_nFoundClusters.begin() + 1, m_nFoundClusters.end(), 0);
124 return {m_iD, (nTotal == 0 ? 0.f : float(nFound) / float(nTotal)) };
125 }
126
127
129 std::pair<int, float> getPuritySVDU() const
130 {
131 return {m_iD, (m_nTotalClusters[1] == 0 ? 0.f : float(m_nFoundClusters[1]) / float(m_nTotalClusters[1])) };
132 }
133
134
136 std::pair<int, float> getPuritySVDV() const
137 {
138 return {m_iD, (m_nTotalClusters[2] == 0 ? 0.f : float(m_nFoundClusters[2]) / float(m_nTotalClusters[2])) };
139 }
140
141
143 int getParticleID() const { return m_iD; }
144
145
147 unsigned int getNClustersTotal() const { return std::accumulate(m_nTotalClusters.begin(), m_nTotalClusters.end(), 0); }
148
149
151 unsigned int getNPXDClustersTotal() const { return m_nTotalClusters[0]; }
152
153
155 unsigned int getNSVDUClustersTotal() const { return m_nTotalClusters[1]; }
156
157
159 unsigned int getNSVDVClustersTotal() const { return m_nTotalClusters[2]; }
160
161
163 unsigned int getNClustersFound() const { return std::accumulate(m_nFoundClusters.begin(), m_nFoundClusters.end(), 0); }
164
165
167 unsigned int getNPXDClusters() const { return m_nFoundClusters[0]; }
168
169
171 unsigned int getNSVDUClusters() const { return m_nFoundClusters[1]; }
172
173
175 unsigned int getNSVDVClusters() const { return m_nFoundClusters[2]; }
176
177
179 unsigned int getNDFTotal() const { return std::accumulate(m_nTotalClusters.begin() + 1, m_nTotalClusters.end(), 0) + 2 * m_nTotalClusters[0]; }
180
181
183 unsigned int getNDFFound() const { return std::accumulate(m_nFoundClusters.begin() + 1, m_nFoundClusters.end(), 0) + 2 * m_nFoundClusters[0]; }
184
185
187 unsigned int getNDFPXDTotal() const { return 2 * m_nTotalClusters[0]; }
188
189
191 unsigned int getNDFPXDFound() const { return 2 * m_nFoundClusters[0]; }
192
193
195 unsigned int getNDFSVDTotal() const { return std::accumulate(m_nTotalClusters.begin() + 1, m_nTotalClusters.end(), 0); }
196
197
199 unsigned int getNDFSVDFound() const { return std::accumulate(m_nFoundClusters.begin() + 1, m_nFoundClusters.end(), 0); }
200
201
203 unsigned int getNDFSVDUTotal() const { return getNSVDUClustersTotal(); }
204
205
207 unsigned int getNDFSVDVTotal() const { return getNSVDVClustersTotal(); }
208
209
211 unsigned int getNDFSVDUFound() const { return getNSVDUClusters(); }
212
213
215 unsigned int getNDFSVDVFound() const { return getNSVDVClusters(); }
216
217
219 std::string dumpToString() const
220 {
221 std::stringstream s;
222 s << "iD: " << m_iD << "\n";
223 for (size_t i = 0; i < m_nTotalClusters.size(); ++i) {
224 s << "totalClusters[" << i << "]: " << m_nTotalClusters[i] << ", foundClusters[" << i << "]: " << m_nFoundClusters[i] << "\n";
225 }
226 return s.str();
227 }
228 };
230}
The MC VXD Purity info container class.
unsigned int getNSVDVClusters() const
getter - returns number of v-type SVDClustes found to this iD
MCVXDPurityInfo()
empty constructor
unsigned int getNDFSVDTotal() const
getter - returns number of degrees of freedom for SVD Clusters in TC total
unsigned int getNDFFound() const
getter - returns number of degrees of freedom for all Clusters in TC found
unsigned int getNPXDClusters() const
getter - returns number of PXDClusters found to this iD
unsigned int getNSVDUClustersTotal() const
getter - returns total number of u-type SVDClustes in the TrackCandidate
unsigned int getNDFSVDVFound() const
getter - returns number of degrees of freedom for v-type SVDClustes found to this iD
std::array< unsigned int, 3 > m_nFoundClusters
stores the number for each ClusterType, PXD in [0], SVD-U in [1], and SVD-V in [2]
std::array< unsigned int, 3 > m_nTotalClusters
stores the number of clusters the TrackCandidate container had.
int m_iD
stores the particleID
std::pair< int, float > getPurity() const
getter - returns overal purity (.second) for this particleID (.first).
unsigned int getNSVDVClustersTotal() const
getter - returns total number of v-type SVDClustes in the TrackCandidate
unsigned int getNClustersFound() const
returns number of clusters the trackCandidate had assigned to this iD
std::pair< int, float > getPuritySVD() const
getter - returns purity for SVDClusters (.second) for this particleID (.first)
unsigned int getNClustersTotal() const
returns total number of clusters the trackCandidate had
unsigned int getNDFTotal() const
getter - returns number of degrees of freedom for all Clusters in TC total
MCVXDPurityInfo(int iD, std::array< unsigned int, 3 > nClustersTotal, std::array< unsigned int, 3 > nMCClusters)
constructor
unsigned int getNDFSVDUFound() const
getter - returns number of degrees of freedom for u-type SVDClustes found to this iD
bool operator>(const MCVXDPurityInfo &b) const
operator for sorting.
std::pair< int, float > getPuritySVDU() const
getter - returns purity for SVDClusters of u-type (.second) for this particleID (....
std::pair< int, float > getPurityPXD() const
getter - returns purity for PXDClusters (.second) for this particleID (.first)
unsigned int getNDFPXDTotal() const
getter - returns number of degrees of freedom for PXD Clusters in TC total
MCVXDPurityInfo(int iD, unsigned int nPXDClustersTotal, unsigned int nSVDUClustersTotal, unsigned int nSVDVClustersTotal, unsigned int nPXDClusters, unsigned int nSVDUClusters, unsigned int nSVDVClusters)
constructor parameters: iD, the particleID nPXDClustersTotal, the number of PXDClusters the TrackCand...
unsigned int getNPXDClustersTotal() const
getter - returns total number of PXDClusters in the TrackCandidate
unsigned int getNDFPXDFound() const
getter - returns number of degrees of freedom for PXD Clusters in TC found
unsigned int getNSVDUClusters() const
getter - returns number of u-type SVDClustes found to this iD
int getParticleID() const
getter - returns the ID of the particle, if value is -1 no particle has been able to be found for it
unsigned int getNDFSVDFound() const
getter - returns number of degrees of freedom for SVD Clusters in TC found
unsigned int getNDFSVDVTotal() const
getter - returns number of degrees of freedom for v-type SVDClustes in the TrackCandidate
std::string dumpToString() const
dump the contents to a string (for easier debugging)
bool operator<(const MCVXDPurityInfo &b) const
operator for sorting.
std::pair< int, float > getPuritySVDV() const
getter - returns purity for SVDClusters of v-type (.second) for this particleID (....
unsigned int getNDFSVDUTotal() const
getter - returns number of degrees of freedom for u-type SVDClustes in the TrackCandidate
Abstract base class for different kinds of events.