Import Geant4 11.1.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2022-07-01 10:44:02 +02:00
parent b3bf75a2a1
commit c07cea1fe0
2172 changed files with 183300 additions and 123938 deletions
@@ -38,7 +38,7 @@ class G4DNAMolecularReactionData;
class Event
{
public:
using Index = G4Voxel::Index;
using Index = G4VDNAMesh::Index;
using MolType = const G4MolecularConfiguration*;
using JumpingData = std::pair<MolType, Index>;
using ReactionData = const G4DNAMolecularReactionData;
@@ -47,21 +47,19 @@ class Event
// using Data = std::variant<std::unique_ptr<JumpingData>, ReactionData*>
using Data = std::pair<std::unique_ptr<JumpingData>, ReactionData*>;
Event(G4double time, unsigned int key, ReactionData*);
Event(G4double time, unsigned int key, std::unique_ptr<JumpingData>&&);
Event(const G4double& time, const Index& index, ReactionData*);
Event(const G4double& time, const Index& index, std::unique_ptr<JumpingData>&&);
virtual ~Event();
G4double GetTime() const { return fTimeStep; }
unsigned int GetKey() const { return fKey; }
inline G4double GetTime() const { return fTimeStep; }
inline Index GetIndex() const { return fIndex; }
void PrintEvent() const;
JumpingData* GetJumpingData() const { return std::get<0>(fData).get(); }
ReactionData* GetReactionData() const { return std::get<1>(fData); }
private:
G4double fTimeStep;
unsigned int fKey;
Index fIndex;
Data fData;
};
@@ -81,15 +79,15 @@ class IEventSet
class G4DNAEventSet : public IEventSet
{
public:
using Key = unsigned int;
using Index = G4VDNAMesh::Index;
using EventSet = std::set<std::unique_ptr<Event>, comparatorEventSet>;
using EventMap = std::map<Key, EventSet::iterator>;
using EventMap = std::unordered_map<Index, EventSet::iterator,G4VDNAMesh::hashFunc>;
G4DNAEventSet();
virtual ~G4DNAEventSet();
void CreateEvent(G4double time, Key index,
void CreateEvent(const G4double& time, const Index& index,
Event::ReactionData* pReactionData);
void CreateEvent(G4double time, Key index,
void CreateEvent(const G4double& time, const Index& index,
std::unique_ptr<Event::JumpingData> jum);
void AddEvent(std::unique_ptr<Event> pEvent);
@@ -98,25 +96,19 @@ class G4DNAEventSet : public IEventSet
fEventSet.clear();
fEventMap.clear();
}
void RemoveEventOfVoxel(const size_t& key);
void RemoveEventOfVoxel(const Index& key);
EventSet::iterator end() { return fEventSet.end(); }
EventSet::iterator begin() { return fEventSet.begin(); }
EventSet::reverse_iterator rend() { return fEventSet.rend(); }
EventSet::reverse_iterator rbegin() { return fEventSet.rbegin(); }
EventSet::const_iterator end() const { return fEventSet.end(); }
EventSet::const_iterator begin() const { return fEventSet.begin(); }
size_t size() { return fEventSet.size(); }
G4bool Empty() { return fEventSet.empty(); }
void RemoveEvent(EventSet::iterator iter);
[[maybe_unused]] void PrintEventSet();
void PrintEventSet();
private:
EventSet fEventSet;
EventMap fEventMap;
@@ -32,33 +32,26 @@
#include <vector>
#include <array>
#include <cmath>
#include <map>
#include <unordered_map>
#include <memory>
#include <sstream>
#include "G4MolecularConfiguration.hh"
#include "G4Track.hh"
class G4Voxel
class G4VDNAMesh
{
public:
G4VDNAMesh() = default;
virtual ~G4VDNAMesh() = default;
struct Index
{
Index()
: x(0)
, y(0)
, z(0)
Index() = default;
Index(G4int _x, G4int _y, G4int _z)
: x(_x)
, y(_y)
, z(_z)
{}
Index(int x0, int y0, int z0)
: x(x0)
, y(y0)
, z(z0)
{}
friend std::ostream& operator<<(std::ostream& stream, const Index& rhs)
{
stream << "(" << rhs.x << ", " << rhs.y << ", " << rhs.z << ")";
return stream;
}
~Index() = default;
G4bool operator==(const Index& rhs) const
{
return x == rhs.x && y == rhs.y && z == rhs.z;
@@ -67,89 +60,78 @@ class G4Voxel
{
return x != rhs.x || y != rhs.y || z != rhs.z;
}
Index operator+(const Index& rhs) const
G4bool operator<(const Index& rhs) const
{
return { x + rhs.x, y + rhs.y, z + rhs.z };
if(x != rhs.x)
{
return x < rhs.x;
}
else if(y != rhs.y)
{
return y < rhs.y;
}
else if(z != rhs.z)
{
return z < rhs.z;
}
else
{
return false;
}
}
int x, y, z;
friend std::ostream& operator<<(std::ostream& s, const Index& rhs);
G4int x = 0;
G4int y = 0;
G4int z = 0;
};
using MolType = const G4MolecularConfiguration*;
using MapList = std::map<MolType, size_t>;
G4Voxel(MapList&& list, Index& index, G4DNABoundingBox&& box)
: fMapList(std::move(list))
, fIndex(index)
, fBox(std::move(box))
{}
~G4Voxel() = default;
const Index& GetIndex() const { return fIndex; }
MapList& GetMapList() { return fMapList; }
void SetMapList(MapList&& mapList) { fMapList = std::move(mapList); }
G4double GetVolume() const
struct hashFunc
{
auto xlo = fBox.Getxlo();
auto ylo = fBox.Getylo();
auto zlo = fBox.Getzlo();
auto xhi = fBox.Getxhi();
auto yhi = fBox.Getyhi();
auto zhi = fBox.Getzhi();
return (xhi - xlo) * (yhi - ylo) * (zhi - zlo);
}
private:
MapList fMapList;
Index fIndex;
G4DNABoundingBox fBox;
size_t operator()(const Index& k) const
{
size_t h1 = std::hash<G4int>()(k.x);
size_t h2 = std::hash<G4int>()(k.y);
size_t h3 = std::hash<G4int>()(k.z);
return (h1 ^ (h2 << 1)) ^ h3;
}
};
};
class G4DNAMesh
class G4DNAMesh : public G4VDNAMesh
{
public:
using Index = G4Voxel::Index;
using Key = unsigned int;
using VoxelMap = std::map<Key, G4Voxel*>;
using Box = G4DNABoundingBox;
using MolType = const G4MolecularConfiguration*;
using Data = std::map<MolType, size_t>;
using Voxel = std::tuple<Index, Box, Data>;
using IndexMap = std::unordered_map<Index, G4int, G4VDNAMesh::hashFunc>;
using VoxelVector = std::vector<Voxel>;
G4DNAMesh(const G4DNABoundingBox&, G4int);
~G4DNAMesh();
Key GetKey(const G4ThreeVector& pos) const;
Index GetIndex(Key key) const;
~G4DNAMesh() override;
Index GetIndex(const G4ThreeVector& position) const;
G4Voxel* GetVoxel(Key key);
[[maybe_unused]] G4Voxel* GetVoxel(const Index& index);
size_t size() { return fMesh.size(); }
Index GetIndex(const Index& index, int) const;
std::vector<Index> FindVoxelNeighbors(const Index& index) const;
Voxel& GetVoxel(const Index& index); // GetorCreateVoxel
size_t size() { return fVoxelVector.size(); };
Index ConvertIndex(const Index& index, const G4int&) const;
std::vector<Index> FindNeighboringVoxels(const Index& index) const;
void Reset();
G4Voxel::MapList& GetVoxelMapList(Key key);
G4Voxel::MapList& GetVoxelMapList(const Index& index);
Key GetKey(const Index& index) const;
VoxelMap::iterator end() { return fMesh.end(); }
VoxelMap::iterator begin() { return fMesh.begin(); }
VoxelMap::const_iterator end() const { return fMesh.end(); }
VoxelMap::const_iterator begin() const { return fMesh.begin(); }
Data& GetVoxelMapList(const Index& index);
auto end() { return fVoxelVector.end(); }
auto begin() { return fVoxelVector.begin(); }
VoxelVector::const_iterator const_end() const { return fVoxelVector.end(); }
VoxelVector::const_iterator const_begin() const
{
return fVoxelVector.begin();
}
void PrintMesh();
void PrintVoxel(const Index& index);
const G4DNABoundingBox& GetBoundingBox() const;
G4DNABoundingBox GetBoundingBox(const Index& index);
G4int GetNumberOfType(G4Voxel::MolType type) const;
void SetVoxelMapList(const Key& key, G4Voxel::MapList&& mapList);
G4int GetNumberOfType(MolType type) const;
void InitializeVoxel(const Index& key, Data&& mapList);
G4double GetResolution() const;
private:
VoxelMap fMesh;
IndexMap fIndexMap;
VoxelVector fVoxelVector;
const G4DNABoundingBox* fpBoundingMesh;
G4double fResolution;
};
@@ -143,7 +143,6 @@ public:
void ScaleForNewTemperature(double temp_K);
private:
void ComputeEffectiveRadius();
protected:
@@ -239,6 +238,8 @@ public:
//_________________________________________________________________
void PrintTable(G4VDNAReactionModel* = 0);
void Reset();
protected:
G4bool fVerbose;
@@ -36,16 +36,15 @@ class G4Material;
class G4MolecularConfiguration;
class G4VChemistryWorld;
using NbMoleculeAgainstTime =
std::map<G4double, G4int, G4::MoleculeCounter::TimePrecision>;
class G4DNAScavengerMaterial : public G4VScavengerMaterial
{
public:
using NbMoleculeInTime =
std::map<G4double, int64_t, G4::MoleculeCounter::TimePrecision>;
using MolType = const G4MolecularConfiguration*;
using MaterialMap = std::map<MolType, G4double>;
using MaterialMap = std::map<MolType, int64_t>;
using ReactantList = std::vector<MolType>;
using CounterMapType = std::map<MolType, NbMoleculeAgainstTime>;
using CounterMapType = std::map<MolType, NbMoleculeInTime>;
G4DNAScavengerMaterial() = default;
explicit G4DNAScavengerMaterial(G4VChemistryWorld*);
~G4DNAScavengerMaterial() override = default;
@@ -98,14 +97,14 @@ class G4DNAScavengerMaterial : public G4VScavengerMaterial
}
void Dump();
G4int GetNMoleculesAtTime(MolType molecule, G4double time);
int64_t GetNMoleculesAtTime(MolType molecule, G4double time);
G4bool SearchTimeMap(MolType molecule);
G4int SearchUpperBoundTime(G4double time, G4bool sameTypeOfMolecule);
int64_t SearchUpperBoundTime(G4double time, G4bool sameTypeOfMolecule);
private:
G4VChemistryWorld* fpChemistryInfo;
G4bool fIsInitialized;
std::map<MolType, G4double> fScavengerTable;
MaterialMap fScavengerTable;
CounterMapType fCounterMap;
G4bool fCounterAgainstTime;
G4int fVerbose;
@@ -113,7 +112,7 @@ class G4DNAScavengerMaterial : public G4VScavengerMaterial
{
Search() { fLowerBoundSet = false; }
CounterMapType::iterator fLastMoleculeSearched;
NbMoleculeAgainstTime::iterator fLowerBoundTime;
NbMoleculeInTime::iterator fLowerBoundTime;
G4bool fLowerBoundSet;
};
@@ -35,9 +35,12 @@
#include <G4UImessenger.hh>
#include <memory>
class G4UIcmdWithAString;
class G4DNAMolecularReactionTable;
class G4UIcmdWithoutParameter;
class G4UIcmdWithABool;
class G4ReactionTableMessenger : public G4UImessenger
{
@@ -48,6 +51,7 @@ public:
protected:
G4DNAMolecularReactionTable* fpTable;
std::unique_ptr<G4UIcmdWithoutParameter> fpActivateReactionUI;
G4UIcmdWithAString* fpAddReaction;
G4UIcmdWithAString* fpNewDiffContReaction;
// G4UIcmdWithAString* fpNewPartDiffContReactionByRadius;
@@ -69,10 +69,10 @@ public :
virtual void InitialiseToPrint(const G4MolecularConfiguration*) = 0 ;
virtual G4double GetReactionRadius(const G4MolecularConfiguration*,
const G4MolecularConfiguration*) = 0;
virtual G4double GetReactionRadius(int) = 0;
virtual G4double GetReactionRadius(const G4int&) = 0;
virtual G4bool FindReaction(const G4Track&, const G4Track&,
G4double /*reactionRadius*/,
G4double& /*separationDistance*/, // To be calculated
G4double& /*separationDistance*/,
G4bool /*hasReachedUserTimeLimit*/) = 0;
void SetReactionTable(const G4DNAMolecularReactionTable*);
@@ -45,15 +45,23 @@
#ifndef G4VUSERCHEMISTRYLIST_HH_
#define G4VUSERCHEMISTRYLIST_HH_
#include "G4Types.hh"
class G4Molecule;
class G4DNAMolecularReactionTable;
class G4VITStepModel;
class G4MoleculeDefinition;
enum TimeStepModel
{
fSBS,
fIRT,
fIRT_syn
};
class G4VUserChemistryList
{
public:
G4VUserChemistryList(bool flag = true);
G4VUserChemistryList(G4bool flag = true);
virtual ~G4VUserChemistryList();
// If your user class also inherits from G4VPhysicsConstructor,
@@ -63,7 +71,7 @@ public:
return fIsPhysicsConstructor;
}
void ThisIsAPhysicsConstructor(bool flag = true)
void ThisIsAPhysicsConstructor(G4bool flag = true)
{
fIsPhysicsConstructor = flag;
}
@@ -91,13 +99,14 @@ public:
void BuildPhysicsTable();
protected:
void RegisterTimeStepModel(G4VITStepModel* timeStepModel,
double startingTime = 0);
protected:
void BuildPhysicsTable(G4MoleculeDefinition*);
int verboseLevel;
bool fIsPhysicsConstructor;
void RegisterTimeStepModel(G4VITStepModel* timeStepModel,
G4double startingTime = 0);
G4int verboseLevel;
G4bool fIsPhysicsConstructor;
};
#endif /* G4VUSERCHEMISTRYLIST_HH_ */