Import Geant4 11.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2021-12-10 14:46:44 +01:00
committed by Ben Morgan
parent 6399a014b6
commit 80e2389dd8
3932 changed files with 202519 additions and 246221 deletions
@@ -64,6 +64,7 @@
#include "G4AutoLock.hh"
class G4ProcessManager;
class G4VTrackingManager;
class G4PDefData
{
@@ -76,6 +77,7 @@ class G4PDefData
void initialize();
G4ProcessManager* theProcessManager = nullptr;
G4VTrackingManager* theTrackingManager = nullptr;
};
class G4PDefManager
@@ -53,6 +53,7 @@ class G4ProcessManager;
class G4DecayTable;
class G4ParticleTable;
class G4ParticlePropertyTable;
class G4VTrackingManager;
using G4ParticleDefinitionSubInstanceManager = G4PDefManager;
@@ -162,6 +163,11 @@ class G4ParticleDefinition
// Set/Get Process Manager
// !! Process Manager can be modified !!
G4VTrackingManager* GetTrackingManager() const;
void SetTrackingManager(G4VTrackingManager* aTrackingManager);
// Set/Get Tracking Manager; nullptr means the default
// !! Tracking Manager can be modified !!
inline G4ParticleTable* GetParticleTable() const;
// Get pointer to the particle table
@@ -208,6 +214,21 @@ class G4ParticleDefinition
void SetParticleDefinitionID(G4int id=-1);
inline G4int GetParticleDefinitionID() const;
inline G4bool IsHypernucleus() const;
inline G4int GetNumberOfLambdasInHypernucleus() const;
inline G4bool IsAntiHypernucleus() const;
inline G4int GetNumberOfAntiLambdasInAntiHypernucleus() const;
// The first two methods return "false" and 0, respectively,
// if the particle is not an hypernucleus; else, they return
// "true" and the number of Lambdas bound in the nucleus.
// Similarly, the last two methods return "false" and 0,
// respectively, if the particle is not an anti-hypernucleus;
// else, they return "true" and the number of anti-Lambdas
// bound in the anti-nucleus.
// Notice that, for the time being, we are assuming that
// (anti-)Lambda is the only type of (anti-)hyperon present
// in all (anti-)hypernuclei.
protected:
G4ParticleDefinition();
@@ -212,3 +212,35 @@ G4int G4ParticleDefinition::GetParticleDefinitionID() const
{
return g4particleDefinitionInstanceID;
}
inline
G4bool G4ParticleDefinition::IsHypernucleus() const
{
if ( GetNumberOfLambdasInHypernucleus() > 0 ) return true;
return false;
}
inline
G4int G4ParticleDefinition::GetNumberOfLambdasInHypernucleus() const
{
// PDG code of hypernuclei: 10LZZZAAAI
G4int numberOfLambdas = 0;
if ( thePDGEncoding > 0 ) numberOfLambdas = (thePDGEncoding/10000000)%100;
return numberOfLambdas;
}
inline
G4bool G4ParticleDefinition::IsAntiHypernucleus() const
{
if ( GetNumberOfAntiLambdasInAntiHypernucleus() > 0 ) return true;
return false;
}
inline
G4int G4ParticleDefinition::GetNumberOfAntiLambdasInAntiHypernucleus() const
{
// PDG code of anti-hypernuclei: -10LZZZAAAI
G4int numberOfAntiLambdas = 0;
if ( thePDGEncoding < 0 ) numberOfAntiLambdas = (std::abs(thePDGEncoding)/10000000)%100;
return numberOfAntiLambdas;
}
@@ -70,10 +70,7 @@ class G4ParticlePropertyMessenger : public G4UImessenger
private:
G4ParticleDefinition* SetCurrentParticle();
G4ParticleTable* theParticleTable = nullptr;
G4ParticleDefinition* currentParticle = nullptr;
G4UIdirectory* thisDirectory = nullptr;
G4UIcmdWithoutParameter* dumpCmd = nullptr;
@@ -43,7 +43,7 @@ class G4PhaseSpaceDecayChannel : public G4VDecayChannel
{
public:
enum { MAX_N_DAUGHTERS=4 };
enum { MAX_N_DAUGHTERS=5 };
G4PhaseSpaceDecayChannel(G4int Verbose = 1);
G4PhaseSpaceDecayChannel(const G4String& theParentName,
@@ -52,7 +52,8 @@ class G4PhaseSpaceDecayChannel : public G4VDecayChannel
const G4String& theDaughterName1,
const G4String& theDaughterName2 = "",
const G4String& theDaughterName3 = "",
const G4String& theDaughterName4 = "" );
const G4String& theDaughterName4 = "",
const G4String& theDaughterName5 = "" );
// Constructors
virtual ~G4PhaseSpaceDecayChannel();
@@ -58,7 +58,8 @@ class G4VDecayChannel
const G4String& theDaughterName1,
const G4String& theDaughterName2 = "",
const G4String& theDaughterName3 = "",
const G4String& theDaughterName4 = "" );
const G4String& theDaughterName4 = "",
const G4String& theDaughterName5 = "" );
// Constructors
virtual ~G4VDecayChannel();
@@ -189,7 +189,7 @@ G4ParticleDefinition* G4DecayTableMessenger::SetCurrentParticle()
G4String G4DecayTableMessenger::GetCurrentValue(G4UIcommand* command)
{
G4String returnValue('\0');
G4String returnValue(1,'\0');
if (SetCurrentParticle() == nullptr)
{
@@ -1357,7 +1357,7 @@ G4bool G4IonTable::IsLightIon(const G4ParticleDefinition* particle) const
= { "proton", "alpha", "deuteron", "triton", "He3"};
// Return true if the particle is pre-defined ion
return std::find(names, names+5, particle->GetParticleName())!=names+5;
return std::find(names, names+5, (particle->GetParticleName()).c_str())!=names+5;
}
// --------------------------------------------------------------------
@@ -1369,7 +1369,7 @@ G4bool G4IonTable::IsLightAntiIon(const G4ParticleDefinition* particle) const
= { "anti_proton", "anti_alpha", "anti_deuteron", "anti_triton", "anti_He3"};
// Return true if the particle is pre-defined ion
return std::find(names, names+5, particle->GetParticleName())!=names+5;
return std::find(names, names+5, (particle->GetParticleName()).c_str())!=names+5;
}
// --------------------------------------------------------------------
@@ -409,7 +409,7 @@ G4NuclideTable::StripFloatLevelBase( const G4String& sFLB )
G4Exception( "G4NuclideTable", "PART70002", FatalException, text );
}
G4Ions::G4FloatLevelBase flb = noFloat;
if ( !(sFLB == '-') )
if ( !(sFLB == "-") )
{
flb = G4Ions::FloatLevelBase( sFLB.back() );
}
@@ -39,6 +39,7 @@
void G4PDefData::initialize()
{
theProcessManager = nullptr;
theTrackingManager = nullptr;
}
G4int& G4PDefManager::slavetotalspace()
@@ -53,6 +53,7 @@ G4PDefManager G4ParticleDefinition::subInstanceManager;
// in the class G4PDefData.
//
#define G4MT_pmanager ((subInstanceManager.offset()[g4particleDefinitionInstanceID]).theProcessManager)
#define G4MT_tmanager ((subInstanceManager.offset()[g4particleDefinitionInstanceID]).theTrackingManager)
// --------------------------------------------------------------------
G4ParticleDefinition::G4ParticleDefinition(
@@ -240,6 +241,13 @@ G4ProcessManager* G4ParticleDefinition::GetProcessManager() const
return G4MT_pmanager;
}
// --------------------------------------------------------------------
G4VTrackingManager* G4ParticleDefinition::GetTrackingManager() const
{
if(g4particleDefinitionInstanceID<0) return nullptr;
return G4MT_tmanager;
}
// --------------------------------------------------------------------
G4int G4ParticleDefinition::FillQuarkContents()
{
@@ -474,3 +482,22 @@ void G4ParticleDefinition::SetProcessManager(G4ProcessManager* aProcessManager)
}
G4MT_pmanager = aProcessManager;
}
// --------------------------------------------------------------------
void G4ParticleDefinition::SetTrackingManager(G4VTrackingManager* aTrackingManager)
{
if(g4particleDefinitionInstanceID<0 && !isGeneralIon)
{
if(G4Threading::G4GetThreadId() >= 0)
{
G4ExceptionDescription ed;
ed << "TrackingManager is being set to " << theParticleName
<< " without proper initialization of TLS pointer vector.\n"
<< "This operation is thread-unsafe.";
G4Exception("G4ParticleDefintion::SetTrackingManager",
"PART10118", JustWarning, ed);
}
SetParticleDefinitionID();
}
G4MT_tmanager = aTrackingManager;
}
@@ -107,7 +107,10 @@ G4ParticlePropertyMessenger::~G4ParticlePropertyMessenger()
void G4ParticlePropertyMessenger::
SetNewValue(G4UIcommand* command, G4String newValue)
{
if (SetCurrentParticle() == nullptr)
G4ParticleDefinition* currentParticle
= const_cast<G4ParticleDefinition*>(theParticleTable->GetSelectedParticle());
if (currentParticle == nullptr)
{
G4cout << "Particle is not selected yet !! Command ignored." << G4endl;
return;
@@ -122,7 +125,7 @@ SetNewValue(G4UIcommand* command, G4String newValue)
else if (command == lifetimeCmd )
{
// Command /particle/property/lifetime
currentParticle->SetPDGLifeTime(lifetimeCmd->GetNewDoubleValue(newValue));
currentParticle->SetPDGLifeTime(lifetimeCmd->GetNewDoubleValue(newValue));
}
else if (command == stableCmd )
@@ -145,39 +148,16 @@ SetNewValue(G4UIcommand* command, G4String newValue)
else if( command==verboseCmd )
{
// Command /particle/property/Verbose
currentParticle->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue));
currentParticle->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue));
}
}
G4ParticleDefinition* G4ParticlePropertyMessenger::SetCurrentParticle()
{
// Set currentParticle pointer
// Get particle name by asking G4ParticleMessenger via UImanager
//
G4String particleName
= G4UImanager::GetUIpointer()->GetCurrentStringValue("/particle/select");
if ( currentParticle != nullptr )
{
// check whether selection is changed
if (currentParticle->GetParticleName() != particleName)
{
currentParticle = theParticleTable->FindParticle(particleName);
}
}
else
{
currentParticle = theParticleTable->FindParticle(particleName);
}
return currentParticle;
}
G4String G4ParticlePropertyMessenger::GetCurrentValue(G4UIcommand* command)
{
G4String returnValue('\0');
G4String returnValue(1,'\0');
if ( SetCurrentParticle() == nullptr )
const G4ParticleDefinition* currentParticle = theParticleTable->GetSelectedParticle();
if ( currentParticle == nullptr )
{
return returnValue; // no particle is selected. return null
}
@@ -326,7 +326,7 @@ void G4ParticleTable::RemoveAllParticles()
G4ParticleDefinition* G4ParticleTable::Insert(G4ParticleDefinition* particle)
{
// check particle name
if ((particle == nullptr) || (GetKey(particle).isNull()))
if ((particle == nullptr) || (GetKey(particle).empty()))
{
G4Exception("G4ParticleTable::Insert()",
"PART121", FatalException,
@@ -602,10 +602,13 @@ G4ParticleDefinition* G4ParticleTable::FindParticle(G4int aPDGEncoding )
G4PTblEncodingDictionary* pedic = fEncodingDictionary;
G4ParticleDefinition* particle = nullptr;
G4PTblEncodingDictionary::iterator it = pedic->find(aPDGEncoding );
if (it != pedic->end())
if (pedic)
{
particle = (*it).second;
G4PTblEncodingDictionary::iterator it = pedic->find(aPDGEncoding );
if (it != pedic->end())
{
particle = (*it).second;
}
}
#ifdef G4MULTITHREADED
@@ -51,10 +51,11 @@ G4PhaseSpaceDecayChannel(const G4String& theParentName,
const G4String& theDaughterName1,
const G4String& theDaughterName2,
const G4String& theDaughterName3,
const G4String& theDaughterName4 )
const G4String& theDaughterName4,
const G4String& theDaughterName5 )
: G4VDecayChannel("Phase Space", theParentName,theBR, theNumberOfDaughters,
theDaughterName1, theDaughterName2,
theDaughterName3, theDaughterName4)
theDaughterName3, theDaughterName4, theDaughterName5)
{
}
@@ -586,6 +587,8 @@ G4DecayProducts* G4PhaseSpaceDecayChannel::ManyBodyDecayIt()
<< " " << daughtermass[2]/GeV << G4endl;
G4cout << "Daughter 4:" << G4MT_daughters[3]->GetParticleName()
<< " " << daughtermass[3]/GeV << G4endl;
G4cout << "Daughter 5:" << G4MT_daughters[4]->GetParticleName()
<< " " << daughtermass[4]/GeV << G4endl;
}
#endif
G4Exception("G4PhaseSpaceDecayChannel::ManyBodyDecayIt()",
@@ -63,7 +63,8 @@ G4VDecayChannel::G4VDecayChannel(const G4String& aName,
const G4String& theDaughterName1,
const G4String& theDaughterName2,
const G4String& theDaughterName3,
const G4String& theDaughterName4 )
const G4String& theDaughterName4,
const G4String& theDaughterName5 )
: kinematics_name(aName), rbranch(theBR), parent_polarization(),
numberOfDaughters(theNumberOfDaughters)
{
@@ -85,6 +86,7 @@ G4VDecayChannel::G4VDecayChannel(const G4String& aName,
if (numberOfDaughters>1) daughters_name[1] = new G4String(theDaughterName2);
if (numberOfDaughters>2) daughters_name[2] = new G4String(theDaughterName3);
if (numberOfDaughters>3) daughters_name[3] = new G4String(theDaughterName4);
if (numberOfDaughters>4) daughters_name[4] = new G4String(theDaughterName5);
if (rbranch <0. ) rbranch = 0.0;
else if (rbranch >1.0 ) rbranch = 1.0;