G4ConvergenceTester Class Reference

#include <G4ConvergenceTester.hh>


Public Member Functions

 G4ConvergenceTester ()
 ~G4ConvergenceTester ()
 G4ConvergenceTester (G4double)
void AddScore (G4double)
void ShowHistory (std::ostream &out=G4cout)
void ShowResult (std::ostream &out=G4cout)
G4double GetValueOfMinimizingFunction (std::vector< G4double > x)
void ComputeStatistics ()
G4double GetMean ()
G4double GetStandardDeviation ()
G4double GetVariance ()
G4double GetR ()
G4double GetEfficiency ()
G4double GetR2eff ()
G4double GetR2int ()
G4double GetShift ()
G4double GetVOV ()
G4double GetFOM ()


Detailed Description

Definition at line 58 of file G4ConvergenceTester.hh.


Constructor & Destructor Documentation

G4ConvergenceTester::G4ConvergenceTester (  ) 

Definition at line 45 of file G4ConvergenceTester.cc.

References G4Timer::Start().

00046  : n(0), sum(0.), mean(0.), var(0.), sd(0.), r(0.), efficiency(0.),
00047    r2eff(0.), r2int(0.), shift(0.), vov(0.), fom(0.), largest(0.),
00048    largest_score_happened(0), mean_1(0.), var_1(0.), sd_1(0.), r_1(0.),
00049    shift_1(0.), vov_1(0.), fom_1(0.), noBinOfHistory(16), slope(0.),
00050    noBinOfPDF(10), minimizer(0), noPass(0), noTotal(8), statsAreUpdated(true)
00051 {
00052    nonzero_histories.clear();
00053    largest_scores.clear();
00054    largest_scores.push_back( 0.0 );
00055 
00056    history_grid.resize( noBinOfHistory , 0 );
00057    mean_history.resize( noBinOfHistory , 0.0 );
00058    var_history.resize( noBinOfHistory , 0.0 );
00059    sd_history.resize( noBinOfHistory , 0.0 );
00060    r_history.resize( noBinOfHistory , 0.0 );
00061    vov_history.resize( noBinOfHistory , 0.0 );
00062    fom_history.resize( noBinOfHistory , 0.0 );
00063    shift_history.resize( noBinOfHistory , 0.0 );
00064    e_history.resize( noBinOfHistory , 0.0 );
00065    r2eff_history.resize( noBinOfHistory , 0.0 );
00066    r2int_history.resize( noBinOfHistory , 0.0 );
00067 
00068    timer = new G4Timer();
00069    timer->Start();
00070    cpu_time.clear();
00071    cpu_time.push_back( 0.0 );
00072 }

G4ConvergenceTester::~G4ConvergenceTester (  ) 

Definition at line 76 of file G4ConvergenceTester.cc.

00077 {
00078    delete timer;
00079 }

G4ConvergenceTester::G4ConvergenceTester ( G4double   ) 


Member Function Documentation

void G4ConvergenceTester::AddScore ( G4double   ) 

Definition at line 83 of file G4ConvergenceTester.cc.

References G4Timer::GetSystemElapsed(), G4Timer::GetUserElapsed(), and G4Timer::Stop().

00084 { 
00085 
00086    //G4cout << x << G4endl;
00087 
00088    timer->Stop();
00089    cpu_time.push_back( timer->GetSystemElapsed() + timer->GetUserElapsed() );
00090 
00091    if ( x == 0.0 ) 
00092    { 
00093    }
00094    else
00095    {
00096        nonzero_histories.insert( std::pair< G4int , G4double > ( n , x ) );
00097        if ( x > largest_scores.back() )  
00098        { 
00099 //        Following serch  should become faster if begin from bottom.
00100           std::vector< G4double >::iterator it; 
00101           for ( it = largest_scores.begin() ; it != largest_scores.end() ; it++ )
00102           { 
00103              if ( x > *it ) 
00104              { 
00105                 largest_scores.insert( it , x );
00106                 break;
00107              }
00108           }
00109 
00110           if ( largest_scores.size() > 201 )
00111           {
00112              largest_scores.pop_back();
00113           } 
00114           //G4cout << largest_scores.size() << " " << largest_scores.front() << " " << largest_scores.back() << G4endl;
00115        }
00116        sum += x; 
00117    }
00118 
00119     // Data has been added so statistics have not been updated to new values
00120    statsAreUpdated = false;
00121    n++;
00122    return; 
00123 }

void G4ConvergenceTester::ComputeStatistics (  )  [inline]

Definition at line 88 of file G4ConvergenceTester.hh.

00088 { calStat(); }

G4double G4ConvergenceTester::GetEfficiency (  )  [inline]

Definition at line 95 of file G4ConvergenceTester.hh.

00095 { CheckIsUpdated(); return efficiency; }

G4double G4ConvergenceTester::GetFOM (  )  [inline]

Definition at line 100 of file G4ConvergenceTester.hh.

00100 { CheckIsUpdated(); return fom; }

