79 static const char* G4Hadronic_Random_File = getenv(
"G4HADRONIC_RANDOM_FILE");
96 G4HadronicProcess_debug_flag =
false;
98 GetEnergyMomentumCheckEnvvars();
116 G4HadronicProcess_debug_flag =
false;
118 GetEnergyMomentumCheckEnvvars();
126 delete theCrossSectionDataStore;
129 void G4HadronicProcess::GetEnergyMomentumCheckEnvvars() {
130 levelsSetByProcess =
false;
133 strtol(getenv(
"G4Hadronic_epReportLevel"),0,10) : 0;
135 epCheckLevels.first = getenv(
"G4Hadronic_epCheckRelativeLevel") ?
136 strtod(getenv(
"G4Hadronic_epCheckRelativeLevel"),0) :
DBL_MAX;
138 epCheckLevels.second = getenv(
"G4Hadronic_epCheckAbsoluteLevel") ?
139 strtod(getenv(
"G4Hadronic_epCheckAbsoluteLevel"),0) :
DBL_MAX;
160 if(getenv(
"G4HadronicProcess_debug")) {
161 G4HadronicProcess_debug_flag =
true;
176 ed <<
" hadronic initialisation fails" <<
G4endl;
177 G4Exception(
"G4HadronicProcess::BuildPhysicsTable",
"had000",
188 theLastCrossSection = aScaleFactor*
197 ed <<
" Cross section is not available" <<
G4endl;
202 if( theLastCrossSection > 0.0 ) { res = 1.0/theLastCrossSection; }
223 anElement = theCrossSectionDataStore->
SampleZandA(aParticle,
232 ed <<
" PostStepDoIt failed on element selection" <<
G4endl;
252 ed <<
"G4HadronicProcess: track in unusable state - "
254 ed <<
"G4HadronicProcess: returning unchanged track " <<
G4endl;
265 G4double kineticEnergy = originalEnergy;
280 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
283 DumpState(aTrack,
"ChooseHadronicInteraction",ed);
284 ed <<
" No HadronicInteraction found out" <<
G4endl;
292 G4int reentryCount = 0;
299 if (G4Hadronic_Random_File) {
311 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
315 ed <<
" ApplyYourself failed" <<
G4endl;
323 if(reentryCount>100) {
326 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
330 ed <<
" ApplyYourself does not completed after 100 attempts" <<
G4endl;
352 outFile <<
"The description for this process has not been written yet.\n";
356 G4double G4HadronicProcess::XBiasSurvivalProbability()
360 G4double biasedProbability = 1.-std::exp(-nLTraversed);
361 G4double realProbability = 1-std::exp(-nLTraversed/aScaleFactor);
362 result = (biasedProbability-realProbability)/biasedProbability;
366 G4double G4HadronicProcess::XBiasSecondaryWeight()
371 1./aScaleFactor*std::exp(-nLTraversed/aScaleFactor*(1-1./aScaleFactor));
384 if(efinal < 0.0) { efinal = 0.0; }
392 }
else if(0.0 == efinal) {
404 G4double newP = std::sqrt(efinal*(efinal + 2*mass));
407 newP4.
rotate(rotation, it);
410 newE = newP4.
e() - mass;
411 if(G4HadronicProcess_debug_flag && newE <= 0.0) {
413 DumpState(aT,
"Primary has zero energy after interaction",ed);
416 if(newE < 0.0) { newE = 0.0; }
427 for (
G4int i = 0; i < nSec; ++i) {
429 theM.
rotate(rotation, it);
435 if (time < 0.0) { time = 0.0; }
456 if (G4HadronicProcess_debug_flag) {
460 DumpState(aT,
"Secondary has zero energy",ed);
608 aScaleFactor = aScale;
610 if( (it !=
"PhotonInelastic") &&
611 (it !=
"ElectroNuclear") &&
612 (it !=
"PositronNuclear") )
616 "Cross-section biasing available only for gamma and electro nuclear reactions.");
622 "Cross-section bias readjusted to be above safe limit. New value is 100");
652 for (
G4int i = 0; i < nSec; i++) {
658 if (std::abs(deltaE) > checkLevels.second && std::abs(deltaE) > checkLevels.first*aPro.
GetKineticEnergy()){
662 desc <<
"Warning: Bad energy non-conservation detected, will "
669 <<
" E(initial - final) = " << deltaE <<
" MeV." <<
G4endl;
689 G4int initial_A = target_A + track_A;
690 G4int initial_Z = target_Z + track_Z;
696 G4int final_A(0), final_Z(0);
726 for (
G4int i = 0; i < nSec; i++) {
739 std::pair<G4double, G4double> checkLevels = epCheckLevels;
740 if (!levelsSetByProcess) {
742 checkLevels.first=
std::min(checkLevels.first, epCheckLevels.first);
743 checkLevels.second=
std::min(checkLevels.second, epCheckLevels.second);
759 if ( std::abs(relative) > checkLevels.first
760 || std::abs(relative_mom) > checkLevels.first) {
762 relResult = checkRelative ?
"fail" :
"N/A";
767 if ( std::abs(absolute) > checkLevels.second
768 || std::abs(absolute_mom) > checkLevels.second ) {
775 if ( (initial_A-final_A)!=0
776 || (initial_Z-final_Z)!=0 ) {
777 chargePass = checkLevels.second <
DBL_MAX ?
false :
true;
778 chargeResult =
"fail";
781 G4bool conservationPass = (relPass || absPass) && chargePass;
783 std::stringstream Myout;
784 G4bool Myout_notempty(
false);
795 Myout <<
" Process: " << processName <<
" , Model: " << modelName <<
G4endl;
799 <<
", target nucleus (" << aNucleus.
GetZ_asInt() <<
","
805 || ! conservationPass ){
807 Myout <<
" "<< relResult <<
" relative, limit " << checkLevels.
first <<
", values E/T(0) = "
808 << relative <<
" p/p(0)= " << relative_mom <<
G4endl;
809 Myout <<
" "<< absResult <<
" absolute, limit (MeV) " << checkLevels.second/
MeV <<
", values E / p (MeV) = "
811 Myout <<
" "<< chargeResult <<
" charge/baryon number balance " << (initial_Z-final_Z) <<
" / " << (initial_A-final_A) <<
" "<<
G4endl;
816 if ( Myout_notempty ) {
827 ed <<
"Unrecoverable error in the method " << method <<
" of "
829 ed <<
"TrackID= "<< aTrack.
GetTrackID() <<
" ParentID= "
835 ed <<
"Position(mm)= " << aTrack.
GetPosition()/CLHEP::mm <<
";";
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 GetKineticEnergy() const
G4double GetTotalEnergy() const
G4LorentzRotation & GetTrafoToLab()
void BiasCrossSectionByFactor(G4double aScale)
static G4HadronicProcessStore * Instance()
const G4DynamicParticle * GetDynamicParticle() const
virtual const std::pair< G4double, G4double > GetFatalEnergyCheckLevels() const
const G4String & GetName() const
const G4ThreeVector & GetPosition() const
G4TrackStatus GetTrackStatus() const
G4double G4NeutronHPJENDLHEData::G4double result
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()
G4ProcessManager * GetProcessManager() const
const G4String & GetParticleName() const
G4EnergyRangeManager * GetManagerPointer()
void SetWeight(G4double aValue)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
void RegisterMe(G4HadronicInteraction *a)
void ProposeWeight(G4double finalWeight)
virtual void BuildPhysicsTable(const G4ParticleDefinition &)
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 *)
virtual std::pair< G4double, G4double > GetEnergyMomentumCheckLevels() const
G4double GetKineticEnergy() const
G4HadronicInteraction * ChooseHadronicInteraction(G4double kineticEnergy, G4Material *aMaterial, G4Element *anElement)
G4HadFinalState * CheckResult(const G4HadProjectile &thePro, const G4Nucleus &targetNucleus, G4HadFinalState *result) 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
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 &)
G4double GetElementCrossSection(const G4DynamicParticle *part, const G4Element *elm, const G4Material *mat=0)
const G4ThreeVector & GetMomentumDirection() const
G4HadronicInteraction * GetHadronicInteraction() const
G4double GetPDGMass() const
const G4ThreeVector & GetMomentumChange() const
void SetNumberOfSecondaries(G4int totSecondaries)
static void saveEngineStatus(const char filename[]="Config.conf")
virtual ~G4HadronicProcess()
G4DynamicParticle * GetParticle()
void ProposeEnergy(G4double finalEnergy)
G4ParticleChange aParticleChange
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
G4double GetEnergy() const
G4HadronicProcess(const G4String &processName="Hadronic", G4ProcessType procType=fHadronic)
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
virtual G4VParticleChange * PostStepDoIt(const G4Track &aTrack, const G4Step &aStep)
G4double GetPDGCharge() const
void Report(std::ostream &aS)
G4int GetNumberOfSecondaries() const
virtual G4HadFinalState * ApplyYourself(const G4HadProjectile &aTrack, G4Nucleus &targetNucleus)=0
G4double GetLocalEnergyDeposit() const
void SetMomentumDirection(const G4ThreeVector &aValue)
G4GLOB_DLL std::ostream G4cerr
G4int GetBaryonNumber() const
G4HadFinalStateStatus GetStatusChange() const
void PrintInfo(const G4ParticleDefinition *)
const G4LorentzRotation & GetTrafoToLab() const
G4double GetTotalEnergy() const
G4double GetWeight() const