Import Geant4 11.1.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2022-07-01 10:44:02 +02:00
parent b3bf75a2a1
commit c07cea1fe0
2172 changed files with 183300 additions and 123938 deletions
+21 -16
View File
@@ -1,29 +1,34 @@
-------------------------------------------------------------------
# Category proccuts History
=========================================================
Geant4 - an Object-Oriented Toolkit for Simulation in HEP
=========================================================
See `CONTRIBUTING.rst` for details of **required** info/format for each entry,
which **must** added in reverse chronological order (newest at the top). It must **not**
be used as a substitute for writing good git commit messages!
Category History file
---------------------
This file should be used by G4 developers and category coordinators
to briefly summarize all major modifications introduced in the code
and keep track of all category-tags.
It DOES NOT substitute the CVS log-message one should put at every
committal in the CVS repository !
## 2022-06-13 Sergio Losilla (proccuts-V11-00-04)
- Added warning when trying to set cuts for particles other than
gamma, e-, e+ or proton.
----------------------------------------------------------
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
## 2022-05-07 Vladimir Ivantchenko (proccuts-V11-00-03)
- G4VRangeToEnergyConverter - fixed static methods to provide
initialisation of energy limits independently on order of
calls in user code; use G4Autoloack to simplify the code;
use "s" prefix for static class members
March. 14th, 2022 - I. Hrivnacova (proccuts-V10-07-07)
## 2022-03-14 Ivana Hrivnacova (proccuts-V11-00-02)
- G4VRangeToEnergyConverter - fixed clearing of static data
in destructor
January. 19th, 2022 - V.Ivantchenko (proccuts-V10-07-06)
## 2022-01-19 Vladimir Ivantchenko (proccuts-V11-00-01)
- G4VRangeToEnergyConverter - fixed construction/destruction of
static data (initial problem identified by I. Hrivnacova)
## 2021-12-10 Ben Morgan (proccuts-V11-00-00)
- Change to new Markdown History format
---
# History entries prior to 11.0
October. 12th, 2021 - V.Ivanchenko (proccuts-V10-07-05)
- G4PhysicsTableHelper - fixed Coverity warning due to index type,
removed G4ThreadLocal variable, substitute old cerr by
@@ -72,11 +72,15 @@ class G4ProductionCuts
G4bool operator!=(const G4ProductionCuts& right) const;
// Equality operators
void SetProductionCut(G4double cut, G4int index = -1);
void SetProductionCut(G4double cut, G4int index);
void SetProductionCut(G4double cut, G4ParticleDefinition* ptcl);
void SetProductionCut(G4double cut, const G4String& pName);
// Set the production cut in range with an index to particle type.
// If index is omitted, the value is applied to all particles
// Set the production cut in range for a specific particle from
// and index, G4ParticleDefinition* or particle name. If the
// particle is not a photon, e-, e+ or proton, the function has
// no effect.
void SetProductionCut(G4double cut);
// Set the production cut in range for photons, e-, e+ and protons.
G4double GetProductionCut(G4int index) const;
// Get the production cut in range with an index to particle type
@@ -113,79 +117,4 @@ class G4ProductionCuts
static G4ThreadLocal G4ParticleDefinition* protonDef; // for proton
};
// ------------------
// Inline methods
// ------------------
inline
void G4ProductionCuts::SetProductionCut(G4double cut, G4int index)
{
if (index<0)
{
for(G4int i = 0; i < NumberOfG4CutIndex; ++i)
{
fRangeCuts[i] = cut;
}
isModified = true;
}
else if (index < NumberOfG4CutIndex)
{
fRangeCuts[index] = cut;
isModified = true;
}
}
inline
void G4ProductionCuts::SetProductionCut(G4double cut,
G4ParticleDefinition* ptcl)
{
G4int idx = -1;
if(ptcl) idx = GetIndex(ptcl);
if(idx>=0) SetProductionCut(cut,idx);
}
inline
void G4ProductionCuts::SetProductionCut(G4double cut, const G4String& pName)
{
G4int idx = GetIndex(pName);
if(idx>=0) SetProductionCut(cut,idx);
}
inline
G4double G4ProductionCuts::GetProductionCut(G4int index) const
{
G4double cut=-1.0;
if ( (index>=0) && (index<NumberOfG4CutIndex) )
{
cut = fRangeCuts[index];
}
return cut;
}
inline
G4double G4ProductionCuts::GetProductionCut(const G4String& name) const
{
return GetProductionCut(GetIndex(name));
}
inline
const std::vector<G4double>& G4ProductionCuts::GetProductionCuts() const
{
return fRangeCuts;
}
inline
G4bool G4ProductionCuts::IsModified() const
{
return isModified;
}
inline
void G4ProductionCuts::PhysicsTableUpdated()
{
isModified = false;
}
#endif
@@ -41,7 +41,6 @@
#include "globals.hh"
#include "G4ParticleDefinition.hh"
#include "G4Material.hh"
#include "G4Threading.hh"
class G4VRangeToEnergyConverter
{
@@ -103,19 +102,17 @@ private:
protected:
#ifdef G4MULTITHREADED
static G4Mutex theMutex;
#endif
static G4double Emin;
static G4double Emax;
static std::vector<G4double>* Energy;
static G4int NbinPerDecade;
static G4int Nbin;
const G4ParticleDefinition* theParticle = nullptr;
G4int fPDG = 0;
private:
static G4double sEmin;
static G4double sEmax;
static std::vector<G4double>* sEnergy;
static G4int sNbinPerDecade;
static G4int sNbin;
G4int verboseLevel = 1;
G4bool isFirstInstance = false;
};
+68 -1
View File
@@ -31,7 +31,7 @@
#include "G4ProductionCuts.hh"
#include "G4ProductionCutsTable.hh"
#include <iomanip>
#include <sstream>
G4ThreadLocal G4ParticleDefinition* G4ProductionCuts::gammaDef = nullptr;
G4ThreadLocal G4ParticleDefinition* G4ProductionCuts::electDef = nullptr;
@@ -83,6 +83,73 @@ G4bool G4ProductionCuts::operator!=(const G4ProductionCuts& right) const
return (this != &right);
}
void G4ProductionCuts::SetProductionCut(G4double cut, G4int index)
{
if(index >= 0 && index < NumberOfG4CutIndex)
{
fRangeCuts[index] = cut;
isModified = true;
}
else
{
std::ostringstream os;
os << "Setting cuts for particles other than photon, e-, e+ or proton has "
"no effect.";
G4Exception("G4ProductionCuts::SetProductionCut", "ProcCuts110",
JustWarning, os.str().c_str());
}
}
void G4ProductionCuts::SetProductionCut(G4double cut)
{
for(G4int i = 0; i < NumberOfG4CutIndex; ++i)
{
fRangeCuts[i] = cut;
}
isModified = true;
}
void G4ProductionCuts::SetProductionCut(G4double cut, G4ParticleDefinition* ptcl)
{
SetProductionCut(cut,GetIndex(ptcl));
}
void G4ProductionCuts::SetProductionCut(G4double cut, const G4String& pName)
{
SetProductionCut(cut,GetIndex(pName));
}
G4double G4ProductionCuts::GetProductionCut(G4int index) const
{
G4double cut=-1.0;
if ( (index>=0) && (index<NumberOfG4CutIndex) )
{
cut = fRangeCuts[index];
}
return cut;
}
G4double G4ProductionCuts::GetProductionCut(const G4String& name) const
{
return GetProductionCut(GetIndex(name));
}
const std::vector<G4double>& G4ProductionCuts::GetProductionCuts() const
{
return fRangeCuts;
}
G4bool G4ProductionCuts::IsModified() const
{
return isModified;
}
void G4ProductionCuts::PhysicsTableUpdated()
{
isModified = false;
}
G4int G4ProductionCuts::GetIndex(const G4String& name)
{
static const G4String gamma ("gamma");
@@ -34,35 +34,32 @@
#include "G4SystemOfUnits.hh"
#include "G4Log.hh"
#include "G4Exp.hh"
#include "G4AutoLock.hh"
#ifdef G4MULTITHREADED
G4Mutex G4VRangeToEnergyConverter::theMutex = G4MUTEX_INITIALIZER;
#endif
namespace
{
G4Mutex theREMutex = G4MUTEX_INITIALIZER;
}
G4double G4VRangeToEnergyConverter::Emin = 0.0;
G4double G4VRangeToEnergyConverter::Emax = 0.0;
G4double G4VRangeToEnergyConverter::sEmin = 0.0;
G4double G4VRangeToEnergyConverter::sEmax = 10000;
std::vector<G4double>* G4VRangeToEnergyConverter::Energy = nullptr;
std::vector<G4double>* G4VRangeToEnergyConverter::sEnergy = nullptr;
G4int G4VRangeToEnergyConverter::NbinPerDecade = 50;
G4int G4VRangeToEnergyConverter::Nbin = 350;
G4int G4VRangeToEnergyConverter::sNbinPerDecade = 50;
G4int G4VRangeToEnergyConverter::sNbin = 350;
// --------------------------------------------------------------------
G4VRangeToEnergyConverter::G4VRangeToEnergyConverter()
{
if(nullptr == Energy)
if(nullptr == sEnergy)
{
#ifdef G4MULTITHREADED
G4MUTEXLOCK(&theMutex);
if(nullptr == Energy)
G4AutoLock l(&theREMutex);
if(nullptr == sEnergy)
{
#endif
isFirstInstance = true;
Energy = new std::vector<G4double>(Nbin + 1);
#ifdef G4MULTITHREADED
}
G4MUTEXUNLOCK(&theMutex);
#endif
l.unlock();
}
// this method defines lock itself
if(isFirstInstance)
@@ -76,10 +73,10 @@ G4VRangeToEnergyConverter::~G4VRangeToEnergyConverter()
{
if(isFirstInstance)
{
delete Energy;
Energy = nullptr;
Emin = 0.;
Emax = 0.;
delete sEnergy;
sEnergy = nullptr;
sEmin = 0.;
sEmax = 10000.;
}
}
@@ -114,7 +111,7 @@ G4double G4VRangeToEnergyConverter::Convert(const G4double rangeCut,
}
}
cut = std::max(Emin, std::min(cut, Emax));
cut = std::max(sEmin, std::min(cut, sEmax));
return cut;
}
@@ -122,7 +119,7 @@ G4double G4VRangeToEnergyConverter::Convert(const G4double rangeCut,
void G4VRangeToEnergyConverter::SetEnergyRange(const G4double lowedge,
const G4double highedge)
{
G4double ehigh = std::min(Emax, highedge);
G4double ehigh = std::min(10.*CLHEP::GeV, highedge);
if(ehigh > lowedge)
{
FillEnergyVector(lowedge, ehigh);
@@ -132,28 +129,29 @@ void G4VRangeToEnergyConverter::SetEnergyRange(const G4double lowedge,
// --------------------------------------------------------------------
G4double G4VRangeToEnergyConverter::GetLowEdgeEnergy()
{
return Emin;
return sEmin;
}
// --------------------------------------------------------------------
G4double G4VRangeToEnergyConverter::GetHighEdgeEnergy()
{
return Emax;
return sEmax;
}
// --------------------------------------------------------------------
G4double G4VRangeToEnergyConverter::GetMaxEnergyCut()
{
return Emax;
return sEmax;
}
// --------------------------------------------------------------------
void G4VRangeToEnergyConverter::SetMaxEnergyCut(const G4double value)
{
if(value > Emin)
G4double ehigh = std::min(10.*CLHEP::GeV, value);
if(ehigh > sEmin)
{
FillEnergyVector(Emin, value);
FillEnergyVector(sEmin, ehigh);
}
}
@@ -161,25 +159,22 @@ void G4VRangeToEnergyConverter::SetMaxEnergyCut(const G4double value)
void G4VRangeToEnergyConverter::FillEnergyVector(const G4double emin,
const G4double emax)
{
if(emin != Emin || emax != Emax)
if(emin != sEmin || emax != sEmax || nullptr == sEnergy)
{
#ifdef G4MULTITHREADED
G4MUTEXLOCK(&theMutex);
if(emin != Emin || emax != Emax)
{
#endif
Emin = emin;
Emax = emax;
Nbin = NbinPerDecade*static_cast<G4int>(std::log10(emax/emin));
Energy->resize(Nbin + 1);
(*Energy)[0] = emin;
(*Energy)[Nbin] = emax;
G4double fact = G4Log(emax/emin)/Nbin;
for(G4int i=1; i<Nbin; ++i) { (*Energy)[i] = emin*G4Exp(i * fact); }
#ifdef G4MULTITHREADED
G4AutoLock l(&theREMutex);
if(emin != sEmin || emax != sEmax || nullptr == sEnergy)
{
sEmin = emin;
sEmax = emax;
sNbin = sNbinPerDecade*static_cast<G4int>(std::log10(emax/emin));
if(nullptr == sEnergy) { sEnergy = new std::vector<G4double>; }
sEnergy->resize(sNbin + 1);
(*sEnergy)[0] = emin;
(*sEnergy)[sNbin] = emax;
G4double fact = G4Log(emax/emin)/sNbin;
for(G4int i=1; i<sNbin; ++i) { (*sEnergy)[i] = emin*G4Exp(i * fact); }
}
G4MUTEXUNLOCK(&theMutex);
#endif
l.unlock();
}
}
@@ -197,9 +192,9 @@ G4VRangeToEnergyConverter::ConvertForGamma(const G4double rangeCut,
G4double range2 = 0.0;
G4double e1 = 0.0;
G4double e2 = 0.0;
for (G4int i=0; i<Nbin; ++i)
for (G4int i=0; i<sNbin; ++i)
{
e2 = (*Energy)[i];
e2 = (*sEnergy)[i];
G4double sig = 0.;
for (G4int j=0; j<nelm; ++j)
@@ -237,9 +232,9 @@ G4VRangeToEnergyConverter::ConvertForElectron(const G4double rangeCut,
G4double e1 = 0.0;
G4double e2 = 0.0;
G4double range = 0.;
for (G4int i=0; i<Nbin; ++i)
for (G4int i=0; i<sNbin; ++i)
{
e2 = (*Energy)[i];
e2 = (*sEnergy)[i];
dedx2 = 0.0;
for (G4int j=0; j<nelm; ++j)
{