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

G4TrialsCounter is a class to keep statistics of the number of trials, including the maximum and how many times it was reached. More...

#include <G4TrialsCounter.hh>

Public Member Functions

 G4TrialsCounter (const G4String &nameStats, const G4String &description, G4bool printOnExit=false)
 ~G4TrialsCounter ()
void AccumulateCounts (G4int noTrials)
void ClearCounts ()
G4int ReturnTotals (G4int &calls, G4int &maxTrials, G4int &numMaxT)
void PrintStatistics ()

Detailed Description

G4TrialsCounter is a class to keep statistics of the number of trials, including the maximum and how many times it was reached.

Definition at line 46 of file G4TrialsCounter.hh.

Constructor & Destructor Documentation

◆ G4TrialsCounter()

G4TrialsCounter::G4TrialsCounter ( const G4String & nameStats,
const G4String & description,
G4bool printOnExit = false )

Constructor for G4TrialsCounter.

Parameters
[in]nameStatsIdentifier.
[in]descriptionDescription text.
[in]printOnExitFlag for enabling additional verbosity on exit.

Definition at line 34 of file G4TrialsCounter.cc.

37 : fName(nameStats), fDescription(description), fStatsVerbose(printOnExit)
38{
39 ClearCounts();
40}

◆ ~G4TrialsCounter()

G4TrialsCounter::~G4TrialsCounter ( )

Destructor.

Definition at line 42 of file G4TrialsCounter.cc.

43{
44 if( (fStatsVerbose) && (!fPrinted) ) { PrintStatistics(); }
45}

Member Function Documentation

◆ AccumulateCounts()

void G4TrialsCounter::AccumulateCounts ( G4int noTrials)
inline

Adds this number to stats.

◆ ClearCounts()

void G4TrialsCounter::ClearCounts ( )

Resets all counts.

Definition at line 63 of file G4TrialsCounter.cc.

64{
65 fTotalNoTrials = 0;
66 fNumberCalls = 0;
67 fmaxTrials = 0; // Maximum --> so only unsigned ints expected
68 fNoTimesMaxTrials = 0;
69}

Referenced by G4TrialsCounter().

◆ PrintStatistics()

void G4TrialsCounter::PrintStatistics ( )

Prints out statistics.

Definition at line 48 of file G4TrialsCounter.cc.

49{
50 // Print Statistics
51 //
52 G4cout << "G4TrialsCounter::PrintStatistics()" << G4endl
53 << "Report of counts for " << fDescription << " : " << G4endl;
54 G4cout << "Stats for '" << fName << "' > "
55 << " No-trials= " << fTotalNoTrials
56 << " No-calls= " << fNumberCalls
57 << " Max-trial= " << fmaxTrials
58 << " no-max= " << fNoTimesMaxTrials
59 << G4endl;
60 fPrinted = true;
61}
#define G4endl
Definition G4ios.hh:67
G4GLOB_DLL std::ostream G4cout

Referenced by ~G4TrialsCounter().

◆ ReturnTotals()

G4int G4TrialsCounter::ReturnTotals ( G4int & calls,
G4int & maxTrials,
G4int & numMaxT )

Returns number of count/trials, calls, max & no-max.

Definition at line 72 of file G4TrialsCounter.cc.

73{
74 calls = fNumberCalls;
75 maxTrials = fmaxTrials;
76 numMaxT = fNoTimesMaxTrials;
77
78 return fTotalNoTrials;
79}

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