Import Geant4 0.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-01 15:25:35 +02:00
parent 54d6b71f95
commit b97f8d0df7
3237 changed files with 807095 additions and 0 deletions
@@ -0,0 +1,122 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4EnergyRangeManager.cc,v 2.3 1998/07/13 17:38:15 fjones Exp $
// GEANT4 tag $Name: geant4-00 $
//
// Hadronic Process: Energy Range Manager
// original by H.P. Wellisch
// modified by J.L. Chuma, TRIUMF, 22-Nov-1996
// Last modified: 24-Mar-1997
// fix in the counter-hndling: H.P. Wellisch 04-Apr-97
// throw an exception if no model found: J.L. Chuma 04-Apr-97
#include "G4EnergyRangeManager.hh"
#include "Randomize.hh"
G4EnergyRangeManager::G4EnergyRangeManager(
const G4EnergyRangeManager &right )
{
if( this != &right )
{
for( G4int i=0; i<theHadronicInteractionCounter; ++i )
theHadronicInteraction[i] = right.theHadronicInteraction[i];
theHadronicInteractionCounter = right.theHadronicInteractionCounter;
}
}
G4EnergyRangeManager &
G4EnergyRangeManager::operator=(
const G4EnergyRangeManager &right )
{
if( this != &right )
{
for( G4int i=0; i<theHadronicInteractionCounter; ++i )
theHadronicInteraction[i] =
right.theHadronicInteraction[i];
theHadronicInteractionCounter =
right.theHadronicInteractionCounter;
}
return *this;
}
void
G4EnergyRangeManager::RegisterMe(
G4HadronicInteraction *a )
{
if( theHadronicInteractionCounter+1 > MAX_NUMBER_OF_MODELS )
G4Exception(
"EnergyRangeManager::RegisterMe: TOO MANY MODELS");
theHadronicInteraction[ theHadronicInteractionCounter++ ] = a;
}
G4HadronicInteraction *
G4EnergyRangeManager::GetHadronicInteraction(
const G4double kineticEnergy,
const G4Material *aMaterial,
const G4Element *anElement ) const
{
G4int counter = GetHadronicInteractionCounter();
if( counter == 0 )
G4Exception("GetHadronicInteraction: NO MODELS STORED");
G4int cou = 0, memory = 0, memor2 = 0;
G4double emi1 = 0.0, ema1 = 0.0, emi2 = 0.0, ema2 = 0.0;
for( G4int i=0; i<counter; i++ ) {
G4double low = theHadronicInteraction[i]->GetMinEnergy( aMaterial, anElement );
// Work-around for particles with 0 kinetic energy, which still
// require a model to return a ParticleChange
if (low == 0.) low = -DBL_MIN;
G4double high = theHadronicInteraction[i]->GetMaxEnergy( aMaterial, anElement );
if( low < kineticEnergy && high >= kineticEnergy )
{
++cou;
emi2 = emi1;
ema2 = ema1;
emi1 = low;
ema1 = high;
memor2 = memory;
memory = i;
}
}
G4int m;
G4double rand;
switch ( cou )
{
case 0:
G4Exception("GetHadronicInteraction: No model found for this energy range");
return 0;
case 1:
m = memory;
break;
case 2:
if( (emi2<=emi1 && ema2>=ema1) || (emi2>=emi1 && ema2<=ema1) )
G4Exception(
"GetHadronicInteraction: Energy ranges of two models fully overlapping");
rand = G4UniformRand();
if( emi1 < emi2 )
{
if( (ema1-kineticEnergy)/(ema1-emi2)<rand )
m = memory;
else
m = memor2;
} else {
if( (ema2-kineticEnergy)/(ema2-emi1)<rand )
m = memor2;
else
m = memory;
}
break;
default:
G4Exception(
"GetHadronicInteraction: More than two competing models in this energy range");
}
return theHadronicInteraction[m];
}
/* end of file */
@@ -0,0 +1,112 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4HadronInelasticProcess.cc,v 2.1 1998/08/24 11:56:59 hpw Exp $
// GEANT4 tag $Name: geant4-00 $
//
// Hadronic Inelastic Process Class
// J.L. Chuma, TRIUMF, 24-Mar-1997
// Last modified: 27-Mar-1997
// J.P. Wellisch: Bug hunting, 23-Apr-97
// Modified by J.L.Chuma 8-Jul-97 to eliminate possible division by zero for sigma
//
// 14-APR-98 F.W.Jones: variant G4HadronInelastic process for
// G4CrossSectionDataSet/DataStore class design.
//
// 17-JUN-98 F.W.Jones: removed extraneous code causing core dump.
//
#include "G4HadronInelasticProcess.hh"
G4double G4HadronInelasticProcess::GetMeanFreePath(
const G4Track &aTrack,
G4double previousStepSize,
G4ForceCondition *condition )
{
const G4DynamicParticle *aParticle = aTrack.GetDynamicParticle();
if( aParticle->GetDefinition() != theParticle )
G4Exception( this->GetProcessName()+
" called for "+
aParticle->GetDefinition()->GetParticleName() );
G4Material *aMaterial = aTrack.GetMaterial();
G4int nElements = aMaterial->GetNumberOfElements();
// returns the mean free path in GEANT4 internal units
const RWTPtrVector<G4Element> *theElementVector =
aMaterial->GetElementVector();
const G4double *theAtomicNumDensityVector =
aMaterial->GetAtomicNumDensityVector();
G4Element *anElement = (*theElementVector)[0];
G4int j = anElement->GetIndex();
// This apparently should not be here (not useful and dumps core)
// FWJ 17-JUN-1998
// G4bool isOutRange;
// G4double xSection = (*((*thePhysicsTable)(j))).GetValue(
// aParticle->GetTotalMomentum()/GeV, isOutRange );
G4double sigma = 0.0;
for( G4int i=0; i<nElements; ++i )
{
G4double xSection =
GetMicroscopicCrossSection( aParticle, (*theElementVector)[i] );
sigma += theAtomicNumDensityVector[i] * xSection;
}
if( sigma > 0.0 )
return 1.0/sigma;
else
return DBL_MAX;
}
void
G4HadronInelasticProcess::BuildThePhysicsTable()
{
if (!theCrossSectionDataStore) {
// G4Exception("G4HadronInelasticProcess::BuildThePhysicsTable: "
// "no CrossSectionDataStore");
return;
}
theCrossSectionDataStore->BuildPhysicsTable(*theParticle);
// G4int numberOfElements = G4Element::GetNumberOfElements();
// thePhysicsTable = new G4PhysicsTable( numberOfElements );
//
// // make a PhysicsVector for each element
//
// static const G4ElementTable *theElementTable = G4Element::GetElementTable();
// for( G4int i=0; i<numberOfElements; ++i )
// (*thePhysicsTable)(i) =
// theCrossSectionData.MakePhysicsVector( *this, *theParticle,
// (*theElementTable)[i] );
}
G4double G4HadronInelasticProcess::GetMicroscopicCrossSection(
const G4DynamicParticle *aParticle,
const G4Element *anElement)
{
// returns the microscopic cross section in GEANT4 internal units
if (!theCrossSectionDataStore) {
G4Exception("G4HadronInelasticProcess::GetMicroscopicCrossSection:"
"no CrossSectionDataStore");
return DBL_MIN;
}
return theCrossSectionDataStore->GetCrossSection(aParticle, anElement);
// G4bool isOutRange;
// G4int j = anElement->GetIndex();
//
// G4double s = (*((*thePhysicsTable)(j))).GetValue(
// aParticle->GetTotalMomentum()/GeV, isOutRange );
// return s;
}
/* end of file */
@@ -0,0 +1,206 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4HadronicInteraction.cc,v 2.2 1998/07/13 17:22:13 urbi Exp $
// GEANT4 tag $Name: geant4-00 $
//
// Hadronic Interaction base class
// original by H.P. Wellisch
// modified by J.L. Chuma, TRIUMF, 21-Mar-1997
// Last modified: 04-Apr-1997
#include "G4HadronicInteraction.hh"
G4double
G4HadronicInteraction::GetMinEnergy(
const G4Material *aMaterial, const G4Element *anElement ) const
{
G4int i;
if( IsBlocked(aMaterial) )return 0.*GeV;
if( IsBlocked(anElement) )return 0.*GeV;
for( i=0; i<theMinCounterElements; ++i )
{
if( anElement == theMinElements[i] )return theMinEnergyListElements[i];
}
for( i=0; i<theMinCounter; ++i )
{
if( aMaterial == theMinMaterials[i] )return theMinEnergyList[i];
}
if( verboseLevel > 0 )
G4cout << "*** Warning from HadronicInteraction::GetMinEnergy" << endl
<< " material " << aMaterial->GetName()
<< " not found in min energy List" << endl;
return theMinEnergy;
}
void
G4HadronicInteraction::SetMinEnergy(
G4double anEnergy,
G4Element *anElement )
{
if( IsBlocked(anElement) )
G4cout << "*** Warning from HadronicInteraction::SetMinEnergy" << endl
<< " The model is not active for the Element "
<< anElement->GetName() << "." << endl;
for( G4int i=0; i<theMinCounterElements; ++i )
{
if( anElement == theMinElements[i] )
{
theMinEnergyListElements[i] = anEnergy;
return;
}
}
if( theMinCounterElements == MAX_LIST_SIZE )
G4Exception("SetMinEnergy: exceeded size of min energy element List");
theMinElements[theMinCounterElements] = anElement;
theMinEnergyListElements[theMinCounterElements++] = anEnergy;
}
void
G4HadronicInteraction::SetMinEnergy(
G4double anEnergy,
G4Material *aMaterial )
{
if( IsBlocked(aMaterial) )
G4cout << "*** Warning from HadronicInteraction::SetMinEnergy" << endl
<< " The model is not active for the Material "
<< aMaterial->GetName() << "." << endl;
for( G4int i=0; i<theMinCounter; ++i )
{
if( aMaterial == theMinMaterials[i] )
{
theMinEnergyList[i] = anEnergy;
return;
}
}
if( theMinCounter == MAX_LIST_SIZE )
G4Exception("SetMinEnergy: exceeded size of min energy material List");
theMinMaterials[theMinCounter] = aMaterial;
theMinEnergyList[theMinCounter++] = anEnergy;
}
G4double
G4HadronicInteraction::GetMaxEnergy(
const G4Material *aMaterial, const G4Element *anElement ) const
{
G4int i;
if( IsBlocked(aMaterial) )return 0.0*GeV;
if( IsBlocked(anElement) )return 0.0*GeV;
for( i=0; i<theMaxCounterElements; ++i )
{
if( anElement == theMaxElements[i] )return theMaxEnergyListElements[i];
}
for( i=0; i<theMaxCounter; ++i )
{
if( aMaterial == theMaxMaterials[i] )return theMaxEnergyList[i];
}
if( verboseLevel > 0 )
G4cout << "*** Warning from HadronicInteraction::GetMaxEnergy" << endl
<< " material " << aMaterial->GetName()
<< " not found in min energy List" << endl;
return theMaxEnergy;
}
void
G4HadronicInteraction::SetMaxEnergy(
G4double anEnergy,
G4Element *anElement )
{
if( IsBlocked(anElement) )
G4cout << "*** Warning from HadronicInteraction::SetMaxEnergy" << endl
<< "Warning: The model is not active for the Element "
<< anElement->GetName() << "." << endl;
for( G4int i=0; i<theMaxCounterElements; ++i )
{
if( anElement == theMaxElements[i] )
{
theMaxEnergyListElements[i] = anEnergy;
return;
}
}
if( theMaxCounterElements == MAX_LIST_SIZE )
G4Exception("SetMaxEnergy: exceeded size of max energy element List");
theMaxElements[theMaxCounterElements] = anElement;
theMaxEnergyListElements[theMaxCounterElements++] = anEnergy;
}
void
G4HadronicInteraction::SetMaxEnergy(
G4double anEnergy,
G4Material *aMaterial )
{
if( IsBlocked(aMaterial) )
G4cout << "*** Warning from HadronicInteraction::SetMaxEnergy" << endl
<< "Warning: The model is not active for the Material "
<< aMaterial->GetName() << "." << endl;
for( G4int i=0; i<theMaxCounter; ++i )
{
if( aMaterial == theMaxMaterials[i] )
{
theMaxEnergyList[i] = anEnergy;
return;
}
}
if( theMaxCounter == MAX_LIST_SIZE )
G4Exception("SetMaxEnergy: exceeded size of max energy material List");
theMaxMaterials[theMaxCounter] = aMaterial;
theMaxEnergyList[theMaxCounter++] = anEnergy;
}
void
G4HadronicInteraction::DeActivateFor( G4Material *aMaterial )
{
if( theBlockedCounter == MAX_LIST_SIZE )
G4Exception("DeActivateFor: exceeded size of blocked material List");
theBlockedList[ theBlockedCounter++ ] = aMaterial;
}
void
G4HadronicInteraction::DeActivateFor( G4Element *anElement )
{
if( theBlockedCounterElements == MAX_LIST_SIZE )
G4Exception("DeActivateFor: exceeded size of blocked elements List");
theBlockedListElements[ theBlockedCounterElements++ ] = anElement;
}
G4bool
G4HadronicInteraction::IsBlocked( const G4Material *aMaterial ) const
{
G4bool tt = false;
for( G4int i=0; i<theBlockedCounter; ++i )
{
if( aMaterial == theBlockedList[i] )
{
tt = true;
break;
}
}
return tt;
}
G4bool
G4HadronicInteraction::IsBlocked( const G4Element *anElement ) const
{
G4bool tt = false;
for( G4int i=0; i<theBlockedCounterElements; ++i )
{
if( anElement == theBlockedListElements[i] )
{
tt = true;
break;
}
}
return tt;
}
/* end of file */
@@ -0,0 +1,72 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
// $Id: G4HadronicProcess.cc,v 2.0 1998/07/02 16:22:25 gunter Exp $
// GEANT4 tag $Name: geant4-00 $
//
// HPW to implement the choosing of an element for scattering.
#include "G4HadronicProcess.hh"
G4Element * G4HadronicProcess::ChooseAandZ(
const G4DynamicParticle *aParticle, const G4Material *aMaterial )
{
currentZ = 0;
currentN = 0;
const G4int numberOfElements = aMaterial->GetNumberOfElements();
const G4ElementVector *theElementVector = aMaterial->GetElementVector();
if( numberOfElements == 1 )
{
currentZ = G4double((*theElementVector)(0)->GetZ());
currentN = (*theElementVector)(0)->GetN();
targetNucleus.SetParameters(currentN, currentZ);
return (*theElementVector)(0);
}
const G4double *theAtomicNumberDensity = aMaterial->GetAtomicNumDensityVector();
G4double crossSectionTotal = 0;
G4int i;
for( i=0; i < numberOfElements; ++i )
crossSectionTotal += theAtomicNumberDensity[i] *
dispatch->GetMicroscopicCrossSection( aParticle, (*theElementVector)(i) );
G4double crossSectionSum= 0.;
G4double random = G4UniformRand()*crossSectionTotal;
for( i=0; i < numberOfElements; ++i )
{
crossSectionSum += theAtomicNumberDensity[i] *
dispatch->GetMicroscopicCrossSection( aParticle, (*theElementVector)(i) );
if( random<=crossSectionSum )
{
currentZ = G4double((*theElementVector)(i)->GetZ());
currentN = (*theElementVector)(i)->GetN();
targetNucleus.SetParameters(currentN, currentZ);
return (*theElementVector)(i);
}
}
currentZ = G4double((*theElementVector)(numberOfElements-1)->GetZ());
currentN = (*theElementVector)(numberOfElements-1)->GetN();
targetNucleus.SetParameters(currentN, currentZ);
return (*theElementVector)(numberOfElements-1);
}
G4VParticleChange *G4HadronicProcess::GeneralPostStepDoIt(
const G4Track &aTrack, const G4Step &aStep )
{
const G4DynamicParticle *aParticle = aTrack.GetDynamicParticle();
G4Material *aMaterial = aTrack.GetMaterial();
G4double kineticEnergy = aParticle->GetKineticEnergy();
G4Element * anElement = ChooseAandZ( aParticle, aMaterial );
theInteraction = ChooseHadronicInteraction( kineticEnergy,
aMaterial, anElement );
G4VParticleChange *result =
theInteraction->ApplyYourself( aTrack, targetNucleus);
ResetNumberOfInteractionLengthLeft();
return result;
}
/* end of file */
@@ -0,0 +1,365 @@
// This code implementation is the intellectual property of
// the RD44 GEANT4 collaboration.
//
// By copying, distributing or modifying the Program (or any work
// based on the Program) you indicate your acceptance of this statement,
// and all its terms.
//
//
// Hadronic Process: Inelastic Interaction
// original by H.P. Wellisch
// modified by J.L. Chuma, TRIUMF, 22-Nov-1996
// Last modified: 27-Mar-1997
// J.P. Wellisch: 23-Apr-97: G4Exception removed
// J.P. Wellisch: 24-Apr-97: correction for SetUpPions
// Modified by J.L. Chuma, 30-Apr-97: added originalTarget to CalculateMomenta
// since TwoBody needed to reset the target particle
// J.L. Chuma, 20-Jun-97: Modified CalculateMomenta to correct the decision process
// for whether to use GenerateXandPt or TwoCluster
// J.L. Chuma, 06-Aug-97: added original incident particle, before Fermi motion and
// evaporation effects are included, needed for calculating
// self absorption and corrections for single particle spectra
// HPW removed misunderstanding of LocalEnergyDeposit, 11.04.98.
#include "G4InelasticInteraction.hh"
#include "Randomize.hh"
G4double
G4InelasticInteraction::Pmltpc( // used in Cascade functions
G4int np, G4int nm, G4int nz, G4int n, G4double b, G4double c )
{
const G4double expxu = 82.; // upper bound for arg. of exp
const G4double expxl = -expxu; // lower bound for arg. of exp
G4double npf = 0.0;
G4double nmf = 0.0;
G4double nzf = 0.0;
G4int i;
for( i=2; i<=np; i++ )npf += log((double)i);
for( i=2; i<=nm; i++ )nmf += log((double)i);
for( i=2; i<=nz; i++ )nzf += log((double)i);
G4double r;
r = min( expxu, max( expxl, -(np-nm+nz+b)*(np-nm+nz+b)/(2*c*c*n*n)-npf-nmf-nzf ) );
return exp(r);
}
G4bool
G4InelasticInteraction::MarkLeadingStrangeParticle(
const G4ReactionProduct &currentParticle,
const G4ReactionProduct &targetParticle,
G4ReactionProduct &leadParticle )
{
// the following was in GenerateXandPt and TwoCluster
// add a parameter to the GenerateXandPt function telling it about the strange particle
//
// assumes that the original particle was a strange particle
//
G4bool lead = false;
if( (currentParticle.GetMass() >= G4KaonPlus::KaonPlus()->GetPDGMass()) &&
(currentParticle.GetDefinition() != G4Proton::Proton()) &&
(currentParticle.GetDefinition() != G4Neutron::Neutron()) )
{
lead = true;
leadParticle = currentParticle; // set lead to the incident particle
}
else if( (targetParticle.GetMass() >= G4KaonPlus::KaonPlus()->GetPDGMass()) &&
(targetParticle.GetDefinition() != G4Proton::Proton()) &&
(targetParticle.GetDefinition() != G4Neutron::Neutron()) )
{
lead = true;
leadParticle = targetParticle; // set lead to the target particle
}
return lead;
}
void
G4InelasticInteraction::SetUpPions(
const G4int np,
const G4int nm,
const G4int nz,
G4FastVector<G4ReactionProduct,128> &vec,
G4int &vecLen )
{
if( np+nm+nz == 0 )return;
G4int i;
G4ReactionProduct *p = new G4ReactionProduct [np+nm+nz];
for( i=0; i<np; ++i )
{
p[i].SetDefinition( G4PionPlus::PionPlus() );
(G4UniformRand() < 0.5) ? p[i].SetSide( -1 ) : p[i].SetSide( 1 );
vec.SetElement( vecLen++, &p[i] );
}
for( i=np; i<np+nm; ++i )
{
p[i].SetDefinition( G4PionMinus::PionMinus() );
(G4UniformRand() < 0.5) ? p[i].SetSide( -1 ) : p[i].SetSide( 1 );
vec.SetElement( vecLen++, &p[i] );
}
for( i=np+nm; i<np+nm+nz; ++i )
{
p[i].SetDefinition( G4PionZero::PionZero() );
(G4UniformRand() < 0.5) ? p[i].SetSide( -1 ) : p[i].SetSide( 1 );
vec.SetElement( vecLen++, &p[i] );
}
}
void
G4InelasticInteraction::GetNormalizationConstant(
const G4double energy, // MeV, <0 means annihilation channels
G4double &n,
G4double &anpn )
{
const G4double expxu = 82.; // upper bound for arg. of exp
const G4double expxl = -expxu; // lower bound for arg. of exp
const G4int numSec = 60;
//
// the only difference between the calculation for annihilation channels
// and normal is the starting value, iBegin, for the loop below
//
G4int iBegin = 1;
G4double en = energy;
if( energy < 0.0 )
{
iBegin = 2;
en *= -1.0;
}
//
// number of total particles vs. centre of mass Energy - 2*proton mass
//
G4double aleab = log(en/GeV);
n = 3.62567 + aleab*(0.665843 + aleab*(0.336514 + aleab*(0.117712 + 0.0136912*aleab)));
n -= 2.0;
//
// normalization constant for kno-distribution
//
anpn = 0.0;
G4double test, temp;
for( G4int i=iBegin; i<=numSec; ++i )
{
temp = pi*i/(2.0*n*n);
test = exp( min( expxu, max( expxl, -(pi/4.0)*(i*i)/(n*n) ) ) );
if( temp < 1.0 )
{
if( test >= 1.0e-10 )anpn += temp*test;
}
else
anpn += temp*test;
}
}
void
G4InelasticInteraction::CalculateMomenta(
G4FastVector<G4ReactionProduct,128> &vec,
G4int &vecLen,
const G4DynamicParticle *originalIncident, // the original incident particle
const G4DynamicParticle *originalTarget,
G4ReactionProduct &modifiedOriginal, // Fermi motion and evap. effects included
G4Nucleus &targetNucleus,
G4ReactionProduct &currentParticle,
G4ReactionProduct &targetParticle,
G4bool &incidentHasChanged,
G4bool &targetHasChanged,
G4bool quasiElastic )
{
theReactionDynamics.ProduceStrangeParticlePairs( vec, vecLen,
modifiedOriginal, originalTarget,
currentParticle, targetParticle,
incidentHasChanged, targetHasChanged );
if( quasiElastic )
{
theReactionDynamics.TwoBody( vec, vecLen,
modifiedOriginal, originalTarget,
currentParticle, targetParticle,
targetNucleus, targetHasChanged );
return;
}
G4ReactionProduct leadingStrangeParticle;
G4bool leadFlag = MarkLeadingStrangeParticle( currentParticle,
targetParticle,
leadingStrangeParticle );
//
// Note: the number of secondaries can be reduced in GenerateXandPt and TwoCluster
//
G4bool finishedGenXPt = false;
G4bool annihilation = false;
if( originalIncident->GetDefinition()->GetPDGEncoding() < 0 &&
currentParticle.GetMass() == 0.0 && targetParticle.GetMass() == 0.0 )
{
// original was an anti-particle and annihilation has taken place
annihilation = true;
G4double ekcor = 1.0;
G4double ek = originalIncident->GetKineticEnergy()/GeV;
const G4double tarmas = originalTarget->GetDefinition()->GetPDGMass()/GeV;
if( ek > 1.0 )ekcor = 1./ek;
const G4double atomicWeight = targetNucleus.GetN();
ek = 2*tarmas + ek*(1.+ekcor/atomicWeight);
modifiedOriginal.SetKineticEnergy( ek*GeV );
//
// evaporation -- re-calculate black track energies
// this was Done already just before the cascade
//
G4double tkin = targetNucleus.EvaporationEffects( ek*GeV )/GeV;
ek -= tkin;
ek = max( 0.0001, ek );
modifiedOriginal.SetKineticEnergy( ek*GeV );
G4double amas = originalIncident->GetDefinition()->GetPDGMass()/GeV;
G4double et = ek + amas;
G4double p = sqrt( abs(et*et-amas*amas) );
G4double pp = modifiedOriginal.GetMomentum().mag()/GeV;
if( pp > 0.0 )
{
G4ThreeVector momentum = modifiedOriginal.GetMomentum();
modifiedOriginal.SetMomentum( momentum * (p/pp) );
}
if( ek <= 0.0001 )
{
modifiedOriginal.SetKineticEnergy( 0.0 );
modifiedOriginal.SetMomentum( 0.0, 0.0, 0.0 );
}
}
const G4double twsup[] = { 1.0, 0.7, 0.5, 0.3, 0.2, 0.1 };
G4double rand1 = G4UniformRand();
G4double rand2 = G4UniformRand();
if( annihilation || (vecLen >= 6) ||
(modifiedOriginal.GetKineticEnergy()/GeV >= 1.0) &&
(((originalIncident->GetDefinition() == G4KaonPlus::KaonPlus() ||
originalIncident->GetDefinition() == G4KaonMinus::KaonMinus() ||
originalIncident->GetDefinition() == G4KaonZeroLong::KaonZeroLong() ||
originalIncident->GetDefinition() == G4KaonZeroShort::KaonZeroShort()) &&
rand1 < 0.5) || rand2 > twsup[vecLen]) )
finishedGenXPt =
theReactionDynamics.GenerateXandPt( vec, vecLen,
modifiedOriginal, originalIncident,
currentParticle, targetParticle,
targetNucleus, incidentHasChanged,
targetHasChanged, leadFlag,
leadingStrangeParticle );
if( finishedGenXPt )return;
G4bool finishedTwoClu = false;
if( modifiedOriginal.GetTotalMomentum()/MeV < 1.0 )vecLen = 0;
else
{
theReactionDynamics.SuppressChargedPions( vec, vecLen,
modifiedOriginal, currentParticle,
targetParticle, targetNucleus,
incidentHasChanged, targetHasChanged );
finishedTwoClu = theReactionDynamics.TwoCluster( vec, vecLen,
modifiedOriginal, originalIncident,
currentParticle, targetParticle,
targetNucleus, incidentHasChanged,
targetHasChanged, leadFlag,
leadingStrangeParticle );
}
if( finishedTwoClu )return;
//
// PNBlackTrackEnergy is the kinetic energy available for
// proton/neutron black track particles [was enp(1) in fortran code]
// DTABlackTrackEnergy is the kinetic energy available for
// deuteron/triton/alpha particles [was enp(3) in fortran code]
//const G4double pnCutOff = 0.1;
//const G4double dtaCutOff = 0.1;
//if( (targetNucleus.GetN() >= 1.5)
// && !(incidentHasChanged || targetHasChanged)
// && (targetNucleus.GetPNBlackTrackEnergy()/MeV <= pnCutOff)
// && (targetNucleus.GetDTABlackTrackEnergy()/MeV <= dtaCutOff) )
//{
// the atomic weight of the target nucleus is >= 1.5 AND
// neither the incident nor the target particles have changed AND
// there is no kinetic energy available for either proton/neutron
// or for deuteron/triton/alpha black track particles
// For diffraction scattering on heavy nuclei use elastic routines instead
//G4cerr << "*** Error in G4InelasticInteraction::CalculateMomenta" << endl;
//G4cerr << "*** the elastic scattering would be better here ***" <<endl;
//}
theReactionDynamics.TwoBody( vec, vecLen,
modifiedOriginal, originalTarget,
currentParticle, targetParticle,
targetNucleus, targetHasChanged );
}
void
G4InelasticInteraction::SetUpChange(
G4FastVector<G4ReactionProduct,128> &vec,
G4int &vecLen,
G4ReactionProduct &currentParticle,
G4ReactionProduct &targetParticle,
G4bool &incidentHasChanged )
{
G4ParticleDefinition *aKaonZL = G4KaonZeroLong::KaonZeroLong();
G4ParticleDefinition *aKaonZS = G4KaonZeroShort::KaonZeroShort();
G4int i;
if( currentParticle.GetDefinition() == aKaonZL )
{
if( G4UniformRand() <= 0.5 )
{
currentParticle.SetDefinition( aKaonZS );
incidentHasChanged = true;
}
}
else if( currentParticle.GetDefinition() == aKaonZS )
{
if( G4UniformRand() > 0.5 )
{
currentParticle.SetDefinition( aKaonZL );
incidentHasChanged = true;
}
}
if( targetParticle.GetDefinition() == aKaonZL )
{
if( G4UniformRand() <= 0.5 )targetParticle.SetDefinition( aKaonZS );
}
else if( targetParticle.GetDefinition() == aKaonZS )
{
if( G4UniformRand() > 0.5 )targetParticle.SetDefinition( aKaonZL );
}
for( i=0; i<vecLen; ++i )
{
if( vec[i]->GetDefinition() == aKaonZL )
{
if( G4UniformRand() <= 0.5 )vec[i]->SetDefinition( aKaonZS );
}
else if( vec[i]->GetDefinition() == aKaonZS )
{
if( G4UniformRand() > 0.5 )vec[i]->SetDefinition( aKaonZL );
}
}
if( incidentHasChanged )
{
theParticleChange.SetNumberOfSecondaries( vecLen+2 );
G4DynamicParticle* p0 = new G4DynamicParticle;
p0->SetDefinition( currentParticle.GetDefinition() );
p0->SetMomentum( currentParticle.GetMomentum() );
theParticleChange.AddSecondary( p0 );
theParticleChange.SetStatusChange( fStopAndKill );
theParticleChange.SetEnergyChange( 0.0 );
}
else
{
theParticleChange.SetNumberOfSecondaries( vecLen+1 );
G4double p = currentParticle.GetMomentum().mag()/MeV;
G4ThreeVector m = currentParticle.GetMomentum();
if( p > DBL_MIN )
theParticleChange.SetMomentumChange( m.x()/p, m.y()/p, m.z()/p );
else
theParticleChange.SetMomentumChange( 0.0, 0.0, 0.0 );
theParticleChange.SetEnergyChange( currentParticle.GetKineticEnergy() );
}
if( targetParticle.GetMass() > 0.0 ) // targetParticle can be eliminated in TwoBody
{
G4DynamicParticle *p1 = new G4DynamicParticle;
p1->SetDefinition( targetParticle.GetDefinition() );
p1->SetMomentum( targetParticle.GetMomentum() );
theParticleChange.AddSecondary( p1 );
}
G4DynamicParticle *p;
for( i=0; i<vecLen; ++i )
{
p = new G4DynamicParticle();
p->SetDefinition( vec[i]->GetDefinition() );
p->SetMomentum( vec[i]->GetMomentum() );
theParticleChange.AddSecondary( p );
}
}
/* end of file */