File indexing completed on 2026-04-17 07:51:37
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 #ifndef G4IAEAphspReader_h
0042 #define G4IAEAphspReader_h 1
0043
0044 #include "G4VPrimaryGenerator.hh"
0045
0046 #include <vector>
0047
0048 #include "globals.hh"
0049 #include "G4ThreeVector.hh"
0050
0051
0052 class G4Event;
0053 class G4IAEAphspReaderMessenger;
0054
0055
0056 class G4IAEAphspReader :public G4VPrimaryGenerator
0057 {
0058
0059 public:
0060
0061 G4IAEAphspReader(const char* filename, const G4int threads = 1);
0062 G4IAEAphspReader(const G4String filename, const G4int threads = 1);
0063
0064 ~G4IAEAphspReader() override;
0065
0066 void GeneratePrimaryVertex(G4Event* evt) override;
0067
0068 inline void SetVerbose(const G4int verb)
0069 {
0070 fVerbose = verb;
0071 if (fVerbose > 0)
0072 G4cout << "G4IAEAphspReader::fVerbose = " << fVerbose << G4endl;
0073 }
0074
0075 inline void SetTotalParallelRuns(const G4int nParallelRuns)
0076 {
0077 fTotalParallelRuns = nParallelRuns;
0078 if (fVerbose > 0)
0079 G4cout << "G4IAEAphspReader::fTotalParallelRuns = " << fTotalParallelRuns
0080 << G4endl;
0081 }
0082
0083 void SetParallelRun(const G4int parallelRun);
0084 inline void SetTotalThreads(const G4int threads) {fTotalThreads = threads;}
0085 inline void SetTimesRecycled(const G4int ntimes) {fTimesRecycled = ntimes;}
0086
0087 inline void SetGlobalPhspTranslation(const G4ThreeVector & pos)
0088 {fGlobalPhspTranslation = pos;}
0089 inline void SetRotationOrder(const G4int ord) { fRotationOrder = ord; }
0090 inline void SetRotationX(const G4double alpha) { fAlpha = alpha; }
0091 inline void SetRotationY(const G4double beta) { fBeta = beta; }
0092 inline void SetRotationZ(const G4double gamma) { fGamma = gamma; }
0093 inline void SetIsocenterPosition(const G4ThreeVector & pos)
0094 {fIsocenterPosition = pos;}
0095 void SetCollimatorRotationAxis(const G4ThreeVector & axis);
0096 void SetGantryRotationAxis(const G4ThreeVector & axis);
0097 inline void SetCollimatorAngle(const G4double ang) {fCollimatorAngle = ang;}
0098 inline void SetGantryAngle(const G4double ang) {fGantryAngle = ang;}
0099
0100 inline void SetAxialSymmetryX(const G4bool value)
0101 {
0102 fAxialSymmetryX = value;
0103 if (value) {
0104 fAxialSymmetryY = false;
0105 fAxialSymmetryZ = false;
0106 }
0107 }
0108 inline void SetAxialSymmetryY(const G4bool value)
0109 {
0110 fAxialSymmetryY = value;
0111 if (value) {
0112 fAxialSymmetryZ = false;
0113 fAxialSymmetryX = false;
0114 }
0115 }
0116 inline void SetAxialSymmetryZ(const G4bool value)
0117 {
0118 fAxialSymmetryZ = value;
0119 if (value) {
0120 fAxialSymmetryX = false;
0121 fAxialSymmetryY = false;
0122 }
0123 }
0124
0125 inline G4String GetFileName() const {return fFileName;}
0126 inline G4int GetSourceReadId() const {return fSourceReadId;}
0127 inline G4long GetOrigHistories() const {return fOrigHistories;}
0128 inline G4long GetUsedOrigHistories() const {return fUsedOrigHistories;}
0129 inline G4long GetTotalParticles() const {return fTotalParticles;}
0130 inline G4int GetNumberOfExtraFloats() const {return fNumberOfExtraFloats;}
0131 inline G4int GetNumberOfExtraInts() const {return fNumberOfExtraInts;}
0132 inline std::vector<G4int>* GetExtraFloatTypes() const
0133 {return fExtraFloatTypes;}
0134 inline std::vector<G4int>* GetExtraIntTypes() const
0135 {return fExtraIntTypes;}
0136 G4long GetTotalParticlesOfType(const G4String type) const;
0137 G4double GetConstantVariable(const G4int index) const;
0138
0139 inline std::vector<G4int>* GetParticleTypeVec() const
0140 {return fParticleTypeVec;}
0141 inline std::vector<G4double>* GetKinEVec() const
0142 {return fKinEVec;}
0143 inline std::vector<G4ThreeVector>* GetPosVec() const
0144 {return fPosVec;}
0145 inline std::vector<G4ThreeVector>* GetMomDirVec() const
0146 {return fMomDirVec;}
0147 inline std::vector<G4double>* GetWeightVec() const
0148 {return fWeightVec;}
0149 inline std::vector< std::vector<G4double> >* GetExtraFloatVec() const
0150 {return fExtraFloatVec;}
0151 inline std::vector< std::vector<G4long> >* GetExtraIntVec() const
0152 {return fExtraIntVec;}
0153
0154 inline G4int GetTotalParallelRuns() const {return fTotalParallelRuns;}
0155 inline G4int GetParallelRun() const {return fParallelRun;}
0156 inline G4int GetTotalThreads() const {return fTotalThreads;}
0157 inline G4long GetFirstParticle() const {return fFirstParticle;}
0158 inline G4long GetLastParticle() const {return fLastParticle;}
0159 inline G4int GetTimesRecycled() const {return fTimesRecycled;}
0160
0161 inline G4ThreeVector GetGlobalPhspTranslation() const
0162 {return fGlobalPhspTranslation;}
0163 inline G4int GetRotationOrder() const {return fRotationOrder;}
0164 inline G4double GetRotationX() const {return fAlpha;}
0165 inline G4double GetRotationY() const {return fBeta;}
0166 inline G4double GetRotationZ() const {return fGamma;}
0167 inline G4ThreeVector GetIsocenterPosition() const
0168 {return fIsocenterPosition;}
0169 inline G4double GetCollimatorAngle() const {return fCollimatorAngle;}
0170 inline G4double GetGantryAngle() const {return fGantryAngle;}
0171 inline G4ThreeVector GetCollimatorRotationAxis() const
0172 {return fCollimatorRotAxis;}
0173 inline G4ThreeVector GetGantryRotationAxis() const {return fGantryRotAxis;}
0174
0175 inline G4bool GetAxialSymmetryX() const {return fAxialSymmetryX;}
0176 inline G4bool GetAxialSymmetryY() const {return fAxialSymmetryY;}
0177 inline G4bool GetAxialSymmetryZ() const {return fAxialSymmetryZ;}
0178
0179
0180 private:
0181
0182 G4IAEAphspReader() = default;
0183
0184 void InitializeMembers();
0185 void InitializeSource(const G4String filename);
0186 void ComputeFirstLastParticle();
0187 void ReadAndStoreFirstParticle();
0188 void PrepareThisEvent();
0189 void ReadThisEvent();
0190 void GeneratePrimaryParticles(G4Event* evt);
0191 void PerformRotations(G4ThreeVector& mom);
0192 void PerformGlobalRotations(G4ThreeVector& mom);
0193 void PerformHeadRotations(G4ThreeVector& mom);
0194 void RestartSourceFile();
0195
0196
0197
0198
0199 private:
0200
0201
0202
0203
0204
0205 G4String fFileName;
0206
0207
0208 G4int fSourceReadId;
0209
0210
0211
0212
0213
0214
0215 G4long fOrigHistories;
0216
0217
0218 G4long fTotalParticles;
0219
0220
0221 G4int fNumberOfExtraFloats, fNumberOfExtraInts;
0222
0223
0224 std::vector<G4int>* fExtraFloatTypes;
0225 std::vector<G4int>* fExtraIntTypes;
0226
0227
0228
0229
0230
0231
0232 std::vector<G4int>* fParticleTypeVec;
0233 std::vector<G4double>* fKinEVec;
0234 std::vector<G4ThreeVector>* fPosVec;
0235 std::vector<G4ThreeVector>* fMomDirVec;
0236 std::vector<G4double>* fWeightVec;
0237 std::vector< std::vector<G4double> >* fExtraFloatVec;
0238 std::vector< std::vector<G4long> >* fExtraIntVec;
0239
0240
0241
0242
0243
0244 G4int fTotalParallelRuns;
0245
0246
0247
0248 G4int fParallelRun;
0249
0250
0251 G4int fTotalThreads;
0252
0253
0254 G4long fFirstParticle;
0255
0256
0257
0258 G4long fLastParticle;
0259
0260
0261
0262 G4int fTimesRecycled;
0263
0264
0265 G4int fNStat;
0266
0267
0268 G4long fUsedOrigHistories;
0269
0270
0271 G4long fCurrentParticle;
0272
0273
0274 G4bool fEndOfFile;
0275
0276
0277 G4bool fLastGenerated;
0278
0279
0280
0281
0282
0283
0284 G4ThreeVector fGlobalPhspTranslation;
0285
0286
0287 G4int fRotationOrder;
0288
0289
0290
0291 G4double fAlpha, fBeta, fGamma;
0292
0293
0294 G4ThreeVector fIsocenterPosition;
0295
0296
0297 G4double fCollimatorAngle, fGantryAngle;
0298 G4ThreeVector fCollimatorRotAxis, fGantryRotAxis;
0299
0300
0301
0302
0303
0304
0305
0306
0307
0308 G4bool fAxialSymmetryX;
0309 G4bool fAxialSymmetryY;
0310 G4bool fAxialSymmetryZ;
0311
0312
0313
0314
0315
0316 G4IAEAphspReaderMessenger* fMessenger;
0317
0318
0319
0320
0321 G4int fVerbose;
0322
0323 };
0324
0325 #endif