79static 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;
129void 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";
356G4double G4HadronicProcess::XBiasSurvivalProbability()
360 G4double biasedProbability = 1.-std::exp(-nLTraversed);
361 G4double realProbability = 1-std::exp(-nLTraversed/aScaleFactor);
362 result = (biasedProbability-realProbability)/biasedProbability;
366G4double 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) = "
810 << absolute/MeV <<
" / " << absolute_mom/MeV <<
G4endl;
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 <<
";";
@ fKillTrackAndSecondaries
G4DLLIMPORT std::ostream G4cerr
G4DLLIMPORT std::ostream G4cout
HepLorentzVector & rotate(double, const Hep3Vector &)
static void saveEngineStatus(const char filename[]="Config.conf")
void BuildPhysicsTable(const G4ParticleDefinition &)
G4Element * SampleZandA(const G4DynamicParticle *, const G4Material *, G4Nucleus &target)
G4double GetCrossSection(const G4DynamicParticle *, const G4Material *)
const G4ParticleDefinition * GetParticleDefinition() const
G4ParticleDefinition * GetDefinition() const
G4LorentzVector Get4Momentum() const
G4double GetKineticEnergy() const
G4double GetTotalEnergy() const
void Set4Momentum(const G4LorentzVector &momentum)
const G4String & GetName() const
void RegisterMe(G4HadronicInteraction *a)
G4double GetEnergyChange() const
const G4LorentzRotation & GetTrafoToLab() const
G4HadFinalStateStatus GetStatusChange() const
void SetTrafoToLab(const G4LorentzRotation &aT)
G4double GetLocalEnergyDeposit() const
G4int GetNumberOfSecondaries() const
const G4ThreeVector & GetMomentumChange() 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
void Report(std::ostream &aS)
virtual const std::pair< G4double, G4double > GetFatalEnergyCheckLevels() const
virtual std::pair< G4double, G4double > GetEnergyMomentumCheckLevels() const
virtual G4HadFinalState * ApplyYourself(const G4HadProjectile &aTrack, G4Nucleus &targetNucleus)=0
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)
void BiasCrossSectionByFactor(G4double aScale)
G4double GetMeanFreePath(const G4Track &aTrack, G4double, G4ForceCondition *)
G4HadronicInteraction * GetHadronicInteraction() const
G4ParticleChange * theTotalResult
virtual G4VParticleChange * PostStepDoIt(const G4Track &aTrack, const G4Step &aStep)
G4EnergyRangeManager * GetManagerPointer()
virtual ~G4HadronicProcess()
virtual void BuildPhysicsTable(const G4ParticleDefinition &)
G4HadronicProcess(const G4String &processName="Hadronic", G4ProcessType procType=fHadronic)
void CheckEnergyMomentumConservation(const G4Track &, const G4Nucleus &)
G4HadronicInteraction * ChooseHadronicInteraction(G4double kineticEnergy, G4Material *aMaterial, G4Element *anElement)
G4double GetElementCrossSection(const G4DynamicParticle *part, const G4Element *elm, const G4Material *mat=0)
void DumpState(const G4Track &, const G4String &, G4ExceptionDescription &)
G4HadFinalState * CheckResult(const G4HadProjectile &thePro, const G4Nucleus &targetNucleus, G4HadFinalState *result) const
virtual void ProcessDescription(std::ostream &outFile) const
void RegisterMe(G4HadronicInteraction *a)
virtual void PreparePhysicsTable(const G4ParticleDefinition &)
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
G4double GetPDGMass() const
G4int GetPDGEncoding() 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
G4int GetParentID() const
void SetKineticEnergy(const G4double aValue)
void SetMomentumDirection(const G4ThreeVector &aValue)
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
G4ParticleChange aParticleChange
void ClearNumberOfInteractionLengthLeft()
void SetProcessSubType(G4int)
G4double GetTotalNumberOfInteractionLengthTraversed() const
const G4String & GetProcessName() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
std::ostringstream G4ExceptionDescription