Import Geant4 10.0.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 11:51:14 +02:00
parent e2d2f9810a
commit 286caacf06
12421 changed files with 730077 additions and 502383 deletions
@@ -7,7 +7,7 @@
#
# Generated on : 24/9/2010
#
# $Id: CMakeLists.txt,v 1.1 2010-09-29 18:56:53 bmorgan Exp $
# $Id: CMakeLists.txt 66797 2013-01-12 15:38:45Z gcosmo $
#
#------------------------------------------------------------------------------
@@ -1,4 +1,4 @@
# $Id: GNUmakefile,v 1.2 2001-11-16 14:22:37 hpw Exp $
# $Id: GNUmakefile 66797 2013-01-12 15:38:45Z gcosmo $
# -----------------------------------------------------------
# GNUmakefile for hadronic library. Gabriele Cosmo, 18/9/96.
# -----------------------------------------------------------
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -58,11 +56,16 @@ namespace G4INCL {
currentTime = 0.0;
firstCollisionTime = 0.0;
firstCollisionXSec = 0.0;
firstCollisionSpectatorPosition = 0.0;
firstCollisionSpectatorMomentum = 0.0;
firstCollisionIsElastic = false;
nAvatars[SurfaceAvatarType] = 0;
nAvatars[CollisionAvatarType] = 0;
nAvatars[DecayAvatarType] = 0;
nAvatars[ParticleEntryAvatarType] = 0;
nCascading = 0;
nEmittedClusters = 0;
nEnergyViolationInteraction = 0;
};
void incrementAcceptedCollisions() { nAcceptedCollisions++; };
@@ -72,12 +75,23 @@ namespace G4INCL {
void incrementAvatars(AvatarType type) { nAvatars[type]++; };
void incrementCascading() { nCascading++; }
void decrementCascading() { nCascading--; }
void incrementEmittedClusters() { nEmittedClusters++; }
void incrementEnergyViolationInteraction() { nEnergyViolationInteraction++; }
void setFirstCollisionTime(G4double t) { firstCollisionTime = t; };
G4double getFirstCollisionTime() { return firstCollisionTime; };
void setFirstCollisionTime(const G4double t) { firstCollisionTime = t; };
G4double getFirstCollisionTime() const { return firstCollisionTime; };
void setFirstCollisionXSec(G4double x) { firstCollisionXSec = x; };
G4double getFirstCollisionXSec() { return firstCollisionXSec; };
void setFirstCollisionXSec(const G4double x) { firstCollisionXSec = x; };
G4double getFirstCollisionXSec() const { return firstCollisionXSec; };
void setFirstCollisionSpectatorPosition(const G4double x) { firstCollisionSpectatorPosition = x; };
G4double getFirstCollisionSpectatorPosition() const { return firstCollisionSpectatorPosition; };
void setFirstCollisionSpectatorMomentum(const G4double x) { firstCollisionSpectatorMomentum = x; };
G4double getFirstCollisionSpectatorMomentum() const { return firstCollisionSpectatorMomentum; };
void setFirstCollisionIsElastic(const G4bool e) { firstCollisionIsElastic = e; };
G4bool getFirstCollisionIsElastic() const { return firstCollisionIsElastic; };
void setCurrentTime(G4double t) { currentTime = t; };
G4double getCurrentTime() { return currentTime; };
@@ -88,6 +102,8 @@ namespace G4INCL {
G4int getBlockedDecays() const {return nBlockedDecays; };
G4int getAvatars(AvatarType type) const { return nAvatars.find(type)->second; };
G4int getCascading() const { return nCascading; };
G4int getEmittedClusters() const { return nEmittedClusters; };
G4int getEnergyViolationInteraction() const { return nEnergyViolationInteraction; };
private:
G4int nAcceptedCollisions;
@@ -97,8 +113,13 @@ namespace G4INCL {
G4double currentTime;
G4double firstCollisionTime;
G4double firstCollisionXSec;
G4double firstCollisionSpectatorPosition;
G4double firstCollisionSpectatorMomentum;
G4bool firstCollisionIsElastic;
std::map<AvatarType,G4int> nAvatars;
G4int nCascading;
G4int nEmittedClusters;
G4int nEnergyViolationInteraction;
};
}
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -41,10 +39,21 @@
#include "G4INCLParticleSpecies.hh"
#include "G4INCLConfigEnums.hh"
#include "G4INCLIRandomGenerator.hh"
#include "G4INCLRandomSeedVector.hh"
#include <iostream>
#include <string>
#include <sstream>
// #include <cassert>
#if defined(HAS_BOOST_PROGRAM_OPTIONS) && !defined(INCLXX_IN_GEANT4_MODE)
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
#include <fstream>
#include <cstdlib>
namespace po = boost::program_options;
#endif
namespace G4INCL {
@@ -124,10 +133,10 @@ namespace G4INCL {
void setProjectileSpecies(ParticleSpecies const &ps) { projectileSpecies=ps; }
/// \brief Get the projectile kinetic energy.
G4float getProjectileKineticEnergy() const { return projectileKineticEnergy; }
G4double getProjectileKineticEnergy() const { return projectileKineticEnergy; }
/// \brief Set the projectile kinetic energy.
void setProjectileKineticEnergy(G4float const kinE) { projectileKineticEnergy=kinE; }
void setProjectileKineticEnergy(G4double const kinE) { projectileKineticEnergy=kinE; }
/// \brief Get the number of the verbose event.
G4int getVerboseEvent() const { return verboseEvent; }
@@ -135,9 +144,19 @@ namespace G4INCL {
/// \brief Get the INCL version ID.
static std::string const getVersionID();
/// \brief Get the INCL version hash.
static std::string const getVersionHash();
/// \brief Get the INCL version string.
static std::string const getVersionString() {
std::stringstream ss;
ss << getVersionID() << "-" << getVersionHash();
return ss.str();
}
/// \brief Get the seeds for the random-number generator.
SeedVector const getRandomSeeds() const {
SeedVector s;
Random::SeedVector getRandomSeeds() const {
Random::SeedVector s;
s.push_back(randomSeed1);
s.push_back(randomSeed2);
return s;
@@ -182,6 +201,9 @@ namespace G4INCL {
/// \brief Get the de-excitation model.
DeExcitationType getDeExcitationType() const { return deExcitationType; }
/// \brief Get the de-excitation string.
std::string getDeExcitationString() const { return deExcitationString; }
/// \brief Get the clustering algorithm.
ClusterAlgorithmType getClusterAlgorithm() const { return clusterAlgorithmType; }
@@ -200,9 +222,6 @@ namespace G4INCL {
/// \brief Set whether to use real masses
void setUseRealMasses(G4bool use) { useRealMasses = use; }
/// \brief Echo the input options.
std::string const echo() const;
std::string const &getINCLXXDataFilePath() const {
return INCLXXDataFilePath;
}
@@ -226,14 +245,90 @@ namespace G4INCL {
G4double getImpactParameter() const { return impactParameter; }
/// \brief Get the separation-energy type.
/// \brief Get the separation-energy type
SeparationEnergyType getSeparationEnergyType() const { return separationEnergyType; }
/// \brief Get the Fermi-momentum type
FermiMomentumType getFermiMomentumType() const { return fermiMomentumType; }
/// \brief Set the Fermi-momentum type
void setFermiMomentumType(FermiMomentumType const f) { fermiMomentumType=f; }
G4double getCutNN() const { return cutNN; }
#ifdef INCL_ROOT_USE
std::string const &getROOTSelectionString() const {
return rootSelectionString;
}
#endif
#ifdef INCL_DEEXCITATION_FERMI_BREAKUP
G4int getMaxMassFermiBreakUp() const {
return maxMassFermiBreakUp;
}
#endif
/// \brief Get the r-p correlation coefficient
G4double getRPCorrelationCoefficient(const ParticleType t) const {
// assert(t==Proton || t==Neutron);
return ((t==Proton) ? rpCorrelationCoefficientProton : rpCorrelationCoefficientNeutron);
}
/// \brief Set the r-p correlation coefficient
void setRPCorrelationCoefficient(const ParticleType t, const G4double corrCoeff) {
// assert(t==Proton || t==Neutron);
if(t==Proton)
rpCorrelationCoefficientProton=corrCoeff;
else
rpCorrelationCoefficientNeutron=corrCoeff;
}
/// \brief Set the r-p correlation coefficient
void setRPCorrelationCoefficient(const G4double corrCoeff) {
setRPCorrelationCoefficient(Proton,corrCoeff);
setRPCorrelationCoefficient(Neutron,corrCoeff);
}
/// \brief Get the neutron-skin thickness
G4double getNeutronSkinThickness() const { return neutronSkinThickness; }
/// \brief Set the neutron-skin thickness
void setNeutronSkinThickness(const G4double d) { neutronSkinThickness=d; }
/// \brief Get the neutron-skin additional diffuseness
G4double getNeutronSkinAdditionalDiffuseness() const { return neutronSkinAdditionalDiffuseness; }
/// \brief Set the neutron-skin additional diffuseness
void setNeutronSkinAdditionalDiffuseness(const G4double d) { neutronSkinAdditionalDiffuseness=d; }
/// \brief True if we should use refraction
G4bool getRefraction() const { return refraction; }
/// \brief Set the refraction variable
void setRefraction(const G4bool r) { refraction = r; }
#if defined(HAS_BOOST_PROGRAM_OPTIONS) && !defined(INCLXX_IN_GEANT4_MODE)
/// \brief Echo the input options.
std::string const echo() const;
#endif
private:
#if defined(HAS_BOOST_PROGRAM_OPTIONS) && !defined(INCLXX_IN_GEANT4_MODE)
std::string echoOptionsDescription(const po::options_description &aDesc) const;
po::options_description runOptDesc;
po::options_description hiddenOptDesc;
po::options_description genericOptDesc;
po::options_description physicsOptDesc;
po::variables_map variablesMap;
#endif
G4int verbosity;
std::string inputFileName;
std::string title;
std::string outputFileRoot;
std::string fileSuffix;
std::string logFileName;
G4int nShots;
@@ -244,11 +339,12 @@ namespace G4INCL {
std::string projectileString;
ParticleSpecies projectileSpecies;
G4float projectileKineticEnergy;
G4double projectileKineticEnergy;
G4int verboseEvent;
G4int randomSeed1, randomSeed2;
static const G4int randomSeedMin, randomSeedMax;
std::string pauliString;
PauliType pauliType;
@@ -267,6 +363,8 @@ namespace G4INCL {
std::string localEnergyPiString;
LocalEnergyType localEnergyPiType;
std::string deExcitationModelList;
std::string deExcitationOptionDescription;
std::string deExcitationString;
DeExcitationType deExcitationType;
#ifdef INCL_DEEXCITATION_ABLAXX
@@ -294,6 +392,27 @@ namespace G4INCL {
std::string separationEnergyString;
SeparationEnergyType separationEnergyType;
std::string fermiMomentumString;
FermiMomentumType fermiMomentumType;
G4double cutNN;
#ifdef INCL_ROOT_USE
std::string rootSelectionString;
#endif
#ifdef INCL_DEEXCITATION_FERMI_BREAKUP
G4int maxMassFermiBreakUp;
#endif
G4double rpCorrelationCoefficient;
G4double rpCorrelationCoefficientProton;
G4double rpCorrelationCoefficientNeutron;
G4double neutronSkinThickness;
G4double neutronSkinAdditionalDiffuseness;
G4bool refraction;
};
}
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -101,6 +99,13 @@ namespace G4INCL {
RealForLightSeparationEnergy
};
// Enumerator for Fermi-momentum types
enum FermiMomentumType {
ConstantFermiMomentum,
ConstantLightFermiMomentum,
MassDependentFermiMomentum
};
}
#endif
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -45,8 +43,8 @@
* \author Davide Mancusi
*/
#ifndef G4INCLEVENTINFO_HH
#define G4INCLEVENTINFO_HH 1
#ifndef G4INCLEVENTINFO_HH_HH
#define G4INCLEVENTINFO_HH_HH 1
#include "G4INCLParticleType.hh"
#ifdef INCL_ROOT_USE
@@ -67,135 +65,132 @@ namespace G4INCL {
struct EventInfo {
EventInfo() :
projectileType(UnknownParticle),
At(0), Zt(0), Ap(0), Zp(0),
Ep(0.),
impactParameter(0.0), nCollisions(0), stoppingTime(0.0),
EBalance(0.0), pLongBalance(0.0), pTransBalance(0.0),
nCascadeParticles(0), nRemnants(0), nParticles(0),
transparent(true),
nParticles(0),
nRemnants(0),
projectileType(0),
At(0),
Zt(0),
Ap(0),
Zp(0),
Ep((Float_t)0.0),
impactParameter((Float_t)0.0),
nCollisions(0),
stoppingTime((Float_t)0.0),
EBalance((Float_t)0.0),
pLongBalance((Float_t)0.0),
pTransBalance((Float_t)0.0),
nCascadeParticles(0),
transparent(false),
forcedCompoundNucleus(false),
nucleonAbsorption(false), pionAbsorption(false), nDecays(0),
nBlockedCollisions(0), nBlockedDecays(0),
effectiveImpactParameter(0.0),
nucleonAbsorption(false),
pionAbsorption(false),
nDecays(0),
nBlockedCollisions(0),
nBlockedDecays(0),
effectiveImpactParameter((Float_t)0.0),
deltasInside(false),
forcedDeltasInside(false),
forcedDeltasOutside(false),
clusterDecay(false),
firstCollisionTime(0.),
firstCollisionXSec(0.),
firstCollisionTime((Float_t)0.0),
firstCollisionXSec((Float_t)0.0),
firstCollisionSpectatorPosition((Float_t)0.0),
firstCollisionSpectatorMomentum((Float_t)0.0),
firstCollisionIsElastic(false),
nReflectionAvatars(0),
nCollisionAvatars(0),
nDecayAvatars(0),
nUnmergedSpectators(0)
{
std::fill_n(ARem, maxSizeRemnants, 0);
std::fill_n(ZRem, maxSizeRemnants, 0);
std::fill_n(EStarRem, maxSizeRemnants, ((Float_t)0.));
std::fill_n(JRem, maxSizeRemnants, ((Float_t)0.));
std::fill_n(EKinRem, maxSizeRemnants, ((Float_t)0.));
std::fill_n(pxRem, maxSizeRemnants, ((Float_t)0.));
std::fill_n(pyRem, maxSizeRemnants, ((Float_t)0.));
std::fill_n(pzRem, maxSizeRemnants, ((Float_t)0.));
std::fill_n(thetaRem, maxSizeRemnants, ((Float_t)0.));
std::fill_n(phiRem, maxSizeRemnants, ((Float_t)0.));
std::fill_n(jxRem, maxSizeRemnants, ((Float_t)0.));
std::fill_n(jyRem, maxSizeRemnants, ((Float_t)0.));
std::fill_n(jzRem, maxSizeRemnants, ((Float_t)0.));
nUnmergedSpectators(0),
nEnergyViolationInteraction(0)
#ifdef INCL_INVERSE_KINEMATICS
#endif
{
std::fill_n(A, maxSizeParticles, 0);
std::fill_n(Z, maxSizeParticles, 0);
std::fill_n(emissionTime, maxSizeParticles, ((Float_t)0.));
std::fill_n(EKin, maxSizeParticles, ((Float_t)0.));
std::fill_n(px, maxSizeParticles, ((Float_t)0.));
std::fill_n(py, maxSizeParticles, ((Float_t)0.));
std::fill_n(pz, maxSizeParticles, ((Float_t)0.));
std::fill_n(theta, maxSizeParticles, ((Float_t)0.));
std::fill_n(phi, maxSizeParticles, ((Float_t)0.));
std::fill_n(EKin, maxSizeParticles, (Float_t)0.0);
std::fill_n(px, maxSizeParticles, (Float_t)0.0);
std::fill_n(py, maxSizeParticles, (Float_t)0.0);
std::fill_n(pz, maxSizeParticles, (Float_t)0.0);
std::fill_n(theta, maxSizeParticles, (Float_t)0.0);
std::fill_n(phi, maxSizeParticles, (Float_t)0.0);
std::fill_n(origin, maxSizeParticles, 0);
};
std::fill_n(emissionTime, maxSizeParticles, (Float_t)0.0);
std::fill_n(ARem, maxSizeRemnants, 0);
std::fill_n(ZRem, maxSizeRemnants, 0);
std::fill_n(EStarRem, maxSizeRemnants, (Float_t)0.0);
std::fill_n(JRem, maxSizeRemnants, (Float_t)0.0);
std::fill_n(EKinRem, maxSizeRemnants, (Float_t)0.0);
std::fill_n(pxRem, maxSizeRemnants, (Float_t)0.0);
std::fill_n(pyRem, maxSizeRemnants, (Float_t)0.0);
std::fill_n(pzRem, maxSizeRemnants, (Float_t)0.0);
std::fill_n(thetaRem, maxSizeRemnants, (Float_t)0.0);
std::fill_n(phiRem, maxSizeRemnants, (Float_t)0.0);
std::fill_n(jxRem, maxSizeRemnants, (Float_t)0.0);
std::fill_n(jyRem, maxSizeRemnants, (Float_t)0.0);
std::fill_n(jzRem, maxSizeRemnants, (Float_t)0.0);
#ifdef INCL_INVERSE_KINEMATICS
std::fill_n(EKinPrime, maxSizeParticles, (Float_t)0.0);
std::fill_n(pzPrime, maxSizeParticles, (Float_t)0.0);
std::fill_n(thetaPrime, maxSizeParticles, (Float_t)0.0);
#endif
}
/** \brief Number of the event */
static Int_t eventNumber;
/** \brief Protjectile particle type */
ParticleType projectileType;
/** \brief Mass number of the target nucleus */
Short_t At;
/** \brief Charge number of the target nucleus */
Short_t Zt;
/** \brief Mass number of the projectile nucleus */
Short_t Ap;
/** \brief Charge number of the projectile nucleus */
Short_t Zp;
/** \brief Projectile kinetic energy given as input */
Float_t Ep;
/** \brief Impact parameter [fm] */
Float_t impactParameter;
/** \brief Number of accepted two-body collisions */
Int_t nCollisions;
/** \brief Cascade stopping time [fm/c] */
Float_t stoppingTime;
/** \brief Energy-conservation balance [MeV] */
Float_t EBalance;
/** \brief Longitudinal momentum-conservation balance [MeV/c] */
Float_t pLongBalance;
/** \brief Transverse momentum-conservation balance [MeV/c] */
Float_t pTransBalance;
/** \brief Number of cascade particles */
Short_t nCascadeParticles;
/** \brief Number of remnants */
Int_t nRemnants;
/** \brief Total number of emitted particles */
Int_t nParticles;
/** \brief True if the event is transparent */
Bool_t transparent;
/** \brief True if the event is a forced CN */
Bool_t forcedCompoundNucleus;
/** \brief True if the event is absorption */
Bool_t nucleonAbsorption;
/** \brief True if the event is absorption */
Bool_t pionAbsorption;
/** \brief Number of accepted Delta decays */
Int_t nDecays;
/** \brief Number of two-body collisions blocked by Pauli or CDPP */
Int_t nBlockedCollisions;
/** \brief Number of decays blocked by Pauli or CDPP */
Int_t nBlockedDecays;
/** \brief Number of reflection avatars */
/** \brief Effective (Coulomb-distorted) impact parameter [fm] */
Float_t effectiveImpactParameter;
/// \brief Event involved deltas in the nucleus at the end of the cascade
Bool_t deltasInside;
/// \brief Event involved forced delta decays inside the nucleus
Bool_t forcedDeltasInside;
/// \brief Event involved forced delta decays outside the nucleus
Bool_t forcedDeltasOutside;
/// \brief Event involved cluster decay
Bool_t clusterDecay;
/** \brief Time of the first collision [fm/c] */
Float_t firstCollisionTime;
/** \brief Cross section of the first collision (mb) */
Float_t firstCollisionXSec;
Int_t nReflectionAvatars;
/** \brief Number of collision avatars */
Int_t nCollisionAvatars;
/** \brief Number of decay avatars */
Int_t nDecayAvatars;
/// \brief Number of dynamical spectators that were merged back into the projectile remnant
Int_t nUnmergedSpectators;
static G4ThreadLocal Int_t eventNumber;
/** \brief Maximum array size for remnants */
static const Short_t maxSizeRemnants = 10;
/** \brief Maximum array size for emitted particles */
static const Short_t maxSizeParticles = 1000;
/** \brief Number of particles in the final state */
Short_t nParticles;
/** \brief Particle mass number */
Short_t A[maxSizeParticles];
/** \brief Particle charge number */
Short_t Z[maxSizeParticles];
/** \brief Particle kinetic energy [MeV] */
Float_t EKin[maxSizeParticles];
/** \brief Particle momentum, x component [MeV/c] */
Float_t px[maxSizeParticles];
/** \brief Particle momentum, y component [MeV/c] */
Float_t py[maxSizeParticles];
/** \brief Particle momentum, z component [MeV/c] */
Float_t pz[maxSizeParticles];
/** \brief Particle momentum polar angle [radians] */
Float_t theta[maxSizeParticles];
/** \brief Particle momentum azimuthal angle [radians] */
Float_t phi[maxSizeParticles];
/** \brief Origin of the particle
*
* Should be -1 for cascade particles, or the number of the remnant for
* de-excitation particles. */
Short_t origin[maxSizeParticles];
/** \brief Emission time [fm/c] */
Float_t emissionTime[maxSizeParticles];
/** \brief History of the particle
*
* Condensed information about the de-excitation chain of a particle. For
* cascade particles, it is just an empty string. For particles arising
* from the de-excitation of a cascade remnant, it is a string of
* characters. Each character represents one or more identical steps in
* the de-excitation process. The currently defined possible character
* values and their meanings are the following:
*
* e: evaporation product
* E: evaporation residue
* m: multifragmentation
* a: light partner in asymmetric fission or IMF emission
* A: heavy partner in asymmetric fission or IMF emission
* f: light partner in fission
* F: heavy partner in fission
* s: saddle-to-scission emission
* n: non-statistical emission (decay) */
std::vector<std::string> history;
/** \brief Number of remnants */
Int_t nRemnants;
/** \brief Remnant mass number */
Short_t ARem[maxSizeRemnants];
/** \brief Remnant charge number */
@@ -216,60 +211,82 @@ namespace G4INCL {
Float_t thetaRem[maxSizeRemnants];
/** \brief Remnant momentum azimuthal angle [radians] */
Float_t phiRem[maxSizeRemnants];
/** \brief Remnant angular momentum, x component [hbar] */
/** \brief Remnant angular momentum, x component [\f$\hbar\f$] */
Float_t jxRem[maxSizeRemnants];
/** \brief Remnant angular momentum, y component [hbar] */
/** \brief Remnant angular momentum, y component [\f$\hbar\f$] */
Float_t jyRem[maxSizeRemnants];
/** \brief Remnant angular momentum, z component [hbar] */
/** \brief Remnant angular momentum, z component [\f$\hbar\f$] */
Float_t jzRem[maxSizeRemnants];
/** \brief Maximum array size for emitted particles */
static const Short_t maxSizeParticles = 1000;
/** \brief Particle mass number */
Short_t A[maxSizeParticles];
/** \brief Particle charge number */
Short_t Z[maxSizeParticles];
/** \brief Emission time [fm/c] */
Float_t emissionTime[maxSizeParticles];
/** \brief Particle kinetic energy [MeV] */
Float_t EKin[maxSizeParticles];
/** \brief Particle momentum, x component [MeV/c] */
Float_t px[maxSizeParticles];
/** \brief Particle momentum, y component [MeV/c] */
Float_t py[maxSizeParticles];
/** \brief Particle momentum, z component [MeV/c] */
Float_t pz[maxSizeParticles];
/** \brief Particle momentum polar angle [radians] */
Float_t theta[maxSizeParticles];
/** \brief Particle momentum azimuthal angle [radians] */
Float_t phi[maxSizeParticles];
/** \brief Origin of the particle
*
* Should be -1 for cascade particles, or the number of the remnant for
* de-excitation particles.
*
*/
Short_t origin[maxSizeParticles];
/** \brief History of the particle
*
* Condensed information about the de-excitation chain of a particle. For
* cascade particles, it is just an empty string. For particles arising
* from the de-excitation of a cascade remnant, it is a string of
* characters. Each character represents one or more identical steps in
* the de-excitation process. The currently defined possible character
* values and their meanings are the following:
*
* e: evaporation product
* E: evaporation residue
* m: multifragmentation
* a: light partner in asymmetric fission or IMF emission
* A: heavy partner in asymmetric fission or IMF emission
* f: light partner in fission
* F: heavy partner in fission
* s: saddle-to-scission emission
* n: non-statistical emission (decay)
*/
std::vector<std::string> history;
/** \brief Projectile particle type */
Int_t projectileType;
/** \brief Mass number of the target nucleus */
Short_t At;
/** \brief Charge number of the target nucleus */
Short_t Zt;
/** \brief Mass number of the projectile nucleus */
Short_t Ap;
/** \brief Charge number of the projectile nucleus */
Short_t Zp;
/** \brief Projectile kinetic energy given as input */
Float_t Ep;
/** \brief Impact parameter [fm] */
Float_t impactParameter;
/** \brief Number of accepted two-body collisions */
Int_t nCollisions;
/** \brief Cascade stopping time [fm/c] */
Float_t stoppingTime;
/** \brief Energy-conservation balance [MeV] */
Float_t EBalance;
/** \brief Longitudinal momentum-conservation balance [MeV/c] */
Float_t pLongBalance;
/** \brief Transverse momentum-conservation balance [MeV/c] */
Float_t pTransBalance;
/** \brief Number of cascade particles */
Short_t nCascadeParticles;
/** \brief True if the event is transparent */
Bool_t transparent;
/** \brief True if the event is a forced CN */
Bool_t forcedCompoundNucleus;
/** \brief True if the event is a nucleon absorption */
Bool_t nucleonAbsorption;
/** \brief True if the event is a pion absorption */
Bool_t pionAbsorption;
/** \brief Number of accepted Delta decays */
Int_t nDecays;
/** \brief Number of two-body collisions blocked by Pauli or CDPP */
Int_t nBlockedCollisions;
/** \brief Number of decays blocked by Pauli or CDPP */
Int_t nBlockedDecays;
/** \brief Effective (Coulomb-distorted) impact parameter [fm] */
Float_t effectiveImpactParameter;
/** \brief Event involved deltas in the nucleus at the end of the cascade */
Bool_t deltasInside;
/** \brief Event involved forced delta decays inside the nucleus */
Bool_t forcedDeltasInside;
/** \brief Event involved forced delta decays outside the nucleus */
Bool_t forcedDeltasOutside;
/** \brief Event involved cluster decay */
Bool_t clusterDecay;
/** \brief Time of the first collision [fm/c] */
Float_t firstCollisionTime;
/** \brief Cross section of the first collision (mb) */
Float_t firstCollisionXSec;
/** \brief Position of the spectator on the first collision (fm) */
Float_t firstCollisionSpectatorPosition;
/** \brief Momentum of the spectator on the first collision (fm) */
Float_t firstCollisionSpectatorMomentum;
/** \brief True if the first collision was elastic */
Bool_t firstCollisionIsElastic;
/** \brief Number of reflection avatars */
Int_t nReflectionAvatars;
/** \brief Number of collision avatars */
Int_t nCollisionAvatars;
/** \brief Number of decay avatars */
Int_t nDecayAvatars;
/** \brief Number of dynamical spectators that were merged back into the projectile remnant */
Int_t nUnmergedSpectators;
/** \brief Number of attempted collisions/decays for which the energy-conservation algorithm failed to find a solution. */
Int_t nEnergyViolationInteraction;
#ifdef INCL_INVERSE_KINEMATICS
/** \brief Particle kinetic energy, in inverse kinematics [MeV] */
@@ -282,39 +299,57 @@ namespace G4INCL {
/** \brief Reset the EventInfo members */
void reset() {
Ap = 0;
Zp = 0;
nParticles = 0;
history.clear();
nRemnants = 0;
projectileType = 0;
At = 0;
Zt = 0;
impactParameter = 0.0;
effectiveImpactParameter = 0.0;
stoppingTime = 0.0;
EBalance = 0.0;
pLongBalance = 0.0;
pTransBalance = 0.0;
Ap = 0;
Zp = 0;
Ep = (Float_t)0.0;
impactParameter = (Float_t)0.0;
nCollisions = 0;
nBlockedCollisions = 0;
nDecays = 0;
nBlockedDecays= 0;
nDecays = 0;
stoppingTime = (Float_t)0.0;
EBalance = (Float_t)0.0;
pLongBalance = (Float_t)0.0;
pTransBalance = (Float_t)0.0;
nCascadeParticles = 0;
nRemnants = 0;
nParticles = 0;
transparent = true;
transparent = false;
forcedCompoundNucleus = false;
nucleonAbsorption = false;
pionAbsorption = false;
nucleonAbsorption = false;
pionAbsorption = false;
nDecays = 0;
nBlockedCollisions = 0;
nBlockedDecays = 0;
effectiveImpactParameter = (Float_t)0.0;
deltasInside = false;
forcedDeltasInside = false;
forcedDeltasOutside = false;
deltasInside = false;
clusterDecay = false;
firstCollisionTime = (Float_t)0.0;
firstCollisionXSec = (Float_t)0.0;
firstCollisionSpectatorPosition = (Float_t)0.0;
firstCollisionSpectatorMomentum = (Float_t)0.0;
firstCollisionIsElastic = false;
nReflectionAvatars = 0;
nCollisionAvatars = 0;
nDecayAvatars = 0;
nUnmergedSpectators = 0;
nEnergyViolationInteraction = 0;
#ifdef INCL_INVERSE_KINEMATICS
#endif
}
/// \brief Move a remnant to the particle array
void remnantToParticle(const G4int remnantIndex);
#ifdef INCL_INVERSE_KINEMATICS
/// \brief Fill the variables describing the reaction in inverse kinematics
void fillInverseKinematics(const Double_t gamma);
#endif // INCL_INVERSE_KINEMATICS
};
}
#endif /* G4INCLEVENTINFO_HH */
#endif /* G4INCLEVENTINFO_HH_HH */
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -51,17 +49,17 @@ namespace G4INCL {
class Geant4RandomGenerator : public G4INCL::IRandomGenerator {
public:
Geant4RandomGenerator() {};
Geant4RandomGenerator(const SeedVector &) {};
Geant4RandomGenerator(const Random::SeedVector &) {};
virtual ~Geant4RandomGenerator() {};
SeedVector getSeeds() const {
WARN("getSeeds not supported.");
SeedVector sv;
Random::SeedVector getSeeds() {
INCL_WARN("getSeeds not supported.");
Random::SeedVector sv;
return sv;
}
void setSeeds(const SeedVector &) {
WARN("setSeeds not supported.");
void setSeeds(const Random::SeedVector &) {
INCL_WARN("setSeeds not supported.");
}
G4double flat() {
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -63,37 +61,46 @@ namespace G4INCL {
struct GlobalInfo {
GlobalInfo() :
nShots(0), nTransparents(0), nNucleonAbsorptions(0), nPionAbsorptions(0),
nForcedTransparents(0), nForcedCompoundNucleus(0),
nucleonAbsorptionCrossSection(0.0), pionAbsorptionCrossSection(0.0),
geometricCrossSection(0.0), reactionCrossSection(0.0),
Ap(0), Zp(0), At(0), Zt(0), Ep(0.0)
{};
#ifdef INCL_ROOT_USE
/** \brief Number of shots */
Int_t nShots;
/** \brief Number of transparent shots */
Int_t nTransparents;
/** \brief Number of nucleon absorptions (no outcoming particles) */
Int_t nNucleonAbsorptions;
/** \brief Number of nucleon absorptions (no outcoming pions) */
Int_t nPionAbsorptions;
/** \brief Number of forced transparents */
Int_t nForcedTransparents;
/** \brief Number of forced compound-nucleus events */
Int_t nForcedCompoundNucleus;
/** \brief Nucleon absorption cross section */
Float_t nucleonAbsorptionCrossSection;
/** \brief Pion absorption cross section */
Float_t pionAbsorptionCrossSection;
/** \brief Geometric cross section */
Float_t geometricCrossSection;
/** \brief Calculated reaction cross section */
Float_t reactionCrossSection;
/** \brief Error on the calculated reaction cross section */
Float_t errorReactionCrossSection;
#endif
Ap(0),
Zp(0),
At(0),
Zt(0),
Ep((Float_t)0.0),
nShots(0),
geometricCrossSection((Float_t)0.0),
nTransparents(0),
reactionCrossSection((Float_t)0.0),
errorReactionCrossSection((Float_t)0.0),
nNucleonAbsorptions(0),
nucleonAbsorptionCrossSection((Float_t)0.0),
nPionAbsorptions(0),
pionAbsorptionCrossSection((Float_t)0.0),
nForcedTransparents(0),
nForcedCompoundNucleus(0),
forcedCNCrossSection((Float_t)0.0),
errorForcedCNCrossSection((Float_t)0.0),
nCompleteFusion(0),
completeFusionCrossSection((Float_t)0.0),
errorCompleteFusionCrossSection((Float_t)0.0),
nEnergyViolationInteraction(0),
energyViolationInteractionCrossSection((Float_t)0.0)
{
#ifdef INCL_ROOT_USE
// \todo{echo all the input parameters here}
#endif
}
#ifdef INCL_ROOT_USE
/** \brief Selection string for an abridged version of the ROOT tree */
std::string rootSelection;
#endif
/** \brief Name of the cascade model */
std::string cascadeModel;
/** \brief Name of the de-excitation model */
std::string deexcitationModel;
/** \brief Projectile mass number given as input */
Short_t Ap;
/** \brief Projectile charge number given as input */
@@ -104,11 +111,42 @@ namespace G4INCL {
Short_t Zt;
/** \brief Projectile kinetic energy given as input */
Float_t Ep;
/** \brief Name of the cascade model */
std::string cascadeModel;
/** \brief Name of the de-excitation model */
std::string deexcitationModel;
/** \brief Number of shots */
Int_t nShots;
/** \brief Geometric cross section */
Float_t geometricCrossSection;
/** \brief Number of transparent shots */
Int_t nTransparents;
/** \brief Calculated reaction cross section */
Float_t reactionCrossSection;
/** \brief Error on the calculated reaction cross section */
Float_t errorReactionCrossSection;
/** \brief Number of nucleon absorptions (no outcoming particles) */
Int_t nNucleonAbsorptions;
/** \brief Nucleon absorption cross section */
Float_t nucleonAbsorptionCrossSection;
/** \brief Number of nucleon absorptions (no outcoming pions) */
Int_t nPionAbsorptions;
/** \brief Pion absorption cross section */
Float_t pionAbsorptionCrossSection;
/** \brief Number of forced transparents */
Int_t nForcedTransparents;
/** \brief Number of forced compound-nucleus events */
Int_t nForcedCompoundNucleus;
/** \brief Calculated forced-compound-nucleus cross section */
Float_t forcedCNCrossSection;
/** \brief Error on the calculated forced-compound-nucleus cross section */
Float_t errorForcedCNCrossSection;
/** \brief Number of complete-fusion events (nParticles==0) */
Int_t nCompleteFusion;
/** \brief Calculated complete-fusion cross section (nParticles==0) */
Float_t completeFusionCrossSection;
/** \brief Error on the calculated complete-fusion cross section (nParticles==0) */
Float_t errorCompleteFusionCrossSection;
/** \brief Number of attempted collisions/decays for which the energy-conservation algorithm failed to find a solution. */
Int_t nEnergyViolationInteraction;
/** \brief Cross section for attempted collisions/decays for which the energy-conservation algorithm failed to find a solution. */
Float_t energyViolationInteractionCrossSection;
};
}
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -40,6 +38,7 @@
#define G4INCLGlobals_hh 1
#include <cmath>
#include <string>
#include "G4INCLParticleType.hh"
namespace G4INCL {
@@ -59,6 +58,9 @@ namespace G4INCL {
/// \brief Fermi momentum squared [(MeV/c)^2]
const G4double PfSquared = Pf*Pf;
/// \brief Fermi momentum cubed [(MeV/c)^3]
const G4double PfCubed = Pf*PfSquared;
/** \brief Coulomb conversion factor [MeV*fm]
*
* \f[ e^2/(4 pi epsilon_0) \f]
@@ -71,6 +73,7 @@ namespace G4INCL {
const G4double twoPi = 2.0 * pi;
const G4double tenPi = 10.0 * pi;
const G4double piOverTwo = 0.5 * pi;
const G4double oneOverSqrtTwo = 1./std::sqrt((G4double)2.);
const G4double oneOverSqrtThree = 1./std::sqrt((G4double)3.);
const G4double oneThird = 1./3.;
const G4double twoThirds = 2./3.;
@@ -98,16 +101,56 @@ namespace G4INCL {
return std::pow(x, twoThirds);
}
inline G4double aSinH(G4double x) {
return std::log(x + std::sqrt(x*x+1.));
}
/**
* A simple sign function that allows us to port fortran code to c++ more easily.
*/
template <typename T> inline G4int sign(T t) {
template <typename T> inline G4int sign(const T t) {
return t > 0 ? 1: t < 0 ? -1 : 0;
}
/// brief Return the largest of the two arguments
template <typename T> inline T max(const T t1, const T t2) {
return t1 > t2 ? t1 : t2;
}
/// brief Return the smallest of the two arguments
template <typename T> inline T min(const T t1, const T t2) {
return t1 < t2 ? t1 : t2;
}
/** \brief Cumulative distribution function for Gaussian
*
* A public-domain approximation taken from Abramowitz and Stegun. Applies
* to a Gaussian with mean=0 and sigma=1.
*
* \param x a Gaussian variable
*/
G4double gaussianCDF(const G4double x);
/** \brief Generic cumulative distribution function for Gaussian
*
* A public-domain approximation taken from Abramowitz and Stegun. Applies
* to a generic Gaussian.
*
* \param x a Gaussian variable
* \param x0 mean of the Gaussian
* \param sigma standard deviation of the Gaussian
*/
G4double gaussianCDF(const G4double x, const G4double x0, const G4double sigma);
}
namespace ParticleConfig {
G4bool isPair(Particle const * const p1, Particle const * const p2, ParticleType t1, ParticleType t2);
}
namespace String {
void wrap(std::string &str, const size_t lineLength=78, const std::string &separators=" \t");
void replaceAll(std::string &str, const std::string &from, const std::string &to, const size_t maxPosition=std::string::npos);
}
}
#endif
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -65,7 +63,7 @@ namespace G4INCL {
IAvatar(G4double time);
virtual ~IAvatar();
virtual G4INCL::IChannel* getChannel() const = 0;
virtual G4INCL::IChannel* getChannel() = 0;
G4INCL::FinalState *getFinalState();
virtual void preInteraction() = 0;
virtual FinalState *postInteraction(FinalState *) = 0;
@@ -86,13 +84,14 @@ namespace G4INCL {
private:
long ID;
AvatarType type;
static long nextID;
static G4ThreadLocal long nextID;
protected:
G4double theTime;
};
typedef std::list<IAvatar*> IAvatarList;
typedef std::list<IAvatar*>::const_iterator IAvatarIter;
typedef UnorderedVector<IAvatar*> IAvatarList;
typedef UnorderedVector<IAvatar*>::const_iterator IAvatarIter;
typedef UnorderedVector<IAvatar*>::iterator IAvatarMutableIter;
}
#endif /* IAVATAR_HH_ */
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -46,19 +44,17 @@
#ifndef G4INCLIRANDOMGENERATOR_HH_
#define G4INCLIRANDOMGENERATOR_HH_
#include <vector>
#include "G4INCLRandomSeedVector.hh"
namespace G4INCL {
typedef std::vector<long> SeedVector;
class IRandomGenerator {
public:
IRandomGenerator() {}
virtual ~IRandomGenerator() {}
virtual SeedVector getSeeds() const = 0;
virtual void setSeeds(const SeedVector &) = 0;
virtual Random::SeedVector getSeeds() = 0;
virtual void setSeeds(const Random::SeedVector &) = 0;
virtual G4double flat() = 0;
};
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -50,6 +48,7 @@
#include <utility>
namespace G4INCL {
/** \brief Intersection-point structure
*
* The structure contains the time and position of the intersection point
@@ -63,33 +62,80 @@ namespace G4INCL {
ThreeVector position;
};
class IntersectionFactory {
public:
/** \brief Compute the first intersection of a straight particle
* trajectory with a sphere.
*
* \param x0 the starting position of the trajectory
* \param p the trajectory direction
* \param r the radius of the sphere (centred in the origin)
* \return an Intersection. The G4bool is true if an intersection exists,
* in which case its position is stored in the ThreeVector and
* its time in the G4double.
*/
static inline Intersection getEarlierTrajectoryIntersection(const ThreeVector &x0, const ThreeVector &p, const G4double r) {
return getTrajectoryIntersection(x0, p, r, true);
namespace IntersectionFactory {
/** \brief Compute the first intersection of a straight particle
* trajectory with a sphere.
*
* \param x0 the starting position of the trajectory
* \param p the trajectory direction
* \param r the radius of the sphere (centred in the origin)
* \return an Intersection. The G4bool is true if an intersection exists,
* in which case its position is stored in the ThreeVector and
* its time in the G4double.
*/
Intersection getEarlierTrajectoryIntersection(const ThreeVector &x0, const ThreeVector &p, const G4double r);
/** \brief Compute the second intersection of a straight particle
* trajectory with a sphere.
*
* \param x0 the starting position of the trajectory
* \param p the trajectory direction
* \param r the radius of the sphere (centred in the origin)
* \return an Intersection. The G4bool is true if an intersection exists,
* in which case its position is stored in the ThreeVector and
* its time in the G4double.
*/
Intersection getLaterTrajectoryIntersection(const ThreeVector &x0, const ThreeVector &p, const G4double r);
/** \brief Compute both intersections of a straight particle
* trajectory with a sphere.
*
* \param x0 the starting position of the trajectory
* \param p the trajectory direction
* \param r the radius of the sphere (centred in the origin)
* \return an Intersection. The G4bool is true if an intersection exists,
* in which case its position is stored in the ThreeVector and
* its time in the G4double.
*/
std::pair<Intersection,Intersection> getTrajectoryIntersections(const ThreeVector &x0, const ThreeVector &p, const G4double r);
namespace {
Intersection getTrajectoryIntersection(const ThreeVector &x0, const ThreeVector &v, const G4double r, const G4bool earliest) {
const G4double scalarVelocity = v.mag();
ThreeVector velocityUnitVector = v / scalarVelocity;
ThreeVector positionTransverse = x0 - velocityUnitVector * x0.dot(velocityUnitVector);
const G4double impactParameter = positionTransverse.mag();
const G4double r2 = r*r;
G4double distanceZ2 = r2 - impactParameter * impactParameter;
if(distanceZ2 < 0.0)
return Intersection(false, 0.0, ThreeVector());
const G4double distanceZ = std::sqrt(distanceZ2);
const ThreeVector position = positionTransverse + velocityUnitVector * (earliest ? -distanceZ : distanceZ);
const G4double time = (position-x0).dot(velocityUnitVector)/scalarVelocity;
return Intersection(true, time, position);
}
static inline Intersection getLaterTrajectoryIntersection(const ThreeVector &x0, const ThreeVector &p, const G4double r) {
return getTrajectoryIntersection(x0, p, r, false);
}
static inline std::pair<Intersection,Intersection> getTrajectoryIntersections(const ThreeVector &x0, const ThreeVector &p, const G4double r) {
return std::make_pair(
getTrajectoryIntersection(x0, p, r, true),
getTrajectoryIntersection(x0, p, r, false)
);
}
private:
static Intersection getTrajectoryIntersection(const ThreeVector &x0, const ThreeVector &p, const G4double r, const G4bool earliest);
};
}
inline Intersection getEarlierTrajectoryIntersection(const ThreeVector &x0, const ThreeVector &p, const G4double r) {
return getTrajectoryIntersection(x0, p, r, true);
}
inline Intersection getLaterTrajectoryIntersection(const ThreeVector &x0, const ThreeVector &p, const G4double r) {
return getTrajectoryIntersection(x0, p, r, false);
}
inline std::pair<Intersection,Intersection> getTrajectoryIntersections(const ThreeVector &x0, const ThreeVector &p, const G4double r) {
return std::make_pair(
getTrajectoryIntersection(x0, p, r, true),
getTrajectoryIntersection(x0, p, r, false)
);
}
}
}
#endif /* G4INCLINTERSECTION_HH */
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -83,11 +81,6 @@ namespace G4INCL {
return (x >= rhs.x);
}
/// \brief Overloaded comparison operator for STL algorithms
friend G4bool operator<(const InterpolationNode &lhs, const G4double rhs) {
return lhs.x < rhs;
}
G4double getX() const { return x; }
G4double getY() const { return y; }
G4double getYPrime() const { return yPrime; }
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -45,6 +43,10 @@
#include <string>
#include <cstdlib>
#ifdef INCLXX_IN_GEANT4_MODE
#include "G4ios.hh"
#endif
namespace G4INCL {
/**
@@ -58,18 +60,14 @@ namespace G4INCL {
DataBlockMsg = 10,
ZeroMsg = 0 };
#ifdef INCL_DEBUG_LOG
#if defined(INCL_DEBUG_LOG) && !defined(INCLXX_IN_GEANT4_MODE)
class LoggerSlave {
public:
// By default, log fatal errors, errors and warnings
LoggerSlave(std::string const &logFileName) : logStream(0), verbosityLevel(4) {
if(logFileName=="-") {
#ifdef INCLXX_IN_GEANT4_MODE
logStream = &(G4cout);
#else
logStream = &(std::cout);
#endif
logToStdout = true;
} else {
logToStdout = false;
@@ -84,9 +82,7 @@ namespace G4INCL {
// Spell out "true" and "false" when logging G4bool variables
std::boolalpha(*logStream);
#ifndef INCLXX_IN_GEANT4_MODE
logMessage(InfoMsg, __FILE__,__LINE__, "# Logging enabled!\n");
#endif
};
~LoggerSlave() {
if(!logToStdout)
@@ -133,108 +129,107 @@ namespace G4INCL {
G4bool logToStdout;
};
class Logger {
public:
namespace Logger {
/// \brief Log a message.
static void logMessage(const MessageType type, std::string const &fileName, const G4int lineNumber, std::string const &s) {
theLoggerSlave->logMessage(type, fileName, lineNumber, s);
}
void logMessage(const MessageType type, std::string const &fileName, const G4int lineNumber, std::string const &s);
/// \brief Flush the log stream
static void flush() { theLoggerSlave->flush(); }
void flush();
/// \brief Log a data block.
static void dataBlock(const std::string &block, const std::string &fileName, const G4int lineNumber) {
theLoggerSlave->logDataBlock(block, fileName, lineNumber);
}
void dataBlock(const std::string &block, const std::string &fileName, const G4int lineNumber);
/// \brief Set the slave Logger.
static void setLoggerSlave(LoggerSlave * const logger) { theLoggerSlave = logger; }
void setLoggerSlave(LoggerSlave * const logger);
/// \brief Set the verbosity of the slave Logger.
static void setVerbosityLevel(G4int lvl) { theLoggerSlave->setVerbosityLevel(lvl); }
void setVerbosityLevel(G4int lvl);
/// \brief Get the verbosity of the slave Logger.
static G4int getVerbosityLevel() { return theLoggerSlave->getVerbosityLevel(); }
G4int getVerbosityLevel();
/// \brief Delete the slave Logger.
static void deleteLoggerSlave() {
delete theLoggerSlave;
theLoggerSlave=NULL;
}
void deleteLoggerSlave();
private:
static LoggerSlave *theLoggerSlave;
};
}
// Macro definitions for line numbering in log files!
#define FATAL(x) \
if(G4INCL::FatalMsg <= G4INCL::Logger::getVerbosityLevel()) {\
std::stringstream ss;\
ss << x;\
G4INCL::Logger::logMessage(G4INCL::FatalMsg, __FILE__,__LINE__, ss.str());\
#define INCL_FATAL(x) \
if(true) {\
std::stringstream ss_;\
ss_ << x;\
G4INCL::Logger::logMessage(G4INCL::FatalMsg, __FILE__,__LINE__, ss_.str());\
G4INCL::Logger::flush();\
std::exit(EXIT_FAILURE);\
} else (void)0
#define ERROR(x) \
#define INCL_ERROR(x) \
if(G4INCL::ErrorMsg <= G4INCL::Logger::getVerbosityLevel()) {\
std::stringstream ss;\
ss << x;\
G4INCL::Logger::logMessage(G4INCL::ErrorMsg, __FILE__,__LINE__, ss.str());\
std::stringstream ss_;\
ss_ << x;\
G4INCL::Logger::logMessage(G4INCL::ErrorMsg, __FILE__,__LINE__, ss_.str());\
} else (void)0
#define WARN(x) \
#define INCL_WARN(x) \
if(G4INCL::WarningMsg <= G4INCL::Logger::getVerbosityLevel()) {\
std::stringstream ss;\
ss << x;\
G4INCL::Logger::logMessage(G4INCL::WarningMsg, __FILE__,__LINE__, ss.str());\
std::stringstream ss_;\
ss_ << x;\
G4INCL::Logger::logMessage(G4INCL::WarningMsg, __FILE__,__LINE__, ss_.str());\
} else (void)0
#define INFO(x) \
#define INCL_INFO(x) \
if(G4INCL::InfoMsg <= G4INCL::Logger::getVerbosityLevel()) {\
std::stringstream ss;\
ss << x;\
G4INCL::Logger::logMessage(G4INCL::InfoMsg, __FILE__,__LINE__, ss.str());\
std::stringstream ss_;\
ss_ << x;\
G4INCL::Logger::logMessage(G4INCL::InfoMsg, __FILE__,__LINE__, ss_.str());\
} else (void)0
#define DEBUG(x) \
#define INCL_DEBUG(x) \
if(G4INCL::DebugMsg <= G4INCL::Logger::getVerbosityLevel()) {\
std::stringstream ss;\
ss << x;\
G4INCL::Logger::logMessage(G4INCL::DebugMsg, __FILE__,__LINE__, ss.str());\
std::stringstream ss_;\
ss_ << x;\
G4INCL::Logger::logMessage(G4INCL::DebugMsg, __FILE__,__LINE__, ss_.str());\
} else (void)0
#define DATABLOCK(x) \
#define INCL_DATABLOCK(x) \
if(G4INCL::DataBlockMsg <= G4INCL::Logger::getVerbosityLevel()) {\
G4INCL::Logger::dataBlock(x,__FILE__,__LINE__);\
} else (void)0
#else
// Empty logger for normal (production) use:
class LoggerSlave {
public:
LoggerSlave(std::string const &) {};
LoggerSlave() {};
~LoggerSlave() {};
void setVerbosityLevel(G4int) {};
};
#else // defined(INCL_DEBUG_LOG) && !defined(INCLXX_IN_GEANT4_MODE)
namespace Logger {
void initVerbosityLevelFromEnvvar();
G4int getVerbosityLevel();
}
class Logger {
public:
Logger() {};
~Logger() {};
static void setVerbosityLevel(G4int) {};
static void setLoggerSlave(LoggerSlave * const slave) { theLoggerSlave = slave; }
static void deleteLoggerSlave() {
delete theLoggerSlave;
theLoggerSlave=NULL;
}
private:
static LoggerSlave *theLoggerSlave;
};
#define INCL_FATAL(x) \
if(true) {\
std::stringstream ss_;\
ss_ << x;\
std::stringstream location_;\
std::string fileName_(__FILE__);\
location_ << fileName_.substr(fileName_.find_last_of("/")+1) << ":" << __LINE__;\
G4Exception(location_.str().c_str(), "INCLXX0000", FatalException, ss_.str().c_str());\
} else (void)0
#define INCL_ERROR(x) \
if(G4INCL::ErrorMsg <= G4INCL::Logger::getVerbosityLevel()) {\
std::string fileName_(__FILE__);\
std::stringstream ss_;\
ss_ << "INCL++ error [" << fileName_.substr(fileName_.find_last_of("/")+1) << ":" << __LINE__ << "] " << x;\
G4cout << ss_.str() << std::endl;\
} else (void)0
#define INCL_WARN(x) \
if(G4INCL::WarningMsg <= G4INCL::Logger::getVerbosityLevel()) {\
std::string fileName_(__FILE__);\
std::stringstream ss_;\
ss_ << "INCL++ warning [" << fileName_.substr(fileName_.find_last_of("/")+1) << ":" << __LINE__ << "] " << x;\
G4cout << ss_.str() << std::endl;\
} else (void)0
#define INCL_INFO(x);
#define INCL_DEBUG(x) \
if(G4INCL::DebugMsg <= G4INCL::Logger::getVerbosityLevel()) {\
std::string fileName_(__FILE__);\
std::stringstream ss_;\
ss_ << "INCL++ debug [" << fileName_.substr(fileName_.find_last_of("/")+1) << ":" << __LINE__ << "] " << x;\
G4cout << ss_.str() << std::endl;\
} else (void)0
#define INCL_DATABLOCK(x);
#define FATAL(x);
#define ERROR(x);
#define WARN(x);
#define INFO(x);
#define DEBUG(x);
#define DATABLOCK(x);
#endif
#endif // defined(INCL_DEBUG_LOG) && !defined(INCLXX_IN_GEANT4_MODE)
}
#endif
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -30,27 +30,35 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
#ifndef G4INCLDeExcitation_hh
#define G4INCLDeExcitation_hh 1
/** \file G4INCLNuclearMassTable.hh
* \brief Functions that encapsulate a mass table
*
* \date 22nd October 2013
* \author Davide Mancusi
*/
#include "G4INCLEventInfo.hh"
#include "G4INCLConfig.hh"
#ifndef G4INCLNuclearMassTable_HH
#define G4INCLNuclearMassTable_HH
#ifndef INCLXX_IN_GEANT4_MODE
#include <map>
#include <string>
namespace G4INCL {
class IDeExcitation {
public:
IDeExcitation() {};
IDeExcitation(G4INCL::Config*) {};
virtual ~IDeExcitation() {};
virtual void deExcite(G4INCL::EventInfo*) = 0;
};
namespace NuclearMassTable {
void initialize(const std::string &path, const G4double pMass, const G4double nMass);
G4double getMass(const G4int A, const G4int Z);
void deleteTable();
}
}
#endif
#endif // INCLXX_IN_GEANT4_MODE
#endif // G4INCLNuclearMassTable_HH
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -51,7 +49,7 @@
#include "G4INCLParticleType.hh"
#include "G4INCLParticleSpecies.hh"
#include "G4INCLLogger.hh"
#include <list>
#include <vector>
#include <sstream>
#include <string>
#include <algorithm>
@@ -60,14 +58,44 @@ namespace G4INCL {
class Particle;
typedef std::list<G4INCL::Particle*> ParticleList;
typedef std::list<G4INCL::Particle*>::const_iterator ParticleIter;
template<class T>
class UnorderedVector : private std::vector<T> {
public:
UnorderedVector() {}
using std::vector<T>::push_back;
using std::vector<T>::pop_back;
using std::vector<T>::size;
using std::vector<T>::begin;
using std::vector<T>::end;
using std::vector<T>::rbegin;
using std::vector<T>::rend;
using std::vector<T>::front;
using std::vector<T>::back;
using std::vector<T>::clear;
using std::vector<T>::empty;
using std::vector<T>::insert;
using std::vector<T>::erase;
using typename std::vector<T>::iterator;
using typename std::vector<T>::reverse_iterator;
using typename std::vector<T>::const_iterator;
using typename std::vector<T>::const_reverse_iterator;
void remove(const T &t) {
const typename std::vector<T>::iterator removeMe = std::find(begin(), end(), t);
// assert(removeMe!=end());
*removeMe = back();
pop_back();
}
};
typedef UnorderedVector<Particle*> ParticleList;
typedef ParticleList::const_iterator ParticleIter;
typedef ParticleList::iterator ParticleMutableIter;
class Particle {
public:
Particle();
Particle(ParticleType t, G4double energy, ThreeVector momentum, ThreeVector position);
Particle(ParticleType t, ThreeVector momentum, ThreeVector position);
Particle(ParticleType t, G4double energy, ThreeVector const &momentum, ThreeVector const &position);
Particle(ParticleType t, ThreeVector const &momentum, ThreeVector const &position);
virtual ~Particle() {}
/** \brief Copy constructor
@@ -87,6 +115,8 @@ namespace G4INCL {
nCollisions(rhs.nCollisions),
nDecays(rhs.nDecays),
thePotentialEnergy(rhs.thePotentialEnergy),
rpCorrelated(rhs.rpCorrelated),
uncorrelatedMomentum(rhs.uncorrelatedMomentum),
theHelicity(rhs.theHelicity),
emissionTime(rhs.emissionTime),
outOfWell(rhs.outOfWell),
@@ -134,6 +164,8 @@ namespace G4INCL {
std::swap(outOfWell, rhs.outOfWell);
std::swap(theMass, rhs.theMass);
std::swap(rpCorrelated, rhs.rpCorrelated);
std::swap(uncorrelatedMomentum, rhs.uncorrelatedMomentum);
}
public:
@@ -196,14 +228,14 @@ namespace G4INCL {
theZ = -1;
break;
case Composite:
// ERROR("Trying to set particle type to Composite! Construct a Cluster object instead" << std::endl);
// INCL_ERROR("Trying to set particle type to Composite! Construct a Cluster object instead" << std::endl);
theA = 0;
theZ = 0;
break;
case UnknownParticle:
theA = 0;
theZ = 0;
ERROR("Trying to set particle type to Unknown!" << std::endl);
INCL_ERROR("Trying to set particle type to Unknown!" << std::endl);
break;
}
@@ -346,7 +378,7 @@ namespace G4INCL {
break;
default:
ERROR("Particle::getINCLMass: Unknown particle type." << std::endl);
INCL_ERROR("Particle::getINCLMass: Unknown particle type." << std::endl);
return 0.0;
break;
}
@@ -375,7 +407,7 @@ namespace G4INCL {
break;
default:
ERROR("Particle::getTableMass: Unknown particle type." << std::endl);
INCL_ERROR("Particle::getTableMass: Unknown particle type." << std::endl);
return 0.0;
break;
}
@@ -404,7 +436,7 @@ namespace G4INCL {
break;
default:
ERROR("Particle::getRealMass: Unknown particle type." << std::endl);
INCL_ERROR("Particle::getRealMass: Unknown particle type." << std::endl);
return 0.0;
break;
}
@@ -496,7 +528,7 @@ namespace G4INCL {
G4double getInvariantMass() const {
const G4double mass = std::pow(theEnergy, 2) - theMomentum.dot(theMomentum);
if(mass < 0.0) {
ERROR("E*E - p*p is negative." << std::endl);
INCL_ERROR("E*E - p*p is negative." << std::endl);
return 0.0;
} else {
return std::sqrt(mass);
@@ -719,10 +751,41 @@ namespace G4INCL {
* Return a NULL pointer
*/
ParticleList const *getParticles() const {
WARN("Particle::getParticles() method was called on a Particle object" << std::endl);
INCL_WARN("Particle::getParticles() method was called on a Particle object" << std::endl);
return 0;
}
/** \brief Return the reflection momentum
*
* The reflection momentum is used by calls to getSurfaceRadius to compute
* the radius of the sphere where the nucleon moves. It is necessary to
* introduce fuzzy r-p correlations.
*/
G4double getReflectionMomentum() const {
if(rpCorrelated)
return theMomentum.mag();
else
return uncorrelatedMomentum;
}
/// \brief Set the uncorrelated momentum
void setUncorrelatedMomentum(const G4double p) { uncorrelatedMomentum = p; }
/// \brief Make the particle follow a strict r-p correlation
void rpCorrelate() { rpCorrelated = true; }
/// \brief Make the particle not follow a strict r-p correlation
void rpDecorrelate() { rpCorrelated = false; }
/// \brief Get the cosine of the angle between position and momentum
G4double getCosRPAngle() const {
const G4double norm = thePosition.mag2()*thePropagationMomentum->mag2();
if(norm>0.)
return thePosition.dot(*thePropagationMomentum) / std::sqrt(norm);
else
return 1.;
}
protected:
G4int theZ, theA;
ParticipantType theParticipantType;
@@ -739,13 +802,16 @@ namespace G4INCL {
G4double thePotentialEnergy;
long ID;
G4bool rpCorrelated;
G4double uncorrelatedMomentum;
private:
G4double theHelicity;
G4double emissionTime;
G4bool outOfWell;
G4double theMass;
static long nextID;
static G4ThreadLocal long nextID;
};
}
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -51,51 +49,59 @@
#ifdef INCLXX_IN_GEANT4_MODE
#include "G4IonTable.hh"
#include "G4ParticleTable.hh"
#include "globals.hh"
#endif
#include "G4INCLGlobals.hh"
#include "G4INCLNaturalIsotopicDistributions.hh"
namespace G4INCL {
class ParticleTable {
public:
namespace ParticleTable {
const G4int maxClusterMass = 12;
const G4int maxClusterCharge = 8;
const G4int clusterTableZSize = maxClusterCharge+1;
const G4int clusterTableASize = maxClusterMass+1;
const G4double effectiveNucleonMass = 938.2796;
const G4double effectiveNucleonMass2 = 8.8036860777616e5;
const G4double effectiveDeltaMass = 1232.0;
const G4double effectivePionMass = 138.0;
extern G4ThreadLocal G4double effectiveDeltaDecayThreshold;
/// \brief Initialize the particle table
static void initialize(Config const * const theConfig = 0);
void initialize(Config const * const theConfig = 0);
/// Get the isospin of a particle
static G4int getIsospin(const ParticleType t);
/// \brief Get the isospin of a particle
G4int getIsospin(const ParticleType t);
/// Get the native INCL name of the particle
static std::string getName(const ParticleType t);
/// \brief Get the native INCL name of the particle
std::string getName(const ParticleType t);
/// Get the short INCL name of the particle
static std::string getShortName(const ParticleType t);
/// \brief Get the short INCL name of the particle
std::string getShortName(const ParticleType t);
/// Get the native INCL name of the particle
static std::string getName(const ParticleSpecies s);
/// \brief Get the native INCL name of the particle
std::string getName(const ParticleSpecies &s);
/// Get the short INCL name of the particle
static std::string getShortName(const ParticleSpecies s);
/// \brief Get the short INCL name of the particle
std::string getShortName(const ParticleSpecies &s);
/// Get the native INCL name of the ion
static std::string getName(const G4int A, const G4int Z);
/// \brief Get the native INCL name of the ion
std::string getName(const G4int A, const G4int Z);
/// Get the short INCL name of the ion
static std::string getShortName(const G4int A, const G4int Z);
/// \brief Get the short INCL name of the ion
std::string getShortName(const G4int A, const G4int Z);
///\brief Get INCL nuclear mass (in MeV/c^2)
static G4double getINCLMass(const G4int A, const G4int Z);
/// \brief Get INCL nuclear mass (in MeV/c^2)
G4double getINCLMass(const G4int A, const G4int Z);
///\brief Get INCL particle mass (in MeV/c^2)
static G4double getINCLMass(const ParticleType t);
/// \brief Get INCL particle mass (in MeV/c^2)
G4double getINCLMass(const ParticleType t);
#ifndef INCLXX_IN_GEANT4_MODE
///\brief Do we have this particle mass?
static G4double hasMassTable(const unsigned int A, const unsigned int Z) {
return ( Z > 0 && A > 0
&& Z < massTableMask.size() && A < massTableMask.at(Z).size()
&& massTableMask.at(Z).at(A));
}
/// \brief Do we have this particle mass?
G4double hasMassTable(const unsigned int A, const unsigned int Z);
/** \brief Weizsaecker mass formula
*
@@ -106,26 +112,13 @@ namespace G4INCL {
* \param Z the charge number
* \return the nuclear mass [MeV/c^2]
*/
static G4double getWeizsaeckerMass(const G4int A, const G4int Z) {
const G4int Npairing = (A-Z)%2; // pairing
const G4int Zpairing = Z%2;
const G4double fA = (G4double) A;
const G4double fZ = (G4double) Z;
G4double binding =
- 15.67*fA // nuclear volume
+ 17.23*Math::pow23(fA) // surface energy
+ 93.15*((fA/2.-fZ)*(fA/2.-fZ))/fA // asymmetry
+ 0.6984523*fZ*fZ*Math::powMinus13(fA); // coulomb
if( Npairing == Zpairing ) binding += (Npairing+Zpairing-1) * 12.0 / std::sqrt(fA); // pairing
return fZ*getRealMass(Proton)+((G4double)(A-Z))*getRealMass(Neutron)+binding;
}
G4double getWeizsaeckerMass(const G4int A, const G4int Z);
#endif
///\brief Get particle mass (in MeV/c^2)
static G4double getRealMass(const G4INCL::ParticleType t);
G4double getRealMass(const G4INCL::ParticleType t);
///\brief Get nuclear mass (in MeV/c^2)
static G4double getRealMass(const G4int A, const G4int Z);
G4double getRealMass(const G4int A, const G4int Z);
/**\brief Get Q-value (in MeV/c^2)
*
@@ -133,9 +126,7 @@ namespace G4INCL {
* following reaction:
* \f[ (A_1,Z_1) + (A_2, Z_2) --> (A_1+A_2,Z_1+Z_2) \f]
*/
static G4double getTableQValue(const G4int A1, const G4int Z1, const G4int A2, const G4int Z2) {
return getTableMass(A1,Z1) + getTableMass(A2,Z2) - getTableMass(A1+A2,Z1+Z2);
}
G4double getTableQValue(const G4int A1, const G4int Z1, const G4int A2, const G4int Z2);
/**\brief Get Q-value (in MeV/c^2)
*
@@ -143,143 +134,54 @@ namespace G4INCL {
* following reaction:
* \f[ (A_1,Z_1) + (A_2, Z_2) --> (A_3,Z_3) + (A1+A2-A3,Z1+Z2-Z3) \f]
*/
static G4double getTableQValue(const G4int A1, const G4int Z1, const G4int A2, const G4int Z2, const G4int A3, const G4int Z3) {
return getTableMass(A1,Z1) + getTableMass(A2,Z2) - getTableMass(A3,Z3) - getTableMass(A1+A2-A3,Z1+Z2-Z3);
}
G4double getTableQValue(const G4int A1, const G4int Z1, const G4int A2, const G4int Z2, const G4int A3, const G4int Z3);
// Typedefs and pointers for transparent handling of mass functions
typedef G4double (*NuclearMassFn)(const G4int, const G4int);
typedef G4double (*ParticleMassFn)(const ParticleType);
static NuclearMassFn getTableMass;
static ParticleMassFn getTableParticleMass;
static G4double getTableSpeciesMass(const ParticleSpecies &p) {
if(p.theType == Composite)
return (*getTableMass)(p.theA, p.theZ);
else
return (*getTableParticleMass)(p.theType);
}
// Typedefs and pointers for transparent handling of separation energies
typedef G4double (*SeparationEnergyFn)(const ParticleType, const G4int, const G4int);
static SeparationEnergyFn getSeparationEnergy;
G4double getTableSpeciesMass(const ParticleSpecies &p);
/// \brief Get mass number from particle type
static G4int getMassNumber(const ParticleType t) {
switch(t) {
case Proton:
case Neutron:
case DeltaPlusPlus:
case DeltaPlus:
case DeltaZero:
case DeltaMinus:
return 1;
break;
case PiPlus:
case PiMinus:
case PiZero:
return 0;
break;
default:
/* FATAL("Can't determine mass number for particle type " << t << std::endl);
std::abort();*/
return 0;
break;
}
}
G4int getMassNumber(const ParticleType t);
/// \brief Get charge number from particle type
static G4int getChargeNumber(const ParticleType t) {
switch(t) {
case DeltaPlusPlus:
return 2;
break;
case Proton:
case DeltaPlus:
case PiPlus:
return 1;
break;
case Neutron:
case DeltaZero:
case PiZero:
return 0;
break;
case DeltaMinus:
case PiMinus:
return -1;
break;
default:
/* FATAL("Can't determine charge number for particle type " << t << std::endl);
std::abort();*/
return 0;
break;
}
}
G4int getChargeNumber(const ParticleType t);
static G4double getNuclearRadius(const G4int A, const G4int Z);
static G4double getRadiusParameter(const G4int A, const G4int Z);
static G4double getMaximumNuclearRadius(const G4int A, const G4int Z);
static G4double getSurfaceDiffuseness(const G4int A, const G4int Z);
G4double getNuclearRadius(const ParticleType t, const G4int A, const G4int Z);
G4double getLargestNuclearRadius(const G4int A, const G4int Z);
G4double getRadiusParameter(const ParticleType t, const G4int A, const G4int Z);
G4double getMaximumNuclearRadius(const ParticleType t, const G4int A, const G4int Z);
G4double getSurfaceDiffuseness(const ParticleType t, const G4int A, const G4int Z);
/// \brief Return the RMS of the momentum distribution (light clusters)
static G4double getMomentumRMS(const G4int A, const G4int Z) {
// assert(Z>=0 && A>=0 && Z<=A);
if(Z<clusterTableZSize && A<clusterTableASize)
return momentumRMS[Z][A];
else
return Math::sqrtThreeFifths * PhysicalConstants::Pf;
}
G4double getMomentumRMS(const G4int A, const G4int Z);
/// \brief Return INCL's default separation energy
static G4double getSeparationEnergyINCL(const ParticleType t, const G4int /*A*/, const G4int /*Z*/) {
if(t==Proton)
return theINCLProtonSeparationEnergy;
else if(t==Neutron)
return theINCLNeutronSeparationEnergy;
else {
ERROR("ParticleTable::getSeparationEnergyINCL : Unknown particle type." << std::endl);
return 0.0;
}
}
G4double getSeparationEnergyINCL(const ParticleType t, const G4int /*A*/, const G4int /*Z*/);
/// \brief Return the real separation energy
static G4double getSeparationEnergyReal(const ParticleType t, const G4int A, const G4int Z) {
// Real separation energies for all nuclei
if(t==Proton)
return (*getTableParticleMass)(Proton) + (*getTableMass)(A-1,Z-1) - (*getTableMass)(A,Z);
else if(t==Neutron)
return (*getTableParticleMass)(Neutron) + (*getTableMass)(A-1,Z) - (*getTableMass)(A,Z);
else {
ERROR("ParticleTable::getSeparationEnergyReal : Unknown particle type." << std::endl);
return 0.0;
}
}
G4double getSeparationEnergyReal(const ParticleType t, const G4int A, const G4int Z);
/// \brief Return the real separation energy only for light nuclei
static G4double getSeparationEnergyRealForLight(const ParticleType t, const G4int A, const G4int Z) {
// Real separation energies for light nuclei, fixed values for heavy nuclei
if(Z<clusterTableZSize && A<clusterTableASize)
return getSeparationEnergyReal(t, A, Z);
else
return getSeparationEnergyINCL(t, A, Z);
}
G4double getSeparationEnergyRealForLight(const ParticleType t, const G4int A, const G4int Z);
/// \brief Getter for protonSeparationEnergy
static G4double getProtonSeparationEnergy() { return protonSeparationEnergy; }
G4double getProtonSeparationEnergy();
/// \brief Getter for neutronSeparationEnergy
static G4double getNeutronSeparationEnergy() { return neutronSeparationEnergy; }
G4double getNeutronSeparationEnergy();
/// \brief Setter for protonSeparationEnergy
static void setProtonSeparationEnergy(const G4double s) { protonSeparationEnergy = s; }
void setProtonSeparationEnergy(const G4double s);
/// \brief Setter for protonSeparationEnergy
static void setNeutronSeparationEnergy(const G4double s) { neutronSeparationEnergy = s; }
void setNeutronSeparationEnergy(const G4double s);
/// \brief Get the name of the element from the atomic number
static std::string getElementName(const G4int Z);
std::string getElementName(const G4int Z);
/// \brief Get the name of an unnamed element from the IUPAC convention
static std::string getIUPACElementName(const G4int Z);
std::string getIUPACElementName(const G4int Z);
/// \brief Get the name of the element from the atomic number
G4int parseElement(std::string pS);
/** \brief Parse a IUPAC element name
*
@@ -288,114 +190,74 @@ namespace G4INCL {
* \param pS a normalised string (lowercase)
* \return the charge number of the nuclide, or zero on fail
*/
static G4int parseIUPACElement(std::string const &pS);
G4int parseIUPACElement(std::string const &pS);
const static G4int elementTableSize = 113; // up to Cn
IsotopicDistribution const &getNaturalIsotopicDistribution(const G4int Z);
const static G4double effectiveNucleonMass;
const static G4double effectiveNucleonMass2;
const static G4double effectiveDeltaMass;
const static G4double effectivePionMass;
const static G4double effectiveDeltaDecayThreshold;
G4int drawRandomNaturalIsotope(const G4int Z);
static const G4int maxClusterMass = 12;
static const G4int maxClusterCharge = 8;
// Typedefs and pointers for transparent handling of mass functions
typedef G4double (*NuclearMassFn)(const G4int, const G4int);
typedef G4double (*ParticleMassFn)(const ParticleType);
/// \brief Static pointer to the mass function for nuclei
extern G4ThreadLocal NuclearMassFn getTableMass;
/// \brief Static pointer to the mass function for particles
extern G4ThreadLocal ParticleMassFn getTableParticleMass;
const static G4int clusterTableZSize = ParticleTable::maxClusterCharge+1;
const static G4int clusterTableASize = ParticleTable::maxClusterMass+1;
const static G4double clusterPosFact[maxClusterMass+1];
const static G4double clusterPosFact2[maxClusterMass+1];
const static G4int clusterZMin[maxClusterMass+1]; // Lower limit of Z for cluster of mass A
const static G4int clusterZMax[maxClusterMass+1]; // Upper limit of Z for cluster of mass A
const static G4double clusterPhaseSpaceCut[maxClusterMass+1];
// Typedefs and pointers for transparent handling of separation energies
typedef G4double (*SeparationEnergyFn)(const ParticleType, const G4int, const G4int);
/// \brief Static pointer to the separation-energy function
extern G4ThreadLocal SeparationEnergyFn getSeparationEnergy;
#ifdef INCLXX_IN_GEANT4_MODE
static G4IonTable *theG4IonTable;
#else
static std::vector< std::vector <G4bool> > massTableMask;
static std::vector< std::vector <G4double> > massTable;
#endif
// Typedefs and pointers for transparent handling of Fermi momentum
typedef G4double (*FermiMomentumFn)(const G4int, const G4int);
extern G4ThreadLocal FermiMomentumFn getFermiMomentum;
// Enumerator for cluster-decay channels
enum ClusterDecayType {
StableCluster,
NeutronDecay,
ProtonDecay,
AlphaDecay,
TwoProtonDecay,
TwoNeutronDecay,
ProtonUnbound,
NeutronUnbound
};
const static ClusterDecayType clusterDecayMode[clusterTableZSize][clusterTableASize];
/** \brief Coulomb conversion factor, in MeV*fm.
/** \brief Return the constant value of the Fermi momentum
*
* \f[ e^2/(4 pi epsilon_0) \f]
* This function should always return PhysicalConstants::Pf.
*/
static const G4double eSquared;
G4double getFermiMomentumConstant(const G4int /*A*/, const G4int /*Z*/);
static IsotopicDistribution const &getNaturalIsotopicDistribution(const G4int Z) {
return getNaturalIsotopicDistributions()->getIsotopicDistribution(Z);
}
/** \brief Return the constant value of the Fermi momentum - special for light
*
* This function should always return PhysicalConstants::Pf for heavy
* nuclei, and values from the momentumRMS table for light nuclei.
*
* \param A mass number
* \param Z charge number
*/
G4double getFermiMomentumConstantLight(const G4int A, const G4int Z);
static G4int drawRandomNaturalIsotope(const G4int Z) {
return getNaturalIsotopicDistributions()->drawRandomIsotope(Z);
}
/** \brief Return the value Fermi momentum from a fit
*
* This function returns a fitted Fermi momentum, based on data from Moniz
* et al., Phys. Rev. Lett. 26 (1971) 445. The fitted functional form is
* \f[
* p_F(A)=\alpha-\beta\cdot e^{(-A\cdot\gamma)}
* \f]
* with \f$\alpha=259.416\f$ MeV/\f$c\f$, \f$\beta=152.824\f$ MeV/\f$c\f$
* and \f$\gamma=9.5157\cdot10^{-2}\f$.
*
* \param A mass number
*/
G4double getFermiMomentumMassDependent(const G4int A, const G4int /*Z*/);
protected:
ParticleTable() {};
~ParticleTable() {};
/** \brief Get the value of the r-p correlation coefficient
*
* \param t the type of the particle (Proton or Neutron)
* \return the value of the r-p correlation coefficient
*/
G4double getRPCorrelationCoefficient(const ParticleType t);
private:
static const G4double theINCLNucleonMass;
static const G4double theINCLPionMass;
static const G4double theINCLNeutronSeparationEnergy;
static const G4double theINCLProtonSeparationEnergy;
static G4double protonMass;
static G4double neutronMass;
static G4double neutronSeparationEnergy;
static G4double protonSeparationEnergy;
static G4double piPlusMass, piMinusMass, piZeroMass;
static G4double theRealProtonMass;
static G4double theRealNeutronMass;
static G4double theRealChargedPiMass;
static G4double theRealPiZeroMass;
/// \brief Get the value of the neutron skin thickness
G4double getNeutronSkinThickness();
const static G4int mediumNucleiTableSize = 30;
const static G4double mediumDiffuseness[mediumNucleiTableSize];
const static G4double mediumRadius[mediumNucleiTableSize];
const static G4double positionRMS[clusterTableZSize][clusterTableASize];
const static G4double momentumRMS[clusterTableZSize][clusterTableASize];
/// \brief Get the value of the additional neutron skin diffuseness
G4double getNeutronSkinAdditionalDiffuseness();
const static std::string elementTable[elementTableSize];
#ifndef INCLXX_IN_GEANT4_MODE
/// \brief Read nuclear masses from a data file
static void readRealMasses(std::string const &path);
#endif
const static std::string elementIUPACDigits;
/// \brief Transform a IUPAC char to an char representing an integer digit
static char iupacToInt(char c) {
return (char)(((G4int)'0')+elementIUPACDigits.find(c));
}
/// \brief Transform an integer digit (represented by a char) to a IUPAC char
static char intToIUPAC(char n) { return elementIUPACDigits.at(n); }
/// \brief Array of natural isotopic distributions
static const NaturalIsotopicDistributions *theNaturalIsotopicDistributions;
/// \brief Get the singleton instance of the natural isotopic distributions
static const NaturalIsotopicDistributions *getNaturalIsotopicDistributions() {
if(!theNaturalIsotopicDistributions)
theNaturalIsotopicDistributions = new NaturalIsotopicDistributions;
return theNaturalIsotopicDistributions;
}
};
}
}
#endif
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -49,7 +47,7 @@
namespace G4INCL {
enum ParticleType {
Proton,
Proton = 0,
Neutron,
PiPlus,
PiMinus,
@@ -59,6 +57,9 @@ namespace G4INCL {
DeltaZero,
DeltaMinus,
Composite,
// WARNING: if you add more particle types, you MUST add them BEFORE the
// UnknownParticle type! This is because UnknownParticle is used as a
// counter of the number of available particle types.
UnknownParticle
};
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -48,6 +46,7 @@
#include <iostream>
#include <cmath>
#include <utility>
#include "G4INCLIRandomGenerator.hh"
#include "G4INCLThreeVector.hh"
#include "G4INCLGlobals.hh"
@@ -55,113 +54,86 @@
namespace G4INCL {
class Random {
private:
Random() {}
virtual ~Random() {}
private:
static IRandomGenerator *theGenerator;
public:
namespace Random {
/**
* Set the random number generator implementation to be used globally by INCL.
*
* @see G4INCL::IRandomGenerator
*/
static void setGenerator(G4INCL::IRandomGenerator *aGenerator) {
if(isInitialized()) {
ERROR("INCL random number generator already initialized." << std::endl);
} else {
theGenerator = aGenerator;
}
};
void setGenerator(G4INCL::IRandomGenerator *aGenerator);
/**
* Set the seeds of the current generator.
*
*/
static void setSeeds(const SeedVector &sv) {
theGenerator->setSeeds(sv);
};
void setSeeds(const SeedVector &sv);
/**
* Get the seeds of the current generator.
*
*/
static SeedVector getSeeds() {
return theGenerator->getSeeds();
};
SeedVector getSeeds();
/**
* Generate flat distribution of random numbers.
*/
static G4double shoot() {return theGenerator->flat(); };
G4double shoot();
/**
* Return a random number in the ]0,1] interval
*/
static G4double shoot0() {
G4double r;
while( (r=shoot()) <= 0. )
;
return r;
}
G4double shoot0();
/**
* Return a random number in the [0,1[ interval
*/
static G4double shoot1() {
G4double r;
while( (r=shoot()) >= 1. )
;
return r;
}
G4double shoot1();
/**
* Return a random integer in the [0,n[ interval
*/
template<typename T> T shootInteger(T n);
/**
* Generate random numbers using gaussian distribution.
*/
static G4double gauss(G4double sigma=1.);
G4double gauss(G4double sigma=1.);
/**
* Generate isotropically-distributed ThreeVectors of given norm.
*/
static ThreeVector normVector(G4double norm=1.);
ThreeVector normVector(G4double norm=1.);
/**
* Generate ThreeVectors that are uniformly distributed in a sphere of
* radius rmax.
*/
static ThreeVector sphereVector(G4double rmax=1.) {
return normVector( rmax*Math::pow13(shoot0()) );
}
ThreeVector sphereVector(G4double rmax=1.);
/** \brief Generate Gaussianly-distributed ThreeVectors
*
* Generate ThreeVectors that are distributed as a three-dimensional
* Gaussian of the given sigma.
*/
static ThreeVector gaussVector(G4double sigma=1.) {
const G4double sigmax = sigma * Math::oneOverSqrtThree;
return ThreeVector(gauss(sigmax), gauss(sigmax), gauss(sigmax));
}
ThreeVector gaussVector(G4double sigma=1.);
/// \brief Generate pairs of correlated Gaussian random numbers
std::pair<G4double,G4double> correlatedGaussian(const G4double corrCoeff, const G4double x0=0., const G4double sigma=1.);
/// \brief Generate pairs of correlated uniform random numbers
std::pair<G4double,G4double> correlatedUniform(const G4double corrCoeff);
/**
* Delete the generator
*/
static void deleteGenerator() {
delete theGenerator;
theGenerator = 0;
}
void deleteGenerator();
/**
* Check if the generator is initialized.
*/
static G4bool isInitialized() {
if(theGenerator == 0) return false;
return true;
};
};
G4bool isInitialized();
}
}
@@ -30,40 +30,43 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
/** \file G4INCLIntersection.cc
* \brief Simple class for computing intersections between a straight line and a sphere.
/*
* \file G4INCLRandomSeedVector.hh
*
* \date 12 December 2011
* \date 17 May 2013
* \author Davide Mancusi
*/
#include "G4INCLIntersection.hh"
#ifndef G4INCLRANDOMSEEDVECTOR_HH_
#define G4INCLRANDOMSEEDVECTOR_HH_
#include <vector>
#include <ostream>
namespace G4INCL {
Intersection IntersectionFactory::getTrajectoryIntersection(const ThreeVector &x0, const ThreeVector &v, const G4double r, const G4bool earliest) {
const G4double scalarVelocity = v.mag();
ThreeVector velocityUnitVector = v / scalarVelocity;
namespace Random {
ThreeVector positionTransverse = x0 - velocityUnitVector * x0.dot(velocityUnitVector);
const G4double impactParameter = positionTransverse.mag();
class SeedVector {
public:
long at(const size_t i) const;
long &operator[](const size_t i);
size_t size() const;
void resize(const size_t n);
void push_back(const long val);
const G4double r2 = r*r;
G4double distanceZ2 = r2 - impactParameter * impactParameter;
if(distanceZ2 < 0.0)
return Intersection(false, 0.0, ThreeVector());
friend std::ostream &operator<<(std::ostream &out, SeedVector const &sv);
private:
std::vector<long> theSeeds;
};
const G4double distanceZ = std::sqrt(distanceZ2);
const ThreeVector position = positionTransverse + velocityUnitVector * (earliest ? -distanceZ : distanceZ);
const G4double time = (position-x0).dot(velocityUnitVector)/scalarVelocity;
return Intersection(true, time, position);
}
}
#endif /* G4INCLIRANDOMSEEDVECTOR_HH_ */
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -47,26 +45,28 @@
#define G4INCLRANECU_HH_
#include "G4INCLIRandomGenerator.hh"
// #include <cassert>
namespace G4INCL {
class Ranecu: public G4INCL::IRandomGenerator {
public:
Ranecu();
Ranecu(const SeedVector &sv);
Ranecu(const Random::SeedVector &sv);
virtual ~Ranecu();
SeedVector getSeeds() const {
SeedVector sv;
Random::SeedVector getSeeds() {
Random::SeedVector sv;
sv.push_back(iseed1);
sv.push_back(iseed2);
return sv;
};
}
void setSeeds(const SeedVector &sv) {
iseed1 = sv[0];
iseed2 = sv[1];
};
void setSeeds(const Random::SeedVector &sv) {
// assert(sv.size()>=2);
iseed1 = sv.at(0);
iseed2 = sv.at(1);
}
G4double flat();
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -63,8 +61,27 @@ namespace G4INCL {
{};
};
class RootFinder {
public:
namespace RootFinder {
class Solution {
public:
Solution() :
success(false),
x(0.),
y(0.)
{}
Solution( const G4double x0, const G4double y0) :
success(true),
x(x0),
y(y0)
{}
~Solution() {}
G4bool success;
G4double x;
G4double y;
};
/** \brief Numerically solve a one-dimensional equation.
*
* Numerically solves the equation f(x)==0. This implementation uses the
@@ -74,42 +91,10 @@ namespace G4INCL {
*
* \param f pointer to a RootFunctor
* \param x0 initial value of the function argument
* \return true if a root was found
* \return a Solution object describing the root, if it was found
*/
static G4bool solve(RootFunctor const * const f, const G4double x0);
Solution solve(RootFunctor const * const f, const G4double x0);
/** \brief Get the solution of the last call to solve().
*
* \return the solution, as an (x,y) pair
*/
static std::pair<G4double,G4double> const &getSolution() { return RootFinder::solution; }
private:
/// \brief The solution obtained in the last call to solve().
static std::pair<G4double,G4double> solution;
/** \brief Bracket the root of the function f.
*
* Tries to find a bracketing value for the function root.
*
* \param f pointer to a RootFunctor
* \param x0 starting value
* \return if the root could be bracketed, returns two values of x
* bracketing the root, as a pair. If the bracketing failed, returns a
* pair with first > second.
*/
static std::pair<G4double,G4double> bracketRoot(RootFunctor const * const f, const G4double x0);
/// \brief Maximum number of iterations for convergence
static const G4int maxIterations=50;
/// \brief Tolerance on the y value
static const G4double toleranceY;
protected:
RootFinder() {};
~RootFinder() {};
};
}
}
#endif /* G4INCLROOTFINDER_HH_ */
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -137,17 +135,16 @@ namespace G4INCL {
}
template<typename T>
inline void operator*= (const T c) {
inline void operator*= (const T &c) {
x *= c;
y *= c;
z *= c;
}
template<typename T>
inline void operator/= (const T c) {
x /= c;
y /= c;
z /= c;
inline void operator/= (const T &c) {
const G4double oneOverC = 1./c;
this->operator*=(oneOverC);
}
inline ThreeVector operator- (const ThreeVector &v) const {
@@ -162,7 +159,8 @@ namespace G4INCL {
* Divides all components of the vector with a constant number.
*/
inline ThreeVector operator/ (const G4double C) const {
return ThreeVector(x/C, y/C, z/C);
const G4double oneOverC = 1./C;
return ThreeVector(x*oneOverC, y*oneOverC, z*oneOverC);
}
inline ThreeVector operator* (const G4double C) const {
@@ -30,11 +30,9 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
#define G4INCL_VERSION_ID "v5.1.8-clean"
#define G4INCL_GIT_HASH "8dac6ca5f84f0395784f96c3f614b8d369a7202b"
#define G4INCL_VERSION_ID "v5.1.14-clean"
#define G4INCL_GIT_HASH "bb67b460681fad81ed45190878e352ee6a18f97a"
@@ -11,7 +11,7 @@
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake,v 1.1 2010-09-29 18:57:01 bmorgan Exp $
# $Id: sources.cmake 75128 2013-10-28 10:02:29Z gcosmo $
#
#------------------------------------------------------------------------------
@@ -35,6 +35,8 @@ include_directories(${CMAKE_SOURCE_DIR}/source/processes/hadronic/cross_sections
include_directories(${CMAKE_SOURCE_DIR}/source/processes/hadronic/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/hadronic/models/binary_cascade/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/hadronic/models/im_r_matrix/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/hadronic/models/pre_equilibrium/exciton_model/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/hadronic/models/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/hadronic/util/include)
include_directories(${CMAKE_SOURCE_DIR}/source/processes/management/include)
include_directories(${CMAKE_SOURCE_DIR}/source/track/include)
@@ -55,7 +57,9 @@ GEANT4_DEFINE_MODULE(NAME G4hadronic_inclxx_utils
G4INCLHashing.hh
G4INCLLogger.hh
G4INCLGlobalInfo.hh
G4INCLNuclearMassTable.hh
G4INCLGlobals.hh
G4INCLRandomSeedVector.hh
G4INCLParticleType.hh
G4INCLBook.hh
G4INCLIRandomGenerator.hh
@@ -66,7 +70,6 @@ GEANT4_DEFINE_MODULE(NAME G4hadronic_inclxx_utils
G4INCLRandom.hh
G4INCLEventInfo.hh
G4INCLRootFinder.hh
G4INCLDeExcitation.hh
G4INCLVersion.hh
G4INCLGeant4Compat.hh
G4INCLParticleSpecies.hh
@@ -80,14 +83,15 @@ GEANT4_DEFINE_MODULE(NAME G4hadronic_inclxx_utils
G4INCLParticleTable.cc
G4INCLIAvatar.cc
G4INCLIFunction1D.cc
G4INCLNuclearMassTable.cc
G4INCLEventInfo.cc
G4INCLGlobals.cc
G4INCLConfigVersion.cc
G4INCLParticle.cc
G4INCLIntersection.cc
G4INCLConfig.cc
G4INCLRootFinder.cc
G4INCLRanecu.cc
G4INCLRandomSeedVector.cc
G4INCLInverseInterpolationTable.cc
G4INCLRandom.cc
G4INCLFinalState.cc
@@ -100,9 +104,6 @@ GEANT4_DEFINE_MODULE(NAME G4hadronic_inclxx_utils
G4bosons
G4geometrymng
G4globman
G4hadronic_mgt
G4hadronic_util
G4hadronic_xsect
G4ions
G4leptons
G4materials
@@ -112,6 +113,18 @@ GEANT4_DEFINE_MODULE(NAME G4hadronic_inclxx_utils
G4track
G4volumes
G4intercoms
G4had_mod_man
G4had_preequ_exciton
G4hadronic_mgt
G4hadronic_util
G4hadronic_xsect
G4hadronic_deex_evaporation
G4hadronic_deex_fermi_breakup
G4hadronic_deex_handler
G4hadronic_deex_management
G4hadronic_deex_multifragmentation
G4hadronic_deex_photon_evaporation
G4hadronic_deex_util
GLOBAL_DEPENDENCIES
G4geometry
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -40,21 +38,13 @@
#include "G4INCLConfig.hh"
#include "G4INCLParticleSpecies.hh"
#include "G4INCLParticleTable.hh"
#ifdef HAS_BOOST_PROGRAM_OPTIONS
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/parsers.hpp>
#include <boost/program_options/variables_map.hpp>
#include <iostream>
#include <fstream>
#include <sstream>
#include <cstdlib>
#include "G4INCLCascade.hh"
#include "G4INCLLogger.hh"
#endif
#include "G4INCLGlobals.hh"
namespace G4INCL {
const G4int Config::randomSeedMin = 1;
const G4int Config::randomSeedMax = ((1<<30)-1)+(1<<30); // 2^31-1
Config::Config()
{
init();
@@ -68,135 +58,205 @@ namespace G4INCL {
}
// NOT used in Geant4 mode
#ifdef HAS_BOOST_PROGRAM_OPTIONS
Config::Config(G4int argc, char *argv[], G4bool isFullRun) : naturalTarget(false) {
const std::string suggestHelpMsg("You might want to run `INCLCascade -h' to get a help message.\n");
#if defined(HAS_BOOST_PROGRAM_OPTIONS) && !defined(INCLXX_IN_GEANT4_MODE)
Config::Config(G4int argc, char *argv[], G4bool isFullRun) :
runOptDesc("Run options"),
hiddenOptDesc("Hidden options"),
genericOptDesc("Generic options"),
physicsOptDesc("Physics options"),
naturalTarget(false)
{
const std::string suggestHelpMsg("You might want to run `INCLCascade --help' to get a help message.\n");
// Define the names of the de-excitation models
const std::string theNoneName = "none";
#ifdef INCL_DEEXCITATION_SMM
const std::string theSMMName = "SMM";
#endif
#ifdef INCL_DEEXCITATION_GEMINIXX
const std::string theGEMINIXXName = "GEMINIXX";
#endif
#ifdef INCL_DEEXCITATION_ABLAXX
const std::string theABLAv3pName = "ABLAv3p";
#endif
#ifdef INCL_DEEXCITATION_ABLA07
const std::string theABLA07Name = "ABLA07";
#endif
// Define the default de-excitation model, in decreasing order of priority
std::string defaultDeExcitationModel = theNoneName;
#ifdef INCL_DEEXCITATION_SMM
defaultDeExcitationModel = theSMMName;
#endif
#ifdef INCL_DEEXCITATION_GEMINIXX
defaultDeExcitationModel = theGEMINIXXName;
#endif
#ifdef INCL_DEEXCITATION_ABLAXX
defaultDeExcitationModel = theABLAv3pName;
#endif
#ifdef INCL_DEEXCITATION_ABLA07
defaultDeExcitationModel = theABLA07Name;
#endif
const std::string listSeparator = "\n \t";
deExcitationModelList =
listSeparator + theNoneName
#ifdef INCL_DEEXCITATION_ABLA07
+ listSeparator + theABLA07Name
#endif
#ifdef INCL_DEEXCITATION_ABLAXX
+ listSeparator + theABLAv3pName
#endif
#ifdef INCL_DEEXCITATION_GEMINIXX
+ listSeparator + theGEMINIXXName
#endif
#ifdef INCL_DEEXCITATION_SMM
+ listSeparator + theSMMName
#endif
;
// Append " (default)" to the name of the default model
size_t defaultModelIndex = deExcitationModelList.find(defaultDeExcitationModel);
if(defaultModelIndex!=std::string::npos) {
deExcitationModelList = deExcitationModelList.substr(0, defaultModelIndex+defaultDeExcitationModel.size())
+ " (default)"
+ deExcitationModelList.substr(defaultModelIndex+defaultDeExcitationModel.size(), std::string::npos);
}
// Spell out the G4bool values
std::cout << std::boolalpha;
try {
// Hidden options
boost::program_options::options_description hiddenOptDesc("Hidden options");
hiddenOptDesc.add_options()
("input-file", boost::program_options::value<std::string>(&inputFileName), "input file")
("impact-parameter", boost::program_options::value<G4double>(&impactParameter)->default_value(-1.), "impact parameter")
("input-file", po::value<std::string>(&inputFileName), "input file")
("impact-parameter", po::value<G4double>(&impactParameter)->default_value(-1.), "impact parameter")
;
// Generic options
std::stringstream verbosityDescription;
verbosityDescription << "set verbosity level:\n"
<< " 0: \tquiet, suppress all output messages\n"
<< " " << InfoMsg << ": \tminimal logging\n"
<< " " << FatalMsg << ": \tlog fatal error messages as well\n"
<< " " << ErrorMsg << ": \tlog error messages as well\n"
<< " " << WarningMsg << ": \tlog warning messages as well\n"
<< " " << DebugMsg << ": \tlog debug messages as well\n"
<< " " << DataBlockMsg << ": \tlog data-block messages as well";
<< " 0: \tquiet, suppress all output messages\n"
<< " " << InfoMsg << ": \tminimal logging\n"
<< " " << FatalMsg << ": \tlog fatal error messages as well\n"
<< " " << ErrorMsg << ": \tlog error messages as well\n"
<< " " << WarningMsg << ": \tlog warning messages as well\n"
<< " " << DebugMsg << ": \tlog debug messages as well\n"
<< " " << DataBlockMsg << ": \tlog data-block messages as well";
boost::program_options::options_description genericOptDesc("Generic options");
genericOptDesc.add_options()
("help,h", "produce this help message")
("version", "print version string and exit")
;
// Run-specific options
boost::program_options::options_description runOptDesc("Run options");
std::stringstream randomSeed1Description, randomSeed2Description;
randomSeed1Description << "first seed for the random-number generator (between "
<< randomSeedMin << "and " << randomSeedMax << ")";
randomSeed2Description << "second seed for the random-number generator (between "
<< randomSeedMin << "and " << randomSeedMax << ")";
runOptDesc.add_options()
("title", boost::program_options::value<std::string>(&title)->default_value("INCL default run title"), "run title")
("output,o", boost::program_options::value<std::string>(&outputFileRoot), "root for generating output file names. Suffixes (.root, .out, etc.) will be appended to this root. Defaults to the input file name, if given; otherwise, defaults to a string composed of the explicitly specified options")
("logfile,l", boost::program_options::value<std::string>(&logFileName), "log file name. Defaults to `<output_root>.log'. Use `-' if you want to redirect logging to stdout")
("number-shots,N", boost::program_options::value<G4int>(&nShots), "* number of shots")
("target,t", boost::program_options::value<std::string>(&targetString), "* target nuclide. Can be specified as Fe56, 56Fe, Fe-56, 56-Fe, Fe_56, 56_Fe or Fe. If the mass number is omitted, natural target composition is assumed.")
("projectile,p", boost::program_options::value<std::string>(&projectileString), "* projectile name:\n"
("title", po::value<std::string>(&title)->default_value("INCL default run title"), "run title")
("output,o", po::value<std::string>(&outputFileRoot), "root for generating output file names. File-specific suffixes (.root, .out, etc.) will be appended to this root. Defaults to the input file name, if given; otherwise, defaults to a string composed of the explicitly specified options and of a customisable suffix, if provided using the -s option")
("suffix,s", po::value<std::string>(&fileSuffix), "suffix to be appended to generated output file names")
("logfile,l", po::value<std::string>(&logFileName), "log file name. Defaults to `<output_root>.log'. Use `-' if you want to redirect logging to stdout")
("number-shots,N", po::value<G4int>(&nShots), "* number of shots")
("target,t", po::value<std::string>(&targetString), "* target nuclide. Can be specified as Fe56, 56Fe, Fe-56, 56-Fe, Fe_56, 56_Fe or Fe. If the mass number is omitted, natural target composition is assumed.")
("projectile,p", po::value<std::string>(&projectileString), "* projectile name:\n"
" \tproton, p\n"
" \tneutron, n\n"
" \tpi+, piplus, pion+, pionplus\n"
" \tpi0, pizero, pion0, pionzero\n"
" \tpi-, piminus, pion-, pionminus\n"
" \td, t, a, deuteron, triton, alpha\n"
" \tHe-4, He4, 4He (and so on)\n")
("energy,E", boost::program_options::value<G4float>(&projectileKineticEnergy), "* total kinetic energy of the projectile, in MeV")
("verbose-event", boost::program_options::value<G4int>(&verboseEvent)->default_value(-1), "request verbose logging for the specified event only")
("random-seed-1", boost::program_options::value<G4int>(&randomSeed1)->default_value(666), "first seed for the random-number generator")
("random-seed-2", boost::program_options::value<G4int>(&randomSeed2)->default_value(777), "second seed for the random-number generator")
("inclxx-datafile-path", boost::program_options::value<std::string>(&INCLXXDataFilePath)->default_value("./data/"))
#ifdef INCL_DEEXCITATION_ABLAXX
("ablav3p-cxx-datafile-path", boost::program_options::value<std::string>(&ablav3pCxxDataFilePath)->default_value("./de-excitation/ablaxx/data/G4ABLA3.0/"))
" \tHe-4, He4, 4He (and so on)")
("energy,E", po::value<G4double>(&projectileKineticEnergy), "* total kinetic energy of the projectile, in MeV")
("verbose-event", po::value<G4int>(&verboseEvent)->default_value(-1), "request verbose logging for the specified event only")
("random-seed-1", po::value<G4int>(&randomSeed1)->default_value(666), randomSeed1Description.str().c_str())
("random-seed-2", po::value<G4int>(&randomSeed2)->default_value(777), randomSeed2Description.str().c_str())
#ifdef INCL_ROOT_USE
("root-selection", po::value<std::string>(&rootSelectionString)->default_value(""), "ROOT selection for abridged output ROOT tree. For example: \"A==1 && Z==0 && theta<3\" selects only events where a neutron is scattered in the forward direction.")
#endif
("inclxx-datafile-path", po::value<std::string>(&INCLXXDataFilePath)->default_value("../data/"),
"path to the INCL++ data files")
#ifdef INCL_DEEXCITATION_ABLA07
("abla07-datafile-path", boost::program_options::value<std::string>(&abla07DataFilePath)->default_value("./de-excitation/abla07/upstream/tables/"))
("abla07-datafile-path", po::value<std::string>(&abla07DataFilePath)->default_value("../de-excitation/abla07/upstream/tables/"),
"path to the ABLA07 data files")
#endif
#ifdef INCL_DEEXCITATION_ABLAXX
("ablav3p-cxx-datafile-path", po::value<std::string>(&ablav3pCxxDataFilePath)->default_value("../de-excitation/ablaxx/data/G4ABLA3.0/"),
"path to the ABLAv3p data files")
#endif
#ifdef INCL_DEEXCITATION_GEMINIXX
("geminixx-datafile-path", boost::program_options::value<std::string>(&geminixxDataFilePath)->default_value("./de-excitation/geminixx/upstream/"))
("geminixx-datafile-path", po::value<std::string>(&geminixxDataFilePath)->default_value("../de-excitation/geminixx/upstream/"),
"path to the GEMINI++ data files")
#endif
("verbosity,v", boost::program_options::value<G4int>(&verbosity)->default_value(4), verbosityDescription.str().c_str())
("verbosity,v", po::value<G4int>(&verbosity)->default_value(4), verbosityDescription.str().c_str())
;
// Physics options
boost::program_options::options_description physicsOptDesc("Physics options");
physicsOptDesc.add_options()
("pauli", boost::program_options::value<std::string>(&pauliString)->default_value("strict-statistical"), "Pauli-blocking algorithm:\n"
("de-excitation,d", po::value<std::string>(&deExcitationString)->default_value(defaultDeExcitationModel.c_str()), ("which de-excitation model to use:" + deExcitationModelList).c_str())
#ifdef INCL_DEEXCITATION_FERMI_BREAKUP
("max-mass-fermi-breakup", po::value<G4int>(&maxMassFermiBreakUp)->default_value(18), "Maximum remnant mass for Fermi break-up. Default: 18.")
#endif
("pauli", po::value<std::string>(&pauliString)->default_value("strict-statistical"), "Pauli-blocking algorithm:\n"
" \tstrict-statistical (default)\n"
" \tstrict\n"
" \tstatistical\n"
" \tglobal\n"
" \tnone")
("cdpp", boost::program_options::value<G4bool>(&CDPP)->default_value(true), "whether to apply CDPP after collisions:\n \ttrue, 1 (default)\n \tfalse, 0")
("coulomb", boost::program_options::value<std::string>(&coulombString)->default_value("non-relativistic"), "Coulomb-distortion algorithm:\n \tnon-relativistic (default)\n \tnone")
("potential", boost::program_options::value<std::string>(&potentialString)->default_value("isospin-energy"), "nucleon potential:\n \tisospin-energy-smooth\n \tisospin-energy (default)\n \tisospin\n \tconstant")
("pion-potential", boost::program_options::value<G4bool>(&pionPotential)->default_value("true"), "whether to use a pion potential:\n \ttrue, 1 (default)\n \tfalse, 0")
("local-energy-BB", boost::program_options::value<std::string>(&localEnergyBBString)->default_value("first-collision"), "local energy in baryon-baryon collisions:\n \talways\n \tfirst-collision (default)\n \tnever")
("local-energy-pi", boost::program_options::value<std::string>(&localEnergyPiString)->default_value("first-collision"), "local energy in pi-N collisions and in delta decays:\n \talways\n \tfirst-collision (default)\n \tnever")
("de-excitation", boost::program_options::value<std::string>(&deExcitationString)->default_value("none"), "which de-excitation model to use:"
"\n \tnone (default)"
#ifdef INCL_DEEXCITATION_ABLAXX
"\n \tABLAv3p"
#endif
#ifdef INCL_DEEXCITATION_ABLA07
"\n \tABLA07"
#endif
#ifdef INCL_DEEXCITATION_SMM
"\n \tSMM"
#endif
#ifdef INCL_DEEXCITATION_GEMINIXX
"\n \tGEMINIXX"
#endif
)
("cluster-algorithm", boost::program_options::value<std::string>(&clusterAlgorithmString)->default_value("intercomparison"), "clustering algorithm for production of composites:\n \tintercomparison (default)\n \tnone")
("cluster-max-mass", boost::program_options::value<G4int>(&clusterMaxMass)->default_value(8), "maximum mass of produced composites:\n \tminimum 2\n \tmaximum 12")
("back-to-spectator", boost::program_options::value<G4bool>(&backToSpectator)->default_value("true"), "whether to use back-to-spectator:\n \ttrue, 1 (default)\n \tfalse, 0")
("use-real-masses", boost::program_options::value<G4bool>(&useRealMasses)->default_value("true"), "whether to use real masses for the outgoing particle energies:\n \ttrue, 1 (default)\n \tfalse, 0")
("separation-energies", boost::program_options::value<std::string>(&separationEnergyString)->default_value("INCL"), "how to assign the separation energies of the INCL nucleus:\n \tINCL (default)\n \treal\n \treal-light")
("cdpp", po::value<G4bool>(&CDPP)->default_value(true), "whether to apply CDPP after collisions:\n \ttrue, 1 (default)\n \tfalse, 0")
("coulomb", po::value<std::string>(&coulombString)->default_value("non-relativistic"), "Coulomb-distortion algorithm:\n \tnon-relativistic (default)\n \tnone")
("potential", po::value<std::string>(&potentialString)->default_value("isospin-energy"), "nucleon potential:\n \tisospin-energy-smooth\n \tisospin-energy (default)\n \tisospin\n \tconstant")
("pion-potential", po::value<G4bool>(&pionPotential)->default_value("true"), "whether to use a pion potential:\n \ttrue, 1 (default)\n \tfalse, 0")
("local-energy-BB", po::value<std::string>(&localEnergyBBString)->default_value("first-collision"), "local energy in baryon-baryon collisions:\n \talways\n \tfirst-collision (default)\n \tnever")
("local-energy-pi", po::value<std::string>(&localEnergyPiString)->default_value("first-collision"), "local energy in pi-N collisions and in delta decays:\n \talways\n \tfirst-collision (default)\n \tnever")
("cluster-algorithm", po::value<std::string>(&clusterAlgorithmString)->default_value("intercomparison"), "clustering algorithm for production of composites:\n \tintercomparison (default)\n \tnone")
("cluster-max-mass", po::value<G4int>(&clusterMaxMass)->default_value(8), "maximum mass of produced composites:\n \tminimum 2\n \tmaximum 12")
("back-to-spectator", po::value<G4bool>(&backToSpectator)->default_value("true"), "whether to use back-to-spectator:\n \ttrue, 1 (default)\n \tfalse, 0")
("use-real-masses", po::value<G4bool>(&useRealMasses)->default_value("true"), "whether to use real masses for the outgoing particle energies:\n \ttrue, 1 (default)\n \tfalse, 0")
("separation-energies", po::value<std::string>(&separationEnergyString)->default_value("INCL"), "how to assign the separation energies of the INCL nucleus:\n \tINCL (default)\n \treal\n \treal-light")
("fermi-momentum", po::value<std::string>(&fermiMomentumString)->default_value("constant"), "how to assign the Fermi momentum of the INCL nucleus:\n \tconstant (default)\n \tconstant-light\n \tmass-dependent")
("cutNN", po::value<G4double>(&cutNN)->default_value(1910.), "minimum CM energy for nucleon-nucleon collisions, in MeV. Default: 1910.")
("rp-correlation", po::value<G4double>(&rpCorrelationCoefficient)->default_value(1.), "correlation coefficient for the r-p correlation. Default: 1 (full correlation).")
("rp-correlation-p", po::value<G4double>(&rpCorrelationCoefficientProton)->default_value(1.), "correlation coefficient for the proton r-p correlation. Overrides the value specified using the rp-correlation option. Default: 1 (full correlation).")
("rp-correlation-n", po::value<G4double>(&rpCorrelationCoefficientNeutron)->default_value(1.), "correlation coefficient for the neutron r-p correlation. Overrides the value specified using the rp-correlation option. Default: 1 (full correlation).")
("neutron-skin-thickness", po::value<G4double>(&neutronSkinThickness)->default_value(0.), "thickness of the neutron skin, in fm. Default: 0.")
("neutron-skin-additional-diffuseness", po::value<G4double>(&neutronSkinAdditionalDiffuseness)->default_value(0.), "additional diffuseness of the neutron density distribution (with respect to the proton diffuseness), in fm. Default: 0.")
("refraction", po::value<G4bool>(&refraction)->default_value(false), "whether to use refraction when particles are transmitted. Default: false.")
;
// Select options allowed on the command line
boost::program_options::options_description cmdLineOptions;
po::options_description cmdLineOptions;
cmdLineOptions.add(hiddenOptDesc).add(genericOptDesc).add(runOptDesc).add(physicsOptDesc);
// Select options allowed in config files
boost::program_options::options_description configFileOptions;
po::options_description configFileOptions;
configFileOptions.add(runOptDesc).add(physicsOptDesc);
// Select visible options
boost::program_options::options_description visibleOptions;
po::options_description visibleOptions;
visibleOptions.add(genericOptDesc).add(runOptDesc).add(physicsOptDesc);
// Declare input-file as a positional option (if we just provide a file
// name on the command line, it should be interpreted as an input-file
// option).
boost::program_options::positional_options_description p;
po::positional_options_description p;
p.add("input-file", 1);
// Disable guessing of option names
G4int cmdstyle =
boost::program_options::command_line_style::default_style &
~boost::program_options::command_line_style::allow_guessing;
po::command_line_style::default_style &
~po::command_line_style::allow_guessing;
// Result of the option processing
boost::program_options::variables_map variablesMap;
boost::program_options::store(boost::program_options::command_line_parser(argc, argv).
po::store(po::command_line_parser(argc, argv).
style(cmdstyle).
options(cmdLineOptions).positional(p).run(), variablesMap);
boost::program_options::notify(variablesMap);
po::notify(variablesMap);
// If an input file was specified, merge the options with the command-line
// options.
@@ -207,20 +267,20 @@ namespace G4INCL {
std::exit(EXIT_FAILURE);
} else {
// Merge options from the input file
boost::program_options::parsed_options parsedOptions = boost::program_options::parse_config_file(inputFileStream, configFileOptions, true);
po::parsed_options parsedOptions = po::parse_config_file(inputFileStream, configFileOptions, true);
// Make sure that the unhandled options are all "*-datafile-path"
std::vector<std::string> unhandledOptions =
boost::program_options::collect_unrecognized(parsedOptions.options, boost::program_options::exclude_positional);
po::collect_unrecognized(parsedOptions.options, po::exclude_positional);
G4bool ignoreNext = false;
const std::string match = "-datafile-path";
for(std::vector<std::string>::const_iterator i=unhandledOptions.begin(); i!=unhandledOptions.end(); ++i) {
for(std::vector<std::string>::const_iterator i=unhandledOptions.begin(), e=unhandledOptions.end(); i!=e; ++i) {
if(ignoreNext) {
ignoreNext=false;
continue;
}
if(i->rfind(match) == i->length()-match.length()) {
std::cerr << "Ignoring unrecognized option " << *i << std::endl;
std::cout << "Ignoring unrecognized option " << *i << std::endl;
ignoreNext = true;
} else {
std::cerr << "Error: unrecognized option " << *i << std::endl;
@@ -230,8 +290,8 @@ namespace G4INCL {
}
// Store the option values in the variablesMap
boost::program_options::store(parsedOptions, variablesMap);
boost::program_options::notify(variablesMap);
po::store(parsedOptions, variablesMap);
po::notify(variablesMap);
}
inputFileStream.close();
}
@@ -256,26 +316,26 @@ namespace G4INCL {
std::ifstream configFileStream(configFileName.c_str());
std::cout << "Reading config file " << configFileName << std::endl;
if(!configFileStream) {
std::cerr << "INCL++ config file " << configFileName
std::cout << "INCL++ config file " << configFileName
<< " not found. Continuing the run regardless."
<< std::endl;
} else {
// Merge options from the input file
boost::program_options::parsed_options parsedOptions = boost::program_options::parse_config_file(configFileStream, configFileOptions, true);
boost::program_options::store(parsedOptions, variablesMap);
po::parsed_options parsedOptions = po::parse_config_file(configFileStream, configFileOptions, true);
po::store(parsedOptions, variablesMap);
// Make sure that the unhandled options are all "*-datafile-path"
std::vector<std::string> unhandledOptions =
boost::program_options::collect_unrecognized(parsedOptions.options, boost::program_options::exclude_positional);
po::collect_unrecognized(parsedOptions.options, po::exclude_positional);
G4bool ignoreNext = false;
const std::string match = "-datafile-path";
for(std::vector<std::string>::const_iterator i=unhandledOptions.begin(); i!=unhandledOptions.end(); ++i) {
for(std::vector<std::string>::const_iterator i=unhandledOptions.begin(), e=unhandledOptions.end(); i!=e; ++i) {
if(ignoreNext) {
ignoreNext=false;
continue;
}
if(i->rfind(match) == i->length()-match.length()) {
std::cerr << "Ignoring unrecognized option " << *i << std::endl;
std::cout << "Ignoring unrecognized option " << *i << std::endl;
ignoreNext = true;
} else {
std::cerr << "Error: unrecognized option " << *i << std::endl;
@@ -285,8 +345,8 @@ namespace G4INCL {
}
// Store the option values in the variablesMap
boost::program_options::store(parsedOptions, variablesMap);
boost::program_options::notify(variablesMap);
po::store(parsedOptions, variablesMap);
po::notify(variablesMap);
}
configFileStream.close();
@@ -296,15 +356,16 @@ namespace G4INCL {
// -h/--help: print the help message and exit successfully
if(variablesMap.count("help")) {
std::cout << "Usage: INCLCascade [options] <input_file>" << std::endl;
std::cout << std::endl << "Options marked with a * are compulsory, i.e. they must be provided either on\nthe command line or in the input file." << std::endl;
std::cout << visibleOptions << std::endl;
std::cout
<< "Usage: INCLCascade [options] <input_file>" << std::endl
<< std::endl << "Options marked with a * are compulsory, i.e. they must be provided either on\nthe command line or in the input file." << std::endl
<< visibleOptions << std::endl;
std::exit(EXIT_SUCCESS);
}
// --version: print the version string and exit successfully
if(variablesMap.count("version")) {
std::cout <<"INCL++ version " << getVersionID() << std::endl;
std::cout <<"INCL++ version " << getVersionString() << std::endl;
std::exit(EXIT_SUCCESS);
}
@@ -387,8 +448,7 @@ namespace G4INCL {
coulombType = NoCoulomb;
else {
std::cerr << "Unrecognized Coulomb-distortion algorithm. Must be one of:" << std::endl
<< " non-relativistic-heavy-ion (default)" << std::endl
<< " non-relativistic" << std::endl
<< " non-relativistic (default)" << std::endl
<< " none" << std::endl;
std::cerr << suggestHelpMsg;
std::exit(EXIT_FAILURE);
@@ -458,7 +518,7 @@ namespace G4INCL {
}
}
// --de-excitation
// -d/--de-excitation
if(variablesMap.count("de-excitation")) {
std::string deExcitationNorm = deExcitationString;
std::transform(deExcitationNorm.begin(),
@@ -485,20 +545,7 @@ namespace G4INCL {
else {
std::cerr << "Unrecognized de-excitation model. "
<< "Must be one of:" << std::endl
<< " none (default)" << std::endl
#ifdef INCL_DEEXCITATION_ABLAXX
<< " ABLAv3p" << std::endl
#endif
#ifdef INCL_DEEXCITATION_ABLA07
<< " ABLA07" << std::endl
#endif
#ifdef INCL_DEEXCITATION_SMM
<< " SMM" << std::endl
#endif
#ifdef INCL_DEEXCITATION_GEMINIXX
<< " GEMINIXX" << std::endl
#endif
;
<< deExcitationModelList << std::endl;
std::cerr << suggestHelpMsg;
std::exit(EXIT_FAILURE);
}
@@ -561,49 +608,97 @@ namespace G4INCL {
separationEnergyType = INCLSeparationEnergy;
}
// --fermi-momentum
if(variablesMap.count("fermi-momentum")) {
std::string fermiMomentumNorm = fermiMomentumString;
std::transform(fermiMomentumNorm.begin(),
fermiMomentumNorm.end(),
fermiMomentumNorm.begin(), ::tolower);
if(fermiMomentumNorm=="constant")
fermiMomentumType = ConstantFermiMomentum;
else if(fermiMomentumNorm=="constant-light")
fermiMomentumType = ConstantLightFermiMomentum;
else if(fermiMomentumNorm=="mass-dependent")
fermiMomentumType = MassDependentFermiMomentum;
else {
std::cerr << "Unrecognized fermi-momentum option. "
<< "Must be one of:" << std::endl
<< " constant (default)" << std::endl
<< " constant-light" << std::endl
<< " mass-dependent" << std::endl;
std::cerr << suggestHelpMsg;
std::exit(EXIT_FAILURE);
}
} else {
fermiMomentumType = ConstantFermiMomentum;
}
// --rp-correlation / --rp-correlation-p / --rp-correlation-n
if(variablesMap.count("rp-correlation")) {
if(!variablesMap.count("rp-correlation-p") || variablesMap.find("rp-correlation-p")->second.defaulted())
rpCorrelationCoefficientProton = rpCorrelationCoefficient;
if(!variablesMap.count("rp-correlation-n") || variablesMap.find("rp-correlation-n")->second.defaulted())
rpCorrelationCoefficientNeutron = rpCorrelationCoefficient;
}
// -s/--suffix
if(!variablesMap.count("suffix")) {
// update the value in the variables_map
variablesMap.insert(std::make_pair("suffix", po::variable_value(boost::any(fileSuffix), false)));
}
// --output: construct a reasonable output file root if not specified
if(!variablesMap.count("output") && isFullRun) {
std::stringstream outputFileRootStream;
// If an input file was specified, use its name as the output file root
if(variablesMap.count("input-file"))
outputFileRoot = inputFileName;
outputFileRootStream << inputFileName << fileSuffix;
else {
std::stringstream outputFileRootStream;
outputFileRootStream.precision(0);
outputFileRootStream.setf(std::ios::fixed, std::ios::floatfield);
outputFileRootStream <<
ParticleTable::getShortName(projectileSpecies) << "_" <<
ParticleTable::getShortName(targetSpecies) << "_" <<
projectileKineticEnergy;
outputFileRootStream.precision(2);
// Append suffixes to the output file root for each explicitly specified CLI option
typedef boost::program_options::variables_map::const_iterator BPOVMIter;
for(BPOVMIter i=variablesMap.begin(); i!=variablesMap.end(); ++i) {
typedef po::variables_map::const_iterator BPOVMIter;
for(BPOVMIter i=variablesMap.begin(), e=variablesMap.end(); i!=e; ++i) {
std::string const &name = i->first;
// Only process CLI options
if(name!="projectile"
&& name!="target"
&& name!="energy"
&& name!="number-shots"
&& name!="random-seed-1"
&& name!="random-seed-2"
&& name!="inclxx-datafile-path"
&& name!="target"
&& name!="energy"
&& name!="number-shots"
&& name!="random-seed-1"
&& name!="random-seed-2"
&& name!="verbosity"
&& name!="verbose-event"
&& name!="suffix"
#ifdef INCL_ROOT_USE
&& name!="root-selection"
#endif
&& name!="inclxx-datafile-path"
#ifdef INCL_DEEXCITATION_ABLA07
&& name!="abla07-datafile-path"
&& name!="abla07-datafile-path"
#endif
#ifdef INCL_DEEXCITATION_ABLAXX
&& name!="ablav3p-cxx-datafile-path"
&& name!="ablav3p-cxx-datafile-path"
#endif
#ifdef INCL_DEEXCITATION_GEMINIXX
&& name!="geminixx-datafile-path"
&& name!="geminixx-datafile-path"
#endif
) {
boost::program_options::variable_value v = i->second;
) {
po::variable_value v = i->second;
if(!v.defaulted()) {
const std::type_info &type = v.value().type();
if(type==typeid(std::string))
outputFileRootStream << "_" << name << "=" << v.as<std::string>();
else if(type==typeid(G4float))
outputFileRootStream << "_" << name << "=" << v.as<G4float>();
else if(type==typeid(G4double))
outputFileRootStream << "_" << name << "=" << v.as<G4double>();
else if(type==typeid(G4int))
outputFileRootStream << "_" << name << "=" << v.as<G4int>();
else if(type==typeid(G4bool))
@@ -612,13 +707,40 @@ namespace G4INCL {
}
}
outputFileRoot = outputFileRootStream.str();
outputFileRootStream << fileSuffix;
}
// update the variable
outputFileRoot = outputFileRootStream.str();
// update the value in the variables_map
variablesMap.insert(std::make_pair("output", po::variable_value(boost::any(outputFileRoot), false)));
}
// -l/--logfile
if(!variablesMap.count("logfile"))
if(!variablesMap.count("logfile")) {
// update the variable
logFileName = outputFileRoot + ".log";
// update the value in the variables_map
variablesMap.insert(std::make_pair("logfile", po::variable_value(boost::any(logFileName), false)));
}
// --random-seed-1 and 2
if(!variablesMap.count("random-seed-1")) {
if(randomSeed1<randomSeedMin || randomSeed1>randomSeedMax) {
std::cerr << "Invalid value for random-seed-1. "
<< "Allowed range: [" << randomSeedMin << ", " << randomSeedMax << "]." << std::endl;
std::cerr << suggestHelpMsg;
std::exit(EXIT_FAILURE);
}
}
if(!variablesMap.count("random-seed-2")) {
if(randomSeed2<randomSeedMin || randomSeed2>randomSeedMax) {
std::cerr << "Invalid value for random-seed-2. "
<< "Allowed range: [" << randomSeedMin << ", " << randomSeedMax << "]." << std::endl;
std::cerr << suggestHelpMsg;
std::exit(EXIT_FAILURE);
}
}
}
catch(std::exception& e)
@@ -673,11 +795,23 @@ namespace G4INCL {
impactParameter = -1.;
separationEnergyString = "INCL";
separationEnergyType = INCLSeparationEnergy;
fermiMomentumString = "constant";
fermiMomentumType = ConstantFermiMomentum;
cutNN = 1910.;
#ifdef INCL_DEEXCITATION_FERMI_BREAKUP
maxMassFermiBreakUp = 18;
#endif
rpCorrelationCoefficient = 1.;
rpCorrelationCoefficientProton = 1.;
rpCorrelationCoefficientNeutron = 1.;
neutronSkinThickness = 0.;
neutronSkinAdditionalDiffuseness = 0.;
refraction=false;
}
std::string Config::summary() {
std::stringstream message;
message << "INCL++ version " << getVersionID() << std::endl;
message << "INCL++ version " << getVersionString() << std::endl;
if(projectileSpecies.theType != Composite)
message << "Projectile: " << ParticleTable::getName(projectileSpecies) << std::endl;
else
@@ -691,79 +825,64 @@ namespace G4INCL {
return message.str();
}
#if defined(HAS_BOOST_PROGRAM_OPTIONS) && !defined(INCLXX_IN_GEANT4_MODE)
std::string const Config::echo() const {
std::stringstream ss;
ss << std::boolalpha;
ss << "###########################" << std::endl
<< "### Start of input echo ###" << std::endl
<< "###########################" << std::endl << std::endl
<< " # You may re-use this snippet of the log file as an input file!" << std::endl
<< " # Options marked with a * are compulsory." << std::endl
<< std::endl
<< "# Run options" << std::endl
<< "title = " << title << "\t# run title" << std::endl
<< "output = " << outputFileRoot << "\t# root for generating output file names. Suffixes (.root, .out, etc.) will be appended to this root. Defaults to the input file name, if given; otherwise, defaults to a string composed of the explicitly specified options" << std::endl
<< "logfile = " << logFileName << "\t# log file name. Defaults to `<output_root>.log'. Use `-' if you want to redirect logging to stdout" << std::endl
<< "number-shots = " << nShots << "\t# * number of shots" << std::endl
<< "inclxx-datafile-path = " << INCLXXDataFilePath << std::endl
#ifdef INCL_DEEXCITATION_ABLAXX
<< "ablav3p-cxx-datafile-path = " << ablav3pCxxDataFilePath << std::endl
#endif
#ifdef INCL_DEEXCITATION_ABLA07
<< "abla07-datafile-path = " << abla07DataFilePath << std::endl
#endif
#ifdef INCL_DEEXCITATION_GEMINIXX
<< "geminixx-datafile-path = " << geminixxDataFilePath << std::endl
#endif
<< std::endl << "# Projectile and target definitions" << std::endl
<< "target = " << targetString << "\t# * target nuclide. Can be specified as Fe56, 56Fe, Fe-56, 56-Fe, Fe_56, 56_Fe or Fe. If the mass number is omitted, natural target composition is assumed." << std::endl
<< " " << "# the target nuclide was parsed as Z=" << targetSpecies.theZ;
ss << "###########################\n"
<< "### Start of input echo ###\n"
<< "###########################\n\n"
<< "# You may re-use this snippet of the log file as an input file!\n"
<< "# Options marked with a * are compulsory.\n"
<< "\n### Run options\n" << echoOptionsDescription(runOptDesc)
<< "\n### Physics options\n" << echoOptionsDescription(physicsOptDesc)
<< "\n# the projectile nuclide was parsed as Z=" << projectileSpecies.theZ
<< ", A=" << projectileSpecies.theA
<< "\n# the target nuclide was parsed as Z=" << targetSpecies.theZ;
if(targetSpecies.theA>0)
ss << ", A=" << targetSpecies.theA;
else
ss << ", natural target";
ss << std::endl
<< "projectile = " << projectileString << "\t# * projectile name (proton, neutron, pi+, pi0, pi-, d, t, a, He-4...)" << std::endl
<< " " << "# the projectile nuclide was parsed as Z=" << projectileSpecies.theZ << ", A=" << projectileSpecies.theA << std::endl
<< "energy = " << projectileKineticEnergy << "\t# * total kinetic energy of the projectile, in MeV" << std::endl
<< std::endl << "# Physics options " << std::endl
<< "pauli = " << pauliString << "\t# Pauli-blocking algorithm. Must be one of: strict-statistical (default), strict, statistical, global, none" << std::endl
<< "cdpp = " << CDPP << "\t# whether to apply CDPP after collisions" << std::endl
<< "coulomb = " << coulombString << "\t# Coulomb-distortion algorithm. Must be one of: non-relativistic (default), none" << std::endl
<< "potential = " << potentialString << "\t# nucleon potential. Must be one of: isospin-energy-smooth, isospin-energy (default), isospin, constant" << std::endl
<< "pion-potential = " << pionPotential << "\t# whether to use a pion potential" << std::endl
<< "local-energy-BB = " << localEnergyBBString << "\t# local energy in baryon-baryon collisions. Must be one of: always, first-collision (default), never" << std::endl
<< "local-energy-pi = " << localEnergyPiString << "\t# local energy in pi-N collisions and in delta decays. Must be one of: always, first-collision (default), never" << std::endl
<< "de-excitation = " << deExcitationString << "\t # which de-excitation model to use. Must be one of:"
" none (default)"
#ifdef INCL_DEEXCITATION_ABLAXX
", ABLAv3p"
#endif
#ifdef INCL_DEEXCITATION_ABLA07
", ABLA07"
#endif
#ifdef INCL_DEEXCITATION_SMM
", SMM"
#endif
#ifdef INCL_DEEXCITATION_GEMINIXX
", GEMINIXX"
#endif
<< std::endl
<< "cluster-algorithm = " << clusterAlgorithmString << "\t# clustering algorithm for production of composites. Must be one of: intercomparison (default), none" << std::endl
<< "cluster-max-mass = " << clusterMaxMass << "\t# maximum mass of produced composites. Must be between 2 and 12 (included)" << std::endl
<< "back-to-spectator = " << backToSpectator << "\t# whether to use back-to-spectator" << std::endl
<< "use-real-masses = " << useRealMasses << "\t# whether to use real masses for the outgoing particle energies" << std::endl
<< "separation-energies = " << separationEnergyString << "\t# how to assign the separation energies of the INCL nucleus. Must be one of: INCL (default), real, real-light" << std::endl
<< std::endl << "# Technical options " << std::endl
<< "verbosity = " << verbosity << "\t# from 0 (quiet) to 10 (most verbose)" << std::endl
<< "verbose-event = " << verboseEvent << "\t# request verbose logging for the specified event only" << std::endl
<< "random-seed-1 = " << randomSeed1 << "\t# first seed for the random-number generator" << std::endl
<< "random-seed-2 = " << randomSeed2 << "\t# second seed for the random-number generator" << std::endl
<< std::endl << "#########################" << std::endl
<< "### End of input echo ###" << std::endl
ss << "\n\n#########################\n"
<< "### End of input echo ###\n"
<< "#########################" << std::endl;
return ss.str();
}
std::string Config::echoOptionsDescription(const po::options_description &aDesc) const {
typedef std::vector< boost::shared_ptr< po::option_description > > OptVector;
typedef std::vector< boost::shared_ptr< po::option_description > >::const_iterator OptIter;
std::stringstream ss;
ss << std::boolalpha;
OptVector const &anOptVect = aDesc.options();
for(OptIter opt=anOptVect.begin(), e=anOptVect.end(); opt!=e; ++opt) {
std::string description = (*opt)->description();
String::wrap(description);
String::replaceAll(description, "\n", "\n# ");
ss << "\n# " << description << std::endl;
const std::string &name = (*opt)->long_name();
ss << name << " = ";
po::variable_value const &value = variablesMap.find(name)->second;
std::type_info const &type = value.value().type();
if(type == typeid(std::string)) {
const std::string svalue = value.as<std::string>();
if(svalue.empty())
ss << "\"\"";
else
ss << svalue;
} else if(type == typeid(G4int))
ss << value.as<G4int>();
else if(type == typeid(G4float))
ss << value.as<G4float>();
else if(type == typeid(G4double))
ss << value.as<G4double>();
else if(type == typeid(G4bool))
ss << value.as<G4bool>();
ss << '\n';
}
return ss.str();
}
#endif
}
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -39,7 +37,7 @@
/** \file G4INCLConfigVersion.cc
* \brief The Config::getVersionID() method.
*
* This method is split out from G4INCLConfig.cc in order to avoid having to
* This methods are split out from G4INCLConfig.cc in order to avoid having to
* recompile the whole file every time the G4INCLVersion.hh header is updated.
*
* \date 18 March 2011
@@ -54,4 +52,6 @@ namespace G4INCL {
std::string const Config::getVersionID() { return G4INCL_VERSION_ID; }
std::string const Config::getVersionHash() { return G4INCL_GIT_HASH; }
}
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -52,38 +50,21 @@
namespace G4INCL {
Int_t EventInfo::eventNumber = 0;
G4ThreadLocal Int_t EventInfo::eventNumber = 0;
#ifdef INCL_INVERSE_KINEMATICS
void EventInfo::fillInverseKinematics(const Double_t gamma) {
const Double_t beta = std::sqrt(1.-1./(gamma*gamma));
for(Int_t i=0; i<nParticles; ++i) {
Double_t mass;
if(A[i]>0) {
mass = ParticleTable::getTableMass(A[i],Z[i]);
} else if(origin[i]==-1) { // cascade particles with A=0, must be pions
if(Z[i]==1)
mass = ParticleTable::getTableParticleMass(PiPlus);
else if(Z[i]==0)
mass = ParticleTable::getTableParticleMass(PiZero);
else
mass = ParticleTable::getTableParticleMass(PiMinus);
} else // gamma rays
mass = 0.;
// determine the particle mass from the kinetic energy and the momentum;
// this ensures consistency with the masses uses by the models
const Double_t mass = std::max(
0.5 * (px[i]*px[i]+py[i]*py[i]+pz[i]*pz[i]-EKin[i]*EKin[i]) / EKin[i],
0.0);
const Double_t ETot = EKin[i] + mass;
const Double_t ETotPrime = gamma*(ETot - beta*pz[i]);
/* Using the invariant mass here avoids negative kinetic energies with
* particles produced by the de-excitation models, which do not
* necessarily use the same mass look-up tables as INCL.
*/
Double_t invariantMass;
if(A[i]>0 || origin[i]==-1) { // massive particles
invariantMass = std::sqrt(ETot*ETot - px[i]*px[i] - py[i]*py[i] - pz[i]*pz[i]);
} else { // gamma rays
invariantMass = 0.;
}
EKinPrime[i] = ETotPrime - invariantMass;
EKinPrime[i] = ETotPrime - mass;
pzPrime[i] = -gamma*(pz[i] - beta*ETot);
const Double_t pPrime = std::sqrt(px[i]*px[i] + py[i]*py[i] + pzPrime[i]*pzPrime[i]);
const Double_t cosThetaPrime = pzPrime[i]/pPrime;
@@ -96,5 +77,32 @@ namespace G4INCL {
}
}
#endif // INCL_INVERSE_KINEMATICS
void EventInfo::remnantToParticle(const G4int remnantIndex) {
A[nParticles] = ARem[remnantIndex];
Z[nParticles] = ZRem[remnantIndex];
emissionTime[nParticles] = stoppingTime;
px[nParticles] = pxRem[remnantIndex];
py[nParticles] = pyRem[remnantIndex];
pz[nParticles] = pzRem[remnantIndex];
const G4double plab = std::sqrt(pxRem[remnantIndex]*pxRem[remnantIndex]
+pyRem[remnantIndex]*pyRem[remnantIndex]
+pzRem[remnantIndex]*pzRem[remnantIndex]);
G4double pznorm = pzRem[remnantIndex]/plab;
if(pznorm>1.)
pznorm = 1.;
else if(pznorm<-1.)
pznorm = -1.;
theta[nParticles] = 180.*std::acos(pznorm)/G4INCL::Math::pi;
phi[nParticles] = 180.*std::atan2(pyRem[remnantIndex],pxRem[remnantIndex])/G4INCL::Math::pi;
EKin[nParticles] = EKinRem[remnantIndex];
origin[nParticles] = -1; // Origin: cascade
history.push_back(""); // history
nParticles++;
// assert(history.size()==(unsigned int)nParticles);
}
}
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -103,19 +101,19 @@ namespace G4INCL {
std::string FinalState::print() const {
std::stringstream ss;
ss << "Modified particles:" << std::endl;
for(ParticleIter iter = modified.begin(); iter != modified.end(); ++iter)
for(ParticleIter iter=modified.begin(), e=modified.end(); iter!=e; ++iter)
ss << (*iter)->print();
ss << "Outgoing particles:" << std::endl;
for(ParticleIter iter = outgoing.begin(); iter != outgoing.end(); ++iter)
for(ParticleIter iter=outgoing.begin(), e=outgoing.end(); iter!=e; ++iter)
ss << (*iter)->print();
ss << "Destroyed particles:" << std::endl;
for(ParticleIter iter = destroyed.begin(); iter != destroyed.end(); ++iter)
for(ParticleIter iter=destroyed.begin(), e=destroyed.end(); iter!=e; ++iter)
ss << (*iter)->print();
ss << "Created particles:" << std::endl;
for(ParticleIter iter = created.begin(); iter != created.end(); ++iter)
for(ParticleIter iter=created.begin(), e=created.end(); iter!=e; ++iter)
ss << (*iter)->print();
ss << "Entering particles:" << std::endl;
for(ParticleIter iter = entering.begin(); iter != entering.end(); ++iter)
for(ParticleIter iter=entering.begin(), e=entering.end(); iter!=e; ++iter)
ss << (*iter)->print();
return ss.str();
}
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -40,10 +38,79 @@
#include "G4INCLParticle.hh"
namespace G4INCL {
namespace Math {
namespace {
// constants for the Gaussian CDF approximation
const G4double gcdfa1 = 0.254829592;
const G4double gcdfa2 = -0.284496736;
const G4double gcdfa3 = 1.421413741;
const G4double gcdfa4 = -1.453152027;
const G4double gcdfa5 = 1.061405429;
const G4double gcdfp = 0.3275911;
}
G4double gaussianCDF(const G4double x)
{
// Save the sign of x
const G4double sgn = sign(x);
const G4double z = std::fabs(x) * oneOverSqrtTwo;
// A&S formula 7.1.26
G4double t = 1.0/(1.0 + gcdfp*z);
G4double y = 1.0 - (((((gcdfa5*t + gcdfa4)*t) + gcdfa3)*t + gcdfa2)*t + gcdfa1)*t*std::exp(-z*z);
return 0.5*(1.0 + sgn*y);
}
G4double gaussianCDF(const G4double x, const G4double x0, const G4double sigma) {
return gaussianCDF((x-x0)/sigma);
}
}
namespace ParticleConfig {
G4bool isPair(Particle const * const p1, Particle const * const p2, ParticleType t1, ParticleType t2) {
return ((p1->getType() == t1 && p2->getType() == t2) ||
(p1->getType() == t2 && p2->getType() == t1));
}
}
#ifndef INCLXX_IN_GEANT4_MODE
namespace String {
void wrap(std::string &str, const size_t lineLength, const std::string &separators) {
const size_t len = str.size();
size_t startPos = 0;
while(len-startPos > lineLength) {
const size_t nextNewline = str.find('\n', startPos);
if(nextNewline!=std::string::npos && nextNewline-startPos<=lineLength)
startPos = nextNewline+1;
else {
size_t lastSeparator = str.find_last_of(separators, startPos+lineLength);
if(lastSeparator!=std::string::npos)
str[lastSeparator] = '\n';
startPos = lastSeparator+1;
}
}
}
void replaceAll(std::string &str, const std::string &from, const std::string &to, const size_t maxPosition) {
if(from.empty())
return;
size_t start_pos = 0;
size_t cur_max_pos = maxPosition;
const size_t from_len = from.length();
const size_t to_len = to.length();
while((start_pos = str.find(from, start_pos)) != std::string::npos
&& (cur_max_pos==std::string::npos || start_pos<cur_max_pos)) {
str.replace(start_pos, from_len, to);
start_pos += to_len; // In case 'to' contains 'from', like replacing 'x' with 'yx'
if(cur_max_pos!=std::string::npos)
cur_max_pos += to_len - from_len;
}
}
}
#endif // INCLXX_IN_GEANT4_MODE
}
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -44,11 +42,12 @@
*/
#include "G4INCLIAvatar.hh"
#include "G4INCLRandom.hh"
#include <sstream>
namespace G4INCL {
long IAvatar::nextID = 1;
G4ThreadLocal long IAvatar::nextID = 1;
IAvatar::IAvatar() :
type(UnknownAvatarType),
@@ -74,7 +73,7 @@ namespace G4INCL {
std::stringstream particleString;
ParticleList pl = getParticles();
G4int numberOfParticles = 0;
for(ParticleIter i = pl.begin(); i != pl.end(); ++i) {
for(ParticleIter i=pl.begin(), e=pl.end(); i!=e; ++i) {
numberOfParticles++;
particleString << (*i)->getID() << " ";
}
@@ -88,12 +87,16 @@ namespace G4INCL {
G4INCL::FinalState* IAvatar::getFinalState()
{
INCL_DEBUG("Random seeds before preInteraction: " << Random::getSeeds() << std::endl);
preInteraction();
INCL_DEBUG("Random seeds before getChannel: " << Random::getSeeds() << std::endl);
IChannel *c = getChannel();
if( !c ) {
return new FinalState;
return NULL;
}
INCL_DEBUG("Random seeds before getFinalState: " << Random::getSeeds() << std::endl);
FinalState *fs = c->getFinalState();
INCL_DEBUG("Random seeds before postInteraction: " << Random::getSeeds() << std::endl);
fs = postInteraction(fs);
delete c;
return fs;
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -118,8 +116,9 @@ namespace G4INCL {
G4double InverseInterpolationTable::operator()(const G4double x) const {
// Find the relevant interpolation bin
InterpolationNode xNode(x,0.,0.);
std::vector<InterpolationNode>::const_iterator iter =
std::lower_bound(nodes.begin(), nodes.end(), x);
std::lower_bound(nodes.begin(), nodes.end(), xNode);
if(iter==nodes.begin())
return nodes.front().getY();
@@ -134,7 +133,7 @@ namespace G4INCL {
std::string InverseInterpolationTable::print() const {
std::string message;
for(std::vector<InterpolationNode>::const_iterator n=nodes.begin(); n!=nodes.end(); ++n)
for(std::vector<InterpolationNode>::const_iterator n=nodes.begin(), e=nodes.end(); n!=e; ++n)
message += n->print();
return message;
}
@@ -30,16 +30,19 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
#include "G4INCLLogger.hh"
#include "G4INCLGlobals.hh"
#ifdef INCLXX_IN_GEANT4_MODE
#include <cstdlib>
#endif
namespace G4INCL {
#ifdef INCL_DEBUG_LOG
#if defined(INCL_DEBUG_LOG) && !defined(INCLXX_IN_GEANT4_MODE)
std::string typeToString(const MessageType t) {
if(t == ErrorMsg)
return std::string("Error");
@@ -58,14 +61,29 @@ namespace G4INCL {
}
void LoggerSlave::logMessage(const MessageType type, const std::string &fileName, const G4int lineNumber, std::string const &s) const {
if(type!=InfoMsg) {
(*logStream) << typeToString(type) << " [" <<
fileName.substr(fileName.find_last_of("/")+1) <<
":" << lineNumber << "] ";
if(type==InfoMsg) {
(*logStream) << s;
return;
}
(*logStream) << s;
std::stringstream headerss;
headerss << typeToString(type) << " [";
std::string cont("\n");
cont += headerss.str();
headerss <<
fileName.substr(fileName.find_last_of("/")+1) <<
":" << lineNumber << "] ";
std::string header = headerss.str();
cont.append(header.size() - cont.size() - 1, '.');
cont += "] ";
std::string message(s);
String::replaceAll(message, "\n", cont, s.size()-2);
(*logStream) << header << message;
return;
}
void LoggerSlave::logDataBlock(const std::string &block, const std::string &fileName, const G4int lineNumber) const {
(*logStream) << typeToString(DataBlockMsg) << " [" <<
fileName.substr(fileName.find_last_of("/")+1) <<
@@ -75,7 +93,58 @@ namespace G4INCL {
<< "ENDDATA" << std::endl;
}
#endif
namespace Logger {
LoggerSlave * Logger::theLoggerSlave = NULL;
namespace {
G4ThreadLocal LoggerSlave *theLoggerSlave = NULL;
}
void logMessage(const MessageType type, std::string const &fileName, const G4int lineNumber, std::string const &s) {
theLoggerSlave->logMessage(type, fileName, lineNumber, s);
}
void flush() { theLoggerSlave->flush(); }
void dataBlock(const std::string &block, const std::string &fileName, const G4int lineNumber) {
theLoggerSlave->logDataBlock(block, fileName, lineNumber);
}
void setLoggerSlave(LoggerSlave * const logger) { theLoggerSlave = logger; }
void setVerbosityLevel(G4int lvl) { theLoggerSlave->setVerbosityLevel(lvl); }
G4int getVerbosityLevel() { return theLoggerSlave->getVerbosityLevel(); }
void deleteLoggerSlave() {
delete theLoggerSlave;
theLoggerSlave=NULL;
}
}
#else // defined(INCL_DEBUG_LOG) && !defined(INCLXX_IN_GEANT4_MODE)
namespace Logger {
namespace {
G4ThreadLocal G4int verbosityLevel = 0;
}
void initVerbosityLevelFromEnvvar() {
const char * const envVar = getenv("G4INCL_DEBUG_VERBOSITY");
if(envVar) {
std::stringstream verbss(envVar);
verbss >> verbosityLevel;
} else {
verbosityLevel = 0;
}
}
G4int getVerbosityLevel() {
return verbosityLevel;
}
}
#endif // defined(INCL_DEBUG_LOG) && !defined(INCLXX_IN_GEANT4_MODE)
}
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -49,12 +47,6 @@
#include <utility>
#include <iostream>
#ifdef INCL_ROOT_USE
#include "TSystem.h"
#else
#include <cstdlib>
#endif
namespace G4INCL {
Isotope::Isotope(const G4int A, const G4double abundance) :
@@ -67,13 +59,13 @@ namespace G4INCL {
{
G4double previousAbundance = 0.;
// Cumulate the abundances
for(IsotopeIter i=theIsotopes.begin(); i!=theIsotopes.end(); ++i) {
for(IsotopeIter i=theIsotopes.begin(), e=theIsotopes.end(); i!=e; ++i) {
i->theAbundance += previousAbundance;
previousAbundance = i->theAbundance;
}
// Normalize the abundances to 1
const G4double normalisation = 1./theIsotopes.back().theAbundance;
for(IsotopeIter i=theIsotopes.begin(); i!=theIsotopes.end(); ++i)
for(IsotopeIter i=theIsotopes.begin(), e=theIsotopes.end(); i!=e; ++i)
i->theAbundance *= normalisation;
}
@@ -95,12 +87,7 @@ namespace G4INCL {
if(i!=theDistributions.end())
return i->second;
else {
FATAL("Requested natural isotopic distribution for synthetic element Z = " << Z << std::endl);
#ifdef INCL_ROOT_USE
gSystem->Exit(EXIT_FAILURE);
#else
std::exit(EXIT_FAILURE);
#endif
INCL_FATAL("Requested natural isotopic distribution for synthetic element Z = " << Z << std::endl);
return theDistributions.begin()->second;
}
}
@@ -0,0 +1,202 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// INCL++ intra-nuclear cascade model
// Pekka Kaitaniemi, CEA and Helsinki Institute of Physics
// Davide Mancusi, CEA
// Alain Boudard, CEA
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
/** \file G4INCLNuclearMassTable.cc
* \brief Functions that encapsulate a mass table
*
* \date 22nd October 2013
* \author Davide Mancusi
*/
#ifndef INCLXX_IN_GEANT4_MODE
#include "G4INCLNuclearMassTable.hh"
#include "G4INCLParticleTable.hh"
#include "G4INCLGlobals.hh"
#include <algorithm>
#include <istream>
namespace G4INCL {
namespace {
G4ThreadLocal G4double **theTable = NULL;
G4ThreadLocal G4int AMax = 0;
G4ThreadLocal G4int *ZMaxArray = NULL;
G4ThreadLocal G4double protonMass = 0.;
G4ThreadLocal G4double neutronMass = 0.;
const G4double amu = 931.494061; // atomic mass unit in MeV/c^2
const G4double eMass = 0.5109988; // electron mass in MeV/c^2
G4double getWeizsaeckerMass(const G4int A, const G4int Z) {
const G4int Npairing = (A-Z)%2; // pairing
const G4int Zpairing = Z%2;
const G4double fA = (G4double) A;
const G4double fZ = (G4double) Z;
G4double binding =
- 15.67*fA // nuclear volume
+ 17.23*Math::pow23(fA) // surface energy
+ 93.15*((fA/2.-fZ)*(fA/2.-fZ))/fA // asymmetry
+ 0.6984523*fZ*fZ*Math::powMinus13(fA); // coulomb
if( Npairing == Zpairing ) binding += (Npairing+Zpairing-1) * 12.0 / std::sqrt(fA); // pairing
return fZ*::G4INCL::ParticleTable::getRealMass(Proton)+((G4double)(A-Z))
*::G4INCL::ParticleTable::getRealMass(Neutron)+binding;
}
void setMass(const G4int A, const G4int Z, const G4double mass) {
theTable[A][Z] = mass;
}
class MassRecord {
public:
MassRecord() :
A(0),
Z(0),
excess(0.)
{}
MassRecord(const G4int a, const G4int z, const G4double e) :
A(a),
Z(z),
excess(e)
{}
friend std::istream &operator>>(std::istream &in, MassRecord &record);
G4int A;
G4int Z;
G4double excess;
};
std::istream &operator>>(std::istream &in, MassRecord &record) {
return (in >> record.A >> record.Z >> record.excess);
}
G4bool compareA(const MassRecord &lhs, const MassRecord &rhs) {
return (lhs.A < rhs.A);
}
}
namespace NuclearMassTable {
void initialize(const std::string &path, const G4double pMass, const G4double nMass) {
protonMass = pMass;
neutronMass = nMass;
// Clear the existing tables, if any
deleteTable();
// File name
std::string fileName(path + "/walletlifetime.dat");
INCL_DEBUG("Reading real nuclear masses from file " << fileName << std::endl);
// Open the file stream
std::ifstream massTableIn(fileName.c_str());
if(!massTableIn.good()) {
std::cerr << "Cannot open " << fileName << " data file." << std::endl;
std::abort();
return;
}
// read the file
std::vector<MassRecord> records;
MassRecord record;
while(massTableIn.good()) {
massTableIn >> record;
records.push_back(record);
}
massTableIn.close();
INCL_DEBUG("Read " << records.size() << " nuclear masses" << std::endl);
// determine the max A
AMax = std::max_element(records.begin(), records.end(), compareA)->A;
INCL_DEBUG("Max A in nuclear-mass table = " << AMax << std::endl);
ZMaxArray = new G4int[AMax+1];
std::fill(ZMaxArray, ZMaxArray+AMax+1, 0);
theTable = new G4double*[AMax+1];
std::fill(theTable, theTable+AMax+1, static_cast<G4double*>(NULL));
// determine the max A per Z
for(std::vector<MassRecord>::const_iterator i=records.begin(), e=records.end(); i!=e; ++i) {
ZMaxArray[i->A] = std::max(ZMaxArray[i->A], i->Z);
}
// allocate the arrays
for(G4int A=1; A<=AMax; ++A) {
theTable[A] = new G4double[ZMaxArray[A]+1];
std::fill(theTable[A], theTable[A]+ZMaxArray[A]+1, -1.);
}
// fill the actual masses
for(std::vector<MassRecord>::const_iterator i=records.begin(), e=records.end(); i!=e; ++i) {
setMass(i->A, i->Z, i->A*amu + i->excess - i->Z*eMass);
}
}
G4double getMass(const G4int A, const G4int Z) {
if(A>AMax || Z>ZMaxArray[A]) {
INCL_DEBUG("Real mass unavailable for isotope A=" << A << ", Z=" << Z
<< ", using Weizsaecker's formula"
<< std::endl);
return getWeizsaeckerMass(A,Z);
}
const G4double mass = theTable[A][Z];
if(mass<0.) {
INCL_DEBUG("Real mass unavailable for isotope A=" << A << ", Z=" << Z
<< ", using Weizsaecker's formula"
<< std::endl);
return getWeizsaeckerMass(A,Z);
} else
return mass;
}
void deleteTable() {
delete[] ZMaxArray;
ZMaxArray = NULL;
for(G4int A=1; A<=AMax; ++A)
delete[] theTable[A];
delete[] theTable;
theTable = NULL;
}
}
}
#endif // INCLXX_IN_GEANT4_MODE
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -48,7 +46,7 @@
namespace G4INCL {
long Particle::nextID = 1;
G4ThreadLocal long Particle::nextID = 1;
Particle::Particle()
: theZ(0), theA(0),
@@ -64,6 +62,8 @@ namespace G4INCL {
nCollisions(0),
nDecays(0),
thePotentialEnergy(0.0),
rpCorrelated(false),
uncorrelatedMomentum(0.),
theHelicity(0.0),
emissionTime(0.0),
outOfWell(false),
@@ -74,7 +74,7 @@ namespace G4INCL {
}
Particle::Particle(ParticleType t, G4double energy,
ThreeVector momentum, ThreeVector position)
ThreeVector const &momentum, ThreeVector const &position)
: theEnergy(energy),
thePropagationEnergy(&theEnergy),
theFrozenEnergy(theEnergy),
@@ -83,28 +83,34 @@ namespace G4INCL {
theFrozenMomentum(theMomentum),
thePosition(position),
nCollisions(0), nDecays(0),
thePotentialEnergy(0.), theHelicity(0.0),
thePotentialEnergy(0.),
rpCorrelated(false),
uncorrelatedMomentum(theMomentum.mag()),
theHelicity(0.0),
emissionTime(0.0), outOfWell(false)
{
theParticipantType = TargetSpectator;
ID = nextID;
nextID++;
if(theEnergy <= 0.0) {
WARN("Particle with energy " << theEnergy << " created." << std::endl);
INCL_WARN("Particle with energy " << theEnergy << " created." << std::endl);
}
setType(t);
setMass(getInvariantMass());
}
Particle::Particle(ParticleType t,
ThreeVector momentum, ThreeVector position)
ThreeVector const &momentum, ThreeVector const &position)
: thePropagationEnergy(&theEnergy),
theMomentum(momentum),
thePropagationMomentum(&theMomentum),
theFrozenMomentum(theMomentum),
thePosition(position),
nCollisions(0), nDecays(0),
thePotentialEnergy(0.), theHelicity(0.0),
thePotentialEnergy(0.),
rpCorrelated(false),
uncorrelatedMomentum(theMomentum.mag()),
theHelicity(0.0),
emissionTime(0.0), outOfWell(false)
{
theParticipantType = TargetSpectator;
@@ -112,7 +118,7 @@ namespace G4INCL {
nextID++;
setType(t);
if( isResonance() ) {
ERROR("Cannot create resonance without specifying its momentum four-vector." << std::endl);
INCL_ERROR("Cannot create resonance without specifying its momentum four-vector." << std::endl);
}
G4double energy = std::sqrt(theMomentum.mag2() + theMass*theMass);
theEnergy = energy;
@@ -123,7 +129,7 @@ namespace G4INCL {
const G4double p2 = theMomentum.mag2();
G4double newp2 = theEnergy*theEnergy - theMass*theMass;
if( newp2<0.0 ) {
ERROR("Particle has E^2 < m^2." << std::endl << print());
INCL_ERROR("Particle has E^2 < m^2." << std::endl << print());
newp2 = 0.0;
theEnergy = theMass;
}
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -238,14 +236,15 @@ namespace G4INCL {
}
G4bool ParticleSpecies::parseElement(std::string const &s) {
for(theZ=1; theZ<ParticleTable::elementTableSize; ++theZ) {
std::string elementName = ParticleTable::getElementName(theZ);
// Normalize the element name
std::transform(elementName.begin(), elementName.end(), elementName.begin(), ::tolower);
if(s.compare(elementName)==0)
return true;
}
return parseIUPACElement(s);
theZ = ParticleTable::parseElement(s);
if(theZ<0)
theZ = ParticleTable::parseIUPACElement(s);
if(theZ<0)
return false;
else
return true;
}
G4bool ParticleSpecies::parseIUPACElement(std::string const &s) {
File diff suppressed because it is too large Load Diff
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -45,40 +43,122 @@
#include "G4INCLRandom.hh"
#include "G4INCLGlobals.hh"
// #include <cassert>
namespace G4INCL {
G4INCL::IRandomGenerator* Random::theGenerator;
namespace Random {
G4double Random::gauss(G4double sigma) {
// generate a Gaussian random number with standard deviation sigma
// uses the flat() and flat0() methods
static G4bool generated = false;
static G4double u, v;
namespace {
G4ThreadLocal IRandomGenerator* theGenerator;
if( !generated )
{
u = shoot0();
v = Math::twoPi*shoot();
generated = true;
return sigma*std::sqrt(-2*std::log(u))*std::cos(v);
}
else
{
generated = false;
return sigma*std::sqrt(-2*std::log(u))*std::sin(v);
void setGenerator(G4INCL::IRandomGenerator *aGenerator) {
if(isInitialized()) {
INCL_ERROR("INCL random number generator already initialized." << std::endl);
} else {
theGenerator = aGenerator;
}
}
}
ThreeVector Random::normVector(G4double norm) {
void setSeeds(const SeedVector &sv) {
theGenerator->setSeeds(sv);
}
const G4double ctheta = (1.-2.*shoot());
const G4double stheta = std::sqrt(1.-ctheta*ctheta);
const G4double phi = Math::twoPi*shoot();
return ThreeVector(
norm * stheta * std::cos(phi),
norm * stheta * std::sin(phi),
norm * ctheta);
SeedVector getSeeds() {
return theGenerator->getSeeds();
}
G4double shoot() {
return theGenerator->flat();
}
G4double shoot0() {
G4double r;
while( (r=shoot()) <= 0. )
;
return r;
}
G4double shoot1() {
G4double r;
while( (r=shoot()) >= 1. )
;
return r;
}
template<typename T>
T shootInteger(T n) {
return static_cast<T>(shoot1() * n);
}
G4double gauss(G4double sigma) {
// generate a Gaussian random number with standard deviation sigma
// uses the flat() and flat0() methods
static G4ThreadLocal G4bool generated = false;
static G4ThreadLocal G4double u, v;
if( !generated )
{
u = shoot0();
v = Math::twoPi*shoot();
generated = true;
return sigma*std::sqrt(-2*std::log(u))*std::cos(v);
}
else
{
generated = false;
return sigma*std::sqrt(-2*std::log(u))*std::sin(v);
}
}
ThreeVector normVector(G4double norm) {
const G4double ctheta = (1.-2.*shoot());
const G4double stheta = std::sqrt(1.-ctheta*ctheta);
const G4double phi = Math::twoPi*shoot();
return ThreeVector(
norm * stheta * std::cos(phi),
norm * stheta * std::sin(phi),
norm * ctheta);
}
ThreeVector sphereVector(G4double rmax) {
return normVector( rmax*Math::pow13(shoot0()) );
}
ThreeVector gaussVector(G4double sigma) {
const G4double sigmax = sigma * Math::oneOverSqrtThree;
return ThreeVector(gauss(sigmax), gauss(sigmax), gauss(sigmax));
}
std::pair<G4double,G4double> correlatedGaussian(const G4double corrCoeff, const G4double x0, const G4double sigma) {
// assert(corrCoeff<=1. && corrCoeff>=-1.);
G4double factor = 1.-corrCoeff*corrCoeff;
if(factor<=0.)
factor=0.;
const G4double x = gauss(sigma) + x0;
const G4double y = corrCoeff * x + gauss(sigma*std::sqrt(factor)) + x0;
return std::make_pair(x, y);
}
std::pair<G4double,G4double> correlatedUniform(const G4double corrCoeff) {
std::pair<G4double,G4double> gaussians = correlatedGaussian(corrCoeff);
return std::make_pair(Math::gaussianCDF(gaussians.first), Math::gaussianCDF(gaussians.second));
}
void deleteGenerator() {
delete theGenerator;
theGenerator = 0;
}
G4bool isInitialized() {
if(theGenerator == 0) return false;
return true;
}
}
@@ -0,0 +1,65 @@
//
// ********************************************************************
// * License and Disclaimer *
// * *
// * The Geant4 software is copyright of the Copyright Holders of *
// * the Geant4 Collaboration. It is provided under the terms and *
// * conditions of the Geant4 Software License, included in the file *
// * LICENSE and available at http://cern.ch/geant4/license . These *
// * include a list of copyright holders. *
// * *
// * Neither the authors of this software system, nor their employing *
// * institutes,nor the agencies providing financial support for this *
// * work make any representation or warranty, express or implied, *
// * regarding this software system or assume any liability for its *
// * use. Please see the license in the file LICENSE and URL above *
// * for the full disclaimer and the limitation of liability. *
// * *
// * This code implementation is the result of the scientific and *
// * technical work of the GEANT4 collaboration. *
// * By using, copying, modifying or distributing the software (or *
// * any work based on the software) you agree to acknowledge its *
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// INCL++ intra-nuclear cascade model
// Pekka Kaitaniemi, CEA and Helsinki Institute of Physics
// Davide Mancusi, CEA
// Alain Boudard, CEA
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
/*
* \file G4INCLRandomSeedVector.cc
*
* \date 17 May 2013
* \author Davide Mancusi
*/
#include "G4INCLRandomSeedVector.hh"
namespace G4INCL {
namespace Random {
long SeedVector::at(const size_t i) const { return theSeeds.at(i); }
long &SeedVector::operator[](const size_t i) { return theSeeds[i]; }
size_t SeedVector::size() const { return theSeeds.size(); }
void SeedVector::resize(const size_t n) { theSeeds.resize(n); }
void SeedVector::push_back(const long val) { theSeeds.push_back(val); }
std::ostream &operator<<(std::ostream &out, SeedVector const &sv) {
if(sv.size()<=0)
return out;
for(size_t i=0; i<sv.size()-1; ++i)
out << sv.at(i) << '\t';
out << sv.at(sv.size()-1);
return out;
}
}
}
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -52,7 +50,7 @@ namespace G4INCL {
iseed2 = 777;
}
Ranecu::Ranecu(const SeedVector &sv) {
Ranecu::Ranecu(const Random::SeedVector &sv) {
setSeeds(sv);
}
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"
@@ -53,125 +51,141 @@
namespace G4INCL {
std::pair<G4double,G4double> RootFinder::solution;
namespace RootFinder {
const G4double RootFinder::toleranceY = 1.e-4;
namespace {
/// \brief Tolerance on the y value
const G4double toleranceY = 1.e-4;
/// \brief Maximum number of iterations for convergence
const G4int maxIterations=50;
/** \brief Bracket the root of the function f.
*
* Tries to find a bracketing value for the function root.
*
* \param f pointer to a RootFunctor
* \param x0 starting value
* \return if the root could be bracketed, returns two values of x
* bracketing the root, as a pair. If the bracketing failed, returns a
* pair with first > second.
*/
std::pair<G4double,G4double> bracketRoot(RootFunctor const * const f, G4double x0) {
G4double y0 = (*f)(x0);
const G4double scaleFactor = 1.5;
G4double x1;
if(x0!=0.)
x1=scaleFactor*x0;
else
x1=1.;
G4double y1 = (*f)(x1);
if(Math::sign(y0)!=Math::sign(y1))
return std::make_pair(x0,x1);
const G4double scaleFactorMinus1 = 1./scaleFactor;
G4double oldx0, oldx1, oldy1;
G4int iterations=0;
do {
if(iterations > maxIterations) {
INCL_DEBUG("Could not bracket the root." << std::endl);
return std::make_pair((G4double) 1.,(G4double) -1.);
}
oldx0=x0;
oldx1=x1;
oldy1=y1;
x0 *= scaleFactorMinus1;
x1 *= scaleFactor;
y0 = (*f)(x0);
y1 = (*f)(x1);
iterations++;
} while(Math::sign(y0)==Math::sign(y1));
if(Math::sign(y1)==Math::sign(oldy1))
return std::make_pair(x0,oldx0);
else
return std::make_pair(oldx1,x1);
}
G4bool RootFinder::solve(RootFunctor const * const f, const G4double x0) {
// If we already have the solution, do nothing
const G4double y0 = (*f)(x0);
if( std::abs(y0) < toleranceY ) {
solution = std::make_pair(x0,y0);
return true;
}
// Bracket the root and set the initial values
std::pair<G4double,G4double> bracket = bracketRoot(f,x0);
G4double x1 = bracket.first;
G4double x2 = bracket.second;
// If x1>x2, it means that we could not bracket the root. Return false.
if(x1>x2) {
// Maybe zero is a good solution?
G4double y_at_zero = (*f)(0.);
if(std::abs(y_at_zero)<=toleranceY) {
f->cleanUp(true);
solution = std::make_pair(0.,y_at_zero);
return true;
} else {
WARN("Root-finding algorithm could not bracket the root." << std::endl);
f->cleanUp(false);
return false;
Solution solve(RootFunctor const * const f, const G4double x0) {
// If we already have the solution, do nothing
const G4double y0 = (*f)(x0);
if( std::abs(y0) < toleranceY ) {
return Solution(x0,y0);
}
// Bracket the root and set the initial values
std::pair<G4double,G4double> bracket = bracketRoot(f,x0);
G4double x1 = bracket.first;
G4double x2 = bracket.second;
// If x1>x2, it means that we could not bracket the root. Return false.
if(x1>x2) {
// Maybe zero is a good solution?
G4double y_at_zero = (*f)(0.);
if(std::abs(y_at_zero)<=toleranceY) {
f->cleanUp(true);
return Solution(0.,y_at_zero);
} else {
INCL_DEBUG("Root-finding algorithm could not bracket the root." << std::endl);
f->cleanUp(false);
return Solution();
}
}
G4double y1 = (*f)(x1);
G4double y2 = (*f)(x2);
G4double x = x1;
G4double y = y1;
/* ********************************
* Start of the false-position loop
* ********************************/
// Keep track of the last updated interval end (-1=left, 1=right)
G4int lastUpdated = 0;
for(G4int iterations=0; std::abs(y) > toleranceY; iterations++) {
if(iterations > maxIterations) {
INCL_DEBUG("Root-finding algorithm did not converge." << std::endl);
f->cleanUp(false);
return Solution();
}
// Estimate the root position by linear interpolation
x = (y1*x2-y2*x1)/(y1-y2);
// Update the value of the function
y = (*f)(x);
// Update the bracketing interval
if(Math::sign(y) == Math::sign(y1)) {
x1=x;
y1=y;
if(lastUpdated==-1) y2 *= 0.5;
lastUpdated = -1;
} else {
x2=x;
y2=y;
if(lastUpdated==1) y1 *= 0.5;
lastUpdated = 1;
}
}
/* ******************************
* End of the false-position loop
* ******************************/
f->cleanUp(true);
return Solution(x,y);
}
G4double y1 = (*f)(x1);
G4double y2 = (*f)(x2);
G4double x = x1;
G4double y = y1;
/* ********************************
* Start of the false-position loop
* ********************************/
// Keep track of the last updated interval end (-1=left, 1=right)
G4int lastUpdated = 0;
for(G4int iterations=0; std::abs(y) > toleranceY; iterations++) {
if(iterations > maxIterations) {
WARN("Root-finding algorithm did not converge." << std::endl);
f->cleanUp(false);
return false;
}
// Estimate the root position by linear interpolation
x = (y1*x2-y2*x1)/(y1-y2);
// Update the value of the function
y = (*f)(x);
// Update the bracketing interval
if(Math::sign(y) == Math::sign(y1)) {
x1=x;
y1=y;
if(lastUpdated==-1) y2 *= 0.5;
lastUpdated = -1;
} else {
x2=x;
y2=y;
if(lastUpdated==1) y1 *= 0.5;
lastUpdated = 1;
}
}
/* ******************************
* End of the false-position loop
* ******************************/
solution = std::make_pair(x,y);
f->cleanUp(true);
return true;
}
std::pair<G4double,G4double> RootFinder::bracketRoot(RootFunctor const * const f, G4double x0) {
G4double y0 = (*f)(x0);
const G4double scaleFactor = 1.5;
G4double x1;
if(x0!=0.)
x1=scaleFactor*x0;
else
x1=1.;
G4double y1 = (*f)(x1);
if(Math::sign(y0)!=Math::sign(y1))
return std::make_pair(x0,x1);
const G4double scaleFactorMinus1 = 1./scaleFactor;
G4double oldx0, oldx1, oldy1;
G4int iterations=0;
do {
if(iterations > maxIterations) {
DEBUG("Could not bracket the root." << std::endl);
return std::make_pair((G4double) 1.,(G4double) -1.);
}
oldx0=x0;
oldx1=x1;
oldy1=y1;
x0 *= scaleFactorMinus1;
x1 *= scaleFactor;
y0 = (*f)(x0);
y1 = (*f)(x1);
iterations++;
} while(Math::sign(y0)==Math::sign(y1));
if(Math::sign(y1)==Math::sign(oldy1))
return std::make_pair(x0,oldx0);
else
return std::make_pair(oldx1,x1);
}
} // namespace RootFinder
}
@@ -30,8 +30,6 @@
// Sylvie Leray, CEA
// Joseph Cugnon, University of Liege
//
// INCL++ revision: v5.1.8
//
#define INCLXX_IN_GEANT4_MODE 1
#include "globals.hh"