83static const char* G4Hadronic_Random_File = std::getenv(
"G4HADRONIC_RANDOM_FILE");
110 delete theEnergyOfCrossSectionMax;
114void G4HadronicProcess::InitialiseLocal() {
120 minKinEnergy = 1*CLHEP::MeV;
122 epCheckLevels.second =
DBL_MAX;
123 GetEnergyMomentumCheckEnvvars();
124 unitVector.
set(0.0, 0.0, 0.1);
128void G4HadronicProcess::GetEnergyMomentumCheckEnvvars() {
129 if ( std::getenv(
"G4Hadronic_epReportLevel") ) {
130 epReportLevel = std::strtol(std::getenv(
"G4Hadronic_epReportLevel"),0,10);
132 if ( std::getenv(
"G4Hadronic_epCheckRelativeLevel") ) {
133 epCheckLevels.first = std::strtod(std::getenv(
"G4Hadronic_epCheckRelativeLevel"),0);
135 if ( std::getenv(
"G4Hadronic_epCheckAbsoluteLevel") ) {
136 epCheckLevels.second = std::strtod(std::getenv(
"G4Hadronic_epCheckAbsoluteLevel"),0);
142 if(
nullptr == a) {
return; }
154 static const G4int nmax = 5;
155 if(nMatWarn < nmax) {
159 <<
" because no material defined \n"
160 <<
" Please, specify material pointer or define simple material"
162 G4Exception(
"G4HadronicProcess::GetElementCrossSection",
"had066",
171 if(std::getenv(
"G4HadronicProcess_debug")) {
172 G4HadronicProcess_debug_flag =
true;
174 if(
nullptr == firstParticle) { firstParticle = &p; }
180 if(firstParticle != &p) {
return; }
203 if(charge != 0.0 && useIntegralXS && !isLepton && ok) {
206 currentParticle = firstParticle;
209 if(std::abs(pdg) == 211) {
211 }
else if(pdg == 321) {
213 }
else if(pdg == 2212) {
216 delete theEnergyOfCrossSectionMax;
217 theEnergyOfCrossSectionMax =
nullptr;
222 if(
nullptr == fXSpeaks) {
227 theEnergyOfCrossSectionMax =
229 if(
nullptr == theEnergyOfCrossSectionMax) {
235 if(
nullptr == masterProcess) {
239 if(
nullptr == masterProcess) {
240 G4cout <<
"G4HadronicProcess::BuildPhysicsTable: for "
242 <<
" fail due to undefined pointer to the master process"
248 theEnergyOfCrossSectionMax =
253 G4cout <<
"G4HadronicProcess::BuildPhysicsTable: for "
262 currentMat =
nullptr;
276 if(mat != currentMat) {
320 return (xs > 0.0) ? 1.0/xs :
DBL_MAX;
366 ed <<
"G4HadronicProcess: track in unusable state - "
368 ed <<
"G4HadronicProcess: returning unchanged track " <<
G4endl;
380 aMaterial, anElement);
381 if(
nullptr == theInteraction) {
383 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
386 DumpState(aTrack,
"ChooseHadronicInteraction",ed);
387 ed <<
" No HadronicInteraction found out" <<
G4endl;
388 G4Exception(
"G4HadronicProcess::PostStepDoIt",
"had005",
394 G4int reentryCount = 0;
408 if (G4Hadronic_Random_File) {
420 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
424 ed <<
" ApplyYourself failed" <<
G4endl;
432 if(reentryCount>100) {
435 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
439 ed <<
" ApplyYourself does not completed after 100 attempts" <<
G4endl;
453 for (
G4int i = 0; i < nSec; ++i ) {
461 dynamicParticle->SetDefinition( newPart );
466 ed <<
" created " << part->GetParticleName() <<
G4endl;
486 outFile <<
"The description for this process has not been written yet.\n";
489G4double G4HadronicProcess::XBiasSurvivalProbability()
494 G4double result = (biasedProbability-realProbability)/biasedProbability;
498G4double G4HadronicProcess::XBiasSecondaryWeight()
520 }
else if(0.0 == efinal) {
545 for (
G4int i = 0; i < nSec; ++i) {
557 const G4double delta_mass_lim = 1.0*CLHEP::keV;
558 const G4double delta_ekin = 0.001*CLHEP::eV;
559 if(std::abs(dmass - mass) > delta_mass_lim) {
562 if(G4HadronicProcess_debug_flag) {
566 <<
" Target Z= " << targetNucleus.
GetZ_asInt() <<
" A= "
570 <<
" EkinNew(MeV)= " << e
571 <<
" DeltaMass(MeV)= " << dmass - mass <<
G4endl;
591 if (G4HadronicProcess_debug_flag) {
595 DumpState(aT,
"Secondary has zero energy",ed);
598 G4Exception(
"G4HadronicProcess::FillResults",
"had011",
616 ed <<
" Wrong biasing factor " << aScale <<
" for " <<
GetProcessName();
617 G4Exception(
"G4HadronicProcess::BiasCrossSectionByFactor",
"had010",
632 if (
nullptr != theModel) {
652 for (
G4int i = 0; i < nSec; ++i) {
657 if ( std::abs(mass_pdg - mass_dyn) > 0.1*mass_pdg + 1.*MeV ) {
666 desc <<
"Warning: Secondary with off-shell dynamic mass detected: "
669 <<
", PDG mass: " << mass_pdg <<
", dynamic mass: "
672 :
"re-sample the interaction") <<
G4endl
678 <<
", target nucleus (" << aNucleus.
GetZ_asInt() <<
", "
680 G4Exception(
"G4HadronicProcess:CheckResult()",
"had012",
688 std::pair<G4double, G4double> checkLevels =
690 if (std::abs(deltaE) > checkLevels.second &&
696 desc <<
"Warning: Bad energy non-conservation detected, will "
698 :
"re-sample the interaction") <<
G4endl
704 <<
", target nucleus (" << aNucleus.
GetZ_asInt() <<
", "
706 <<
" E(initial - final) = " << deltaE <<
" MeV." <<
G4endl;
707 G4Exception(
"G4HadronicProcess:CheckResult()",
"had012",
722 + nICelectrons*CLHEP::electron_mass_c2);
728 G4int initial_A = target_A + track_A;
729 G4int initial_Z = target_Z + track_Z - nICelectrons;
735 G4int final_A(0), final_Z(0);
744 final4mom = initial4mom;
753 G4double ptot = std::sqrt(ekin*(ekin + 2*mass));
754 final4mom.
set(ptot*v.
x(), ptot*v.
y(), ptot*v.
z(), mass + ekin);
764 for (
G4int i = 0; i < nSec; i++) {
777 std::pair<G4double, G4double> checkLevels = epCheckLevels;
778 if (!levelsSetByProcess) {
780 checkLevels.first= std::min(checkLevels.first, epCheckLevels.first);
781 checkLevels.second=std::min(checkLevels.second, epCheckLevels.second);
797 if ( std::abs(relative) > checkLevels.first
798 || std::abs(relative_mom) > checkLevels.first) {
800 relResult = checkRelative ?
"fail" :
"N/A";
805 if ( std::abs(absolute) > checkLevels.second
806 || std::abs(absolute_mom) > checkLevels.second ) {
813 if ( (initial_A-final_A)!=0
814 || (initial_Z-final_Z)!=0 ) {
815 chargePass = checkLevels.second <
DBL_MAX ? false :
true;
816 chargeResult =
"fail";
819 G4bool conservationPass = (relPass || absPass) && chargePass;
821 std::stringstream Myout;
822 G4bool Myout_notempty(
false);
833 Myout <<
" Process: " << processName <<
" , Model: " << modelName <<
G4endl;
837 <<
", target nucleus (" << aNucleus.
GetZ_asInt() <<
","
843 || ! conservationPass ){
845 Myout <<
" "<< relResult <<
" relative, limit " << checkLevels.first <<
", values E/T(0) = "
846 << relative <<
" p/p(0)= " << relative_mom <<
G4endl;
847 Myout <<
" "<< absResult <<
" absolute, limit (MeV) " << checkLevels.second/MeV <<
", values E / p (MeV) = "
848 << absolute/MeV <<
" / " << absolute_mom/MeV <<
" 3mom: " << (diff.
vect())*1./MeV <<
G4endl;
849 Myout <<
" "<< chargeResult <<
" charge/baryon number balance " << (initial_Z-final_Z) <<
" / " << (initial_A-final_A) <<
" "<<
G4endl;
854 if ( Myout_notempty ) {
864 ed <<
"Unrecoverable error in the method " << method <<
" of "
866 ed <<
"TrackID= "<< aTrack.
GetTrackID() <<
" ParentID= "
872 ed <<
"Position(mm)= " << aTrack.
GetPosition()/CLHEP::mm <<
";";
895std::vector<G4HadronicInteraction*>&
904 std::vector<G4HadronicInteraction*>& list
906 for (
auto & mod : list) {
907 if (mod->GetModelName() == modelName)
return mod;
923void G4HadronicProcess::RecomputeXSandMFP(
const G4double kinEnergy)
932void G4HadronicProcess::UpdateCrossSectionAndMFP(
const G4double e)
944 if(e < mfpKinEnergy && mfpKinEnergy > minKinEnergy) {
947 RecomputeXSandMFP(e1);
951 G4double epeak = (*theEnergyOfCrossSectionMax)[matIdx];
960 RecomputeXSandMFP(e1);
981 RecomputeXSandMFP(e1);
1000 RecomputeXSandMFP(e1);
1017 RecomputeXSandMFP(e1);
G4double condition(const G4ErrorSymMatrix &m)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
G4double G4Exp(G4double initial_x)
Exponential Function double precision.
constexpr G4double lambdaFactor
constexpr G4double invLambdaFactor
G4double G4Log(G4double x)
@ fKillTrackAndSecondaries
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
void set(double x, double y, double z)
Hep3Vector & rotateUz(const Hep3Vector &)
void set(double x, double y, double z, double t)
static void saveEngineStatus(const char filename[]="Config.conf")
static G4AntiKaonZero * Definition()
void BuildPhysicsTable(const G4ParticleDefinition &)
void AddDataSet(G4VCrossSectionDataSet *)
void DumpPhysicsTable(const G4ParticleDefinition &)
G4double ComputeCrossSection(const G4DynamicParticle *, const G4Material *)
G4double GetCrossSection(const G4DynamicParticle *, const G4Material *)
const G4Element * SampleZandA(const G4DynamicParticle *, const G4Material *, G4Nucleus &target)
void SetMomentumDirection(const G4ThreeVector &aDirection)
const G4ThreeVector & GetMomentumDirection() const
void SetMass(G4double mass)
const G4ParticleDefinition * GetParticleDefinition() const
G4ParticleDefinition * GetDefinition() const
G4LorentzVector Get4Momentum() const
G4double GetKineticEnergy() const
G4double GetTotalEnergy() const
void SetKineticEnergy(G4double aEnergy)
const G4String & GetName() const
void RegisterMe(G4HadronicInteraction *a)
void BuildPhysicsTable(const G4ParticleDefinition &)
std::vector< G4HadronicInteraction * > & GetHadronicInteractionList()
G4double GetEnergyChange() const
G4HadFinalStateStatus GetStatusChange() const
void SetTrafoToLab(const G4LorentzRotation &aT)
G4double GetLocalEnergyDeposit() const
const G4ThreeVector & GetMomentumChange() const
std::size_t GetNumberOfSecondaries() const
G4HadSecondary * GetSecondary(size_t i)
void Initialise(const G4Track &aT)
const G4ParticleDefinition * GetDefinition() const
G4LorentzRotation & GetTrafoToLab()
G4double GetKineticEnergy() const
const G4LorentzVector & Get4Momentum() const
G4double GetTotalEnergy() const
G4DynamicParticle * GetParticle()
G4int GetParentResonanceID() const
G4double GetWeight() const
const G4ParticleDefinition * GetParentResonanceDef() const
G4int GetCreatorModelID() const
static std::vector< G4TwoPeaksHadXS * > * FillPeaksStructure(G4HadronicProcess *, const G4ParticleDefinition *, const G4double tmin, const G4double tmax)
static std::vector< G4double > * FindCrossSectionMax(G4HadronicProcess *, const G4ParticleDefinition *, const G4double tmin, const G4double tmax)
void Report(std::ostream &aS) const
virtual G4HadFinalState * ApplyYourself(const G4HadProjectile &aTrack, G4Nucleus &targetNucleus)
virtual const std::pair< G4double, G4double > GetFatalEnergyCheckLevels() const
virtual std::pair< G4double, G4double > GetEnergyMomentumCheckLevels() const
const G4String & GetModelName() const
G4bool EnableIntegralInelasticXS() const
static G4HadronicParameters * Instance()
G4int GetVerboseLevel() const
G4bool EnableIntegralElasticXS() const
G4double GetMaxEnergy() const
void DeRegister(G4HadronicProcess *)
void RegisterParticle(G4HadronicProcess *, const G4ParticleDefinition *)
static G4HadronicProcessStore * Instance()
void RegisterInteraction(G4HadronicProcess *, G4HadronicInteraction *)
void Register(G4HadronicProcess *)
void PrintInfo(const G4ParticleDefinition *)
void FillResult(G4HadFinalState *aR, const G4Track &aT)
G4VParticleChange * PostStepDoIt(const G4Track &aTrack, const G4Step &aStep) override
void ProcessDescription(std::ostream &outFile) const override
G4double ComputeCrossSection(const G4ParticleDefinition *, const G4Material *, const G4double kinEnergy)
void BiasCrossSectionByFactor(G4double aScale)
void StartTracking(G4Track *track) override
G4HadFinalState * CheckResult(const G4HadProjectile &thePro, const G4Nucleus &targetNucleus, G4HadFinalState *result)
G4double GetMeanFreePath(const G4Track &aTrack, G4double, G4ForceCondition *) override
G4HadronicInteraction * GetHadronicInteraction() const
G4ParticleChange * theTotalResult
void AddDataSet(G4VCrossSectionDataSet *aDataSet)
std::vector< G4TwoPeaksHadXS * > * TwoPeaksXS() const
G4HadXSType CrossSectionType() const
G4double GetElementCrossSection(const G4DynamicParticle *part, const G4Element *elm, const G4Material *mat=nullptr)
std::vector< G4HadronicInteraction * > & GetHadronicInteractionList()
void PreparePhysicsTable(const G4ParticleDefinition &) override
G4HadronicProcess(const G4String &processName="Hadronic", G4ProcessType procType=fHadronic)
G4HadronicInteraction * ChooseHadronicInteraction(const G4HadProjectile &aHadProjectile, G4Nucleus &aTargetNucleus, const G4Material *aMaterial, const G4Element *anElement)
~G4HadronicProcess() override
void BuildPhysicsTable(const G4ParticleDefinition &) override
G4CrossSectionDataStore * theCrossSectionDataStore
void CheckEnergyMomentumConservation(const G4Track &, const G4Nucleus &)
G4HadronicInteraction * GetHadronicModel(const G4String &)
void DumpState(const G4Track &, const G4String &, G4ExceptionDescription &)
void DumpPhysicsTable(const G4ParticleDefinition &p)
void MultiplyCrossSectionBy(G4double factor)
G4double PostStepGetPhysicalInteractionLength(const G4Track &track, G4double, G4ForceCondition *) override
G4double theLastCrossSection
void RegisterMe(G4HadronicInteraction *a)
std::vector< G4double > * EnergyOfCrossSectionMax() const
static G4KaonZeroLong * Definition()
static G4KaonZeroShort * Definition()
static G4KaonZero * Definition()
const G4String & GetName() const
static G4double GetNuclearMass(const G4double A, const G4double Z)
void AddSecondary(G4Track *aSecondary)
G4double GetEnergy() const
void Initialize(const G4Track &) override
const G4ThreeVector * GetMomentumDirection() const
void ProposeEnergy(G4double finalEnergy)
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
G4ProcessManager * GetProcessManager() const
G4int GetAtomicNumber() const
G4bool IsShortLived() const
G4double GetPDGMass() const
G4int GetPDGEncoding() const
G4int GetLeptonNumber() const
G4double GetPDGWidth() const
G4double GetPDGCharge() const
G4int GetBaryonNumber() const
const G4String & GetParticleName() const
G4ProcessVector * GetAtRestProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const
G4TrackStatus GetTrackStatus() const
const G4ParticleDefinition * GetParticleDefinition() const
G4VPhysicalVolume * GetVolume() const
G4double GetWeight() const
void SetWeight(G4double aValue)
void SetParentResonanceID(const G4int parentID)
const G4ThreeVector & GetPosition() const
void SetTouchableHandle(const G4TouchableHandle &apValue)
G4double GetGlobalTime() const
G4ThreeVector GetMomentum() const
G4Material * GetMaterial() const
G4ParticleDefinition * GetDefinition() const
const G4DynamicParticle * GetDynamicParticle() const
const G4TouchableHandle & GetTouchableHandle() const
const G4ThreeVector & GetMomentumDirection() const
G4double GetKineticEnergy() const
void SetCreatorModelID(const G4int id)
G4int GetParentID() const
void SetParentResonanceDef(const G4ParticleDefinition *parent)
void ProposeTrackStatus(G4TrackStatus status)
void SetSecondaryWeightByProcess(G4bool)
void ProposeWeight(G4double finalWeight)
G4int GetNumberOfSecondaries() const
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
void SetNumberOfSecondaries(G4int totSecondaries)
G4Track * GetSecondary(G4int anIndex) const
G4TrackStatus GetTrackStatus() const
const G4String & GetName() const
G4double currentInteractionLength
G4double theInitialNumberOfInteractionLength
const G4VProcess * GetMasterProcess() const
G4double theNumberOfInteractionLengthLeft
void SetProcessSubType(G4int)
G4double GetTotalNumberOfInteractionLengthTraversed() const
G4int GetProcessSubType() const
const G4String & GetProcessName() const