G4double G4ConvergenceTester::GetMean (  )  [inline]

Definition at line 91 of file G4ConvergenceTester.hh.

00091 { CheckIsUpdated(); return mean; }

G4double G4ConvergenceTester::GetR (  )  [inline]

Definition at line 94 of file G4ConvergenceTester.hh.

00094 { CheckIsUpdated(); return r; }

G4double G4ConvergenceTester::GetR2eff (  )  [inline]

Definition at line 96 of file G4ConvergenceTester.hh.

00096 { CheckIsUpdated(); return r2eff; }

G4double G4ConvergenceTester::GetR2int (  )  [inline]

Definition at line 97 of file G4ConvergenceTester.hh.

00097 { CheckIsUpdated(); return r2int; }

G4double G4ConvergenceTester::GetShift (  )  [inline]

Definition at line 98 of file G4ConvergenceTester.hh.

00098 { CheckIsUpdated(); return shift; }

G4double G4ConvergenceTester::GetStandardDeviation (  )  [inline]

Definition at line 92 of file G4ConvergenceTester.hh.

00092 { CheckIsUpdated(); return sd; }

G4double G4ConvergenceTester::GetValueOfMinimizingFunction ( std::vector< G4double x  )  [inline]

Definition at line 74 of file G4ConvergenceTester.hh.

00075              { return slope_fitting_function( x ); }

G4double G4ConvergenceTester::GetVariance (  )  [inline]

Definition at line 93 of file G4ConvergenceTester.hh.

00093 { CheckIsUpdated(); return var; }

G4double G4ConvergenceTester::GetVOV (  )  [inline]

Definition at line 99 of file G4ConvergenceTester.hh.

00099 { CheckIsUpdated(); return vov; }

void G4ConvergenceTester::ShowHistory ( std::ostream &  out = G4cout  ) 

Definition at line 385 of file G4ConvergenceTester.cc.

References G4endl.

00386 {
00387    out << "i/" << noBinOfHistory << " till_ith  mean  var  sd  r  vov  fom  shift  e  r2eff  r2int" << G4endl;
00388    for ( G4int i = 1 ; i <=  noBinOfHistory  ; i++ )
00389    {
00390       out << i << " " 
00391              << history_grid [ i-1 ] << " "
00392              << mean_history [ i-1 ] << " "  
00393              << var_history [ i-1 ] << " "  
00394              << sd_history [ i-1 ] << " "  
00395              << r_history [ i-1 ] << " "  
00396              << vov_history [ i-1 ] << " "  
00397              << fom_history [ i-1 ] << " " 
00398              << shift_history [ i-1 ] << " "  
00399              << e_history [ i-1 ] << " " 
00400              << r2eff_history [ i-1 ] << " " 
00401              << r2int_history [ i-1 ] << " " 
00402              << G4endl;
00403    }
00404 }

void G4ConvergenceTester::ShowResult ( std::ostream &  out = G4cout  ) 

Definition at line 345 of file G4ConvergenceTester.cc.

References G4endl.

00346 {
00347     // if data has been added since the last computation of the statistical values (not statsAreUpdated)
00348     // call calStat to recompute the statistical values
00349    if(!statsAreUpdated) { calStat(); }
00350 
00351    out << "EFFICIENCY = " << efficiency << G4endl;
00352    out << "MEAN = " << mean << G4endl;
00353    out << "VAR = " << var << G4endl;
00354    out << "SD = " << sd << G4endl;
00355    out << "R = "<< r << G4endl;
00356    out << "SHIFT = "<< shift << G4endl;
00357    out << "VOV = "<< vov << G4endl;
00358    out << "FOM = "<< fom << G4endl;
00359 
00360    out << "THE LARGEST SCORE = " << largest << " and it happend at " << largest_score_happened << "th event" << G4endl;
00361    out << "Affected Mean = " << mean_1 << " and its ratio to orignal is " << mean_1/mean << G4endl;
00362    out << "Affected VAR = " << var_1 << " and its ratio to orignal is " << var_1/var << G4endl;
00363    out << "Affected R = " << r_1 << " and its ratio to orignal is " << r_1/r << G4endl;
00364    out << "Affected SHIFT = " << shift_1 << " and its ratio to orignal is " << shift_1/shift << G4endl;
00365    out << "Affected FOM = " << fom_1 << " and its ratio to orignal is " << fom_1/fom << G4endl;
00366 
00367    check_stat_history(out);
00368 
00369 // check SLOPE and output result
00370    if ( slope >= 3 )
00371    {    
00372       noPass++;
00373       out << "SLOPE is large enough" << G4endl; 
00374    }
00375    else
00376    {
00377       out << "SLOPE is not large enough" << G4endl; 
00378    }
00379 
00380    out << "This result passes " << noPass << " / "<< noTotal << " Convergence Test." << G4endl; 
00381    out << G4endl;
00382 
00383 }


The documentation for this class was generated from the following files:
Generated on Mon May 27 17:51:42 2013 for Geant4 by  doxygen 1.4.7