130 if ( std::getenv(
"G4Hadronic_epReportLevel") ) {
131 epReportLevel = std::strtol(std::getenv(
"G4Hadronic_epReportLevel"),0,10);
133 if ( std::getenv(
"G4Hadronic_epCheckRelativeLevel") ) {
134 epCheckLevels.first = std::strtod(std::getenv(
"G4Hadronic_epCheckRelativeLevel"),0);
136 if ( std::getenv(
"G4Hadronic_epCheckAbsoluteLevel") ) {
137 epCheckLevels.second = std::strtod(std::getenv(
"G4Hadronic_epCheckAbsoluteLevel"),0);
155 static const G4int nmax = 5;
160 <<
" because no material defined \n"
161 <<
" Please, specify material pointer or define simple material"
163 G4Exception(
"G4HadronicProcess::GetElementCrossSection",
"had066",
173 if(std::getenv(
"G4HadronicProcess_debug")) {
236 ed <<
"G4HadronicProcess: track in unusable state - "
238 ed <<
"G4HadronicProcess: returning unchanged track " <<
G4endl;
250 aMaterial, anElement);
253 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
256 DumpState(aTrack,
"ChooseHadronicInteraction",ed);
257 ed <<
" No HadronicInteraction found out" <<
G4endl;
263 G4int reentryCount = 0;
289 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
293 ed <<
" ApplyYourself failed" <<
G4endl;
301 if(reentryCount>100) {
304 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
308 ed <<
" ApplyYourself does not completed after 100 attempts" <<
G4endl;
322 for (
G4int i = 0; i < nSec; ++i ) {
359 outFile <<
"The description for this process has not been written yet.\n";
368 G4double result = (biasedProbability-realProbability)/biasedProbability;
394 }
else if(0.0 == efinal) {
419 for (
G4int i = 0; i < nSec; ++i) {
433 if(std::abs(dmass - mass) > delta_mass_lim) {
443 <<
" EkinNew(MeV)= " << e
444 <<
" DeltaMass(MeV)= " << dmass - mass <<
G4endl;
466 DumpState(aT,
"Secondary has zero energy",ed);
469 G4Exception(
"G4HadronicProcess::FillResults",
"had011",
487 ed <<
" Wrong biasing factor " << aScale <<
" for " <<
GetProcessName();
488 G4Exception(
"G4HadronicProcess::BiasCrossSectionByFactor",
"had010",
524 for (
G4int i = 0; i < nSec; i++) {
529 if ( std::abs(mass_pdg - mass_dyn) > 0.1*mass_pdg + 1.*
MeV ) {
538 desc <<
"Warning: Secondary with off-shell dynamic mass detected: "
541 <<
", PDG mass: " << mass_pdg <<
", dynamic mass: "
544 :
"re-sample the interaction") <<
G4endl
550 <<
", target nucleus (" << aNucleus.
GetZ_asInt() <<
", "
552 G4Exception(
"G4HadronicProcess:CheckResult()",
"had012",
560 std::pair<G4double, G4double> checkLevels =
562 if (std::abs(deltaE) > checkLevels.second &&
568 desc <<
"Warning: Bad energy non-conservation detected, will "
570 :
"re-sample the interaction") <<
G4endl
576 <<
", target nucleus (" << aNucleus.
GetZ_asInt() <<
", "
578 <<
" E(initial - final) = " << deltaE <<
" MeV." <<
G4endl;
579 G4Exception(
"G4HadronicProcess:CheckResult()",
"had012",
600 G4int initial_A = target_A + track_A;
607 G4int final_A(0), final_Z(0);
616 final4mom = initial4mom;
625 G4double ptot = std::sqrt(ekin*(ekin + 2*mass));
626 final4mom.
set(ptot*v.
x(), ptot*v.
y(), ptot*v.
z(), mass + ekin);
636 for (
G4int i = 0; i < nSec; i++) {
669 if ( std::abs(relative) > checkLevels.first
670 || std::abs(relative_mom) > checkLevels.first) {
672 relResult = checkRelative ?
"fail" :
"N/A";
677 if ( std::abs(absolute) > checkLevels.second
678 || std::abs(absolute_mom) > checkLevels.second ) {
685 if ( (initial_A-final_A)!=0
686 || (initial_Z-final_Z)!=0 ) {
687 chargePass = checkLevels.second <
DBL_MAX ? false :
true;
688 chargeResult =
"fail";
691 G4bool conservationPass = (relPass || absPass) && chargePass;
693 std::stringstream Myout;
694 G4bool Myout_notempty(
false);
705 Myout <<
" Process: " << processName <<
" , Model: " << modelName <<
G4endl;
709 <<
", target nucleus (" << aNucleus.
GetZ_asInt() <<
","
715 || ! conservationPass ){
717 Myout <<
" "<< relResult <<
" relative, limit " << checkLevels.first <<
", values E/T(0) = "
718 << relative <<
" p/p(0)= " << relative_mom <<
G4endl;
719 Myout <<
" "<< absResult <<
" absolute, limit (MeV) " << checkLevels.second/
MeV <<
", values E / p (MeV) = "
720 << absolute/
MeV <<
" / " << absolute_mom/
MeV <<
" 3mom: " << (diff.
vect())*1./
MeV <<
G4endl;
721 Myout <<
" "<< chargeResult <<
" charge/baryon number balance " << (initial_Z-final_Z) <<
" / " << (initial_A-final_A) <<
" "<<
G4endl;
726 if ( Myout_notempty ) {
736 ed <<
"Unrecoverable error in the method " << method <<
" of "
738 ed <<
"TrackID= "<< aTrack.
GetTrackID() <<
" ParentID= "
767std::vector<G4HadronicInteraction*>&
776 std::vector<G4HadronicInteraction*>& list
778 for (
size_t li=0; li<list.size(); li++) {
779 if (list[li]->GetModelName() == modelName)
return list[li];
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.
static const char * G4Hadronic_Random_File
static constexpr double MeV
@ fKillTrackAndSecondaries
G4GLOB_DLL std::ostream G4cerr
G4GLOB_DLL std::ostream G4cout
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 SetDefinition(const G4ParticleDefinition *aParticleDefinition)
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()
G4double GetWeight() const
G4int GetCreatorModelID() const
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
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
void BiasCrossSectionByFactor(G4double aScale)
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
G4double theInitialNumberOfInteractionLength
void CheckEnergyMomentumConservation(const G4Track &, const G4Nucleus &)
G4HadronicInteraction * GetHadronicModel(const G4String &)
G4EnergyRangeManager theEnergyRangeManager
G4double XBiasSecondaryWeight()
bool G4HadronicProcess_debug_flag
G4HadronicProcessStore * theProcessStore
G4HadronicInteraction * theInteraction
G4double XBiasSurvivalProbability()
void DumpState(const G4Track &, const G4String &, G4ExceptionDescription &)
void GetEnergyMomentumCheckEnvvars()
void DumpPhysicsTable(const G4ParticleDefinition &p)
G4bool levelsSetByProcess
void MultiplyCrossSectionBy(G4double factor)
std::pair< G4double, G4double > epCheckLevels
G4double theLastCrossSection
void RegisterMe(G4HadronicInteraction *a)
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
const G4ThreeVector * GetMomentumDirection() const
void ProposeEnergy(G4double finalEnergy)
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
virtual void Initialize(const G4Track &)
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)
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 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
void ClearNumberOfInteractionLengthLeft()
void SetProcessSubType(G4int)
G4double GetTotalNumberOfInteractionLengthTraversed() const
const G4String & GetProcessName() const
static constexpr double mm
static constexpr double electron_mass_c2
static constexpr double GeV
static constexpr double keV
static constexpr double eV
T max(const T t1, const T t2)
brief Return the largest of the two arguments
T min(const T t1, const T t2)
brief Return the smallest of the two arguments