Import Geant4 10.1.0 source tree
This commit is contained in:
@@ -23,7 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id: G4EnergyRangeManager.cc 71734 2013-06-21 08:53:11Z gcosmo $
|
||||
// $Id: G4EnergyRangeManager.cc 83772 2014-09-15 07:18:08Z gcosmo $
|
||||
//
|
||||
// Hadronic Process: Energy Range Manager
|
||||
// original by H.P. Wellisch
|
||||
@@ -36,72 +36,80 @@
|
||||
#include "Randomize.hh"
|
||||
#include "G4HadronicException.hh"
|
||||
|
||||
|
||||
G4EnergyRangeManager::G4EnergyRangeManager()
|
||||
: theHadronicInteractionCounter(0)
|
||||
{
|
||||
for (G4int i = 0; i < G4EnergyRangeManager::MAX_NUMBER_OF_MODELS; i++)
|
||||
theHadronicInteraction[i] = 0;
|
||||
}
|
||||
{}
|
||||
|
||||
G4EnergyRangeManager::~G4EnergyRangeManager()
|
||||
{}
|
||||
|
||||
G4EnergyRangeManager::G4EnergyRangeManager(const G4EnergyRangeManager& right)
|
||||
{
|
||||
if (this != &right) {
|
||||
theHadronicInteractionCounter = right.theHadronicInteractionCounter;
|
||||
for (G4int i = 0; i < theHadronicInteractionCounter; ++i)
|
||||
theHadronicInteraction[i] = right.theHadronicInteraction[i];
|
||||
theHadronicInteraction = right.theHadronicInteraction;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
G4EnergyRangeManager& G4EnergyRangeManager::operator=(
|
||||
const G4EnergyRangeManager& right)
|
||||
{
|
||||
if (this != &right) {
|
||||
theHadronicInteractionCounter = right.theHadronicInteractionCounter;
|
||||
for (G4int i=0; i<theHadronicInteractionCounter; ++i)
|
||||
theHadronicInteraction[i] = right.theHadronicInteraction[i];
|
||||
theHadronicInteraction = right.theHadronicInteraction;
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void G4EnergyRangeManager::RegisterMe(G4HadronicInteraction* a)
|
||||
{
|
||||
if (theHadronicInteractionCounter+1 > MAX_NUMBER_OF_MODELS) {
|
||||
throw G4HadronicException(__FILE__, __LINE__,"RegisterMe: TOO MANY MODELS");
|
||||
if(!a) { return; }
|
||||
if(0 < theHadronicInteractionCounter) {
|
||||
for(G4int i=0; i<theHadronicInteractionCounter; ++i) {
|
||||
if(a == theHadronicInteraction[i]) { return; }
|
||||
}
|
||||
}
|
||||
theHadronicInteraction[ theHadronicInteractionCounter++ ] = a;
|
||||
theHadronicInteraction.push_back(a);
|
||||
++theHadronicInteractionCounter;
|
||||
}
|
||||
|
||||
|
||||
|
||||
G4HadronicInteraction*
|
||||
G4EnergyRangeManager::GetHadronicInteraction(const G4double kineticEnergy,
|
||||
G4EnergyRangeManager::GetHadronicInteraction(const G4HadProjectile & aHadProjectile,
|
||||
G4Nucleus & aTargetNucleus,
|
||||
const G4Material* aMaterial,
|
||||
const G4Element* anElement) const
|
||||
{
|
||||
G4int counter = GetHadronicInteractionCounter();
|
||||
if (counter == 0) throw G4HadronicException(__FILE__, __LINE__,
|
||||
"GetHadronicInteraction: NO MODELS STORED");
|
||||
if(0 == theHadronicInteractionCounter) {
|
||||
throw G4HadronicException(__FILE__, __LINE__,
|
||||
"GetHadronicInteraction: NO MODELS STORED");
|
||||
}
|
||||
|
||||
G4double kineticEnergy = aHadProjectile.GetKineticEnergy();
|
||||
// For ions, get kinetic energy per nucleon
|
||||
if ( aHadProjectile.GetDefinition()->GetBaryonNumber() > 1.5 ) {
|
||||
kineticEnergy /= aHadProjectile.GetDefinition()->GetBaryonNumber();
|
||||
}
|
||||
|
||||
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;
|
||||
for (G4int i = 0; i<theHadronicInteractionCounter; ++i) {
|
||||
if ( theHadronicInteraction[i]->IsApplicable( aHadProjectile, aTargetNucleus ) ) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,10 +117,12 @@ G4EnergyRangeManager::GetHadronicInteraction(const G4double kineticEnergy,
|
||||
G4double rand;
|
||||
switch (cou) {
|
||||
case 0:
|
||||
G4cout<<"G4EnergyRangeManager:GetHadronicInteraction: counter="<<counter<<", Ek="
|
||||
<<kineticEnergy<<", Material = "<<aMaterial->GetName()<<", Element = "
|
||||
G4cout<<"G4EnergyRangeManager:GetHadronicInteraction: counter="
|
||||
<<theHadronicInteractionCounter<<", Ek="
|
||||
<<kineticEnergy<<", Material = "<<aMaterial->GetName()
|
||||
<<", Element = "
|
||||
<<anElement->GetName()<<G4endl;
|
||||
for( G4int j=0; j<counter; j++ )
|
||||
for( G4int j=0; j<theHadronicInteractionCounter; ++j)
|
||||
{
|
||||
G4HadronicInteraction* HInt=theHadronicInteraction[j];
|
||||
G4cout<<"*"<<j<<"* low=" <<HInt->GetMinEnergy(aMaterial,anElement)
|
||||
@@ -127,41 +137,142 @@ G4EnergyRangeManager::GetHadronicInteraction(const G4double kineticEnergy,
|
||||
case 2:
|
||||
if( (emi2<=emi1 && ema2>=ema1) || (emi2>=emi1 && ema2<=ema1) )
|
||||
{
|
||||
G4cout<<"G4EnergyRangeManager:GetHadronicInteraction: counter="<<counter<<", Ek="
|
||||
<<kineticEnergy<<", Material = "<<aMaterial->GetName()<<", Element = "
|
||||
G4cout<<"G4EnergyRangeManager:GetHadronicInteraction: counter="
|
||||
<<theHadronicInteractionCounter<<", Ek="
|
||||
<<kineticEnergy<<", Material = "<<aMaterial->GetName()
|
||||
<<", Element = "
|
||||
<<anElement->GetName()<<G4endl;
|
||||
if(counter) for( G4int j=0; j<counter; j++ )
|
||||
for( G4int j=0; j<theHadronicInteractionCounter; ++j)
|
||||
{
|
||||
G4HadronicInteraction* HInt=theHadronicInteraction[j];
|
||||
G4cout<<"*"<<j<<"* low=" <<HInt->GetMinEnergy(aMaterial,anElement)
|
||||
<<", high="<<HInt->GetMaxEnergy(aMaterial,anElement)<<G4endl;
|
||||
}
|
||||
throw G4HadronicException(__FILE__, __LINE__,
|
||||
"GetHadronicInteraction: Energy ranges of two models fully overlapping");
|
||||
"GetHadronicInteraction: Energy ranges of two models fully overlapping");
|
||||
}
|
||||
rand = G4UniformRand();
|
||||
if( emi1 < emi2 )
|
||||
{
|
||||
if( (ema1-kineticEnergy)/(ema1-emi2)<rand )
|
||||
if( (ema1-kineticEnergy) < rand*(ema1-emi2) ) {
|
||||
mem = memor2;
|
||||
else
|
||||
} else {
|
||||
mem = memory;
|
||||
}
|
||||
} else {
|
||||
if( (ema2-kineticEnergy)/(ema2-emi1)<rand )
|
||||
if( (ema2-kineticEnergy) < rand*(ema2-emi1) ) {
|
||||
mem = memory;
|
||||
else
|
||||
} else {
|
||||
mem = memor2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw G4HadronicException(__FILE__, __LINE__,
|
||||
"GetHadronicInteraction: More than two competing models in this energy range");
|
||||
"GetHadronicInteraction: More than two competing models in this energy range");
|
||||
}
|
||||
|
||||
return theHadronicInteraction[mem];
|
||||
}
|
||||
|
||||
|
||||
G4HadronicInteraction*
|
||||
G4EnergyRangeManager::GetHadronicInteraction(const G4double kineticEnergy,
|
||||
const G4Material* aMaterial,
|
||||
const G4Element* anElement) const
|
||||
{
|
||||
if(0 == theHadronicInteractionCounter) {
|
||||
throw G4HadronicException(__FILE__, __LINE__,
|
||||
"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<theHadronicInteractionCounter; ++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 mem = -1;
|
||||
G4double rand;
|
||||
switch (cou) {
|
||||
case 0:
|
||||
G4cout<<"G4EnergyRangeManager:GetHadronicInteraction: counter="
|
||||
<<theHadronicInteractionCounter<<", Ek="
|
||||
<<kineticEnergy<<", Material = "<<aMaterial->GetName()
|
||||
<<", Element = "
|
||||
<<anElement->GetName()<<G4endl;
|
||||
for( G4int j=0; j<theHadronicInteractionCounter; ++j)
|
||||
{
|
||||
G4HadronicInteraction* HInt=theHadronicInteraction[j];
|
||||
G4cout<<"*"<<j<<"* low=" <<HInt->GetMinEnergy(aMaterial,anElement)
|
||||
<<", high="<<HInt->GetMaxEnergy(aMaterial,anElement)<<G4endl;
|
||||
}
|
||||
throw G4HadronicException(__FILE__, __LINE__,
|
||||
"GetHadronicInteraction: No Model found");
|
||||
return 0;
|
||||
case 1:
|
||||
mem = memory;
|
||||
break;
|
||||
case 2:
|
||||
if( (emi2<=emi1 && ema2>=ema1) || (emi2>=emi1 && ema2<=ema1) )
|
||||
{
|
||||
G4cout<<"G4EnergyRangeManager:GetHadronicInteraction: counter="
|
||||
<<theHadronicInteractionCounter<<", Ek="
|
||||
<<kineticEnergy<<", Material = "<<aMaterial->GetName()
|
||||
<<", Element = "
|
||||
<<anElement->GetName()<<G4endl;
|
||||
for( G4int j=0; j<theHadronicInteractionCounter; ++j)
|
||||
{
|
||||
G4HadronicInteraction* HInt=theHadronicInteraction[j];
|
||||
G4cout<<"*"<<j<<"* low=" <<HInt->GetMinEnergy(aMaterial,anElement)
|
||||
<<", high="<<HInt->GetMaxEnergy(aMaterial,anElement)<<G4endl;
|
||||
}
|
||||
throw G4HadronicException(__FILE__, __LINE__,
|
||||
"GetHadronicInteraction: Energy ranges of two models fully overlapping");
|
||||
}
|
||||
rand = G4UniformRand();
|
||||
if( emi1 < emi2 )
|
||||
{
|
||||
if( (ema1-kineticEnergy) < rand*(ema1-emi2) ) {
|
||||
mem = memor2;
|
||||
} else {
|
||||
mem = memory;
|
||||
}
|
||||
} else {
|
||||
if( (ema2-kineticEnergy) < rand*(ema2-emi1) ) {
|
||||
mem = memory;
|
||||
} else {
|
||||
mem = memor2;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw G4HadronicException(__FILE__, __LINE__,
|
||||
"GetHadronicInteraction: More than two competing models in this energy range");
|
||||
}
|
||||
|
||||
return theHadronicInteraction[mem];
|
||||
}
|
||||
|
||||
std::vector<G4HadronicInteraction*>&
|
||||
G4EnergyRangeManager::GetHadronicInteractionList()
|
||||
{
|
||||
return theHadronicInteraction;
|
||||
}
|
||||
|
||||
#include "G4SystemOfUnits.hh"
|
||||
void G4EnergyRangeManager::Dump( G4int verbose )
|
||||
{
|
||||
@@ -170,11 +281,22 @@ void G4EnergyRangeManager::Dump( G4int verbose )
|
||||
G4cout << " HadronicModel " << i <<":"
|
||||
<< theHadronicInteraction[i]->GetModelName() << G4endl;
|
||||
if (verbose > 0) {
|
||||
G4cout << " Minimum Energy " << theHadronicInteraction[i]->GetMinEnergy()/GeV << " [GeV], "
|
||||
<< "Maximum Energy " << theHadronicInteraction[i]->GetMaxEnergy()/GeV << " [GeV]"
|
||||
G4cout << " Minimum Energy "
|
||||
<< theHadronicInteraction[i]->GetMinEnergy()/GeV << " [GeV], "
|
||||
<< "Maximum Energy "
|
||||
<< theHadronicInteraction[i]->GetMaxEnergy()/GeV << " [GeV]"
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
G4EnergyRangeManager::BuildPhysicsTable(const G4ParticleDefinition& aParticleType)
|
||||
{
|
||||
for ( std::vector<G4HadronicInteraction*>::iterator
|
||||
it = theHadronicInteraction.begin() ; it != theHadronicInteraction.end() ; it++ ) {
|
||||
(*it)->BuildPhysicsTable( aParticleType );
|
||||
}
|
||||
}
|
||||
/* end of file */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user