Belle II Software  release-05-01-25
MCVXDPurityInfo.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2010 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Jakob Lettenbichler *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 // stl:
13 #include <array>
14 #include <utility> // std::pair
15 #include <numeric> // std::accumulate
16 #include <sstream>
17 #include <string>
18 
19 namespace Belle2 {
29  class MCVXDPurityInfo {
30  protected:
32  int m_iD;
33 
37  std::array<unsigned int, 3> m_nTotalClusters;
38 
40  std::array<unsigned int, 3> m_nFoundClusters;
41 
42  public:
43 
46  m_iD(-1),
47  m_nTotalClusters( { {0, 0, 0} }),
48  m_nFoundClusters({ {0, 0, 0} }) {}
49 
60  MCVXDPurityInfo(int iD,
61  unsigned int nPXDClustersTotal,
62  unsigned int nSVDUClustersTotal,
63  unsigned int nSVDVClustersTotal,
64  unsigned int nPXDClusters,
65  unsigned int nSVDUClusters,
66  unsigned int nSVDVClusters) :
67  m_iD(iD),
68  m_nTotalClusters( { {nPXDClustersTotal, nSVDUClustersTotal, nSVDVClustersTotal} }),
69  m_nFoundClusters({ {nPXDClusters, nSVDUClusters, nSVDVClusters} }) {}
70 
77  MCVXDPurityInfo(int iD, std::array<unsigned int, 3> nClustersTotal, std::array<unsigned int, 3> nMCClusters) :
78  m_iD(iD), m_nTotalClusters(nClustersTotal), m_nFoundClusters(nMCClusters) { }
79 
85  inline bool operator > (const MCVXDPurityInfo& b) const
86  {
87  return getPurity().second > b.getPurity().second;
88  }
89 
90 
96  inline bool operator < (const MCVXDPurityInfo& b) const
97  {
98  return getPurity().second < b.getPurity().second;
99  }
100 
101 
106  std::pair<int, float> getPurity() const
107  {
108  unsigned int nTotal = std::accumulate(m_nTotalClusters.begin() + 1, m_nTotalClusters.end(), 0) + 2 * m_nTotalClusters[0];
109  unsigned int nFound = std::accumulate(m_nFoundClusters.begin() + 1, m_nFoundClusters.end(), 0) + 2 * m_nFoundClusters[0];
110  return {m_iD, (nTotal == 0 ? 0.f : float(nFound) / float(nTotal)) };
111  }
112 
113 
115  std::pair<int, float> getPurityPXD() const
116  {
117  return {m_iD, (m_nTotalClusters[0] == 0 ? 0.f : float(m_nFoundClusters[0]) / float(m_nTotalClusters[0])) };
118  }
119 
120 
122  std::pair<int, float> getPuritySVD() const
123  {
124  unsigned int nTotal = std::accumulate(m_nTotalClusters.begin() + 1, m_nTotalClusters.end(), 0);
125  unsigned int nFound = std::accumulate(m_nFoundClusters.begin() + 1, m_nFoundClusters.end(), 0);
126  return {m_iD, (nTotal == 0 ? 0.f : float(nFound) / float(nTotal)) };
127  }
128 
129 
131  std::pair<int, float> getPuritySVDU() const
132  {
133  return {m_iD, (m_nTotalClusters[1] == 0 ? 0.f : float(m_nFoundClusters[1]) / float(m_nTotalClusters[1])) };
134  }
135 
136 
138  std::pair<int, float> getPuritySVDV() const
139  {
140  return {m_iD, (m_nTotalClusters[2] == 0 ? 0.f : float(m_nFoundClusters[2]) / float(m_nTotalClusters[2])) };
141  }
142 
143 
145  int getParticleID() const { return m_iD; }
146 
147 
149  unsigned int getNClustersTotal() const { return std::accumulate(m_nTotalClusters.begin(), m_nTotalClusters.end(), 0); }
150 
151 
153  unsigned int getNPXDClustersTotal() const { return m_nTotalClusters[0]; }
154 
155 
157  unsigned int getNSVDUClustersTotal() const { return m_nTotalClusters[1]; }
158 
159 
161  unsigned int getNSVDVClustersTotal() const { return m_nTotalClusters[2]; }
162 
163 
165  unsigned int getNClustersFound() const { return std::accumulate(m_nFoundClusters.begin(), m_nFoundClusters.end(), 0); }
166 
167 
169  unsigned int getNPXDClusters() const { return m_nFoundClusters[0]; }
170 
171 
173  unsigned int getNSVDUClusters() const { return m_nFoundClusters[1]; }
174 
175 
177  unsigned int getNSVDVClusters() const { return m_nFoundClusters[2]; }
178 
179 
181  unsigned int getNDFTotal() const { return std::accumulate(m_nTotalClusters.begin() + 1, m_nTotalClusters.end(), 0) + 2 * m_nTotalClusters[0]; }
182 
183 
185  unsigned int getNDFFound() const { return std::accumulate(m_nFoundClusters.begin() + 1, m_nFoundClusters.end(), 0) + 2 * m_nFoundClusters[0]; }
186 
187 
189  unsigned int getNDFPXDTotal() const { return 2 * m_nTotalClusters[0]; }
190 
191 
193  unsigned int getNDFPXDFound() const { return 2 * m_nFoundClusters[0]; }
194 
195 
197  unsigned int getNDFSVDTotal() const { return std::accumulate(m_nTotalClusters.begin() + 1, m_nTotalClusters.end(), 0); }
198 
199 
201  unsigned int getNDFSVDFound() const { return std::accumulate(m_nFoundClusters.begin() + 1, m_nFoundClusters.end(), 0); }
202 
203 
205  unsigned int getNDFSVDUTotal() const { return getNSVDUClustersTotal(); }
206 
207 
209  unsigned int getNDFSVDVTotal() const { return getNSVDVClustersTotal(); }
210 
211 
213  unsigned int getNDFSVDUFound() const { return getNSVDUClusters(); }
214 
215 
217  unsigned int getNDFSVDVFound() const { return getNSVDVClusters(); }
218 
219 
221  std::string dumpToString() const
222  {
223  std::stringstream s;
224  s << "iD: " << m_iD << "\n";
225  for (size_t i = 0; i < m_nTotalClusters.size(); ++i) {
226  s << "totalClusters[" << i << "]: " << m_nTotalClusters[i] << ", foundClusters[" << i << "]: " << m_nFoundClusters[i] << "\n";
227  }
228  return s.str();
229  }
230  };
232 }
Belle2::MCVXDPurityInfo::getPuritySVDU
std::pair< int, float > getPuritySVDU() const
getter - returns purity for SVDClusters of u-type (.second) for this particleID (....
Definition: MCVXDPurityInfo.h:139
Belle2::MCVXDPurityInfo::getPuritySVD
std::pair< int, float > getPuritySVD() const
getter - returns purity for SVDClusters (.second) for this particleID (.first)
Definition: MCVXDPurityInfo.h:130
Belle2::MCVXDPurityInfo::m_nFoundClusters
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]
Definition: MCVXDPurityInfo.h:48
Belle2::MCVXDPurityInfo::getNSVDVClusters
unsigned int getNSVDVClusters() const
getter - returns number of v-type SVDClustes found to this iD
Definition: MCVXDPurityInfo.h:185
Belle2::MCVXDPurityInfo::getNDFSVDVFound
unsigned int getNDFSVDVFound() const
getter - returns number of degrees of freedom for v-type SVDClustes found to this iD
Definition: MCVXDPurityInfo.h:225
Belle2::MCVXDPurityInfo::getNDFPXDFound
unsigned int getNDFPXDFound() const
getter - returns number of degrees of freedom for PXD Clusters in TC found
Definition: MCVXDPurityInfo.h:201
Belle2::MCVXDPurityInfo::getNDFSVDUFound
unsigned int getNDFSVDUFound() const
getter - returns number of degrees of freedom for u-type SVDClustes found to this iD
Definition: MCVXDPurityInfo.h:221
Belle2::MCVXDPurityInfo::m_iD
int m_iD
stores the particleID
Definition: MCVXDPurityInfo.h:40
Belle2::MCVXDPurityInfo::operator<
bool operator<(const MCVXDPurityInfo &b) const
operator for sorting.
Definition: MCVXDPurityInfo.h:104
Belle2::MCVXDPurityInfo
The MC VXD Purity info container class.
Definition: MCVXDPurityInfo.h:37
Belle2::MCVXDPurityInfo::m_nTotalClusters
std::array< unsigned int, 3 > m_nTotalClusters
stores the number of clusters the TrackCandidate container had.
Definition: MCVXDPurityInfo.h:45
Belle2::MCVXDPurityInfo::getPurityPXD
std::pair< int, float > getPurityPXD() const
getter - returns purity for PXDClusters (.second) for this particleID (.first)
Definition: MCVXDPurityInfo.h:123
Belle2::MCVXDPurityInfo::getNClustersFound
unsigned int getNClustersFound() const
returns number of clusters the trackCandidate had assigned to this iD
Definition: MCVXDPurityInfo.h:173
Belle2::MCVXDPurityInfo::getPurity
std::pair< int, float > getPurity() const
getter - returns overal purity (.second) for this particleID (.first).
Definition: MCVXDPurityInfo.h:114
Belle2::MCVXDPurityInfo::getNClustersTotal
unsigned int getNClustersTotal() const
returns total number of clusters the trackCandidate had
Definition: MCVXDPurityInfo.h:157
Belle2::MCVXDPurityInfo::getNDFSVDTotal
unsigned int getNDFSVDTotal() const
getter - returns number of degrees of freedom for SVD Clusters in TC total
Definition: MCVXDPurityInfo.h:205
Belle2::MCVXDPurityInfo::getNSVDUClustersTotal
unsigned int getNSVDUClustersTotal() const
getter - returns total number of u-type SVDClustes in the TrackCandidate
Definition: MCVXDPurityInfo.h:165
Belle2::MCVXDPurityInfo::getNDFSVDVTotal
unsigned int getNDFSVDVTotal() const
getter - returns number of degrees of freedom for v-type SVDClustes in the TrackCandidate
Definition: MCVXDPurityInfo.h:217
Belle2::MCVXDPurityInfo::getNSVDUClusters
unsigned int getNSVDUClusters() const
getter - returns number of u-type SVDClustes found to this iD
Definition: MCVXDPurityInfo.h:181
Belle2::MCVXDPurityInfo::getNDFPXDTotal
unsigned int getNDFPXDTotal() const
getter - returns number of degrees of freedom for PXD Clusters in TC total
Definition: MCVXDPurityInfo.h:197
Belle2::MCVXDPurityInfo::getNSVDVClustersTotal
unsigned int getNSVDVClustersTotal() const
getter - returns total number of v-type SVDClustes in the TrackCandidate
Definition: MCVXDPurityInfo.h:169
Belle2::MCVXDPurityInfo::operator>
bool operator>(const MCVXDPurityInfo &b) const
operator for sorting.
Definition: MCVXDPurityInfo.h:93
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::MCVXDPurityInfo::getNPXDClustersTotal
unsigned int getNPXDClustersTotal() const
getter - returns total number of PXDClusters in the TrackCandidate
Definition: MCVXDPurityInfo.h:161
Belle2::MCVXDPurityInfo::dumpToString
std::string dumpToString() const
dump the contents to a string (for easier debugging)
Definition: MCVXDPurityInfo.h:229
Belle2::MCVXDPurityInfo::getPuritySVDV
std::pair< int, float > getPuritySVDV() const
getter - returns purity for SVDClusters of v-type (.second) for this particleID (....
Definition: MCVXDPurityInfo.h:146
Belle2::MCVXDPurityInfo::getNDFSVDUTotal
unsigned int getNDFSVDUTotal() const
getter - returns number of degrees of freedom for u-type SVDClustes in the TrackCandidate
Definition: MCVXDPurityInfo.h:213
Belle2::MCVXDPurityInfo::getNDFSVDFound
unsigned int getNDFSVDFound() const
getter - returns number of degrees of freedom for SVD Clusters in TC found
Definition: MCVXDPurityInfo.h:209
Belle2::MCVXDPurityInfo::getNDFFound
unsigned int getNDFFound() const
getter - returns number of degrees of freedom for all Clusters in TC found
Definition: MCVXDPurityInfo.h:193
Belle2::MCVXDPurityInfo::getNDFTotal
unsigned int getNDFTotal() const
getter - returns number of degrees of freedom for all Clusters in TC total
Definition: MCVXDPurityInfo.h:189
Belle2::MCVXDPurityInfo::getParticleID
int getParticleID() const
getter - returns the ID of the particle, if value is -1 no particle has been able to be found for it
Definition: MCVXDPurityInfo.h:153
Belle2::MCVXDPurityInfo::MCVXDPurityInfo
MCVXDPurityInfo()
empty constructor
Definition: MCVXDPurityInfo.h:53
Belle2::MCVXDPurityInfo::getNPXDClusters
unsigned int getNPXDClusters() const
getter - returns number of PXDClusters found to this iD
Definition: MCVXDPurityInfo.h:177