81 constexpr G4double lambdaFactor = 0.8;
82 constexpr G4double invLambdaFactor = 1.0/lambdaFactor;
105 theProcessStore->DeRegister(
this);
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; }
139 theEnergyRangeManager.RegisterMe( a );
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; }
168 theProcessStore->RegisterParticle(
this, &p);
173 if(firstParticle != &p) {
return; }
176 theEnergyRangeManager.BuildPhysicsTable(p);
189 if(
nullptr == masterProcess) {
194 if(isMaster ||
nullptr == masterProcess) {
198 if(charge != 0.0 && useIntegralXS) {
200 currentParticle = firstParticle;
203 if (std::abs(pdg) == 211) {
205 }
else if (pdg == 321) {
207 }
else if (pdg == -321) {
209 }
else if (pdg == 2212) {
211 }
else if (pdg == -2212 || pdg == -1000010020 || pdg == -1000010030 ||
212 pdg == -1000020030 || pdg == -1000020040) {
214 }
else if (charge > 0.0 || pdg == 11 || pdg == 13) {
218 delete theEnergyOfCrossSectionMax;
219 theEnergyOfCrossSectionMax =
nullptr;
221 if (fXSpeaks !=
nullptr) {
222 for (
auto const& e : *fXSpeaks ) {
229 if(
nullptr == fXSpeaks) {
234 theEnergyOfCrossSectionMax =
236 if(
nullptr == theEnergyOfCrossSectionMax) {
243 fXSType = masterProcess->CrossSectionType();
244 fXSpeaks = masterProcess->TwoPeaksXS();
245 theEnergyOfCrossSectionMax = masterProcess->EnergyOfCrossSectionMax();
248 G4cout <<
"G4HadronicProcess::BuildPhysicsTable: for "
257 currentMat =
nullptr;
271 if(mat != currentMat) {
305 return (xs > 0.0) ? 1.0/xs :
DBL_MAX;
351 ed <<
"G4HadronicProcess: track in unusable state - "
353 ed <<
"G4HadronicProcess: returning unchanged track " <<
G4endl;
362 thePro.Initialise(aTrack);
365 aMaterial, anElement);
366 if(
nullptr == theInteraction) {
368 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
369 << targetNucleus.GetZ_asInt() <<
" A= "
370 << targetNucleus.GetA_asInt() <<
G4endl;
371 DumpState(aTrack,
"ChooseHadronicInteraction",ed);
372 ed <<
" No HadronicInteraction found out" <<
G4endl;
373 G4Exception(
"G4HadronicProcess::PostStepDoIt",
"had005",
379 G4int reentryCount = 0;
393 result = theInteraction->ApplyYourself(
thePro, targetNucleus);
400 ed <<
"Call for " << theInteraction->GetModelName() <<
G4endl;
401 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
402 << targetNucleus.GetZ_asInt()
403 <<
" A= " << targetNucleus.GetA_asInt() <<
G4endl;
405 ed <<
" ApplyYourself failed" <<
G4endl;
413 if(reentryCount>100) {
415 ed <<
"Call for " << theInteraction->GetModelName() <<
G4endl;
416 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
417 << targetNucleus.GetZ_asInt()
418 <<
" A= " << targetNucleus.GetA_asInt() <<
G4endl;
420 ed <<
" ApplyYourself does not completed after 100 attempts" <<
G4endl;
436 for (
G4int i = 0; i < nSec; ++i ) {
444 dynamicParticle->SetDefinition( newPart );
461 outFile <<
"The description for this process has not been written yet.\n";
464G4double G4HadronicProcess::XBiasSurvivalProbability()
469 G4double result = (biasedProbability-realProbability)/biasedProbability;
473G4double G4HadronicProcess::XBiasSecondaryWeight()
495 }
else if(0.0 == efinal) {
520 for (
G4int i = 0; i < nSec; ++i) {
532 const G4double delta_mass_lim = 1.0*CLHEP::keV;
533 const G4double delta_ekin = 0.001*CLHEP::eV;
534 if(std::abs(dmass - mass) > delta_mass_lim) {
541 <<
" Target Z= " << targetNucleus.GetZ_asInt() <<
" A= "
542 << targetNucleus.GetA_asInt()
545 <<
" EkinNew(MeV)= " << e
546 <<
" DeltaMass(MeV)= " << dmass - mass <<
G4endl;
580 ed <<
" Wrong biasing factor " << aScale <<
" for " <<
GetProcessName();
581 G4Exception(
"G4HadronicProcess::BiasCrossSectionByFactor",
"had010",
596 if (
nullptr != theModel) {
616 for (
G4int i = 0; i < nSec; ++i) {
621 if ( std::abs(mass_pdg - mass_dyn) > 0.1*mass_pdg + 1.*MeV ) {
630 desc <<
"Warning: Secondary with off-shell dynamic mass detected: "
633 <<
", PDG mass: " << mass_pdg <<
", dynamic mass: "
636 :
"re-sample the interaction") <<
G4endl
642 <<
", target nucleus (" << aNucleus.
GetZ_asInt() <<
", "
644 G4Exception(
"G4HadronicProcess:CheckResult()",
"had012",
652 std::pair<G4double, G4double> checkLevels =
654 if (std::abs(deltaE) > checkLevels.second &&
660 desc <<
"Warning: Bad energy non-conservation detected, will "
662 :
"re-sample the interaction") <<
G4endl
668 <<
", target nucleus (" << aNucleus.
GetZ_asInt() <<
", "
670 <<
" E(initial - final) = " << deltaE <<
" MeV." <<
G4endl;
671 G4Exception(
"G4HadronicProcess:CheckResult()",
"had012",
686 + nICelectrons*CLHEP::electron_mass_c2);
692 G4int initial_A = target_A + track_A;
693 G4int initial_Z = target_Z + track_Z - nICelectrons;
699 G4int final_A(0), final_Z(0);
708 final4mom = initial4mom;
717 G4double ptot = std::sqrt(ekin*(ekin + 2*mass));
718 final4mom.
set(ptot*v.
x(), ptot*v.
y(), ptot*v.
z(), mass + ekin);
728 for (
G4int i = 0; i < nSec; i++) {
741 std::pair<G4double, G4double> checkLevels = epCheckLevels;
742 if (!levelsSetByProcess) {
744 checkLevels.first= std::min(checkLevels.first, epCheckLevels.first);
745 checkLevels.second=std::min(checkLevels.second, epCheckLevels.second);
761 if ( std::abs(relative) > checkLevels.first
762 || std::abs(relative_mom) > checkLevels.first) {
764 relResult = checkRelative ?
"fail" :
"N/A";
769 if ( std::abs(absolute) > checkLevels.second
770 || std::abs(absolute_mom) > checkLevels.second ) {
777 if ( (initial_A-final_A)!=0
778 || (initial_Z-final_Z)!=0 ) {
779 chargePass = checkLevels.second <
DBL_MAX ? false :
true;
780 chargeResult =
"fail";
783 G4bool conservationPass = (relPass || absPass) && chargePass;
785 std::stringstream Myout;
786 G4bool Myout_notempty(
false);
797 Myout <<
" Process: " << processName <<
" , Model: " << modelName <<
G4endl;
801 <<
", target nucleus (" << aNucleus.
GetZ_asInt() <<
","
807 || ! conservationPass ){
809 Myout <<
" "<< relResult <<
" relative, limit " << checkLevels.first <<
", values E/T(0) = "
810 << relative <<
" p/p(0)= " << relative_mom <<
G4endl;
811 Myout <<
" "<< absResult <<
" absolute, limit (MeV) " << checkLevels.second/MeV <<
", values E / p (MeV) = "
812 << absolute/MeV <<
" / " << absolute_mom/MeV <<
" 3mom: " << (diff.
vect())*1./MeV <<
G4endl;
813 Myout <<
" "<< chargeResult <<
" charge/baryon number balance " << (initial_Z-final_Z) <<
" / " << (initial_A-final_A) <<
" "<<
G4endl;
818 if ( Myout_notempty ) {
828 ed <<
"Unrecoverable error in the method " << method <<
" of "
830 ed <<
"TrackID= "<< aTrack.
GetTrackID() <<
" ParentID= "
836 ed <<
"Position(mm)= " << aTrack.
GetPosition()/CLHEP::mm <<
";";
859std::vector<G4HadronicInteraction*>&
862 return theEnergyRangeManager.GetHadronicInteractionList();
868 std::vector<G4HadronicInteraction*>& list
869 = theEnergyRangeManager.GetHadronicInteractionList();
870 for (
auto & mod : list) {
871 if (mod->GetModelName() == modelName)
return mod;
887void G4HadronicProcess::RecomputeXSandMFP(
const G4double kinEnergy)
896void G4HadronicProcess::UpdateCrossSectionAndMFP(
const G4double e)
908 if(e < mfpKinEnergy && mfpKinEnergy > minKinEnergy) {
909 G4double e1 = std::max(e*lambdaFactor, minKinEnergy);
911 RecomputeXSandMFP(e1);
915 G4double epeak = (*theEnergyOfCrossSectionMax)[matIdx];
922 G4double e1 = std::max(epeak, e*lambdaFactor);
924 RecomputeXSandMFP(e1);
928 G4TwoPeaksHadXS* xs = (*fXSpeaks)[matIdx];
943 const G4double e1 = std::max(e1peak, e*lambdaFactor);
945 RecomputeXSandMFP(e1);
962 const G4double e1 = std::max(e2peak, e*lambdaFactor);
964 RecomputeXSandMFP(e1);
979 const G4double e1 = std::max(e3peak, e*lambdaFactor);
981 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)
CLHEP::HepLorentzVector G4LorentzVector
CLHEP::Hep3Vector G4ThreeVector
@ 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()
G4double ComputeCrossSection(const G4DynamicParticle *, const G4Material *)
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
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)
const G4ParticleDefinition * GetDefinition() const
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 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
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)
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)
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)
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)
G4VDiscreteProcess(const G4String &aName, G4ProcessType aType=fNotDefined)
void SetSecondaryWeightByProcess(G4bool)
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