Belle II Software development
Statistic Class Reference

Public Member Functions

 __init__ (self, nTrueSig, nSig, nBg)
 
 nSig (self)
 
 nTrueSig (self)
 
 nBg (self)
 
 nTotal (self)
 
 purity (self)
 
 efficiency (self)
 
 purityError (self)
 
 efficiencyError (self)
 
 calcStandardDeviation (self, k, n)
 
 __str__ (self)
 
 __add__ (self, a)
 
 __radd__ (self, a)
 

Protected Attributes

int _nTrueSig = nTrueSig
 the number of true signal particles
 
int _nSig = nSig
 the number of reconstructed signal candidates
 
 _nBg = nBg
 the number of reconstructed background candidates
 

Detailed Description

This class provides the efficiency, purity and other quantities for a
given number of true signal candidates, signal candidates and background candidates

Definition at line 49 of file monitoring.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ ( self,
nTrueSig,
nSig,
nBg )
Create a new Statistic object
@param nTrueSig the number of true signal particles
@param nSig the number of reconstructed signal candidates
@param nBg the number of reconstructed background candidates

Definition at line 55 of file monitoring.py.

55 def __init__(self, nTrueSig, nSig, nBg):
56 """
57 Create a new Statistic object
58 @param nTrueSig the number of true signal particles
59 @param nSig the number of reconstructed signal candidates
60 @param nBg the number of reconstructed background candidates
61 """
62
63 self._nTrueSig = nTrueSig
64
65 self._nSig = nSig
66
67 self._nBg = nBg
68

Member Function Documentation

◆ __add__()

__add__ ( self,
a )
 Adds two Statistics objects and returns a new object. 

Definition at line 145 of file monitoring.py.

145 def __add__(self, a):
146 """ Adds two Statistics objects and returns a new object. """
147 # \cond false positive doxygen warning
148 return Statistic(self.nTrueSig, self.nSig + a.nSig, self.nBg + a.nBg)
149 # \endcond
150

◆ __radd__()

__radd__ ( self,
a )
Returns a new Statistic object if the current one is added to zero.
Necessary to apply sum-function to Statistic objects.

Definition at line 151 of file monitoring.py.

151 def __radd__(self, a):
152 """
153 Returns a new Statistic object if the current one is added to zero.
154 Necessary to apply sum-function to Statistic objects.
155 """
156 if a != 0:
157 return NotImplemented
158 # \cond false positive doxygen warning
159 return Statistic(self.nTrueSig, self.nSig, self.nBg)
160 # \endcond
161
162

◆ __str__()

__str__ ( self)
 Returns a string representation of a Statistic object. 

Definition at line 138 of file monitoring.py.

138 def __str__(self):
139 """ Returns a string representation of a Statistic object. """
140 o = f"nTrueSig {self.nTrueSig} nSig {self.nSig} nBg {self.nBg}\n"
141 o += f"Efficiency {self.efficiency:.3f} ({self.efficiencyError:.3f})\n"
142 o += f"Purity {self.purity:.3f} ({self.purityError:.3f})\n"
143 return o
144

◆ calcStandardDeviation()

calcStandardDeviation ( self,
k,
n )
 Helper method to calculate the standard deviation for efficiencies. 

Definition at line 129 of file monitoring.py.

129 def calcStandardDeviation(self, k, n):
130 """ Helper method to calculate the standard deviation for efficiencies. """
131 k = float(k)
132 n = float(n)
133 variance = (k + 1) * (k + 2) / ((n + 2) * (n + 3)) - (k + 1) ** 2 / ((n + 2) ** 2)
134 if variance <= 0:
135 return 0.0
136 return math.sqrt(variance)
137

◆ efficiency()

efficiency ( self)
 Returns the efficiency of the reconstructed signal candidates with respect to the number of true signal particles. 

Definition at line 101 of file monitoring.py.

101 def efficiency(self):
102 """ Returns the efficiency of the reconstructed signal candidates with respect to the number of true signal particles. """
103 if self._nSig == 0:
104 return 0.0
105 if self._nTrueSig == 0:
106 return float('inf')
107 return self._nSig / float(self._nTrueSig)
108

◆ efficiencyError()

efficiencyError ( self)
Returns the uncertainty of the efficiency.
For an efficiency eps = self._nSig/self._nTrueSig, this function calculates the
standard deviation according to http://arxiv.org/abs/physics/0701199 .

Definition at line 119 of file monitoring.py.

119 def efficiencyError(self):
120 """
121 Returns the uncertainty of the efficiency.
122 For an efficiency eps = self._nSig/self._nTrueSig, this function calculates the
123 standard deviation according to http://arxiv.org/abs/physics/0701199 .
124 """
125 if self._nTrueSig == 0:
126 return float('inf')
127 return self.calcStandardDeviation(self._nSig, self._nTrueSig)
128

◆ nBg()

nBg ( self)
 Returns the number of reconstructed background candidates. 

Definition at line 80 of file monitoring.py.

80 def nBg(self):
81 """ Returns the number of reconstructed background candidates. """
82 return self._nBg
83

◆ nSig()

nSig ( self)
 Returns the number of reconstructed signal candidates. 

Definition at line 70 of file monitoring.py.

70 def nSig(self):
71 """ Returns the number of reconstructed signal candidates. """
72 return self._nSig
73

◆ nTotal()

nTotal ( self)
 Returns total number of reconstructed candidates. 

Definition at line 85 of file monitoring.py.

85 def nTotal(self):
86 """ Returns total number of reconstructed candidates. """
87 return self._nSig + self._nBg
88

◆ nTrueSig()

nTrueSig ( self)
 Returns the number of reconstructed true signal candidates. 

Definition at line 75 of file monitoring.py.

75 def nTrueSig(self):
76 """ Returns the number of reconstructed true signal candidates. """
77 return self._nTrueSig
78

◆ purity()

purity ( self)
 Returns the purity of the reconstructed candidates. 

Definition at line 90 of file monitoring.py.

90 def purity(self):
91 """ Returns the purity of the reconstructed candidates. """
92 if self._nSig == 0:
93 return 0.0
94 # \cond false positive doxygen warning
95 if self.nTotal == 0:
96 return 0.0
97 return self._nSig / float(self.nTotal)
98 # \endcond
99

◆ purityError()

purityError ( self)
 Returns the uncertainty of the purity. 

Definition at line 110 of file monitoring.py.

110 def purityError(self):
111 """ Returns the uncertainty of the purity. """
112 # \cond false positive doxygen warning
113 if self.nTotal == 0:
114 return 0.0
115 return self.calcStandardDeviation(self._nSig, self.nTotal)
116 # \endcond
117

Member Data Documentation

◆ _nBg

_nBg = nBg
protected

the number of reconstructed background candidates

Definition at line 67 of file monitoring.py.

◆ _nSig

_nSig = nSig
protected

the number of reconstructed signal candidates

Definition at line 65 of file monitoring.py.

◆ _nTrueSig

_nTrueSig = nTrueSig
protected

the number of true signal particles

Definition at line 63 of file monitoring.py.


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