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