140 strtol(getenv(
"G4Hadronic_epReportLevel"),0,10) : 0;
142 epCheckLevels.first = getenv(
"G4Hadronic_epCheckRelativeLevel") ?
143 strtod(getenv(
"G4Hadronic_epCheckRelativeLevel"),0) :
DBL_MAX;
145 epCheckLevels.second = getenv(
"G4Hadronic_epCheckAbsoluteLevel") ?
146 strtod(getenv(
"G4Hadronic_epCheckAbsoluteLevel"),0) :
DBL_MAX;
181 if(x < 0.0) { x = 0.0; }
196 if(getenv(
"G4HadronicProcess_debug")) {
213 ed <<
" hadronic initialisation fails" <<
G4endl;
214 G4Exception(
"G4HadronicProcess::BuildPhysicsTable",
"had000",
236 ed <<
" Cross section is not available" <<
G4endl;
274 ed <<
" PostStepDoIt failed on element selection" <<
G4endl;
295 ed <<
"G4HadronicProcess: track in unusable state - "
297 ed <<
"G4HadronicProcess: returning unchanged track " <<
G4endl;
317 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
320 DumpState(aTrack,
"ChooseHadronicInteraction",ed);
321 ed <<
" No HadronicInteraction found out" <<
G4endl;
327 G4int reentryCount = 0;
346 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
350 ed <<
" ApplyYourself failed" <<
G4endl;
358 if(reentryCount>100) {
361 ed <<
"Target element "<<anElement->
GetName()<<
" Z= "
365 ed <<
" ApplyYourself does not completed after 100 attempts" <<
G4endl;
388 outFile <<
"The description for this process has not been written yet.\n";
396 G4double biasedProbability = 1.-std::exp(-nLTraversed);
398 result = (biasedProbability-realProbability)/biasedProbability;
420 if(efinal < 0.0) { efinal = 0.0; }
428 }
else if(0.0 == efinal) {
440 G4double newP = std::sqrt(efinal*(efinal + 2*mass));
443 newP4.rotate(rotation, it);
446 newE = newP4.e() - mass;
449 DumpState(aT,
"Primary has zero energy after interaction",ed);
452 if(newE < 0.0) { newE = 0.0; }
466 for (
G4int i = 0; i < nSec; ++i) {
468 theM.rotate(rotation, it);
474 if (time < 0.0) { time = 0.0; }
500 DumpState(aT,
"Secondary has zero energy",ed);
503 G4Exception(
"G4HadronicProcess::FillResults",
"had011",
518 if ((it !=
"photonNuclear") &&
519 (it !=
"electronNuclear") &&
520 (it !=
"positronNuclear") ) {
522 G4Exception(
"G4HadronicProcess::BiasCrossSectionByFactor",
"had009",
524 "Cross-section biasing available only for gamma and electro nuclear reactions.");
530 "Cross-section bias readjusted to be above safe limit. New value is 100");
564 for (
G4int i = 0; i < nSec; i++) {
569 if ( std::abs(mass_pdg - mass_dyn) > 0.1*mass_pdg + 1.*
MeV){
573 desc <<
"Warning: Secondary with off-shell dynamic mass detected: " <<
G4endl
575 <<
", PDG mass: " << mass_pdg <<
", dynamic mass: "<< mass_dyn <<
G4endl
582 <<
", target nucleus (" << aNucleus.
GetZ_asInt() <<
", "
584 G4Exception(
"G4HadronicProcess:CheckResult()",
"had012",
592 std::pair<G4double, G4double> checkLevels =
594 if (std::abs(deltaE) > checkLevels.second &&
600 desc <<
"Warning: Bad energy non-conservation detected, will "
607 <<
", target nucleus (" << aNucleus.
GetZ_asInt() <<
", "
609 <<
" E(initial - final) = " << deltaE <<
" MeV." <<
G4endl;
610 G4Exception(
"G4HadronicProcess:CheckResult()",
"had012",
630 G4int initial_A = target_A + track_A;
631 G4int initial_Z = target_Z + track_Z;
637 G4int final_A(0), final_Z(0);
667 for (
G4int i = 0; i < nSec; i++) {
694 G4double absolute_mom = diff.vect().mag();
700 if ( std::abs(relative) > checkLevels.first
701 || std::abs(relative_mom) > checkLevels.first) {
703 relResult = checkRelative ?
"fail" :
"N/A";
708 if ( std::abs(absolute) > checkLevels.second
709 || std::abs(absolute_mom) > checkLevels.second ) {
716 if ( (initial_A-final_A)!=0
717 || (initial_Z-final_Z)!=0 ) {
718 chargePass = checkLevels.second <
DBL_MAX ?
false :
true;
719 chargeResult =
"fail";
722 G4bool conservationPass = (relPass || absPass) && chargePass;
724 std::stringstream Myout;
725 G4bool Myout_notempty(
false);
736 Myout <<
" Process: " << processName <<
" , Model: " << modelName <<
G4endl;
740 <<
", target nucleus (" << aNucleus.
GetZ_asInt() <<
","
746 || ! conservationPass ){
748 Myout <<
" "<< relResult <<
" relative, limit " << checkLevels.
first <<
", values E/T(0) = "
749 << relative <<
" p/p(0)= " << relative_mom <<
G4endl;
750 Myout <<
" "<< absResult <<
" absolute, limit (MeV) " << checkLevels.second/
MeV <<
", values E / p (MeV) = "
751 << absolute/
MeV <<
" / " << absolute_mom/
MeV <<
" 3mom: " << (diff.vect())*1./
MeV << G4endl;
752 Myout <<
" "<< chargeResult <<
" charge/baryon number balance " << (initial_Z-final_Z) <<
" / " << (initial_A-final_A) <<
" "<<
G4endl;
757 if ( Myout_notempty ) {
768 ed <<
"Unrecoverable error in the method " << method <<
" of "
770 ed <<
"TrackID= "<< aTrack.
GetTrackID() <<
" ParentID= "
G4bool levelsSetByProcess
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)
CLHEP::Hep3Vector G4ThreeVector
G4double GetTotalEnergy() const
G4LorentzRotation & GetTrafoToLab()
void BiasCrossSectionByFactor(G4double aScale)
static G4HadronicProcessStore * Instance()
G4Material * FindOrBuildSimpleMaterial(G4int Z, G4bool warning=false)
const G4DynamicParticle * GetDynamicParticle() const
bool G4HadronicProcess_debug_flag
virtual const std::pair< G4double, G4double > GetFatalEnergyCheckLevels() const
const G4String & GetName() const
G4HadronicInteraction * theInteraction
const G4ThreeVector & GetMomentumChange() const
const G4ThreeVector & GetPosition() const
G4TrackStatus GetTrackStatus() const
G4EnergyRangeManager theEnergyRangeManager
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
static G4NistManager * Instance()
#define G4MUTEX_INITIALIZER
const G4String & GetParticleName() const
std::pair< G4double, G4double > epCheckLevels
G4int GetCreatorModelType() const
void SetWeight(G4double aValue)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
void GetEnergyMomentumCheckEnvvars()
void SetCreatorModelIndex(G4int idx)
void RegisterMe(G4HadronicInteraction *a)
void ProposeWeight(G4double finalWeight)
virtual void BuildPhysicsTable(const G4ParticleDefinition &)
const G4LorentzRotation & GetTrafoToLab() const
void SetSecondaryWeightByProcess(G4bool)
G4CrossSectionDataStore * theCrossSectionDataStore
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 *)
G4double XBiasSurvivalProbability()
virtual std::pair< G4double, G4double > GetEnergyMomentumCheckLevels() const
G4double GetKineticEnergy() const
static const double twopi
G4double theInitialNumberOfInteractionLength
G4double GetCrossSection(const G4DynamicParticle *, const G4Material *)
const G4ParticleDefinition * GetParticleDefinition() const
void SetProcessSubType(G4int)
virtual void ProcessDescription(std::ostream &outFile) const
G4double GetGlobalTime() const
static const char * G4Hadronic_Random_File
void RegisterParticle(G4HadronicProcess *, const G4ParticleDefinition *)
G4HadronicProcessStore * theProcessStore
const G4String & GetProcessName() const
const G4LorentzVector & Get4Momentum() const
void DeRegister(G4HadronicProcess *)
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)
G4Material * InitialiseMaterial(G4int Z)
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
G4double XBiasSecondaryWeight()
void SetNumberOfSecondaries(G4int totSecondaries)
virtual ~G4HadronicProcess()
G4DynamicParticle * GetParticle()
void BuildPhysicsTable(const G4ParticleDefinition &)
const G4double x[NPOINTSGL]
void ProposeEnergy(G4double finalEnergy)
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
G4HadronicInteraction * ChooseHadronicInteraction(const G4HadProjectile &aHadProjectile, G4Nucleus &aTargetNucleus, G4Material *aMaterial, G4Element *anElement)
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)
G4double theLastCrossSection
G4int GetNumberOfSecondaries() const
virtual G4HadFinalState * ApplyYourself(const G4HadProjectile &aTrack, G4Nucleus &targetNucleus)=0
G4double GetLocalEnergyDeposit() const
void SetMomentumDirection(const G4ThreeVector &aValue)
G4HadFinalState * CheckResult(const G4HadProjectile &thePro, const G4Nucleus &targetNucleus, G4HadFinalState *result)
G4GLOB_DLL std::ostream G4cerr
G4int GetBaryonNumber() const
G4HadFinalStateStatus GetStatusChange() const
void PrintInfo(const G4ParticleDefinition *)
G4double GetTotalEnergy() const
CLHEP::HepLorentzVector G4LorentzVector
G4double GetWeight() const