Warning, file /include/Geant4/G4QSS_CustomStats.hh was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 #ifndef _QSS_CUSTOM_STATS_HH_
0033 #define _QSS_CUSTOM_STATS_HH_
0034
0035 #include <time.h>
0036
0037 #define GET_TIME(t0) (clock_gettime(CLOCK_MONOTONIC, &t0))
0038 #define TIME_SECS(t0, t1) ((t1.tv_sec - t0.tv_sec) + (t1.tv_nsec - t0.tv_nsec) / 1e9)
0039
0040
0041
0042
0043
0044
0045 #include "G4qss_misc.hh"
0046 #include "G4Types.hh"
0047
0048 #include <atomic>
0049
0050 struct QSSStats
0051 {
0052 G4double precision_dQMin;
0053 G4double precision_dQRel;
0054 G4int currentStep;
0055 G4int substeps;
0056 std::atomic<G4int> stepperSteps;
0057 std::map<G4int, std::map<G4int, G4int>> substepsByStepNumberByTrackID;
0058
0059 G4double reset_time;
0060 G4double integration_time;
0061
0062 G4int dqrel_changes[Qss_misc::VAR_IDX_END];
0063 G4int dqmin_changes[Qss_misc::VAR_IDX_END];
0064 G4double max_error[Qss_misc::VAR_IDX_END];
0065
0066 QSSStats()
0067 {
0068 substeps = 0;
0069 reset_time = 0;
0070 integration_time = 0;
0071
0072 for (size_t i = 0; i < Qss_misc::VAR_IDX_END; i++) {
0073 dqrel_changes[i] = 0;
0074 dqmin_changes[i] = 0;
0075 max_error[i] = 0;
0076 }
0077 };
0078
0079 void print() const
0080 {
0081 G4int steps = stepperSteps.load();
0082
0083 std::vector<std::string> vars{"x", "y", "z", "vx", "vy", "vz"};
0084
0085 G4double avg_substeps = (G4double)substeps / steps;
0086 G4double avg_integration_time = (G4double)integration_time / steps;
0087 G4double avg_substeps_integration_time = (G4double)integration_time / substeps;
0088 G4double avg_reset_time = (G4double)reset_time / steps;
0089
0090 std::stringstream ss;
0091
0092 ss << "QSS stats:" << std::endl;
0093 ss << "dQMin: " << precision_dQMin << std::endl;
0094 ss << "dQRel: " << precision_dQRel << std::endl;
0095
0096 ss << " Total steps: " << steps << std::endl
0097 << " Total substeps: " << substeps << std::endl
0098 << " Substeps average per step: " << avg_substeps << std::endl;
0099
0100 ss << " Substeps by track-step:" << std::endl;
0101 for (auto it = substepsByStepNumberByTrackID.begin(); it != substepsByStepNumberByTrackID.end();
0102 ++it)
0103 {
0104 ss << " Track #" << it->first << std::endl;
0105 for (auto it2 = it->second.begin(); it2 != it->second.end(); ++it2) {
0106 ss << " Step " << it2->first << " => " << it2->second << " substeps" << std::endl;
0107 }
0108 }
0109
0110 ss << " Integration time: " << integration_time << std::endl
0111 << " Integration time average (step): " << avg_integration_time << std::endl
0112 << " Integration time average (substep): " << avg_substeps_integration_time << std::endl;
0113
0114 ss << " Reset time: " << reset_time << std::endl
0115 << " Reset time average: " << avg_reset_time << std::endl;
0116
0117 for (G4int index = 0; index < Qss_misc::VAR_IDX_END; index++) {
0118 ss << " Variable " << vars[index] << ":" << std::endl;
0119 ss << " dQRel changes: " << dqrel_changes[index] << std::endl;
0120 ss << " dQMin changes: " << dqmin_changes[index] << std::endl;
0121 ss << " Max error: " << max_error[index] << std::endl;
0122 }
0123
0124 std::cout << ss.rdbuf();
0125 };
0126 };
0127
0128 #endif