Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes
G4HadronicProcess Class Reference

#include <G4HadronicProcess.hh>

Inheritance diagram for G4HadronicProcess:
G4VDiscreteProcess G4VProcess CexmcHadronicProcess G4ChargeExchangeProcess G4HadronCaptureProcess G4HadronElasticProcess G4HadronFissionProcess G4HadronInelasticProcess G4HadronStoppingProcess G4MuonNuclearProcess

Public Member Functions

 G4HadronicProcess (const G4String &processName="Hadronic", G4ProcessType procType=fHadronic)
 
 G4HadronicProcess (const G4String &processName, G4HadronicProcessType subType)
 
virtual ~G4HadronicProcess ()
 
void RegisterMe (G4HadronicInteraction *a)
 
G4double GetElementCrossSection (const G4DynamicParticle *part, const G4Element *elm, const G4Material *mat=0)
 
G4double GetMicroscopicCrossSection (const G4DynamicParticle *part, const G4Element *elm, const G4Material *mat=0)
 
virtual G4VParticleChangePostStepDoIt (const G4Track &aTrack, const G4Step &aStep)
 
virtual void PreparePhysicsTable (const G4ParticleDefinition &)
 
virtual void BuildPhysicsTable (const G4ParticleDefinition &)
 
void DumpPhysicsTable (const G4ParticleDefinition &p)
 
void AddDataSet (G4VCrossSectionDataSet *aDataSet)
 
G4EnergyRangeManagerGetManagerPointer ()
 
G4double GetMeanFreePath (const G4Track &aTrack, G4double, G4ForceCondition *)
 
const G4NucleusGetTargetNucleus () const
 
const G4IsotopeGetTargetIsotope ()
 
virtual void ProcessDescription (std::ostream &outFile) const
 
void BiasCrossSectionByFactor (G4double aScale)
 
void SetEpReportLevel (G4int level)
 
void SetEnergyMomentumCheckLevels (G4double relativeLevel, G4double absoluteLevel)
 
std::pair< G4double, G4doubleGetEnergyMomentumCheckLevels () const
 
G4CrossSectionDataStoreGetCrossSectionDataStore ()
 
void MultiplyCrossSectionBy (G4double factor)
 
- Public Member Functions inherited from G4VDiscreteProcess
 G4VDiscreteProcess (const G4String &, G4ProcessType aType=fNotDefined)
 
 G4VDiscreteProcess (G4VDiscreteProcess &)
 
virtual ~G4VDiscreteProcess ()
 
