Import Geant4 11.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2024-12-06 11:11:40 +01:00
parent e58e650b32
commit 32390e802b
1984 changed files with 98713 additions and 83996 deletions
@@ -301,7 +301,7 @@ void G4AdjointCSManager::BuildCrossSectionMatrices()
<< " does not use cross section matrices" << G4endl;
std::vector<G4AdjointCSMatrix*> two_empty_matrices;
fAdjointCSMatricesForProdToProj.push_back(two_empty_matrices);
fAdjointCSMatricesForScatProjToProj.push_back(two_empty_matrices);
fAdjointCSMatricesForScatProjToProj.push_back(std::move(two_empty_matrices));
}
}
G4cout << " All adjoint cross section matrices are computed!"
@@ -1066,11 +1066,10 @@ void G4AdjointCSManager::DefineCurrentMaterial(
void G4AdjointCSManager::DefineCurrentParticle(
const G4ParticleDefinition* aPartDef)
{
static G4ParticleDefinition* currentParticleDef = nullptr;
if(aPartDef != currentParticleDef)
if(aPartDef != fCurrentParticleDef)
{
currentParticleDef = const_cast<G4ParticleDefinition*>(aPartDef);
fCurrentParticleDef = const_cast<G4ParticleDefinition*>(aPartDef);
fMassRatio = 1.;
if(aPartDef == fAdjIon)
fMassRatio = proton_mass_c2 / aPartDef->GetPDGMass();
@@ -79,9 +79,9 @@ void G4AdjointCSMatrix::Clear()
///////////////////////////////////////////////////////
void G4AdjointCSMatrix::AddData(G4double aLogPrimEnergy, G4double aLogCS,
std::vector<double>* aLogSecondEnergyVector,
std::vector<double>* aLogProbVector,
size_t n_pro_decade)
std::vector<G4double>* aLogSecondEnergyVector,
std::vector<G4double>* aLogProbVector,
std::size_t n_pro_decade)
{
G4AdjointInterpolator* theInterpolator = G4AdjointInterpolator::GetInstance();
@@ -91,14 +91,14 @@ void G4AdjointCSMatrix::AddData(G4double aLogPrimEnergy, G4double aLogCS,
fLogSecondEnergyMatrix.push_back(aLogSecondEnergyVector);
fLogProbMatrix.push_back(aLogProbVector);
std::vector<size_t>* aLogProbVectorIndex = nullptr;
std::vector<std::size_t>* aLogProbVectorIndex = nullptr;
if(n_pro_decade > 0 && !aLogProbVector->empty())
{
aLogProbVectorIndex = new std::vector<size_t>();
aLogProbVectorIndex = new std::vector<std::size_t>();
G4double dlog = std::log(10.) / n_pro_decade;
G4double log_val =
int(std::min((*aLogProbVector)[0], aLogProbVector->back()) / dlog) * dlog;
G4int(std::min((*aLogProbVector)[0], aLogProbVector->back()) / dlog) * dlog;
fLog0Vector.push_back(log_val);
// Loop checking, 07-Aug-2015, Vladimir Ivanchenko
@@ -121,9 +121,9 @@ void G4AdjointCSMatrix::AddData(G4double aLogPrimEnergy, G4double aLogCS,
///////////////////////////////////////////////////////
G4bool G4AdjointCSMatrix::GetData(unsigned int i, G4double& aLogPrimEnergy,
G4double& aLogCS, G4double& log0,
std::vector<double>*& aLogSecondEnergyVector,
std::vector<double>*& aLogProbVector,
std::vector<size_t>*& aLogProbVectorIndex)
std::vector<G4double>*& aLogSecondEnergyVector,
std::vector<G4double>*& aLogProbVector,
std::vector<std::size_t>*& aLogProbVectorIndex)
{
if(i >= fNbPrimEnergy)
return false;
@@ -137,19 +137,19 @@ G4bool G4AdjointCSMatrix::GetData(unsigned int i, G4double& aLogPrimEnergy,
}
///////////////////////////////////////////////////////
void G4AdjointCSMatrix::Write(G4String file_name)
void G4AdjointCSMatrix::Write(const G4String& file_name)
{
std::fstream FileOutput(file_name, std::ios::out);
FileOutput << std::setiosflags(std::ios::scientific);
FileOutput << std::setprecision(6);
FileOutput << fLogPrimEnergyVector.size() << G4endl;
for(size_t i = 0; i < fLogPrimEnergyVector.size(); ++i)
for(std::size_t i = 0; i < fLogPrimEnergyVector.size(); ++i)
{
FileOutput << std::exp(fLogPrimEnergyVector[i]) / MeV << '\t'
<< std::exp(fLogCrossSectionVector[i]) << G4endl;
size_t j1 = 0;
std::size_t j1 = 0;
FileOutput << fLogSecondEnergyMatrix[i]->size() << G4endl;
for(size_t j = 0; j < fLogSecondEnergyMatrix[i]->size(); ++j)
for(std::size_t j = 0; j < fLogSecondEnergyMatrix[i]->size(); ++j)
{
FileOutput << std::exp((*fLogSecondEnergyMatrix[i])[j]);
++j1;
@@ -165,7 +165,7 @@ void G4AdjointCSMatrix::Write(G4String file_name)
FileOutput << G4endl;
j1 = 0;
FileOutput << fLogProbMatrix[i]->size() << G4endl;
for(size_t j = 0; j < fLogProbMatrix[i]->size(); ++j)
for(std::size_t j = 0; j < fLogProbMatrix[i]->size(); ++j)
{
FileOutput << std::exp((*fLogProbMatrix[i])[j]);
++j1;
@@ -183,17 +183,17 @@ void G4AdjointCSMatrix::Write(G4String file_name)
}
///////////////////////////////////////////////////////
void G4AdjointCSMatrix::Read(G4String file_name)
void G4AdjointCSMatrix::Read(const G4String& file_name)
{
std::fstream FileOutput(file_name, std::ios::in);
size_t n1, n2;
std::size_t n1, n2;
fLogPrimEnergyVector.clear();
fLogCrossSectionVector.clear();
fLogSecondEnergyMatrix.clear();
fLogProbMatrix.clear();
FileOutput >> n1;
for(size_t i = 0; i < n1; ++i)
for(std::size_t i = 0; i < n1; ++i)
{
G4double E, CS;
FileOutput >> E >> CS;
@@ -203,14 +203,14 @@ void G4AdjointCSMatrix::Read(G4String file_name)
fLogSecondEnergyMatrix.push_back(new std::vector<G4double>());
fLogProbMatrix.push_back(new std::vector<G4double>());
for(size_t j = 0; j < n2; ++j)
for(std::size_t j = 0; j < n2; ++j)
{
G4double E1;
FileOutput >> E1;
fLogSecondEnergyMatrix[i]->push_back(E1);
}
FileOutput >> n2;
for(size_t j = 0; j < n2; ++j)
for(std::size_t j = 0; j < n2; ++j)
{
G4double prob;
FileOutput >> prob;
@@ -34,7 +34,7 @@
#include "G4VEmAdjointModel.hh"
G4AdjointForcedInteractionForGamma::G4AdjointForcedInteractionForGamma(
G4String process_name)
const G4String& process_name)
: G4VContinuousDiscreteProcess(process_name)
, fAdjointComptonModel(nullptr)
, fAdjointBremModel(nullptr)
@@ -226,13 +226,12 @@ G4double
G4AdjointForcedInteractionForGamma::PostStepGetPhysicalInteractionLength(
const G4Track& track, G4double, G4ForceCondition* condition)
{
static G4int lastFreeFlightTrackId = 1000;
G4int step_id = track.GetCurrentStepNumber();
*condition = NotForced;
fCopyGammaForForced = false;
G4int track_id = track.GetTrackID();
fFreeFlightGamma =
(track_id != lastFreeFlightTrackId + 1 || fContinueGammaAsNewFreeFlight);
(track_id != fLastFreeFlightTrackId + 1 || fContinueGammaAsNewFreeFlight);
if(fFreeFlightGamma)
{
if(step_id == 1 || fContinueGammaAsNewFreeFlight)
@@ -241,7 +240,7 @@ G4AdjointForcedInteractionForGamma::PostStepGetPhysicalInteractionLength(
// A gamma with same conditions will be generate at next post_step do it
// for the forced interaction
fCopyGammaForForced = true;
lastFreeFlightTrackId = track_id;
fLastFreeFlightTrackId = track_id;
fAccTrackLength = 0.;
fTotNbAdjIntLength = 0.;
fContinueGammaAsNewFreeFlight = false;
@@ -85,7 +85,7 @@ G4double G4AdjointInterpolator::ExponentialInterpolation(
G4double G4AdjointInterpolator::Interpolation(G4double& x, G4double& x1,
G4double& x2, G4double& y1,
G4double& y2,
G4String InterPolMethod)
const G4String& InterPolMethod)
{
if(InterPolMethod == "Log")
{
@@ -111,15 +111,15 @@ G4double G4AdjointInterpolator::Interpolation(G4double& x, G4double& x1,
///////////////////////////////////////////////////////
// only valid if x_vec is monotically increasing
size_t G4AdjointInterpolator::FindPosition(G4double& x,
std::vector<G4double>& x_vec, size_t,
size_t)
std::size_t G4AdjointInterpolator::FindPosition(G4double& x,
std::vector<G4double>& x_vec, std::size_t,
std::size_t)
{
// most rapid method could be used probably
size_t ndim = x_vec.size();
size_t ind1 = 0;
size_t ind2 = ndim - 1;
std::size_t ndim = x_vec.size();
std::size_t ind1 = 0;
std::size_t ind2 = ndim - 1;
if(ndim > 1)
{
@@ -127,7 +127,7 @@ size_t G4AdjointInterpolator::FindPosition(G4double& x,
{ // increasing
do
{
size_t midBin = (ind1 + ind2) / 2;
std::size_t midBin = (ind1 + ind2) / 2;
if(x < x_vec[midBin])
ind2 = midBin;
else
@@ -138,7 +138,7 @@ size_t G4AdjointInterpolator::FindPosition(G4double& x,
{
do
{
size_t midBin = (ind1 + ind2) / 2;
std::size_t midBin = (ind1 + ind2) / 2;
if(x < x_vec[midBin])
ind1 = midBin;
else
@@ -152,7 +152,7 @@ size_t G4AdjointInterpolator::FindPosition(G4double& x,
///////////////////////////////////////////////////////
// only valid if x_vec is monotically increasing
size_t G4AdjointInterpolator::FindPositionForLogVector(
std::size_t G4AdjointInterpolator::FindPositionForLogVector(
G4double& log_x, std::vector<G4double>& log_x_vec)
{
// most rapid method could be used probably
@@ -163,9 +163,9 @@ size_t G4AdjointInterpolator::FindPositionForLogVector(
G4double G4AdjointInterpolator::Interpolate(G4double& x,
std::vector<G4double>& x_vec,
std::vector<G4double>& y_vec,
G4String InterPolMethod)
const G4String& InterPolMethod)
{
size_t i = FindPosition(x, x_vec);
std::size_t i = FindPosition(x, x_vec);
return Interpolation(x, x_vec[i], x_vec[i + 1], y_vec[i], y_vec[i + 1],
InterPolMethod);
}
@@ -173,19 +173,19 @@ G4double G4AdjointInterpolator::Interpolate(G4double& x,
///////////////////////////////////////////////////////
G4double G4AdjointInterpolator::InterpolateWithIndexVector(
G4double& x, std::vector<G4double>& x_vec, std::vector<G4double>& y_vec,
std::vector<size_t>& index_vec, G4double x0,
std::vector<std::size_t>& index_vec, G4double x0,
G4double dx) // only linear interpolation possible
{
size_t ind = 0;
std::size_t ind = 0;
if(x > x0)
ind = int((x - x0) / dx);
ind = G4int((x - x0) / dx);
if(ind >= index_vec.size() - 1)
ind = index_vec.size() - 2;
size_t ind1 = index_vec[ind];
size_t ind2 = index_vec[ind + 1];
std::size_t ind1 = index_vec[ind];
std::size_t ind2 = index_vec[ind + 1];
if(ind1 > ind2)
{
size_t ind11 = ind1;
std::size_t ind11 = ind1;
ind1 = ind2;
ind2 = ind11;
}
@@ -199,7 +199,7 @@ G4double G4AdjointInterpolator::InterpolateForLogVector(
G4double& log_x, std::vector<G4double>& log_x_vec,
std::vector<G4double>& log_y_vec)
{
size_t i = FindPositionForLogVector(log_x, log_x_vec);
std::size_t i = FindPositionForLogVector(log_x, log_x_vec);
G4double log_y = LinearInterpolation(log_x, log_x_vec[i], log_x_vec[i + 1],
log_y_vec[i], log_y_vec[i + 1]);
@@ -30,7 +30,7 @@
#include "G4VEmAdjointModel.hh"
////////////////////////////////////////////////////////////////////////////////
G4InversePEEffect::G4InversePEEffect(G4String process_name,
G4InversePEEffect::G4InversePEEffect(const G4String& process_name,
G4AdjointPhotoElectricModel* aModel)
: G4VAdjointReverseReaction(process_name, false)
{
@@ -38,7 +38,7 @@
////////////////////////////////////////////////////////////////////////////////
G4IonInverseIonisation::G4IonInverseIonisation(
G4bool whichScatCase, G4String process_name,
G4bool whichScatCase, const G4String& process_name,
G4AdjointIonIonisationModel* aEmAdjointModel)
: G4VAdjointReverseReaction(process_name, whichScatCase)
{
@@ -46,9 +46,6 @@ G4IonInverseIonisation::G4IonInverseIonisation(
fAdjointModel->SetSecondPartOfSameType(false);
}
////////////////////////////////////////////////////////////////////////////////
G4IonInverseIonisation::~G4IonInverseIonisation() {}
////////////////////////////////////////////////////////////////////////////////
void G4IonInverseIonisation::ProcessDescription(std::ostream& out) const
{
@@ -30,7 +30,7 @@
#include "G4ParticleChange.hh"
#include "G4VEmAdjointModel.hh"
G4VAdjointReverseReaction::G4VAdjointReverseReaction(G4String process_name,
G4VAdjointReverseReaction::G4VAdjointReverseReaction(const G4String& process_name,
G4bool whichScatCase)
: G4VDiscreteProcess(process_name)
{
@@ -47,9 +47,6 @@ G4eAdjointMultipleScattering::G4eAdjointMultipleScattering(
: G4VMultipleScattering(processName)
{}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4eAdjointMultipleScattering::~G4eAdjointMultipleScattering() {}
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void G4eAdjointMultipleScattering::ProcessDescription(std::ostream& out) const
{
@@ -29,7 +29,7 @@
////////////////////////////////////////////////////////////////////////////////
G4eInverseBremsstrahlung::G4eInverseBremsstrahlung(
G4bool whichScatCase, G4String process_name,
G4bool whichScatCase, const G4String& process_name,
G4VEmAdjointModel* aBremAdjointModel)
: G4VAdjointReverseReaction(process_name, whichScatCase)
{
@@ -37,9 +37,6 @@ G4eInverseBremsstrahlung::G4eInverseBremsstrahlung(
fAdjointModel->SetSecondPartOfSameType(false);
}
////////////////////////////////////////////////////////////////////////////////
G4eInverseBremsstrahlung::~G4eInverseBremsstrahlung() {}
////////////////////////////////////////////////////////////////////////////////
void G4eInverseBremsstrahlung::ProcessDescription(std::ostream& out) const
{
@@ -38,7 +38,7 @@
////////////////////////////////////////////////////////////////////////////////
G4eInverseCompton::G4eInverseCompton(
G4bool whichScatCase, G4String process_name,
G4bool whichScatCase, const G4String& process_name,
G4AdjointComptonModel* aComptonAdjointModel)
: G4VAdjointReverseReaction(process_name, whichScatCase)
{
@@ -46,9 +46,6 @@ G4eInverseCompton::G4eInverseCompton(
fAdjointModel->SetSecondPartOfSameType(false);
}
////////////////////////////////////////////////////////////////////////////////
G4eInverseCompton::~G4eInverseCompton() {}
////////////////////////////////////////////////////////////////////////////////
void G4eInverseCompton::ProcessDescription(std::ostream& out) const
{
@@ -38,7 +38,7 @@
////////////////////////////////////////////////////////////////////////////////
G4eInverseIonisation::G4eInverseIonisation(G4bool whichScatCase,
G4String process_name,
const G4String& process_name,
G4VEmAdjointModel* aEmAdjointModel)
: G4VAdjointReverseReaction(process_name, whichScatCase)
{
@@ -46,9 +46,6 @@ G4eInverseIonisation::G4eInverseIonisation(G4bool whichScatCase,
fAdjointModel->SetSecondPartOfSameType(true);
}
////////////////////////////////////////////////////////////////////////////////
G4eInverseIonisation::~G4eInverseIonisation() {}
////////////////////////////////////////////////////////////////////////////////
void G4eInverseIonisation::ProcessDescription(std::ostream& out) const
{
@@ -39,13 +39,10 @@
///////////////////////////////////////////////////////////////////////////////
G4hInverseIonisation::G4hInverseIonisation(
G4bool whichScatCase, G4String process_name,
G4bool whichScatCase, const G4String& process_name,
G4AdjointhIonisationModel* aEmAdjointModel)
: G4VAdjointReverseReaction(process_name, whichScatCase)
{
fAdjointModel = aEmAdjointModel;
fAdjointModel->SetSecondPartOfSameType(false);
}
///////////////////////////////////////////////////////////////////////////////
G4hInverseIonisation::~G4hInverseIonisation() {}