Import Geant4 9.0.0 source tree
This commit is contained in:
@@ -31,7 +31,7 @@
|
||||
#include <sstream>
|
||||
#include <stdlib.h>
|
||||
#include "G4HadronicProcess.hh"
|
||||
#include "G4EffectiveCharge.hh"
|
||||
// #include "G4EffectiveCharge.hh"
|
||||
#include "G4HadProjectile.hh"
|
||||
#include "G4ElementVector.hh"
|
||||
#include "G4Track.hh"
|
||||
@@ -62,8 +62,8 @@ namespace G4HadronicProcess_local
|
||||
}
|
||||
}
|
||||
|
||||
G4IsoParticleChange * G4HadronicProcess::theIsoResult = NULL;
|
||||
G4IsoParticleChange * G4HadronicProcess::theOldIsoResult = NULL;
|
||||
G4IsoParticleChange * G4HadronicProcess::theIsoResult = 0;
|
||||
G4IsoParticleChange * G4HadronicProcess::theOldIsoResult = 0;
|
||||
G4bool G4HadronicProcess::isoIsEnabled = true;
|
||||
|
||||
void G4HadronicProcess::
|
||||
@@ -77,7 +77,7 @@ G4HadronicProcess::G4HadronicProcess( const G4String &processName,
|
||||
G4VDiscreteProcess( processName, aType)
|
||||
{
|
||||
ModelingState = 0;
|
||||
isoIsOnAnyway = 0;
|
||||
isoIsOnAnyway = -1;
|
||||
theTotalResult = new G4ParticleChange();
|
||||
theCrossSectionDataStore = new G4CrossSectionDataStore();
|
||||
aScaleFactor = 1;
|
||||
@@ -88,13 +88,13 @@ G4VDiscreteProcess( processName, aType)
|
||||
G4HadronicProcess::~G4HadronicProcess()
|
||||
{
|
||||
delete theTotalResult;
|
||||
std::for_each(theProductionModels.begin(),
|
||||
theProductionModels.end(),
|
||||
G4Delete());
|
||||
std::for_each(theBias.begin(),
|
||||
theBias.end(),
|
||||
G4Delete());
|
||||
if(theOldIsoResult) delete theOldIsoResult;
|
||||
|
||||
std::for_each(theProductionModels.begin(),
|
||||
theProductionModels.end(), G4Delete());
|
||||
std::for_each(theBias.begin(), theBias.end(), G4Delete());
|
||||
|
||||
delete theOldIsoResult; delete theIsoResult;
|
||||
delete theCrossSectionDataStore;
|
||||
}
|
||||
|
||||
void G4HadronicProcess::RegisterMe( G4HadronicInteraction *a )
|
||||
@@ -223,7 +223,6 @@ const G4Track &aTrack, const G4Step &)
|
||||
return theTotalResult;
|
||||
}
|
||||
|
||||
|
||||
// Get kinetic energy per nucleon for ions
|
||||
|
||||
if(aParticle->GetDefinition()->GetBaryonNumber() > 1.5)
|
||||
@@ -314,7 +313,6 @@ const G4Track &aTrack, const G4Step &)
|
||||
}
|
||||
while(!result);
|
||||
|
||||
|
||||
if(!ModelingState && !getenv("BypassAllSafetyChecks") )
|
||||
{
|
||||
G4cout << "ERROR IN EXECUTION -- HADRONIC PROCESS STATE NOT VALID"<<G4endl;
|
||||
@@ -322,7 +320,6 @@ const G4Track &aTrack, const G4Step &)
|
||||
}
|
||||
|
||||
// NOT USED ?? Projectile particle has changed character during interaction
|
||||
|
||||
if(result->GetStatusChange() == isAlive &&
|
||||
thePro.GetDefinition() != aTrack.GetDefinition())
|
||||
{
|
||||
@@ -333,6 +330,7 @@ const G4Track &aTrack, const G4Step &)
|
||||
|
||||
result->SetTrafoToLab(thePro.GetTrafoToLab());
|
||||
|
||||
/*
|
||||
// Loop over charged ion secondaries
|
||||
|
||||
for(G4int i=0; i<result->GetNumberOfSecondaries(); i++)
|
||||
@@ -354,7 +352,8 @@ const G4Track &aTrack, const G4Step &)
|
||||
aSecTrack->SetCharge(charge);
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
if(getenv("HadronicDoitLogging") )
|
||||
{
|
||||
G4cout << "HadronicDoitLogging "
|
||||
@@ -391,6 +390,7 @@ const G4Track &aTrack, const G4Step &)
|
||||
FillTotalResult(result, aTrack);
|
||||
if(G4HadronicProcess_debug_flag)
|
||||
std::cout << "@@@@ hadronic process end "<< std::endl;
|
||||
|
||||
return theTotalResult;
|
||||
}
|
||||
|
||||
@@ -401,23 +401,25 @@ G4HadronicProcess::DoIsotopeCounting(G4HadFinalState * aResult,
|
||||
const G4Nucleus & aNucleus)
|
||||
{
|
||||
// get the PC from iso-production
|
||||
if(theOldIsoResult) delete theOldIsoResult;
|
||||
if(theIsoResult) delete theIsoResult;
|
||||
delete theOldIsoResult;
|
||||
theOldIsoResult = 0;
|
||||
delete theIsoResult;
|
||||
theIsoResult = new G4IsoParticleChange;
|
||||
G4bool done = false;
|
||||
G4IsoResult * anIsoResult = NULL;
|
||||
G4IsoResult * anIsoResult = 0;
|
||||
for(unsigned int i=0; i<theProductionModels.size(); i++)
|
||||
{
|
||||
anIsoResult = theProductionModels[i]->GetIsotope(aTrack, aNucleus);
|
||||
if(anIsoResult!=NULL)
|
||||
if(anIsoResult!=0)
|
||||
{
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if none in charge, use default iso production
|
||||
|
||||
// If no production models active, use default iso production
|
||||
if(!done) anIsoResult = ExtractResidualNucleus(aTrack, aNucleus, aResult);
|
||||
|
||||
|
||||
// Add all info explicitely and add typename from model called.
|
||||
theIsoResult->SetIsotope(anIsoResult->GetIsotope());
|
||||
theIsoResult->SetProductionPosition(aTrack.GetPosition());
|
||||
@@ -427,6 +429,17 @@ G4HadronicProcess::DoIsotopeCounting(G4HadFinalState * aResult,
|
||||
theIsoResult->SetProducer(typeid(*theInteraction).name());
|
||||
|
||||
delete anIsoResult;
|
||||
|
||||
// If isotope production is enabled the GetIsotopeProductionInfo()
|
||||
// method must be called or else a memory leak will result
|
||||
//
|
||||
// The following code will fix the memory leak, but remove the
|
||||
// isotope information:
|
||||
//
|
||||
// if(theIsoResult) {
|
||||
// delete theIsoResult;
|
||||
// theIsoResult = 0;
|
||||
// }
|
||||
|
||||
return aResult;
|
||||
}
|
||||
@@ -470,14 +483,6 @@ G4HadronicProcess::ExtractResidualNucleus(const G4Track&,
|
||||
G4String biff = ost1.str();
|
||||
G4IsoResult * theResult = new G4IsoResult(biff, aNucleus);
|
||||
|
||||
// char the1[100] = {""};
|
||||
// std::ostrstream ost1(the1, 100, std::ios::out);
|
||||
// ost1 <<Z<<"_"<<A<<"\0";
|
||||
// G4String * biff = new G4String(the1);
|
||||
// G4IsoResult * theResult = new G4IsoResult(*biff, aNucleus);
|
||||
// // cleaning up.
|
||||
// delete biff;
|
||||
|
||||
return theResult;
|
||||
}
|
||||
|
||||
@@ -511,6 +516,7 @@ G4HadronicProcess::FillTotalResult(G4HadFinalState * aR, const G4Track & aT)
|
||||
theTotalResult->ProposeTrackStatus(fAlive);
|
||||
G4double rotation = 2.*pi*G4UniformRand();
|
||||
G4ThreeVector it(0., 0., 1.);
|
||||
|
||||
/*
|
||||
if(xBiasOn)
|
||||
{
|
||||
@@ -596,32 +602,29 @@ G4HadronicProcess::FillTotalResult(G4HadFinalState * aR, const G4Track & aT)
|
||||
G4Exception("G4HadronicProcess", "007", FatalException,
|
||||
"use of unsupported track-status.");
|
||||
}
|
||||
|
||||
if(GetProcessName() != "hElastic" && GetProcessName() != "HadronElastic"
|
||||
&& theTotalResult->GetTrackStatus()==fAlive
|
||||
&& aR->GetStatusChange()==isAlive
|
||||
)
|
||||
{
|
||||
G4double newWeight = theTotalResult->GetParentWeight();
|
||||
G4double newM=aT.GetDefinition()->GetPDGMass();
|
||||
G4double newE=aR->GetEnergyChange() + newM;
|
||||
G4double newP=std::sqrt(newE*newE - newM*newM);
|
||||
G4DynamicParticle * aNew =
|
||||
new G4DynamicParticle(aT.GetDefinition(), newE, newP*aR->GetMomentumChange());
|
||||
// std::cout << "Debug 0 "<<aR->GetNumberOfSecondaries()<<std::endl;
|
||||
//std::cout << "Debug 1 "<<aR->GetEnergyChange()<<" "<< aNew->GetTotalEnergy() <<std::endl;
|
||||
//std::cout << "Debug 2 "<<aR->GetMomentumChange()<<" "<< aNew->GetMomentum() << std::endl;
|
||||
//std::cout << "Debug 3 "<<newWeight<<std::endl;
|
||||
//std::cout << std::endl;
|
||||
// Use for debugging: G4double newWeight = theTotalResult->GetParentWeight();
|
||||
|
||||
G4double newKE = std::max(DBL_MIN, aR->GetEnergyChange());
|
||||
G4DynamicParticle* aNew = new G4DynamicParticle(aT.GetDefinition(),
|
||||
aR->GetMomentumChange(),
|
||||
newKE);
|
||||
G4HadSecondary* theSec = new G4HadSecondary(aNew, 1.0);
|
||||
aR->AddSecondary(theSec);
|
||||
aR->SetStatusChange(stopAndKill);
|
||||
|
||||
theTotalResult->ProposeTrackStatus(fStopAndKill);
|
||||
theTotalResult->ProposeEnergy( 0.0 );
|
||||
//std::cout << "Debug 4 "<< aR->GetNumberOfSecondaries() <<std::endl;
|
||||
|
||||
}
|
||||
theTotalResult->ProposeLocalEnergyDeposit(aR->GetLocalEnergyDeposit());
|
||||
theTotalResult->SetNumberOfSecondaries(aR->GetNumberOfSecondaries());
|
||||
|
||||
|
||||
if(aR->GetStatusChange() != stopAndKill)
|
||||
{
|
||||
G4double newM=aT.GetDefinition()->GetPDGMass();
|
||||
@@ -633,12 +636,13 @@ G4HadronicProcess::FillTotalResult(G4HadFinalState * aR, const G4Track & aT)
|
||||
newP4*=aR->GetTrafoToLab();
|
||||
theTotalResult->ProposeMomentumDirection(newP4.vect().unit());
|
||||
}
|
||||
|
||||
for(G4int i=0; i<aR->GetNumberOfSecondaries(); i++)
|
||||
{
|
||||
//std::cout << "Debug 5 "<< aR->GetNumberOfSecondaries() <<std::endl;
|
||||
G4LorentzVector theM = aR->GetSecondary(i)->GetParticle()->Get4Momentum();
|
||||
theM.rotate(rotation, it);
|
||||
theM*=aR->GetTrafoToLab();
|
||||
|
||||
if(go_wild(theM.e()))
|
||||
{
|
||||
G4Exception("G4HadronicProcess", "007", FatalException,
|
||||
@@ -651,12 +655,15 @@ G4HadronicProcess::FillTotalResult(G4HadFinalState * aR, const G4Track & aT)
|
||||
G4Exception("G4HadronicProcess", "007", FatalException,
|
||||
"secondary track received NaN momentum.");
|
||||
}
|
||||
|
||||
aR->GetSecondary(i)->GetParticle()->Set4Momentum(theM);
|
||||
G4double time = aR->GetSecondary(i)->GetTime();
|
||||
if(time<0) time = aT.GetGlobalTime();
|
||||
|
||||
G4Track* track = new G4Track(aR->GetSecondary(i)->GetParticle(),
|
||||
aT.GetGlobalTime(),
|
||||
aT.GetPosition());
|
||||
|
||||
G4double newWeight = aT.GetWeight()*aR->GetSecondary(i)->GetWeight();
|
||||
//static G4double pinelcount=0;
|
||||
if(xBiasOn) newWeight *= XBiasSecondaryWeight();
|
||||
@@ -681,10 +688,10 @@ G4HadronicProcess::FillTotalResult(G4HadFinalState * aR, const G4Track & aT)
|
||||
<<" "<<aT.GetDefinition()->GetParticleName()
|
||||
<<G4endl;
|
||||
}
|
||||
|
||||
track->SetTouchableHandle(aT.GetTouchableHandle());
|
||||
theTotalResult->AddSecondary(track);
|
||||
}
|
||||
|
||||
aR->Clear();
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user