virtual G4double PostStepGetPhysicalInteractionLength (const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
 
virtual G4double AlongStepGetPhysicalInteractionLength (const G4Track &, G4double, G4double, G4double &, G4GPILSelection *)
 
virtual G4double AtRestGetPhysicalInteractionLength (const G4Track &, G4ForceCondition *)
 
virtual G4VParticleChangeAtRestDoIt (const G4Track &, const G4Step &)
 
virtual G4VParticleChangeAlongStepDoIt (const G4Track &, const G4Step &)
 
- Public Member Functions inherited from G4VProcess
 G4VProcess (const G4String &aName="NoName", G4ProcessType aType=fNotDefined)
 
 G4VProcess (const G4VProcess &right)
 
virtual ~G4VProcess ()
 
G4int operator== (const G4VProcess &right) const
 
G4int operator!= (const G4VProcess &right) const
 
G4double GetCurrentInteractionLength () const
 
void SetPILfactor (G4double value)
 
G4double GetPILfactor () const
 
G4double AlongStepGPIL (const G4Track &track, G4double previousStepSize, G4double currentMinimumStep, G4double &proposedSafety, G4GPILSelection *selection)
 
G4double AtRestGPIL (const G4Track &track, G4ForceCondition *condition)
 
G4double PostStepGPIL (const G4Track &track, G4double previousStepSize, G4ForceCondition *condition)
 
virtual G4bool IsApplicable (const G4ParticleDefinition &)
 
virtual G4bool StorePhysicsTable (const G4ParticleDefinition *, const G4String &, G4bool)
 
virtual G4bool RetrievePhysicsTable (const G4ParticleDefinition *, const G4String &, G4bool)
 
const G4StringGetPhysicsTableFileName (const G4ParticleDefinition *, const G4String &directory, const G4String &tableName, G4bool ascii=false)
 
const G4StringGetProcessName () const
 
G4ProcessType GetProcessType () const
 
void SetProcessType (G4ProcessType)
 
G4int GetProcessSubType () const
 
void SetProcessSubType (G4int)
 
virtual void StartTracking (G4Track *)
 
virtual void EndTracking ()
 
virtual void SetProcessManager (const G4ProcessManager *)
 
virtual const G4ProcessManagerGetProcessManager ()
 
virtual void ResetNumberOfInteractionLengthLeft ()
 
G4double GetNumberOfInteractionLengthLeft () const
 
G4double GetTotalNumberOfInteractionLengthTraversed () const
 
G4bool isAtRestDoItIsEnabled () const
 
G4bool isAlongStepDoItIsEnabled () const
 
G4bool isPostStepDoItIsEnabled () const
 
virtual void DumpInfo () const
 
void SetVerboseLevel (G4int value)
 
G4int GetVerboseLevel () const
 
virtual void SetMasterProcess (G4VProcess *masterP)
 
const G4VProcessGetMasterProcess () const
 
virtual void BuildWorkerPhysicsTable (const G4ParticleDefinition &part)
 
virtual void PrepareWorkerPhysicsTable (const G4ParticleDefinition &)
 

Protected Member Functions

G4HadronicInteractionChooseHadronicInteraction (G4double kineticEnergy, G4Material *aMaterial, G4Element *anElement)
 
G4NucleusGetTargetNucleusPointer ()
 
void DumpState (const G4Track &, const G4String &, G4ExceptionDescription &)
 
const G4EnergyRangeManagerGetEnergyRangeManager () const
 
void SetEnergyRangeManager (const G4EnergyRangeManager &value)
 
G4HadronicInteractionGetHadronicInteraction () const
 
G4double GetLastCrossSection ()
 
void FillResult (G4HadFinalState *aR, const G4Track &aT)
 
G4HadFinalStateCheckResult (const G4HadProjectile &thePro, const G4Nucleus &targetNucleus, G4HadFinalState *result) const
 
void CheckEnergyMomentumConservation (const G4Track &, const G4Nucleus &)
 
- Protected Member Functions inherited from G4VProcess
void SubtractNumberOfInteractionLengthLeft (G4double previousStepSize)
 
void ClearNumberOfInteractionLengthLeft ()
 

Protected Attributes

G4HadProjectile thePro
 
G4ParticleChangetheTotalResult
 
G4int epReportLevel
 
- Protected Attributes inherited from G4VProcess
const G4ProcessManageraProcessManager
 
G4VParticleChangepParticleChange
 
G4ParticleChange aParticleChange
 
G4double theNumberOfInteractionLengthLeft
 
G4double currentInteractionLength
 
G4double theInitialNumberOfInteractionLength
 
G4String theProcessName
 
G4String thePhysicsTableFileName
 
G4ProcessType theProcessType
 
G4int theProcessSubType
 
G4double thePILfactor
 
G4bool enableAtRestDoIt
 
G4bool enableAlongStepDoIt
 
G4bool enablePostStepDoIt
 
G4int verboseLevel
 

Additional Inherited Members

- Static Public Member Functions inherited from G4VProcess
static const G4StringGetProcessTypeName (G4ProcessType)
 

Detailed Description

Definition at line 69 of file G4HadronicProcess.hh.

Constructor & Destructor Documentation

G4HadronicProcess::G4HadronicProcess ( const G4String processName = "Hadronic",
G4ProcessType  procType = fHadronic 
)

Definition at line 83 of file G4HadronicProcess.cc.

References fHadronInelastic, G4HadronicProcessStore::Instance(), G4HadronicProcessStore::Register(), G4VProcess::SetProcessSubType(), G4VParticleChange::SetSecondaryWeightByProcess(), and theTotalResult.

85  : G4VDiscreteProcess(processName, procType)
86 {
87  SetProcessSubType(fHadronInelastic); // Default unless subclass changes
88 
91  theInteraction = 0;
92  theCrossSectionDataStore = new G4CrossSectionDataStore();
94  aScaleFactor = 1;
95  xBiasOn = false;
96  G4HadronicProcess_debug_flag = false;
97 
98  GetEnergyMomentumCheckEnvvars();
99 }
static G4HadronicProcessStore * Instance()
void SetSecondaryWeightByProcess(G4bool)
G4ParticleChange * theTotalResult
void Register(G4HadronicProcess *)
void SetProcessSubType(G4int)
Definition: G4VProcess.hh:432
G4HadronicProcess::G4HadronicProcess ( const G4String processName,
G4HadronicProcessType  subType 
)

Definition at line 103 of file G4HadronicProcess.cc.

References G4HadronicProcessStore::Instance(), G4HadronicProcessStore::Register(), G4VProcess::SetProcessSubType(), G4VParticleChange::SetSecondaryWeightByProcess(), and theTotalResult.

105  : G4VDiscreteProcess(processName, fHadronic)
106 {
107  SetProcessSubType(aHadSubType);
108 
111  theInteraction = 0;
112  theCrossSectionDataStore = new G4CrossSectionDataStore();
114  aScaleFactor = 1;
115  xBiasOn = false;
116  G4HadronicProcess_debug_flag = false;
117 
118  GetEnergyMomentumCheckEnvvars();
119 }
static G4HadronicProcessStore * Instance()
void SetSecondaryWeightByProcess(G4bool)
G4ParticleChange * theTotalResult
void Register(G4HadronicProcess *)
void SetProcessSubType(G4int)
Definition: G4VProcess.hh:432
G4HadronicProcess::~G4HadronicProcess ( )
virtual

Definition at line 122 of file G4HadronicProcess.cc.

References G4HadronicProcessStore::DeRegister(), G4HadronicProcessStore::Instance(), and theTotalResult.

123 {
125  delete theTotalResult;
126  delete theCrossSectionDataStore;
127 }
static G4HadronicProcessStore * Instance()
G4ParticleChange * theTotalResult
void DeRegister(G4HadronicProcess *)

Member Function Documentation

void G4HadronicProcess::AddDataSet ( G4VCrossSectionDataSet aDataSet)
inline

Definition at line 117 of file G4HadronicProcess.hh.

References G4CrossSectionDataStore::AddDataSet().

Referenced by G4VHadronPhysics::AddCaptureCrossSection(), G4VHadronPhysics::AddElasticCrossSection(), G4VHadronPhysics::AddFissionCrossSection(), G4VHadronPhysics::AddInelasticCrossSection(), G4HadronElasticPhysicsXS::AddXSection(), G4NeutronLENDBuilder::Build(), G4NeutronHPBuilder::Build(), G4BinaryPionBuilder::Build(), G4BertiniKaonBuilder::Build(), G4PrecoProtonBuilder::Build(), G4INCLXXPiKBuilder::Build(), G4PrecoNeutronBuilder::Build(), G4INCLXXNeutronBuilder::Build(), G4FTFBinaryKaonBuilder::Build(), G4FTFBinaryPionBuilder::Build(), G4FTFPPionBuilder::Build(), G4FTFPProtonBuilder::Build(), G4FTFBinaryProtonBuilder::Build(), G4QGSBinaryKaonBuilder::Build(), G4QGSPPionBuilder::Build(), G4FTFBinaryPiKBuilder::Build(), G4QGSBinaryPionBuilder::Build(), G4QGSBinaryProtonBuilder::Build(), G4QGSPPiKBuilder::Build(), G4QGSPProtonBuilder::Build(), G4FTFBinaryNeutronBuilder::Build(), G4FTFPNeutronBuilder::Build(), G4FTFPAntiBarionBuilder::Build(), G4QGSPNeutronBuilder::Build(), G4FTFPPiKBuilder::Build(), G4QGSBinaryNeutronBuilder::Build(), G4QGSBinaryPiKBuilder::Build(), G4INCLXXProtonBuilder::Build(), G4HyperonFTFPBuilder::Build(), DicomPhysicsList::ConstructHad(), B03PhysicsList::ConstructHad(), DMXPhysicsList::ConstructHad(), NeutronHPphysics::ConstructProcess(), G4NeutronCrossSectionXS::ConstructProcess(), G4HadronDElasticPhysics::ConstructProcess(), G4HadronHElasticPhysics::ConstructProcess(), exrdmPhysListHadron::ConstructProcess(), G4IonElasticPhysics::ConstructProcess(), G4HadronElasticPhysicsHP::ConstructProcess(), G4HadronElasticPhysicsLEND::ConstructProcess(), G4HadronInelasticQBBC::ConstructProcess(), G4HadronElasticPhysics::ConstructProcess(), G4HadronPhysicsFTFP_BERT_HP::ConstructProcess(), G4HadronPhysicsFTF_BIC::ConstructProcess(), G4HadronPhysicsQGSP_FTFP_BERT::ConstructProcess(), G4HadronPhysicsFTFP_BERT::ConstructProcess(), G4HadronPhysicsShielding::ConstructProcess(), G4HadronPhysicsFTFP_BERT_TRV::ConstructProcess(), G4HadronPhysicsQGSP_BERT_HP::ConstructProcess(), G4HadronPhysicsQGSP_BIC::ConstructProcess(), G4HadronPhysicsQGSP_BERT::ConstructProcess(), G4HadronPhysicsQGSP_BIC_HP::ConstructProcess(), G4HadronPhysicsQGS_BIC::ConstructProcess(), GammaRayTelIonPhysics::ConstructProcess(), G4HadronPhysicsINCLXX::ConstructProcess(), GammaRayTelHadronPhysics::ConstructProcess(), G4ChargeExchangeProcess::G4ChargeExchangeProcess(), G4HadronCaptureProcess::G4HadronCaptureProcess(), G4HadronElasticProcess::G4HadronElasticProcess(), G4HadronFissionProcess::G4HadronFissionProcess(), G4HadronInelasticProcess::G4HadronInelasticProcess(), and G4MuonNuclearProcess::G4MuonNuclearProcess().

118  { theCrossSectionDataStore->AddDataSet(aDataSet);}
void AddDataSet(G4VCrossSectionDataSet *)
void G4HadronicProcess::BiasCrossSectionByFactor ( G4double  aScale)

Definition at line 605 of file G4HadronicProcess.cc.

References FatalException, G4Exception(), G4VProcess::GetProcessName(), and JustWarning.

606 {
607  xBiasOn = true;
608  aScaleFactor = aScale;
609  G4String it = GetProcessName();
610  if( (it != "PhotonInelastic") &&
611  (it != "ElectroNuclear") &&
612  (it != "PositronNuclear") )
613  {
615  G4Exception("G4HadronicProcess::BiasCrossSectionByFactor", "had009", FatalException, ed,
616  "Cross-section biasing available only for gamma and electro nuclear reactions.");
617  }
618  if(aScale<100)
619  {
621  G4Exception("G4HadronicProcess::BiasCrossSectionByFactor", "had010", JustWarning,ed,
622  "Cross-section bias readjusted to be above safe limit. New value is 100");
623  aScaleFactor = 100.;
624  }
625 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void G4HadronicProcess::BuildPhysicsTable ( const G4ParticleDefinition p)
virtual

Reimplemented from G4VProcess.

Reimplemented in G4HadronStoppingProcess, and G4ChargeExchangeProcess.

Definition at line 166 of file G4HadronicProcess.cc.

References G4CrossSectionDataStore::BuildPhysicsTable(), FatalException, G4endl, G4Exception(), G4HadronicProcessStore::Instance(), G4HadronicProcessStore::PrintInfo(), and G4HadronicException::Report().

Referenced by G4ChargeExchangeProcess::BuildPhysicsTable().

167 {
168  try
169  {
170  theCrossSectionDataStore->BuildPhysicsTable(p);
171  }
172  catch(G4HadronicException aR)
173  {
175  aR.Report(ed);
176  ed << " hadronic initialisation fails" << G4endl;
177  G4Exception("G4HadronicProcess::BuildPhysicsTable", "had000",
178  FatalException,ed);
179  }
181 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
static G4HadronicProcessStore * Instance()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void BuildPhysicsTable(const G4ParticleDefinition &)
#define G4endl
Definition: G4ios.hh:61
void Report(std::ostream &aS)
void PrintInfo(const G4ParticleDefinition *)
void G4HadronicProcess::CheckEnergyMomentumConservation ( const G4Track aTrack,
const G4Nucleus aNucleus 
)
protected

Definition at line 677 of file G4HadronicProcess.cc.

References DBL_MAX, CLHEP::HepLorentzVector::e(), epReportLevel, G4String::first(), fStopAndKill, G4cerr, G4cout, G4endl, G4lrint(), G4DynamicParticle::Get4Momentum(), G4Nucleus::GetA_asInt(), G4ParticleDefinition::GetBaryonNumber(), G4Track::GetDefinition(), G4Track::GetDynamicParticle(), G4ParticleChange::GetEnergy(), G4HadronicInteraction::GetEnergyMomentumCheckLevels(), GetHadronicInteraction(), G4Track::GetKineticEnergy(), G4HadronicInteraction::GetModelName(), G4Track::GetMomentum(), G4ParticleChange::GetMomentumDirection(), G4NucleiProperties::GetNuclearMass(), G4VParticleChange::GetNumberOfSecondaries(), G4Track::GetParticleDefinition(), G4ParticleDefinition::GetParticleName(), G4ParticleDefinition::GetPDGCharge(), G4ParticleDefinition::GetPDGEncoding(), G4VProcess::GetProcessName(), G4VParticleChange::GetSecondary(), G4VParticleChange::GetTrackStatus(), G4Nucleus::GetZ_asInt(), CLHEP::Hep3Vector::mag(), python.hepunit::MeV, G4INCL::Math::min(), G4Track::SetKineticEnergy(), G4Track::SetMomentumDirection(), theTotalResult, and CLHEP::HepLorentzVector::vect().

Referenced by G4HadronStoppingProcess::AtRestDoIt(), and PostStepDoIt().

679 {
680  G4int target_A=aNucleus.GetA_asInt();
681  G4int target_Z=aNucleus.GetZ_asInt();
682  G4double targetMass = G4NucleiProperties::GetNuclearMass(target_A,target_Z);
683  G4LorentzVector target4mom(0, 0, 0, targetMass);
684 
685  G4LorentzVector projectile4mom = aTrack.GetDynamicParticle()->Get4Momentum();
686  G4int track_A = aTrack.GetDefinition()->GetBaryonNumber();
687  G4int track_Z = G4lrint(aTrack.GetDefinition()->GetPDGCharge());
688 
689  G4int initial_A = target_A + track_A;
690  G4int initial_Z = target_Z + track_Z;
691 
692  G4LorentzVector initial4mom = projectile4mom + target4mom;
693 
694  // Compute final-state momentum for scattering and "do nothing" results
695  G4LorentzVector final4mom;
696  G4int final_A(0), final_Z(0);
697 
699  if (theTotalResult->GetTrackStatus() != fStopAndKill) { // If it is Alive
700  // Either interaction didn't complete, returned "do nothing" state
701  // or the primary survived the interaction (e.g. electro-nucleus )
702  G4Track temp(aTrack);
703 
704  // Use the final energy / momentum
705  temp.SetMomentumDirection(*theTotalResult->GetMomentumDirection());
706  temp.SetKineticEnergy(theTotalResult->GetEnergy());
707 
708  if( nSec == 0 ){
709  // Interaction didn't complete, returned "do nothing" state
710  // - or suppressed recoil (e.g. Neutron elastic )
711  final4mom = temp.GetDynamicParticle()->Get4Momentum() + target4mom;
712  final_A = initial_A;
713  final_Z = initial_Z;
714  }else{
715  // The primary remains in final state (e.g. electro-nucleus )
716  final4mom = temp.GetDynamicParticle()->Get4Momentum();
717  final_A = track_A;
718  final_Z = track_Z;
719  // Expect that the target nucleus will have interacted,
720  // and its products, including recoil, will be included in secondaries.
721  }
722  }
723  if( nSec > 0 ) {
724  G4Track* sec;
725 
726  for (G4int i = 0; i < nSec; i++) {
727  sec = theTotalResult->GetSecondary(i);
728  final4mom += sec->GetDynamicParticle()->Get4Momentum();
729  final_A += sec->GetDefinition()->GetBaryonNumber();
730  final_Z += G4lrint(sec->GetDefinition()->GetPDGCharge());
731  }
732  }
733 
734  // Get level-checking information (used to cut-off relative checks)
735  G4String processName = GetProcessName();
737  G4String modelName("none");
738  if (theModel) modelName = theModel->GetModelName();
739  std::pair<G4double, G4double> checkLevels = epCheckLevels;
740  if (!levelsSetByProcess) {
741  if (theModel) checkLevels = theModel->GetEnergyMomentumCheckLevels();
742  checkLevels.first= std::min(checkLevels.first, epCheckLevels.first);
743  checkLevels.second=std::min(checkLevels.second, epCheckLevels.second);
744  }
745 
746  // Compute absolute total-energy difference, and relative kinetic-energy
747  G4bool checkRelative = (aTrack.GetKineticEnergy() > checkLevels.second);
748 
749  G4LorentzVector diff = initial4mom - final4mom;
750  G4double absolute = diff.e();
751  G4double relative = checkRelative ? absolute/aTrack.GetKineticEnergy() : 0.;
752 
753  G4double absolute_mom = diff.vect().mag();
754  G4double relative_mom = checkRelative ? absolute_mom/aTrack.GetMomentum().mag() : 0.;
755 
756  // Evaluate relative and absolute conservation
757  G4bool relPass = true;
758  G4String relResult = "pass";
759  if ( std::abs(relative) > checkLevels.first
760  || std::abs(relative_mom) > checkLevels.first) {
761  relPass = false;
762  relResult = checkRelative ? "fail" : "N/A";
763  }
764 
765  G4bool absPass = true;
766  G4String absResult = "pass";
767  if ( std::abs(absolute) > checkLevels.second
768  || std::abs(absolute_mom) > checkLevels.second ) {
769  absPass = false ;
770  absResult = "fail";
771  }
772 
773  G4bool chargePass = true;
774  G4String chargeResult = "pass";
775  if ( (initial_A-final_A)!=0
776  || (initial_Z-final_Z)!=0 ) {
777  chargePass = checkLevels.second < DBL_MAX ? false : true;
778  chargeResult = "fail";
779  }
780 
781  G4bool conservationPass = (relPass || absPass) && chargePass;
782 
783  std::stringstream Myout;
784  G4bool Myout_notempty(false);
785  // Options for level of reporting detail:
786  // 0. off
787  // 1. report only when E/p not conserved
788  // 2. report regardless of E/p conservation
789  // 3. report only when E/p not conserved, with model names, process names, and limits
790  // 4. report regardless of E/p conservation, with model names, process names, and limits
791  // negative -1.., as above, but send output to stderr
792 
793  if( std::abs(epReportLevel) == 4
794  || ( std::abs(epReportLevel) == 3 && ! conservationPass ) ){
795  Myout << " Process: " << processName << " , Model: " << modelName << G4endl;
796  Myout << " Primary: " << aTrack.GetParticleDefinition()->GetParticleName()
797  << " (" << aTrack.GetParticleDefinition()->GetPDGEncoding() << "),"
798  << " E= " << aTrack.GetDynamicParticle()->Get4Momentum().e()
799  << ", target nucleus (" << aNucleus.GetZ_asInt() << ","
800  << aNucleus.GetA_asInt() << ")" << G4endl;
801  Myout_notempty=true;
802  }
803  if ( std::abs(epReportLevel) == 4
804  || std::abs(epReportLevel) == 2
805  || ! conservationPass ){
806 
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 << " 3mom: " << (diff.vect())*1./MeV << G4endl;
811  Myout << " "<< chargeResult << " charge/baryon number balance " << (initial_Z-final_Z) << " / " << (initial_A-final_A) << " "<< G4endl;
812  Myout_notempty=true;
813 
814  }
815  Myout.flush();
816  if ( Myout_notempty ) {
817  if (epReportLevel > 0) G4cout << Myout.str()<< G4endl;
818  else if (epReportLevel < 0) G4cerr << Myout.str()<< G4endl;
819  }
820 }
G4ParticleDefinition * GetDefinition() const
G4int GetA_asInt() const
Definition: G4Nucleus.hh:109
static G4double GetNuclearMass(const G4double A, const G4double Z)
G4int GetNumberOfSecondaries() const
G4Track * GetSecondary(G4int anIndex) const
const G4DynamicParticle * GetDynamicParticle() const
G4int first(char) const
const G4ThreeVector * GetMomentumDirection() const
const G4String & GetModelName() const
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4double GetKineticEnergy() const
Hep3Vector vect() const
G4GLOB_DLL std::ostream G4cout
G4ParticleChange * theTotalResult
bool G4bool
Definition: G4Types.hh:79
virtual std::pair< G4double, G4double > GetEnergyMomentumCheckLevels() const
const G4ParticleDefinition * GetParticleDefinition() const
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
G4LorentzVector Get4Momentum() const
G4ThreeVector GetMomentum() const
G4HadronicInteraction * GetHadronicInteraction() const
int G4lrint(double ad)
Definition: templates.hh:163
G4int GetZ_asInt() const
Definition: G4Nucleus.hh:115
T min(const T t1, const T t2)
brief Return the smallest of the two arguments
G4double GetEnergy() const
#define G4endl
Definition: G4ios.hh:61
G4TrackStatus GetTrackStatus() const
double G4double
Definition: G4Types.hh:76
G4double GetPDGCharge() const
double mag() const
#define DBL_MAX
Definition: templates.hh:83
G4GLOB_DLL std::ostream G4cerr
G4HadFinalState * G4HadronicProcess::CheckResult ( const G4HadProjectile thePro,
const G4Nucleus targetNucleus,
G4HadFinalState result 
) const
protected

Definition at line 627 of file G4HadronicProcess.cc.

References CLHEP::HepLorentzVector::e(), epReportLevel, EventMustBeAborted, G4endl, G4Exception(), G4HadProjectile::Get4Momentum(), G4Nucleus::GetA_asInt(), G4HadProjectile::GetDefinition(), G4HadFinalState::GetEnergyChange(), G4HadronicInteraction::GetFatalEnergyCheckLevels(), GetHadronicInteraction(), G4HadProjectile::GetKineticEnergy(), G4HadFinalState::GetLocalEnergyDeposit(), G4HadronicInteraction::GetModelName(), G4NucleiProperties::GetNuclearMass(), G4HadFinalState::GetNumberOfSecondaries(), G4HadSecondary::GetParticle(), G4ParticleDefinition::GetParticleName(), G4ParticleDefinition::GetPDGEncoding(), G4ParticleDefinition::GetPDGMass(), G4VProcess::GetProcessName(), G4HadFinalState::GetSecondary(), G4HadFinalState::GetStatusChange(), G4HadProjectile::GetTotalEnergy(), G4DynamicParticle::GetTotalEnergy(), G4Nucleus::GetZ_asInt(), JustWarning, and stopAndKill.

Referenced by G4HadronStoppingProcess::AtRestDoIt(), and PostStepDoIt().

628 {
629  // check for catastrophic energy non-conservation, to re-sample the interaction
630 
632  G4double nuclearMass(0);
633  if (theModel){
634 
635  // Compute final-state total energy
636  G4double finalE(0.);
637  G4int nSec = result->GetNumberOfSecondaries();
638 
639  nuclearMass = G4NucleiProperties::GetNuclearMass(aNucleus.GetA_asInt(),
640  aNucleus.GetZ_asInt());
641  if (result->GetStatusChange() != stopAndKill) {
642  // Interaction didn't complete, returned "do nothing" state => reset nucleus
643  // or the primary survived the interaction (e.g. electro-nuclear ) => keep nucleus
644  finalE=result->GetLocalEnergyDeposit() +
645  aPro.GetDefinition()->GetPDGMass() + result->GetEnergyChange();
646  if( nSec == 0 ){
647  // Since there are no secondaries, there is no recoil nucleus.
648  // To check energy balance we must neglect the initial nucleus too.
649  nuclearMass=0.0;
650  }
651  }
652  for (G4int i = 0; i < nSec; i++) {
653  finalE += result->GetSecondary(i)->GetParticle()->GetTotalEnergy();
654  }
655  G4double deltaE= nuclearMass + aPro.GetTotalEnergy() - finalE;
656 
657  std::pair<G4double, G4double> checkLevels = theModel->GetFatalEnergyCheckLevels(); // (relative, absolute)
658  if (std::abs(deltaE) > checkLevels.second && std::abs(deltaE) > checkLevels.first*aPro.GetKineticEnergy()){
659  // do not delete result, this is a pointer to a data member;
660  result=0;
662  desc << "Warning: Bad energy non-conservation detected, will "
663  << (epReportLevel<0 ? "abort the event" : "re-sample the interaction") << G4endl
664  << " Process / Model: " << GetProcessName()<< " / " << theModel->GetModelName() << G4endl
665  << " Primary: " << aPro.GetDefinition()->GetParticleName()
666  << " (" << aPro.GetDefinition()->GetPDGEncoding() << "),"
667  << " E= " << aPro.Get4Momentum().e()
668  << ", target nucleus (" << aNucleus.GetZ_asInt() << ","<< aNucleus.GetA_asInt() << ")" << G4endl
669  << " E(initial - final) = " << deltaE << " MeV." << G4endl;
670  G4Exception("G4HadronicProcess:CheckResult()", "had012", epReportLevel<0 ? EventMustBeAborted : JustWarning,desc);
671  }
672  }
673  return result;
674 }
static G4double GetNuclearMass(const G4double A, const G4double Z)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4HadSecondary * GetSecondary(size_t i)
G4double GetTotalEnergy() const
virtual const std::pair< G4double, G4double > GetFatalEnergyCheckLevels() const
G4double GetEnergyChange() const
const G4String & GetModelName() const
int G4int
Definition: G4Types.hh:78
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4HadronicInteraction * GetHadronicInteraction() const
G4DynamicParticle * GetParticle()
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4int GetNumberOfSecondaries() const
G4double GetLocalEnergyDeposit() const
G4HadFinalStateStatus GetStatusChange() const
G4HadronicInteraction* G4HadronicProcess::ChooseHadronicInteraction ( G4double  kineticEnergy,
G4Material aMaterial,
G4Element anElement 
)
inlineprotected

Definition at line 142 of file G4HadronicProcess.hh.

References G4EnergyRangeManager::GetHadronicInteraction().

Referenced by G4HadronStoppingProcess::AtRestDoIt(), G4HadronElasticProcess::PostStepDoIt(), and PostStepDoIt().

144  { return theEnergyRangeManager.GetHadronicInteraction(kineticEnergy,
145  aMaterial,anElement);
146  }
G4HadronicInteraction * GetHadronicInteraction(const G4double kineticEnergy, const G4Material *aMaterial, const G4Element *anElement) const
void G4HadronicProcess::DumpPhysicsTable ( const G4ParticleDefinition p)
inline

Definition at line 113 of file G4HadronicProcess.hh.

References G4CrossSectionDataStore::DumpPhysicsTable().

114  { theCrossSectionDataStore->DumpPhysicsTable(p); }
void DumpPhysicsTable(const G4ParticleDefinition &)
void G4HadronicProcess::DumpState ( const G4Track aTrack,
const G4String method,
G4ExceptionDescription ed 
)
protected

Definition at line 823 of file G4HadronicProcess.cc.

References G4endl, G4Track::GetKineticEnergy(), G4Track::GetMaterial(), G4Track::GetMomentumDirection(), G4VPhysicalVolume::GetName(), G4Material::GetName(), G4Track::GetParentID(), G4Track::GetParticleDefinition(), G4ParticleDefinition::GetParticleName(), G4Track::GetPosition(), G4VProcess::GetProcessName(), G4Track::GetTrackID(), and G4Track::GetVolume().

Referenced by G4HadronStoppingProcess::AtRestDoIt(), FillResult(), GetMeanFreePath(), G4HadronElasticProcess::PostStepDoIt(), and PostStepDoIt().

826 {
827  ed << "Unrecoverable error in the method " << method << " of "
828  << GetProcessName() << G4endl;
829  ed << "TrackID= "<< aTrack.GetTrackID() << " ParentID= "
830  << aTrack.GetParentID()
831  << " " << aTrack.GetParticleDefinition()->GetParticleName()
832  << G4endl;
833  ed << "Ekin(GeV)= " << aTrack.GetKineticEnergy()/CLHEP::GeV
834  << "; direction= " << aTrack.GetMomentumDirection() << G4endl;
835  ed << "Position(mm)= " << aTrack.GetPosition()/CLHEP::mm << ";";
836 
837  if (aTrack.GetMaterial()) {
838  ed << " material " << aTrack.GetMaterial()->GetName();
839  }
840  ed << G4endl;
841 
842  if (aTrack.GetVolume()) {
843  ed << "PhysicalVolume <" << aTrack.GetVolume()->GetName()
844  << ">" << G4endl;
845  }
846 }
G4int GetParentID() const
const G4String & GetName() const
Definition: G4Material.hh:176
const G4ThreeVector & GetPosition() const
const G4String & GetParticleName() const
G4double GetKineticEnergy() const
const G4String & GetName() const
const G4ParticleDefinition * GetParticleDefinition() const
G4int GetTrackID() const
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
G4Material * GetMaterial() const
const G4ThreeVector & GetMomentumDirection() const
G4VPhysicalVolume * GetVolume() const
#define G4endl
Definition: G4ios.hh:61
void G4HadronicProcess::FillResult ( G4HadFinalState aR,
const G4Track aT 
)
protected

Definition at line 376 of file G4HadronicProcess.cc.

References G4ParticleChange::AddSecondary(), G4VProcess::aParticleChange, G4HadFinalState::Clear(), DumpState(), CLHEP::HepLorentzVector::e(), fAlive, fStopAndKill, fStopButAlive, G4endl, G4Exception(), G4UniformRand, G4DynamicParticle::Get4Momentum(), G4ProcessManager::GetAtRestProcessVector(), G4Track::GetDefinition(), G4HadFinalState::GetEnergyChange(), G4Track::GetGlobalTime(), G4Track::GetKineticEnergy(), G4HadFinalState::GetLocalEnergyDeposit(), G4HadFinalState::GetMomentumChange(), G4HadFinalState::GetNumberOfSecondaries(), G4HadSecondary::GetParticle(), G4Track::GetParticleDefinition(), G4ParticleDefinition::GetParticleName(), G4ParticleDefinition::GetPDGMass(), G4Track::GetPosition(), G4ParticleDefinition::GetProcessManager(), G4HadFinalState::GetSecondary(), G4HadFinalState::GetStatusChange(), G4HadSecondary::GetTime(), G4Track::GetTouchableHandle(), G4HadFinalState::GetTrafoToLab(), G4HadSecondary::GetWeight(), G4Track::GetWeight(), JustWarning, G4ParticleChange::ProposeEnergy(), G4VParticleChange::ProposeLocalEnergyDeposit(), G4ParticleChange::ProposeMomentumDirection(), G4VParticleChange::ProposeTrackStatus(), CLHEP::HepLorentzVector::rotate(), G4DynamicParticle::Set4Momentum(), G4VParticleChange::SetNumberOfSecondaries(), G4Track::SetTouchableHandle(), G4Track::SetWeight(), G4ProcessVector::size(), stopAndKill, theTotalResult, CLHEP::Hep3Vector::unit(), and CLHEP::HepLorentzVector::vect().

Referenced by PostStepDoIt().

377 {
379 
380  G4double rotation = CLHEP::twopi*G4UniformRand();
381  G4ThreeVector it(0., 0., 1.);
382 
383  G4double efinal = aR->GetEnergyChange();
384  if(efinal < 0.0) { efinal = 0.0; }
385 
386  // check status of primary
387  if(aR->GetStatusChange() == stopAndKill) {
390 
391  // check its final energy
392  } else if(0.0 == efinal) {
395  ->GetAtRestProcessVector()->size() > 0)
398 
399  // primary is not killed apply rotation and Lorentz transformation
400  } else {
403  G4double newE = efinal + mass;
404  G4double newP = std::sqrt(efinal*(efinal + 2*mass));
405  G4ThreeVector newPV = newP*aR->GetMomentumChange();
406  G4LorentzVector newP4(newE, newPV);
407  newP4.rotate(rotation, it);
408  newP4 *= aR->GetTrafoToLab();
409  theTotalResult->ProposeMomentumDirection(newP4.vect().unit());
410  newE = newP4.e() - mass;
411  if(G4HadronicProcess_debug_flag && newE <= 0.0) {
413  DumpState(aT,"Primary has zero energy after interaction",ed);
414  G4Exception("G4HadronicProcess::FillResults", "had011", JustWarning, ed);
415  }
416  if(newE < 0.0) { newE = 0.0; }
417  theTotalResult->ProposeEnergy( newE );
418  }
419 
420  // check secondaries: apply rotation and Lorentz transformation
421  G4int nSec = aR->GetNumberOfSecondaries();
423  G4double weight = aT.GetWeight();
424 
425  if (nSec > 0) {
426  G4double time0 = aT.GetGlobalTime();
427  for (G4int i = 0; i < nSec; ++i) {
429  theM.rotate(rotation, it);
430  theM *= aR->GetTrafoToLab();
431  aR->GetSecondary(i)->GetParticle()->Set4Momentum(theM);
432 
433  // time of interaction starts from zero
434  G4double time = aR->GetSecondary(i)->GetTime();
435  if (time < 0.0) { time = 0.0; }
436 
437  // take into account global time
438  time += time0;
439 
440  G4Track* track = new G4Track(aR->GetSecondary(i)->GetParticle(),
441  time, aT.GetPosition());
442  G4double newWeight = weight*aR->GetSecondary(i)->GetWeight();
443  // G4cout << "#### ParticleDebug "
444  // <<GetProcessName()<<" "
445  // <<aR->GetSecondary(i)->GetParticle()->GetDefinition()->GetParticleName()<<" "
446  // <<aScaleFactor<<" "
447  // <<XBiasSurvivalProbability()<<" "
448  // <<XBiasSecondaryWeight()<<" "
449  // <<aT.GetWeight()<<" "
450  // <<aR->GetSecondary(i)->GetWeight()<<" "
451  // <<aR->GetSecondary(i)->GetParticle()->Get4Momentum()<<" "
452  // <<G4endl;
453  track->SetWeight(newWeight);
456  if (G4HadronicProcess_debug_flag) {
457  G4double e = track->GetKineticEnergy();
458  if (e <= 0.0) {
460  DumpState(aT,"Secondary has zero energy",ed);
461  ed << "Secondary " << track->GetDefinition()->GetParticleName()
462  << G4endl;
463  G4Exception("G4HadronicProcess::FillResults", "had011", JustWarning,ed);
464  }
465  }
466  }
467  }
468 
469  aR->Clear();
470  return;
471 }
G4ParticleDefinition * GetDefinition() const
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4HadSecondary * GetSecondary(size_t i)
const G4ThreeVector & GetPosition() const
void SetTouchableHandle(const G4TouchableHandle &apValue)
G4double GetEnergyChange() const
G4double GetTime() const
G4ProcessManager * GetProcessManager() const
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
void SetWeight(G4double aValue)
void ProposeLocalEnergyDeposit(G4double anEnergyPart)
void DumpState(const G4Track &, const G4String &, G4ExceptionDescription &)
G4ProcessVector * GetAtRestProcessVector(G4ProcessVectorTypeIndex typ=typeGPIL) const
G4double GetKineticEnergy() const
#define G4UniformRand()
Definition: Randomize.hh:87
G4ParticleChange * theTotalResult
const G4ParticleDefinition * GetParticleDefinition() const
G4double GetGlobalTime() const
HepLorentzVector & rotate(double, const Hep3Vector &)
const G4TouchableHandle & GetTouchableHandle() const
G4LorentzVector Get4Momentum() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
void Set4Momentum(const G4LorentzVector &momentum)
G4int size() const
G4double GetPDGMass() const
const G4ThreeVector & GetMomentumChange() const
void SetNumberOfSecondaries(G4int totSecondaries)
G4DynamicParticle * GetParticle()
void ProposeEnergy(G4double finalEnergy)
G4ParticleChange aParticleChange
Definition: G4VProcess.hh:289
void AddSecondary(G4Track *aSecondary)
G4double GetWeight() const
#define G4endl
Definition: G4ios.hh:61
void ProposeMomentumDirection(G4double Px, G4double Py, G4double Pz)
double G4double
Definition: G4Types.hh:76
void ProposeTrackStatus(G4TrackStatus status)
G4int GetNumberOfSecondaries() const
G4double GetLocalEnergyDeposit() const
G4HadFinalStateStatus GetStatusChange() const
const G4LorentzRotation & GetTrafoToLab() const
G4double GetWeight() const
G4CrossSectionDataStore* G4HadronicProcess::GetCrossSectionDataStore ( )
inline
G4double G4HadronicProcess::GetElementCrossSection ( const G4DynamicParticle part,
const G4Element elm,
const G4Material mat = 0 
)
inline
std::pair<G4double, G4double> G4HadronicProcess::GetEnergyMomentumCheckLevels ( ) const
inline

Definition at line 166 of file G4HadronicProcess.hh.

Referenced by G4HadronicProcessStore::SetProcessAbsLevel(), and G4HadronicProcessStore::SetProcessRelLevel().

167  { return epCheckLevels; }
const G4EnergyRangeManager& G4HadronicProcess::GetEnergyRangeManager ( ) const
inlineprotected

Definition at line 181 of file G4HadronicProcess.hh.

182  { return theEnergyRangeManager; }
G4HadronicInteraction* G4HadronicProcess::GetHadronicInteraction ( ) const
inlineprotected

Definition at line 189 of file G4HadronicProcess.hh.

Referenced by CheckEnergyMomentumConservation(), and CheckResult().

190  { return theInteraction; }
G4double G4HadronicProcess::GetLastCrossSection ( )
inlineprotected

Definition at line 193 of file G4HadronicProcess.hh.

194  { return theLastCrossSection; }
G4EnergyRangeManager* G4HadronicProcess::GetManagerPointer ( )
inline

Definition at line 121 of file G4HadronicProcess.hh.

Referenced by RegisterMe().

122  { return &theEnergyRangeManager; }
G4double G4HadronicProcess::GetMeanFreePath ( const G4Track aTrack,
G4double  ,
G4ForceCondition  
)
virtual

Implements G4VDiscreteProcess.

Definition at line 184 of file G4HadronicProcess.cc.

References DBL_MAX, DumpState(), FatalException, G4endl, G4Exception(), G4CrossSectionDataStore::GetCrossSection(), G4Track::GetDynamicParticle(), G4Track::GetMaterial(), and G4HadronicException::Report().

185 {
186  try
187  {
188  theLastCrossSection = aScaleFactor*
189  theCrossSectionDataStore->GetCrossSection(aTrack.GetDynamicParticle(),
190  aTrack.GetMaterial());
191  }
192  catch(G4HadronicException aR)
193  {
195  aR.Report(ed);
196  DumpState(aTrack,"GetMeanFreePath",ed);
197  ed << " Cross section is not available" << G4endl;
198  G4Exception("G4HadronicProcess::GetMeanFreePath", "had002", FatalException,
199  ed);
200  }
201  G4double res = DBL_MAX;
202  if( theLastCrossSection > 0.0 ) { res = 1.0/theLastCrossSection; }
203  return res;
204 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
const G4DynamicParticle * GetDynamicParticle() const
void DumpState(const G4Track &, const G4String &, G4ExceptionDescription &)
G4double GetCrossSection(const G4DynamicParticle *, const G4Material *)
G4Material * GetMaterial() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
#define DBL_MAX
Definition: templates.hh:83
void Report(std::ostream &aS)
G4double G4HadronicProcess::GetMicroscopicCrossSection ( const G4DynamicParticle part,
const G4Element elm,
const G4Material mat = 0 
)
inline

Definition at line 97 of file G4HadronicProcess.hh.

References GetElementCrossSection().

100  { return GetElementCrossSection(part, elm, mat); }
G4double GetElementCrossSection(const G4DynamicParticle *part, const G4Element *elm, const G4Material *mat=0)
const G4Isotope* G4HadronicProcess::GetTargetIsotope ( )
inline

Definition at line 133 of file G4HadronicProcess.hh.

References G4Nucleus::GetIsotope().

134  { return targetNucleus.GetIsotope(); }
const G4Isotope * GetIsotope()
Definition: G4Nucleus.hh:119
const G4Nucleus* G4HadronicProcess::GetTargetNucleus ( ) const
inline

Definition at line 129 of file G4HadronicProcess.hh.

130  { return &targetNucleus; }
G4Nucleus* G4HadronicProcess::GetTargetNucleusPointer ( )
inlineprotected

Definition at line 149 of file G4HadronicProcess.hh.

Referenced by G4HadronStoppingProcess::AtRestDoIt(), and G4HadronElasticProcess::PostStepDoIt().

150  { return &targetNucleus; }
void G4HadronicProcess::MultiplyCrossSectionBy ( G4double  factor)
inline

Definition at line 173 of file G4HadronicProcess.hh.

174  { aScaleFactor = factor; }
G4VParticleChange * G4HadronicProcess::PostStepDoIt ( const G4Track aTrack,
const G4Step aStep 
)
virtual

Reimplemented from G4VDiscreteProcess.

Reimplemented in CexmcHadronicProcess, and G4HadronElasticProcess.

Definition at line 207 of file G4HadronicProcess.cc.

References G4HadronicInteraction::ApplyYourself(), CheckEnergyMomentumConservation(), CheckResult(), ChooseHadronicInteraction(), G4VParticleChange::Clear(), G4VProcess::ClearNumberOfInteractionLengthLeft(), DumpState(), epReportLevel, fAlive, FatalException, FillResult(), fKillTrackAndSecondaries, fPostponeToNextEvent, fStopAndKill, fSuspend, G4endl, G4Exception(), G4Nucleus::GetA_asInt(), G4ParticleDefinition::GetBaryonNumber(), G4DynamicParticle::GetDefinition(), G4Track::GetDynamicParticle(), GetElementCrossSection(), G4DynamicParticle::GetKineticEnergy(), G4Track::GetMaterial(), G4HadronicInteraction::GetModelName(), G4Element::GetName(), G4DynamicParticle::GetParticleDefinition(), G4ParticleDefinition::GetPDGCharge(), G4Track::GetTrackStatus(), G4HadProjectile::GetTrafoToLab(), G4Track::GetWeight(), G4Nucleus::GetZ_asInt(), G4HadProjectile::Initialise(), G4ParticleChange::Initialize(), JustWarning, G4VParticleChange::ProposeWeight(), G4HadronicException::Report(), G4CrossSectionDataStore::SampleZandA(), CLHEP::HepRandom::saveEngineStatus(), G4HadFinalState::SetTrafoToLab(), thePro, and theTotalResult.

208 {
209  // if primary is not Alive then do nothing
211  theTotalResult->Initialize(aTrack);
213  if(aTrack.GetTrackStatus() != fAlive) { return theTotalResult; }
214 
215  // Find cross section at end of step and check if <= 0
216  //
217  const G4DynamicParticle* aParticle = aTrack.GetDynamicParticle();
218  G4Material* aMaterial = aTrack.GetMaterial();
219 
220  G4Element* anElement = 0;
221  try
222  {
223  anElement = theCrossSectionDataStore->SampleZandA(aParticle,
224  aMaterial,
225  targetNucleus);
226  }
227  catch(G4HadronicException & aR)
228  {
230  aR.Report(ed);
231  DumpState(aTrack,"SampleZandA",ed);
232  ed << " PostStepDoIt failed on element selection" << G4endl;
233  G4Exception("G4HadronicProcess::PostStepDoIt", "had003", FatalException,
234  ed);
235  }
236 
237  // check only for charged particles
238  if(aParticle->GetDefinition()->GetPDGCharge() != 0.0) {
239  if (GetElementCrossSection(aParticle, anElement, aMaterial) <= 0.0) {
240  // No interaction
241  return theTotalResult;
242  }
243  }
244 
245  // Next check for illegal track status
246  //
247  if (aTrack.GetTrackStatus() != fAlive && aTrack.GetTrackStatus() != fSuspend) {
248  if (aTrack.GetTrackStatus() == fStopAndKill ||
250  aTrack.GetTrackStatus() == fPostponeToNextEvent) {
252  ed << "G4HadronicProcess: track in unusable state - "
253  << aTrack.GetTrackStatus() << G4endl;
254  ed << "G4HadronicProcess: returning unchanged track " << G4endl;
255  DumpState(aTrack,"PostStepDoIt",ed);
256  G4Exception("G4HadronicProcess::PostStepDoIt", "had004", JustWarning, ed);
257  }
258  // No warning for fStopButAlive which is a legal status here
259  return theTotalResult;
260  }
261 
262  // Go on to regular case
263  //
264  G4double originalEnergy = aParticle->GetKineticEnergy();
265  G4double kineticEnergy = originalEnergy;
266 
267  // Get kinetic energy per nucleon for ions
268  if(aParticle->GetParticleDefinition()->GetBaryonNumber() > 1.5)
269  kineticEnergy/=aParticle->GetParticleDefinition()->GetBaryonNumber();
270 
271  try
272  {
273  theInteraction =
274  ChooseHadronicInteraction( kineticEnergy, aMaterial, anElement );
275  }
276  catch(G4HadronicException & aE)
277  {
279  aE.Report(ed);
280  ed << "Target element "<<anElement->GetName()<<" Z= "
281  << targetNucleus.GetZ_asInt() << " A= "
282  << targetNucleus.GetA_asInt() << G4endl;
283  DumpState(aTrack,"ChooseHadronicInteraction",ed);
284  ed << " No HadronicInteraction found out" << G4endl;
285  G4Exception("G4HadronicProcess::PostStepDoIt", "had005", FatalException,
286  ed);
287  }
288 
289  // Initialize the hadronic projectile from the track
290  thePro.Initialise(aTrack);
291  G4HadFinalState* result = 0;
292  G4int reentryCount = 0;
293 
294  do
295  {
296  try
297  {
298  // Save random engine if requested for debugging
299  if (G4Hadronic_Random_File) {
300  CLHEP::HepRandom::saveEngineStatus(G4Hadronic_Random_File);
301  }
302  // Call the interaction
303  result = theInteraction->ApplyYourself( thePro, targetNucleus);
304  ++reentryCount;
305  }
306  catch(G4HadronicException aR)
307  {
309  aR.Report(ed);
310  ed << "Call for " << theInteraction->GetModelName() << G4endl;
311  ed << "Target element "<<anElement->GetName()<<" Z= "
312  << targetNucleus.GetZ_asInt()
313  << " A= " << targetNucleus.GetA_asInt() << G4endl;
314  DumpState(aTrack,"ApplyYourself",ed);
315  ed << " ApplyYourself failed" << G4endl;
316  G4Exception("G4HadronicProcess::PostStepDoIt", "had006", FatalException,
317  ed);
318  }
319 
320  // Check the result for catastrophic energy non-conservation
321  result = CheckResult(thePro,targetNucleus, result);
322 
323  if(reentryCount>100) {
325  ed << "Call for " << theInteraction->GetModelName() << G4endl;
326  ed << "Target element "<<anElement->GetName()<<" Z= "
327  << targetNucleus.GetZ_asInt()
328  << " A= " << targetNucleus.GetA_asInt() << G4endl;
329  DumpState(aTrack,"ApplyYourself",ed);
330  ed << " ApplyYourself does not completed after 100 attempts" << G4endl;
331  G4Exception("G4HadronicProcess::PostStepDoIt", "had006", FatalException,
332  ed);
333  }
334  }
335  while(!result);
336 
338 
340 
341  FillResult(result, aTrack);
342 
343  if (epReportLevel != 0) {
344  CheckEnergyMomentumConservation(aTrack, targetNucleus);
345  }
346  return theTotalResult;
347 }
G4int GetA_asInt() const
Definition: G4Nucleus.hh:109
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4double GetKineticEnergy() const
G4LorentzRotation & GetTrafoToLab()
const G4DynamicParticle * GetDynamicParticle() const
G4TrackStatus GetTrackStatus() const
G4HadProjectile thePro
G4ParticleDefinition * GetDefinition() const
void CheckEnergyMomentumConservation(const G4Track &, const G4Nucleus &)
const G4String & GetModelName() const
void ClearNumberOfInteractionLengthLeft()
Definition: G4VProcess.hh:447
int G4int
Definition: G4Types.hh:78
void ProposeWeight(G4double finalWeight)
void DumpState(const G4Track &, const G4String &, G4ExceptionDescription &)
void SetTrafoToLab(const G4LorentzRotation &aT)
void FillResult(G4HadFinalState *aR, const G4Track &aT)
G4ParticleChange * theTotalResult
G4HadronicInteraction * ChooseHadronicInteraction(G4double kineticEnergy, G4Material *aMaterial, G4Element *anElement)
G4HadFinalState * CheckResult(const G4HadProjectile &thePro, const G4Nucleus &targetNucleus, G4HadFinalState *result) const
const G4ParticleDefinition * GetParticleDefinition() const
G4Material * GetMaterial() const
void Initialise(const G4Track &aT)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
virtual void Initialize(const G4Track &)
G4double GetElementCrossSection(const G4DynamicParticle *part, const G4Element *elm, const G4Material *mat=0)
static void saveEngineStatus(const char filename[]="Config.conf")
Definition: Random.cc:175
G4int GetZ_asInt() const
Definition: G4Nucleus.hh:115
G4double GetWeight() const
#define G4endl
Definition: G4ios.hh:61
G4Element * SampleZandA(const G4DynamicParticle *, const G4Material *, G4Nucleus &target)
double G4double
Definition: G4Types.hh:76
const G4String & GetName() const
Definition: G4Element.hh:127
G4double GetPDGCharge() const
void Report(std::ostream &aS)
virtual G4HadFinalState * ApplyYourself(const G4HadProjectile &aTrack, G4Nucleus &targetNucleus)=0
void G4HadronicProcess::PreparePhysicsTable ( const G4ParticleDefinition p)
virtual

Reimplemented from G4VProcess.

Reimplemented in G4HadronStoppingProcess, and G4HadronElasticProcess.

Definition at line 158 of file G4HadronicProcess.cc.

References G4HadronicProcessStore::Instance(), and G4HadronicProcessStore::RegisterParticle().

Referenced by G4HadronElasticProcess::PreparePhysicsTable().

159 {
160  if(getenv("G4HadronicProcess_debug")) {
161  G4HadronicProcess_debug_flag = true;
162  }
164 }
static G4HadronicProcessStore * Instance()
void RegisterParticle(G4HadronicProcess *, const G4ParticleDefinition *)
void G4HadronicProcess::ProcessDescription ( std::ostream &  outFile) const
virtual
void G4HadronicProcess::RegisterMe ( G4HadronicInteraction a)

Definition at line 142 of file G4HadronicProcess.cc.

References FatalException, G4endl, G4Exception(), GetManagerPointer(), G4HadronicInteraction::GetModelName(), G4VProcess::GetProcessName(), G4HadronicProcessStore::Instance(), G4HadronicProcessStore::RegisterInteraction(), G4EnergyRangeManager::RegisterMe(), and G4HadronicException::Report().

Referenced by G4NeutronHPBuilder::Build(), G4NeutronLENDBuilder::Build(), G4BertiniElectroNuclearBuilder::Build(), G4BinaryPionBuilder::Build(), G4BertiniProtonBuilder::Build(), G4BertiniKaonBuilder::Build(), G4PrecoProtonBuilder::Build(), G4BinaryProtonBuilder::Build(), G4BertiniPiKBuilder::Build(), G4BinaryPiKBuilder::Build(), G4BertiniNeutronBuilder::Build(), G4BertiniPionBuilder::Build(), G4BinaryNeutronBuilder::Build(), G4INCLXXPiKBuilder::Build(), G4PrecoNeutronBuilder::Build(), G4INCLXXNeutronBuilder::Build(), G4FTFBinaryKaonBuilder::Build(), G4FTFBinaryPionBuilder::Build(), G4QGSPPionBuilder::Build(), G4FTFBinaryProtonBuilder::Build(), G4FTFPKaonBuilder::Build(), G4FTFPPionBuilder::Build(), G4FTFPProtonBuilder::Build(), G4QGSBinaryKaonBuilder::Build(), G4QGSPPiKBuilder::Build(), G4QGSPProtonBuilder::Build(), G4FTFBinaryPiKBuilder::Build(), G4QGSBinaryPionBuilder::Build(), G4QGSBinaryProtonBuilder::Build(), G4FTFBinaryNeutronBuilder::Build(), G4FTFPAntiBarionBuilder::Build(), G4FTFPNeutronBuilder::Build(), G4QGSPNeutronBuilder::Build(), G4FTFPPiKBuilder::Build(), G4QGSBinaryNeutronBuilder::Build(), G4QGSBinaryPiKBuilder::Build(), G4INCLXXProtonBuilder::Build(), G4HyperonFTFPBuilder::Build(), DicomPhysicsList::ConstructHad(), B03PhysicsList::ConstructHad(), DMXPhysicsList::ConstructHad(), GammaPhysics::ConstructProcess(), NeutronHPphysics::ConstructProcess(), MuNuclearBuilder::ConstructProcess(), G4HadronDElasticPhysics::ConstructProcess(), G4HadronHElasticPhysics::ConstructProcess(), exrdmPhysListHadron::ConstructProcess(), G4IonElasticPhysics::ConstructProcess(), G4ChargeExchangePhysics::ConstructProcess(), G4HadronElasticPhysicsLEND::ConstructProcess(), G4HadronElasticPhysicsHP::ConstructProcess(), G4HadronInelasticQBBC::ConstructProcess(), G4HadronElasticPhysics::ConstructProcess(), G4HadronPhysicsFTF_BIC::ConstructProcess(), G4HadronPhysicsFTFP_BERT_HP::ConstructProcess(), G4HadronPhysicsFTFP_BERT::ConstructProcess(), G4HadronPhysicsQGSP_FTFP_BERT::ConstructProcess(), G4HadronPhysicsShielding::ConstructProcess(), G4HadronPhysicsFTFP_BERT_TRV::ConstructProcess(), G4HadronPhysicsQGSP_BERT_HP::ConstructProcess(), G4HadronPhysicsQGSP_BIC::ConstructProcess(), G4HadronPhysicsQGSP_BERT::ConstructProcess(), G4HadronPhysicsQGS_BIC::ConstructProcess(), G4HadronPhysicsQGSP_BIC_HP::ConstructProcess(), GammaRayTelIonPhysics::ConstructProcess(), G4HadronPhysicsINCLXX::ConstructProcess(), GammaRayTelHadronPhysics::ConstructProcess(), G4HadronicAbsorptionBertini::G4HadronicAbsorptionBertini(), G4HadronicAbsorptionFritiof::G4HadronicAbsorptionFritiof(), G4MuonMinusCapture::G4MuonMinusCapture(), and CexmcHadronicProcess::RegisterProductionModel().

143 {
144  if(!a) { return; }
145  try{GetManagerPointer()->RegisterMe( a );}
146  catch(G4HadronicException & aE)
147  {
149  aE.Report(ed);
150  ed << "Unrecoverable error in " << GetProcessName()
151  << " to register " << a->GetModelName() << G4endl;
152  G4Exception("G4HadronicProcess::RegisterMe", "had001", FatalException,
153  ed);
154  }
156 }
void RegisterMe(G4HadronicInteraction *a)
void RegisterInteraction(G4HadronicProcess *, G4HadronicInteraction *)
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
static G4HadronicProcessStore * Instance()
const G4String & GetModelName() const
G4EnergyRangeManager * GetManagerPointer()
const G4String & GetProcessName() const
Definition: G4VProcess.hh:408
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
void Report(std::ostream &aS)
void G4HadronicProcess::SetEnergyMomentumCheckLevels ( G4double  relativeLevel,
G4double  absoluteLevel 
)
inline

Definition at line 160 of file G4HadronicProcess.hh.

Referenced by G4HadronicProcessStore::SetProcessAbsLevel(), and G4HadronicProcessStore::SetProcessRelLevel().

161  { epCheckLevels.first = relativeLevel;
162  epCheckLevels.second = absoluteLevel;
163  levelsSetByProcess = true;
164  }
void G4HadronicProcess::SetEnergyRangeManager ( const G4EnergyRangeManager value)
inlineprotected

Definition at line 185 of file G4HadronicProcess.hh.

186  { theEnergyRangeManager = value; }
const XML_Char int const XML_Char * value
void G4HadronicProcess::SetEpReportLevel ( G4int  level)
inline

Definition at line 157 of file G4HadronicProcess.hh.

References epReportLevel.

158  { epReportLevel = level; }

Field Documentation

G4int G4HadronicProcess::epReportLevel
protected
G4HadProjectile G4HadronicProcess::thePro
protected

Definition at line 220 of file G4HadronicProcess.hh.

Referenced by G4HadronStoppingProcess::AtRestDoIt(), and PostStepDoIt().

G4ParticleChange* G4HadronicProcess::theTotalResult
protected

The documentation for this class was generated from the following files: