Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4ConvergenceTester Class Reference

#include <G4ConvergenceTester.hh>

Public Member Functions

 G4ConvergenceTester ()
 
 ~G4ConvergenceTester ()
 
 G4ConvergenceTester (G4double)
 
void AddScore (G4double)
 
void ShowHistory ()
 
void ShowResult ()
 
G4double GetValueOfMinimizingFunction (std::vector< G4double > x)
 

Detailed Description

Definition at line 58 of file G4ConvergenceTester.hh.

Constructor & Destructor Documentation

◆ G4ConvergenceTester() [1/2]

G4ConvergenceTester::G4ConvergenceTester ( )

Definition at line 45 of file G4ConvergenceTester.cc.

46 : n(0), sum(0.), mean(0.), var(0.), sd(0.), r(0.), efficiency(0.),
47 r2eff(0.), r2int(0.), shift(0.), vov(0.), fom(0.), largest(0.),
48 largest_score_happened(0), mean_1(0.), var_1(0.), sd_1(0.), r_1(0.),
49 shift_1(0.), vov_1(0.), fom_1(0.), noBinOfHistory(16), slope(0.),
50 noBinOfPDF(10), minimizer(0), noPass(0), noTotal(8)
51{
52 nonzero_histories.clear();
53 largest_scores.clear();
54 largest_scores.push_back( 0.0 );
55
56 history_grid.resize( noBinOfHistory , 0 );
57 mean_history.resize( noBinOfHistory , 0.0 );
58 var_history.resize( noBinOfHistory , 0.0 );
59 sd_history.resize( noBinOfHistory , 0.0 );
60 r_history.resize( noBinOfHistory , 0.0 );
61 vov_history.resize( noBinOfHistory , 0.0 );
62 fom_history.resize( noBinOfHistory , 0.0 );
63 shift_history.resize( noBinOfHistory , 0.0 );
64 e_history.resize( noBinOfHistory , 0.0 );
65 r2eff_history.resize( noBinOfHistory , 0.0 );
66 r2int_history.resize( noBinOfHistory , 0.0 );
67
68 timer = new G4Timer();
69 timer->Start();
70 cpu_time.clear();
71 cpu_time.push_back( 0.0 );
72}
void Start()

◆ ~G4ConvergenceTester()

G4ConvergenceTester::~G4ConvergenceTester ( )

Definition at line 76 of file G4ConvergenceTester.cc.

77{
78 delete timer;
79}

◆ G4ConvergenceTester() [2/2]

G4ConvergenceTester::G4ConvergenceTester ( G4double  )

Member Function Documentation

◆ AddScore()

void G4ConvergenceTester::AddScore ( G4double  x)

Definition at line 83 of file G4ConvergenceTester.cc.

84{
85
86 //G4cout << x << G4endl;
87
88 timer->Stop();
89 cpu_time.push_back( timer->GetSystemElapsed() + timer->GetUserElapsed() );
90
91 if ( x == 0.0 )
92 {
93 }
94 else
95 {
96 nonzero_histories.insert( std::pair< G4int , G4double > ( n , x ) );
97 if ( x > largest_scores.back() )
98 {
99// Following serch should become faster if begin from bottom.
100 std::vector< G4double >::iterator it;
101 for ( it = largest_scores.begin() ; it != largest_scores.end() ; it++ )
102 {
103 if ( x > *it )
104 {
105 largest_scores.insert( it , x );
106 break;
107 }
108 }
109
110 if ( largest_scores.size() > 201 )
111 {
112 largest_scores.pop_back();
113 }
114 //G4cout << largest_scores.size() << " " << largest_scores.front() << " " << largest_scores.back() << G4endl;
115 }
116 sum += x;
117 }
118
119 n++;
120 return;
121}
void Stop()
G4double GetSystemElapsed() const
Definition: G4Timer.cc:119
G4double GetUserElapsed() const
Definition: G4Timer.cc:130

◆ GetValueOfMinimizingFunction()

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

Definition at line 73 of file G4ConvergenceTester.hh.

74 { return slope_fitting_function( x ); }

◆ ShowHistory()

void G4ConvergenceTester::ShowHistory ( )

Definition at line 377 of file G4ConvergenceTester.cc.

378{
379 G4cout << "i/" << noBinOfHistory << " till_ith mean var sd r vov fom shift e r2eff r2int" << G4endl;
380 for ( G4int i = 1 ; i <= noBinOfHistory ; i++ )
381 {
382 G4cout << i << " "
383 << history_grid [ i-1 ] << " "
384 << mean_history [ i-1 ] << " "
385 << var_history [ i-1 ] << " "
386 << sd_history [ i-1 ] << " "
387 << r_history [ i-1 ] << " "
388 << vov_history [ i-1 ] << " "
389 << fom_history [ i-1 ] << " "
390 << shift_history [ i-1 ] << " "
391 << e_history [ i-1 ] << " "
392 << r2eff_history [ i-1 ] << " "
393 << r2int_history [ i-1 ] << " "
394 << G4endl;
395 }
396}
int G4int
Definition: G4Types.hh:66
#define G4endl
Definition: G4ios.hh:52
G4DLLIMPORT std::ostream G4cout

◆ ShowResult()

void G4ConvergenceTester::ShowResult ( )

Definition at line 339 of file G4ConvergenceTester.cc.

340{
341 calStat();
342
343 G4cout << "EFFICIENCY = " << efficiency << G4endl;
344 G4cout << "MEAN = " << mean << G4endl;
345 G4cout << "VAR = " << var << G4endl;
346 G4cout << "SD = " << sd << G4endl;
347 G4cout << "R = "<< r << G4endl;
348 G4cout << "SHIFT = "<< shift << G4endl;
349 G4cout << "VOV = "<< vov << G4endl;
350 G4cout << "FOM = "<< fom << G4endl;
351
352 G4cout << "THE LARGEST SCORE = " << largest << " and it happend at " << largest_score_happened << "th event" << G4endl;
353 G4cout << "Affected Mean = " << mean_1 << " and its ratio to orignal is " << mean_1/mean << G4endl;
354 G4cout << "Affected VAR = " << var_1 << " and its ratio to orignal is " << var_1/var << G4endl;
355 G4cout << "Affected R = " << r_1 << " and its ratio to orignal is " << r_1/r << G4endl;
356 G4cout << "Affected SHIFT = " << shift_1 << " and its ratio to orignal is " << shift_1/shift << G4endl;
357 G4cout << "Affected FOM = " << fom_1 << " and its ratio to orignal is " << fom_1/fom << G4endl;
358
359 check_stat_history();
360
361// check SLOPE and output result
362 if ( slope >= 3 )
363 {
364 noPass++;
365 G4cout << "SLOPE is large enough" << G4endl;
366 }
367 else
368 {
369 G4cout << "SLOPE is not large enough" << G4endl;
370 }
371
372 G4cout << "This result passes " << noPass << " / "<< noTotal << " Convergence Test." << G4endl;
373 G4cout << G4endl;
374
375}

The documentation for this class was generated from the following files: