source: trunk/examples/extended/analysis/N03Con/include/G4ConvergenceTester.hh @ 1337

Last change on this file since 1337 was 807, checked in by garnier, 16 years ago

update

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