Import Geant4 10.1.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 12:08:39 +02:00
parent 286caacf06
commit c9b32a6c0a
5770 changed files with 1050949 additions and 367105 deletions
@@ -14,6 +14,101 @@ code and to keep track of all tags.
* Please list in reverse chronological order (last date on top)
---------------------------------------------------------------
19 November 2014 G. Folger(hadr-man-V10-00-17)
---------------------------------------------------
- G4HadronicProcess::CheckResult(): Add check for dynamic mass
to correspond to PDG mass within ~10%.
12 November 2014 V. Ivanchenko (hadr-man-V10-00-16)
---------------------------------------------------
- G4HadronicProcessStore -fixed computation of cross sections for ions
12 November 2014 V. Ivanchenko (hadr-man-V10-00-15)
---------------------------------------------------
- G4HadronicProcess - fixed final track status for some models like
G4WilsonAbrasionModel
11 November 2014 V. Ivanchenko (hadr-man-V10-00-14)
---------------------------------------------------
- G4HadronicProcess - clear final state before resample interaction
due to energy balance violation
7 November 2014 V. Ivanchenko (hadr-man-V10-00-13)
------------------------------------------------
4 November 2014 V. Ivanchenko (hadr-man-V10-00-12)
------------------------------------------------
- G4HadronicProcess - added creator model type to secondary
12 September 2014 Tatsumi Koi (hadr-man-V10-00-11)
------------------------------------------------
- Add BuildPhysics method for Initialisation of models before run
Co working with hadr-modman-V10-00-05
include/G4EnergyRangeManager.hh
src/G4EnergyRangeManager.cc
src/G4HadronicProcess.cc
4 August 2014 V. Ivanchenko (hadr-man-V10-00-10)
------------------------------------------------
- G4HadronicProcessStore, G4HadronicProcess: simplified registration and
de-registration; fixed Coverity report
1 August 2014 Alberto Ribon (hadr-man-V10-00-09)
------------------------------------------------
- G4EnergyRangeManager, G4HadronicProcess: moved the computation of
the kinetic energy per nucleon (in the case of ion projectile)
from G4HadronicProcess to G4EnergyRangeManager.
1 August 2014 Alberto Ribon (hadr-man-V10-00-08)
------------------------------------------------
- G4EnergyRangeManager : added a new method GetHadronicInteraction
which uses G4HadronicInteraction::IsApplicable.
- G4HadronicProcess : replaced the old method of G4EnergyRangeManager
(still there but deprecated) with the new one.
1 July 2014 Gunter Folger (hadr-man-V10-00-07)
----------------------------------------------
- G4HadronicProcessStore::PrintHtml(): include ProcessDescription
inline in physics lists description
22 May 2014 Andrea Dotti (hadr-man-V10-00-06)
--------------------------------------------
- Code cleanup
22 May 2014 Andrea Dotti (hadr-man-V10-00-05)
--------------------------------------------
- Fixing valgrind report
21 May 2014 Andrea Dotti (hadr-man-V10-00-04)
--------------------------------------------
- Retagging: previous tag was ok.
21 May 2014 Alberto Ribon (hadr-man-V10-00-03)
---------------------------------------------
- G4HadronicProcessStore : add printout information for deuteron, triton,
He3 and alpha.
20 May 2014 Andrea Dotti (hadr-man-V10-00-02)
---------------------------------------------
- G4HadronicProcessStore : correct for bug in Clear() for which stopping
processes are deleted twice (once because are registered as normal
processes and once are registered as extra processes).
15 May 2014 Vladimir Ivanchenko (hadr-man-V10-00-01)
---------------------------------------------------
- G4HadronicProcess: added method GetHadronicInteractionList() allowing
access to the list of registered models, removed obsolete access
methods to G4EnergyRangeManager
- G4HadronicProcessStore - become G4ThreadLocalSingletone allowing
proper destruction of hadronic processes/models/x-sections
- G4EnergyRangeManager - cleaned up; instead of c-array models pointers
are stored in stl vector
- this tag requires remove deletion of Physics vectors from destructors
of all hadronic classes
03 February 2014 Gunter Folger (hadr-man-V10-00-00)
---------------------------------------------------
- G4HadronicProcess: in EnergyMomentumCheck... add printout of 3momentum
20 June 2013 Dennis Wright (hadr-man-V09-06-03)
-------------------------------------------------
- G4EnergyRangeManager : re-order initialization of hadronicInteractionCounter
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4EnergyRangeManager.hh 71734 2013-06-21 08:53:11Z gcosmo $
// $Id: G4EnergyRangeManager.hh 83772 2014-09-15 07:18:08Z gcosmo $
//
// Hadronic Process: Energy Range Manager
// original by H.P. Wellisch
@@ -35,50 +35,50 @@
#define G4EnergyRangeManager_h 1
#include "G4HadronicInteraction.hh"
#include <vector>
class G4EnergyRangeManager
{
public:
{
public:
G4EnergyRangeManager();
G4EnergyRangeManager();
~G4EnergyRangeManager() {}
~G4EnergyRangeManager();
G4EnergyRangeManager(const G4EnergyRangeManager& right);
G4EnergyRangeManager(const G4EnergyRangeManager& right);
G4EnergyRangeManager& operator=( const G4EnergyRangeManager &right );
G4EnergyRangeManager& operator=( const G4EnergyRangeManager &right );
public:
inline G4bool operator==( const G4EnergyRangeManager &right ) const
inline G4bool operator==( const G4EnergyRangeManager &right ) const
{ return ( this == (G4EnergyRangeManager *) &right ); }
inline G4bool operator!=( const G4EnergyRangeManager &right ) const
inline G4bool operator!=( const G4EnergyRangeManager &right ) const
{ return ( this != (G4EnergyRangeManager *) &right ); }
void RegisterMe( G4HadronicInteraction *a );
void RegisterMe( G4HadronicInteraction *a );
G4HadronicInteraction *GetHadronicInteraction(
const G4double kineticEnergy,
const G4Material *aMaterial,
const G4Element *anElement ) const;
//private:
inline G4int GetHadronicInteractionCounter() const
{ return theHadronicInteractionCounter; }
G4HadronicInteraction *GetHadronicInteraction(const G4HadProjectile & aHadProjectile,
G4Nucleus & aTargetNucleus,
const G4Material *aMaterial,
const G4Element *anElement ) const;
// This is the new one to be used.
void Dump( G4int verbose = 0 );
G4HadronicInteraction *GetHadronicInteraction(const G4double kineticEnergy,
const G4Material *aMaterial,
const G4Element *anElement ) const;
// This is the old, deprecated one, which will be removed later on.
std::vector<G4HadronicInteraction*>& GetHadronicInteractionList();
private:
void Dump( G4int verbose = 0 );
void BuildPhysicsTable(const G4ParticleDefinition&);
private:
enum { MAX_NUMBER_OF_MODELS = 100 };
G4int theHadronicInteractionCounter;
G4HadronicInteraction* theHadronicInteraction[ MAX_NUMBER_OF_MODELS ];
};
G4int theHadronicInteractionCounter;
std::vector<G4HadronicInteraction*> theHadronicInteraction;
};
#endif
@@ -25,13 +25,13 @@
//
//
//
// Hadronic Inelastic Process class
// The specific particle inelastic processes derive from this class
// This is an abstract base class, since the pure virtual function
// PostStepDoIt has not been defined yet.
//
// J.L. Chuma, TRIUMF, 10-Mar-1997
// Last modified: 27-Mar-1997
// Hadronic Inelastic Process class
// The specific particle inelastic processes derive from this class
// This is an abstract base class, since the pure virtual function
// PostStepDoIt has not been defined yet.
//
// J.L. Chuma, TRIUMF, 10-Mar-1997
// Last modified: 27-Mar-1997
//
// 14-APR-98 F.W.Jones: variant G4HadronInelastic process for
// G4CrossSectionDataSet/DataStore class design.
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4HadronicProcess.hh 67989 2013-03-13 10:54:03Z gcosmo $
// $Id: G4HadronicProcess.hh 86448 2014-11-12 09:48:41Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -65,7 +65,6 @@ class G4Step;
class G4Element;
class G4ParticleChange;
class G4HadronicProcess : public G4VDiscreteProcess
{
public:
@@ -117,9 +116,9 @@ public:
inline void AddDataSet(G4VCrossSectionDataSet * aDataSet)
{ theCrossSectionDataStore->AddDataSet(aDataSet);}
// access to the manager
inline G4EnergyRangeManager *GetManagerPointer()
{ return &theEnergyRangeManager; }
// access to the list of hadronic interactions
std::vector<G4HadronicInteraction*>& GetHadronicInteractionList()
{ return theEnergyRangeManager.GetHadronicInteractionList(); }
// get inverse cross section per volume
G4double GetMeanFreePath(const G4Track &aTrack, G4double,
@@ -140,8 +139,10 @@ protected:
// generic method to choose secondary generator
// recommended for all derived classes
inline G4HadronicInteraction* ChooseHadronicInteraction(
G4double kineticEnergy, G4Material* aMaterial, G4Element* anElement)
{ return theEnergyRangeManager.GetHadronicInteraction(kineticEnergy,
const G4HadProjectile & aHadProjectile, G4Nucleus & aTargetNucleus,
G4Material* aMaterial, G4Element* anElement)
{ return theEnergyRangeManager.GetHadronicInteraction(aHadProjectile,
aTargetNucleus,
aMaterial,anElement);
}
@@ -177,14 +178,6 @@ protected:
void DumpState(const G4Track&, const G4String&, G4ExceptionDescription&);
// obsolete method will be removed
inline const G4EnergyRangeManager &GetEnergyRangeManager() const
{ return theEnergyRangeManager; }
// obsolete method will be removed
inline void SetEnergyRangeManager( const G4EnergyRangeManager &value )
{ theEnergyRangeManager = value; }
// access to the chosen generator
inline G4HadronicInteraction* GetHadronicInteraction() const
{ return theInteraction; }
@@ -199,7 +192,7 @@ protected:
// Check the result for catastrophic energy non-conservation
G4HadFinalState* CheckResult(const G4HadProjectile& thePro,
const G4Nucleus& targetNucleus,
G4HadFinalState* result) const;
G4HadFinalState* result);
// Check 4-momentum balance
void CheckEnergyMomentumConservation(const G4Track&, const G4Nucleus&);
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4HadronicProcessStore.hh 67989 2013-03-13 10:54:03Z gcosmo $
// $Id: G4HadronicProcessStore.hh 86515 2014-11-13 09:11:45Z gcosmo $
//
//
// -------------------------------------------------------------------
@@ -57,6 +57,7 @@
#include "G4HadronicInteraction.hh"
#include "G4ParticleDefinition.hh"
#include "G4HadronicProcessType.hh"
#include "G4ThreadLocalSingleton.hh"
#include <map>
#include <vector>
#include <iostream>
@@ -68,6 +69,8 @@ class G4HadronicEPTestMessenger;
class G4HadronicProcessStore
{
friend class G4ThreadLocalSingleton<G4HadronicProcessStore>;
public:
static G4HadronicProcessStore* Instance();
@@ -211,8 +214,6 @@ private:
// print process info
void Print(G4int idxProcess, G4int idxParticle);
static G4ThreadLocal G4HadronicProcessStore* theInstance;
typedef const G4ParticleDefinition* PD;
typedef G4HadronicProcess* HP;
typedef G4HadronicInteraction* HI;
@@ -240,9 +241,10 @@ private:
G4int verbose;
G4bool buildTableStart;
// cash
// cache
HP currentProcess;
PD currentParticle;
PD theGenericIon;
G4DynamicParticle localDP;
@@ -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 */
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4HadronicProcess.cc 67989 2013-03-13 10:54:03Z gcosmo $
// $Id: G4HadronicProcess.cc 86863 2014-11-19 14:39:31Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -94,7 +94,6 @@ G4HadronicProcess::G4HadronicProcess(const G4String& processName,
aScaleFactor = 1;
xBiasOn = false;
G4HadronicProcess_debug_flag = false;
GetEnergyMomentumCheckEnvvars();
}
@@ -114,7 +113,6 @@ G4HadronicProcess::G4HadronicProcess(const G4String& processName,
aScaleFactor = 1;
xBiasOn = false;
G4HadronicProcess_debug_flag = false;
GetEnergyMomentumCheckEnvvars();
}
@@ -142,7 +140,7 @@ void G4HadronicProcess::GetEnergyMomentumCheckEnvvars() {
void G4HadronicProcess::RegisterMe( G4HadronicInteraction *a )
{
if(!a) { return; }
try{GetManagerPointer()->RegisterMe( a );}
try{ theEnergyRangeManager.RegisterMe( a ); }
catch(G4HadronicException & aE)
{
G4ExceptionDescription ed;
@@ -168,6 +166,7 @@ void G4HadronicProcess::BuildPhysicsTable(const G4ParticleDefinition& p)
try
{
theCrossSectionDataStore->BuildPhysicsTable(p);
theEnergyRangeManager.BuildPhysicsTable(p);
}
catch(G4HadronicException aR)
{
@@ -183,6 +182,8 @@ void G4HadronicProcess::BuildPhysicsTable(const G4ParticleDefinition& p)
G4double G4HadronicProcess::
GetMeanFreePath(const G4Track &aTrack, G4double, G4ForceCondition *)
{
//G4cout << "GetMeanFreePath " << aTrack.GetDefinition()->GetParticleName()
// << " Ekin= " << aTrack.GetKineticEnergy() << G4endl;
try
{
theLastCrossSection = aScaleFactor*
@@ -200,12 +201,15 @@ GetMeanFreePath(const G4Track &aTrack, G4double, G4ForceCondition *)
}
G4double res = DBL_MAX;
if( theLastCrossSection > 0.0 ) { res = 1.0/theLastCrossSection; }
//G4cout << " xsection= " << res << G4endl;
return res;
}
G4VParticleChange*
G4HadronicProcess::PostStepDoIt(const G4Track& aTrack, const G4Step&)
{
//G4cout << "PostStepDoIt " << aTrack.GetDefinition()->GetParticleName()
// << " Ekin= " << aTrack.GetKineticEnergy() << G4endl;
// if primary is not Alive then do nothing
theTotalResult->Clear();
theTotalResult->Initialize(aTrack);
@@ -244,7 +248,8 @@ G4HadronicProcess::PostStepDoIt(const G4Track& aTrack, const G4Step&)
// Next check for illegal track status
//
if (aTrack.GetTrackStatus() != fAlive && aTrack.GetTrackStatus() != fSuspend) {
if (aTrack.GetTrackStatus() != fAlive &&
aTrack.GetTrackStatus() != fSuspend) {
if (aTrack.GetTrackStatus() == fStopAndKill ||
aTrack.GetTrackStatus() == fKillTrackAndSecondaries ||
aTrack.GetTrackStatus() == fPostponeToNextEvent) {
@@ -259,19 +264,13 @@ G4HadronicProcess::PostStepDoIt(const G4Track& aTrack, const G4Step&)
return theTotalResult;
}
// Go on to regular case
//
G4double originalEnergy = aParticle->GetKineticEnergy();
G4double kineticEnergy = originalEnergy;
// Get kinetic energy per nucleon for ions
if(aParticle->GetParticleDefinition()->GetBaryonNumber() > 1.5)
kineticEnergy/=aParticle->GetParticleDefinition()->GetBaryonNumber();
// Initialize the hadronic projectile from the track
thePro.Initialise(aTrack);
try
{
theInteraction =
ChooseHadronicInteraction( kineticEnergy, aMaterial, anElement );
ChooseHadronicInteraction( thePro, targetNucleus, aMaterial, anElement );
}
catch(G4HadronicException & aE)
{
@@ -286,8 +285,6 @@ G4HadronicProcess::PostStepDoIt(const G4Track& aTrack, const G4Step&)
ed);
}
// Initialize the hadronic projectile from the track
thePro.Initialise(aTrack);
G4HadFinalState* result = 0;
G4int reentryCount = 0;
@@ -318,7 +315,7 @@ G4HadronicProcess::PostStepDoIt(const G4Track& aTrack, const G4Step&)
}
// Check the result for catastrophic energy non-conservation
result = CheckResult(thePro,targetNucleus, result);
CheckResult(thePro, targetNucleus, result);
if(reentryCount>100) {
G4ExceptionDescription ed;
@@ -343,6 +340,7 @@ G4HadronicProcess::PostStepDoIt(const G4Track& aTrack, const G4Step&)
if (epReportLevel != 0) {
CheckEnergyMomentumConservation(aTrack, targetNucleus);
}
//G4cout << "PostStepDoIt done " << G4endl;
return theTotalResult;
}
@@ -393,8 +391,8 @@ G4HadronicProcess::FillResult(G4HadFinalState * aR, const G4Track & aT)
theTotalResult->ProposeEnergy( 0.0 );
if(aT.GetParticleDefinition()->GetProcessManager()
->GetAtRestProcessVector()->size() > 0)
{ aParticleChange.ProposeTrackStatus(fStopButAlive); }
else { aParticleChange.ProposeTrackStatus(fStopAndKill); }
{ theTotalResult->ProposeTrackStatus(fStopButAlive); }
else { theTotalResult->ProposeTrackStatus(fStopAndKill); }
// primary is not killed apply rotation and Lorentz transformation
} else {
@@ -416,6 +414,9 @@ G4HadronicProcess::FillResult(G4HadFinalState * aR, const G4Track & aT)
if(newE < 0.0) { newE = 0.0; }
theTotalResult->ProposeEnergy( newE );
}
//G4cout << "FillResult: Efinal= " << efinal << " status= "
// << theTotalResult->GetTrackStatus()
// << " fKill= " << fStopAndKill << G4endl;
// check secondaries: apply rotation and Lorentz transformation
G4int nSec = aR->GetNumberOfSecondaries();
@@ -439,10 +440,11 @@ G4HadronicProcess::FillResult(G4HadFinalState * aR, const G4Track & aT)
G4Track* track = new G4Track(aR->GetSecondary(i)->GetParticle(),
time, aT.GetPosition());
track->SetCreatorModelIndex(aR->GetSecondary(i)->GetCreatorModelType());
G4double newWeight = weight*aR->GetSecondary(i)->GetWeight();
// G4cout << "#### ParticleDebug "
// <<GetProcessName()<<" "
// <<aR->GetSecondary(i)->GetParticle()->GetDefinition()->GetParticleName()<<" "
//<<aR->GetSecondary(i)->GetParticle()->GetDefinition()->GetParticleName()<<" "
// <<aScaleFactor<<" "
// <<XBiasSurvivalProbability()<<" "
// <<XBiasSecondaryWeight()<<" "
@@ -460,147 +462,15 @@ G4HadronicProcess::FillResult(G4HadFinalState * aR, const G4Track & aT)
DumpState(aT,"Secondary has zero energy",ed);
ed << "Secondary " << track->GetDefinition()->GetParticleName()
<< G4endl;
G4Exception("G4HadronicProcess::FillResults", "had011", JustWarning,ed);
G4Exception("G4HadronicProcess::FillResults", "had011",
JustWarning,ed);
}
}
}
}
aR->Clear();
return;
}
/*
void
G4HadronicProcess::FillTotalResult(G4HadFinalState* aR, const G4Track& aT)
{
theTotalResult->Clear();
theTotalResult->ProposeLocalEnergyDeposit(0.);
theTotalResult->Initialize(aT);
theTotalResult->SetSecondaryWeightByProcess(true);
theTotalResult->ProposeTrackStatus(fAlive);
G4double rotation = CLHEP::twopi*G4UniformRand();
G4ThreeVector it(0., 0., 1.);
if(aR->GetStatusChange()==stopAndKill)
{
if( xBiasOn && G4UniformRand()<XBiasSurvivalProbability() )
{
theTotalResult->ProposeParentWeight( XBiasSurvivalProbability()*aT.GetWeight() );
}
else
{
theTotalResult->ProposeTrackStatus(fStopAndKill);
theTotalResult->ProposeEnergy( 0.0 );
}
}
else if(aR->GetStatusChange()!=stopAndKill )
{
if(aR->GetStatusChange()==suspend)
{
theTotalResult->ProposeTrackStatus(fSuspend);
if(xBiasOn)
{
G4ExceptionDescription ed;
DumpState(aT,"FillTotalResult",ed);
G4Exception("G4HadronicProcess::FillTotalResult", "had007", FatalException,
ed,"Cannot cross-section bias a process that suspends tracks.");
}
} else if (aT.GetKineticEnergy() == 0) {
theTotalResult->ProposeTrackStatus(fStopButAlive);
}
if(xBiasOn && G4UniformRand()<XBiasSurvivalProbability())
{
theTotalResult->ProposeParentWeight( XBiasSurvivalProbability()*aT.GetWeight() );
G4double newWeight = aR->GetWeightChange()*aT.GetWeight();
G4double newM=aT.GetParticleDefinition()->GetPDGMass();
G4double newE=aR->GetEnergyChange() + newM;
G4double newP=std::sqrt(newE*newE - newM*newM);
G4DynamicParticle * aNew =
new G4DynamicParticle(aT.GetParticleDefinition(), newE, newP*aR->GetMomentumChange());
aR->AddSecondary(G4HadSecondary(aNew, newWeight));
}
else
{
G4double newWeight = aR->GetWeightChange()*aT.GetWeight();
theTotalResult->ProposeParentWeight(newWeight); // This is multiplicative
if(aR->GetEnergyChange()>-.5)
{
theTotalResult->ProposeEnergy(aR->GetEnergyChange());
}
G4LorentzVector newDirection(aR->GetMomentumChange().unit(), 1.);
newDirection*=aR->GetTrafoToLab();
theTotalResult->ProposeMomentumDirection(newDirection.vect());
}
}
else
{
G4ExceptionDescription ed;
ed << "Call for " << theInteraction->GetModelName() << G4endl;
ed << "Target Z= "
<< targetNucleus.GetZ_asInt()
<< " A= " << targetNucleus.GetA_asInt() << G4endl;
DumpState(aT,"FillTotalResult",ed);
G4Exception("G4HadronicProcess", "had008", FatalException,
"use of unsupported track-status.");
}
if(GetProcessName() != "hElastic" && GetProcessName() != "HadronElastic"
&& theTotalResult->GetTrackStatus()==fAlive
&& aR->GetStatusChange()==isAlive)
{
// Use for debugging: G4double newWeight = theTotalResult->GetParentWeight();
G4double newKE = std::max(DBL_MIN, aR->GetEnergyChange());
G4DynamicParticle* aNew = new G4DynamicParticle(aT.GetParticleDefinition(),
aR->GetMomentumChange(),
newKE);
aR->AddSecondary(aNew);
aR->SetStatusChange(stopAndKill);
theTotalResult->ProposeTrackStatus(fStopAndKill);
theTotalResult->ProposeEnergy( 0.0 );
}
theTotalResult->ProposeLocalEnergyDeposit(aR->GetLocalEnergyDeposit());
theTotalResult->SetNumberOfSecondaries(aR->GetNumberOfSecondaries());
if(aR->GetStatusChange() != stopAndKill)
{
G4double newM=aT.GetParticleDefinition()->GetPDGMass();
G4double newE=aR->GetEnergyChange() + newM;
G4double newP=std::sqrt(newE*newE - newM*newM);
G4ThreeVector newPV = newP*aR->GetMomentumChange();
G4LorentzVector newP4(newE, newPV);
newP4.rotate(rotation, it);
newP4*=aR->GetTrafoToLab();
theTotalResult->ProposeMomentumDirection(newP4.vect().unit());
}
for(G4int i=0; i<aR->GetNumberOfSecondaries(); ++i)
{
G4LorentzVector theM = aR->GetSecondary(i)->GetParticle()->Get4Momentum();
theM.rotate(rotation, it);
theM*=aR->GetTrafoToLab();
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(),
time,
aT.GetPosition());
G4double newWeight = aT.GetWeight()*aR->GetSecondary(i)->GetWeight();
if(xBiasOn) { newWeight *= XBiasSecondaryWeight(); }
track->SetWeight(newWeight);
track->SetTouchableHandle(aT.GetTouchableHandle());
theTotalResult->AddSecondary(track);
}
aR->Clear();
return;
}
*/
void G4HadronicProcess::BiasCrossSectionByFactor(G4double aScale)
{
@@ -612,7 +482,8 @@ void G4HadronicProcess::BiasCrossSectionByFactor(G4double aScale)
(it != "PositronNuclear") )
{
G4ExceptionDescription ed;
G4Exception("G4HadronicProcess::BiasCrossSectionByFactor", "had009", FatalException, ed,
G4Exception("G4HadronicProcess::BiasCrossSectionByFactor", "had009",
FatalException, ed,
"Cross-section biasing available only for gamma and electro nuclear reactions.");
}
if(aScale<100)
@@ -624,53 +495,86 @@ void G4HadronicProcess::BiasCrossSectionByFactor(G4double aScale)
}
}
G4HadFinalState* G4HadronicProcess::CheckResult(const G4HadProjectile & aPro,const G4Nucleus &aNucleus, G4HadFinalState * result) const
G4HadFinalState* G4HadronicProcess::CheckResult(const G4HadProjectile & aPro,
const G4Nucleus &aNucleus,
G4HadFinalState * result)
{
// check for catastrophic energy non-conservation, to re-sample the interaction
// check for catastrophic energy non-conservation
// to re-sample the interaction
G4HadronicInteraction * theModel = GetHadronicInteraction();
G4double nuclearMass(0);
if (theModel){
G4HadronicInteraction * theModel = GetHadronicInteraction();
G4double nuclearMass(0);
if (theModel) {
// Compute final-state total energy
G4double finalE(0.);
G4int nSec = result->GetNumberOfSecondaries();
// Compute final-state total energy
G4double finalE(0.);
G4int nSec = result->GetNumberOfSecondaries();
nuclearMass = G4NucleiProperties::GetNuclearMass(aNucleus.GetA_asInt(),
aNucleus.GetZ_asInt());
if (result->GetStatusChange() != stopAndKill) {
// Interaction didn't complete, returned "do nothing" state => reset nucleus
// or the primary survived the interaction (e.g. electro-nuclear ) => keep nucleus
finalE=result->GetLocalEnergyDeposit() +
aPro.GetDefinition()->GetPDGMass() + result->GetEnergyChange();
if( nSec == 0 ){
// Since there are no secondaries, there is no recoil nucleus.
// To check energy balance we must neglect the initial nucleus too.
nuclearMass=0.0;
}
nuclearMass = G4NucleiProperties::GetNuclearMass(aNucleus.GetA_asInt(),
aNucleus.GetZ_asInt());
if (result->GetStatusChange() != stopAndKill) {
// Interaction didn't complete, returned "do nothing" state
// and reset nucleus or the primary survived the interaction
// (e.g. electro-nuclear ) => keep nucleus
finalE=result->GetLocalEnergyDeposit() +
aPro.GetDefinition()->GetPDGMass() + result->GetEnergyChange();
if( nSec == 0 ){
// Since there are no secondaries, there is no recoil nucleus.
// To check energy balance we must neglect the initial nucleus too.
nuclearMass=0.0;
}
for (G4int i = 0; i < nSec; i++) {
finalE += result->GetSecondary(i)->GetParticle()->GetTotalEnergy();
}
for (G4int i = 0; i < nSec; i++) {
G4DynamicParticle *pdyn=result->GetSecondary(i)->GetParticle();
finalE += pdyn->GetTotalEnergy();
G4double mass_pdg=pdyn->GetDefinition()->GetPDGMass();
G4double mass_dyn=pdyn->GetMass();
if ( std::abs(mass_pdg - mass_dyn) > 0.1*mass_pdg + 1.*MeV){
result->Clear();
result = 0;
G4ExceptionDescription desc;
desc << "Warning: Secondary with off-shell dynamic mass detected: " << G4endl
<< " " << pdyn->GetDefinition()->GetParticleName()
<< ", PDG mass: " << mass_pdg << ", dynamic mass: "<< mass_dyn << G4endl
<< (epReportLevel<0 ? "abort the event" : "re-sample the interaction") << G4endl
<< " Process / Model: " << GetProcessName()<< " / "
<< theModel->GetModelName() << G4endl
<< " Primary: " << aPro.GetDefinition()->GetParticleName()
<< " (" << aPro.GetDefinition()->GetPDGEncoding() << "), "
<< " E= " << aPro.Get4Momentum().e()
<< ", target nucleus (" << aNucleus.GetZ_asInt() << ", "
<< aNucleus.GetA_asInt() << ")" << G4endl;
G4Exception("G4HadronicProcess:CheckResult()", "had012",
epReportLevel<0 ? EventMustBeAborted : JustWarning,desc);
// must return here.....
return result;
}
G4double deltaE= nuclearMass + aPro.GetTotalEnergy() - finalE;
}
G4double deltaE= nuclearMass + aPro.GetTotalEnergy() - finalE;
std::pair<G4double, G4double> checkLevels = theModel->GetFatalEnergyCheckLevels(); // (relative, absolute)
if (std::abs(deltaE) > checkLevels.second && std::abs(deltaE) > checkLevels.first*aPro.GetKineticEnergy()){
// do not delete result, this is a pointer to a data member;
result=0;
G4ExceptionDescription desc;
desc << "Warning: Bad energy non-conservation detected, will "
<< (epReportLevel<0 ? "abort the event" : "re-sample the interaction") << G4endl
<< " Process / Model: " << GetProcessName()<< " / " << theModel->GetModelName() << G4endl
<< " Primary: " << aPro.GetDefinition()->GetParticleName()
<< " (" << aPro.GetDefinition()->GetPDGEncoding() << "),"
<< " E= " << aPro.Get4Momentum().e()
<< ", target nucleus (" << aNucleus.GetZ_asInt() << ","<< aNucleus.GetA_asInt() << ")" << G4endl
<< " E(initial - final) = " << deltaE << " MeV." << G4endl;
G4Exception("G4HadronicProcess:CheckResult()", "had012", epReportLevel<0 ? EventMustBeAborted : JustWarning,desc);
}
}
return result;
std::pair<G4double, G4double> checkLevels =
theModel->GetFatalEnergyCheckLevels(); // (relative, absolute)
if (std::abs(deltaE) > checkLevels.second &&
std::abs(deltaE) > checkLevels.first*aPro.GetKineticEnergy()){
// do not delete result, this is a pointer to a data member;
result->Clear();
result = 0;
G4ExceptionDescription desc;
desc << "Warning: Bad energy non-conservation detected, will "
<< (epReportLevel<0 ? "abort the event" : "re-sample the interaction") << G4endl
<< " Process / Model: " << GetProcessName()<< " / "
<< theModel->GetModelName() << G4endl
<< " Primary: " << aPro.GetDefinition()->GetParticleName()
<< " (" << aPro.GetDefinition()->GetPDGEncoding() << "), "
<< " E= " << aPro.Get4Momentum().e()
<< ", target nucleus (" << aNucleus.GetZ_asInt() << ", "
<< aNucleus.GetA_asInt() << ")" << G4endl
<< " E(initial - final) = " << deltaE << " MeV." << G4endl;
G4Exception("G4HadronicProcess:CheckResult()", "had012",
epReportLevel<0 ? EventMustBeAborted : JustWarning,desc);
}
}
return result;
}
void
@@ -807,7 +711,7 @@ G4HadronicProcess::CheckEnergyMomentumConservation(const G4Track& aTrack,
Myout << " "<< relResult <<" relative, limit " << checkLevels.first << ", values E/T(0) = "
<< relative << " p/p(0)= " << relative_mom << G4endl;
Myout << " "<< absResult << " absolute, limit (MeV) " << checkLevels.second/MeV << ", values E / p (MeV) = "
<< absolute/MeV << " / " << absolute_mom/MeV << G4endl;
<< absolute/MeV << " / " << absolute_mom/MeV << " 3mom: " << (diff.vect())*1./MeV << G4endl;
Myout << " "<< chargeResult << " charge/baryon number balance " << (initial_Z-final_Z) << " / " << (initial_A-final_A) << " "<< G4endl;
Myout_notempty=true;
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4HadronicProcessStore.cc 67989 2013-03-13 10:54:03Z gcosmo $
// $Id: G4HadronicProcessStore.cc 86515 2014-11-13 09:11:45Z gcosmo $
//
// -------------------------------------------------------------------
//
@@ -55,21 +55,17 @@
#include "G4ProcessManager.hh"
#include "G4Electron.hh"
#include "G4Proton.hh"
#include "G4ParticleTable.hh"
#include "G4HadronicInteractionRegistry.hh"
#include "G4CrossSectionDataSetRegistry.hh"
#include "G4HadronicEPTestMessenger.hh"
G4ThreadLocal G4HadronicProcessStore* G4HadronicProcessStore::theInstance = 0;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
G4HadronicProcessStore* G4HadronicProcessStore::Instance()
{
if(0 == theInstance) {
static G4ThreadLocal G4HadronicProcessStore *manager_G4MT_TLS_ = 0 ; if (!manager_G4MT_TLS_) manager_G4MT_TLS_ = new G4HadronicProcessStore ; G4HadronicProcessStore &manager = *manager_G4MT_TLS_;
theInstance = &manager;
}
return theInstance;
static G4ThreadLocalSingleton<G4HadronicProcessStore> instance;
return instance.Instance();
}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
@@ -89,30 +85,24 @@ void G4HadronicProcessStore::Clean()
G4int i;
//G4cout << "G4HadronicProcessStore::Clean() Nproc= " << n_proc
// << " Nextra= " << n_extra << G4endl;
if(n_proc > 0) {
for (i=0; i<n_proc; ++i) {
if( process[i] ) {
//G4cout << "G4HadronicProcessStore::Clean() delete hadronic " << i << G4endl;
//G4cout << process[i]->GetProcessName() << G4endl;
G4HadronicProcess* p = process[i];
process[i] = 0;
delete p;
}
for (i=0; i<n_proc; ++i) {
if( process[i] ) {
//G4cout << "G4HadronicProcessStore::Clean() delete hadronic "
// << i << " " << process[i]->GetProcessName() << G4endl;
G4HadronicProcess* p = process[i];
DeRegister(p);
delete p;
}
}
if(n_extra > 0) {
for(i=0; i<n_extra; ++i) {
if(extraProcess[i]) {
//G4cout << "G4HadronicProcessStore::Clean() delete extra "
// << i << G4endl;
//G4cout << extraProcess[i]->GetProcessName() << G4endl;
G4VProcess* p = extraProcess[i];
for(i=0; i<n_extra; ++i) {
if(extraProcess[i]) {
// G4cout << "G4HadronicProcessStore::Clean() delete extra proc "
//<< i << " " << extraProcess[i]->GetProcessName() << G4endl;
delete extraProcess[i];
extraProcess[i] = 0;
delete p;
}
}
}
//G4cout << "G4HadronicProcessStore::Clean() done" << G4endl;
//G4cout << "G4HadronicProcessStore::Clean() done" << G4endl;
n_extra = 0;
n_proc = 0;
}
@@ -127,6 +117,8 @@ G4HadronicProcessStore::G4HadronicProcessStore()
n_extra= 0;
currentProcess = 0;
currentParticle = 0;
theGenericIon =
G4ParticleTable::GetParticleTable()->FindParticle("GenericIon");
verbose = 1;
buildTableStart = true;
theEPTestMessenger = new G4HadronicEPTestMessenger(this);
@@ -187,7 +179,8 @@ G4double G4HadronicProcessStore::GetElasticCrossSectionPerVolume(
{
G4double cross = 0.0;
const G4ElementVector* theElementVector = material->GetElementVector();
const G4double* theAtomNumDensityVector = material->GetVecNbOfAtomsPerVolume();
const G4double* theAtomNumDensityVector =
material->GetVecNbOfAtomsPerVolume();
size_t nelm = material->GetNumberOfElements();
for (size_t i=0; i<nelm; ++i) {
const G4Element* elm = (*theElementVector)[i];
@@ -232,7 +225,8 @@ G4double G4HadronicProcessStore::GetInelasticCrossSectionPerVolume(
{
G4double cross = 0.0;
const G4ElementVector* theElementVector = material->GetElementVector();
const G4double* theAtomNumDensityVector = material->GetVecNbOfAtomsPerVolume();
const G4double* theAtomNumDensityVector =
material->GetVecNbOfAtomsPerVolume();
size_t nelm = material->GetNumberOfElements();
for (size_t i=0; i<nelm; ++i) {
const G4Element* elm = (*theElementVector)[i];
@@ -277,7 +271,8 @@ G4double G4HadronicProcessStore::GetCaptureCrossSectionPerVolume(
{
G4double cross = 0.0;
const G4ElementVector* theElementVector = material->GetElementVector();
const G4double* theAtomNumDensityVector = material->GetVecNbOfAtomsPerVolume();
const G4double* theAtomNumDensityVector =
material->GetVecNbOfAtomsPerVolume();
size_t nelm = material->GetNumberOfElements();
for (size_t i=0; i<nelm; ++i) {
const G4Element* elm = (*theElementVector)[i];
@@ -322,7 +317,8 @@ G4double G4HadronicProcessStore::GetFissionCrossSectionPerVolume(
{
G4double cross = 0.0;
const G4ElementVector* theElementVector = material->GetElementVector();
const G4double* theAtomNumDensityVector = material->GetVecNbOfAtomsPerVolume();
const G4double* theAtomNumDensityVector =
material->GetVecNbOfAtomsPerVolume();
size_t nelm = material->GetNumberOfElements();
for (size_t i=0; i<nelm; i++) {
const G4Element* elm = (*theElementVector)[i];
@@ -367,12 +363,13 @@ G4double G4HadronicProcessStore::GetChargeExchangeCrossSectionPerVolume(
{
G4double cross = 0.0;
const G4ElementVector* theElementVector = material->GetElementVector();
const G4double* theAtomNumDensityVector = material->GetVecNbOfAtomsPerVolume();
const G4double* theAtomNumDensityVector =
material->GetVecNbOfAtomsPerVolume();
size_t nelm = material->GetNumberOfElements();
for (size_t i=0; i<nelm; ++i) {
const G4Element* elm = (*theElementVector)[i];
cross += theAtomNumDensityVector[i]*
GetChargeExchangeCrossSectionPerAtom(aParticle,kineticEnergy,elm,material);
GetChargeExchangeCrossSectionPerAtom(aParticle,kineticEnergy,elm,material);
}
return cross;
}
@@ -412,8 +409,10 @@ void G4HadronicProcessStore::Register(G4HadronicProcess* proc)
if(process[i] == proc) { return; }
}
}
// G4cout << "G4HadronicProcessStore::Register hadronic " << n_proc
// << " " << proc->GetProcessName() << G4endl;
if(1 < verbose) {
G4cout << "G4HadronicProcessStore::Register hadronic " << n_proc
<< " " << proc->GetProcessName() << G4endl;
}
++n_proc;
process.push_back(proc);
}
@@ -428,6 +427,11 @@ void G4HadronicProcessStore::RegisterParticle(G4HadronicProcess* proc,
G4int j=0;
for(; j<n_part; ++j) {if(particle[j] == part) break;}
if(1 < verbose) {
G4cout << "G4HadronicProcessStore::RegisterParticle "
<< part->GetParticleName()
<< " for " << proc->GetProcessName() << G4endl;
}
if(j == n_part) {
++n_part;
particle.push_back(part);
@@ -471,10 +475,10 @@ void G4HadronicProcessStore::RegisterInteraction(G4HadronicProcess* proc,
void G4HadronicProcessStore::DeRegister(G4HadronicProcess* proc)
{
if(0 == n_proc) return;
for(G4int i=0; i<n_proc; ++i) {
if(process[i] == proc) {
process[i] = 0;
DeRegisterExtraProcess((G4VProcess*)proc);
return;
}
}
@@ -489,10 +493,17 @@ void G4HadronicProcessStore::RegisterExtraProcess(G4VProcess* proc)
if(extraProcess[i] == proc) { return; }
}
}
//G4cout << "Extra Process: " << n_extra << " " << proc->GetProcessName()
// << " " << proc << G4endl;
n_extra++;
G4HadronicProcess* hproc = reinterpret_cast<G4HadronicProcess*>(proc);
if(hproc) {
for(G4int i=0; i<n_proc; ++i) {
if(process[i] == hproc) { return; }
}
}
if(1 < verbose) {
G4cout << "Extra Process: " << n_extra
<< " " << proc->GetProcessName() << G4endl;
}
++n_extra;
extraProcess.push_back(proc);
}
@@ -531,12 +542,13 @@ void G4HadronicProcessStore::RegisterParticleForExtraProcess(
void G4HadronicProcessStore::DeRegisterExtraProcess(G4VProcess* proc)
{
//G4cout << "Deregister Extra Process: " << proc << " "<<proc->GetProcessName()<< G4endl;
if(0 == n_extra) { return; }
for(G4int i=0; i<n_extra; ++i) {
if(extraProcess[i] == proc) {
extraProcess[i] = 0;
//G4cout << "Extra Process: " << i << " is deregisted " << G4endl;
if(1 < verbose) {
G4cout << "Extra Process: " << i << " "
<<proc->GetProcessName()<< " is deregisted " << G4endl;
}
return;
}
}
@@ -625,19 +637,24 @@ void G4HadronicProcessStore::PrintHtml(const G4ParticleDefinition* theParticle,
G4HadronicProcess* theProcess;
for (PDHPmap::iterator it = itpart.first; it != itpart.second; ++it) {
theProcess = (*it).second;
outFile << "<br> &nbsp;&nbsp; <b><font color=\" 0000ff \">process : <a href=\""
<< theProcess->GetProcessName() << ".html\"> "
<< theProcess->GetProcessName() << "</a></font></b>\n";
// description is inline
//outFile << "<br> &nbsp;&nbsp; <b><font color=\" 0000ff \">process : <a href=\""
// << theProcess->GetProcessName() << ".html\"> "
// << theProcess->GetProcessName() << "</a></font></b>\n";
outFile << "<br> &nbsp;&nbsp; <b><font color=\" 0000ff \">process : "
<< theProcess->GetProcessName() << "</font></b>\n";
outFile << "<ul>\n";
outFile << " <li><b><font color=\" 00AA00 \">models : </font></b>\n";
outFile << " <li>";
theProcess->ProcessDescription(outFile);
outFile << " <li><b><font color=\" 00AA00 \">models : </font></b>\n";
// Loop over models assigned to process
std::pair<HPHImap::iterator, HPHImap::iterator> itmod =
m_map.equal_range(theProcess);
outFile << " <ul>\n";
for (HPHImap::iterator jt = itmod.first; jt != itmod.second; ++jt) {
outFile << " <li><b><a href=\"" << (*jt).second->GetModelName() << ".html\"> "
outFile << " <li><b><a href=\"" << (*jt).second->GetModelName()
<< ".html\"> "
<< (*jt).second->GetModelName() << "</a>"
<< " from " << (*jt).second->GetMinEnergy()/GeV
<< " GeV to " << (*jt).second->GetMaxEnergy()/GeV
@@ -664,7 +681,8 @@ void G4HadronicProcessStore::PrintHtml(const G4ParticleDefinition* theParticle,
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.....
void G4HadronicProcessStore::PrintModelHtml(const G4HadronicInteraction * mod) const
void
G4HadronicProcessStore::PrintModelHtml(const G4HadronicInteraction * mod) const
{
G4String dirName(getenv("G4PhysListDocDir"));
G4String pathName = dirName + "/" + mod->GetModelName() + ".html";
@@ -672,7 +690,8 @@ void G4HadronicProcessStore::PrintModelHtml(const G4HadronicInteraction * mod) c
outModel.open(pathName);
outModel << "<html>\n";
outModel << "<head>\n";
outModel << "<title>Description of " << mod->GetModelName() << "</title>\n";
outModel << "<title>Description of " << mod->GetModelName()
<< "</title>\n";
outModel << "</head>\n";
outModel << "<body>\n";
@@ -701,6 +720,10 @@ void G4HadronicProcessStore::Dump(G4int level)
if (level == 1 && (pname == "proton" ||
pname == "neutron" ||
pname == "deuteron" ||
pname == "triton" ||
pname == "He3" ||
pname == "alpha" ||
pname == "pi+" ||
pname == "pi-" ||
pname == "gamma" ||
@@ -713,7 +736,11 @@ void G4HadronicProcessStore::Dump(G4int level)
pname == "lambda" ||
pname == "GenericIon" ||
pname == "anti_neutron" ||
pname == "anti_proton")) yes = true;
pname == "anti_proton" ||
pname == "anti_deuteron" ||
pname == "anti_triton" ||
pname == "anti_He3" ||
pname == "anti_alpha")) yes = true;
if (level > 1) yes = true;
if (yes) {
// main processes
@@ -735,7 +762,7 @@ void G4HadronicProcessStore::Dump(G4int level)
if(itp->first == part) {
G4VProcess* proc = (itp->second);
if (wasPrinted[i] == 0) {
G4cout << "\n---------------------------------------------------\n"
G4cout << "\n---------------------------------------------------\n"
<< std::setw(50) << "Hadronic Processes for "
<< part->GetParticleName() << "\n";
wasPrinted[i] = 1;
@@ -813,30 +840,39 @@ G4HadronicProcess* G4HadronicProcessStore::FindProcess(
{
bool isNew = false;
G4HadronicProcess* hp = 0;
localDP.SetDefinition(part);
if(part != currentParticle) {
isNew = true;
currentParticle = part;
localDP.SetDefinition(part);
} else if(!currentProcess) {
isNew = true;
} else if(subType == currentProcess->GetProcessSubType()) {
hp = currentProcess;
} else {
isNew = true;
const G4ParticleDefinition* p = part;
if(p->GetBaryonNumber() > 4 && p->GetParticleType() == "nucleus") {
p = theGenericIon;
}
if(p != currentParticle) {
isNew = true;
currentParticle = p;
}
}
if(!isNew) {
if(!currentProcess) {
isNew = true;
} else if(subType == currentProcess->GetProcessSubType()) {
hp = currentProcess;
} else {
isNew = true;
}
}
if(isNew) {
std::multimap<PD,HP,std::less<PD> >::iterator it;
for(it=p_map.lower_bound(part); it!=p_map.upper_bound(part); ++it) {
if(it->first == part && subType == (it->second)->GetProcessSubType()) {
for(it=p_map.lower_bound(currentParticle);
it!=p_map.upper_bound(currentParticle); ++it) {
if(it->first == currentParticle &&
subType == (it->second)->GetProcessSubType()) {
hp = it->second;
break;
}
}
currentProcess = hp;
}
return hp;
}
@@ -855,7 +891,8 @@ void G4HadronicProcessStore::SetEpReportLevel(G4int level)
void G4HadronicProcessStore::SetProcessAbsLevel(G4double abslevel)
{
G4cout << " Setting absolute energy/momentum test level to " << abslevel << G4endl;
G4cout << " Setting absolute energy/momentum test level to " << abslevel
<< G4endl;
G4double rellevel = 0.0;
G4HadronicProcess* theProcess = 0;
for (G4int i = 0; i < G4int(process.size()); ++i) {
@@ -869,7 +906,8 @@ void G4HadronicProcessStore::SetProcessAbsLevel(G4double abslevel)
void G4HadronicProcessStore::SetProcessRelLevel(G4double rellevel)
{
G4cout << " Setting relative energy/momentum test level to " << rellevel << G4endl;
G4cout << " Setting relative energy/momentum test level to " << rellevel
<< G4endl;
G4double abslevel = 0.0;
G4HadronicProcess* theProcess = 0;
for (G4int i = 0; i < G4int(process.size()); ++i) {