Import Geant4 10.6.0 source tree

This commit is contained in:
Gabriele Cosmo
2019-12-06 15:12:28 +01:00
parent b2a62ae692
commit 5baee230e9
2997 changed files with 141580 additions and 98673 deletions
+3
View File
@@ -16,6 +16,9 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
September 19th, 2019 G.Cosmo (geombias-V10-05-00)
- Implemented minor c++11 revision and code cleanup.
March 7th, 2017 A.Howard (geombias-V10-03-00)
- Added mutex locks to methods within G4IStore and G4ImportanceAlgorithm
should fix bug#1945 (created by me) - erratic behaviour in MT-mode and
@@ -23,23 +23,19 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ----------------------------------------------------------------------
// Class G4GeometryCell
// G4GeometryCell
//
// Class description:
//
// This class is usde by scoring and importance sampling.
// It serves to address a "cell". A "cell" is somewhat
// related to a touchable in Geant4. It is identified by a reference
// to a G4VPhysicalVolume and a number (replica number).
// Only simple replicas are supported.
// This class is used by scoring and importance sampling.
// It serves to address a "cell". A "cell" is somewhat related to a
// touchable. It is identified by a reference to a G4VPhysicalVolume
// and a number (replica number). Only simple replicas are supported.
// Author: Michael Dressel (Michael.Dressel@cern.ch)
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#ifndef G4GeometryCell_hh
#define G4GeometryCell_hh G4GeometryCell_hh
#ifndef G4GEOMETRYCELL_HH
#define G4GEOMETRYCELL_HH 1
#include "globals.hh"
@@ -47,34 +43,34 @@ class G4VPhysicalVolume;
class G4GeometryCell
{
public: // with description
public: // with description
G4GeometryCell(const G4VPhysicalVolume &aVolume, G4int RepNum);
G4GeometryCell(const G4VPhysicalVolume& aVolume, G4int RepNum);
// initialise volume and replica number
G4GeometryCell(const G4GeometryCell &rhs);
// initialise volume and replica number
G4GeometryCell(const G4GeometryCell& rhs);
G4GeometryCell& operator=(const G4GeometryCell& rhs);
// copy constructor and assignment operator
~G4GeometryCell();
// simple destruction
~G4GeometryCell();
// simple destruction
const G4VPhysicalVolume &GetPhysicalVolume() const;
// return the physical volume of the cell
const G4VPhysicalVolume& GetPhysicalVolume() const;
// return the physical volume of the cell
G4int GetReplicaNumber() const;
// returns the replica number of the cell
G4int GetReplicaNumber() const;
// returns the replica number of the cell
private:
G4GeometryCell &operator=(const G4GeometryCell &rhs);
private:
const G4VPhysicalVolume *fVPhysicalVolume;
// pointer to the G4VPhysicalVolume of the "cell"
// it is treated as identifyer
const G4VPhysicalVolume* fVPhysicalVolume = nullptr;
// pointer to the G4VPhysicalVolume of the "cell"; treated as identifyer
G4int fRepNum;
// replica number of the "cell"
G4int fRepNum = 0;
// replica number of the "cell"
};
G4bool operator==(const G4GeometryCell &k1, const G4GeometryCell &k2);
G4bool operator!=(const G4GeometryCell &k1, const G4GeometryCell &k2);
G4bool operator==(const G4GeometryCell& k1, const G4GeometryCell& k2);
G4bool operator!=(const G4GeometryCell& k1, const G4GeometryCell& k2);
#endif
@@ -23,19 +23,16 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ----------------------------------------------------------------------
// Class G4GeometryCellComp
// G4GeometryCellComp
//
// Class description:
//
// A class needed for comparing G4GeometryCell e.g. in stl containers.
// A class needed for comparing G4GeometryCell e.g. in STL containers.
// Author: Michael Dressel (Michael.Dressel@cern.ch)
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#ifndef G4GeometryCellComp_hh
#define G4GeometryCellComp_hh G4GeometryCellComp_hh
#ifndef G4GEOMETRYCELLCOMP_HH
#define G4GEOMETRYCELLCOMP_HH 1
#include "globals.hh"
@@ -43,14 +40,13 @@ class G4GeometryCell;
class G4GeometryCellComp
{
public:
public: // without description
G4GeometryCellComp();
G4GeometryCellComp();
G4bool operator() (const G4GeometryCell &g1,
const G4GeometryCell &g2) const;
// returns true if g1 < g2
G4bool operator() (const G4GeometryCell& g1,
const G4GeometryCell& g2) const;
// returns true if g1 < g2
};
#endif
@@ -23,29 +23,28 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ----------------------------------------------------------------------
// Class G4GeometryCellImportance
// G4GeometryCellImportance
//
// Class description:
//
// Used internally by importance sampling.
// It is acontainer for "cell" importance value pairs.
// It is a container for "cell" importance value pairs.
// Author: Michael Dressel (Michael.Dressel@cern.ch)
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#ifndef G4GeometryCellImportance_hh
#define G4GeometryCellImportance_hh G4GeometryCellImportance_hh
#ifndef GEOMETRYCELLIMPORTANCE_HH
#define GEOMETRYCELLIMPORTANCE_HH 1
#include <map>
#include "globals.hh"
#include "G4GeometryCell.hh"
#include "G4GeometryCellComp.hh"
typedef std::map<G4GeometryCell, G4double, G4GeometryCellComp> G4GeometryCellImportance;
using G4GeometryCellImportance = std::map<G4GeometryCell,
G4double, G4GeometryCellComp>;
// implement container G4GeometryCellImportance as map
std::ostream& operator<<(std::ostream &out, const G4GeometryCellImportance &gCelli);
std::ostream& operator<<(std::ostream& out,
const G4GeometryCellImportance& gCelli);
#endif
@@ -23,94 +23,96 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ----------------------------------------------------------------------
// Class G4GeometryCellStep
// G4GeometryCellStep
//
// Class description:
//
// This class serves to address the "cell" a track previously
// touched and a "cell" a track is currently in. It is used
// for scoring and importance sampling in the "mass" geometry as well
// as in a "parallel" geometry.
// The "cell" information is available with the GetPreGeometryCell and
// the GetPostGeometryCell functions.
// The GetCrossBoundary finction returns true in case the step
// This class serves to address the "cell" a track previously touched
// and a "cell" a track is currently in. It is used for scoring and
// importance sampling in the "mass" geometry as well as in a "parallel"
// geometry.
// The "cell" information is available with the GetPreGeometryCell() and
// the GetPostGeometryCell() functions.
// The GetCrossBoundary() function returns true in case the step
// crosses a boundary in the geometry this G4GeometryCellStep
// refers to.
// Author: Michael Dressel (Michael.Dressel@cern.ch)
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#ifndef G4GeometryCellStep_hh
#define G4GeometryCellStep_hh G4GeometryCellStep_hh
#ifndef G4GEOMETRYCELLSTEP_HH
#define G4GEOMETRYCELLSTEP_HH 1
#include "G4GeometryCell.hh"
class G4GeometryCellStep
{
public: // with description
G4GeometryCellStep(const G4GeometryCell &preCell,
const G4GeometryCell &postCell);
// initialise pre and post G4GeometryCell
public: // with description
~G4GeometryCellStep();
G4GeometryCellStep(const G4GeometryCell& preCell,
const G4GeometryCell& postCell);
// initialise pre and post G4GeometryCell
const G4GeometryCell &GetPreGeometryCell() const;
// addressing the "cell" the track previously touched
~G4GeometryCellStep();
const G4GeometryCell &GetPostGeometryCell() const;
// addressing the current "cell"
inline const G4GeometryCell& GetPreGeometryCell() const;
// addressing the "cell" the track previously touched
G4bool GetCrossBoundary() const;
// returns true if step crosses boundary of the geometry it refers to
inline const G4GeometryCell& GetPostGeometryCell() const;
// addressing the current "cell"
// the following functions are used by the scoring and importance
// system to set the cell information.
void SetPreGeometryCell(const G4GeometryCell &preCell);
void SetPostGeometryCell(const G4GeometryCell &postCell);
void SetCrossBoundary(G4bool b);
inline G4bool GetCrossBoundary() const;
// returns true if step crosses boundary of the geometry it refers to
private:
G4GeometryCell fPreGeometryCell;
G4GeometryCell fPostGeometryCell;
G4bool fCrossBoundary;
// the following functions are used by the scoring and importance
// system to set the cell information.
//
inline void SetPreGeometryCell(const G4GeometryCell& preCell);
inline void SetPostGeometryCell(const G4GeometryCell& postCell);
inline void SetCrossBoundary(G4bool b);
private:
G4GeometryCell fPreGeometryCell;
G4GeometryCell fPostGeometryCell;
G4bool fCrossBoundary = false;
};
// Inline methods
inline void G4GeometryCellStep::SetPreGeometryCell(const G4GeometryCell &preCell)
inline void
G4GeometryCellStep::SetPreGeometryCell(const G4GeometryCell& preCell)
{
fPreGeometryCell = preCell;
}
inline void G4GeometryCellStep::SetPostGeometryCell(const G4GeometryCell &postCell)
inline void
G4GeometryCellStep::SetPostGeometryCell(const G4GeometryCell& postCell)
{
fPostGeometryCell = postCell;
}
inline void G4GeometryCellStep::SetCrossBoundary(G4bool b)
inline void
G4GeometryCellStep::SetCrossBoundary(G4bool b)
{
fCrossBoundary = b;
}
inline const G4GeometryCell &G4GeometryCellStep::GetPreGeometryCell() const
inline const G4GeometryCell&
G4GeometryCellStep::GetPreGeometryCell() const
{
return fPreGeometryCell;
}
inline const G4GeometryCell &G4GeometryCellStep::GetPostGeometryCell() const
inline const G4GeometryCell&
G4GeometryCellStep::GetPostGeometryCell() const
{
return fPostGeometryCell;
}
inline G4bool G4GeometryCellStep::GetCrossBoundary() const
inline G4bool
G4GeometryCellStep::GetCrossBoundary() const
{
return fCrossBoundary;
}
#endif
@@ -23,24 +23,19 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ----------------------------------------------------------------------
// Declarations
//
// Declaration description:
//
// declarations of streams for G4GeometryCell and G4GeometryCellStep
// Declarations of streams for G4GeometryCell and G4GeometryCellStep
// Author: Michael Dressel (Michael.Dressel@cern.ch)
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#ifndef G4GeometryCellStepStream_hh
#define G4GeometryCellStepStream_hh G4GeometryCellStepStream_hh
#ifndef G4GEOMETRYCELLSTEPSTREAM_HH
#define G4GEOMETRYCELLSTEPSTREAM_HH 1
#include "G4GeometryCell.hh"
#include "G4GeometryCellStep.hh"
std::ostream& operator<<(std::ostream &out, const G4GeometryCell &tk);
std::ostream& operator<<(std::ostream &out, const G4GeometryCellStep &ps);
std::ostream& operator<<(std::ostream& out, const G4GeometryCell& tk);
std::ostream& operator<<(std::ostream& out, const G4GeometryCellStep& ps);
#endif
@@ -23,27 +23,27 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ----------------------------------------------------------------------
// Class G4GeometryCellWeight
// G4GeometryCellWeight
//
// Class description:
//
// Used internally by weight window tehnique sampling.
// Used internally by weight window technique sampling.
// It is a map of geometry cells to maps of upper energy
// to lower weight bounds.
// Author: Michael Dressel (Michael.Dressel@cern.ch)
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#ifndef G4GeometryCellWeight_hh
#define G4GeometryCellWeight_hh G4GeometryCellWeight_hh
#ifndef G4GEOMETRYCELLWEIGHT_HH
#define G4GEOMETRYCELLWEIGHT_HH 1
#include <map>
#include "globals.hh"
#include "G4GeometryCell.hh"
#include "G4GeometryCellComp.hh"
typedef std::map<G4double, G4double, std::less<G4double> > G4UpperEnergyToLowerWeightMap;
typedef std::map<G4GeometryCell, G4UpperEnergyToLowerWeightMap, G4GeometryCellComp> G4GeometryCellWeight;
using G4UpperEnergyToLowerWeightMap =
std::map<G4double, G4double, std::less<G4double> >;
using G4GeometryCellWeight =
std::map<G4GeometryCell, G4UpperEnergyToLowerWeightMap, G4GeometryCellComp>;
#endif
+61 -89
View File
@@ -23,36 +23,24 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ----------------------------------------------------------------------
// Class G4IStore
// G4IStore
//
// Class description:
//
// An implementation of a "importance store" with the interface
// An implementation of an "importance store" with the interface
// G4VIStore. See description in G4VIStore.
// This implementation uses G4GeometryCellImportance as the container
// to store the "cells" together with the importance values.
// Giving a cell the importance 0 is allowed as
// a flagging that no biasing should happen between this
// cell and it's neighbors
// If a cell is not known by the importance store no biasing
// should be applied between this cell and it's nighbors.
// Giving a cell the importance 0 is allowed as a flagging that no biasing
// should happen between this cell and its neighbors.
// If a cell is not known by the importance store no biasing should be
// applied between this cell and its nighbors.
// Author: Michael Dressel (Michael.Dressel@cern.ch)
//
// Alex Howard (alexander.howard@cern.ch):
// Changed class to a `singleton', with access via the static method
// G4IStore::GetInstance().
//
// Member data:
//
// static G4IStore* fInstance
// - Ptr to the unique instance of class
// Author: Michael Dressel (CERN), 2002
// Modified: Alex Howard (CERN), 2013 - Changed class to a 'singleton'
// ----------------------------------------------------------------------
#ifndef G4IStore_hh
#define G4IStore_hh G4IStore_hh
#ifndef G4ISTORE_HH
#define G4ISTORE_HH 1
#include "G4VIStore.hh"
#include "G4GeometryCellImportance.hh"
@@ -60,92 +48,76 @@
class G4IStore : public G4VIStore
{
public:
public:
static G4IStore* GetInstance();
// return ptr to singleton instance of the class.
// static G4ThreadLocal G4IStore* GetInstance();
static G4IStore* GetInstance();
// Return ptr to singleton instance of the class.
// static G4ThreadLocal G4IStore* GetInstance(G4String ParallelWorldName);
static G4IStore* GetInstance(const G4String& ParallelWorldName);
// Return ptr to singleton instance of the class.
static G4IStore* GetInstance(const G4String& ParallelWorldName);
// return ptr to singleton instance of the class.
protected:
virtual G4double GetImportance(const G4GeometryCell& gCell) const;
// derive an importance value of a "cell" addressed by a
// G4GeometryCell from the store.
explicit G4IStore();
// initialise the importance store for the given geometry
explicit G4IStore(const G4String& ParallelWorldName);
// initialise the importance store for the given geometry
virtual G4bool IsKnown(const G4GeometryCell& gCell) const;
// returns true if the gCell is in the store, else false
~G4IStore();
// destruct
void Clear();
public: // with description
void SetWorldVolume();
// set a reference to the world volume of the "importance" geometry
virtual G4double GetImportance(const G4GeometryCell &gCell) const;
// derive an importance value of a "cell" addressed by a G4GeometryCell
// from the store.
void SetParallelWorldVolume(const G4String& paraName);
// set a reference to parallel world volume of the "importance" geometry
virtual G4bool IsKnown(const G4GeometryCell &gCell) const;
// returns true if the gCell is in the store, else false
virtual const G4VPhysicalVolume& GetWorldVolume() const;
// return a reference to the world volume of the "importance" geometry
void Clear();
virtual const G4VPhysicalVolume* GetParallelWorldVolumePointer() const;
// return a pointer to the world volume of the "importance" geometry
void SetWorldVolume();
// set a reference to the world volume of the
// "importance" geometry
void AddImportanceGeometryCell(G4double importance,
const G4GeometryCell &gCell);
void AddImportanceGeometryCell(G4double importance,
const G4VPhysicalVolume &,
G4int aRepNum = 0);
// add a "cell" together with a importance value to the store.
void SetParallelWorldVolume(G4String paraName);
// set a reference to the parallel world volume of the
// "importance" geometry
void ChangeImportance(G4double importance, const G4GeometryCell& gCell);
void ChangeImportance(G4double importance, const G4VPhysicalVolume&,
G4int aRepNum = 0);
// change a importance value of a "cell".
virtual const G4VPhysicalVolume& GetWorldVolume() const;
// return a reference to the world volume of the
// "importance" geometry
// virtual const G4VPhysicalVolume& GetParallelWorldVolume() const;
// // return a reference to the world volume of the
// // "importance" geometry
virtual const G4VPhysicalVolume* GetParallelWorldVolumePointer() const;
// return a pointer to the world volume of the
// "importance" geometry
void AddImportanceGeometryCell(G4double importance,
const G4GeometryCell &gCell);
void AddImportanceGeometryCell(G4double importance,
const G4VPhysicalVolume &,
G4int aRepNum = 0);
// Add a "cell" together with a importance value to the store.
void ChangeImportance(G4double importance,
const G4GeometryCell &gCell);
void ChangeImportance(G4double importance,
const G4VPhysicalVolume &,
G4int aRepNum = 0);
// Change a importance value of a "cell".
G4double GetImportance(const G4VPhysicalVolume &,
G4int aRepNum = 0) const ;
G4double GetImportance(const G4VPhysicalVolume&, G4int aRepNum = 0) const;
private:
protected:
G4bool IsInWorld(const G4VPhysicalVolume &) const;
void SetInternalIterator(const G4GeometryCell &gCell) const;
void Error(const G4String &m) const;
private:
explicit G4IStore();
// initialise the importance store for the given geometry
explicit G4IStore(const G4String& ParallelWorldName);
// initialise the importance store for the given geometry
~G4IStore();
// destructor
private:
G4bool IsInWorld(const G4VPhysicalVolume&) const;
void SetInternalIterator(const G4GeometryCell& gCell) const;
void Error(const G4String& m) const;
private:
const G4VPhysicalVolume* fWorldVolume;
// const G4VPhysicalVolume* fParallelWorldVolume;
// G4bool fParaFlag;
G4GeometryCellImportance fGeometryCelli;
const G4VPhysicalVolume* fWorldVolume = nullptr;
G4GeometryCellImportance fGeometryCelli;
mutable G4GeometryCellImportance::const_iterator fCurrentIterator;
mutable G4GeometryCellImportance::const_iterator fCurrentIterator;
static G4ThreadLocal G4IStore* fInstance;
static G4ThreadLocal G4IStore* fInstance;
#ifdef G4MULTITHREADED
static G4Mutex IStoreMutex;
static G4Mutex IStoreMutex;
#endif
};
@@ -23,51 +23,47 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ----------------------------------------------------------------------
// Class G4ImportanceAlgorithm
// G4ImportanceAlgorithm
//
// Class description:
//
// An implementation of a G4VImportanceAlgorithm (see description in
// G4VImportanceAlgorithm.hh).
// G4VImportanceAlgorithm header).
// Author: Michael Dressel (Michael.Dressel@cern.ch)
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#ifndef G4ImportanceAlgorithm_hh
#define G4ImportanceAlgorithm_hh G4ImportanceAlgorithm_hh
#ifndef G4IMPORTANCEALGORITHM_HH
#define G4IMPORTANCEALGORITHM_HH 1
#include "G4VImportanceAlgorithm.hh"
class G4ImportanceAlgorithm : public G4VImportanceAlgorithm
{
public: // with description
public: // with description
G4ImportanceAlgorithm();
// simple construction
G4ImportanceAlgorithm();
// simple construction
virtual ~G4ImportanceAlgorithm();
// repeate warning if triggered
virtual ~G4ImportanceAlgorithm();
// repeate warning if triggered
virtual G4Nsplit_Weight Calculate(G4double ipre,
G4double ipost,
G4double init_w) const;
// calculate the number of tracks and their weight according to the
// pre and post importance value and the weight of the mother track
virtual G4Nsplit_Weight Calculate(G4double ipre,
G4double ipost,
G4double init_w) const;
// calculate the number of tracks and their weight according
// to the pre and post importance value and the weight of
// the mother track.
private:
private:
void Error(const G4String &m) const;
void Warning(const G4String &m) const;
void Error(const G4String& m) const;
void Warning(const G4String& m) const;
private:
private:
mutable G4bool fWorned;
mutable G4bool fWarned = false;
#ifdef G4MULTITHREADED
static G4Mutex ImportanceMutex;
static G4Mutex ImportanceMutex;
#endif
};
@@ -23,20 +23,17 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ----------------------------------------------------------------------
// Class G4Nsplit_Weight
// G4Nsplit_Weight
//
// Class description:
//
// A class (struct) used by importance sampling. It contains the number
// of tracks a mother track should be split into and their weight.
// Author: Michael Dressel (Michael.Dressel@cern.ch)
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#ifndef G4Nsplit_Weight_hh
#define G4Nsplit_Weight_hh G4Nsplit_Weight_hh
#ifndef G4NSPLIT_WEIGHT_HH
#define G4NSPLIT_WEIGHT_HH 1
#include "globals.hh"
@@ -44,26 +41,14 @@ class G4Nsplit_Weight
{
public:
G4int fN;
// number of tracks a mother track should be split into
// including the mother track
G4int fN = 0;
// number of tracks a mother track should be split into
// including the mother track
G4double fW;
// the weight to be given to the tracks
G4double fW = 0.0;
// the weight to be given to the tracks
};
std::ostream& operator<<(std::ostream &out,
const G4Nsplit_Weight &nw);
std::ostream& operator<<(std::ostream& out, const G4Nsplit_Weight& nw);
#endif
@@ -23,23 +23,19 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ----------------------------------------------------------------------
// Class G4VGCellFinder
// G4VGCellFinder
//
// Class description:
//
// An interface of an GCellFinder. The G4GeometryCell is obtained
// in the parallel geometry from G4VParallelStepper and in the
// mass geometry form G4Step. This interface allows to implement
// mass geometry from G4Step. This interface allows to implement
// the two different ways to get a G4GeometryCell used by a process.
//
// Author: Michael Dressel (Michael.Dressel@cern.ch)
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#ifndef G4VGCellFinder_hh
#define G4VGCellFinder_hh G4VGCellFinder_hh
#ifndef G4VGCELLFINDER_HH
#define G4VGCELLFINDER_HH 1
#include "globals.hh"
#include "G4GeometryCell.hh"
@@ -48,17 +44,13 @@ class G4Step;
class G4VGCellFinder
{
public: // with description
public: // with description
G4VGCellFinder();
virtual ~G4VGCellFinder();
G4VGCellFinder();
virtual ~G4VGCellFinder();
virtual G4GeometryCell
GetPreGeometryCell(const G4Step &aStep) const=0;
virtual G4GeometryCell
GetPostGeometryCell(const G4Step &aStep) const=0;
virtual G4GeometryCell GetPreGeometryCell(const G4Step& aStep) const = 0;
virtual G4GeometryCell GetPostGeometryCell(const G4Step& aStep) const = 0;
};
#endif
+13 -17
View File
@@ -23,10 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ----------------------------------------------------------------------
// Class G4VIStore
// G4VIStore
//
// Class description:
//
@@ -37,10 +34,10 @@
// from the "importance store".
//
// Author: Michael Dressel (Michael.Dressel@cern.ch)
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#ifndef G4VIStore_hh
#define G4VIStore_hh G4VIStore_hh
#ifndef G4VISTORE_HH
#define G4VISTORE_HH 1
#include "globals.hh"
@@ -49,20 +46,19 @@ class G4VPhysicalVolume;
class G4VIStore
{
public: // with description
public: // with description
G4VIStore();
virtual ~G4VIStore();
G4VIStore();
virtual ~G4VIStore();
virtual G4double GetImportance(const G4GeometryCell& gCell) const = 0;
// derive a importance value of a "cell" addressed by a G4GeometryCell
// from the store
virtual G4double GetImportance(const G4GeometryCell &gCell) const = 0;
// derive a importance value of a "cell" addresed by a G4GeometryCell
// from the store.
virtual G4bool IsKnown(const G4GeometryCell& gCell) const = 0;
// returns true if the gCell is in the store, else false
virtual G4bool IsKnown(const G4GeometryCell &gCell) const = 0;
// returns true if the gCell is in the store, else false
virtual const G4VPhysicalVolume &GetWorldVolume() const = 0;
virtual const G4VPhysicalVolume& GetWorldVolume() const = 0;
};
#endif
@@ -23,10 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ----------------------------------------------------------------------
// Class G4VImportanceAlgorithm
// G4VImportanceAlgorithm
//
// Class description:
//
@@ -40,26 +37,24 @@
// A user defined algorithm deriving from this interface may be used
// by the importance sampling.
// Author: Michael Dressel (Michael.Dressel@cern.ch)
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#ifndef G4VImportanceAlgorithm_hh
#define G4VImportanceAlgorithm_hh G4VImportanceAlgorithm_hh
#ifndef G4VIMPORTANCEALGORITHM_HH
#define G4VIMPORTANCEALGORITHM_HH 1
#include "G4Nsplit_Weight.hh"
class G4VImportanceAlgorithm
{
public: // with description
public: // with description
G4VImportanceAlgorithm();
virtual ~G4VImportanceAlgorithm();
virtual G4Nsplit_Weight Calculate(G4double ipre,
G4double ipost,
G4double init_w) const = 0;
// calculate the number of tracks and their weight according
// to the pre and post importance value and the weight of
// the mother track.
G4VImportanceAlgorithm();
virtual ~G4VImportanceAlgorithm();
virtual G4Nsplit_Weight Calculate(G4double ipre,
G4double ipost,
G4double init_w) const = 0;
// calculate the number of tracks and their weight according to the
// pre and post importance value and the weight of the mother track
};
#endif
@@ -23,10 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ----------------------------------------------------------------------
// Class G4VImportanceSplitExaminer
// G4VImportanceSplitExaminer
//
// Class description:
//
@@ -36,22 +33,22 @@
// remaining necessary information about the ratio of importances
// in the pre and post "cell".
// Author: Michael Dressel (Michael.Dressel@cern.ch)
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#ifndef G4VImportanceSplitExaminer_hh
#define G4VImportanceSplitExaminer_hh G4VImportanceSplitExaminer_hh
#ifndef G4VIMPORTANCESPLITEXAMINER_HH
#define G4VIMPORTANCESPLITEXAMINER_HH 1
#include "globals.hh"
#include "G4Nsplit_Weight.hh"
class G4VImportanceSplitExaminer
{
public: // with description
public: // with description
G4VImportanceSplitExaminer();
virtual ~G4VImportanceSplitExaminer();
virtual G4Nsplit_Weight Examine(G4double w) const = 0;
// Get G4Nsplit_Weight for a given mother track weight.
G4VImportanceSplitExaminer();
virtual ~G4VImportanceSplitExaminer();
virtual G4Nsplit_Weight Examine(G4double w) const = 0;
// Get G4Nsplit_Weight for a given mother track weight
};
#endif
@@ -23,40 +23,33 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ----------------------------------------------------------------------
// Class G4VWeightWindowAlgorithm
// G4VWeightWindowAlgorithm
//
// Class description:
//
// Interface class for an weight window algorithm. It calculates
// Interface class for a weight window algorithm. It calculates
// the number of tracks and their weight according to the inital
// track weight and the lower energy bound in the energy-space
// cell.
//
// Author: Michael Dressel (Michael.Dressel@cern.ch)
// Author: Michael Dressel (CERN), 2003
// ----------------------------------------------------------------------
#ifndef G4VWeightWindowAlgorithm_hh
#define G4VWeightWindowAlgorithm_hh G4VWeightWindowAlgorithm_hh
#ifndef G4VWEIGHTWINDOWALGORITHM_HH
#define G4VWEIGHTWINDOWALGORITHM_HH 1
#include "G4Nsplit_Weight.hh"
class G4VWeightWindowAlgorithm
{
public: // with description
public: // with description
G4VWeightWindowAlgorithm();
virtual ~G4VWeightWindowAlgorithm();
virtual G4Nsplit_Weight Calculate(G4double init_w,
G4double lowerWeightBound) const = 0;
// calculate number of tracks and their weight according
// to the initial track weight and the lower energy bound
G4VWeightWindowAlgorithm();
virtual ~G4VWeightWindowAlgorithm();
virtual G4Nsplit_Weight Calculate(G4double init_w,
G4double lowerWeightBound) const = 0;
// calculate number of tracks and their weight according
// to the initial track weight and the lower energy bound
};
#endif
@@ -23,10 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ----------------------------------------------------------------------
// Class G4VWeightWindowStore
// G4VWeightWindowStore
//
// Class description:
//
@@ -34,36 +31,33 @@
// weight window bound can be obtained from a weight window store.
//
// Author: Michael Dressel (Michael.Dressel@cern.ch)
// Author: Michael Dressel (CERN), 2003
// ----------------------------------------------------------------------
#ifndef G4VWeightWindowStore_hh
#define G4VWeightWindowStore_hh G4VWeightWindowStore_hh
#ifndef G4VWEIGHTWINDOWSTORE_HH
#define G4VWEIGHTWINDOWSTORE_HH 1
#include "globals.hh"
class G4GeometryCell;
class G4VPhysicalVolume;
class G4VWeightWindowStore
class G4VWeightWindowStore
{
public: // with description
public: // with description
G4VWeightWindowStore();
virtual ~G4VWeightWindowStore();
G4VWeightWindowStore();
virtual ~G4VWeightWindowStore();
virtual G4double GetLowerWeight(const G4GeometryCell& gCell,
G4double partEnergy) const = 0;
// derive a lower weight bound value of a "cell" addresed by a
// G4GeometryCell and the coresponding energy from the store.
virtual G4double GetLowerWeight(const G4GeometryCell &gCell,
G4double partEnergy) const = 0;
// derive a lower weight bound value of a "cell" addresed by a
// G4GeometryCell and the coresponding energy from the store.
virtual G4bool IsKnown(const G4GeometryCell& gCell) const = 0;
// returns true if the gCell is in the store, else false
virtual G4bool IsKnown(const G4GeometryCell &gCell) const = 0;
// returns true if the gCell is in the store, else false
virtual const G4VPhysicalVolume &GetWorldVolume() const = 0;
// return a reference to the wolrd volume of the
// geometry
virtual const G4VPhysicalVolume &GetWorldVolume() const = 0;
// return a reference to the wolrd volume of the geometry
};
#endif
@@ -23,57 +23,53 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ----------------------------------------------------------------------
// Class G4WeightWindowAlgorithm
// G4WeightWindowAlgorithm
//
// Class description:
//
// Implementation of a weight window algorithm.
// The arguments in the constructor configure the algorithm:
// - upperLimitFaktor: the factor defining the upper weight limit
// W_u = upperLimitFaktor * W_l (W_l lower weight bound)
// - survivalFaktor: used in calculating the survival weight
// W_s = survivalFaktor * W_l
// - upperLimitFactor: the factor defining the upper weight limit
// W_u = upperLimitFactor * W_l (W_l lower weight bound)
// - survivalFactor: used in calculating the survival weight
// W_s = survivalFactor * W_l
// - maxNumberOfSplits: the maximal number of splits allowed
// to be created in one go, and the reciprocal of the minimal
// survival probability in case of Russian roulette
//
// In case of upperLimitFaktor=survivalFaktor=1 the algorithm
// becomes the expected weight algorithm of the importance sampling
// technique.
//
// see also G4VWeightWindowAlgorithm.
// In case of upperLimitFactor=survivalFactor=1 the algorithm becomes
// the expected weight algorithm of the importance sampling technique.
//
// See also G4VWeightWindowAlgorithm.
// Author: Michael Dressel (Michael.Dressel@cern.ch)
// Author: Michael Dressel (CERN), 2003
// ----------------------------------------------------------------------
#ifndef G4WeightWindowAlgorithm_hh
#define G4WeightWindowAlgorithm_hh G4WeightWindowAlgorithm_hh
#ifndef G4WEIGHTWINDOWALGORITHM_HH
#define G4WEIGHTWINDOWALGORITHM_HH 1
#include "G4Nsplit_Weight.hh"
#include "G4VWeightWindowAlgorithm.hh"
class G4WeightWindowAlgorithm : public G4VWeightWindowAlgorithm
{
public: // with description
public: // with description
G4WeightWindowAlgorithm(G4double upperLimitFaktor = 5,
G4double survivalFaktor = 3,
G4int maxNumberOfSplits = 5);
G4WeightWindowAlgorithm(G4double upperLimitFactor = 5,
G4double survivalFactor = 3,
G4int maxNumberOfSplits = 5);
virtual ~G4WeightWindowAlgorithm();
virtual ~G4WeightWindowAlgorithm();
virtual G4Nsplit_Weight Calculate(G4double init_w,
G4double lowerWeightBound) const;
// calculate number of tracks and their weight according
// to the initial track weight and the lower energy bound
virtual G4Nsplit_Weight Calculate(G4double init_w,
G4double lowerWeightBound) const;
// calculate number of tracks and their weight according
// to the initial track weight and the lower energy bound
private:
G4double fUpperLimitFaktor;
G4double fSurvivalFaktor;
G4int fMaxNumberOfSplits;
private:
G4double fUpperLimitFactor = 0.0;
G4double fSurvivalFactor = 0.0;
G4int fMaxNumberOfSplits = 0;
};
#endif
@@ -23,31 +23,19 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
// ----------------------------------------------------------------------
// Class G4WeightWindowStore
// G4WeightWindowStore
//
// Class description:
//
// Implementation of a weight window store according to the
// G4VWeightWindowStore interface.
// See G4VWeightWindowStore.
// See also G4VWeightWindowStore.
// Author: Michael Dressel (Michael.Dressel@cern.ch)
//
// Alex Howard (alexander.howard@cern.ch):
// Changed class to a `singleton', with access via the static method
// G4WeightWindowStore::GetInstance().
//
// Member data:
//
// static G4WeightWindowStore* fInstance
// - Ptr to the unique instance of class
//
// Author: Michael Dressel (CERN), 2003
// Modified: Alex Howard (CERN), 2013 - Changed class to a 'singleton'
// ----------------------------------------------------------------------
#ifndef G4WeightWindowStore_hh
#define G4WeightWindowStore_hh G4WeightWindowStore_hh
#ifndef G4WEIGHTWINDOWSTORE_HH
#define G4WEIGHTWINDOWSTORE_HH 1
#include "G4VWeightWindowStore.hh"
#include "G4GeometryCellWeight.hh"
@@ -56,81 +44,69 @@
class G4WeightWindowStore: public G4VWeightWindowStore
{
public: // with description
public: // with description
static G4WeightWindowStore* GetInstance();
// return ptr to singleton instance of the class
static G4WeightWindowStore* GetInstance();
// Return ptr to singleton instance of the class.
static G4WeightWindowStore* GetInstance(const G4String& ParallelWorldName);
// return ptr to singleton instance of the class
static G4WeightWindowStore* GetInstance(const G4String& ParallelWorldName);
// Return ptr to singleton instance of the class.
virtual G4double GetLowerWeight(const G4GeometryCell& gCell,
G4double partEnergy) const;
// derive a lower weight bound value of a "cell" addressed by a
// G4GeometryCell and the corresponding energy from the store
protected:
virtual G4bool IsKnown(const G4GeometryCell &gCell) const;
// returns true if the gCell is in the store, else false
explicit G4WeightWindowStore();
// initialise the weight window store for the given geometry
explicit G4WeightWindowStore(const G4String& ParallelWorldName);
// initialise the weight window store for the given geometry
void Clear();
~G4WeightWindowStore();
// destructor
void SetWorldVolume();
// set a pointer to the world volume of the weightwindow geometry
void SetParallelWorldVolume(const G4String& paraName);
// set a pointer to parallel world volume of the weightwindow geometry
public: // with description
virtual const G4VPhysicalVolume& GetWorldVolume() const;
// return a reference to the world volume of the weightwindow geometry
virtual const G4VPhysicalVolume* GetParallelWorldVolumePointer() const;
// return a pointer to parallel world volume of the weightwindow geometry
virtual G4double GetLowerWeight(const G4GeometryCell &gCell,
G4double partEnergy) const;
// derive a lower weight bound value of a "cell" addresed by a
// G4GeometryCell and the coresponding energy from the store.
void AddLowerWeights(const G4GeometryCell& gCell,
const std::vector<G4double>& lowerWeights);
// add lower weights. Only if general upper energy bounds have been set
virtual G4bool IsKnown(const G4GeometryCell &gCell) const;
// returns true if the gCell is in the store, else false
void AddUpperEboundLowerWeightPairs(const G4GeometryCell& gCell,
const G4UpperEnergyToLowerWeightMap& enWeMap);
// set upper energy - lower weight pairs for a cell
void Clear();
void SetGeneralUpperEnergyBounds(const std::set<G4double,
std::less<G4double> >& enBounds);
protected:
void SetWorldVolume();
// set a pointer to the world volume of the
// weightwindow geometry
void SetParallelWorldVolume(G4String paraName);
// set a pointer to the parallel world volume of the
// weightwindow geometry
explicit G4WeightWindowStore();
// initialise the weight window store for the given geometry
explicit G4WeightWindowStore(const G4String& ParallelWorldName);
// initialise the weight window store for the given geometry
~G4WeightWindowStore();
// destructor
virtual const G4VPhysicalVolume &GetWorldVolume() const;
// return a reference to the world volume of the
// weightwindow geometry
virtual const G4VPhysicalVolume* GetParallelWorldVolumePointer() const;
// return a pointer to the parallel world volume of the
// weightwindow geometry
private:
void AddLowerWeights(const G4GeometryCell &gCell,
const std::vector<G4double> &lowerWeights);
// add lower weights. Only if general upper energy bounds have
// been set
void AddUpperEboundLowerWeightPairs(const G4GeometryCell &gCell,
const G4UpperEnergyToLowerWeightMap&
enWeMap);
// set upper energy - lower weight pairs for a cell
G4bool IsInWorld(const G4VPhysicalVolume&) const;
void Error(const G4String& m) const;
void SetInternalIterator(const G4GeometryCell& gCell) const;
void SetGeneralUpperEnergyBounds(const std::set<G4double, std::less<G4double> > &enBounds);
private:
private:
G4bool IsInWorld(const G4VPhysicalVolume &) const;
void Error(const G4String &m) const;
void SetInternalIterator(const G4GeometryCell &gCell) const;
private:
const G4VPhysicalVolume* fWorldVolume = nullptr;
const G4VPhysicalVolume* fWorldVolume;
// G4bool fParaFlag;
std::set<G4double, std::less<G4double> > fGeneralUpperEnergyBounds;
G4GeometryCellWeight fCellToUpEnBoundLoWePairsMap;
mutable G4GeometryCellWeight::const_iterator fCurrentIterator;
std::set<G4double, std::less<G4double> > fGeneralUpperEnergyBounds;
G4GeometryCellWeight fCellToUpEnBoundLoWePairsMap;
mutable G4GeometryCellWeight::const_iterator fCurrentIterator;
static G4ThreadLocal G4WeightWindowStore* fInstance;
static G4ThreadLocal G4WeightWindowStore* fInstance;
};
#endif
+24 -24
View File
@@ -23,28 +23,23 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4GeometryCell implementation
//
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4GeometryCell.cc
//
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#include "G4GeometryCell.hh"
G4GeometryCell::G4GeometryCell(const G4VPhysicalVolume &aVolume,
G4GeometryCell::G4GeometryCell(const G4VPhysicalVolume& aVolume,
G4int RepNum)
: fVPhysicalVolume(&aVolume),
fRepNum(RepNum)
: fVPhysicalVolume(&aVolume), fRepNum(RepNum)
{}
G4GeometryCell::~G4GeometryCell()
{}
const G4VPhysicalVolume &G4GeometryCell::GetPhysicalVolume() const
const G4VPhysicalVolume& G4GeometryCell::GetPhysicalVolume() const
{
return *fVPhysicalVolume;
}
@@ -55,14 +50,15 @@ G4int G4GeometryCell::GetReplicaNumber() const
}
G4GeometryCell::G4GeometryCell(const G4GeometryCell &rhs)
: fVPhysicalVolume(rhs.fVPhysicalVolume),
fRepNum(rhs.fRepNum)
G4GeometryCell::G4GeometryCell(const G4GeometryCell& rhs)
: fVPhysicalVolume(rhs.fVPhysicalVolume), fRepNum(rhs.fRepNum)
{
}
G4GeometryCell &G4GeometryCell::operator=(const G4GeometryCell &rhs){
if (this != &rhs) {
G4GeometryCell& G4GeometryCell::operator=(const G4GeometryCell& rhs)
{
if (this != &rhs)
{
fVPhysicalVolume = rhs.fVPhysicalVolume; // this is treated
// as identifyer
fRepNum = rhs.fRepNum;
@@ -71,26 +67,30 @@ G4GeometryCell &G4GeometryCell::operator=(const G4GeometryCell &rhs){
}
G4bool operator==(const G4GeometryCell &k1, const G4GeometryCell &k2)
G4bool operator==(const G4GeometryCell& k1, const G4GeometryCell& k2)
{
G4bool equal=true;
if (&(k1.GetPhysicalVolume()) != &(k2.GetPhysicalVolume())) {
G4bool equal = true;
if (&(k1.GetPhysicalVolume()) != &(k2.GetPhysicalVolume()))
{
equal = false;
}
else if (k1.GetReplicaNumber() != k2.GetReplicaNumber()) {
else if (k1.GetReplicaNumber() != k2.GetReplicaNumber())
{
equal = false;
}
return equal;
}
G4bool operator!=(const G4GeometryCell &k1, const G4GeometryCell &k2)
G4bool operator!=(const G4GeometryCell& k1, const G4GeometryCell& k2)
{
G4bool unequal = false;
if (&(k1.GetPhysicalVolume()) != &(k2.GetPhysicalVolume())) {
unequal = true;
if (&(k1.GetPhysicalVolume()) != &(k2.GetPhysicalVolume()))
{
unequal = true;
}
else if (k1.GetReplicaNumber() != k2.GetReplicaNumber()) {
unequal = true;
else if (k1.GetReplicaNumber() != k2.GetReplicaNumber())
{
unequal = true;
}
return unequal;
}
@@ -23,30 +23,29 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4GeometryCellCmp implementation
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4GeometryCellCmp.cc
//
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#include "G4GeometryCellComp.hh"
#include "G4GeometryCell.hh"
//#include "G4VPhysicalVolume.hh"
G4GeometryCellComp::G4GeometryCellComp()
{}
G4bool G4GeometryCellComp::operator() (const G4GeometryCell &k1,
const G4GeometryCell &k2) const
{
G4bool smaler=false;
if (&(k1.GetPhysicalVolume()) != &(k2.GetPhysicalVolume())) {
smaler = &(k1.GetPhysicalVolume()) < &(k2.GetPhysicalVolume());
} else {
smaler = k1.GetReplicaNumber() < k2.GetReplicaNumber();
}
return smaler;
}
G4bool G4GeometryCellComp::operator() (const G4GeometryCell& k1,
const G4GeometryCell& k2) const
{
G4bool smaller = false;
if (&(k1.GetPhysicalVolume()) != &(k2.GetPhysicalVolume()))
{
smaller = &(k1.GetPhysicalVolume()) < &(k2.GetPhysicalVolume());
}
else
{
smaller = k1.GetReplicaNumber() < k2.GetReplicaNumber();
}
return smaller;
}
@@ -23,22 +23,19 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4GeometryCellImportance implementation
//
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4GeometryCellImportance.cc
//
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#include "G4GeometryCellImportance.hh"
#include "G4GeometryCellStepStream.hh"
std::ostream& operator<<(std::ostream &out, const G4GeometryCellImportance &gCelli)
std::ostream& operator<<(std::ostream& out,
const G4GeometryCellImportance& gCelli)
{
for (G4GeometryCellImportance::const_iterator it = gCelli.begin();
it != gCelli.end(); ++it) {
for (auto it = gCelli.cbegin(); it != gCelli.cend(); ++it)
{
out << (*it).first << ", importance = ";
out << (*it).second << "\n";
}
@@ -23,24 +23,19 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4GeometryCellStep implementation
//
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4GeometryCellStep.cc
//
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#include "G4GeometryCellStep.hh"
G4GeometryCellStep::G4GeometryCellStep(const G4GeometryCell &preCell,
const G4GeometryCell &postCell)
:
fPreGeometryCell(preCell),
fPostGeometryCell(postCell),
fCrossBoundary(false)
{}
G4GeometryCellStep::G4GeometryCellStep(const G4GeometryCell& preCell,
const G4GeometryCell& postCell)
: fPreGeometryCell(preCell), fPostGeometryCell(postCell)
{
}
G4GeometryCellStep::~G4GeometryCellStep()
{}
{
}
@@ -23,27 +23,23 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4GeometryCellStepStream implementation
//
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4GeometryCellStepStream.cc
//
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#include "G4GeometryCellStepStream.hh"
#include "G4VPhysicalVolume.hh"
#include "G4GeometryCellStep.hh"
std::ostream& operator<<(std::ostream &out, const G4GeometryCell &tk)
std::ostream& operator<<(std::ostream& out, const G4GeometryCell& tk)
{
out << "Volume name = " << tk.GetPhysicalVolume().GetName() << ", ";
out << "Replica number = " << tk.GetReplicaNumber();
return out;
}
std::ostream& operator<<(std::ostream &out, const G4GeometryCellStep &ps)
std::ostream& operator<<(std::ostream& out, const G4GeometryCellStep& ps)
{
out << "PreGeometryCell : " << ps.GetPreGeometryCell() << " ";
out << "PostGeometryCell: " << ps.GetPostGeometryCell() << " ";
+78 -66
View File
@@ -23,13 +23,10 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4IStore implementation
//
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4IStore.cc
//
// Author: Michael Dressel (CERN), 2002
// Modified: Alex Howard (CERN), 2013 - Changed class to a 'singleton'
// ----------------------------------------------------------------------
#include "G4IStore.hh"
@@ -46,21 +43,29 @@ G4Mutex G4IStore::IStoreMutex = G4MUTEX_INITIALIZER;
// ***************************************************************************
// Static class variable: ptr to single instance of class
// ***************************************************************************
G4ThreadLocal G4IStore* G4IStore::fInstance = 0;
G4ThreadLocal G4IStore* G4IStore::fInstance = nullptr;
G4IStore::G4IStore() :
fWorldVolume(G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume())
{}
G4IStore::G4IStore(const G4String& ParallelWorldName) :
fWorldVolume(G4TransportationManager::GetTransportationManager()->GetParallelWorld(ParallelWorldName))
G4IStore::G4IStore()
: fWorldVolume(G4TransportationManager::GetTransportationManager()
->GetNavigatorForTracking()->GetWorldVolume())
{
G4cout << " G4IStore:: ParallelWorldName = " << ParallelWorldName << G4endl;
G4cout << " G4IStore:: fParallelWorldVolume = " << fWorldVolume->GetName() << G4endl;
}
G4IStore::G4IStore(const G4String& ParallelWorldName)
: fWorldVolume(G4TransportationManager::GetTransportationManager()
->GetParallelWorld(ParallelWorldName))
{
#ifdef G4VERBOSE
G4cout << " G4IStore:: ParallelWorldName = "
<< ParallelWorldName << G4endl;
G4cout << " G4IStore:: fParallelWorldVolume = "
<< fWorldVolume->GetName() << G4endl;
#endif
}
G4IStore::~G4IStore()
{}
{
}
void G4IStore::Clear()
{
@@ -70,17 +75,19 @@ void G4IStore::Clear()
void G4IStore::SetWorldVolume()
{
G4cout << " G4IStore:: SetWorldVolume " << G4endl;
fWorldVolume = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
fWorldVolume = G4TransportationManager::GetTransportationManager()
->GetNavigatorForTracking()->GetWorldVolume();
G4cout << " World volume is: " << fWorldVolume->GetName() << G4endl;
// fGeometryCelli = new G4GeometryCellImportance;
// fGeometryCelli = new G4GeometryCellImportance;
}
void G4IStore::SetParallelWorldVolume(G4String paraName)
void G4IStore::SetParallelWorldVolume(const G4String& paraName)
{
G4cout << " G4IStore:: SetParallelWorldVolume " << G4endl;
fWorldVolume = G4TransportationManager::GetTransportationManager()->GetParallelWorld(paraName);
fWorldVolume = G4TransportationManager::GetTransportationManager()
->GetParallelWorld(paraName);
G4cout << " ParallelWorld volume is: " << fWorldVolume->GetName() << G4endl;
// fGeometryCelli = new G4GeometryCellImportance;
// fGeometryCelli = new G4GeometryCellImportance;
}
const G4VPhysicalVolume& G4IStore::GetWorldVolume() const
@@ -88,76 +95,79 @@ const G4VPhysicalVolume& G4IStore::GetWorldVolume() const
return *fWorldVolume;
}
// const G4VPhysicalVolume& G4IStore::GetParallelWorldVolume() const
// {
// return *fParallelWorldVolume;
// }
const G4VPhysicalVolume* G4IStore::GetParallelWorldVolumePointer() const
{
return fWorldVolume;
}
void G4IStore::SetInternalIterator(const G4GeometryCell &gCell) const
void G4IStore::SetInternalIterator(const G4GeometryCell& gCell) const
{
fCurrentIterator = fGeometryCelli.find(gCell);
}
void G4IStore::AddImportanceGeometryCell(G4double importance,
const G4GeometryCell &gCell)
const G4GeometryCell& gCell)
{
if (importance < 0 ) {
if (importance < 0 )
{
Error("AddImportanceGeometryCell() - Invalid importance value given.");
}
if (!IsInWorld(gCell.GetPhysicalVolume()) ) {
if (!IsInWorld(gCell.GetPhysicalVolume()) )
{
Error("AddImportanceGeometryCell() - Physical volume not found!");
}
SetInternalIterator(gCell);
if (fCurrentIterator!=fGeometryCelli.end()) {
if (fCurrentIterator != fGeometryCelli.cend())
{
Error("AddImportanceGeometryCell() - Region already existing!");
}
fGeometryCelli[gCell] = importance;
}
void G4IStore::AddImportanceGeometryCell(G4double importance,
const G4VPhysicalVolume &aVolume,
G4int aRepNum)
const G4VPhysicalVolume& aVolume,
G4int aRepNum)
{
AddImportanceGeometryCell(importance,
G4GeometryCell(aVolume, aRepNum));
AddImportanceGeometryCell(importance, G4GeometryCell(aVolume, aRepNum));
}
void G4IStore::ChangeImportance(G4double importance,
const G4GeometryCell &gCell){
if (importance < 0 ) {
const G4GeometryCell& gCell)
{
if (importance < 0 )
{
Error("ChangeImportance() - Invalid importance value given.");
}
if (!IsInWorld(gCell.GetPhysicalVolume()) ) {
if (!IsInWorld(gCell.GetPhysicalVolume()))
{
Error("ChangeImportance() - Physical volume not found!");
}
SetInternalIterator(gCell);
if (fCurrentIterator==fGeometryCelli.end()) {
if (fCurrentIterator == fGeometryCelli.cend())
{
Error("ChangeImportance() - Region does not exist!");
}
fGeometryCelli[gCell] = importance;
}
void G4IStore::ChangeImportance(G4double importance,
const G4VPhysicalVolume &aVolume,
G4int aRepNum)
const G4VPhysicalVolume& aVolume,
G4int aRepNum)
{
ChangeImportance(importance, G4GeometryCell(aVolume, aRepNum));
}
G4double G4IStore::GetImportance(const G4VPhysicalVolume &aVolume,
G4int aRepNum) const
G4double G4IStore::GetImportance(const G4VPhysicalVolume& aVolume,
G4int aRepNum) const
{
#ifdef G4MULTITHREADED
G4MUTEXLOCK(&G4IStore::IStoreMutex);
#endif
SetInternalIterator(G4GeometryCell(aVolume, aRepNum));
G4GeometryCellImportance::const_iterator gCellIterator = fCurrentIterator;
if (gCellIterator==fGeometryCelli.end()) {
auto gCellIterator = fCurrentIterator;
if (gCellIterator == fGeometryCelli.cend())
{
Error("GetImportance() - Region does not exist!");
return 0.;
}
@@ -166,18 +176,17 @@ G4double G4IStore::GetImportance(const G4VPhysicalVolume &aVolume,
G4MUTEXUNLOCK(&G4IStore::IStoreMutex);
#endif
return importance_value;
// return (*fCurrentIterator).second;
}
G4double G4IStore::GetImportance(const G4GeometryCell &gCell) const
G4double G4IStore::GetImportance(const G4GeometryCell& gCell) const
{
#ifdef G4MULTITHREADED
G4MUTEXLOCK(&G4IStore::IStoreMutex);
#endif
SetInternalIterator(gCell);
G4GeometryCellImportance::const_iterator gCellIterator = fCurrentIterator;
if (gCellIterator==fGeometryCelli.end()) {
auto gCellIterator = fCurrentIterator;
if (gCellIterator == fGeometryCelli.cend())
{
std::ostringstream err_mess;
err_mess << "GetImportance() - Region does not exist!" << G4endl
<< "Geometry cell, " << gCell
@@ -193,15 +202,17 @@ G4double G4IStore::GetImportance(const G4GeometryCell &gCell) const
// return (*fCurrentIterator).second;
}
G4bool G4IStore::IsKnown(const G4GeometryCell &gCell) const {
G4bool G4IStore::IsKnown(const G4GeometryCell& gCell) const
{
#ifdef G4MULTITHREADED
G4MUTEXLOCK(&G4IStore::IStoreMutex);
#endif
G4bool inWorldKnown(IsInWorld(gCell.GetPhysicalVolume()));
if ( inWorldKnown ) {
if ( inWorldKnown )
{
SetInternalIterator(gCell);
inWorldKnown = (fCurrentIterator!=fGeometryCelli.end());
inWorldKnown = (fCurrentIterator != fGeometryCelli.cend());
}
#ifdef G4MULTITHREADED
G4MUTEXUNLOCK(&G4IStore::IStoreMutex);
@@ -209,20 +220,17 @@ G4bool G4IStore::IsKnown(const G4GeometryCell &gCell) const {
return inWorldKnown;
}
G4bool G4IStore::IsInWorld(const G4VPhysicalVolume &aVolume) const
G4bool G4IStore::IsInWorld(const G4VPhysicalVolume& aVolume) const
{
G4bool isIn(true);
// G4cout << "G4IStore:: aVolume: " << aVolume.GetName() << G4endl;
// G4cout << "G4IStore:: fWorld: " << fWorldVolume->GetName() << G4endl;
if (!(aVolume == *fWorldVolume)) {
isIn = fWorldVolume->GetLogicalVolume()->IsAncestor(&aVolume);
if (!(aVolume == *fWorldVolume))
{
isIn = fWorldVolume->GetLogicalVolume()->IsAncestor(&aVolume);
}
return isIn;
}
void G4IStore::Error(const G4String &msg) const
void G4IStore::Error(const G4String& msg) const
{
G4Exception("G4IStore::Error()", "GeomBias0002", FatalException, msg);
}
@@ -234,9 +242,11 @@ void G4IStore::Error(const G4String &msg) const
//
G4IStore* G4IStore::GetInstance()
{
if (!fInstance)
if (fInstance == nullptr)
{
#ifdef G4VERBOSE
G4cout << "G4IStore:: Creating new MASS IStore " << G4endl;
#endif
fInstance = new G4IStore();
}
return fInstance;
@@ -249,11 +259,13 @@ G4IStore* G4IStore::GetInstance()
//
G4IStore* G4IStore::GetInstance(const G4String& ParallelWorldName)
{
if (!fInstance)
if (fInstance == nullptr)
{
G4cout << "G4IStore:: Creating new Parallel IStore " << ParallelWorldName << G4endl;
#ifdef G4VERBOSE
G4cout << "G4IStore:: Creating new Parallel IStore "
<< ParallelWorldName << G4endl;
#endif
fInstance = new G4IStore(ParallelWorldName);
}
return fInstance;
}
@@ -23,13 +23,9 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4ImportanceAlgorithm implementation
//
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4ImportanceAlgorithm.cc
//
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#include "G4Types.hh"
@@ -43,7 +39,7 @@
G4Mutex G4ImportanceAlgorithm::ImportanceMutex = G4MUTEX_INITIALIZER;
#endif
G4ImportanceAlgorithm::G4ImportanceAlgorithm(): fWorned(false)
G4ImportanceAlgorithm::G4ImportanceAlgorithm()
{
}
@@ -53,7 +49,7 @@ G4ImportanceAlgorithm::~G4ImportanceAlgorithm()
G4Nsplit_Weight
G4ImportanceAlgorithm::Calculate(G4double ipre,
G4double ipost,
G4double ipost,
G4double init_w) const
{
@@ -61,23 +57,28 @@ G4ImportanceAlgorithm::Calculate(G4double ipre,
G4MUTEXLOCK(&G4ImportanceAlgorithm::ImportanceMutex);
#endif
G4Nsplit_Weight nw = {0,0};
if (ipost>0.){
if (!(ipre>0.)){
G4Nsplit_Weight nw;
if (ipost>0.)
{
if (!(ipre>0.))
{
Error("Calculate() - ipre==0.");
}
G4double ipre_over_ipost = ipre/ipost;
if ((ipre_over_ipost<0.25 || ipre_over_ipost> 4) && !fWorned) {
if ((ipre_over_ipost<0.25 || ipre_over_ipost> 4) && !fWarned)
{
std::ostringstream os;
os << "Calculate() - ipre_over_ipost ! in [0.25, 4]." << G4endl
<< "ipre_over_ipost = " << ipre_over_ipost << ".";
Warning(os.str());
fWorned = true;
if (ipre_over_ipost<=0) {
Error("Calculate() - ipre_over_ipost<=0.");
fWarned = true;
if (ipre_over_ipost<=0)
{
Error("Calculate() - ipre_over_ipost<=0.");
}
}
if (init_w<=0.) {
if (init_w<=0.)
{
Error("Calculate() - iniitweight<= 0. found!");
}
@@ -89,32 +90,36 @@ G4ImportanceAlgorithm::Calculate(G4double ipre,
nw.fW = init_w * ipre_over_ipost;
// geometrical splitting for double mode
if (ipre_over_ipost<1) {
if ( static_cast<G4double>(nw.fN) != inv) {
// double mode
// probability p for splitting into n+1 tracks
G4double p = inv - nw.fN;
// get a random number out of [0,1)
G4double r = G4UniformRand();
if (r<p) {
nw.fN++;
}
if (ipre_over_ipost<1)
{
if ( static_cast<G4double>(nw.fN) != inv)
{
// double mode
// probability p for splitting into n+1 tracks
G4double p = inv - nw.fN;
// get a random number out of [0,1)
G4double r = G4UniformRand();
if (r<p)
{
++nw.fN;
}
}
}
// ipre_over_ipost > 1
// russian roulett
else if (ipre_over_ipost>1) {
else if (ipre_over_ipost>1) // russian roulette
{
// probabiity for killing track
G4double p = 1-inv;
// get a random number out of [0,1)
G4double r = G4UniformRand();
if (r<p) {
// kill track
nw.fN = 0;
nw.fW = 0;
if (r<p)
{
// kill track
nw.fN = 0;
nw.fW = 0;
}
else {
nw.fN = 1;
else
{
nw.fN = 1;
}
}
}
@@ -124,13 +129,13 @@ G4ImportanceAlgorithm::Calculate(G4double ipre,
return nw;
}
void G4ImportanceAlgorithm::Error(const G4String &msg) const
void G4ImportanceAlgorithm::Error(const G4String& msg) const
{
G4Exception("G4ImportanceAlgorithm::Error()",
"GeomBias0002", FatalException, msg);
}
void G4ImportanceAlgorithm::Warning(const G4String &msg) const
void G4ImportanceAlgorithm::Warning(const G4String& msg) const
{
G4Exception("G4ImportanceAlgorithm::Warning()",
"GeomBias1001", JustWarning, msg);
@@ -23,18 +23,13 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4Nsplit_Weight implementation
//
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4Nsplit_Weight.cc
//
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#include "G4Nsplit_Weight.hh"
std::ostream& operator<<(std::ostream &out,
const G4Nsplit_Weight &nw)
std::ostream& operator<<(std::ostream& out, const G4Nsplit_Weight& nw)
{
out << "nw.fN = " << nw.fN << ", nw.fW = " << nw.fW;
return out;
@@ -23,18 +23,17 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VGCellFinder implementation
//
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4VGCellFinder.cc
//
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#include "G4VGCellFinder.hh"
G4VGCellFinder::G4VGCellFinder()
{}
{
}
G4VGCellFinder::~G4VGCellFinder()
{}
{
}
+6 -8
View File
@@ -23,19 +23,17 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VIStore implementation
//
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4VIStore.cc
//
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#include "G4VIStore.hh"
G4VIStore::G4VIStore()
{}
{
}
G4VIStore::~G4VIStore()
{}
{
}
@@ -23,19 +23,17 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VImportanceAlgortihm implementation
//
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4VImportanceAlgortihm.cc
//
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#include "G4VImportanceAlgorithm.hh"
G4VImportanceAlgorithm::G4VImportanceAlgorithm()
{}
{
}
G4VImportanceAlgorithm::~G4VImportanceAlgorithm()
{}
{
}
@@ -23,19 +23,17 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VImportanceSplitExaminer implementation
//
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4VImportanceSplitExaminer.cc
//
// Author: Michael Dressel (CERN), 2002
// ----------------------------------------------------------------------
#include "G4VImportanceSplitExaminer.hh"
G4VImportanceSplitExaminer::G4VImportanceSplitExaminer()
{}
{
}
G4VImportanceSplitExaminer::~G4VImportanceSplitExaminer()
{}
{
}
@@ -23,20 +23,17 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VWeightWindowAlgorithm implementation
//
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4VWeightWindowAlgorithm.cc
//
// Author: Michael Dressel (CERN), 2003
// ----------------------------------------------------------------------
#include "G4VWeightWindowAlgorithm.hh"
G4VWeightWindowAlgorithm::G4VWeightWindowAlgorithm()
{}
{
}
G4VWeightWindowAlgorithm::~G4VWeightWindowAlgorithm()
{}
{
}
@@ -23,17 +23,17 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VWeightWindowStore implementation
//
//
// Author: Michael Dressel (CERN), 2003
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4VWeightWindowStore
//
// ----------------------------------------------------------------------
#include "G4VWeightWindowStore.hh"
G4VWeightWindowStore::G4VWeightWindowStore(){}
G4VWeightWindowStore::~G4VWeightWindowStore(){}
G4VWeightWindowStore::G4VWeightWindowStore()
{
}
G4VWeightWindowStore::~G4VWeightWindowStore()
{
}
@@ -23,72 +23,63 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4WeightWindowAlgorithm implementation
//
//
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4WeightWindowAlgorithm.cc
//
// Author: Michael Dressel (CERN), 2003
// ----------------------------------------------------------------------
#include "G4WeightWindowAlgorithm.hh"
#include "Randomize.hh"
G4WeightWindowAlgorithm::
G4WeightWindowAlgorithm(G4double upperLimitFaktor,
G4double survivalFaktor,
G4int maxNumberOfSplits) :
fUpperLimitFaktor(upperLimitFaktor),
fSurvivalFaktor(survivalFaktor),
fMaxNumberOfSplits(maxNumberOfSplits)
{}
G4WeightWindowAlgorithm(G4double upperLimitFactor,
G4double survivalFactor,
G4int maxNumberOfSplits)
: fUpperLimitFactor(upperLimitFactor),
fSurvivalFactor(survivalFactor),
fMaxNumberOfSplits(maxNumberOfSplits)
{
}
G4WeightWindowAlgorithm::~G4WeightWindowAlgorithm()
{}
{
}
G4Nsplit_Weight
G4WeightWindowAlgorithm::Calculate(G4double init_w,
G4double lowerWeightBound) const {
G4double survivalWeight = lowerWeightBound * fSurvivalFaktor;
G4double upperWeight = lowerWeightBound * fUpperLimitFaktor;
G4double lowerWeightBound) const
{
G4double survivalWeight = lowerWeightBound * fSurvivalFactor;
G4double upperWeight = lowerWeightBound * fUpperLimitFactor;
// initialize return value for case weight in window
//
G4Nsplit_Weight nw;
nw.fN = 1;
nw.fW = init_w;
if (init_w > upperWeight) {
if (init_w > upperWeight)
{
// splitting
//TB G4double wi_ws = init_w/survivalWeight;
//TB
//
G4double temp_wi_ws = init_w/upperWeight;
G4int split_i = static_cast<int>(temp_wi_ws);
if(split_i != temp_wi_ws) split_i++;
G4int split_i = static_cast<G4int>(temp_wi_ws);
if(split_i != temp_wi_ws) { ++split_i; }
G4double wi_ws = init_w/split_i;
//TB
//TB G4int int_wi_ws = static_cast<int>(wi_ws);
// values in case integer mode or in csae of double
// mode and the lower number of splits will be diced
//TB nw.fN = int_wi_ws;
//TB nw.fW = survivalWeight;
//
nw.fN = split_i;
nw.fW = wi_ws;
nw.fW = wi_ws;
//TB if (wi_ws <= fMaxNumberOfSplits) {
//TB if (wi_ws > int_wi_ws) {
//TB // double mode
//TB G4double p2 = wi_ws - int_wi_ws;
//TB G4double r = G4UniformRand();
//TB if (r<p2) {
//TB nw.fN = int_wi_ws + 1;
//TB }
//TB // double mode
//TB G4double p2 = wi_ws - int_wi_ws;
//TB G4double r = G4UniformRand();
//TB if (r<p2) {
//TB nw.fN = int_wi_ws + 1;
//TB }
//TB }
//TB }
//TB else {
@@ -97,23 +88,25 @@ G4WeightWindowAlgorithm::Calculate(G4double init_w,
//TB nw.fW = init_w/fMaxNumberOfSplits;
//TB }
} else if (init_w < lowerWeightBound) {
// Russian roulette
}
else if (init_w < lowerWeightBound) // Russian roulette
{
G4double wi_ws = init_w/survivalWeight;
G4double p = std::max(wi_ws,1./fMaxNumberOfSplits);
G4double r = G4UniformRand();
if (r<p){
if (r<p)
{
nw.fW = init_w/p;
nw.fN = 1;
} else {
}
else
{
nw.fW = 0;
nw.fN = 0;
}
}
// else do nothing
return nw;
}
@@ -23,15 +23,11 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4WeightWindowStore implementation
//
//
// Author: Michael Dressel (CERN), 2003
// Modified: Alex Howard (CERN), 2013 - Changed class to a 'singleton'
// ----------------------------------------------------------------------
// GEANT 4 class source file
//
// G4WeightWindowStore
//
// ----------------------------------------------------------------------
#include "G4WeightWindowStore.hh"
#include "G4VPhysicalVolume.hh"
@@ -42,84 +38,92 @@
// ***************************************************************************
// Static class variable: ptr to single instance of class
// ***************************************************************************
G4ThreadLocal G4WeightWindowStore* G4WeightWindowStore::fInstance = 0;
G4ThreadLocal G4WeightWindowStore* G4WeightWindowStore::fInstance = nullptr;
G4WeightWindowStore::
G4WeightWindowStore() :
fWorldVolume(G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume()),
fGeneralUpperEnergyBounds(),
fCellToUpEnBoundLoWePairsMap(),
fCurrentIterator(fCellToUpEnBoundLoWePairsMap.end())
{}
G4WeightWindowStore()
: fWorldVolume(G4TransportationManager::GetTransportationManager()
->GetNavigatorForTracking()->GetWorldVolume()),
fGeneralUpperEnergyBounds(),
fCellToUpEnBoundLoWePairsMap(),
fCurrentIterator(fCellToUpEnBoundLoWePairsMap.cend())
{
}
G4WeightWindowStore::
G4WeightWindowStore(const G4String& ParallelWorldName) :
fWorldVolume(G4TransportationManager::GetTransportationManager()->GetParallelWorld(ParallelWorldName)),
fGeneralUpperEnergyBounds(),
fCellToUpEnBoundLoWePairsMap(),
fCurrentIterator(fCellToUpEnBoundLoWePairsMap.end())
{}
G4WeightWindowStore(const G4String& ParallelWorldName)
: fWorldVolume(G4TransportationManager::GetTransportationManager()
->GetParallelWorld(ParallelWorldName)),
fGeneralUpperEnergyBounds(),
fCellToUpEnBoundLoWePairsMap(),
fCurrentIterator(fCellToUpEnBoundLoWePairsMap.cend())
{
}
G4WeightWindowStore::~G4WeightWindowStore()
{}
G4WeightWindowStore::
~G4WeightWindowStore()
{
}
G4double G4WeightWindowStore::GetLowerWeight(const G4GeometryCell &gCell,
G4double partEnergy) const
G4double G4WeightWindowStore::
GetLowerWeight(const G4GeometryCell& gCell,
G4double partEnergy) const
{
SetInternalIterator(gCell);
G4GeometryCellWeight::const_iterator gCellIterator = fCurrentIterator;
if (gCellIterator == fCellToUpEnBoundLoWePairsMap.end()) {
auto gCellIterator = fCurrentIterator;
if (gCellIterator == fCellToUpEnBoundLoWePairsMap.cend())
{
Error("GetLowerWitgh() - Cell does not exist!");
return 0.;
}
G4UpperEnergyToLowerWeightMap upEnLoWeiPairs =
fCurrentIterator->second;
G4UpperEnergyToLowerWeightMap upEnLoWeiPairs = fCurrentIterator->second;
G4double lowerWeight = -1;
G4bool found = false;
for (G4UpperEnergyToLowerWeightMap::iterator it =
upEnLoWeiPairs.begin(); it != upEnLoWeiPairs.end(); it++) {
if (partEnergy < it->first) {
for (auto it = upEnLoWeiPairs.cbegin(); it != upEnLoWeiPairs.cend(); ++it)
{
if (partEnergy < it->first)
{
lowerWeight = it->second;
found = true;
break;
}
}
if (!found) {
if (!found)
{
std::ostringstream err_mess;
err_mess << "GetLowerWitgh() - Couldn't find lower weight bound." << G4endl
<< "Energy: " << partEnergy << ".";
Error(err_mess.str());
}
return lowerWeight;
}
void G4WeightWindowStore::
SetInternalIterator(const G4GeometryCell &gCell) const
SetInternalIterator(const G4GeometryCell& gCell) const
{
fCurrentIterator = fCellToUpEnBoundLoWePairsMap.find(gCell);
}
G4bool G4WeightWindowStore::
IsInWorld(const G4VPhysicalVolume &aVolume) const
IsInWorld(const G4VPhysicalVolume& aVolume) const
{
G4bool isIn(true);
if (!(aVolume == *fWorldVolume)) {
if (!(aVolume == *fWorldVolume))
{
isIn = fWorldVolume->GetLogicalVolume()->IsAncestor(&aVolume);
}
return isIn;
}
G4bool G4WeightWindowStore::IsKnown(const G4GeometryCell &gCell) const
G4bool G4WeightWindowStore::
IsKnown(const G4GeometryCell& gCell) const
{
G4bool inWorldKnown(IsInWorld(gCell.GetPhysicalVolume()));
if ( inWorldKnown ) {
if ( inWorldKnown )
{
SetInternalIterator(gCell);
inWorldKnown = (fCurrentIterator!=fCellToUpEnBoundLoWePairsMap.end());
inWorldKnown = (fCurrentIterator!=fCellToUpEnBoundLoWePairsMap.cend());
}
return inWorldKnown;
}
@@ -132,41 +136,44 @@ void G4WeightWindowStore::Clear()
void G4WeightWindowStore::SetWorldVolume()
{
G4cout << " G4IStore:: SetWorldVolume " << G4endl;
fWorldVolume = G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking()->GetWorldVolume();
fWorldVolume = G4TransportationManager::GetTransportationManager()
->GetNavigatorForTracking()->GetWorldVolume();
G4cout << " World volume is: " << fWorldVolume->GetName() << G4endl;
// fGeometryCelli = new G4GeometryCellImportance;
// fGeometryCelli = new G4GeometryCellImportance;
}
void G4WeightWindowStore::SetParallelWorldVolume(G4String paraName)
void G4WeightWindowStore::SetParallelWorldVolume(const G4String& paraName)
{
fWorldVolume = G4TransportationManager::GetTransportationManager()->GetParallelWorld(paraName);
// fGeometryCelli = new G4GeometryCellImportance;
fWorldVolume = G4TransportationManager::GetTransportationManager()
->GetParallelWorld(paraName);
// fGeometryCelli = new G4GeometryCellImportance;
}
const G4VPhysicalVolume &G4WeightWindowStore::GetWorldVolume() const
{
return *fWorldVolume;
}
const G4VPhysicalVolume* G4WeightWindowStore::GetParallelWorldVolumePointer() const
const G4VPhysicalVolume* G4WeightWindowStore::
GetParallelWorldVolumePointer() const
{
return fWorldVolume;
}
void G4WeightWindowStore::
AddLowerWeights(const G4GeometryCell & gCell,
const std::vector<G4double> &lowerWeights)
AddLowerWeights(const G4GeometryCell& gCell,
const std::vector<G4double>& lowerWeights)
{
if (fGeneralUpperEnergyBounds.empty()) {
if (fGeneralUpperEnergyBounds.empty())
{
Error("AddLowerWeights() - No general upper energy limits set!");
}
if (IsKnown(gCell)) {
if (IsKnown(gCell))
{
Error("AddLowerWeights() - Cell already in the store.");
}
if (lowerWeights.size() != fGeneralUpperEnergyBounds.size()) {
if (lowerWeights.size() != fGeneralUpperEnergyBounds.size())
{
std::ostringstream err_mess;
err_mess << "AddLowerWeights() - Mismatch between "
<< "number of lower weights (" << lowerWeights.size()
@@ -176,50 +183,48 @@ AddLowerWeights(const G4GeometryCell & gCell,
}
G4UpperEnergyToLowerWeightMap map;
G4int i = 0;
for (std::set<G4double, std::less<G4double> >::iterator it =
fGeneralUpperEnergyBounds.begin();
it != fGeneralUpperEnergyBounds.end();
it++) {
for (auto it = fGeneralUpperEnergyBounds.cbegin();
it != fGeneralUpperEnergyBounds.cend(); ++it)
{
map[*it] = lowerWeights[i];
i++;
++i;
}
fCellToUpEnBoundLoWePairsMap[gCell] = map;
}
void G4WeightWindowStore::
AddUpperEboundLowerWeightPairs(const G4GeometryCell &gCell,
AddUpperEboundLowerWeightPairs(const G4GeometryCell& gCell,
const G4UpperEnergyToLowerWeightMap& enWeMap)
{
if (IsKnown(gCell)) {
if (IsKnown(gCell))
{
Error("AddUpperEboundLowerWeightPairs() - Cell already in the store.");
}
if (IsKnown(gCell)) {
if (IsKnown(gCell))
{
Error("AddUpperEboundLowerWeightPairs() - Cell already in the store.");
}
fCellToUpEnBoundLoWePairsMap[gCell] = enWeMap;
}
void G4WeightWindowStore::
SetGeneralUpperEnergyBounds(const std::set<G4double,
std::less<G4double> > &enBounds)
std::less<G4double> >& enBounds)
{
if (!fGeneralUpperEnergyBounds.empty()) {
if (!fGeneralUpperEnergyBounds.empty())
{
Error("SetGeneralUpperEnergyBounds() - Energy bounds already set.");
}
fGeneralUpperEnergyBounds = enBounds;
}
void G4WeightWindowStore::Error(const G4String &msg) const
void G4WeightWindowStore::Error(const G4String& msg) const
{
G4Exception("G4WeightWindowStore::Error()",
"GeomBias0002", FatalException, msg);
}
// ***************************************************************************
// Returns the instance of the singleton.
// Creates it in case it's called for the first time.
@@ -227,7 +232,7 @@ void G4WeightWindowStore::Error(const G4String &msg) const
//
G4WeightWindowStore* G4WeightWindowStore::GetInstance()
{
if (!fInstance)
if (fInstance == nullptr)
{
fInstance = new G4WeightWindowStore();
}
@@ -239,13 +244,16 @@ G4WeightWindowStore* G4WeightWindowStore::GetInstance()
// Creates it in case it's called for the first time.
// ***************************************************************************
//
G4WeightWindowStore* G4WeightWindowStore::GetInstance(const G4String& ParallelWorldName)
G4WeightWindowStore* G4WeightWindowStore::
GetInstance(const G4String& ParallelWorldName)
{
if (!fInstance)
if (fInstance == nullptr)
{
G4cout << "G4IStore:: Creating new Parallel IStore " << ParallelWorldName << G4endl;
#ifdef G4VERBOSE
G4cout << "G4IStore:: Creating new Parallel IStore "
<< ParallelWorldName << G4endl;
#endif
fInstance = new G4WeightWindowStore(ParallelWorldName);
}
return fInstance;
}