ECCE @ EIC Software
Reference for
ECCE @ EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
G4ConvergenceTester.hh
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file G4ConvergenceTester.hh
1
//
2
// ********************************************************************
3
// * License and Disclaimer *
4
// * *
5
// * The Geant4 software is copyright of the Copyright Holders of *
6
// * the Geant4 Collaboration. It is provided under the terms and *
7
// * conditions of the Geant4 Software License, included in the file *
8
// * LICENSE and available at http://cern.ch/geant4/license . These *
9
// * include a list of copyright holders. *
10
// * *
11
// * Neither the authors of this software system, nor their employing *
12
// * institutes,nor the agencies providing financial support for this *
13
// * work make any representation or warranty, express or implied, *
14
// * regarding this software system or assume any liability for its *
15
// * use. Please see the license in the file LICENSE and URL above *
16
// * for the full disclaimer and the limitation of liability. *
17
// * *
18
// * This code implementation is the result of the scientific and *
19
// * technical work of the GEANT4 collaboration. *
20
// * By using, copying, modifying or distributing the software (or *
21
// * any work based on the software) you agree to acknowledge its *
22
// * use in resulting scientific publications, and indicate your *
23
// * acceptance of all terms of the Geant4 Software license. *
24
// ********************************************************************
25
//
26
//
27
//
28
// Class description:
29
//
30
// Convergence Tests for Monte Carlo results.
31
//
32
// Reference
33
// MCNP(TM) -A General Monte Carlo N-Particle Transport Code
34
// Version 4B
35
// Judith F. Briesmeister, Editor
36
// LA-12625-M, Issued: March 1997, UC 705 and UC 700
37
// CHAPTER 2. GEOMETRY, DATA, PHYSICS, AND MATHEMATICS
38
// VI. ESTIMATION OF THE MONTE CARLO PRECISION
39
//
40
// Positives numbers are assumed for input values
41
42
// Author: Tatsumi Koi (SLAC/SCCS)
43
//
44
// --------------------------------------------------------------------
45
46
#ifndef G4ConvergenceTester
47
#define G4ConvergenceTester_h 1
48
49
#include "
G4SimplexDownhill.hh
"
50
51
#include "
G4Timer.hh
"
52
#include "
globals.hh
"
53
54
#include <map>
55
#include <vector>
56
57
class
G4ConvergenceTester
58
{
59
public
:
60
61
G4ConvergenceTester
(
G4String
theName=
"NONAME"
);
62
~G4ConvergenceTester
();
63
G4ConvergenceTester
(
G4double
);
64
65
public
:
66
67
void
AddScore
(
G4double
);
68
69
G4ConvergenceTester
&
operator+=
(
G4double
val)
70
{ this->
AddScore
(val);
return
*
this
; }
71
72
// default to G4cout but can redirected to another ostream
73
void
ShowHistory
(std::ostream& out = G4cout);
74
void
ShowResult
(std::ostream& out = G4cout);
75
76
inline
G4double
GetValueOfMinimizingFunction
( std::vector<G4double>
x
)
77
{
return
slope_fitting_function
( x ); }
78
79
private
:
80
81
void
calStat
();
82
// boolean value of “statsAreUpdated” is set to TRUE at end of calStat
83
// and set to FALSE at end of AddScore
84
// NOTE : A thread lock for Geant4-MT needs to be put in AddScore so calStat is not
85
// executed in one thread while AddScore is modifying/adding data
86
void
CheckIsUpdated
() {
if
(!
statsAreUpdated
) {
calStat
(); } }
87
88
public
:
89
// Public function to explicitly calculate statistics
90
void
ComputeStatistics
() {
calStat
(); }
91
92
// All “Get” functions check to make sure value is current before returning
93
G4double
GetMean
() {
CheckIsUpdated
();
return
mean
; }
94
G4double
GetStandardDeviation
() {
CheckIsUpdated
();
return
sd
; }
95
G4double
GetVariance
() {
CheckIsUpdated
();
return
var
; }
96
G4double
GetR
() {
CheckIsUpdated
();
return
r
; }
97
G4double
GetEfficiency
() {
CheckIsUpdated
();
return
efficiency
; }
98
G4double
GetR2eff
() {
CheckIsUpdated
();
return
r2eff
; }
99
G4double
GetR2int
() {
CheckIsUpdated
();
return
r2int
; }
100
G4double
GetShift
() {
CheckIsUpdated
();
return
shift
; }
101
G4double
GetVOV
() {
CheckIsUpdated
();
return
vov
; }
102
G4double
GetFOM
() {
CheckIsUpdated
();
return
fom
; }
103
104
private
:
105
void
calc_grid_point_of_history
();
106
void
calc_stat_history
();
107
void
check_stat_history
(std::ostream& out = G4cout);
108
G4double
calc_Pearson_r
(
G4int
, std::vector<G4double>,
109
std::vector<G4double> );
110
G4bool
is_monotonically_decrease
( std::vector<G4double> );
111
void
calc_slope_fit
( std::vector< G4double > );
112
G4double
slope_fitting_function
( std::vector< G4double > );
113
114
private
:
115
116
G4String
name
;
117
std::map< G4int , G4double >
nonzero_histories
;
118
// (ith-history , score value)
119
G4int
n
;
120
// number of history
121
G4double
sum
;
// sum of scores;
122
123
G4Timer
*
timer
;
124
std::vector<G4double>
cpu_time
;
125
126
G4double
mean
;
127
G4double
var
;
128
G4double
sd
;
129
G4double
r
;
// relative err sd/mean/sqrt(n)
130
G4double
efficiency
;
// rate of non zero score
131
G4double
r2eff
;
132
G4double
r2int
;
133
G4double
shift
;
134
G4double
vov
;
135
G4double
fom
;
136
137
G4double
largest
;
138
G4int
largest_score_happened
;
139
140
G4double
mean_1
;
141
G4double
var_1
;
142
G4double
sd_1
;
143
G4double
r_1
;
// relative err sd/mean/sqrt(n)
144
G4double
shift_1
;
145
G4double
vov_1
;
146
G4double
fom_1
;
147
148
G4int
noBinOfHistory
;
149
std::vector< G4int >
history_grid
;
150
std::vector< G4double >
mean_history
;
151
std::vector< G4double >
var_history
;
152
std::vector< G4double >
sd_history
;
153
std::vector< G4double >
r_history
;
154
std::vector< G4double >
vov_history
;
155
std::vector< G4double >
fom_history
;
156
std::vector< G4double >
shift_history
;
157
std::vector< G4double >
e_history
;
158
std::vector< G4double >
r2eff_history
;
159
std::vector< G4double >
r2int_history
;
160
161
G4double
slope
;
162
std::vector< G4double >
largest_scores
;
163
std::vector< G4double >
f_xi
;
164
std::vector< G4double >
f_yi
;
165
G4int
noBinOfPDF
;
166
G4SimplexDownhill<G4ConvergenceTester>
*
minimizer
;
167
168
G4int
noPass
;
169
G4int
noTotal
;
// Total number of tests
170
171
G4bool
statsAreUpdated
;
172
173
G4bool
showHistory
;
174
G4bool
calcSLOPE
;
175
};
176
#endif
177
geant4
tree
geant4-10.6-release
source
global
HEPNumerics
include
G4ConvergenceTester.hh
Built by
Jin Huang
. updated:
Wed Jun 29 2022 17:25:20
using
1.8.2 with
ECCE GitHub integration