File indexing completed on 2025-01-31 09:22:16
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 #ifndef HadrontherapyRBE_H
0030 #define HadrontherapyRBE_H 1
0031
0032 #include "globals.hh"
0033 #include <vector>
0034 #include <valarray>
0035 #include <map>
0036 #include "G4Pow.hh"
0037
0038 class G4GenericMessenger;
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056 class HadrontherapyRBE
0057 {
0058 public:
0059 virtual ~HadrontherapyRBE();
0060
0061
0062 static HadrontherapyRBE* CreateInstance(G4int nX, G4int nY, G4int nZ, G4double massOfVoxel);
0063 static HadrontherapyRBE* GetInstance();
0064
0065
0066 G4bool IsCalculationEnabled() const { return fCalculationEnabled; }
0067
0068
0069 G4bool IsAccumulationEnabled() const { return fAccumulate; }
0070
0071
0072 void LoadLEMTable(G4String path);
0073
0074
0075 void SetCellLine(G4String name);
0076
0077
0078 std::tuple<G4double, G4double> GetHitAlphaAndBeta(G4double E, G4int Z);
0079
0080
0081 void SetDoseScale(G4double scale);
0082 void SetCalculationEnabled(G4bool enabled);
0083 void SetAccumulationEnabled(G4bool accumulate);
0084
0085
0086 void SetVerboseLevel(G4int level) { fVerboseLevel = level; }
0087 G4int GetVerboseLevel() const { return fVerboseLevel; }
0088
0089
0090 using array_type = std::valarray<G4double>;
0091
0092
0093 void ComputeAlphaAndBeta();
0094 void ComputeRBE();
0095
0096
0097
0098 void SetAlphaNumerator(const array_type alpha);
0099 void SetBetaNumerator(const array_type beta);
0100 void SetEnergyDeposit(const array_type eDep);
0101 void SetDenominator(const array_type denom);
0102
0103
0104 void AddAlphaNumerator(const array_type alpha);
0105 void AddBetaNumerator(const array_type beta);
0106 void AddEnergyDeposit(const array_type eDep);
0107 void AddDenominator(const array_type denom);
0108
0109
0110 void Reset();
0111
0112
0113 void StoreAlphaAndBeta();
0114 void StoreRBE();
0115
0116
0117 G4int GetNumberOfVoxelsAlongX() const { return fNumberOfVoxelsAlongX; }
0118 G4int GetNumberOfVoxelsAlongY() const { return fNumberOfVoxelsAlongY; }
0119 G4int GetNumberOfVoxelsAlongZ() const { return fNumberOfVoxelsAlongZ; }
0120
0121
0122 void PrintParameters();
0123
0124 protected:
0125 inline G4int Index(G4int i, G4int j, G4int k) {return (i * fNumberOfVoxelsAlongY + j) * fNumberOfVoxelsAlongZ + k;}
0126
0127
0128
0129
0130
0131
0132
0133
0134
0135
0136 void CreateMessenger();
0137
0138 private:
0139 HadrontherapyRBE(G4int numberOfVoxelX, G4int numberOfVoxelY, G4int numberOfVoxelZ, G4double massOfVoxel);
0140
0141 G4GenericMessenger* fMessenger;
0142 G4Pow* g4pow = G4Pow::GetInstance();
0143
0144 static HadrontherapyRBE* instance;
0145 G4int fVerboseLevel { 1 };
0146
0147
0148 G4double fAlphaX { 0.0 };
0149 G4double fBetaX { 0.0 };
0150 G4double fDoseCut { 0.0 };
0151 G4double fDoseScale { 1.0 };
0152
0153
0154 G4String fAlphaBetaPath { "AlphaAndBeta.out" };
0155 G4String fRBEPath { "RBE.out" };
0156
0157
0158 G4int fNumberOfVoxelsAlongX, fNumberOfVoxelsAlongY, fNumberOfVoxelsAlongZ;
0159 G4int fNumberOfVoxels;
0160 G4double fMassOfVoxel;
0161
0162 G4double* x;
0163
0164 G4bool fCalculationEnabled { false };
0165 G4bool fAccumulate { false };
0166
0167
0168 array_type fAlpha;
0169 array_type fBeta;
0170 array_type fDose;
0171
0172 array_type fAlphaNumerator;
0173 array_type fBetaNumerator;
0174 array_type fDenominator;
0175
0176
0177 array_type fLnS;
0178 array_type fSurvival;
0179 array_type fDoseX;
0180 array_type fRBE;
0181
0182
0183 using vector_type = std::map<G4int, std::vector<G4double>>;
0184 std::map<G4String, vector_type> fTablesEnergy;
0185
0186 std::map<G4String, vector_type> fTablesAlpha;
0187 std::map<G4String, vector_type> fTablesBeta;
0188 std::map<G4String, G4double> fTablesAlphaX;
0189 std::map<G4String, G4double> fTablesBetaX;
0190 std::map<G4String, G4double> fTablesDoseCut;
0191
0192
0193
0194 G4String fActiveCellLine = "";
0195 vector_type* fActiveTableEnergy { nullptr };
0196
0197 vector_type* fActiveTableAlpha { nullptr };
0198 vector_type* fActiveTableBeta { nullptr };
0199 std::map<G4int, G4double> fMaxEnergies;
0200 std::map<G4int, G4double> fMinEnergies;
0201 G4int fMinZ;
0202 G4int fMaxZ;
0203 };
0204 #endif
0205