Import Geant4 11.4.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2025-06-26 09:17:29 +02:00
parent 20a218bbe1
commit a499fb82e9
1941 changed files with 203285 additions and 95593 deletions
@@ -79,8 +79,13 @@ public:
void CrossSectionDescription(std::ostream&) const final;
const G4ParticleDefinition*
SampleSecondaryType(const G4ParticleDefinition*,
const G4int Z, const G4int A);
SampleSecondaryType(const G4ParticleDefinition*, const G4Material*,
G4int Z, G4int A, G4double etot);
G4double GetPartialPionXS(G4int idx);
G4double GetPionTFactor(G4int idx, const G4ParticleDefinition* part,
G4double pEtot);
void SetEnergyLimit(G4double val) { fEnergyLimit = val; };
@@ -93,6 +98,9 @@ public:
private:
G4double GetCrossSection(const G4ParticleDefinition*, const G4Material*,
G4int Z, G4double etot);
G4double ComputeDeuteronFraction(const G4Material*);
G4Pow* g4calc;
@@ -34,24 +34,31 @@
class G4VBaseXSFactory
{
public:
G4VBaseXSFactory()
{
fRegistry = G4CrossSectionFactoryRegistry::Instance();
}
virtual ~G4VBaseXSFactory() = default;
virtual G4VCrossSectionDataSet* Instantiate() = 0;
protected:
G4CrossSectionFactoryRegistry* fRegistry;
};
//Generic template XS-factory
template <typename T, int mode> class G4CrossSectionFactory : public G4VBaseXSFactory
{
public:
G4CrossSectionFactory(const G4String& name)
{
G4CrossSectionFactoryRegistry::Instance()->Register(name,this);
fRegistry->Register(name, this);
}
virtual G4VCrossSectionDataSet* Instantiate()
G4VCrossSectionDataSet* Instantiate() override
{
G4ExceptionDescription msg;
msg<<"Factory mode: "<<mode<<" not supported!";
@@ -66,15 +73,15 @@ template <typename T> class G4CrossSectionFactory<T,0> : public G4VBaseXSFactory
{
public:
G4CrossSectionFactory(const G4String& name)
{
G4CrossSectionFactoryRegistry::Instance()->Register(name,this);
}
virtual G4VCrossSectionDataSet* Instantiate()
{
return new T();
}
G4CrossSectionFactory(const G4String& name)
{
fRegistry->Register(name, this);
}
G4VCrossSectionDataSet* Instantiate() override
{
return new T();
}
};
//Partial specialized template for singleton, shared factory
@@ -82,32 +89,32 @@ public:
template <typename T> class G4CrossSectionFactory<T,1> : public G4VBaseXSFactory
{
public:
G4CrossSectionFactory(const G4String& name)
{
G4CrossSectionFactoryRegistry::Instance()->Register(name,this);
}
virtual G4VCrossSectionDataSet* Instantiate()
{
static T* shared = new T();
return shared;
}
G4CrossSectionFactory(const G4String& name)
{
fRegistry->Register(name,this);
}
G4VCrossSectionDataSet* Instantiate() override
{
static T* shared = new T();
return shared;
}
};
//Partial specialized template for singleton, shared factory
// each call to Instantiate returns pointer to static thread-local object
template <typename T> class G4CrossSectionFactory<T,2> : public G4VBaseXSFactory
{
G4CrossSectionFactory(const G4String& name)
{
G4CrossSectionFactoryRegistry::Instance()->Register(name,this);
}
virtual G4VCrossSectionDataSet* Instantiate()
{
static G4ThreadLocal T* shared = new T();
return shared;
}
G4CrossSectionFactory(const G4String& name)
{
fRegistry->Register(name,this);
}
G4VCrossSectionDataSet* Instantiate() override
{
static G4ThreadLocal T* shared = new T();
return shared;
}
};
@@ -47,19 +47,27 @@ class G4VBaseXSFactory;
class G4CrossSectionFactoryRegistry
{
friend std::ostream& operator<<(std::ostream&, const G4CrossSectionFactoryRegistry&);
private:
std::map<G4String, G4VBaseXSFactory*> factories;
static G4CrossSectionFactoryRegistry* instance; //Note this is shared among threads
G4CrossSectionFactoryRegistry();
G4CrossSectionFactoryRegistry(const G4CrossSectionFactoryRegistry& );
G4CrossSectionFactoryRegistry& operator=(const G4CrossSectionFactoryRegistry&);
//Disable copy-ctr and assignement operator
friend std::ostream& operator<<(std::ostream&, const G4CrossSectionFactoryRegistry&);
public:
static G4CrossSectionFactoryRegistry* Instance();
G4VBaseXSFactory* GetFactory( const G4String& name , G4bool abortIfNotFound = true) const;
//Search a cross-section factory by name, by default rise an exception if factory is not found
void Register( const G4String& name , G4VBaseXSFactory* factory );
static G4CrossSectionFactoryRegistry* Instance();
~G4CrossSectionFactoryRegistry() = default;
G4VBaseXSFactory* GetFactory( const G4String& name, G4bool abortIfNotFound = true) const;
//Search a cross-section factory by name, by default rise an exception if factory is not found
void Register( const G4String& name, G4VBaseXSFactory* factory );
void DeRegister( G4VBaseXSFactory* factory );
G4CrossSectionFactoryRegistry(const G4CrossSectionFactoryRegistry&) = delete;
G4CrossSectionFactoryRegistry& operator=(const G4CrossSectionFactoryRegistry&) = delete;
private:
G4CrossSectionFactoryRegistry();
std::map<G4String, G4VBaseXSFactory*> factories;
static G4CrossSectionFactoryRegistry* instance; //Note this is shared among threads
};
std::ostream& operator<<(std::ostream& msg, const G4CrossSectionFactoryRegistry& rhs);
@@ -60,16 +60,16 @@ class G4ElectroNuclearCrossSection : public G4VCrossSectionDataSet
public:
G4ElectroNuclearCrossSection();
virtual ~G4ElectroNuclearCrossSection();
~G4ElectroNuclearCrossSection() override;
static const char* Default_Name() {return "ElectroNuclearXS";}
virtual void CrossSectionDescription(std::ostream&) const;
void CrossSectionDescription(std::ostream&) const override;
virtual G4bool IsElementApplicable(const G4DynamicParticle*, G4int Z,
const G4Material*);
virtual G4double GetElementCrossSection(const G4DynamicParticle*, G4int Z,
const G4Material* mat);
G4bool IsElementApplicable(const G4DynamicParticle*, G4int Z,
const G4Material*) override;
G4double GetElementCrossSection(const G4DynamicParticle*, G4int Z,
const G4Material* mat) override;
G4double GetEquivalentPhotonEnergy();
@@ -77,6 +77,10 @@ public:
G4double GetEquivalentPhotonQ2(G4double nu);
G4ElectroNuclearCrossSection& operator=
(const G4ElectroNuclearCrossSection &right) = delete;
G4ElectroNuclearCrossSection(const G4ElectroNuclearCrossSection&) = delete;
private:
G4int GetFunctions(G4double a, G4double* x, G4double* y, G4double* z);
@@ -44,8 +44,8 @@
#include "G4VCrossSectionDataSet.hh"
#include "globals.hh"
#include "G4ElementData.hh"
#include "G4PhysicsVector.hh"
#include <vector>
class G4DynamicParticle;
class G4ParticleDefinition;
@@ -58,7 +58,7 @@ public:
G4NeutronElasticXS();
~G4NeutronElasticXS() final;
~G4NeutronElasticXS() override = default;
static const char* Default_Name() {return "G4NeutronElasticXS";}
@@ -97,7 +97,7 @@ public:
G4double ElementCrossSection(G4double kinEnergy, G4double loge, G4int Z);
G4NeutronElasticXS & operator=(const G4NeutronElasticXS &right) = delete;
G4NeutronElasticXS& operator=(const G4NeutronElasticXS &right) = delete;
G4NeutronElasticXS(const G4NeutronElasticXS&) = delete;
private:
@@ -108,25 +108,30 @@ private:
const G4String& FindDirectoryPath();
inline G4PhysicsVector* GetPhysicsVector(G4int Z);
inline const G4PhysicsVector* GetPhysicsVector(G4int Z);
G4VComponentCrossSection* ggXsection = nullptr;
G4PhysicsVector* RetrieveVector(std::ostringstream& in, G4bool warn);
G4VComponentCrossSection* ggXsection{nullptr};
const G4ParticleDefinition* neutron;
G4bool isFirst = false;
G4bool isInitializer{false};
static const G4int MAXZEL = 93;
static G4PhysicsVector* data[MAXZEL];
static G4ElementData* data;
static G4double coeff[MAXZEL];
static G4String gDataDirectory;
static G4bool fLock;
};
inline
inline const
G4PhysicsVector* G4NeutronElasticXS::GetPhysicsVector(G4int Z)
{
if(nullptr == data[Z]) { InitialiseOnFly(Z); }
return data[Z];
const G4PhysicsVector* pv = data->GetElementData(Z);
if (pv == nullptr) {
InitialiseOnFly(Z);
pv = data->GetElementData(Z);
}
return pv;
}
#endif
@@ -107,6 +107,8 @@ private:
void Initialise(G4int Z);
void InitialiseOnFly(G4int Z);
inline const G4PhysicsVector* GetPhysicsVector(G4int Z);
G4PhysicsVector* RetrieveVector(std::ostringstream& in, G4bool warn);
@@ -130,7 +132,7 @@ const G4PhysicsVector* G4ParticleInelasticXS::GetPhysicsVector(G4int Z)
{
const G4PhysicsVector* pv = data[index]->GetElementData(Z);
if (pv == nullptr) {
Initialise(Z);
InitialiseOnFly(Z);
pv = data[index]->GetElementData(Z);
}
return pv;