File indexing completed on 2026-07-17 08:30:49
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
0044
0045
0046
0047 #ifndef G4HadronicProcess_h
0048 #define G4HadronicProcess_h 1
0049
0050 #include "globals.hh"
0051 #include "G4VDiscreteProcess.hh"
0052 #include "G4EnergyRangeManager.hh"
0053 #include "G4Nucleus.hh"
0054 #include "G4ReactionProduct.hh"
0055 #include "G4HadronicProcessType.hh"
0056 #include "G4CrossSectionDataStore.hh"
0057 #include "G4Material.hh"
0058 #include "G4DynamicParticle.hh"
0059 #include "G4ThreeVector.hh"
0060 #include "G4HadXSTypes.hh"
0061 #include <vector>
0062
0063 class G4Track;
0064 class G4Step;
0065 class G4Element;
0066 class G4ParticleChange;
0067 class G4HadronicInteraction;
0068 class G4HadronicProcessStore;
0069 class G4VCrossSectionDataSet;
0070 class G4VLeadingParticleBiasing;
0071 class G4ParticleDefinition;
0072
0073 class G4HadronicProcess : public G4VDiscreteProcess
0074 {
0075 public:
0076 G4HadronicProcess(const G4String& processName="Hadronic",
0077 G4ProcessType procType=fHadronic);
0078
0079
0080 G4HadronicProcess(const G4String& processName,
0081 G4HadronicProcessType subType);
0082
0083 ~G4HadronicProcess() override;
0084
0085
0086 void RegisterMe(G4HadronicInteraction* a);
0087
0088
0089 G4double GetElementCrossSection(const G4DynamicParticle * part,
0090 const G4Element * elm,
0091 const G4Material* mat = nullptr);
0092
0093
0094 inline
0095 G4double GetMicroscopicCrossSection(const G4DynamicParticle * part,
0096 const G4Element * elm,
0097 const G4Material* mat = nullptr);
0098
0099
0100 void StartTracking(G4Track* track) override;
0101
0102
0103 G4double PostStepGetPhysicalInteractionLength(const G4Track& track,
0104 G4double, G4ForceCondition*) override;
0105
0106
0107 G4VParticleChange* PostStepDoIt(const G4Track& aTrack,
0108 const G4Step& aStep) override;
0109
0110
0111 void PreparePhysicsTable(const G4ParticleDefinition&) override;
0112
0113
0114 void BuildPhysicsTable(const G4ParticleDefinition&) override;
0115
0116
0117 void DumpPhysicsTable(const G4ParticleDefinition& p);
0118
0119
0120 void AddDataSet(G4VCrossSectionDataSet * aDataSet);
0121
0122
0123 std::vector<G4HadronicInteraction*>& GetHadronicInteractionList();
0124
0125
0126 G4HadronicInteraction* GetHadronicModel(const G4String&);
0127
0128
0129 inline G4HadronicInteraction* GetHadronicInteraction() const;
0130
0131
0132 G4double GetMeanFreePath(const G4Track &aTrack, G4double,
0133 G4ForceCondition *) override;
0134
0135
0136 inline const G4Nucleus* GetTargetNucleus() const;
0137
0138 inline G4Nucleus* GetTargetNucleusPointer();
0139
0140 inline const G4Isotope* GetTargetIsotope();
0141
0142
0143 G4double ComputeCrossSection(const G4ParticleDefinition*,
0144 const G4Material*,
0145 const G4double kinEnergy);
0146
0147 inline G4HadXSType CrossSectionType() const;
0148 inline void SetCrossSectionType(G4HadXSType val);
0149
0150 void ProcessDescription(std::ostream& outFile) const override;
0151
0152
0153 void BiasCrossSectionByFactor(G4double aScale);
0154 void MultiplyCrossSectionBy(G4double factor);
0155 inline G4double CrossSectionFactor() const;
0156
0157
0158 inline void SetIntegral(G4bool val);
0159
0160
0161 inline void SetEpReportLevel(G4int level);
0162 inline void SetEnergyMomentumCheckLevels(G4double relativeLevel,
0163 G4double absoluteLevel);
0164 inline std::pair<G4double, G4double> GetEnergyMomentumCheckLevels() const;
0165
0166
0167 inline G4CrossSectionDataStore* GetCrossSectionDataStore();
0168
0169
0170 inline std::vector<G4TwoPeaksHadXS*>* TwoPeaksXS() const;
0171 inline std::vector<G4double>* EnergyOfCrossSectionMax() const;
0172
0173
0174 G4HadronicProcess& operator=(const G4HadronicProcess& right) = delete;
0175 G4HadronicProcess(const G4HadronicProcess&) = delete;
0176
0177 protected:
0178
0179
0180
0181 inline G4HadronicInteraction* ChooseHadronicInteraction(
0182 const G4HadProjectile & aHadProjectile, G4Nucleus& aTargetNucleus,
0183 const G4Material* aMaterial, const G4Element* anElement);
0184
0185
0186 inline G4double GetLastCrossSection();
0187
0188
0189 void FillResult(G4HadFinalState* aR, const G4Track& aT);
0190
0191 void DumpState(const G4Track&, const G4String&, G4ExceptionDescription&);
0192
0193
0194 G4HadFinalState* CheckResult(const G4HadProjectile& thePro,
0195 const G4Nucleus& targetNucleus,
0196 G4HadFinalState* result);
0197
0198
0199 void CheckEnergyMomentumConservation(const G4Track&, const G4Nucleus&);
0200
0201 private:
0202
0203 void InitialiseLocal();
0204 void UpdateCrossSectionAndMFP(const G4double kinEnergy);
0205 void RecomputeXSandMFP(const G4double kinEnergy);
0206
0207 inline void DefineXSandMFP();
0208 inline void ComputeXSandMFP();
0209
0210 G4double XBiasSurvivalProbability();
0211 G4double XBiasSecondaryWeight();
0212
0213 protected:
0214
0215 G4HadProjectile thePro;
0216
0217 G4ParticleChange* theTotalResult;
0218 G4CrossSectionDataStore* theCrossSectionDataStore;
0219
0220 G4double fWeight = 1.0;
0221 G4double aScaleFactor = 1.0;
0222 G4double theLastCrossSection = 0.0;
0223 G4double mfpKinEnergy = DBL_MAX;
0224 G4int epReportLevel = 0;
0225
0226 G4HadXSType fXSType = fHadNoIntegral;
0227
0228 private:
0229
0230 G4EnergyRangeManager theEnergyRangeManager;
0231 G4Nucleus targetNucleus;
0232
0233 G4HadronicInteraction* theInteraction = nullptr;
0234 G4HadronicProcessStore* theProcessStore;
0235 const G4HadronicProcess* masterProcess = nullptr;
0236 const G4ParticleDefinition* firstParticle = nullptr;
0237 const G4ParticleDefinition* currentParticle = nullptr;
0238 const G4Material* currentMat = nullptr;
0239 const G4DynamicParticle* fDynParticle = nullptr;
0240
0241 std::vector<G4double>* theEnergyOfCrossSectionMax = nullptr;
0242 std::vector<G4TwoPeaksHadXS*>* fXSpeaks = nullptr;
0243
0244 G4double theMFP = DBL_MAX;
0245 G4double minKinEnergy;
0246
0247
0248 G4int nMatWarn = 0;
0249 G4int nICelectrons = 0;
0250 G4int matIdx = 0;
0251
0252
0253 G4bool levelsSetByProcess = false;
0254 G4bool useIntegralXS = true;
0255 G4bool isMaster = true;
0256
0257 G4ThreeVector unitVector;
0258
0259
0260 std::pair<G4double, G4double> epCheckLevels;
0261 std::vector<G4VLeadingParticleBiasing*> theBias;
0262 };
0263
0264 inline G4double G4HadronicProcess::
0265 GetMicroscopicCrossSection(const G4DynamicParticle * part,
0266 const G4Element * elm,
0267 const G4Material* mat)
0268 {
0269 return GetElementCrossSection(part, elm, mat);
0270 }
0271
0272 inline G4HadronicInteraction*
0273 G4HadronicProcess::GetHadronicInteraction() const
0274 {
0275 return theInteraction;
0276 }
0277
0278 inline const G4Nucleus*
0279 G4HadronicProcess::GetTargetNucleus() const
0280 {
0281 return &targetNucleus;
0282 }
0283
0284 inline const G4Isotope* G4HadronicProcess::GetTargetIsotope()
0285 {
0286 return targetNucleus.GetIsotope();
0287 }
0288
0289 inline G4HadXSType
0290 G4HadronicProcess::CrossSectionType() const
0291 {
0292 return fXSType;
0293 }
0294
0295 inline void
0296 G4HadronicProcess::SetCrossSectionType(G4HadXSType val)
0297 {
0298 fXSType = val;
0299 }
0300
0301 inline G4double G4HadronicProcess::CrossSectionFactor() const
0302 {
0303 return aScaleFactor;
0304 }
0305
0306 inline void G4HadronicProcess::SetIntegral(G4bool val)
0307 {
0308 useIntegralXS = val;
0309 }
0310
0311 inline void G4HadronicProcess::SetEpReportLevel(G4int level)
0312 {
0313 epReportLevel = level;
0314 }
0315
0316 inline void
0317 G4HadronicProcess::SetEnergyMomentumCheckLevels(G4double relativeLevel,
0318 G4double absoluteLevel)
0319 {
0320 epCheckLevels.first = relativeLevel;
0321 epCheckLevels.second = absoluteLevel;
0322 levelsSetByProcess = true;
0323 }
0324
0325 inline std::pair<G4double, G4double>
0326 G4HadronicProcess::GetEnergyMomentumCheckLevels() const
0327 {
0328 return epCheckLevels;
0329 }
0330
0331 inline G4CrossSectionDataStore*
0332 G4HadronicProcess::GetCrossSectionDataStore()
0333 {
0334 return theCrossSectionDataStore;
0335 }
0336
0337 inline std::vector<G4TwoPeaksHadXS*>*
0338 G4HadronicProcess::TwoPeaksXS() const
0339 {
0340 return fXSpeaks;
0341 }
0342
0343 inline std::vector<G4double>*
0344 G4HadronicProcess::EnergyOfCrossSectionMax() const
0345 {
0346 return theEnergyOfCrossSectionMax;
0347 }
0348
0349 inline G4HadronicInteraction* G4HadronicProcess::
0350 ChooseHadronicInteraction(const G4HadProjectile& aHadProjectile,
0351 G4Nucleus& aTargetNucleus,
0352 const G4Material* aMaterial,
0353 const G4Element* anElement)
0354 {
0355 return theEnergyRangeManager.GetHadronicInteraction(aHadProjectile,
0356 aTargetNucleus,
0357 aMaterial,anElement);
0358 }
0359
0360 inline G4Nucleus* G4HadronicProcess::GetTargetNucleusPointer()
0361 {
0362 return &targetNucleus;
0363 }
0364
0365 inline G4double G4HadronicProcess::GetLastCrossSection()
0366 {
0367 return theLastCrossSection;
0368 }
0369
0370 inline void G4HadronicProcess::DefineXSandMFP()
0371 {
0372 theLastCrossSection = aScaleFactor*
0373 theCrossSectionDataStore->GetCrossSection(fDynParticle, currentMat);
0374 theMFP = (theLastCrossSection > 0.0) ? 1.0/theLastCrossSection : DBL_MAX;
0375 }
0376
0377 inline void G4HadronicProcess::ComputeXSandMFP()
0378 {
0379 theLastCrossSection = aScaleFactor*
0380 theCrossSectionDataStore->ComputeCrossSection(fDynParticle, currentMat);
0381 theMFP = (theLastCrossSection > 0.0) ? 1.0/theLastCrossSection : DBL_MAX;
0382 }
0383
0384 #endif
0385