Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
G4ConvergenceTester.hh
Go to the documentation of this file.
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// $Id$
28//
29// Class description:
30//
31// Convergence Tests for Monte Carlo results.
32//
33// Reference
34// MCNP(TM) -A General Monte Carlo N-Particle Transport Code
35// Version 4B
36// Judith F. Briesmeister, Editor
37// LA-12625-M, Issued: March 1997, UC 705 and UC 700
38// CHAPTER 2. GEOMETRY, DATA, PHYSICS, AND MATHEMATICS
39// VI. ESTIMATION OF THE MONTE CARLO PRECISION
40//
41// Positives numbers are assumed for input values
42
43// Author: Tatsumi Koi (SLAC/SCCS)
44//
45// --------------------------------------------------------------------
46
47#ifndef G4ConvergenceTester
48#define G4ConvergenceTester_h 1
49
50#include "G4SimplexDownhill.hh"
51
52#include "G4Timer.hh"
53#include "globals.hh"
54
55#include <map>
56#include <vector>
57
59{
60 public:
61
65
66 public:
67
68 void AddScore( G4double );
69
70 void ShowHistory();
71 void ShowResult();
72
73 inline G4double GetValueOfMinimizingFunction( std::vector<G4double> x )
74 { return slope_fitting_function( x ); }
75
76 private:
77
78 void calStat();
79
80 G4double GetMean() { return mean; }
81 G4double GetStandardDeviation() { return sd; }
82 G4double GetVariance() { return var; }
83 G4double GetR() { return r; }
84 G4double GetEfficiency() { return efficiency; }
85 G4double GetR2eff() { return r2eff; }
86 G4double GetR2int() { return r2int; }
87 G4double GetShift() { return shift; }
88 G4double GetVOV() { return vov; }
89 G4double GetFOM() { return fom; }
90
91 void calc_grid_point_of_history();
92 void calc_stat_history();
93 void check_stat_history();
94 G4double calc_Pearson_r( G4int, std::vector<G4double>,
95 std::vector<G4double> );
96 G4bool is_monotonically_decrease( std::vector<G4double> );
97 void calc_slope_fit( std::vector< G4double > );
98 G4double slope_fitting_function( std::vector< G4double > );
99
100 private:
101
102 std::map< G4int , G4double > nonzero_histories;
103 // (ith-history , score value)
104 G4int n;
105 // number of history
106 G4double sum; // sum of scores;
107
108 G4Timer* timer;
109 std::vector<G4double> cpu_time;
110
111 G4double mean;
112 G4double var;
113 G4double sd;
114 G4double r; // relative err sd/mean/sqrt(n)
115 G4double efficiency; // rate of non zero score
116 G4double r2eff;
117 G4double r2int;
118 G4double shift;
119 G4double vov;
120 G4double fom;
121
122 G4double largest;
123 G4int largest_score_happened;
124
125 G4double mean_1;
126 G4double var_1;
127 G4double sd_1;
128 G4double r_1; // relative err sd/mean/sqrt(n)
129 G4double shift_1;
130 G4double vov_1;
131 G4double fom_1;
132
133 G4int noBinOfHistory;
134 std::vector< G4int > history_grid;
135 std::vector< G4double > mean_history;
136 std::vector< G4double > var_history;
137 std::vector< G4double > sd_history;
138 std::vector< G4double > r_history;
139 std::vector< G4double > vov_history;
140 std::vector< G4double > fom_history;
141 std::vector< G4double > shift_history;
142 std::vector< G4double > e_history;
143 std::vector< G4double > r2eff_history;
144 std::vector< G4double > r2int_history;
145
146 G4double slope;
147 std::vector< G4double > largest_scores;
148 std::vector< G4double > f_xi;
149 std::vector< G4double > f_yi;
150 G4int noBinOfPDF;
152
153 G4int noPass;
154 G4int noTotal; // Total number of tests
155
156};
157#endif
158
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
bool G4bool
Definition: G4Types.hh:67
G4double GetValueOfMinimizingFunction(std::vector< G4double > x)
G4ConvergenceTester(G4double)