File indexing completed on 2025-01-18 09:58:25
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 #ifndef G4ICRU90StoppingData_h
0028 #define G4ICRU90StoppingData_h 1
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050 #include "G4Material.hh"
0051 #include "G4PhysicsFreeVector.hh"
0052 #include "globals.hh"
0053
0054 class G4ICRU90StoppingData
0055 {
0056 public:
0057
0058 G4ICRU90StoppingData();
0059
0060 ~G4ICRU90StoppingData();
0061
0062
0063 G4ICRU90StoppingData& operator=(const G4ICRU90StoppingData& right) = delete;
0064 G4ICRU90StoppingData(const G4ICRU90StoppingData&) = delete;
0065
0066 void Initialise();
0067
0068 G4double GetElectronicDEDXforProton(const G4Material*, G4double kinEnergy) const;
0069
0070 G4double GetElectronicDEDXforAlpha(const G4Material*, G4double scaledKinEnergy) const;
0071
0072 inline G4int GetIndex(const G4Material*) const;
0073
0074 inline G4int GetIndex(const G4String&) const;
0075
0076 inline G4double GetElectronicDEDXforProton(G4int idx, G4double kinEnergy) const;
0077
0078 inline G4double GetElectronicDEDXforAlpha(G4int idx, G4double scaledKinEnergy) const;
0079
0080 inline G4bool IsApplicable(const G4Material*) const;
0081
0082 private:
0083
0084 inline G4double GetDEDX(const G4PhysicsFreeVector*, G4double e) const;
0085
0086 void FillData();
0087
0088 G4PhysicsFreeVector* AddData(G4int n, const G4float* e, const G4float* dedx);
0089
0090 static constexpr G4int nvectors = 3;
0091 const G4Material* materials[nvectors];
0092 G4PhysicsFreeVector* sdata_proton[nvectors];
0093 G4PhysicsFreeVector* sdata_alpha[nvectors];
0094 G4bool isInitialized{false};
0095 };
0096
0097
0098
0099 inline G4bool G4ICRU90StoppingData::IsApplicable(const G4Material* mat) const
0100 {
0101 return (mat == materials[1] || mat == materials[0] || mat == materials[2]);
0102 }
0103
0104
0105
0106 inline G4int G4ICRU90StoppingData::GetIndex(const G4Material* mat) const
0107 {
0108 G4int idx = -1;
0109 if (mat == materials[1]) {
0110 idx = 1;
0111 }
0112 else if (mat == materials[0]) {
0113 idx = 0;
0114 }
0115 else if (mat == materials[2]) {
0116 idx = 2;
0117 }
0118 return idx;
0119 }
0120
0121
0122
0123 inline G4int G4ICRU90StoppingData::GetIndex(const G4String& nam) const
0124 {
0125 G4int idx = -1;
0126 if (nam == materials[1]->GetName()) {
0127 idx = 1;
0128 }
0129 else if (nam == materials[0]->GetName()) {
0130 idx = 0;
0131 }
0132 else if (nam == materials[2]->GetName()) {
0133 idx = 2;
0134 }
0135 return idx;
0136 }
0137
0138
0139
0140 inline G4double G4ICRU90StoppingData::GetDEDX(const G4PhysicsFreeVector* data,
0141 G4double e) const
0142 {
0143 const G4double emin = data->Energy(0);
0144 return (e >= emin) ? data->Value(e) : (*data)[0] * std::sqrt(e / emin);
0145 }
0146
0147
0148
0149 inline G4double G4ICRU90StoppingData::GetElectronicDEDXforProton(
0150 G4int idx, G4double kinEnergy) const
0151 {
0152 return (idx >= 0 && idx < nvectors) ? GetDEDX(sdata_proton[idx], kinEnergy) : 0.0;
0153 }
0154
0155
0156
0157 inline G4double G4ICRU90StoppingData::GetElectronicDEDXforAlpha(
0158 G4int idx, G4double scaledKinEnergy) const
0159 {
0160 return (idx >= 0 && idx < nvectors) ? GetDEDX(sdata_alpha[idx], scaledKinEnergy) : 0.0;
0161 }
0162
0163 #endif