81 constexpr G4double lambdaFactor = 0.8;
82 constexpr G4double invLambdaFactor = 1.0/lambdaFactor;
109 if (fXSpeaks !=
nullptr) {
110 for (
auto const& e : *fXSpeaks ) {
115 delete theEnergyOfCrossSectionMax;
119void G4HadronicProcess::InitialiseLocal() {
125 minKinEnergy = 1*CLHEP::MeV;
132 unitVector.
set(0.0, 0.0, 0.1);
138 if(
nullptr == a) {
return; }
150 static const G4int nmax = 5;
151 if(nMatWarn < nmax) {
155 <<
" because no material defined \n"
156 <<
" Please, specify material pointer or define simple material"
158 G4Exception(
"G4HadronicProcess::GetElementCrossSection",
"had066",
167 if(
nullptr == firstParticle) { firstParticle = &p; }
173 if(firstParticle != &p) {
return; }
189 if(
nullptr == masterProcess) {
192 if(
nullptr == masterProcess) {
195 ed <<
"G4HadronicProcess::BuildPhysicsTable: for "
197 <<
" fail due to undefined pointer to the master process \n"
199 <<
" initialisation of worker started before master initialisation";
200 G4Exception(
"G4HadronicProcess::BuildPhysicsTable",
"had066",
206 if(isMaster ||
nullptr == masterProcess) {
210 if(charge != 0.0 && useIntegralXS) {
212 currentParticle = firstParticle;
215 if (std::abs(pdg) == 211) {
217 }
else if (pdg == 321) {
219 }
else if (pdg == -321) {
221 }
else if (pdg == 2212) {
223 }
else if (pdg == -2212 || pdg == -1000010020 || pdg == -1000010030 ||
224 pdg == -1000020030 || pdg == -1000020040) {
226 }
else if (charge > 0.0 || pdg == 11 || pdg == 13) {
230 delete theEnergyOfCrossSectionMax;
231 theEnergyOfCrossSectionMax =
nullptr;
233 if (fXSpeaks !=
nullptr) {
234 for (
auto const& e : *fXSpeaks ) {
241 if(
nullptr == fXSpeaks) {
246 theEnergyOfCrossSectionMax =
248 if(
nullptr == theEnergyOfCrossSectionMax) {
260 G4cout <<
"G4HadronicProcess::BuildPhysicsTable: for "
269 currentMat =
nullptr;
283 if(mat != currentMat) {
317 return (xs > 0.0) ? 1.0/xs :
DBL_MAX;
363 ed <<
"G4HadronicProcess: track in unusable state - "
365 ed <<
"G4HadronicProcess: returning unchanged track " <<
G4endl;
377 aMaterial, anElement);
378 if(
nullptr == theInteraction) {
380 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
383 DumpState(aTrack,
"ChooseHadronicInteraction",ed);
384 ed <<
" No HadronicInteraction found out" <<
G4endl;
385 G4Exception(
"G4HadronicProcess::PostStepDoIt",
"had005",
391 G4int reentryCount = 0;
413 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
417 ed <<
" ApplyYourself failed" <<
G4endl;
425 if(reentryCount>100) {
428 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
432 ed <<
" ApplyYourself does not completed after 100 attempts" <<
G4endl;
448 for (
G4int i = 0; i < nSec; ++i ) {
456 dynamicParticle->SetDefinition( newPart );
457 if ( nKaonWarn < 1 ) {
461 ed <<
" created " << part->GetParticleName() <<
G4endl;
481 outFile <<
"The description for this process has not been written yet.\n";
484G4double G4HadronicProcess::XBiasSurvivalProbability()
489 G4double result = (biasedProbability-realProbability)/biasedProbability;
493G4double G4HadronicProcess::XBiasSecondaryWeight()
515 }
else if(0.0 == efinal) {
540 for (
G4int i = 0; i < nSec; ++i) {
552 const G4double delta_mass_lim = 1.0*CLHEP::keV;
553 const G4double delta_ekin = 0.001*CLHEP::eV;
554 if(std::abs(dmass - mass) > delta_mass_lim) {
561 <<
" Target Z= " << targetNucleus.
GetZ_asInt() <<
" A= "
565 <<
" EkinNew(MeV)= " << e
566 <<
" DeltaMass(MeV)= " << dmass - mass <<
G4endl;
600 ed <<
" Wrong biasing factor " << aScale <<
" for " <<
GetProcessName();
601 G4Exception(
"G4HadronicProcess::BiasCrossSectionByFactor",
"had010",
616 if (
nullptr != theModel) {
636 for (
G4int i = 0; i < nSec; ++i) {
641 if ( std::abs(mass_pdg - mass_dyn) > 0.1*mass_pdg + 1.*MeV ) {
650 desc <<
"Warning: Secondary with off-shell dynamic mass detected: "
653 <<
", PDG mass: " << mass_pdg <<
", dynamic mass: "
656 :
"re-sample the interaction") <<
G4endl
662 <<
", target nucleus (" << aNucleus.
GetZ_asInt() <<
", "
664 G4Exception(
"G4HadronicProcess:CheckResult()",
"had012",
672 std::pair<G4double, G4double> checkLevels =
674 if (std::abs(deltaE) > checkLevels.second &&
680 desc <<
"Warning: Bad energy non-conservation detected, will "
682 :
"re-sample the interaction") <<
G4endl
688 <<
", target nucleus (" << aNucleus.
GetZ_asInt() <<
", "
690 <<
" E(initial - final) = " << deltaE <<
" MeV." <<
G4endl;
691 G4Exception(
"G4HadronicProcess:CheckResult()",
"had012",
706 + nICelectrons*CLHEP::electron_mass_c2);
712 G4int initial_A = target_A + track_A;
713 G4int initial_Z = target_Z + track_Z - nICelectrons;
719 G4int final_A(0), final_Z(0);
728 final4mom = initial4mom;
737 G4double ptot = std::sqrt(ekin*(ekin + 2*mass));
738 final4mom.
set(ptot*v.
x(), ptot*v.
y(), ptot*v.
z(), mass + ekin);
748 for (
G4int i = 0; i < nSec; i++) {
761 std::pair<G4double, G4double> checkLevels = epCheckLevels;
762 if (!levelsSetByProcess) {
764 checkLevels.first= std::min(checkLevels.first, epCheckLevels.first);
765 checkLevels.second=std::min(checkLevels.second, epCheckLevels.second);
781 if ( std::abs(relative) > checkLevels.first
782 || std::abs(relative_mom) > checkLevels.first) {
784 relResult = checkRelative ?
"fail" :
"N/A";
789 if ( std::abs(absolute) > checkLevels.second
790 || std::abs(absolute_mom) > checkLevels.second ) {
797 if ( (initial_A-final_A)!=0
798 || (initial_Z-final_Z)!=0 ) {
799 chargePass = checkLevels.second <
DBL_MAX ? false :
true;
800 chargeResult =
"fail";
803 G4bool conservationPass = (relPass || absPass) && chargePass;
805 std::stringstream Myout;
806 G4bool Myout_notempty(
false);
817 Myout <<
" Process: " << processName <<
" , Model: " << modelName <<
G4endl;
821 <<
", target nucleus (" << aNucleus.
GetZ_asInt() <<
","
827 || ! conservationPass ){
829 Myout <<
" "<< relResult <<
" relative, limit " << checkLevels.first <<
", values E/T(0) = "
830 << relative <<
" p/p(0)= " << relative_mom <<
G4endl;
831 Myout <<
" "<< absResult <<
" absolute, limit (MeV) " << checkLevels.second/MeV <<
", values E / p (MeV) = "
832 << absolute/MeV <<
" / " << absolute_mom/MeV <<
" 3mom: " << (diff.
vect())*1./MeV <<
G4endl;
833 Myout <<
" "<< chargeResult <<
" charge/baryon number balance " << (initial_Z-final_Z) <<
" / " << (initial_A-final_A) <<
" "<<
G4endl;
838 if ( Myout_notempty ) {
848 ed <<
"Unrecoverable error in the method " << method <<
" of "
850 ed <<
"TrackID= "<< aTrack.
GetTrackID() <<
" ParentID= "
856 ed <<
"Position(mm)= " << aTrack.
GetPosition()/CLHEP::mm <<
";";
879std::vector<G4HadronicInteraction*>&
888 std::vector<G4HadronicInteraction*>& list
890 for (
auto & mod : list) {
891 if (mod->GetModelName() == modelName)
return mod;
907void G4HadronicProcess::RecomputeXSandMFP(
const G4double kinEnergy)
916void G4HadronicProcess::UpdateCrossSectionAndMFP(
const G4double e)
928 if(e < mfpKinEnergy && mfpKinEnergy > minKinEnergy) {
929 G4double e1 = std::max(e*lambdaFactor, minKinEnergy);
931 RecomputeXSandMFP(e1);
935 G4double epeak = (*theEnergyOfCrossSectionMax)[matIdx];
942 G4double e1 = std::max(epeak, e*lambdaFactor);
944 RecomputeXSandMFP(e1);
963 const G4double e1 = std::max(e1peak, e*lambdaFactor);
965 RecomputeXSandMFP(e1);
982 const G4double e1 = std::max(e2peak, e*lambdaFactor);
984 RecomputeXSandMFP(e1);
999 const G4double e1 = std::max(e3peak, e*lambdaFactor);
1001 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.
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 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
G4double GetEPRelativeLevel() const
G4double GetEPAbsoluteLevel() const
G4int GetEPReportLevel() 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()
std::size_t GetIndex() const
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
G4bool IsShortLived() const
G4double GetPDGMass() const
G4int GetPDGEncoding() 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