94 theInteraction =
nullptr;
98 theInitialNumberOfInteractionLength = 0.0;
102 useIntegralXS =
true;
103 theLastCrossSection = 0.0;
104 G4HadronicProcess_debug_flag =
false;
105 GetEnergyMomentumCheckEnvvars();
118 theInteraction =
nullptr;
122 theInitialNumberOfInteractionLength = 0.0;
125 useIntegralXS =
true;
127 theLastCrossSection = 0.0;
128 G4HadronicProcess_debug_flag =
false;
129 GetEnergyMomentumCheckEnvvars();
137 delete theCrossSectionDataStore;
140 void G4HadronicProcess::GetEnergyMomentumCheckEnvvars() {
141 levelsSetByProcess =
false;
144 strtol(getenv(
"G4Hadronic_epReportLevel"),0,10) : 0;
146 epCheckLevels.first = getenv(
"G4Hadronic_epCheckRelativeLevel") ?
147 strtod(getenv(
"G4Hadronic_epCheckRelativeLevel"),0) :
DBL_MAX;
149 epCheckLevels.second = getenv(
"G4Hadronic_epCheckAbsoluteLevel") ?
150 strtod(getenv(
"G4Hadronic_epCheckAbsoluteLevel"),0) :
DBL_MAX;
185 if(nMatWarn < nmax) {
188 <<
" because no material defined \n"
189 <<
" Please, specify material pointer or define simple material"
203 if(getenv(
"G4HadronicProcess_debug")) {
204 G4HadronicProcess_debug_flag =
true;
220 ed <<
" hadronic initialisation fails";
221 G4Exception(
"G4HadronicProcess::BuildPhysicsTable",
"had000",
234 theLastCrossSection = aScaleFactor*
243 ed <<
" Cross section is not available" <<
G4endl;
247 G4double res = (theLastCrossSection > 0.0) ? 1.0/theLastCrossSection :
DBL_MAX;
273 xs = aScaleFactor*theCrossSectionDataStore->
GetCrossSection(aParticle,aMaterial);
280 ed <<
" Cross section is not available" <<
G4endl;
283 if(xs <= 0.0 || (useIntegralXS && xs < theLastCrossSection*
G4UniformRand())) {
292 anElement = theCrossSectionDataStore->
SampleZandA(aParticle,
301 ed <<
" PostStepDoIt failed on element selection" <<
G4endl;
314 ed <<
"G4HadronicProcess: track in unusable state - "
316 ed <<
"G4HadronicProcess: returning unchanged track " <<
G4endl;
336 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
339 DumpState(aTrack,
"ChooseHadronicInteraction",ed);
340 ed <<
" No HadronicInteraction found out" <<
G4endl;
346 G4int reentryCount = 0;
365 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
369 ed <<
" ApplyYourself failed" <<
G4endl;
377 if(reentryCount>100) {
380 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
384 ed <<
" ApplyYourself does not completed after 100 attempts" <<
G4endl;
398 for (
G4int i = 0; i < nSec; ++i ) {
407 dynamicParticle->
SetMass( dynamicMass );
437 outFile <<
"The description for this process has not been written yet.\n";
441 G4double G4HadronicProcess::XBiasSurvivalProbability()
445 G4double biasedProbability = 1.-std::exp(-nLTraversed);
446 G4double realProbability = 1-std::exp(-nLTraversed/aScaleFactor);
447 result = (biasedProbability-realProbability)/biasedProbability;
451 G4double G4HadronicProcess::XBiasSecondaryWeight()
456 1./aScaleFactor*std::exp(-nLTraversed/aScaleFactor*(1-1./aScaleFactor));
469 if(efinal < 0.0) { efinal = 0.0; }
477 }
else if(0.0 == efinal) {
489 G4double newP = std::sqrt(efinal*(efinal + 2*mass));
492 newP4.
rotate(rotation, it);
495 newE = newP4.
e() - mass;
496 if(G4HadronicProcess_debug_flag && newE <= 0.0) {
498 DumpState(aT,
"Primary has zero energy after interaction",ed);
501 if(newE < 0.0) { newE = 0.0; }
515 for (
G4int i = 0; i < nSec; ++i) {
517 theM.
rotate(rotation, it);
523 if (time < 0.0) { time = 0.0; }
545 if (G4HadronicProcess_debug_flag) {
549 DumpState(aT,
"Secondary has zero energy",ed);
552 G4Exception(
"G4HadronicProcess::FillResults",
"had011",
565 aScaleFactor = aScale;
567 if ((it !=
"photonNuclear") &&
568 (it !=
"electronNuclear") &&
569 (it !=
"positronNuclear") ) {
571 G4Exception(
"G4HadronicProcess::BiasCrossSectionByFactor",
"had009",
573 "Cross-section biasing available only for gamma and electro nuclear reactions.");
579 "Cross-section bias readjusted to be above safe limit. New value is 100");
613 for (
G4int i = 0; i < nSec; i++) {
618 if ( std::abs(mass_pdg - mass_dyn) > 0.1*mass_pdg + 1.*
MeV){
622 desc <<
"Warning: Secondary with off-shell dynamic mass detected: " <<
G4endl
624 <<
", PDG mass: " << mass_pdg <<
", dynamic mass: "<< mass_dyn <<
G4endl
631 <<
", target nucleus (" << aNucleus.
GetZ_asInt() <<
", "
633 G4Exception(
"G4HadronicProcess:CheckResult()",
"had012",
641 std::pair<G4double, G4double> checkLevels =
643 if (std::abs(deltaE) > checkLevels.second &&
649 desc <<
"Warning: Bad energy non-conservation detected, will "
656 <<
", target nucleus (" << aNucleus.
GetZ_asInt() <<
", "
658 <<
" E(initial - final) = " << deltaE <<
" MeV." <<
G4endl;
659 G4Exception(
"G4HadronicProcess:CheckResult()",
"had012",
679 G4int initial_A = target_A + track_A;
680 G4int initial_Z = target_Z + track_Z;
686 G4int final_A(0), final_Z(0);
716 for (
G4int i = 0; i < nSec; i++) {
729 std::pair<G4double, G4double> checkLevels = epCheckLevels;
730 if (!levelsSetByProcess) {
732 checkLevels.first=
std::min(checkLevels.first, epCheckLevels.first);
733 checkLevels.second=
std::min(checkLevels.second, epCheckLevels.second);
749 if ( std::abs(relative) > checkLevels.first
750 || std::abs(relative_mom) > checkLevels.first) {
752 relResult = checkRelative ?
"fail" :
"N/A";
757 if ( std::abs(absolute) > checkLevels.second
758 || std::abs(absolute_mom) > checkLevels.second ) {
765 if ( (initial_A-final_A)!=0
766 || (initial_Z-final_Z)!=0 ) {
767 chargePass = checkLevels.second <
DBL_MAX ?
false :
true;
768 chargeResult =
"fail";
771 G4bool conservationPass = (relPass || absPass) && chargePass;
773 std::stringstream Myout;
774 G4bool Myout_notempty(
false);
785 Myout <<
" Process: " << processName <<
" , Model: " << modelName <<
G4endl;
789 <<
", target nucleus (" << aNucleus.
GetZ_asInt() <<
","
795 || ! conservationPass ){
797 Myout <<
" "<< relResult <<
" relative, limit " << checkLevels.
first <<
", values E/T(0) = "
798 << relative <<
" p/p(0)= " << relative_mom <<
G4endl;
799 Myout <<
" "<< absResult <<
" absolute, limit (MeV) " << checkLevels.second/
MeV <<
", values E / p (MeV) = "
800 << absolute/
MeV <<
" / " << absolute_mom/
MeV <<
" 3mom: " << (diff.
vect())*1./
MeV << G4endl;
801 Myout <<
" "<< chargeResult <<
" charge/baryon number balance " << (initial_Z-final_Z) <<
" / " << (initial_A-final_A) <<
" "<<
G4endl;
806 if ( Myout_notempty ) {
817 ed <<
"Unrecoverable error in the method " << method <<
" of "
819 ed <<
"TrackID= "<< aTrack.
GetTrackID() <<
" ParentID= "
G4double G4ParticleHPJENDLHEData::G4double result
G4ParticleDefinition * GetDefinition() const
G4int GetParentID() const
static G4double GetNuclearMass(const G4double A, const G4double Z)
G4int GetNumberOfSecondaries() const
void RegisterMe(G4HadronicInteraction *a)
G4Track * GetSecondary(G4int anIndex) const
void RegisterInteraction(G4HadronicProcess *, G4HadronicInteraction *)
std::ostringstream G4ExceptionDescription
G4HadSecondary * GetSecondary(size_t i)
G4double GetTotalEnergy() const
G4LorentzRotation & GetTrafoToLab()
void BiasCrossSectionByFactor(G4double aScale)
static G4HadronicProcessStore * Instance()
const G4DynamicParticle * GetDynamicParticle() const
static G4KaonZero * Definition()
std::vector< ExP01TrackerHit * > a
static G4AntiKaonZero * Definition()
virtual const std::pair< G4double, G4double > GetFatalEnergyCheckLevels() const
const G4String & GetName() const
G4double GetElementCrossSection(const G4DynamicParticle *part, const G4Element *elm, const G4Material *mat=nullptr)
const G4ThreeVector & GetMomentumChange() const
const G4ThreeVector & GetPosition() const
G4TrackStatus GetTrackStatus() const
virtual void PreparePhysicsTable(const G4ParticleDefinition &)
void SetTouchableHandle(const G4TouchableHandle &apValue)
G4int GetPDGEncoding() const
G4double GetEnergyChange() const
G4ParticleDefinition * GetDefinition() const
const G4ThreeVector * GetMomentumDirection() const
void CheckEnergyMomentumConservation(const G4Track &, const G4Nucleus &)
const G4String & GetModelName() const
void ClearNumberOfInteractionLengthLeft()
static G4NistManager * Instance()
const G4String & GetParticleName() const
G4int GetCreatorModelType() const
void SetWeight(G4double aValue)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
void SetCreatorModelIndex(G4int idx)
void RegisterMe(G4HadronicInteraction *a)
void ProposeWeight(G4double finalWeight)
virtual void BuildPhysicsTable(const G4ParticleDefinition &)
const G4LorentzRotation & GetTrafoToLab() const
void SetSecondaryWeightByProcess(G4bool)
void DumpState(const G4Track &, const G4String &, G4ExceptionDescription &)
void SetTrafoToLab(const G4LorentzRotation &aT)
G4ProcessVector * GetAtRestProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const
G4double GetKineticEnergy() const
void FillResult(G4HadFinalState *aR, const G4Track &aT)
G4GLOB_DLL std::ostream G4cout
G4double GetTotalNumberOfInteractionLengthTraversed() const
G4ParticleChange * theTotalResult
const G4ParticleDefinition * GetDefinition() const
void Register(G4HadronicProcess *)
const G4String & GetName() const
G4double GetMeanFreePath(const G4Track &aTrack, G4double, G4ForceCondition *)
static constexpr double mm
virtual std::pair< G4double, G4double > GetEnergyMomentumCheckLevels() const
G4double GetKineticEnergy() const
G4double GetCrossSection(const G4DynamicParticle *, const G4Material *)
const G4ParticleDefinition * GetParticleDefinition() const
void SetProcessSubType(G4int)
const G4ParticleDefinition * GetParticleDefinition() const
virtual void ProcessDescription(std::ostream &outFile) const
G4double GetGlobalTime() const
static G4KaonZeroLong * Definition()
static const char * G4Hadronic_Random_File
void RegisterParticle(G4HadronicProcess *, const G4ParticleDefinition *)
const G4String & GetProcessName() const
const G4LorentzVector & Get4Momentum() const
void DeRegister(G4HadronicProcess *)
HepLorentzVector & rotate(double, const Hep3Vector &)
const G4TouchableHandle & GetTouchableHandle() const
G4LorentzVector Get4Momentum() const
G4Material * GetMaterial() const
void Initialise(const G4Track &aT)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
void Set4Momentum(const G4LorentzVector &momentum)
void BuildPhysicsTable(const G4ParticleDefinition &)
G4ThreeVector GetMomentum() const
virtual void Initialize(const G4Track &)
static constexpr double GeV
const G4ThreeVector & GetMomentumDirection() const
G4HadronicInteraction * GetHadronicInteraction() const
G4double GetPDGMass() const
T max(const T t1, const T t2)
brief Return the largest of the two arguments
G4ProcessManager * GetProcessManager() const
void SetNumberOfSecondaries(G4int totSecondaries)
static void saveEngineStatus(const char filename[]="Config.conf")
virtual ~G4HadronicProcess()
G4DynamicParticle * GetParticle()
void BuildPhysicsTable(const G4ParticleDefinition &)
static G4KaonZeroShort * Definition()
void ProposeEnergy(G4double finalEnergy)
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4VPhysicalVolume * GetVolume() const
void AddSecondary(G4Track *aSecondary)
G4double GetWeight() const
G4HadronicInteraction * ChooseHadronicInteraction(const G4HadProjectile &aHadProjectile, G4Nucleus &aTargetNucleus, G4Material *aMaterial, G4Element *anElement)
G4double GetEnergy() const
G4HadronicProcess(const G4String &processName="Hadronic", G4ProcessType procType=fHadronic)
static constexpr double MeV
G4TrackStatus GetTrackStatus() const
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
G4Element * SampleZandA(const G4DynamicParticle *, const G4Material *, G4Nucleus &target)
void SetKineticEnergy(const G4double aValue)
void ProposeTrackStatus(G4TrackStatus status)
const G4String & GetName() const
void SetDefinition(const G4ParticleDefinition *aParticleDefinition)
virtual G4VParticleChange * PostStepDoIt(const G4Track &aTrack, const G4Step &aStep)
G4double GetPDGCharge() const
void SetMass(G4double mass)
void Report(std::ostream &aS)
static constexpr double twopi
G4int GetNumberOfSecondaries() const
virtual G4HadFinalState * ApplyYourself(const G4HadProjectile &aTrack, G4Nucleus &targetNucleus)=0
G4Material * FindSimpleMaterial(G4int Z) const
G4double GetLocalEnergyDeposit() const
void SetMomentumDirection(const G4ThreeVector &aValue)
G4HadFinalState * CheckResult(const G4HadProjectile &thePro, const G4Nucleus &targetNucleus, G4HadFinalState *result)
G4GLOB_DLL std::ostream G4cerr
G4int GetBaryonNumber() const
G4HadFinalStateStatus GetStatusChange() const
void PrintInfo(const G4ParticleDefinition *)
G4double GetTotalEnergy() const
G4double GetWeight() const