File indexing completed on 2025-01-18 09:59:06
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
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 #ifndef G4StatAnalysis_hh
0044 #define G4StatAnalysis_hh 1
0045
0046 #include <cmath>
0047 #include <fstream>
0048 #include <iomanip>
0049 #include <iostream>
0050 #include <limits>
0051 #include <optional>
0052
0053 #include "globals.hh"
0054 #include "tls.hh"
0055
0056 #include "G4Allocator.hh"
0057 #include "G4Timer.hh"
0058 #include "G4Types.hh"
0059 #include "G4ios.hh"
0060
0061 class G4StatAnalysis
0062 {
0063 public:
0064 inline G4StatAnalysis();
0065 inline ~G4StatAnalysis() {}
0066
0067
0068 inline G4double GetMean() const;
0069 inline const G4double& GetSum() const;
0070 inline const G4double& GetSumSquared() const;
0071 inline const G4double& GetSum1() const;
0072 inline const G4double& GetSum2() const;
0073 inline const G4int& GetHits() const;
0074 inline G4int GetNumNonZero() const;
0075 inline G4int GetNumZero() const;
0076
0077
0078 inline void SetSum(const G4double& val);
0079 inline void SetSumSquared(const G4double& val);
0080 inline void SetSum1(const G4double& val);
0081 inline void SetSum2(const G4double& val);
0082 inline void SetHits(const G4int& val);
0083 inline void SetZero(const G4int& val);
0084
0085
0086 inline G4double GetFOM() const;
0087 inline G4double GetRelativeError() const;
0088 inline G4double GetStdDev() const;
0089 inline G4double GetVariance() const;
0090 inline G4double GetCoeffVariation() const;
0091 inline G4double GetEfficiency() const;
0092 inline G4double GetR2Int() const;
0093 inline G4double GetR2Eff() const;
0094
0095
0096 inline operator G4double() const;
0097
0098
0099 inline void Reset();
0100 inline void Add(const G4double& _val, const G4double& _weight = 1.0);
0101 inline void Rescale(const G4double& factor);
0102
0103
0104 inline void PrintInfo(std::ostream& os, const std::string& = "") const;
0105
0106
0107 inline G4StatAnalysis& operator+=(const G4double& _val);
0108 inline G4StatAnalysis& operator/=(const G4double& _val);
0109 inline G4StatAnalysis& operator+=(const G4StatAnalysis&);
0110 inline G4StatAnalysis& operator-=(const G4StatAnalysis&);
0111
0112
0113 inline void* operator new(std::size_t);
0114 inline void operator delete(void*);
0115
0116
0117 inline G4double GetCpuTime() const;
0118
0119 static tms* GetCpuClock()
0120 {
0121 G4ThreadLocalStatic std::optional<tms> _instance(std::nullopt);
0122 if(_instance == std::nullopt)
0123 {
0124 _instance = tms();
0125 times(&_instance.value());
0126 }
0127 return &_instance.value();
0128 }
0129
0130
0131
0132
0133
0134
0135 static void ResetCpuClock()
0136 {
0137 tms* _clock = GetCpuClock();
0138 times(_clock);
0139 }
0140
0141
0142 friend std::ostream& operator<<(std::ostream& os, const G4StatAnalysis& obj)
0143 {
0144 obj.PrintInfo(os);
0145 return os;
0146 }
0147
0148 friend const G4StatAnalysis operator+(const G4StatAnalysis& lhs,
0149 const G4StatAnalysis& rhs)
0150 {
0151 return G4StatAnalysis(lhs) += rhs;
0152 }
0153
0154 friend const G4StatAnalysis operator-(const G4StatAnalysis& lhs,
0155 const G4StatAnalysis& rhs)
0156 {
0157 return G4StatAnalysis(lhs) -= rhs;
0158 }
0159
0160 private:
0161 G4double fSum1 = 0.0;
0162 G4double fSum2 = 0.0;
0163 G4int fHits = 0;
0164 G4int fZero = 0;
0165 };
0166
0167 #include "G4StatAnalysis.icc"
0168
0169 #endif