Import Geant4 11.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2023-12-08 10:43:34 +01:00
parent dd1f179cda
commit 860a2b92bf
3962 changed files with 139318 additions and 164259 deletions
@@ -49,19 +49,19 @@ public:
G4DNACPA100LogLogInterpolation();
~G4DNACPA100LogLogInterpolation();
~G4DNACPA100LogLogInterpolation() override;
G4double Calculate(G4double point, G4int bin,
const G4DataVector& energies,
const G4DataVector& data) const;
const G4DataVector& data) const override;
G4double Calculate(G4double point, G4int bin,
const G4DataVector& energies,
const G4DataVector& data,
const G4DataVector& log_energies,
const G4DataVector& log_data) const;
const G4DataVector& log_data) const override;
virtual G4VDataSetAlgorithm* Clone() const;
G4VDataSetAlgorithm* Clone() const override;
private:
@@ -225,7 +225,7 @@ private:
std::unique_ptr<G4UIcmdWithoutParameter> fpInitChem;
static G4DNAChemistryManager* fgInstance;
G4bool fActiveChemistry;
G4bool fActiveChemistry{false};
struct ThreadLocalData{
ThreadLocalData();
@@ -236,20 +236,20 @@ private:
static G4ThreadLocal ThreadLocalData* fpThreadData;
G4bool fMasterInitialized;
G4bool fForceThreadReinitialization;
G4bool fMasterInitialized{false};
G4bool fForceThreadReinitialization{false};
std::unique_ptr<G4DNAWaterExcitationStructure> fpExcitationLevel;
std::unique_ptr<G4DNAWaterIonisationStructure> fpIonisationLevel;
std::unique_ptr<G4VUserChemistryList> fpUserChemistryList;
G4bool fOwnChemistryList;
G4bool fUseInStandalone;
G4bool fPhysicsTableBuilt;
G4bool fSkipReactions;
G4bool fOwnChemistryList{false};
G4bool fUseInStandalone{false};
G4bool fPhysicsTableBuilt{false};
G4bool fSkipReactions{false};
G4bool fGeometryClosed;
G4bool fGeometryClosed{false};
G4int fVerbose;
G4bool fResetCounterWhenRunEnds;
G4int fVerbose{0};
G4bool fResetCounterWhenRunEnds{true};
};
@@ -55,51 +55,55 @@ class G4DNACrossSectionDataSet : public G4VEMDataSet
{
public:
G4DNACrossSectionDataSet() = delete;
G4DNACrossSectionDataSet(G4VDataSetAlgorithm* algo,
G4double xUnit=CLHEP::MeV,
G4double dataUnit=CLHEP::barn);
virtual ~G4DNACrossSectionDataSet();
virtual G4double FindValue(G4double e, G4int componentId=0) const;
~G4DNACrossSectionDataSet() override;
virtual void PrintData(void) const;
G4DNACrossSectionDataSet(const G4DNACrossSectionDataSet & copy) = delete;
G4DNACrossSectionDataSet& operator=(const G4DNACrossSectionDataSet & right) = delete;
virtual const G4VEMDataSet* GetComponent(G4int componentId) const
G4double FindValue(G4double e, G4int componentId=0) const override;
void PrintData() const override;
const G4VEMDataSet* GetComponent(G4int componentId) const override
{ return components[componentId]; }
virtual void AddComponent(G4VEMDataSet* dataSet)
void AddComponent(G4VEMDataSet* dataSet) override
{ components.push_back(dataSet); }
virtual size_t NumberOfComponents(void) const
size_t NumberOfComponents() const override
{ return components.size(); }
virtual const G4DataVector& GetEnergies(G4int componentId) const
const G4DataVector& GetEnergies(G4int componentId) const override
{ return GetComponent(componentId)->GetEnergies(0); }
virtual const G4DataVector& GetData(G4int componentId) const
const G4DataVector& GetData(G4int componentId) const override
{ return GetComponent(componentId)->GetData(0); }
virtual const G4DataVector& GetLogEnergies(G4int componentId) const
const G4DataVector& GetLogEnergies(G4int componentId) const override
{ return GetComponent(componentId)->GetLogEnergies(0); }
virtual const G4DataVector& GetLogData(G4int componentId) const
const G4DataVector& GetLogData(G4int componentId) const override
{ return GetComponent(componentId)->GetLogData(0); }
virtual void SetEnergiesData(G4DataVector* x, G4DataVector* values, G4int componentId);
void SetEnergiesData(G4DataVector* x, G4DataVector* values, G4int componentId) override;
virtual void SetLogEnergiesData(G4DataVector* x,
void SetLogEnergiesData(G4DataVector* x,
G4DataVector* values,
G4DataVector* log_x,
G4DataVector* log_values,
G4int componentId);
G4int componentId) override;
virtual G4bool LoadData(const G4String & argFileName);
virtual G4bool LoadNonLogData(const G4String & argFileName);
G4bool LoadData(const G4String & argFileName) override;
G4bool LoadNonLogData(const G4String & argFileName) override;
virtual G4bool SaveData(const G4String & argFileName) const;
G4bool SaveData(const G4String & argFileName) const override;
virtual G4double RandomSelect(G4int /*componentId */) const { return -1.; };
G4double RandomSelect(G4int /*componentId */) const override { return -1.; };
// void CleanUpComponents();
@@ -108,11 +112,6 @@ private:
G4String FullFileName(const G4String & argFileName) const;
// Hide copy constructor and assignment operator
G4DNACrossSectionDataSet();
G4DNACrossSectionDataSet(const G4DNACrossSectionDataSet & copy);
G4DNACrossSectionDataSet& operator=(const G4DNACrossSectionDataSet & right);
std::vector<G4VEMDataSet*> components; // Owned pointers
G4int z;
@@ -126,7 +125,7 @@ private:
G4double GetUnitData() const { return unitData; }
const G4VDataSetAlgorithm* GetAlgorithm() const { return algorithm; }
void CleanUpComponents(void);
void CleanUpComponents();
};
@@ -51,8 +51,8 @@
class G4VDNAHit
{
public :
G4VDNAHit(){;}
virtual ~G4VDNAHit(){;}
G4VDNAHit()= default;
virtual ~G4VDNAHit()= default;
};
class G4DNAIndirectHit : public G4VDNAHit
@@ -60,7 +60,7 @@ class G4DNAIndirectHit : public G4VDNAHit
public :
G4DNAIndirectHit(const G4String& baseName, const G4Molecule* molecule,
const G4ThreeVector& position, G4double time);
virtual ~G4DNAIndirectHit();
~G4DNAIndirectHit() override;
inline const G4Molecule* GetMolecule() {return fpMolecule;}
inline const G4ThreeVector& GetPosition() {return fPosition;}
@@ -54,7 +54,7 @@ public:
private:
G4int nLevels;
G4int nLevels{5};
std::vector<G4double> energyConstant;
@@ -53,7 +53,7 @@ public:
private:
G4int nLevels;
G4int nLevels{5};
std::vector<G4double> energyConstant;
@@ -38,19 +38,19 @@
class G4DNAGenericIonsManager
{
public:
static G4DNAGenericIonsManager * Instance(void);
~G4DNAGenericIonsManager() = delete;
G4DNAGenericIonsManager(const G4DNAGenericIonsManager &) = delete;
const G4DNAGenericIonsManager &operator=(const G4DNAGenericIonsManager &) = delete;
static G4DNAGenericIonsManager * Instance();
G4ParticleDefinition * GetIon(const G4String & name);
private:
G4DNAGenericIonsManager();
~G4DNAGenericIonsManager();
G4DNAGenericIonsManager(const G4DNAGenericIonsManager &);
const G4DNAGenericIonsManager &operator=(const G4DNAGenericIonsManager &);
static G4DNAGenericIonsManager * theInstance;
typedef std::map<G4String, G4ParticleDefinition *> IonsMap;
using IonsMap = std::map<G4String, G4ParticleDefinition *>;
IonsMap map;
};
@@ -65,7 +65,7 @@ class G4DNAIons : public G4ParticleDefinition
);
public:
virtual ~G4DNAIons();
~G4DNAIons() override;
G4DNAIons* IonsDefinition();
G4DNAIons* Ions();
@@ -95,11 +95,14 @@ using ComponentMap = std::map<const G4Material*, G4double, CompareMaterial>;
class G4DNAMolecularMaterial: public G4VStateDependent
{
public:
G4DNAMolecularMaterial(const G4DNAMolecularMaterial& right) = delete;
G4DNAMolecularMaterial& operator=(const G4DNAMolecularMaterial&) = delete;
static G4DNAMolecularMaterial* Instance();
void Initialize();
void Clear();
virtual G4bool Notify(G4ApplicationState requestedState);
G4bool Notify(G4ApplicationState requestedState) override;
//----------------------------------------------------------------------------
@@ -221,9 +224,7 @@ public:
protected:
static G4DNAMolecularMaterial* fInstance;
G4DNAMolecularMaterial();
G4DNAMolecularMaterial(const G4DNAMolecularMaterial& right);
G4DNAMolecularMaterial& operator=(const G4DNAMolecularMaterial&);
virtual ~G4DNAMolecularMaterial();
~G4DNAMolecularMaterial() override;
void Create();
void InitializeNumMolPerVol();
void InitializeDensity();
@@ -127,7 +127,7 @@ public:
//----------------------------------------------------------------------------
// Temperature scaling
typedef std::function<double(double)> RateParam;
using RateParam = std::function<double (double)>;
static double PolynomialParam(double temp_K, std::vector<double> P);
static double ArrehniusParam(double temp_K, std::vector<double> P);
@@ -181,7 +181,7 @@ public:
static G4DNAMolecularReactionTable* GetReactionTable();
static G4DNAMolecularReactionTable* Instance();
static void DeleteInstance();
virtual ~G4DNAMolecularReactionTable();
~G4DNAMolecularReactionTable() override;
using Reactant = const G4MolecularConfiguration;
using Data = const G4DNAMolecularReactionData;
@@ -236,14 +236,14 @@ public:
void ScaleReactionRateForNewTemperature(double temp_K);
//_________________________________________________________________
void PrintTable(G4VDNAReactionModel* = 0);
void PrintTable(G4VDNAReactionModel* = nullptr);
void Reset();
protected:
G4bool fVerbose;
G4bool fVerbose{false};
G4VDNAMolecularGeometry* fGeometry;
G4VDNAMolecularGeometry* fGeometry{nullptr};
ReactionDataMap fReactionData;
ReactivesMV fReactantsMV;
ReactionDataMV fReactionDataMV;
@@ -32,6 +32,8 @@
#include <vector>
#include "G4MoleculeCounter.hh"
#include "G4VScavengerMaterial.hh"
#include "G4MoleculeTable.hh"
class G4Material;
class G4MolecularConfiguration;
class G4VChemistryWorld;
@@ -78,13 +80,14 @@ class G4DNAScavengerMaterial : public G4VScavengerMaterial
{
return it->second > 0;
}
else
{
return false;
}
return false;
}
void SetCounterAgainstTime() { fCounterAgainstTime = true; }
void SetpH(const G4int& ph);
G4double GetpH();
std::vector<MolType> GetScavengerList() const
{
@@ -108,6 +111,9 @@ class G4DNAScavengerMaterial : public G4VScavengerMaterial
CounterMapType fCounterMap;
G4bool fCounterAgainstTime;
G4int fVerbose;
MolType fH3Op = G4MoleculeTable::Instance()->GetConfiguration("H3Op(B)");
MolType fH2O = G4MoleculeTable::Instance()->GetConfiguration("H2O");
MolType fHOm = G4MoleculeTable::Instance()->GetConfiguration("OHm(B)");
struct Search
{
Search() { fLowerBoundSet = false; }
@@ -117,5 +123,7 @@ class G4DNAScavengerMaterial : public G4VScavengerMaterial
};
std::unique_ptr<Search> fpLastSearch;
void WaterEquilibrium();
};
#endif // G4DNASCAVENGERMATERIAL_HH
@@ -47,7 +47,7 @@ public:
private:
// Number of excitation levels of the water molecule
G4int nLevels;
G4int nLevels{5};
std::vector<G4double> energyConstant;
@@ -47,7 +47,7 @@ public:
private:
// Number of Ionisation levels of the water molecule
G4int nLevels;
G4int nLevels{5};
std::vector<G4double> energyConstant;
@@ -53,7 +53,6 @@
#define G4ERRORFUNCTION_HH_
#include "globals.hh"
#include <vector>
class G4ErrorFunction {
public:
@@ -101,9 +101,9 @@ template<typename TYPE>
class TG4MoleculeShoot : public G4MoleculeShoot
{
public:
TG4MoleculeShoot() : G4MoleculeShoot(){;}
virtual ~TG4MoleculeShoot(){;}
void Shoot(G4MoleculeGun*){}
TG4MoleculeShoot() : G4MoleculeShoot(){}
~TG4MoleculeShoot() override= default;
void Shoot(G4MoleculeGun*) override{}
protected:
void ShootAtRandomPosition(G4MoleculeGun*){}
@@ -129,9 +129,9 @@ class G4MoleculeGun : public G4ITGun
{
public:
G4MoleculeGun();
virtual ~G4MoleculeGun();
~G4MoleculeGun() override;
virtual void DefineTracks();
void DefineTracks() override;
/*
* Create a single molecule
@@ -192,7 +192,7 @@ public:
return fShoots;
}
typedef std::map<G4String, G4int> NameNumber;
using NameNumber = std::map<G4String, G4int>;
void GetNameAndNumber(NameNumber&);
@@ -67,9 +67,9 @@ public:
G4MoleculeShootMessenger(const G4String& name,
G4MoleculeGunMessenger*,
G4shared_ptr<G4MoleculeShoot>);
virtual ~G4MoleculeShootMessenger();
virtual void SetNewValue(G4UIcommand * command, G4String newValue);
virtual G4String GetCurrentValue(G4UIcommand * command);
~G4MoleculeShootMessenger() override;
void SetNewValue(G4UIcommand * command, G4String newValue) override;
G4String GetCurrentValue(G4UIcommand * command) override;
inline G4shared_ptr<G4MoleculeShoot>& GetShoot() {
return fpShoot;
@@ -92,10 +92,10 @@ class G4MoleculeGunMessenger : public G4UImessenger
public:
G4MoleculeGunMessenger(G4MoleculeGun*);
virtual ~G4MoleculeGunMessenger();
~G4MoleculeGunMessenger() override;
virtual void SetNewValue(G4UIcommand * command, G4String newValue);
virtual G4String GetCurrentValue(G4UIcommand * command);
void SetNewValue(G4UIcommand * command, G4String newValue) override;
G4String GetCurrentValue(G4UIcommand * command) override;
const std::vector<G4MoleculeShootMessenger*>&
GetShootMessengers() const
@@ -111,7 +111,7 @@ protected:
G4MoleculeShootMessenger* CreateNewType(const G4String& name)
{
G4shared_ptr<G4MoleculeShoot> moleculeShoot(new TG4MoleculeShoot<T>());
G4MoleculeShootMessenger* shoot =
auto shoot =
new G4MoleculeShootMessenger(name,
this,
moleculeShoot);
@@ -41,14 +41,14 @@ class FormattedText: public G4VPhysChemIO
{
public:
FormattedText();
virtual ~FormattedText();
~FormattedText() override;
virtual void InitializeMaster(){}
virtual void InitializeThread(){}
virtual void InitializeFile();
void InitializeMaster() override{}
void InitializeThread() override{}
void InitializeFile() override;
virtual void NewRun(){}
virtual void NewEvent(){}
void NewRun() override{}
void NewEvent() override{}
/**
* When DNA physics model create a water molecule, you'll get a notification
@@ -58,18 +58,18 @@ public:
* model and the IncomingTrack is the track responsible for the creation
* of this molecule (electron, proton...)
*/
virtual void CreateWaterMolecule(G4int electronicModif,
void CreateWaterMolecule(G4int electronicModif,
G4int /*electronicLevel*/,
G4double energy,
const G4Track* /*theIncomingTrack*/);
const G4Track* /*theIncomingTrack*/) override;
/**
* Same idea as the previous method but for solvated electron.
* This method should be used by the physics model of the ElectronSolvatation
* process.
*/
virtual void CreateSolvatedElectron(const G4Track* /*theIncomingTrack*/,
G4ThreeVector* finalPosition = 0);
void CreateSolvatedElectron(const G4Track* /*theIncomingTrack*/,
G4ThreeVector* finalPosition = nullptr) override;
//============================================================================
// FILE OPERATIONS
@@ -80,14 +80,14 @@ public:
* the position and electronic state of the water molecule
* and the position thermalized or not of the solvated electron
*/
virtual void WriteInto(const G4String&,
std::ios_base::openmode mode = std::ios_base::out);
virtual void AddEmptyLineInOutputFile();
void WriteInto(const G4String&,
std::ios_base::openmode mode = std::ios_base::out) override;
void AddEmptyLineInOutputFile() override;
/**
* Close the file specified with WriteInto
*/
virtual void CloseFile();
void CloseFile() override;
protected:
G4int fRunID; // unused
@@ -102,14 +102,14 @@ class G4Analysis: public G4VPhysChemIO
{
public:
G4Analysis(G4VAnalysisManager*);
virtual ~G4Analysis();
~G4Analysis() override;
virtual void InitializeMaster(){}
virtual void InitializeThread(){}
virtual void InitializeFile();
void InitializeMaster() override{}
void InitializeThread() override{}
void InitializeFile() override;
virtual void NewRun(){}
virtual void NewEvent(){}
void NewRun() override{}
void NewEvent() override{}
/**
* Method used by DNA physics model to create a water molecule.
@@ -118,18 +118,18 @@ public:
* model and the IncomingTrack is the track responsible for the creation
* of this molecule, for instance an electron.
*/
virtual void CreateWaterMolecule(G4int electronicModif,
void CreateWaterMolecule(G4int electronicModif,
G4int /*electronicLevel*/,
G4double energy,
const G4Track* /*theIncomingTrack*/);
const G4Track* /*theIncomingTrack*/) override;
/**
* Same idea as the previous method but for solvated electron.
* This method should be used by the physics model of the ElectronSolvatation
* process.
*/
virtual void CreateSolvatedElectron(const G4Track* /*theIncomingTrack*/,
G4ThreeVector* finalPosition = 0);
void CreateSolvatedElectron(const G4Track* /*theIncomingTrack*/,
G4ThreeVector* finalPosition = nullptr) override;
//============================================================================
// FILE OPERATIONS
@@ -140,14 +140,14 @@ public:
* the position and electronic state of the water molecule
* and the position thermalized or not of the solvated electron
*/
virtual void WriteInto(const G4String&, std::ios_base::openmode mode =
std::ios_base::out);
virtual void AddEmptyLineInOutputFile(){}
void WriteInto(const G4String&, std::ios_base::openmode mode =
std::ios_base::out) override;
void AddEmptyLineInOutputFile() override{}
/**
* Close the file specified with WriteInto
*/
virtual void CloseFile();
void CloseFile() override;
protected:
G4VAnalysisManager* fpAnalysisManager;
@@ -46,8 +46,8 @@ class G4ReactionTableMessenger : public G4UImessenger
{
public:
G4ReactionTableMessenger(G4DNAMolecularReactionTable*);
virtual ~G4ReactionTableMessenger();
virtual void SetNewValue(G4UIcommand * command,G4String newValue);
~G4ReactionTableMessenger() override;
void SetNewValue(G4UIcommand * command,G4String newValue) override;
protected:
G4DNAMolecularReactionTable* fpTable;
@@ -65,7 +65,7 @@ public :
G4VDNAReactionModel& operator=(const G4VDNAReactionModel&) = delete;
virtual ~G4VDNAReactionModel();
virtual void Initialise(const G4MolecularConfiguration*, const G4Track&) {;}
virtual void Initialise(const G4MolecularConfiguration*, const G4Track&) {}
virtual void InitialiseToPrint(const G4MolecularConfiguration*) = 0 ;
virtual G4double GetReactionRadius(const G4MolecularConfiguration*,
const G4MolecularConfiguration*) = 0;
@@ -79,5 +79,5 @@ public :
const G4DNAMolecularReactionTable* GetReactionTable();
protected :
const G4DNAMolecularReactionTable* fpReactionTable ;
const G4DNAMolecularReactionTable* fpReactionTable{nullptr} ;
};
@@ -72,7 +72,7 @@ public:
* process.
*/
virtual void CreateSolvatedElectron(const G4Track* /*theIncomingTrack*/,
G4ThreeVector* finalPosition = 0) = 0;
G4ThreeVector* finalPosition = nullptr) = 0;
//============================================================================
// FILE OPERATIONS
@@ -41,12 +41,12 @@
// Constructor
G4DNACPA100LogLogInterpolation::G4DNACPA100LogLogInterpolation()
{ }
= default;
// Destructor
G4DNACPA100LogLogInterpolation::~G4DNACPA100LogLogInterpolation()
{ }
= default;
G4VDataSetAlgorithm* G4DNACPA100LogLogInterpolation::Clone() const
{ return new G4DNACPA100LogLogInterpolation; }
@@ -57,7 +57,7 @@ G4double G4DNACPA100LogLogInterpolation::Calculate(G4double x, G4int bin,
const G4DataVector& data) const
{
//G4cout << "G4DNACPA100LogLogInterpolation is performed (2 arguments) " << G4endl;
G4int nBins = G4int(data.size() - 1);
auto nBins = G4int(data.size() - 1);
//G4double oldresult = 0.;
G4double value = 0.;
if (x < points[0])
@@ -115,7 +115,7 @@ G4double G4DNACPA100LogLogInterpolation::Calculate(G4double x, G4int bin,
const G4DataVector& log_points,
const G4DataVector& log_data) const
{
G4int nBins = G4int(data.size() - 1);
auto nBins = G4int(data.size() - 1);
G4double value = 0.;
G4double log_x = std::log10(x);
if (x < points[0])
@@ -37,30 +37,32 @@
#include "G4DNAChemistryManager.hh"
#include "G4Scheduler.hh"
#include "G4SystemOfUnits.hh"
#include "G4Molecule.hh"
#include "G4VITTrackHolder.hh"
#include "G4H2O.hh"
#include "G4AutoLock.hh"
#include "G4DNAMolecularReactionTable.hh"
#include "G4DNAWaterExcitationStructure.hh"
#include "G4DNAWaterIonisationStructure.hh"
#include "G4Electron_aq.hh"
#include "G4MolecularConfiguration.hh"
#include "G4VMoleculeCounter.hh"
#include "G4VUserChemistryList.hh"
#include "G4AutoLock.hh"
#include "G4UIcmdWithABool.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4GeometryManager.hh"
#include "G4StateManager.hh"
#include "G4H2O.hh"
#include "G4MolecularConfiguration.hh"
#include "G4Molecule.hh"
#include "G4MoleculeFinder.hh"
#include "G4MoleculeTable.hh"
#include "G4PhysChemIO.hh"
#include "G4Scheduler.hh"
#include "G4StateManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4UIcmdWithABool.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIcmdWithoutParameter.hh"
#include "G4VITTrackHolder.hh"
#include "G4VMoleculeCounter.hh"
#include "G4VUserChemistryList.hh"
#include "G4VUserPulseInfo.hh"
#include <memory>
G4DNAChemistryManager* G4DNAChemistryManager::fgInstance = nullptr;
G4ThreadLocal G4DNAChemistryManager::ThreadLocalData*
@@ -99,27 +101,17 @@ void G4DNAChemistryManager::SetPhysChemIO(std::unique_ptr<G4VPhysChemIO> pPhysCh
*/
//------------------------------------------------------------------------------
G4DNAChemistryManager::G4DNAChemistryManager()
: G4UImessenger()
, G4VStateDependent()
, fpChemDNADirectory(new G4UIdirectory("/chem/"))
:
fpChemDNADirectory(new G4UIdirectory("/chem/"))
, fpActivateChem(new G4UIcmdWithABool("/chem/activate", this))
, fpRunChem(new G4UIcmdWithAnInteger("/chem/run", this))
, fpSkipReactionsFromChemList(new G4UIcmdWithoutParameter("/chem/skipReactionsFromChemList", this))
, fpScaleForNewTemperature(new G4UIcmdWithADoubleAndUnit("/chem/temperature", this))
, fpInitChem(new G4UIcmdWithoutParameter("/chem/init", this))
, fActiveChemistry(false)
, fMasterInitialized(false)
, fForceThreadReinitialization(false)
, fpExcitationLevel(nullptr)
,
fpExcitationLevel(nullptr)
, fpIonisationLevel(nullptr)
, fpUserChemistryList(nullptr)
, fOwnChemistryList(false)
, fUseInStandalone(false)
, fPhysicsTableBuilt(false)
, fSkipReactions(false)
, fGeometryClosed(false)
, fVerbose(0)
, fResetCounterWhenRunEnds(true)
{
fpRunChem->SetParameterName("Number of runs to execute for the chemistry module"
"(this works when used in standalone", true, true);
@@ -223,7 +215,7 @@ G4bool G4DNAChemistryManager::Notify(G4ApplicationState requestedState)
{
if (requestedState == G4State_Quit)
{
if (fVerbose)
if (fVerbose != 0)
{
G4cout << "G4DNAChemistryManager::Notify ---> received G4State_Quit"
<< G4endl;
@@ -281,11 +273,11 @@ G4String G4DNAChemistryManager::GetCurrentValue(G4UIcommand* pCommand)
{
return G4UIcmdWithABool::ConvertToString(fActiveChemistry);
}
else if (pCommand == fpScaleForNewTemperature.get())
if (pCommand == fpScaleForNewTemperature.get())
{
return fpScaleForNewTemperature->ConvertToStringWithBestUnit(G4MolecularConfiguration::GetGlobalTemperature());
}
else if (pCommand == fpSkipReactionsFromChemList.get())
if (pCommand == fpSkipReactionsFromChemList.get())
{
return G4UIcmdWithABool::ConvertToString(fSkipReactions);
}
@@ -375,23 +367,19 @@ void G4DNAChemistryManager::Initialize()
//==========================================================================
// ON MASTER THREAD
//==========================================================================
else
{
InitializeMaster();
InitializeThreadSharedData();
return;
}
InitializeMaster();
InitializeThreadSharedData();
return;
}
//===========================================================================
// IS NOT IN MT MODE
//===========================================================================
else
{
InitializeMaster();
InitializeThreadSharedData();
// In this case: InitializeThread is called when Run() is called
return;
}
InitializeMaster();
InitializeThreadSharedData();
// In this case: InitializeThread is called when Run() is called
return;
}
//------------------------------------------------------------------------------
@@ -403,7 +391,7 @@ void G4DNAChemistryManager::InitializeMaster()
return;
}
if (fVerbose)
if (fVerbose != 0)
{
G4cout << "G4DNAChemistryManager::InitializeMaster() is called" << G4endl;
}
@@ -442,7 +430,7 @@ void G4DNAChemistryManager::HandleStandaloneInitialization()
return;
}
if (fVerbose)
if (fVerbose != 0)
{
G4cout << "G4DNAChemistryManager: Build the physics tables for "
"molecule definition only."
@@ -453,7 +441,7 @@ void G4DNAChemistryManager::HandleStandaloneInitialization()
if (!fGeometryClosed)
{
if (fVerbose)
if (fVerbose != 0)
{
G4cout << "G4DNAChemistryManager: Close geometry" << G4endl;
}
@@ -488,7 +476,7 @@ void G4DNAChemistryManager::InitializeThread()
fpUserChemistryList->ConstructTimeStepModel(G4DNAMolecularReactionTable::GetReactionTable());
}
if (fVerbose)
if (fVerbose != 0)
{
G4cout << "G4DNAChemistryManager::InitializeThread() is called"
<< G4endl;
@@ -507,7 +495,7 @@ void G4DNAChemistryManager::InitializeThread()
void G4DNAChemistryManager::InitializeFile()
{
if (fVerbose)
if (fVerbose != 0)
{
G4cout << "G4DNAChemistryManager::InitializeFile() is called"
<< G4endl;
@@ -523,7 +511,7 @@ void G4DNAChemistryManager::InitializeFile()
G4bool G4DNAChemistryManager::IsActivated()
{
return fgInstance ? fgInstance->IsChemistryActivated() : false;
return fgInstance != nullptr ? fgInstance->IsChemistryActivated() : false;
}
//------------------------------------------------------------------------------
@@ -545,7 +533,7 @@ void G4DNAChemistryManager::SetChemistryActivation(G4bool flag)
void G4DNAChemistryManager::WriteInto(const G4String& output,
std::ios_base::openmode mode)
{
if (fVerbose)
if (fVerbose != 0)
{
G4cout << "G4DNAChemistryManager: Write chemical stage into "
<< output.data() << G4endl;
@@ -553,7 +541,7 @@ void G4DNAChemistryManager::WriteInto(const G4String& output,
if (!fpThreadData->fpPhysChemIO)
{
fpThreadData->fpPhysChemIO.reset(new G4PhysChemIO::FormattedText());
fpThreadData->fpPhysChemIO = std::make_unique<G4PhysChemIO::FormattedText>();
}
fpThreadData->fpPhysChemIO->WriteInto(output, mode);
@@ -586,7 +574,7 @@ G4DNAWaterExcitationStructure* G4DNAChemistryManager::GetExcitationLevel()
{
if (!fpExcitationLevel)
{
fpExcitationLevel.reset(new G4DNAWaterExcitationStructure);
fpExcitationLevel = std::make_unique<G4DNAWaterExcitationStructure>();
}
return fpExcitationLevel.get();
}
@@ -597,7 +585,7 @@ G4DNAWaterIonisationStructure* G4DNAChemistryManager::GetIonisationLevel()
{
if (!fpIonisationLevel)
{
fpIonisationLevel.reset(new G4DNAWaterIonisationStructure);
fpIonisationLevel = std::make_unique<G4DNAWaterIonisationStructure>();
}
return fpIonisationLevel.get();
}
@@ -633,7 +621,7 @@ void G4DNAChemistryManager::CreateWaterMolecule(ElectronicModification modificat
if (fActiveChemistry)
{
G4Molecule* pH2OMolecule = new G4Molecule(G4H2O::Definition());
auto pH2OMolecule = new G4Molecule(G4H2O::Definition());
switch (modification)
{
@@ -693,9 +681,9 @@ void G4DNAChemistryManager::CreateSolvatedElectron(const G4Track* pIncomingTrack
}
}
PushMolecule(std::unique_ptr<G4Molecule>(new G4Molecule(G4Electron_aq::Definition())),
PushMolecule(std::make_unique<G4Molecule>(G4Electron_aq::Definition()),
picosecond + delayedTime,
pFinalPosition ? *pFinalPosition : pIncomingTrack->GetPosition(),
pFinalPosition != nullptr ? *pFinalPosition : pIncomingTrack->GetPosition(),
pIncomingTrack->GetTrackID());
}
}
@@ -76,7 +76,7 @@ G4DNACrossSectionDataSet::~G4DNACrossSectionDataSet()
{
CleanUpComponents();
if (algorithm)
delete algorithm;
}
@@ -100,7 +100,7 @@ G4bool G4DNACrossSectionDataSet::LoadData(const G4String & argFileName)
std::vector<G4DataVector *> columns;
std::vector<G4DataVector *> log_columns;
std::stringstream *stream(new std::stringstream);
auto stream(new std::stringstream);
char c;
G4bool comment(false);
G4bool space(true);
@@ -216,10 +216,10 @@ G4bool G4DNACrossSectionDataSet::LoadData(const G4String & argFileName)
std::size_t j(0);
G4DataVector *argEnergies=new G4DataVector;
G4DataVector *argData=new G4DataVector;
G4DataVector *argLogEnergies=new G4DataVector;
G4DataVector *argLogData=new G4DataVector;
auto argEnergies=new G4DataVector;
auto argData=new G4DataVector;
auto argLogEnergies=new G4DataVector;
auto argLogData=new G4DataVector;
while(j<maxJ)
{
@@ -266,7 +266,7 @@ G4bool G4DNACrossSectionDataSet::LoadNonLogData(const G4String & argFileName)
std::vector<G4DataVector *> columns;
std::stringstream *stream(new std::stringstream);
auto stream(new std::stringstream);
char c;
G4bool comment(false);
G4bool space(true);
@@ -366,8 +366,8 @@ G4bool G4DNACrossSectionDataSet::LoadNonLogData(const G4String & argFileName)
std::size_t j(0);
G4DataVector *argEnergies=new G4DataVector;
G4DataVector *argData=new G4DataVector;
auto argEnergies=new G4DataVector;
auto argData=new G4DataVector;
while(j<maxJ)
{
@@ -417,9 +417,9 @@ G4bool G4DNACrossSectionDataSet::SaveData(const G4String & argFileName) const
return false;
}
G4DataVector::const_iterator iEnergies(GetComponent(0)->GetEnergies(0).begin());
G4DataVector::const_iterator iEnergiesEnd(GetComponent(0)->GetEnergies(0).end());
G4DataVector::const_iterator * iData(new G4DataVector::const_iterator[n]);
auto iEnergies(GetComponent(0)->GetEnergies(0).begin());
auto iEnergiesEnd(GetComponent(0)->GetEnergies(0).end());
auto iData(new G4DataVector::const_iterator[n]);
std::size_t k(n);
@@ -464,7 +464,7 @@ G4bool G4DNACrossSectionDataSet::SaveData(const G4String & argFileName) const
G4String G4DNACrossSectionDataSet::FullFileName(const G4String& argFileName) const
{
const char* path = G4FindDataDir("G4LEDATA");
if (!path)
if (path == nullptr)
{
G4Exception("G4DNACrossSectionDataSet::FullFileName","em0006",
FatalException,"G4LEDATA environment variable not set.");
@@ -485,8 +485,8 @@ G4double G4DNACrossSectionDataSet::FindValue(G4double argEnergy, G4int /* argCom
// Returns the sum over the shells corresponding to e
G4double value = 0.;
std::vector<G4VEMDataSet *>::const_iterator i(components.begin());
std::vector<G4VEMDataSet *>::const_iterator end(components.end());
auto i(components.begin());
auto end(components.end());
while (i!=end)
{
@@ -498,9 +498,9 @@ G4double G4DNACrossSectionDataSet::FindValue(G4double argEnergy, G4int /* argCom
}
void G4DNACrossSectionDataSet::PrintData(void) const
void G4DNACrossSectionDataSet::PrintData() const
{
const G4int n = (G4int)NumberOfComponents();
const auto n = (G4int)NumberOfComponents();
G4cout << "The data set has " << n << " components" << G4endl;
G4cout << G4endl;
@@ -522,7 +522,7 @@ void G4DNACrossSectionDataSet::SetEnergiesData(G4DataVector* argEnergies,
{
G4VEMDataSet * component(components[argComponentId]);
if (component)
if (component != nullptr)
{
component->SetEnergiesData(argEnergies, argData, 0);
return;
@@ -545,7 +545,7 @@ void G4DNACrossSectionDataSet::SetLogEnergiesData(G4DataVector* argEnergies,
{
G4VEMDataSet * component(components[argComponentId]);
if (component)
if (component != nullptr)
{
component->SetLogEnergiesData(argEnergies, argData, argLogEnergies, argLogData, 0);
return;
@@ -564,7 +564,7 @@ void G4DNACrossSectionDataSet::CleanUpComponents()
{
while (!components.empty())
{
if (components.back()) delete components.back();
if (components.back() != nullptr) delete components.back();
components.pop_back();
}
}
@@ -33,7 +33,7 @@ G4DNAIndirectHit::G4DNAIndirectHit(const G4String& baseName,
const G4Molecule* molecule,
const G4ThreeVector& position,
G4double time) :
G4VDNAHit(), fpMolecule(molecule)
fpMolecule(molecule)
{
fBaseName = baseName;
fPosition = position;
@@ -42,7 +42,7 @@ G4DNAIndirectHit::G4DNAIndirectHit(const G4String& baseName,
G4DNAIndirectHit::~G4DNAIndirectHit()
{
if (fpMolecule != nullptr) delete fpMolecule;
delete fpMolecule;
fpMolecule = nullptr;
}
@@ -69,25 +69,25 @@ G4DNADamage::G4DNADamage()
G4DNADamage::~G4DNADamage()
{
for (G4int i = 0; i < (G4int) fIndirectHits.size(); ++i)
for (auto & fIndirectHit : fIndirectHits)
{
if (fIndirectHits[i]) delete fIndirectHits[i];
delete fIndirectHit;
}
fIndirectHits.clear();
}
void G4DNADamage::DeleteInstance()
{
if (fpInstance) delete fpInstance;
delete fpInstance;
fpInstance = nullptr;
}
void G4DNADamage::Reset()
{
fNIndirectDamage = 0;
for (G4int i = 0; i < (G4int) fIndirectHits.size(); ++i)
for (auto & fIndirectHit : fIndirectHits)
{
if (fIndirectHits[i]) delete fIndirectHits[i];
delete fIndirectHit;
}
fIndirectHits.clear();
}
@@ -38,7 +38,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4DNAEmfietzoglouWaterExcitationStructure::G4DNAEmfietzoglouWaterExcitationStructure(): nLevels(5)
G4DNAEmfietzoglouWaterExcitationStructure::G4DNAEmfietzoglouWaterExcitationStructure()
{
energyConstant.push_back(8.22*eV);
energyConstant.push_back(10.00*eV);
@@ -52,7 +52,7 @@ G4DNAEmfietzoglouWaterExcitationStructure::G4DNAEmfietzoglouWaterExcitationStruc
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4DNAEmfietzoglouWaterExcitationStructure::~G4DNAEmfietzoglouWaterExcitationStructure()
{ }
= default;
G4double G4DNAEmfietzoglouWaterExcitationStructure::ExcitationEnergy(G4int level)
{
@@ -38,7 +38,7 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4DNAEmfietzoglouWaterIonisationStructure::G4DNAEmfietzoglouWaterIonisationStructure(): nLevels(5)
G4DNAEmfietzoglouWaterIonisationStructure::G4DNAEmfietzoglouWaterIonisationStructure()
{
energyConstant.push_back(10.*eV);
energyConstant.push_back(13.*eV);
@@ -52,7 +52,7 @@ G4DNAEmfietzoglouWaterIonisationStructure::G4DNAEmfietzoglouWaterIonisationStruc
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4DNAEmfietzoglouWaterIonisationStructure::~G4DNAEmfietzoglouWaterIonisationStructure()
{ }
= default;
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
@@ -32,9 +32,9 @@
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4DNAGenericIonsManager * G4DNAGenericIonsManager :: Instance(void)
G4DNAGenericIonsManager * G4DNAGenericIonsManager :: Instance()
{
if (!theInstance)
if (theInstance == nullptr)
theInstance=new G4DNAGenericIonsManager;
return theInstance;
@@ -44,10 +44,10 @@ G4DNAGenericIonsManager * G4DNAGenericIonsManager :: Instance(void)
G4ParticleDefinition * G4DNAGenericIonsManager :: GetIon(const G4String & name)
{
IonsMap::const_iterator i(map.find(name));
auto i = map.find(name);
if (i==map.end())
return 0;
return nullptr;
return i->second;
}
@@ -81,7 +81,7 @@ G4DNAGenericIonsManager :: G4DNAGenericIonsManager()
0, +1, 0,
0, 0, 0,
"DNAion", +26, +56, 0,
true, -1.0, 0,
true, -1.0, nullptr,
false, "", 0,
0.0);
@@ -90,7 +90,7 @@ G4DNAGenericIonsManager :: G4DNAGenericIonsManager()
0, +1, 0,
0, 0, 0,
"DNAion", +14, +28, 0,
true, -1.0, 0,
true, -1.0, nullptr,
false, "", 0,
0.0);
@@ -101,7 +101,7 @@ G4DNAGenericIonsManager :: G4DNAGenericIonsManager()
0, +1, 0,
0, 0, 0,
"DNAion", +8, +16, 0,
true, -1.0, 0,
true, -1.0, nullptr,
false, "", 0,
0.0);
@@ -111,7 +111,7 @@ G4DNAGenericIonsManager :: G4DNAGenericIonsManager()
0, +1, 0,
0, 0, 0,
"DNAion", +7, +14, 0,
true, -1.0, 0,
true, -1.0, nullptr,
false, "", 0,
0.0);
@@ -120,7 +120,7 @@ G4DNAGenericIonsManager :: G4DNAGenericIonsManager()
0, +1, 0,
0, 0, 0,
"DNAion", +6, +12, 0,
true, -1.0, 0,
true, -1.0, nullptr,
false, "", 0,
0.0);
@@ -129,7 +129,7 @@ G4DNAGenericIonsManager :: G4DNAGenericIonsManager()
0, +1, 0,
0, 0, 0,
"DNAion", +2, +4, 0,
true, -1.0, 0,
true, -1.0, nullptr,
false, "", 0,
0.0);
@@ -137,28 +137,28 @@ G4DNAGenericIonsManager :: G4DNAGenericIonsManager()
1, +1, 0,
0, 0, 0,
"DNAion", +1, +4, 0,
true, -1.0, 0, false,
true, -1.0, nullptr, false,
"", 0, 0.0);
hydrogen= new G4DNAIons("hydrogen", 0.9382723*GeV, 0.0*MeV, +0.0*eplus,
0, +1, 0,
0, 0, 0,
"DNAion", +1, +1, 0,
true, -1.0, 0, false,
true, -1.0, nullptr, false,
"", 0, 0.0);
positronium1s= new G4DNAIons("Ps-1s", 2*electron_mass_c2, 0.0*MeV, +0.0*eplus,
0, 0, 0,
0, 0, 0,
"DNAion", 0, 0, 0,
true, -1.0, 0, false,
true, -1.0, nullptr, false,
"", 0, 0.0);
positronium2s= new G4DNAIons("Ps-2s", 2*electron_mass_c2, 0.0*MeV, +0.0*eplus,
0, 0, 0,
0, 0, 0,
"DNAion", 0, 0, 0,
true, -1.0, 0, false,
true, -1.0, nullptr, false,
"", 0, 0.0);
@@ -179,5 +179,5 @@ G4DNAGenericIonsManager :: G4DNAGenericIonsManager()
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4DNAGenericIonsManager * G4DNAGenericIonsManager::theInstance(0);
G4DNAGenericIonsManager * G4DNAGenericIonsManager::theInstance(nullptr);
@@ -73,8 +73,7 @@ G4DNAIons::G4DNAIons(
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
G4DNAIons::~G4DNAIons()
{
}
= default;
@@ -45,11 +45,9 @@ G4DNAMesh::Voxel& G4DNAMesh::GetVoxel(const Index& key)
fIndexMap[key] = G4int(fVoxelVector.size() - 1);
return voxel;
}
else
{
auto index = fIndexMap[key];
return fVoxelVector[index];
}
auto index = fIndexMap[key];
return fVoxelVector[index];
}
G4DNAMesh::G4DNAMesh(const G4DNABoundingBox& boundingBox, G4int pixel)
@@ -156,27 +154,27 @@ G4DNAMesh::FindNeighboringVoxels(const Index& index) const
if(index.x - 1 >= 0)
{
neighbors.push_back(Index(index.x - 1, index.y, index.z));
neighbors.emplace_back(index.x - 1, index.y, index.z);
}
if(index.y - 1 >= 0)
{
neighbors.push_back(Index(index.x, index.y - 1, index.z));
neighbors.emplace_back(index.x, index.y - 1, index.z);
}
if(index.z - 1 >= 0)
{
neighbors.push_back(Index(index.x, index.y, index.z - 1));
neighbors.emplace_back(index.x, index.y, index.z - 1);
}
if(index.x + 1 < xMax)
{
neighbors.push_back(Index(index.x + 1, index.y, index.z));
neighbors.emplace_back(index.x + 1, index.y, index.z);
}
if(index.y + 1 < yMax)
{
neighbors.push_back(Index(index.x, index.y + 1, index.z));
neighbors.emplace_back(index.x, index.y + 1, index.z);
}
if(index.z + 1 < zMax)
{
neighbors.push_back(Index(index.x, index.y, index.z + 1));
neighbors.emplace_back(index.x, index.y, index.z + 1);
}
return neighbors;
@@ -27,15 +27,15 @@
// Author: Mathieu Karamitros
//
#include <utility>
#include "G4DNAMolecularMaterial.hh"
#include "G4AutoLock.hh"
#include "G4Material.hh"
#include "G4MoleculeTable.hh"
#include "G4StateManager.hh"
#include "G4Threading.hh"
#include "G4AutoLock.hh"
#include "G4StateManager.hh"
#include "G4MoleculeTable.hh"
#include <utility>
using namespace std;
@@ -58,16 +58,16 @@ bool CompareMaterial::operator()(const G4Material* mat1,
const G4Material* baseMat1 = mat1->GetBaseMaterial();
const G4Material* baseMat2 = mat2->GetBaseMaterial();
if (((baseMat1 != nullptr) || (baseMat2 != nullptr)) == false){
if ((baseMat1 == nullptr) && (baseMat2 == nullptr)){
// None of the materials derives from a base material
return mat1 < mat2;
}
else if ((baseMat1 != nullptr) && (baseMat2 != nullptr)){
if ((baseMat1 != nullptr) && (baseMat2 != nullptr)){
// Both materials derive from a base material
return baseMat1 < baseMat2;
}
else if ((baseMat1 != nullptr) && (baseMat2 == nullptr)){
if ((baseMat1 != nullptr) && (baseMat2 == nullptr)){
// Only the material 1 derives from a base material
return baseMat1 < mat2;
}
@@ -79,7 +79,7 @@ bool CompareMaterial::operator()(const G4Material* mat1,
G4DNAMolecularMaterial* G4DNAMolecularMaterial::Instance()
{
if (!fInstance) fInstance = new G4DNAMolecularMaterial();
if (fInstance == nullptr) fInstance = new G4DNAMolecularMaterial();
return fInstance;
}
@@ -136,8 +136,7 @@ void G4DNAMolecularMaterial::Clear()
//------------------------------------------------------------------------------
G4DNAMolecularMaterial::G4DNAMolecularMaterial() :
G4VStateDependent()
G4DNAMolecularMaterial::G4DNAMolecularMaterial()
{
Create();
}
@@ -155,25 +154,6 @@ G4bool G4DNAMolecularMaterial::Notify(G4ApplicationState requestedState)
//------------------------------------------------------------------------------
G4DNAMolecularMaterial::G4DNAMolecularMaterial(
const G4DNAMolecularMaterial& /*rhs*/) :
G4VStateDependent()
{
Create();
}
//------------------------------------------------------------------------------
G4DNAMolecularMaterial&
G4DNAMolecularMaterial::operator=(const G4DNAMolecularMaterial& rhs)
{
if (this == &rhs) return *this;
Create();
return *this;
}
//------------------------------------------------------------------------------
G4DNAMolecularMaterial::~G4DNAMolecularMaterial()
{
Clear();
@@ -216,7 +196,7 @@ void G4DNAMolecularMaterial::Initialize()
void G4DNAMolecularMaterial::InitializeDensity()
{
if (fpCompFractionTable){
if (fpCompFractionTable != nullptr){
const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
fpCompDensityTable = new vector<ComponentMap>(
G4Material::GetMaterialTable()->size());
@@ -233,10 +213,9 @@ void G4DNAMolecularMaterial::InitializeDensity()
parentDensity = parentMat->GetDensity();
for (auto it = massFractionComp.cbegin();
it != massFractionComp.cend(); ++it){
compMat = it->first;
massFraction = it->second;
for (const auto& it : massFractionComp){
compMat = it.first;
massFraction = it.second;
densityComp[compMat] = massFraction * parentDensity;
compMat = nullptr;
massFraction = -1;
@@ -257,7 +236,7 @@ void G4DNAMolecularMaterial::InitializeDensity()
void G4DNAMolecularMaterial::InitializeNumMolPerVol()
{
if (fpCompDensityTable){
if (fpCompDensityTable != nullptr){
fpCompNumMolPerVolTable = new vector<ComponentMap>(fNMaterials);
const G4Material* compMat(nullptr);
@@ -267,9 +246,8 @@ void G4DNAMolecularMaterial::InitializeNumMolPerVol()
ComponentMap& densityComp = (*fpCompDensityTable)[i];
ComponentMap& numMolPerVol = (*fpCompNumMolPerVolTable)[i];
for (auto it = massFractionComp.cbegin();
it != massFractionComp.cend(); ++it){
compMat = it->first;
for (auto& it : massFractionComp){
compMat = it.first;
numMolPerVol[compMat] = densityComp[compMat]
/ compMat->GetMassOfMolecule();
compMat = nullptr;
@@ -348,7 +326,7 @@ const std::vector<G4double>*
G4DNAMolecularMaterial::
GetDensityTableFor(const G4Material* lookForMaterial) const
{
if (!fpCompDensityTable){
if (fpCompDensityTable == nullptr){
if (fIsInitialized){
G4ExceptionDescription exceptionDescription;
exceptionDescription
@@ -383,7 +361,7 @@ GetDensityTableFor(const G4Material* lookForMaterial) const
const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
std::vector<G4double>* output = new std::vector<G4double>(materialTable->size());
auto output = new std::vector<G4double>(materialTable->size());
ComponentMap::const_iterator it;
@@ -420,7 +398,7 @@ const std::vector<G4double>* G4DNAMolecularMaterial::GetNumMolPerVolTableFor(
{
if(lookForMaterial==nullptr) return nullptr;
if (!fpCompNumMolPerVolTable){
if (fpCompNumMolPerVolTable == nullptr){
if (fIsInitialized){
G4ExceptionDescription exceptionDescription;
exceptionDescription
@@ -454,7 +432,7 @@ const std::vector<G4double>* G4DNAMolecularMaterial::GetNumMolPerVolTableFor(
const G4MaterialTable* materialTable = G4Material::GetMaterialTable();
std::vector<G4double>* output = new std::vector<G4double>(materialTable->size());
auto output = new std::vector<G4double>(materialTable->size());
ComponentMap::const_iterator it;
@@ -522,7 +500,7 @@ G4MolecularConfiguration*
G4DNAMolecularMaterial::
GetMolecularConfiguration(const G4Material* material) const
{
G4int material_id = (G4int)material->GetIndex();
auto material_id = (G4int)material->GetIndex();
auto it = fMaterialToMolecularConf.find(material_id);
if(it == fMaterialToMolecularConf.cend()) return nullptr;
return it->second;
@@ -536,7 +514,7 @@ SetMolecularConfiguration(const G4Material* material,
G4MolecularConfiguration* molConf)
{
assert(material != nullptr);
G4int material_id = (G4int)material->GetIndex();
auto material_id = (G4int)material->GetIndex();
fMaterialToMolecularConf[material_id] = molConf;
}
@@ -547,7 +525,7 @@ G4DNAMolecularMaterial::SetMolecularConfiguration(const G4Material* material,
const G4String& molUserID)
{
assert(material != nullptr);
G4int material_id = (G4int)material->GetIndex();
auto material_id = (G4int)material->GetIndex();
fMaterialToMolecularConf[material_id] =
G4MoleculeTable::Instance()->GetConfiguration(molUserID, true);
}
@@ -348,7 +348,7 @@ double G4DNAMolecularReactionData::ScaledParameterization(double temp_K,
G4DNAMolecularReactionTable* G4DNAMolecularReactionTable::GetReactionTable()
{
if (!fpInstance)
if (fpInstance == nullptr)
{
fpInstance = new G4DNAMolecularReactionTable();
}
@@ -359,7 +359,7 @@ G4DNAMolecularReactionTable* G4DNAMolecularReactionTable::GetReactionTable()
G4DNAMolecularReactionTable* G4DNAMolecularReactionTable::Instance()
{
if (!fpInstance)
if (fpInstance == nullptr)
{
fpInstance = new G4DNAMolecularReactionTable();
}
@@ -370,20 +370,18 @@ G4DNAMolecularReactionTable* G4DNAMolecularReactionTable::Instance()
void G4DNAMolecularReactionTable::DeleteInstance()
{
if (fpInstance)
{
delete fpInstance;
}
fpInstance = nullptr;
}
//_____________________________________________________________________________________
G4DNAMolecularReactionTable::G4DNAMolecularReactionTable()
: G4ITReactionTable()
, fVerbose(false)
, fGeometry(nullptr)
, fpMessenger(new G4ReactionTableMessenger(this))
:
fpMessenger(new G4ReactionTableMessenger(this))
{
}
@@ -427,7 +425,7 @@ void G4DNAMolecularReactionTable::PrintTable(G4VDNAReactionModel* pReactionModel
G4IosFlagsSaver iosfs(G4cout);
if (pReactionModel && !(pReactionModel->GetReactionTable()))
if ((pReactionModel != nullptr) && ((pReactionModel->GetReactionTable()) == nullptr))
{
pReactionModel->SetReactionTable(this);
}
@@ -441,20 +439,20 @@ void G4DNAMolecularReactionTable::PrintTable(G4VDNAReactionModel* pReactionModel
std::size_t nbPrintable = fReactantsMV.size() * fReactantsMV.size();
G4String* outputReaction = new G4String[nbPrintable];
G4String* outputReactionRate = new G4String[nbPrintable];
G4String* outputRange = new G4String[nbPrintable];
auto outputReaction = new G4String[nbPrintable];
auto outputReactionRate = new G4String[nbPrintable];
auto outputRange = new G4String[nbPrintable];
G4int n = 0;
for (itReactives = fReactantsMV.begin(); itReactives != fReactantsMV.end();
++itReactives)
{
Reactant* moleculeA = (Reactant*)itReactives->first;
auto moleculeA = (Reactant*)itReactives->first;
const vector<Reactant*>* reactivesVector = CanReactWith(moleculeA);
if (pReactionModel) pReactionModel->InitialiseToPrint(moleculeA);
if (pReactionModel != nullptr) pReactionModel->InitialiseToPrint(moleculeA);
G4int nbReactants = (G4int)fReactantsMV[itReactives->first].size();
auto nbReactants = (G4int)fReactantsMV[itReactives->first].size();
for (G4int iReact = 0; iReact < nbReactants; iReact++)
{
@@ -470,7 +468,7 @@ void G4DNAMolecularReactionTable::PrintTable(G4VDNAReactionModel* pReactionModel
G4int nbProducts = reactionData->GetNbProducts();
if (nbProducts)
if (nbProducts != 0)
{
outputReaction[n] += " -> " + reactionData->GetProduct(0)->GetName();
@@ -492,7 +490,7 @@ void G4DNAMolecularReactionTable::PrintTable(G4VDNAReactionModel* pReactionModel
//-----------------------------------------------------------
// Calculation of the Interaction Range
G4double interactionRange = -1;
if (pReactionModel) interactionRange =
if (pReactionModel != nullptr) interactionRange =
pReactionModel->GetReactionRadius(iReact);
if (interactionRange != -1)
@@ -540,24 +538,24 @@ void G4DNAMolecularReactionTable::PrintTable(G4VDNAReactionModel* pReactionModel
G4String* title;
if (pReactionModel) title = new G4String[3];
if (pReactionModel != nullptr) title = new G4String[3];
else title = new G4String[2];
title[0] = "Reaction";
title[1] = "Reaction Rate [dm3/(mol*s)]";
if (pReactionModel) title[2] =
if (pReactionModel != nullptr) title[2] =
"Interaction Range for chosen reaction model [nm]";
G4cout << setfill(' ') << setw(maxlengthOutputReaction) << left << title[0]
<< setw(maxlengthOutputReactionRate) << left << title[1];
if (pReactionModel) G4cout << setw(2) << left << title[2];
if (pReactionModel != nullptr) G4cout << setw(2) << left << title[2];
G4cout << G4endl;
G4cout.fill('-');
if (pReactionModel) G4cout.width(
if (pReactionModel != nullptr) G4cout.width(
maxlengthOutputReaction + 2 + maxlengthOutputReactionRate + 2
+ (G4int)title[2].length());
else G4cout.width(maxlengthOutputReaction + 2 + maxlengthOutputReactionRate);
@@ -570,12 +568,12 @@ void G4DNAMolecularReactionTable::PrintTable(G4VDNAReactionModel* pReactionModel
<< setw(maxlengthOutputReactionRate) << left
<< outputReactionRate[i];
if (pReactionModel) G4cout << setw(2) << left << outputRange[i];
if (pReactionModel != nullptr) G4cout << setw(2) << left << outputRange[i];
G4cout << G4endl;
G4cout.fill('-');
if (pReactionModel) G4cout.width(
if (pReactionModel != nullptr) G4cout.width(
maxlengthOutputReaction + 2 + maxlengthOutputReactionRate + 2
+ (G4int)title[2].length());
else G4cout.width(
@@ -618,9 +616,11 @@ G4DNAMolecularReactionTable::GetReactionData(Reactant* pReactant1,
->GetName();
G4Exception("G4MolecularInteractionTable::GetReactionData", "",
FatalErrorInArgument, errMsg);
// Though the above is Fatal and will terminate program, put return in to quieten Coverity
return nullptr;
}
ReactionDataMap::mapped_type::const_iterator it2 = it1->second.find(pReactant2);
auto it2 = it1->second.find(pReactant2);
if (it2 == it1->second.end())
{
@@ -660,7 +660,7 @@ G4DNAMolecularReactionTable::CanReactWith(Reactant* pMolecule) const
G4String errMsg = "No reaction table was implemented";
G4Exception("G4MolecularInteractionTable::CanReactWith", "",
FatalErrorInArgument, errMsg);
return 0;
return nullptr;
}
auto itReactivesMap = fReactantsMV.find(pMolecule);
@@ -708,7 +708,7 @@ G4DNAMolecularReactionTable::GetReativesNData(const G4MolecularConfiguration* mo
FatalErrorInArgument, errMsg);
}
ReactionDataMap::const_iterator itReactivesMap = fReactionData.find(molecule);
auto itReactivesMap = fReactionData.find(molecule);
if (itReactivesMap == fReactionData.end())
{
@@ -721,7 +721,7 @@ G4DNAMolecularReactionTable::GetReativesNData(const G4MolecularConfiguration* mo
G4cout << "You are checking reactants for : " << molecule->GetName() << G4endl;
G4cout << " the number of reactants is : " << itReactivesMap->second.size() << G4endl;
SpecificDataList::const_iterator itProductsVector = itReactivesMap->second.begin();
auto itProductsVector = itReactivesMap->second.begin();
for (; itProductsVector != itReactivesMap->second.end(); itProductsVector++)
{
@@ -749,6 +749,8 @@ G4DNAMolecularReactionTable::GetReactionData(const G4MolecularConfiguration* mol
G4String errMsg = "No reaction table was implemented for this molecule Definition : "
+ molecule->GetName();
G4Exception("G4MolecularInteractionTable::GetReactionData", "", FatalErrorInArgument, errMsg);
// Though the above is Fatal and will terminate program, put return in to quieten Coverity
return nullptr;
}
return &(it->second);
@@ -234,19 +234,19 @@ size_t G4DNAPTBIonisationStructure::ReplaceMaterial(const size_t& materialID)
if (fpBackbone_THF != nullptr && materialID == fpBackbone_THF->GetIndex()) {
return fpTHF->GetIndex();
}
else if (fpBackbone_TMP != nullptr && materialID == fpBackbone_TMP->GetIndex()) {
if (fpBackbone_TMP != nullptr && materialID == fpBackbone_TMP->GetIndex()) {
return fpTMP->GetIndex();
}
else if (fpAdenine_PU != nullptr && materialID == fpAdenine_PU->GetIndex()) {
if (fpAdenine_PU != nullptr && materialID == fpAdenine_PU->GetIndex()) {
return fpPU->GetIndex();
}
else if (fpGuanine_PU != nullptr && materialID == fpGuanine_PU->GetIndex()) {
if (fpGuanine_PU != nullptr && materialID == fpGuanine_PU->GetIndex()) {
return fpPU->GetIndex();
}
else if (fpThymine_PY != nullptr && materialID == fpThymine_PY->GetIndex()) {
if (fpThymine_PY != nullptr && materialID == fpThymine_PY->GetIndex()) {
return fpPY->GetIndex();
}
else if (fpCytosine_PY != nullptr && materialID == fpCytosine_PY->GetIndex()) {
if (fpCytosine_PY != nullptr && materialID == fpCytosine_PY->GetIndex()) {
return fpPY->GetIndex();
}
return materialID;
@@ -24,30 +24,26 @@
// ********************************************************************
//
//
#include <memory>
#include "G4DNAScavengerMaterial.hh"
#include "G4StateManager.hh"
#include "G4DNAMolecularMaterial.hh"
#include "G4PhysicalConstants.hh"
#include "G4MolecularConfiguration.hh"
#include "G4SystemOfUnits.hh"
#include "G4DNABoundingBox.hh"
#include "G4VChemistryWorld.hh"
#include "G4DNAMolecularMaterial.hh"
#include "G4MolecularConfiguration.hh"
#include "G4PhysicalConstants.hh"
#include "G4Scheduler.hh"
#include "G4StateManager.hh"
#include "G4SystemOfUnits.hh"
#include "G4UnitsTable.hh"
#include "G4MoleculeTable.hh"
#include "G4VChemistryWorld.hh"
#include <memory>
using namespace std;
//------------------------------------------------------------------------------
G4DNAScavengerMaterial::G4DNAScavengerMaterial(
G4VChemistryWorld* pChemistryInfo)
: G4VScavengerMaterial()
, fpChemistryInfo(pChemistryInfo)
, fIsInitialized(false)
, fCounterAgainstTime(false)
, fVerbose(0)
G4DNAScavengerMaterial::G4DNAScavengerMaterial(G4VChemistryWorld* pChemistryInfo)
: fpChemistryInfo(pChemistryInfo), fIsInitialized(false), fCounterAgainstTime(false), fVerbose(0)
{
Initialize();
}
@@ -56,87 +52,73 @@ G4DNAScavengerMaterial::G4DNAScavengerMaterial(
void G4DNAScavengerMaterial::Initialize()
{
if(fIsInitialized)
{
if (fIsInitialized) {
return;
}
if(fpChemistryInfo->size() == 0)
{
if (fpChemistryInfo->size() == 0) {
G4cout << "G4DNAScavengerMaterial existed but empty" << G4endl;
}
Reset();
fIsInitialized = true;
}
G4double G4DNAScavengerMaterial::GetNumberMoleculePerVolumeUnitForMaterialConf(
MolType matConf) const
G4double
G4DNAScavengerMaterial::GetNumberMoleculePerVolumeUnitForMaterialConf(MolType matConf) const
{
// no change these molecules
if(G4MoleculeTable::Instance()->GetConfiguration("H2O") == matConf)
{
if (fH2O == matConf) {
G4ExceptionDescription exceptionDescription;
exceptionDescription << "matConf : "<<matConf->GetName();
G4Exception("G4DNAScavengerMaterial::GetNumberMoleculePerVolumeUnitForMaterialConf", "G4DNAScavengerMaterial001",
FatalErrorInArgument, exceptionDescription);
exceptionDescription << "matConf : " << matConf->GetName();
G4Exception("G4DNAScavengerMaterial::GetNumberMoleculePerVolumeUnitForMaterialConf",
"G4DNAScavengerMaterial001", FatalErrorInArgument, exceptionDescription);
}
auto iter = fScavengerTable.find(matConf);
if(iter == fScavengerTable.end())
{
if (iter == fScavengerTable.end()) {
return 0;
}
else
{
if(iter->second >= 1)
{
return (floor)(iter->second);
}
else
{
return 0;
}
if (iter->second >= 1) {
return (floor)(iter->second);
}
return 0;
}
void G4DNAScavengerMaterial::ReduceNumberMoleculePerVolumeUnitForMaterialConf(
MolType matConf, G4double time)
void G4DNAScavengerMaterial::ReduceNumberMoleculePerVolumeUnitForMaterialConf(MolType matConf,
G4double time)
{
// no change these molecules
if(G4MoleculeTable::Instance()->GetConfiguration("H2O") == matConf ||
G4MoleculeTable::Instance()->GetConfiguration("H3Op(B)") ==
matConf || // suppose that pH is not changed during simu
G4MoleculeTable::Instance()->GetConfiguration("OHm(B)") == matConf)
if (fH2O == matConf || fH3Op == matConf || // suppose that pH is not changed during simu
fHOm == matConf)
{
// G4cout<<"moletype : "<<matConf->GetName()<<G4endl;
// kobs is already counted these molecule concentrations
return;
}
if(!find(matConf)) // matConf must greater than 0
if (!find(matConf)) // matConf must greater than 0
{
return;
}
fScavengerTable[matConf]--;
if(fScavengerTable[matConf] < 0) // projection
if (fScavengerTable[matConf] < 0) // projection
{
assert(false);
}
if(fCounterAgainstTime)
{
if (fCounterAgainstTime) {
RemoveAMoleculeAtTime(matConf, time);
}
}
void G4DNAScavengerMaterial::AddNumberMoleculePerVolumeUnitForMaterialConf(
MolType matConf, G4double time)
void G4DNAScavengerMaterial::AddNumberMoleculePerVolumeUnitForMaterialConf(MolType matConf,
G4double time)
{
// no change these molecules
if(G4MoleculeTable::Instance()->GetConfiguration("H2O") == matConf ||
G4MoleculeTable::Instance()->GetConfiguration("H3Op(B)") ==
matConf || // pH has no change
G4MoleculeTable::Instance()->GetConfiguration("OHm(B)") == matConf)
if (fH2O == matConf || fH3Op == matConf || // pH has no change
G4MoleculeTable::Instance()->GetConfiguration("OHm(B)") == matConf)
{
// G4cout<<"moletype : "<<matConf->GetName()<<G4endl;
// kobs is already counted these molecule concentrations
@@ -144,14 +126,13 @@ void G4DNAScavengerMaterial::AddNumberMoleculePerVolumeUnitForMaterialConf(
}
auto it = fScavengerTable.find(matConf);
if(it == fScavengerTable.end()) // matConf must be in fScavengerTable
if (it == fScavengerTable.end()) // matConf must be in fScavengerTable
{
return;
}
fScavengerTable[matConf]++;
if(fCounterAgainstTime)
{
if (fCounterAgainstTime) {
AddAMoleculeAtTime(matConf, time);
}
}
@@ -159,45 +140,36 @@ void G4DNAScavengerMaterial::AddNumberMoleculePerVolumeUnitForMaterialConf(
void G4DNAScavengerMaterial::PrintInfo()
{
auto pConfinedBox = fpChemistryInfo->GetChemistryBoundary();
auto iter = fpChemistryInfo->begin();
G4cout << "**************************************************************"
<< G4endl;
for(; iter != fpChemistryInfo->end(); iter++)
{
auto iter = fpChemistryInfo->begin();
G4cout << "**************************************************************" << G4endl;
for (; iter != fpChemistryInfo->end(); iter++) {
auto containedConf = iter->first;
// auto concentration = iter->second;
auto concentration =
fScavengerTable[containedConf] / (Avogadro * pConfinedBox->Volume());
auto concentration = fScavengerTable[containedConf] / (Avogadro * pConfinedBox->Volume());
G4cout << "Scavenger:" << containedConf->GetName() << " : "
<< concentration / 1.0e-6 /*mm3 to L*/ << " (M) with : "
<< fScavengerTable[containedConf] << " (molecules)"
<< "in: " << pConfinedBox->Volume() / (um * um * um) << " (um3)"
<< G4endl;
if(fScavengerTable[containedConf] < 1)
{
<< "in: " << pConfinedBox->Volume() / (um * um * um) << " (um3)" << G4endl;
if (fScavengerTable[containedConf] < 1) {
G4cout << "!!!!!!!!!!!!! this molecule has less one molecule for "
"considered volume"
<< G4endl;
// assert(false);
}
if(fVerbose != 0)
{
if (fVerbose != 0) {
Dump();
}
}
G4cout << "**************************************************************"
<< G4endl;
G4cout << "**************************************************************" << G4endl;
}
void G4DNAScavengerMaterial::Reset()
{
if(fpChemistryInfo == nullptr)
{
if (fpChemistryInfo == nullptr) {
return;
}
if(fpChemistryInfo->size() == 0)
{
if (fpChemistryInfo->size() == 0) {
return;
}
@@ -206,57 +178,48 @@ void G4DNAScavengerMaterial::Reset()
fpLastSearch.reset(nullptr);
auto pConfinedBox = fpChemistryInfo->GetChemistryBoundary();
auto iter = fpChemistryInfo->begin();
for(; iter != fpChemistryInfo->end(); iter++)
{
auto iter = fpChemistryInfo->begin();
for (; iter != fpChemistryInfo->end(); iter++) {
auto containedConf = iter->first;
auto concentration = iter->second;
fScavengerTable[containedConf] =
floor(Avogadro * concentration * pConfinedBox->Volume());
fScavengerTable[containedConf] = floor(Avogadro * concentration * pConfinedBox->Volume());
fCounterMap[containedConf][1 * picosecond] =
floor(Avogadro * concentration * pConfinedBox->Volume());
}
if(fVerbose != 0){PrintInfo();}
if (fVerbose != 0) {
PrintInfo();
}
}
//------------------------------------------------------------------------------
void G4DNAScavengerMaterial::AddAMoleculeAtTime(
MolType molecule, G4double time, const G4ThreeVector* /*position*/,
int number)
void G4DNAScavengerMaterial::AddAMoleculeAtTime(MolType molecule, G4double time,
const G4ThreeVector* /*position*/, int number)
{
if(fVerbose != 0)
{
G4cout << "G4DNAScavengerMaterial::AddAMoleculeAtTime : "
<< molecule->GetName() << " at time : " << G4BestUnit(time, "Time")
<< G4endl;
if (fVerbose != 0) {
G4cout << "G4DNAScavengerMaterial::AddAMoleculeAtTime : " << molecule->GetName()
<< " at time : " << G4BestUnit(time, "Time") << G4endl;
}
auto counterMap_i = fCounterMap.find(molecule);
if(counterMap_i == fCounterMap.end())
{
if (counterMap_i == fCounterMap.end()) {
fCounterMap[molecule][time] = number;
}
else if(counterMap_i->second.empty())
{
else if (counterMap_i->second.empty()) {
counterMap_i->second[time] = number;
}
else
{
else {
auto end = counterMap_i->second.rbegin();
if(end->first <= time || fabs(end->first - time) <=
G4::MoleculeCounter::TimePrecision::fPrecision)
{
G4double newValue = end->second + number;
if (end->first <= time
|| fabs(end->first - time) <= G4::MoleculeCounter::TimePrecision::fPrecision) {
G4double newValue = end->second + number;
counterMap_i->second[time] = newValue;
if(newValue != (floor)(fScavengerTable[molecule])) // protection
if (newValue != (floor)(fScavengerTable[molecule])) // protection
{
G4String errMsg = "You are trying to add wrong molecule ";
G4Exception("AddAMoleculeAtTime", "",
FatalErrorInArgument, errMsg);
G4Exception("AddAMoleculeAtTime", "", FatalErrorInArgument, errMsg);
}
}
}
@@ -264,88 +227,73 @@ void G4DNAScavengerMaterial::AddAMoleculeAtTime(
//------------------------------------------------------------------------------
void G4DNAScavengerMaterial::RemoveAMoleculeAtTime(
MolType pMolecule, G4double time, const G4ThreeVector* /*position*/,
int number)
void G4DNAScavengerMaterial::RemoveAMoleculeAtTime(MolType pMolecule, G4double time,
const G4ThreeVector* /*position*/, int number)
{
NbMoleculeInTime& nbMolPerTime = fCounterMap[pMolecule];
if(fVerbose != 0)
{
if (fVerbose != 0) {
auto it_ = nbMolPerTime.rbegin();
G4cout << "G4DNAScavengerMaterial::RemoveAMoleculeAtTime : "
<< pMolecule->GetName() << " at time : " << G4BestUnit(time, "Time")
G4cout << "G4DNAScavengerMaterial::RemoveAMoleculeAtTime : " << pMolecule->GetName()
<< " at time : " << G4BestUnit(time, "Time")
<< " form : " << it_->second << G4endl;
}
if(nbMolPerTime.empty())
{
if (nbMolPerTime.empty()) {
Dump();
G4String errMsg = "You are trying to remove molecule " +
pMolecule->GetName() +
" from the counter while this kind of molecules has not "
"been registered yet";
G4Exception("G4DNAScavengerMaterial::RemoveAMoleculeAtTime", "",
FatalErrorInArgument, errMsg);
G4Exception("G4DNAScavengerMaterial::RemoveAMoleculeAtTime", "", FatalErrorInArgument, errMsg);
return;
}
else
auto it = nbMolPerTime.rbegin();
if (it == nbMolPerTime.rend()) {
it--;
G4String errMsg = "There was no " + pMolecule->GetName()
+ " recorded at the time or even before the time asked";
G4Exception("G4DNAScavengerMaterial::RemoveAMoleculeAtTime", "", FatalErrorInArgument, errMsg);
}
G4double finalN = it->second - number;
if (finalN < 0) {
Dump();
G4cout << "fScavengerTable : " << pMolecule->GetName() << " : " << (fScavengerTable[pMolecule])
<< G4endl;
G4ExceptionDescription errMsg;
errMsg << "After removal of " << number << " species of "
<< " " << it->second << " " << pMolecule->GetName() << " the final number at time "
<< G4BestUnit(time, "Time") << " is less than zero and so not valid." << G4endl;
G4cout << " Global time is " << G4BestUnit(G4Scheduler::Instance()->GetGlobalTime(), "Time")
<< ". Previous selected time is " << G4BestUnit(it->first, "Time") << G4endl;
G4Exception("G4DNAScavengerMaterial::RemoveAMoleculeAtTime", "N_INF_0", FatalException, errMsg);
}
nbMolPerTime[time] = finalN;
if (finalN != (floor)(fScavengerTable[pMolecule])) // protection
{
auto it = nbMolPerTime.rbegin();
if(it == nbMolPerTime.rend())
{
it--;
G4String errMsg = "There was no " + pMolecule->GetName() +
" recorded at the time or even before the time asked";
G4Exception("G4DNAScavengerMaterial::RemoveAMoleculeAtTime", "",
FatalErrorInArgument, errMsg);
}
G4double finalN = it->second - number;
if(finalN < 0)
{
Dump();
G4cout << "fScavengerTable : " << pMolecule->GetName() << " : "
<< (fScavengerTable[pMolecule]) << G4endl;
G4ExceptionDescription errMsg;
errMsg << "After removal of " << number << " species of "
<< " " << it->second << " " << pMolecule->GetName()
<< " the final number at time " << G4BestUnit(time, "Time")
<< " is less than zero and so not valid." << G4endl;
G4cout << " Global time is "
<< G4BestUnit(G4Scheduler::Instance()->GetGlobalTime(), "Time")
<< ". Previous selected time is " << G4BestUnit(it->first, "Time")
<< G4endl;
G4Exception("G4DNAScavengerMaterial::RemoveAMoleculeAtTime", "N_INF_0",
FatalException, errMsg);
}
nbMolPerTime[time] = finalN;
if(finalN != (floor)(fScavengerTable[pMolecule])) // protection
{
assert(false);
}
assert(false);
}
}
void G4DNAScavengerMaterial::Dump()
{
auto pConfinedBox = fpChemistryInfo->GetChemistryBoundary();
auto V = pConfinedBox->Volume();
for(const auto& it : fCounterMap)
{
auto V = pConfinedBox->Volume();
for (const auto& it : fCounterMap) {
auto pReactant = it.first;
G4cout << " --- > For " << pReactant->GetName() << G4endl;
for(const auto& it2 : it.second)
{
for (const auto& it2 : it.second) {
G4cout << " " << G4BestUnit(it2.first, "Time") << " "
<< it2.second / (Avogadro * V * 1.0e-6 /*mm3 to L*/) << G4endl;
}
@@ -354,51 +302,40 @@ void G4DNAScavengerMaterial::Dump()
int64_t G4DNAScavengerMaterial::GetNMoleculesAtTime(MolType molecule, G4double time)
{
if(!fCounterAgainstTime)
{
if (!fCounterAgainstTime) {
G4cout << "fCounterAgainstTime == false" << G4endl;
assert(false);
}
G4bool sameTypeOfMolecule = SearchTimeMap(molecule);
auto output = SearchUpperBoundTime(time, sameTypeOfMolecule);
if(output < 0)
{
if (output < 0) {
G4ExceptionDescription errMsg;
errMsg << "N molecules not valid < 0 : "<<
molecule->GetName() <<" N : "<< output << G4endl;
G4Exception("G4DNAScavengerMaterial::GetNMoleculesAtTime", "",
FatalErrorInArgument, errMsg);
errMsg << "N molecules not valid < 0 : " << molecule->GetName() << " N : " << output << G4endl;
G4Exception("G4DNAScavengerMaterial::GetNMoleculesAtTime", "", FatalErrorInArgument, errMsg);
}
return output;
}
G4bool G4DNAScavengerMaterial::SearchTimeMap(MolType molecule)
{
if(fpLastSearch == nullptr)
{
if (fpLastSearch == nullptr) {
fpLastSearch = std::make_unique<Search>();
}
else
{
if(fpLastSearch->fLowerBoundSet &&
fpLastSearch->fLastMoleculeSearched->first == molecule)
{
else {
if (fpLastSearch->fLowerBoundSet && fpLastSearch->fLastMoleculeSearched->first == molecule) {
return true;
}
}
auto mol_it = fCounterMap.find(molecule);
auto mol_it = fCounterMap.find(molecule);
fpLastSearch->fLastMoleculeSearched = mol_it;
if(mol_it != fCounterMap.end())
{
fpLastSearch->fLowerBoundTime =
fpLastSearch->fLastMoleculeSearched->second.end();
if (mol_it != fCounterMap.end()) {
fpLastSearch->fLowerBoundTime = fpLastSearch->fLastMoleculeSearched->second.end();
fpLastSearch->fLowerBoundSet = true;
}
else
{
else {
fpLastSearch->fLowerBoundSet = false;
}
@@ -407,38 +344,29 @@ G4bool G4DNAScavengerMaterial::SearchTimeMap(MolType molecule)
//------------------------------------------------------------------------------
int64_t G4DNAScavengerMaterial::SearchUpperBoundTime(G4double time,
G4bool sameTypeOfMolecule)
int64_t G4DNAScavengerMaterial::SearchUpperBoundTime(G4double time, G4bool sameTypeOfMolecule)
{
auto mol_it = fpLastSearch->fLastMoleculeSearched;
if(mol_it == fCounterMap.end())
{
if (mol_it == fCounterMap.end()) {
return 0;
}
NbMoleculeInTime& timeMap = mol_it->second;
if(timeMap.empty())
{
if (timeMap.empty()) {
return 0;
}
if(sameTypeOfMolecule)
{
if(fpLastSearch->fLowerBoundSet &&
fpLastSearch->fLowerBoundTime != timeMap.end())
{
if(fpLastSearch->fLowerBoundTime->first < time)
{
if (sameTypeOfMolecule) {
if (fpLastSearch->fLowerBoundSet && fpLastSearch->fLowerBoundTime != timeMap.end()) {
if (fpLastSearch->fLowerBoundTime->first < time) {
auto upperToLast = fpLastSearch->fLowerBoundTime;
upperToLast++;
if(upperToLast == timeMap.end())
{
if (upperToLast == timeMap.end()) {
return fpLastSearch->fLowerBoundTime->second;
}
if(upperToLast->first > time)
{
if (upperToLast->first > time) {
return fpLastSearch->fLowerBoundTime->second;
}
}
@@ -447,20 +375,56 @@ int64_t G4DNAScavengerMaterial::SearchUpperBoundTime(G4double time,
auto up_time_it = timeMap.upper_bound(time);
if(up_time_it == timeMap.end())
{
if (up_time_it == timeMap.end()) {
auto last_time = timeMap.rbegin();
return last_time->second;
}
if(up_time_it == timeMap.begin())
{
if (up_time_it == timeMap.begin()) {
return 0;
}
up_time_it--;
fpLastSearch->fLowerBoundTime = up_time_it;
fpLastSearch->fLowerBoundSet = true;
fpLastSearch->fLowerBoundSet = true;
return fpLastSearch->fLowerBoundTime->second;
}
void G4DNAScavengerMaterial::WaterEquilibrium()
{
auto convertFactor = Avogadro * fpChemistryInfo->GetChemistryBoundary()->Volume() / liter;
G4double kw = 1.01e-14;
fScavengerTable[fHOm] = (kw / ((G4double)fScavengerTable[fH3Op] / convertFactor)) * convertFactor;
G4cout << "pH : " << GetpH() << G4endl;
return;
}
void G4DNAScavengerMaterial::SetpH(const G4int& ph)
{
auto volume = fpChemistryInfo->GetChemistryBoundary()->Volume();
fScavengerTable[fH3Op] = floor(Avogadro * std::pow(10, -ph) * volume / liter);
fScavengerTable[fHOm] = floor(Avogadro * std::pow(10, -(14 - ph)) * volume / liter);
}
G4double G4DNAScavengerMaterial::GetpH()
{
G4double volumeInLiter = fpChemistryInfo->GetChemistryBoundary()->Volume() / liter;
G4double Cion = (G4double)fScavengerTable[fH3Op] / (Avogadro * volumeInLiter);
G4double pH = std::log10(Cion);
// G4cout<<"OH- : "<<fScavengerTable[fHOm]<<" H3O+ : "<<fScavengerTable[fH3Op]<<" pH :
// "<<-pH<<G4endl;
if (fScavengerTable[fH3Op] < 0) // protect me
{
G4Exception("G4DNAScavengerMaterial::GetpH()", "G4DNAScavengerMaterial001", JustWarning,
"H3O+ < 0");
fScavengerTable[fH3Op] = 0;
}
if (fScavengerTable[fHOm] < 0) // protect me
{
G4Exception("G4DNAScavengerMaterial::GetpH()", "G4DNAScavengerMaterial001", JustWarning,
"HO- < 0");
fScavengerTable[fHOm] = 0;
}
return -pH;
}
@@ -26,7 +26,7 @@
#include "G4DNAWaterExcitationStructure.hh"
#include "G4SystemOfUnits.hh"
G4DNAWaterExcitationStructure::G4DNAWaterExcitationStructure(): nLevels(5)
G4DNAWaterExcitationStructure::G4DNAWaterExcitationStructure()
{
energyConstant.push_back(8.22*eV);
energyConstant.push_back(10.00*eV);
@@ -39,7 +39,7 @@ G4DNAWaterExcitationStructure::G4DNAWaterExcitationStructure(): nLevels(5)
G4DNAWaterExcitationStructure::~G4DNAWaterExcitationStructure()
{ }
= default;
G4double G4DNAWaterExcitationStructure::ExcitationEnergy(G4int level)
@@ -26,7 +26,7 @@
#include "G4DNAWaterIonisationStructure.hh"
#include "G4SystemOfUnits.hh"
G4DNAWaterIonisationStructure::G4DNAWaterIonisationStructure(): nLevels(5)
G4DNAWaterIonisationStructure::G4DNAWaterIonisationStructure()
{
energyConstant.push_back(10.79*eV);
energyConstant.push_back(13.39*eV);
@@ -39,7 +39,7 @@ G4DNAWaterIonisationStructure::G4DNAWaterIonisationStructure(): nLevels(5)
G4DNAWaterIonisationStructure::~G4DNAWaterIonisationStructure()
{ }
= default;
G4double G4DNAWaterIonisationStructure::IonisationEnergy(G4int level)
@@ -53,12 +53,12 @@
#include "globals.hh"
#include "G4SystemOfUnits.hh"
#include "Randomize.hh"
#include <vector>
#include <cmath>
G4ErrorFunction::G4ErrorFunction() {;}
G4ErrorFunction::G4ErrorFunction() = default;
G4ErrorFunction::~G4ErrorFunction() {;}
G4ErrorFunction::~G4ErrorFunction() = default;
@@ -577,14 +577,14 @@ G4double G4ErrorFunction::erfcx(G4double x)
}
return erfcx_y100(400/(4+x));
}
else
return x < -26.7 ? HUGE_VAL : (x < -6.1 ? 2*std::exp(x*x)
: 2*std::exp(x*x) - erfcx_y100(400/(4-x)));
return x < -26.7 ? HUGE_VAL : (x < -6.1 ? 2*std::exp(x*x)
: 2*std::exp(x*x) - erfcx_y100(400/(4-x)));
}
G4double G4ErrorFunction::erfc(G4double x) {
return 1.0 - std::erf(x);
return std::erfc(x);
}
@@ -73,7 +73,7 @@ void TG4MoleculeShoot<G4Track>::ShootAtFixedPosition(G4MoleculeGun* gun)
template<>
void TG4MoleculeShoot<G4Track>::Shoot(G4MoleculeGun* gun)
{
if(fBoxSize) ShootAtRandomPosition(gun);
if(fBoxSize != nullptr) ShootAtRandomPosition(gun);
else ShootAtFixedPosition(gun);
}
@@ -99,16 +99,16 @@ G4MoleculeGun::G4MoleculeGun()
G4MoleculeGun::~G4MoleculeGun()
{
if (fpMessenger) delete fpMessenger;
delete fpMessenger;
}
//------------------------------------------------------------------------------
void G4MoleculeGun::DefineTracks()
{
for (std::size_t i = 0; i < fShoots.size(); i++)
for (const auto & fShoot : fShoots)
{
fShoots[i]->Shoot(this);
fShoot->Shoot(this);
}
}
@@ -167,7 +167,7 @@ void G4MoleculeGun::BuildAndPushTrack(const G4String& name,
G4MolecularConfiguration* conf =
G4MoleculeTable::Instance()->GetConfiguration(name);
assert(conf != 0);
G4Molecule* molecule = new G4Molecule(conf);
auto molecule = new G4Molecule(conf);
PushTrack(molecule->BuildTrack(time, position));
}
@@ -176,9 +176,9 @@ void G4MoleculeGun::BuildAndPushTrack(const G4String& name,
void G4MoleculeGun::GetNameAndNumber(G4MoleculeGun::NameNumber& output)
{
for(std::size_t i = 0 ; i < fShoots.size() ; ++i)
for(const auto & fShoot : fShoots)
{
output[fShoots[i]->fMoleculeName]+=fShoots[i]->fNumber;
output[fShoot->fMoleculeName]+=fShoot->fNumber;
}
}
@@ -194,20 +194,19 @@ void G4MoleculeShoot::RandomPosInBox(const G4ThreeVector& boxSize,
//------------------------------------------------------------------------------
G4MoleculeShoot::G4MoleculeShoot() :
G4enable_shared_from_this<G4MoleculeShoot>()
G4MoleculeShoot::G4MoleculeShoot()
{
fMoleculeName = "";
fTime = 0;
fNumber = 1;
fBoxSize = 0;
fBoxSize = nullptr;
}
//------------------------------------------------------------------------------
G4MoleculeShoot::~G4MoleculeShoot()
{
if(fBoxSize) delete fBoxSize;
delete fBoxSize;
}
//------------------------------------------------------------------------------
@@ -31,15 +31,12 @@
*/
#include "G4MoleculeGunMessenger.hh"
#include "G4MoleculeGun.hh"
#include "G4Tokenizer.hh"
#include "G4UIdirectory.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWith3VectorAndUnit.hh"
#include "G4UIcmdWithADoubleAndUnit.hh"
#include "G4UIcmdWithAString.hh"
#include "G4UIcmdWithAnInteger.hh"
#include "G4UIdirectory.hh"
@@ -57,7 +54,7 @@ G4MoleculeGunMessenger::G4MoleculeGunMessenger(G4MoleculeGun* gun) :
G4MoleculeGunMessenger::~G4MoleculeGunMessenger()
{
if (fpGunNewGunType) delete fpGunNewGunType;
delete fpGunNewGunType;
}
//------------------------------------------------------------------------------
@@ -82,7 +79,7 @@ void G4MoleculeGunMessenger::SetNewValue(G4UIcommand* command,
G4String shootType;
iss >> shootType;
if(shootType == "" || shootType.empty())
if(shootType.empty() || shootType.empty())
{
CreateNewType<G4Track>(shootName);
}
@@ -99,7 +96,7 @@ G4MoleculeShootMessenger::G4MoleculeShootMessenger(const G4String& name,
G4MoleculeGunMessenger*,
G4shared_ptr<G4MoleculeShoot>
shoot) :
G4UImessenger(), fpShoot(shoot)
fpShoot(shoot)
{
G4String dir("/chem/gun/");
dir += name;
@@ -136,10 +133,10 @@ G4MoleculeShootMessenger::G4MoleculeShootMessenger(const G4String& name,
G4MoleculeShootMessenger::~G4MoleculeShootMessenger()
{
if (fpGunSpecies) delete fpGunSpecies;
if (fpGunPosition) delete fpGunPosition;
if (fpGunTime) delete fpGunTime;
if (fpGunN) delete fpGunN;
delete fpGunSpecies;
delete fpGunPosition;
delete fpGunTime;
delete fpGunN;
}
//------------------------------------------------------------------------------
@@ -186,23 +183,23 @@ G4String G4MoleculeShootMessenger::GetCurrentValue(G4UIcommand* command)
{
return fpShoot->fMoleculeName;
}
else if (command == fpGunPosition)
if (command == fpGunPosition)
{
return fpGunPosition->ConvertToStringWithBestUnit(fpShoot->fPosition);
}
else if (command == fpGunRdnmPosition)
if (command == fpGunRdnmPosition)
{
if(fpShoot->fBoxSize)
if(fpShoot->fBoxSize != nullptr)
{
return fpGunRdnmPosition->ConvertToStringWithBestUnit(*fpShoot->fBoxSize);
}
return fpGunRdnmPosition->ConvertToStringWithBestUnit(G4ThreeVector());
}
else if (command == fpGunTime)
if (command == fpGunTime)
{
return fpGunTime->ConvertToStringWithBestUnit(fpShoot->fTime);
}
else if (command == fpGunN)
if (command == fpGunN)
{
return fpGunN->ConvertToString(fpShoot->fNumber);
}
@@ -95,7 +95,7 @@ void FormattedText::AddEmptyLineInOutputFile()
void FormattedText::CloseFile()
{
if (fFileInitialized == false) return;
if (!fFileInitialized) return;
if (fOfstream.is_open())
{
@@ -144,7 +144,7 @@ void FormattedText::CreateSolvatedElectron(const G4Track* theIncomingTrack,
<< setw(22)
<< (theIncomingTrack->GetPosition().z()) / nanometer;
if (finalPosition != 0)
if (finalPosition != nullptr)
{
fOfstream << setw(14) << (finalPosition->x()) / nanometer << setw(14)
<< (finalPosition->y()) / nanometer << setw(14)
@@ -170,7 +170,7 @@ fpAnalysisManager(analysisManager)
G4Analysis::~G4Analysis()
{
fpAnalysisManager = 0;
fpAnalysisManager = nullptr;
}
//------------------------------------------------------------------------------
@@ -290,7 +290,7 @@ void G4Analysis::CreateSolvatedElectron(const G4Track* electronTrack,
fpAnalysisManager->FillNtupleDColumn(fNtupleID,6, parentPos.y() *i_nm);
fpAnalysisManager->FillNtupleDColumn(fNtupleID,7, parentPos.z() *i_nm);
if (finalPosition != 0)
if (finalPosition != nullptr)
{
fpAnalysisManager->FillNtupleDColumn(fNtupleID,8, finalPosition->x()*i_nm);
fpAnalysisManager->FillNtupleDColumn(fNtupleID,9, finalPosition->y()*i_nm);
@@ -42,8 +42,8 @@
//------------------------------------------------------------------------------
G4ReactionTableMessenger::G4ReactionTableMessenger(G4DNAMolecularReactionTable* table)
: G4UImessenger()
, fpTable(table)
:
fpTable(table)
, fpActivateReactionUI(new G4UIcmdWithoutParameter("/chem/reaction/UI", this))
{
fpNewDiffContReaction = new G4UIcmdWithAString("/chem/reaction/new", this);
@@ -55,9 +55,9 @@ G4ReactionTableMessenger::G4ReactionTableMessenger(G4DNAMolecularReactionTable*
G4ReactionTableMessenger::~G4ReactionTableMessenger()
{
if(fpNewDiffContReaction) delete fpNewDiffContReaction;
if(fpAddReaction) delete fpAddReaction;
if(fpPrintTable) delete fpPrintTable;
delete fpNewDiffContReaction;
delete fpAddReaction;
delete fpPrintTable;
}
//------------------------------------------------------------------------------
@@ -114,12 +114,12 @@ void G4ReactionTableMessenger::SetNewValue(G4UIcommand* command,
// reactionData->SetProductionRate(dimensionedProductionRate);
// }
while(iss.eof() == false)
while(!iss.eof())
{
G4String product;
iss >> product;
if(product != "")
if(!product.empty())
{
reactionData->AddProduct(product);
}
@@ -272,7 +272,7 @@ void G4ReactionTableMessenger::SetNewValue(G4UIcommand* command,
//--------------------------------------------------------------------------
G4DNAMolecularReactionData* reactionData =
auto reactionData =
new G4DNAMolecularReactionData(0,
species1,
species2);
@@ -286,7 +286,7 @@ void G4ReactionTableMessenger::SetNewValue(G4UIcommand* command,
while(marker!="|"
//&& marker!=""
&& iss.eof() == false
&& !iss.eof()
)
{
//G4cout << marker << G4endl;
@@ -27,9 +27,8 @@
#include "G4VDNAReactionModel.hh"
G4VDNAReactionModel::G4VDNAReactionModel()
: fpReactionTable(nullptr)
{
}
= default;
G4VDNAReactionModel::~G4VDNAReactionModel() = default;
@@ -35,11 +35,9 @@
//------------------------------------------------------------------------------
G4VPhysChemIO::G4VPhysChemIO()
{
}
= default;
//------------------------------------------------------------------------------
G4VPhysChemIO::~G4VPhysChemIO()
{
}
= default;