Import Geant4 11.0.0.beta source tree

This commit is contained in:
Gabriele Cosmo
2021-06-25 16:12:29 +02:00
parent c968e26a39
commit 6399a014b6
4200 changed files with 207479 additions and 237366 deletions
@@ -23,159 +23,162 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4AdjointPrimaryGeneratorAction
//
/////////////////////////////////////////////////////////////////////////////////
// Class Name: G4AdjointPrimaryGeneratorAction
// Author: L. Desorgher
// Organisation: SpaceIT GmbH
// Contract: ESA contract 21435/08/NL/AT
// Customer: ESA/ESTEC
/////////////////////////////////////////////////////////////////////////////////
// Class description:
//
// CHANGE HISTORY
// --------------
// ChangeHistory:
// 10-01-2007 creation by L. Desorgher
// 1-11-2009 Splitting of G4AdjointPrimaryGeneratorAction in two classes
// G4AdjointPrimaryGeneratorAction and G4AdjointPrimaryGenerator
// L.Desorgher
//
//
//-------------------------------------------------------------
// Documentation:
// This class represents the PrimaryGeneratorAction that is used during the
//entire
// adjoint simulation. It uses the class G4AdjointPrimaryGenerator to
// generate randomly adjoint primary particles on a user selected adjoint
// source (External surface of a volume or Sphere). The spectrum of the
// primary adjoint particles is set as 1/E with user defined max and min
// energy. The weight of the primary is set according to ReverseMC theory as
// w=log(Emax/Emin)*E*adjoint_source_area*pi/n, with E the energy of the
// particle, n the number of adjoint primary particles of same type that will be
// generated during the simulation. Different types of adjoint particles are
// generated event after event in order to cover all the type of primaries
// and secondaries needed for the simulation. For example if reverse e-
// ionisation, brem, photo
// electric effect, and compton are considered both adjoint gamma and adjoint
// e- will be considered alternatively as adjoint primary. The user can
// decide to consider/neglect some type of particle by using the macro commands
// /adjoint/ConsiderAsPrimary and
/// adjoint/NeglectAsPrimary. If an adjoint primary or its secondary has
/// reached the
// external surface, in the next event a fwd primary particle equivalent to
// the last generated adjoint primary is generated with the same position,
// energy but opposite direction and the forward tracking phase starts.
//
//
//
#ifndef G4AdjointPrimaryGeneratorAction_h
#define G4AdjointPrimaryGeneratorAction_h 1
#include "G4ThreeVector.hh"
#include "G4VUserPrimaryGeneratorAction.hh"
#include "globals.hh"
// This class represents the PrimaryGeneratorAction that is used during
// the entire adjoint simulation.
// It uses the class G4AdjointPrimaryGenerator to generate randomly
// adjoint primary particles on a user selected adjoint source
// (External surface of a volume or Sphere).
// The spectrum of the primary adjoint particles is set as 1/E with
// user defined max and min energy.
// The weight of the primary is set according to ReverseMC theory as
// w=log(Emax/Emin)*E*adjoint_source_area*pi/n, with E the energy of
// the particle, n the number of adjoint primary particles of same type
// that will be generated during the simulation.
// Different types of adjoint particles are generated event after event
// in order to cover all the type of primaries and secondaries needed
// for the simulation. For example if reverse e- ionisation, brem,
// photo electric effect, and compton are considered both adjoint gamma
// and adjoint e- will be considered alternatively as adjoint primary.
// The user can decide to consider/neglect some type of particle by
// using the macro commands "/adjoint/ConsiderAsPrimary" and
// "/adjoint/NeglectAsPrimary". If an adjoint primary or its secondary
// has reached the external surface, in the next event a fwd primary
// particle equivalent to the last generated adjoint primary is
// generated with the same position, energy but opposite direction
// and the forward tracking phase starts.
// --------------------------------------------------------------------
// Class Name: G4AdjointPrimaryGeneratorAction
// Author: L. Desorgher, 2007-2009
// Organisation: SpaceIT GmbH
// Contract: ESA contract 21435/08/NL/AT
// Customer: ESA/ESTEC
// --------------------------------------------------------------------
#ifndef G4AdjointPrimaryGeneratorAction_hh
#define G4AdjointPrimaryGeneratorAction_hh 1
#include <iterator>
#include <map>
#include <vector>
#include "globals.hh"
#include "G4ThreeVector.hh"
#include "G4VUserPrimaryGeneratorAction.hh"
class G4AdjointPosOnPhysVolGenerator;
class G4ParticleGun;
class G4Event;
class G4AdjointPrimaryGenerator;
class G4ParticleDefinition;
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
// --------------------------------------------------------------------
class G4AdjointPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
{
public: // constructor, destructor
G4AdjointPrimaryGeneratorAction();
~G4AdjointPrimaryGeneratorAction();
public:
public: // public methods
void GeneratePrimaries(G4Event*);
void SetRndmFlag(const G4String& val) { rndmFlag = val; }
void SetEmin(G4double val);
void SetEmax(G4double val);
void SetEminIon(G4double val);
void SetEmaxIon(G4double val);
void SetSphericalAdjointPrimarySource(G4double radius, G4ThreeVector pos);
void SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(
const G4String& volume_name);
void ConsiderParticleAsPrimary(const G4String& particle_name);
void NeglectParticleAsPrimary(const G4String& particle_name);
void SetPrimaryIon(G4ParticleDefinition* adjointIon,
G4ParticleDefinition* fwdIon);
void UpdateListOfPrimaryParticles();
inline size_t GetNbOfAdjointPrimaryTypes()
{
return ListOfPrimaryAdjParticles.size();
}
inline std::vector<G4ParticleDefinition*>* GetListOfPrimaryFwdParticles()
{
return &ListOfPrimaryFwdParticles;
}
inline const G4String& GetPrimaryIonName() { return ion_name; }
inline void SetNbPrimaryFwdGammasPerEvent(G4int nb)
{
nb_fwd_gammas_per_event = nb;
}
inline void SetNbAdjointPrimaryGammasPerEvent(G4int nb)
{
nb_adj_primary_gammas_per_event = nb;
}
inline void SetNbAdjointPrimaryElectronsPerEvent(G4int nb)
{
nb_adj_primary_electrons_per_event = nb;
}
inline G4ParticleDefinition* GetLastGeneratedFwdPrimaryParticle()
{
return ListOfPrimaryFwdParticles[index_particle];
}
G4AdjointPrimaryGeneratorAction();
~G4AdjointPrimaryGeneratorAction();
private: // private methods
G4double ComputeEnergyDistWeight(G4double energy, G4double E1, G4double E2);
G4AdjointPrimaryGeneratorAction(
const G4AdjointPrimaryGeneratorAction&) = delete;
G4AdjointPrimaryGeneratorAction& operator=(
const G4AdjointPrimaryGeneratorAction&) = delete;
private: // attributes
G4String rndmFlag; // flag for a rndm impact point
void GeneratePrimaries(G4Event*);
void SetEmin(G4double val);
void SetEmax(G4double val);
void SetEminIon(G4double val);
void SetEmaxIon(G4double val);
void SetSphericalAdjointPrimarySource(G4double radius,
G4ThreeVector pos);
void SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(
const G4String& volume_name);
void ConsiderParticleAsPrimary(const G4String& particle_name);
void NeglectParticleAsPrimary(const G4String& particle_name);
void SetPrimaryIon(G4ParticleDefinition* adjointIon,
G4ParticleDefinition* fwdIon);
void UpdateListOfPrimaryParticles();
// The generator of primary vertex except for weight
G4AdjointPrimaryGenerator* theAdjointPrimaryGenerator;
inline void SetRndmFlag(const G4String& val)
{
rndmFlag = val;
}
inline size_t GetNbOfAdjointPrimaryTypes()
{
return ListOfPrimaryAdjParticles.size();
}
inline std::vector<G4ParticleDefinition*>* GetListOfPrimaryFwdParticles()
{
return &ListOfPrimaryFwdParticles;
}
inline const G4String& GetPrimaryIonName()
{
return ion_name;
}
inline void SetNbPrimaryFwdGammasPerEvent(G4int nb)
{
nb_fwd_gammas_per_event = nb;
}
inline void SetNbAdjointPrimaryGammasPerEvent(G4int nb)
{
nb_adj_primary_gammas_per_event = nb;
}
inline void SetNbAdjointPrimaryElectronsPerEvent(G4int nb)
{
nb_adj_primary_electrons_per_event = nb;
}
inline G4ParticleDefinition* GetLastGeneratedFwdPrimaryParticle()
{
return ListOfPrimaryFwdParticles[index_particle];
}
// Emin and Emax energies of the adjoint source
//---------------------------------------------
G4double Emin;
G4double Emax;
G4double EminIon;
G4double EmaxIon;
private: // methods
// List of type of primary adjoint and forward particle used in the
// simulation
//---------------------------------------------------------------------------
std::vector<G4ParticleDefinition*> ListOfPrimaryFwdParticles;
std::vector<G4ParticleDefinition*> ListOfPrimaryAdjParticles;
std::map<G4String, G4bool>
PrimariesConsideredInAdjointSim; // if true considered if
// false not considered
G4double ComputeEnergyDistWeight(G4double energy, G4double E1, G4double E2);
size_t index_particle;
private: // attributes
G4ThreeVector pos, direction, p;
G4String rndmFlag; // flag for a rndm impact point
G4String type_of_adjoint_source; // Spherical ExtSurfaceOfAVolume
G4double radius_spherical_source;
G4ThreeVector center_spherical_source;
G4int nb_fwd_gammas_per_event;
G4int nb_adj_primary_gammas_per_event;
G4int nb_adj_primary_electrons_per_event;
// The generator of primary vertex except for weight
G4AdjointPrimaryGenerator* theAdjointPrimaryGenerator = nullptr;
// For simulation with ions
//--------------------------
G4ParticleDefinition* fwd_ion;
G4ParticleDefinition* adj_ion;
G4String ion_name;
// disable copy constructor and assignement operator
G4AdjointPrimaryGeneratorAction(const G4AdjointPrimaryGeneratorAction&);
G4AdjointPrimaryGeneratorAction& operator=(
const G4AdjointPrimaryGeneratorAction&);
// Emin and Emax energies of the adjoint source
//---------------------------------------------
G4double Emin = 0.0;
G4double Emax = 0.0;
G4double EminIon = 0.0;
G4double EmaxIon = 0.0;
// List of type of primary adjoint and forward particle used in the
// simulation
//------------------------------------------------------------------
std::vector<G4ParticleDefinition*> ListOfPrimaryFwdParticles;
std::vector<G4ParticleDefinition*> ListOfPrimaryAdjParticles;
std::map<G4String, G4bool> PrimariesConsideredInAdjointSim;
// if true considered if false not considered
std::size_t index_particle = 100000;
G4ThreeVector pos, direction, p;
G4String type_of_adjoint_source; // Spherical ExtSurfaceOfAVolume
G4double radius_spherical_source = 0.0;
G4ThreeVector center_spherical_source;
G4int nb_fwd_gammas_per_event = 1;
G4int nb_adj_primary_gammas_per_event = 1;
G4int nb_adj_primary_electrons_per_event = 1;
// For simulation with ions
//--------------------------
G4ParticleDefinition* fwd_ion = nullptr;
G4ParticleDefinition* adj_ion = nullptr;
G4String ion_name = "not_defined";
};
#endif
+273 -290
View File
@@ -23,145 +23,125 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4AdjointSimManager
//
/////////////////////////////////////////////////////////////////////////////////
// Class Name: G4AdjointSimManager.hh
// Author: L. Desorgher
// Organisation: SpaceIT GmbH
// Contract: ESA contract 21435/08/NL/AT
// Customer: ESA/ESTEC
/////////////////////////////////////////////////////////////////////////////////
// Class description:
//
// CHANGE HISTORY
// --------------
// ChangeHistory:
// -15-01-2007 creation by L. Desorgher
// -March 2008 Redesigned as a non RunManager. L. Desorgher
// -01-11-2009 Add the possibility to use user defined run, event, tracking,
// stepping, and stacking actions during the adjoint tracking phase. L.
// Desorgher
// This class represents the Manager of an adjoint/reverse MC simulation.
// An adjoint run is divided in a serie of alternative adjoint and forward
// tracking of adjoint and normal particles.
//
//
//
//-------------------------------------------------------------
// Documentation:
// This class represents the Manager of an adjoint/reverse MC simulation.
// An adjoint run is divided in a serie of alternative adjoint and forward
//tracking of adjoint and normal particles.
//
// Reverse tracking phase:
// -----------------------
// An adjoint particle of a given type (adjoint_e-, adjoint_gamma,...) is
//first
// generated on the so called adjoint source with a random energy (1/E
// distribution) and direction. The adjoint source is the external surface of
// a user defined volume or of a user defined sphere. The adjoint source
// Reverse tracking phase:
// -----------------------
// An adjoint particle of a given type (adjoint_e-, adjoint_gamma,...) is
// first generated on the so called adjoint source with a random energy (1/E
// distribution) and direction. The adjoint source is the external surface
// of a user defined volume or of a user defined sphere. The adjoint source
// should contain one or several sensitive volumes and should be small compared
// to the entire geometry. The user can set the min and max energy of the
// adjoint source. After its generation the adjoint primary particle is tracked
// bacward in the geometry till a user defined external surface (spherical or
// boundary of a volume) or is killed before if it reaches a user defined
// upper energy limit that represents the maximum energy of the external
// source. During the reverse tracking, reverse processes take place where
// the adjoint particle being tracked can be either scattered or transformed
// boundary of a volume) or is killed before if it reaches a user defined
// upper energy limit that represents the maximum energy of the external
// source. During the reverse tracking, reverse processes take place where
// the adjoint particle being tracked can be either scattered or transformed
// in another type of adjoint paticle. During the reverse tracking the
// G4SimulationManager replaces the user defined Primary, Run, ... actions, by
// its own actions.
//
// Forward tracking phase
// -----------------------
// When an adjoint particle reaches the external surface its weight,type,
//position, and directions are registered and a normal primary particle with a
//type
// equivalent to the last generated primary adjoint is generated with the
// same energy, position but opposite direction and is tracked normally in the
// sensitive region as in a fwd MC simulation. During this forward tracking
// phase the event, stacking, stepping, tracking actions defined by the user for
// its general fwd application are used. By this clear separation between
// adjoint and fwd tracking phases , the code of the user developed for a fwd
// simulation should be only slightly modified to adapt it for an adjoint
// simulation. Indeed the computation of the signal is done by the same actions
// or classes that the one used in the fwd simulation mode.
// Forward tracking phase
// -----------------------
// When an adjoint particle reaches the external surface its weight,type,
// position, and directions are registered and a normal primary particle
// with a type equivalent to the last generated primary adjoint is generated
// with the same energy, position but opposite direction and is tracked
// normally in the sensitive region as in a fwd MC simulation. During this
// forward tracking phase the event, stacking, stepping, tracking actions
// defined by the user for its general fwd application are used. By this clear
// separation between adjoint and fwd tracking phases, the code of the user
// developed for a fwd simulation should be only slightly modified to adapt it
// for an adjoint simulation. Indeed the computation of the signal is done by
// the same actions or classes that the one used in the fwd simulation mode.
//
// Modification to brought in a existing G4 application to use the ReverseMC
//method
// -------------------------------
// In order to be able to use the ReverseMC method in his simulation, the
//user should
// modify its code as such: 1) Adapt its physics list to use
// ReverseProcesses for adjoint particles. An example of such physics list is
// provided in an extended example. 2) Create an instance of
// G4AdjointSimManager somewhere in the main code. 3) Modify the analysis
// part of the code to normalise the signal computed during the fwd phase to the
// weight of the last adjoint particle that reaches the external surface. This
// is done by using the following method of G4AdjointSimManager.
// Modification to bring in an existing G4 application to use the ReverseMC
// ------------------------------------------------------------------------
// In order to be able to use the ReverseMC method in his simulation, the
// user should modify its code as such:
// 1) Adapt its physics list to use ReverseProcesses for adjoint particles.
// An example of such physics list is provided in an extended example.
// 2) Create an instance of G4AdjointSimManager somewhere in the main code.
// 3) Modify the analysis part of the code to normalise the signal computed
// during the fwd phase to the weight of the last adjoint particle that
// reaches the external surface. This is done by using the following
// method of G4AdjointSimManager:
//
// G4int GetIDOfLastAdjParticleReachingExtSource()
// G4ThreeVector GetPositionAtEndOfLastAdjointTrack(){ return
// last_pos;}
// G4ThreeVector GetDirectionAtEndOfLastAdjointTrack(){ return
// last_direction;} G4double GetEkinAtEndOfLastAdjointTrack(){ return
// last_ekin;} G4double GetEkinNucAtEndOfLastAdjointTrack(){ return
// last_ekin_nuc;} G4double GetWeightAtEndOfLastAdjointTrack(){return
// last_weight;}
// G4double GetCosthAtEndOfLastAdjointTrack(){return last_cos_th;}
// G4String GetFwdParticleNameAtEndOfLastAdjointTrack(){return
// last_fwd_part_name;} G4int
// GetFwdParticlePDGEncodingAtEndOfLastAdjointTrack(){return
// last_fwd_part_PDGEncoding;} G4int
// GetFwdParticleIndexAtEndOfLastAdjointTrack().
// G4int GetIDOfLastAdjParticleReachingExtSource()
// G4ThreeVector GetPositionAtEndOfLastAdjointTrack()
// G4ThreeVector GetDirectionAtEndOfLastAdjointTrack()
// G4double GetEkinAtEndOfLastAdjointTrack()
// G4double GetEkinNucAtEndOfLastAdjointTrack()
// G4double GetWeightAtEndOfLastAdjointTrack()
// G4double GetCosthAtEndOfLastAdjointTrack()
// G4String GetFwdParticleNameAtEndOfLastAdjointTrack()
// G4int GetFwdParticlePDGEncodingAtEndOfLastAdjointTrack()
// G4int GetFwdParticleIndexAtEndOfLastAdjointTrack().
//
// In orther to have a code working for both forward and adjoint
//simulation
// mode, the extra code needed in user actions for the adjoint simulation
// mode can be seperated to the code needed only for the normal forward
// simulation by using the following method
// In order to have a code working for both forward and adjoint simulation
// mode, the extra code needed in user actions for the adjoint simulation
// mode can be separated from the code needed only for the normal forward
// simulation by using the following method:
// G4bool GetAdjointSimMode()
// that returns true if an adjoint simulation is running and false if not!
//
// G4bool GetAdjointSimMode() that return true if an adjoint
//simulation
// is running and false if not!
//
// Example of modification in the analysis part of the code:
// -------------------------------------------------------------
// Let say that in the forward simulation a G4 application computes the
// energy
// deposited in a volume. The user wants to normalise its results for an
// Example of modification in the analysis part of the code
// --------------------------------------------------------
// Let's say that in the forward simulation a G4 application computes the
// energy deposited in a volume. The user wants to normalise its results for an
// external isotropic source of e- with differential spectrum given by f(E). A
// possible modification of the code where the deposited energy Edep during an
// event is registered would be the following
// event is registered would be the following:
//
// G4AdjointSimManager* theAdjSimManager =
// G4AdjointSimManager::GetInstance();
// if (theAdjSimManager->GetAdjointSimMode()) {
// //code of the user that should be consider only for forwrad
//simulation G4double normalised_edep = 0.; if
//(theAdjSimManager->GetFwdParticleNameAtEndOfLastAdjointTrack() == "e-"){
//G4double ekin_prim =
// theAdjSimManager->GetEkinAtEndOfLastAdjointTrack(); G4double
// weight_prim = theAdjSimManager->GetWeightAtEndOfLastAdjointTrack();
// normalised_edep = weight_prim*f(ekin_prim);
// }
// //then follow the code where normalised_edep is printed, or
//registered
// or whatever ....
// }
//
// else { //code of the user that should be consider only for forward
// simulation
// }
// Note that in this example a normalisation to only primary e- with only
//one
// spectrum f(E) is considered. The example code could be easily adapted
// for a normalisatin to several spectra and several type of primary particles
// in the same simulation.
// G4AdjointSimManager* theAdjSimManager = G4AdjointSimManager::GetInstance();
// if (theAdjSimManager->GetAdjointSimMode())
// {
// // code of the user that should be consider only for forward simulation
// G4double normalised_edep = 0.;
// if (theAdjSimManager->GetFwdParticleNameAtEndOfLastAdjointTrack()=="e-")
// {
// G4double ekin_prim =
// theAdjSimManager->GetEkinAtEndOfLastAdjointTrack();
// G4double weight_prim =
// theAdjSimManager->GetWeightAtEndOfLastAdjointTrack();
// normalised_edep = weight_prim*f(ekin_prim);
// }
// // then follow the code where normalised_edep is printed, or registered
// // or whatever ....
// }
// else
// {
// // code that should be considered only for forward simulation
// }
//
// Note that in this example a normalisation to only primary e- with only
// one spectrum f(E) is considered. The example code could be easily
// adapted for a normalisation to several spectra and several types of
// primary particles in the same simulation.
#ifndef G4AdjointSimManager_h
#define G4AdjointSimManager_h 1
// --------------------------------------------------------------------
// Class Name: G4AdjointSimManager
// Author: L. Desorgher, 2007-2009
// Organisation: SpaceIT GmbH
// Contract: ESA contract 21435/08/NL/AT
// Customer: ESA/ESTEC
// --------------------------------------------------------------------
#ifndef G4AdjointSimManager_hh
#define G4AdjointSimManager_hh 1
#include <vector>
#include "globals.hh"
#include "G4ThreeVector.hh"
#include "G4UserRunAction.hh"
#include "globals.hh"
#include <vector>
class G4UserEventAction;
class G4VUserPrimaryGeneratorAction;
@@ -181,216 +161,219 @@ class G4Run;
class G4AdjointSimManager : public G4UserRunAction
{
public:
static G4AdjointSimManager* GetInstance();
public:
public: // public methods
virtual void BeginOfRunAction(const G4Run* aRun);
virtual void EndOfRunAction(const G4Run* aRun);
void RunAdjointSimulation(G4int nb_evt);
static G4AdjointSimManager* GetInstance();
inline G4int GetNbEvtOfLastRun() { return nb_evt_of_last_run; }
virtual void BeginOfRunAction(const G4Run* aRun);
virtual void EndOfRunAction(const G4Run* aRun);
void RunAdjointSimulation(G4int nb_evt);
void SetAdjointTrackingMode(G4bool aBool);
G4bool
GetAdjointTrackingMode(); // true if an adjoint track is being processed
inline G4bool GetAdjointSimMode()
{
return adjoint_sim_mode;
} // true if an adjoint simulation is running
inline G4int GetNbEvtOfLastRun() { return nb_evt_of_last_run; }
G4bool GetDidAdjParticleReachTheExtSource();
void RegisterAtEndOfAdjointTrack();
void RegisterAdjointPrimaryWeight(G4double aWeight);
void ResetDidOneAdjPartReachExtSourceDuringEvent();
// to continue here
inline G4int GetIDOfLastAdjParticleReachingExtSource()
{
return ID_of_last_particle_that_reach_the_ext_source;
};
G4ThreeVector GetPositionAtEndOfLastAdjointTrack(size_t i = 0);
G4ThreeVector GetDirectionAtEndOfLastAdjointTrack(size_t i = 0);
G4double GetEkinAtEndOfLastAdjointTrack(size_t i = 0);
G4double GetEkinNucAtEndOfLastAdjointTrack(size_t i = 0);
G4double GetWeightAtEndOfLastAdjointTrack(size_t i = 0);
G4double GetCosthAtEndOfLastAdjointTrack(size_t i = 0);
const G4String& GetFwdParticleNameAtEndOfLastAdjointTrack();
G4int GetFwdParticlePDGEncodingAtEndOfLastAdjointTrack(size_t i = 0);
G4int GetFwdParticleIndexAtEndOfLastAdjointTrack(size_t i = 0);
size_t GetNbOfAdointTracksReachingTheExternalSurface();
void ClearEndOfAdjointTrackInfoVectors();
G4ParticleDefinition* GetLastGeneratedFwdPrimaryParticle();
void SetAdjointTrackingMode(G4bool aBool);
G4bool GetAdjointTrackingMode();
// true if an adjoint track is being processed
std::vector<G4ParticleDefinition*>* GetListOfPrimaryFwdParticles();
size_t GetNbOfPrimaryFwdParticles();
inline G4bool GetAdjointSimMode()
{
return adjoint_sim_mode;
} // true if an adjoint simulation is running
G4bool DefineSphericalExtSource(G4double radius, G4ThreeVector pos);
G4bool DefineSphericalExtSourceWithCentreAtTheCentreOfAVolume(
G4double radius, const G4String& volume_name);
G4bool DefineExtSourceOnTheExtSurfaceOfAVolume(const G4String& volume_name);
void SetExtSourceEmax(G4double Emax);
G4bool GetDidAdjParticleReachTheExtSource();
void RegisterAtEndOfAdjointTrack();
void RegisterAdjointPrimaryWeight(G4double aWeight);
void ResetDidOneAdjPartReachExtSourceDuringEvent();
// Definition of adjoint source
//----------------------------
inline G4int GetIDOfLastAdjParticleReachingExtSource()
{
return ID_of_last_particle_that_reach_the_ext_source;
}
G4bool DefineSphericalAdjointSource(G4double radius, G4ThreeVector pos);
G4bool DefineSphericalAdjointSourceWithCentreAtTheCentreOfAVolume(
G4double radius, const G4String& volume_name);
G4bool DefineAdjointSourceOnTheExtSurfaceOfAVolume(
const G4String& volume_name);
void SetAdjointSourceEmin(G4double Emin);
void SetAdjointSourceEmax(G4double Emax);
inline G4double GetAdjointSourceArea() { return area_of_the_adjoint_source; }
void ConsiderParticleAsPrimary(const G4String& particle_name);
void NeglectParticleAsPrimary(const G4String& particle_name);
void SetPrimaryIon(G4ParticleDefinition* adjointIon,
G4ParticleDefinition* fwdIon);
const G4String& GetPrimaryIonName();
G4ThreeVector GetPositionAtEndOfLastAdjointTrack(std::size_t i = 0);
G4ThreeVector GetDirectionAtEndOfLastAdjointTrack(std::size_t i = 0);
G4double GetEkinAtEndOfLastAdjointTrack(std::size_t i = 0);
G4double GetEkinNucAtEndOfLastAdjointTrack(std::size_t i = 0);
G4double GetWeightAtEndOfLastAdjointTrack(std::size_t i = 0);
G4double GetCosthAtEndOfLastAdjointTrack(std::size_t i = 0);
const G4String& GetFwdParticleNameAtEndOfLastAdjointTrack();
G4int GetFwdParticlePDGEncodingAtEndOfLastAdjointTrack(std::size_t i = 0);
G4int GetFwdParticleIndexAtEndOfLastAdjointTrack(std::size_t i = 0);
std::size_t GetNbOfAdointTracksReachingTheExternalSurface();
void ClearEndOfAdjointTrackInfoVectors();
G4ParticleDefinition* GetLastGeneratedFwdPrimaryParticle();
inline void SetNormalisationMode(G4int n) { normalisation_mode = n; };
G4int GetNormalisationMode() { return normalisation_mode; };
G4double GetNumberNucleonsInIon() { return nb_nuc; };
std::vector<G4ParticleDefinition*>* GetListOfPrimaryFwdParticles();
std::size_t GetNbOfPrimaryFwdParticles();
// Definition of user actions for the adjoint tracking phase
//----------------------------
void SetAdjointEventAction(G4UserEventAction* anAction);
void SetAdjointSteppingAction(G4UserSteppingAction* anAction);
void SetAdjointStackingAction(G4UserStackingAction* anAction);
void SetAdjointRunAction(G4UserRunAction* anAction);
G4bool DefineSphericalExtSource(G4double radius, G4ThreeVector pos);
G4bool DefineSphericalExtSourceWithCentreAtTheCentreOfAVolume(
G4double radius, const G4String& volume_name);
G4bool DefineExtSourceOnTheExtSurfaceOfAVolume(const G4String& volume_name);
void SetExtSourceEmax(G4double Emax);
// Set methods for user run actions
//--------------------------------
inline void UseUserStackingActionInFwdTrackingPhase(G4bool aBool)
{
use_user_StackingAction = aBool;
}
inline void UseUserTrackingActionInFwdTrackingPhase(G4bool aBool)
{
use_user_TrackingAction = aBool;
}
// Definition of adjoint source
//----------------------------
G4bool DefineSphericalAdjointSource(G4double radius, G4ThreeVector pos);
G4bool DefineSphericalAdjointSourceWithCentreAtTheCentreOfAVolume(
G4double radius, const G4String& volume_name);
G4bool DefineAdjointSourceOnTheExtSurfaceOfAVolume(
const G4String& volume_name);
void SetAdjointSourceEmin(G4double Emin);
void SetAdjointSourceEmax(G4double Emax);
inline G4double GetAdjointSourceArea()
{
return area_of_the_adjoint_source;
}
void ConsiderParticleAsPrimary(const G4String& particle_name);
void NeglectParticleAsPrimary(const G4String& particle_name);
void SetPrimaryIon(G4ParticleDefinition* adjointIon,
G4ParticleDefinition* fwdIon);
const G4String& GetPrimaryIonName();
// Set nb of primary fwd gamma
//---------------------------
void SetNbOfPrimaryFwdGammasPerEvent(G4int);
inline void SetNormalisationMode(G4int n) { normalisation_mode = n; }
inline G4int GetNormalisationMode() { return normalisation_mode; }
inline G4double GetNumberNucleonsInIon() { return nb_nuc; }
// Set nb of adjoint primaries for reverse splitting
//-------------------------------------------------
void SetNbAdjointPrimaryGammasPerEvent(G4int);
void SetNbAdjointPrimaryElectronsPerEvent(G4int);
// Definition of user actions for the adjoint tracking phase
//----------------------------
void SetAdjointEventAction(G4UserEventAction* anAction);
void SetAdjointSteppingAction(G4UserSteppingAction* anAction);
void SetAdjointStackingAction(G4UserStackingAction* anAction);
void SetAdjointRunAction(G4UserRunAction* anAction);
// Convergence test
//-----------------------
/*
void RegisterSignalForConvergenceTest(G4double aSignal);
void DefineExponentialPrimarySpectrumForConvergenceTest(G4ParticleDefinition*
aPartDef, G4double E0); void
DefinePowerLawPrimarySpectrumForConvergenceTest(G4ParticleDefinition*
aPartDef, G4double alpha);
// Set methods for user run actions
//--------------------------------
inline void UseUserStackingActionInFwdTrackingPhase(G4bool aBool)
{
use_user_StackingAction = aBool;
}
inline void UseUserTrackingActionInFwdTrackingPhase(G4bool aBool)
{
use_user_TrackingAction = aBool;
}
*/
// Set nb of primary fwd gamma
//---------------------------
void SetNbOfPrimaryFwdGammasPerEvent(G4int);
private:
static G4ThreadLocal G4AdjointSimManager* instance;
// Set nb of adjoint primaries for reverse splitting
//-------------------------------------------------
void SetNbAdjointPrimaryGammasPerEvent(G4int);
void SetNbAdjointPrimaryElectronsPerEvent(G4int);
private: // methods
void SetRestOfAdjointActions();
void SetAdjointPrimaryRunAndStackingActions();
void SetAdjointActions();
void ResetRestOfUserActions();
void ResetUserPrimaryRunAndStackingActions();
void ResetUserActions();
void DefineUserActions();
// Convergence test
//-----------------------
/*
void RegisterSignalForConvergenceTest(G4double aSignal);
void DefineExponentialPrimarySpectrumForConvergenceTest(
G4ParticleDefinition* aPartDef, G4double E0);
void DefinePowerLawPrimarySpectrumForConvergenceTest(
G4ParticleDefinition* aPartDef, G4double alpha);
*/
public:
void SwitchToAdjointSimulationMode();
void BackToFwdSimulationMode();
void SwitchToAdjointSimulationMode();
void BackToFwdSimulationMode();
private: // constructor and destructor
G4AdjointSimManager();
~G4AdjointSimManager();
private: // methods
private: // attributes
// Messenger
//----------
G4AdjointSimMessenger* theMessenger;
static G4ThreadLocal G4AdjointSimManager* instance;
// user defined actions for the normal fwd simulation. Taken from the
// G4RunManager
//-------------------------------------------------
bool user_action_already_defined;
G4UserRunAction* fUserRunAction;
G4UserEventAction* fUserEventAction;
G4VUserPrimaryGeneratorAction* fUserPrimaryGeneratorAction;
G4UserTrackingAction* fUserTrackingAction;
G4UserSteppingAction* fUserSteppingAction;
G4UserStackingAction* fUserStackingAction;
bool use_user_StackingAction; // only for fwd part of the adjoint simulation
bool use_user_TrackingAction;
void SetRestOfAdjointActions();
void SetAdjointPrimaryRunAndStackingActions();
void SetAdjointActions();
void ResetRestOfUserActions();
void ResetUserPrimaryRunAndStackingActions();
void ResetUserActions();
void DefineUserActions();
// action for adjoint simulation
//-----------------------------
G4UserRunAction* theAdjointRunAction;
G4UserEventAction* theAdjointEventAction;
G4AdjointPrimaryGeneratorAction* theAdjointPrimaryGeneratorAction;
G4AdjointTrackingAction* theAdjointTrackingAction;
G4AdjointSteppingAction* theAdjointSteppingAction;
G4AdjointStackingAction* theAdjointStackingAction;
G4AdjointSimManager();
~G4AdjointSimManager();
// private constructor and destructor
// adjoint mode
//-------------
G4bool adjoint_tracking_mode;
G4bool adjoint_sim_mode;
private: // attributes
// adjoint particle information on the external surface
//-----------------------------
std::vector<G4ThreeVector> last_pos_vec;
std::vector<G4ThreeVector> last_direction_vec;
std::vector<G4double> last_ekin_vec;
std::vector<G4double> last_ekin_nuc_vec;
std::vector<G4double> last_cos_th_vec;
std::vector<G4double> last_weight_vec;
std::vector<G4int> last_fwd_part_PDGEncoding_vec;
std::vector<G4int> last_fwd_part_index_vec;
std::vector<G4int> ID_of_last_particle_that_reach_the_ext_source_vec;
// Messenger
//----------
G4AdjointSimMessenger* theMessenger = nullptr;
G4ThreeVector last_pos;
G4ThreeVector last_direction;
G4double last_ekin,
last_ekin_nuc; // last_ekin_nuc=last_ekin/nuc, nuc is 1 if not a nucleus
G4double last_cos_th;
G4String last_fwd_part_name;
G4int last_fwd_part_PDGEncoding;
G4int last_fwd_part_index;
G4double last_weight;
G4int ID_of_last_particle_that_reach_the_ext_source;
// user defined actions for the normal fwd simulation.
// Taken from the G4RunManager
//-------------------------------------------------
G4bool user_action_already_defined = false;
G4UserRunAction* fUserRunAction = nullptr;
G4UserEventAction* fUserEventAction = nullptr;
G4VUserPrimaryGeneratorAction* fUserPrimaryGeneratorAction = nullptr;
G4UserTrackingAction* fUserTrackingAction = nullptr;
G4UserSteppingAction* fUserSteppingAction = nullptr;
G4UserStackingAction* fUserStackingAction = nullptr;
G4bool use_user_StackingAction = false; // only for fwd part of adjoint sim
G4bool use_user_TrackingAction = false;
G4int nb_evt_of_last_run;
G4int normalisation_mode;
// action for adjoint simulation
//-----------------------------
G4UserRunAction* theAdjointRunAction = nullptr;
G4UserEventAction* theAdjointEventAction = nullptr;
G4AdjointPrimaryGeneratorAction* theAdjointPrimaryGeneratorAction = nullptr;
G4AdjointTrackingAction* theAdjointTrackingAction = nullptr;
G4AdjointSteppingAction* theAdjointSteppingAction = nullptr;
G4AdjointStackingAction* theAdjointStackingAction = nullptr;
// Adjoint source
//--------------
G4double area_of_the_adjoint_source;
G4double nb_nuc;
G4double theAdjointPrimaryWeight;
// adjoint mode
//-------------
G4bool adjoint_tracking_mode = false;
G4bool adjoint_sim_mode = false;
// Weight Analysis
//----------
/*G4PhysicsLogVector* electron_last_weight_vector;
G4PhysicsLogVector* proton_last_weight_vector;
G4PhysicsLogVector* gamma_last_weight_vector;*/
// adjoint particle information on the external surface
//-----------------------------
std::vector<G4ThreeVector> last_pos_vec;
std::vector<G4ThreeVector> last_direction_vec;
std::vector<G4double> last_ekin_vec;
std::vector<G4double> last_ekin_nuc_vec;
std::vector<G4double> last_cos_th_vec;
std::vector<G4double> last_weight_vec;
std::vector<G4int> last_fwd_part_PDGEncoding_vec;
std::vector<G4int> last_fwd_part_index_vec;
std::vector<G4int> ID_of_last_particle_that_reach_the_ext_source_vec;
G4bool welcome_message;
G4ThreeVector last_pos;
G4ThreeVector last_direction;
G4double last_ekin = 0.0, last_ekin_nuc = 0.0;
// last_ekin_nuc=last_ekin/nuc, nuc is 1 if not a nucleus
G4double last_cos_th = 0.0;
G4String last_fwd_part_name;
G4int last_fwd_part_PDGEncoding = 0;
G4int last_fwd_part_index = 0;
G4double last_weight = 0.0;
G4int ID_of_last_particle_that_reach_the_ext_source = 0;
/* For the future
G4int nb_evt_of_last_run = 0;
G4int normalisation_mode = 3;
// Adjoint source
//--------------
G4double area_of_the_adjoint_source = 0.0;
G4double nb_nuc = 1.0;
G4double theAdjointPrimaryWeight = 0.0;
// Weight Analysis
//----------
/*G4PhysicsLogVector* electron_last_weight_vector;
G4PhysicsLogVector* proton_last_weight_vector;
G4PhysicsLogVector* gamma_last_weight_vector;*/
G4bool welcome_message = true;
/* For the future
//Convergence test
//----------------
G4double normalised_signal;
G4double error_signal;
G4bool convergence_test_is_used;
G4bool power_law_spectrum_for_convergence_test; // true PowerLaw, ;
G4bool power_law_spectrum_for_convergence_test; // true PowerLaw
G4ParticleDefinition* the_par_def_for_convergence_test;
*/
*/
};
#endif
+98 -136
View File
@@ -23,110 +23,87 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4AdjointSimMessenger
//
/////////////////////////////////////////////////////////////////////////////////
// Class Name: G4AdjointSimMessenger.hh
// Author: L. Desorgher
// Organisation: SpaceIT GmbH
// Contract: ESA contract 21435/08/NL/AT
// Customer: ESA/ESTEC
/////////////////////////////////////////////////////////////////////////////////
// Class description:
//
// CHANGE HISTORY
// --------------
// ChangeHistory:
// -1st January 2007 creation by L. Desorgher
// -November-December 2009 Some cleaning and adaptation for the first Release
//in the
// Geant4 toolkit, L. Desorgher
// This class represents the Messenger that defines the G4UI macro commands
// allowing the user controlling an adjoint/reverse MC simulation. It calls
// methods of G4AdjointSimManager.
//
//
//-------------------------------------------------------------
// Documentation:
// This class represents the Messenger that defined the G4UI macro comands
//allowing
// the user contreol an adjoint/reverse MC simulation. It calls methods of
// G4AdjointSimManager List of commands
// -----------------
// 1)Start an adjoint simulation
// --------------------------------------------
// Command:
// -/adjoint/start_run nb: Start an adjoint simulation with a number of
//events
// given by nb. 2)Definition of the external source
// ---------------------------------------------------
// The external source represents the real external source of particles till
//which
// adjoint particles are tracked in the reverse tracking mode of the
// 1) Start an adjoint simulation
// ---------------------------------------------------
// Command:
// -/adjoint/start_run nb: Start an adjoint simulation with a number of
// events given by nb.
// 2) Definition of the external source
// ---------------------------------------------------
// The external source represents the real external source of particles till
// which adjoint particles are tracked in the reverse tracking mode of the
// simulation (see G4AdjointSimManager.hh and G4Application Developer guide for
// more infos). The user can define the source as the external surface of a
// sphere or of G4 volume of the geometry. He can also set the maximum energy of
// the source. If an adjoint particle get an energy higher than this maximum
// energy before reaching the external surface source it is killed without being
// registered. Commands:
// -/adjoint/DefineSphericalExtSource R X Y Z unit_length:
// The external source is set on a sphere with radius R and centered on
// position (X,Y,Z)
// more infos). The user can define the source as the external surface of a
// sphere or of G4 volume of the geometry. He can also set the maximum energy
// of the source. If an adjoint particle get an energy higher than this maximum
// energy before reaching the external surface source it is killed without
// being registered.
// Commands:
// -/adjoint/DefineSphericalExtSource R X Y Z unit_length
// The external source is set on a sphere with radius R and centered on
// position (X,Y,Z)
// -/adjoint/DefineSphericalExtSourceCenteredOnAVolume pvol_name R unit_length
// The external source is set on a sphere with radius R and with its center
// position located at the center of the physical volume specified by the
// name pvol_name.
// -/adjoint/DefineExtSourceOnExtSurfaceOfAVolume pvol_name
// The external surface is set as the external boundary of a the physical
// volume with name pvol_name.
// -/adjoint/SetExtSourceEmax Emax energy_unit
// Set the maximum energy of the external source.
//
// -/adjoint/DefineSphericalExtSourceCenteredOnAVolume phys_vol_name R
// unit_length The external source is set on a sphere with radius R and
// with its center position located at the center of the the physical
// volume specified by the name phys_vol_name.
// -/adjoint/DefineExtSourceOnExtSurfaceOfAVolume phys_vol_name
// The external surface is set as the external boundary of a the
//physical
// volume with name phys_vol_name
// -/adjoint/SetExtSourceEmax Emax energy_unit
// Set the maximum energy of the external source
//
//
// 3)Definition of the adjoint source
// ---------------------------------------------------
// The adjoint source represents the source from which adjoint primary
//particles are
// generated.(see G4AdjointSimManager.hh and G4Application Developer guide for
// more infos) The user can define the source as the external surface of a
// sphere or of G4 volume of the geometry. He set the minimum maximum energy of
// the source and define which type of adjoint primary particles should be
// considered. Commands:
// -/adjoint/DefineSphericalAdjSource R X Y Z unit_length:
// The adjoint source is set on a sphere with radius R and centered on
// position (X,Y,Z)
//
// -/adjoint/DefineSphericalAdjSourceCenteredOnAVolume phys_vol_name R
// unit_length The external source is set on a sphere with radius R and
// with its center position located at the center of the the physical
// volume specified by the name phys_vol_name.
// -/adjoint/DefineAdjSourceOnExtSurfaceOfAVolume phys_vol_name
// The external surface is set as the external boundary of a the
//physical
// volume with name phys_vol_name
//
// -/adjoint/SetAdjSourceEmin Emin energy_unit
// Set the minimum energy of the external source
//
// -/adjoint/SetAdjSourceEmax Emax energy_unit
// Set the maximum energy of the external source
//
// -/adjoint/ConsiderAsPrimary particle_name
// The type of particle specified by "particle_name" will be added in
// the list
// of primary adjoint particles. The list of candidates depends on the
// reverse physics
// processes considered in the simulation. At the most the potential
// candidates are (e-, gamma, proton , ion)
//
// -/adjoint/NeglectAsPrimary particle_name
// The type of particle specified by "particle_name" will be removed
// from the
// list of primary adjoint particles. The list of candidates depends
// 3) Definition of the adjoint source
// ---------------------------------------------------
// The adjoint source represents the source from which adjoint primary
// particles are generated (see G4AdjointSimManager.hh and G4Application
// Developer guide for more infos).
// The user can define the source as the external surface of a sphere or of
// G4 volume of the geometry. He sets the minimum maximum energy of the
// source and defines which type of adjoint primary particles should be
// considered.
// Commands:
// -/adjoint/DefineSphericalAdjSource R X Y Z unit_length
// The adjoint source is set on a sphere with radius R and centered on
// position (X,Y,Z)
// -/adjoint/DefineSphericalAdjSourceCenteredOnAVolume pvol_name R unit_length
// The external source is set on a sphere with radius R and with its center
// position located at the center of the physical volume specified by the
// name pvol_name.
// -/adjoint/DefineAdjSourceOnExtSurfaceOfAVolume pvol_name
// The external surface is set as the external boundary of a the
// physical volume with name pvol_name
// -/adjoint/SetAdjSourceEmin Emin energy_unit
// Set the minimum energy of the external source
// -/adjoint/SetAdjSourceEmax Emax energy_unit
// Set the maximum energy of the external source
// -/adjoint/ConsiderAsPrimary particle_name
// The type of particle specified by "particle_name" will be added in
// the list of primary adjoint particles. The list of candidates depends on the
// reverse physics processes considered in the simulation. At the most the potential
// candidates are (e-, gamma, proton, ion).
// -/adjoint/NeglectAsPrimary particle_name
// The type of particle specified by "particle_name" will be removed
// from the list of primary adjoint particles. The list of candidates depends
// on the reverse physics processes considered in the simulation. At the most
// the potential candidates are (e-, gamma, proton , ion)
//
//
// the potential candidates are (e-, gamma, proton, ion).
#ifndef G4AdjointSimMessenger_h
#define G4AdjointSimMessenger_h 1
// --------------------------------------------------------------------
// Class Name: G4AdjointSimMessenger
// Author: L. Desorgher, 2007-2009
// Organisation: SpaceIT GmbH
// Contract: ESA contract 21435/08/NL/AT
// Customer: ESA/ESTEC
// --------------------------------------------------------------------
#ifndef G4AdjointSimMessenger_hh
#define G4AdjointSimMessenger_hh 1
#include "G4UImessenger.hh"
#include "globals.hh"
@@ -140,58 +117,43 @@ class G4UIcmdWithABool;
class G4UIcmdWithADoubleAndUnit;
class G4UIcmdWithoutParameter;
class G4UIcmdWithADouble;
/*
#ifdef G4MULTITHREADED
class G4MTAdjointSimManager;
#endif
*/
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
// --------------------------------------------------------------------
class G4AdjointSimMessenger : public G4UImessenger
{
public:
G4AdjointSimMessenger(G4AdjointSimManager*);
/*
#ifdef G4MULTITHREADED
G4AdjointSimMessenger(G4MTAdjointSimManager* );
#endif
*/
public:
~G4AdjointSimMessenger();
G4AdjointSimMessenger(G4AdjointSimManager*);
~G4AdjointSimMessenger();
void SetNewValue(G4UIcommand*, G4String);
void SetNewValue(G4UIcommand*, G4String);
private:
G4AdjointSimManager* theAdjointRunManager;
/*
#ifdef G4MULTITHREADED
G4MTAdjointSimManager* theMTAdjointRunManager;
#endif
*/
private:
G4UIdirectory* AdjointSimDir;
G4UIcommand* beamOnCmd;
G4AdjointSimManager* theAdjointRunManager;
G4UIcommand* DefineSpherExtSourceCmd;
G4UIcommand* DefineSpherExtSourceCenteredOnAVolumeCmd;
G4UIcmdWithAString* DefineExtSourceOnAVolumeExtSurfaceCmd;
G4UIcmdWithADoubleAndUnit* setExtSourceEMaxCmd;
G4UIdirectory* AdjointSimDir = nullptr;
G4UIcommand* beamOnCmd = nullptr;
G4UIcommand* DefineSpherAdjSourceCmd;
G4UIcommand* DefineSpherAdjSourceCenteredOnAVolumeCmd;
G4UIcmdWithAString* DefineAdjSourceOnAVolumeExtSurfaceCmd;
G4UIcommand* DefineSpherExtSourceCmd = nullptr;
G4UIcommand* DefineSpherExtSourceCenteredOnAVolumeCmd = nullptr;
G4UIcmdWithAString* DefineExtSourceOnAVolumeExtSurfaceCmd = nullptr;
G4UIcmdWithADoubleAndUnit* setExtSourceEMaxCmd = nullptr;
G4UIcmdWithADoubleAndUnit* setAdjSourceEminCmd;
G4UIcmdWithADoubleAndUnit* setAdjSourceEmaxCmd;
G4UIcommand* DefineSpherAdjSourceCmd = nullptr;
G4UIcommand* DefineSpherAdjSourceCenteredOnAVolumeCmd = nullptr;
G4UIcmdWithAString* DefineAdjSourceOnAVolumeExtSurfaceCmd = nullptr;
G4UIcmdWithAString* ConsiderParticleAsPrimaryCmd;
G4UIcmdWithAString* NeglectParticleAsPrimaryCmd;
G4UIcmdWithADoubleAndUnit* setAdjSourceEminCmd = nullptr;
G4UIcmdWithADoubleAndUnit* setAdjSourceEmaxCmd = nullptr;
G4UIcmdWithAnInteger* setNbOfPrimaryFwdGammasPerEventCmd;
G4UIcmdWithAnInteger* setNbOfPrimaryAdjGammasPerEventCmd;
G4UIcmdWithAnInteger* setNbOfPrimaryAdjElectronsPerEventCmd;
G4UIcmdWithAString* ConsiderParticleAsPrimaryCmd = nullptr;
G4UIcmdWithAString* NeglectParticleAsPrimaryCmd = nullptr;
G4UIcmdWithAnInteger* setNbOfPrimaryFwdGammasPerEventCmd = nullptr;
G4UIcmdWithAnInteger* setNbOfPrimaryAdjGammasPerEventCmd = nullptr;
G4UIcmdWithAnInteger* setNbOfPrimaryAdjElectronsPerEventCmd = nullptr;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
#endif
+27 -39
View File
@@ -23,58 +23,46 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// ------------------------------------------------------------
// GEANT 4 class header file
//
//
// ---------------- G4ExceptionHandler ----------------
//
// Authors: M.Asai - August 2002
//
// ------------------------------------------------------------
// G4ExceptionHandler
//
// Class description:
//
// Abstract base class which need to be notified when G4Exception occurs.
// The concrete class object derived from this base class will be automatically
// registered to G4StateManager and the virtual method Notify() will be invoked
// when G4Exception occurs.
// Abstract base class which needs to be notified when G4Exception occurs.
// The concrete class object derived from this class will be automatically
// registered to G4StateManager and the virtual method Notify() will be
// invoked when G4Exception occurs.
// ------------------------------------------------------------
#ifndef G4ExceptionHandler_h
#define G4ExceptionHandler_h 1
// Author: M.Asai - August 2002
// --------------------------------------------------------------------
#ifndef G4ExceptionHandler_hh
#define G4ExceptionHandler_hh 1
#include "globals.hh"
#include "G4ExceptionSeverity.hh"
#include "G4VExceptionHandler.hh"
#include "globals.hh"
class G4ExceptionHandler : public G4VExceptionHandler
{
public:
G4ExceptionHandler();
virtual ~G4ExceptionHandler();
G4bool operator==(const G4ExceptionHandler& right) const;
G4bool operator!=(const G4ExceptionHandler& right) const;
public:
public: // with description
virtual G4bool Notify(const char* originOfException,
const char* exceptionCode, G4ExceptionSeverity severity,
const char* description);
// Virtual method which will be invoked by G4StateManager when
// G4Exception occurs.
// If TRUE returned, core dump will be generated, while FALSE returned,
// program execution continues.
G4ExceptionHandler();
virtual ~G4ExceptionHandler();
G4bool operator==(const G4ExceptionHandler& right) const;
G4bool operator!=(const G4ExceptionHandler& right) const;
private:
G4ExceptionHandler(const G4ExceptionHandler& right);
G4ExceptionHandler& operator=(const G4ExceptionHandler& right);
G4ExceptionHandler(const G4ExceptionHandler&) = delete;
G4ExceptionHandler& operator=(const G4ExceptionHandler&) = delete;
private:
void DumpTrackInfo();
virtual G4bool Notify(const char* originOfException,
const char* exceptionCode, G4ExceptionSeverity severity,
const char* description);
// Will be invoked by G4StateManager when G4Exception occurs.
// If TRUE returned, core dump is generated, while if FALSE,
// the program execution continues.
private:
void DumpTrackInfo();
};
#endif
+27 -29
View File
@@ -23,45 +23,43 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// class description:
//
//////////////////////
// G4MSSteppingAction
/////////////////////
//
// Class description:
//
// Stepping action for material scanner.
#ifndef G4MSSteppingAction_h
#define G4MSSteppingAction_h 1
// Author: M.Asai, 5 May 2006
// --------------------------------------------------------------------
#ifndef G4MSSteppingAction_hh
#define G4MSSteppingAction_hh 1
#include "globals.hh"
#include "G4UserSteppingAction.hh"
class G4Region;
#include "G4UserSteppingAction.hh"
#include "globals.hh"
class G4MSSteppingAction : public G4UserSteppingAction
{
public:
G4MSSteppingAction();
virtual ~G4MSSteppingAction();
public:
void Initialize(G4bool rSens, G4Region* reg);
virtual void UserSteppingAction(const G4Step*);
G4MSSteppingAction();
virtual ~G4MSSteppingAction();
private:
G4bool regionSensitive;
G4Region* theRegion;
G4double length;
G4double x0;
G4double lambda;
void Initialize(G4bool rSens, G4Region* reg);
virtual void UserSteppingAction(const G4Step*);
public:
inline G4double GetTotalStepLength() const { return length; }
inline G4double GetX0() const { return x0; }
inline G4double GetLambda0() const { return lambda; }
inline G4double GetTotalStepLength() const { return length; }
inline G4double GetX0() const { return x0; }
inline G4double GetLambda0() const { return lambda; }
private:
G4bool regionSensitive = false;
G4Region* theRegion = nullptr;
G4double length = 0.0;
G4double x0 = 0.0;
G4double lambda = 0.0;
};
#endif
+229 -231
View File
@@ -23,24 +23,29 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4MTRunManager
//
// class description:
// This is a class for run control in GEANT4 for multi-threaded runs
// It extends G4RunManager re-implementing multi-threaded behavior in
// key methods. See documentation for G4RunManager
// Users initializes an instance of this class instead of G4RunManager
// to start a multi-threaded simulation.
// Class description:
//
// This is a class for run control in Geant4 of multi-threaded runs.
// It extends G4RunManager re-implementing multi-threaded behavior in
// key methods (see documentation for G4RunManager).
// Users initialise an instance of this class instead of G4RunManager
// to start a multi-threaded simulation.
#ifndef G4MTRunManager_h
#define G4MTRunManager_h 1
// Original authors: X.Dong, A.Dotti - February 2013
// --------------------------------------------------------------------
#ifndef G4MTRunManager_hh
#define G4MTRunManager_hh 1
#include <list>
#include <map>
#include "G4MTBarrier.hh"
#include "G4RNGHelper.hh"
#include "G4RunManager.hh"
#include "G4Threading.hh"
#include "G4Profiler.hh"
#include <list>
#include <map>
class G4MTRunManagerKernel;
class G4ScoringManager;
@@ -54,246 +59,239 @@ class G4MTRunManager : public G4RunManager
{
friend class G4RunManagerFactory;
public:
// the profiler aliases are only used when compiled with GEANT4_USE_TIMEMORY
using ProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>;
public:
public:
G4MTRunManager();
virtual ~G4MTRunManager();
// New method
virtual void SetNumberOfThreads(G4int n);
virtual G4int GetNumberOfThreads() const { return nworkers; }
void SetPinAffinity(G4int n = 1);
G4int GetPinAffinity() const { return pinAffinity; }
using ProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>;
// The profiler aliases are only used when compiled with
// GEANT4_USE_TIMEMORY.
public:
// Inherited methods to re-implement for MT case
virtual void Initialize();
virtual void InitializeEventLoop(G4int n_event, const char* macroFile = 0,
G4int n_select = -1);
virtual void InitializeThreadPool() {}
using masterWorlds_t = std::map<G4int, G4VPhysicalVolume*>;
// Map of defined worlds.
// The following do not do anything for this runmanager
virtual void TerminateOneEvent();
virtual void ProcessOneEvent(G4int i_event);
////virtual void TerminateEventLoop();
virtual void ConstructScoringWorlds();
virtual void RunTermination();
G4MTRunManager();
virtual ~G4MTRunManager();
// The following method should be invoked by G4WorkerRunManager for each
// event. False is returned if no more event to be processed. Note: G4Event
// object must be instantiated by a worker thread. In case no more
// event remains to be processed, that worker thread must delete that G4Event
// object. If a worker runs with its own random number sequence, the boolean
// flag reseedRequired should be set to false. This is *NOT* allowed for the
// first event.
virtual G4bool SetUpAnEvent(G4Event*, long& s1, long& s2, long& s3,
G4bool reseedRequired = true);
// Same as above method, but the seeds are set only once over "eventModulo"
// events. The return value shows the number of events the caller Worker has
// to process (between 1 and eventModulo depending on number of events yet to
// be processed). G4Event object has the event ID of the first event of this
// bunch. If zero is returned no more event needs to be processed, and worker
// thread must delete that G4Event.
virtual G4int SetUpNEvents(G4Event*, G4SeedsQueue* seedsQueue,
G4bool reseedRequired = true);
virtual void SetNumberOfThreads(G4int n);
virtual G4int GetNumberOfThreads() const { return nworkers; }
void SetPinAffinity(G4int n = 1);
inline G4int GetPinAffinity() const { return pinAffinity; }
// Method called by Initialize() method
protected:
// Initialize the seeds list, if derived class does not implement this method
// A default generation will be used (nevents*2 random seeds)
// Return true if initialization is done.
virtual G4bool InitializeSeeds(G4int /*nevts*/) { return false; };
// Adds one seed to the list of seeds
virtual void PrepareCommandsStack();
virtual void StoreRNGStatus(const G4String& filenamePrefix);
virtual void rndmSaveThisRun();
virtual void rndmSaveThisEvent();
virtual void CreateAndStartWorkers();
// Creates worker threads and signal to start
public:
std::vector<G4String> GetCommandStack();
// This method is invoked just before spawning the threads to
// collect from UI managere the list of commands that threads
// will execute.
virtual size_t GetNumberActiveThreads() const { return threads.size(); }
// Returns number of currently active threads.
// This number may be different from the number of threads currently
// in running state (e.g. the number returned by:
// G4Threading::GetNumberOfActiveWorkerThreads() method).
static G4ThreadId GetMasterThreadId();
// Inherited methods to re-implement for MT case
virtual void Initialize();
virtual void InitializeEventLoop(G4int n_event, const char* macroFile = 0,
G4int n_select = -1);
virtual void InitializeThreadPool() {}
protected:
// Number of worker threads. To be set by SetNumberOfThreads() method.
G4int nworkers;
// Force to use this number regardless of SetNumberOfThreads() method.
G4int forcedNwokers;
// The following do not do anything for this runmanager
virtual void TerminateOneEvent();
virtual void ProcessOneEvent(G4int i_event);
virtual void ConstructScoringWorlds();
virtual void RunTermination();
private:
// Pin Affinity parameter
G4int pinAffinity;
// List of workers (i.e. thread)
typedef std::list<G4Thread*> G4ThreadsList;
G4ThreadsList threads;
// List of workers run managers
// List of all workers run managers
std::vector<G4String> uiCmdsForWorkers;
// List of UI commands for workers.
CLHEP::HepRandomEngine* masterRNGEngine;
// Pointer to the mastet thread random engine
protected:
virtual void WaitForReadyWorkers();
// Master thread barrier:
// Call this function to block master thread and
// wait workers to be ready to process work.
// This function will return only when all
// workers are ready to perform event loop.
virtual void WaitForEndEventLoopWorkers();
// Master thread barrier:
// Call this function to block master thread and
// wait workers have finished current event loop.
// This function will return only when all
// workers have finished processing events for this run.
protected:
G4int numberOfEventToBeProcessed;
virtual void TerminateWorkers();
// Empty the workersList
virtual G4bool SetUpAnEvent(G4Event*, long& s1, long& s2, long& s3,
G4bool reseedRequired = true);
// The following method should be invoked by G4WorkerRunManager for each
// event. False is returned if no more event to be processed.
// Note: G4Event object must be instantiated by a worker thread.
// In case no more events remain to be processed, that worker thread must
// delete that G4Event object. If a worker runs with its own random number
// sequence, the Boolean flag 'reseedRequired' should be set to false.
// This is *NOT* allowed for the first event.
public:
virtual void ThisWorkerReady();
// Worker threads barrier:
// This method should be called by each
// worker when ready to start thread event-loop
// This method will return only when all workers
// are ready.
// static void ThisWorkerFinishWork();
// Worker threads barrier:
// This static method should be called by each
// worker when finish to process events
virtual void ThisWorkerEndEventLoop();
// Worker threads barrier:
// This method should be called by each
// worker when worker event loop is terminated.
typedef std::map<G4int, G4VPhysicalVolume*> masterWorlds_t;
static G4ScoringManager* GetMasterScoringManager();
static masterWorlds_t& GetMasterWorlds();
static void addWorld(G4int counter, G4VPhysicalVolume* w);
virtual G4int SetUpNEvents(G4Event*, G4SeedsQueue* seedsQueue,
G4bool reseedRequired = true);
// Same as above method, but seeds are set only once over "eventModulo"
// events. The return value shows the number of events the caller Worker
// has to process (between 1 and eventModulo depending on number of events
// yet to be processed). G4Event object has the event ID of the first
// event of this bunch. If zero is returned no more events need to be
// processed, and worker thread must delete that G4Event.
// Called by Initialize() method.
const CLHEP::HepRandomEngine* getMasterRandomEngine() const
{
return masterRNGEngine;
}
std::vector<G4String> GetCommandStack();
// This method is invoked just before spawning the threads to
// collect from UI manager the list of commands that threads
// will execute.
protected:
// Handling of master thread scoring worlds, access to it is needed by workers
G4MTRUN_DLL static G4ScoringManager* masterScM;
G4MTRUN_DLL static masterWorlds_t masterWorlds;
// Singleton implementing master thread behavior
G4MTRUN_DLL static G4MTRunManager* fMasterRM;
virtual size_t GetNumberActiveThreads() const { return threads.size(); }
// Returns number of currently active threads.
// This number may be different from the number of threads currently
// in running state, e.g. the number returned by:
// G4Threading::GetNumberOfActiveWorkerThreads() method.
private:
G4MTRunManagerKernel* MTkernel;
static G4ThreadId GetMasterThreadId();
public: // with description
static G4MTRunManager* GetMasterRunManager();
// Returns the singleton instance of the run manager common to all threads
// implementing the master behavior
static G4RunManagerKernel* GetMasterRunManagerKernel();
static G4MTRunManagerKernel* GetMTMasterRunManagerKernel();
// Returns the singleton instance of the run manager kernel common to all
// threads
virtual void ThisWorkerReady();
// Worker threads barrier: this method should be called by each
// worker when ready to start thread event-loop.
// This method will return only when all workers are ready.
virtual void SetUserInitialization(G4VUserPhysicsList* userPL);
virtual void SetUserInitialization(G4VUserDetectorConstruction* userDC);
virtual void SetUserInitialization(G4UserWorkerInitialization* userInit);
virtual void SetUserInitialization(
G4UserWorkerThreadInitialization* userInit);
virtual void SetUserInitialization(G4VUserActionInitialization* userInit);
virtual void SetUserAction(G4UserRunAction* userAction);
virtual void SetUserAction(G4VUserPrimaryGeneratorAction* userAction);
virtual void SetUserAction(G4UserEventAction* userAction);
virtual void SetUserAction(G4UserStackingAction* userAction);
virtual void SetUserAction(G4UserTrackingAction* userAction);
virtual void SetUserAction(G4UserSteppingAction* userAction);
virtual void ThisWorkerEndEventLoop();
// Worker threads barrier: this method should be called by each
// worker when worker event loop is terminated.
public:
// To be invoked solely from G4WorkerRunManager to merge the results
void MergeScores(const G4ScoringManager* localScoringManager);
void MergeRun(const G4Run* localRun);
static G4ScoringManager* GetMasterScoringManager();
static masterWorlds_t& GetMasterWorlds();
static void addWorld(G4int counter, G4VPhysicalVolume* w);
public:
// Handling of more than one run per thread
enum class WorkerActionRequest
{
UNDEFINED,
NEXTITERATION, // There is another set of UI commands to be executed
PROCESSUI, // Process UI commands w/o a /run/beamOn
ENDWORKER // Terminate thread, work finished
};
virtual void RequestWorkersProcessCommandsStack();
// Called to force workers to request and process the UI commands stack
// This will block untill all workers have processed UI commands
virtual void ThisWorkerProcessCommandsStackDone();
// Called by workers to signal to master it has completed processing of
// UI commands
virtual WorkerActionRequest ThisWorkerWaitForNextAction();
// Worker thread barrier
// This method should be used by workers' run manager to wait,
// after an event loop for the next action to be performed
// (for example execute a new run)
// This returns the action to be performed
protected:
WorkerActionRequest nextActionRequest;
virtual void NewActionRequest(WorkerActionRequest newRequest);
inline const CLHEP::HepRandomEngine* getMasterRandomEngine() const
{
return masterRNGEngine;
}
protected:
G4int eventModuloDef;
G4int eventModulo;
G4int nSeedsUsed;
G4int nSeedsFilled;
G4int nSeedsMax;
G4int nSeedsPerEvent;
double* randDbl;
static G4MTRunManager* GetMasterRunManager();
// Returns the singleton instance of the run manager common to all
// threads implementing the master behavior
static G4RunManagerKernel* GetMasterRunManagerKernel();
static G4MTRunManagerKernel* GetMTMasterRunManagerKernel();
// Returns the singleton instance of the run manager kernel common to all
//threads
virtual void RefillSeeds();
virtual void SetUserInitialization(G4VUserPhysicsList* userPL);
virtual void SetUserInitialization(G4VUserDetectorConstruction* userDC);
virtual void SetUserInitialization(G4UserWorkerInitialization* userInit);
virtual void SetUserInitialization(G4UserWorkerThreadInitialization* userInit);
virtual void SetUserInitialization(G4VUserActionInitialization* userInit);
virtual void SetUserAction(G4UserRunAction* userAction);
virtual void SetUserAction(G4VUserPrimaryGeneratorAction* userAction);
virtual void SetUserAction(G4UserEventAction* userAction);
virtual void SetUserAction(G4UserStackingAction* userAction);
virtual void SetUserAction(G4UserTrackingAction* userAction);
virtual void SetUserAction(G4UserSteppingAction* userAction);
public:
inline void SetEventModulo(G4int i = 1) { eventModuloDef = i; }
inline G4int GetEventModulo() const { return eventModuloDef; }
// To be invoked solely from G4WorkerRunManager to merge the results
void MergeScores(const G4ScoringManager* localScoringManager);
void MergeRun(const G4Run* localRun);
public:
virtual void AbortRun(G4bool softAbort = false);
virtual void AbortEvent();
// Handling of more than one run per thread
enum class WorkerActionRequest
{
UNDEFINED,
NEXTITERATION, // There is another set of UI commands to be executed
PROCESSUI, // Process UI commands w/o a /run/beamOn
ENDWORKER // Terminate thread, work finished
};
protected:
static G4ThreadId masterThreadId;
static G4int seedOncePerCommunication;
// - If it is set to 0 (default), seeds that are centrally managed
// by G4MTRunManager are set for every event of every worker thread.
// This option guarantees event reproducability regardless of number
// of threads.
// - If it is set to 1, seeds are set only once for the first
// event of each run of each worker thread. Event reproducability is
// guaranteed only if the same number of worker threads are used.
// On the other hand, this option offers better computing performance
// in particular for applications with relatively small primary
// particle energy and large number of events.
// - If it is set to 2, seeds are set only for the first event of
// group of N events. This option is reserved for the future use when
// Geant4 allows number of threads to be dynatically changed during an
// event loop.
public:
static G4int SeedOncePerCommunication();
static void SetSeedOncePerCommunication(G4int val);
static G4ThreadId GetMasterTheadId();
protected:
// Barriers: synch points between master and workers
G4MTBarrier beginOfEventLoopBarrier;
G4MTBarrier endOfEventLoopBarrier;
G4MTBarrier nextActionRequestBarrier;
G4MTBarrier processUIBarrier;
virtual void RequestWorkersProcessCommandsStack();
// Called to force workers to request and process the UI commands stack
// This will block untill all workers have processed UI commands
virtual void ThisWorkerProcessCommandsStackDone();
// Called by workers to signal to master it has completed processing of
// UI commands
virtual WorkerActionRequest ThisWorkerWaitForNextAction();
// Worker thread barrier: this method should be used by workers' run
// manager to wait, after an event loop for the next action to be
// performed (for example execute a new run).
// This returns the action to be performed.
inline void SetEventModulo(G4int i = 1) { eventModuloDef = i; }
inline G4int GetEventModulo() const { return eventModuloDef; }
virtual void AbortRun(G4bool softAbort = false);
virtual void AbortEvent();
static G4int SeedOncePerCommunication();
static void SetSeedOncePerCommunication(G4int val);
static G4ThreadId GetMasterTheadId();
protected:
virtual G4bool InitializeSeeds(G4int /*nevts*/) { return false; };
// Initialize the seeds list, if derived class does not implement this
// method, a default generation will be used (nevents*2 random seeds).
// Return true if initialization is done.
// Adds one seed to the list of seeds.
virtual void PrepareCommandsStack();
virtual void StoreRNGStatus(const G4String& filenamePrefix);
virtual void rndmSaveThisRun();
virtual void rndmSaveThisEvent();
virtual void CreateAndStartWorkers();
// Creates worker threads and signal to start
virtual void WaitForReadyWorkers();
// Master thread barrier: call this function to block master thread and
// wait workers to be ready to process work. This function will return
// only when all workers are ready to perform event loop.
virtual void WaitForEndEventLoopWorkers();
// Master thread barrier: call this function to block master thread and
// wait workers have finished current event loop. This function will
// return only when all workers have finished processing events for
// this run.
virtual void TerminateWorkers();
// Empty the workersList.
virtual void NewActionRequest(WorkerActionRequest newRequest);
virtual void RefillSeeds();
protected:
G4int nworkers = 2;
// Number of worker threads. To be set by SetNumberOfThreads() method.
G4int forcedNwokers = -1;
// Force to use this number regardless of SetNumberOfThreads() method.
G4int numberOfEventToBeProcessed = 0;
G4MTRUN_DLL static G4ScoringManager* masterScM;
// Handling of master thread scoring worlds, access is needed by workers
G4MTRUN_DLL static masterWorlds_t masterWorlds;
G4MTRUN_DLL static G4MTRunManager* fMasterRM;
// Singleton implementing master thread behavior
WorkerActionRequest nextActionRequest = WorkerActionRequest::UNDEFINED;
G4int eventModuloDef = 0;
G4int eventModulo = 1;
G4int nSeedsUsed = 0;
G4int nSeedsFilled = 0;
G4int nSeedsMax = 10000;
G4int nSeedsPerEvent = 2;
G4double* randDbl = nullptr;
static G4ThreadId masterThreadId;
static G4int seedOncePerCommunication;
// - If it is set to 0 (default), seeds that are centrally managed
// by G4MTRunManager are set for every event of every worker thread.
// This option guarantees event reproducibility regardless of number
// of threads.
// - If it is set to 1, seeds are set only once for the first
// event of each run of each worker thread. Event reproducibility is
// guaranteed only if the same number of worker threads are used.
// On the other hand, this option offers better computing performance
// in particular for applications with relatively small primary
// particle energy and large number of events.
// - If it is set to 2, seeds are set only for the first event of
// group of N events. This option is reserved for the future use when
// Geant4 will allow number of threads to be dynamically changed during
// an event loop.
// Barriers: synch points between master and workers
G4MTBarrier beginOfEventLoopBarrier;
G4MTBarrier endOfEventLoopBarrier;
G4MTBarrier nextActionRequestBarrier;
G4MTBarrier processUIBarrier;
private:
using G4ThreadsList = std::list<G4Thread*>;
// List of workers (i.e. thread)
G4int pinAffinity = 0;
// Pin Affinity parameter
G4ThreadsList threads;
// List of workers run managers
// List of all workers run managers
std::vector<G4String> uiCmdsForWorkers;
// List of UI commands for workers.
CLHEP::HepRandomEngine* masterRNGEngine = nullptr;
// Pointer to the mastet thread random engine
G4MTRunManagerKernel* MTkernel = nullptr;
};
#endif // G4MTRunManager_h
#endif // G4MTRunManager_hh
+51 -55
View File
@@ -23,36 +23,38 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
////
// G4MTRunManagerKernel
//
// Class description:
//
// This is a class for mandatory control of the Geant4 kernel.
// This class implements Worker behavior in a MT application.
//
// This class is constructed by G4MTRunManager. If a user uses his/her own
// class instead of G4MTRunManager, this class must be instantiated by at the
// very beginning of the application and must be deleted at the very end.
// Also, the following methods must be invoked in the proper order:
// DefineWorldVolume()
// InitializePhysics()
// RunInitialization()
// RunTermination()
//
// User must provide his/her own classes derived from the following
// abstract class and register it to the RunManagerKernel:
// G4VUserPhysicsList - Particle types, Processes and Cuts
//
// G4MTRunManagerKernel does not have an event loop. Handling of events
// is managed by G4RunManager.
//
// This class re-implements only the methods that require special treatment
// to implement worker behavior
// class description:
//
// This is a class for mandatory control of GEANT4 kernel.
// This class implements Worker behavior in a MT application.
//
// This class is constructed by G4MTRunManager. If a user uses his/her own
// class instead of G4MTRunManager, this class must be instantiated by
// him/herself at the very beginning of the application and must be deleted
// at the very end of the application. Also, following methods must be
// invoked in the proper order.
// DefineWorldVolume
// InitializePhysics
// RunInitialization
// RunTermination
//
// User must provide his/her own classes derived from the following
// abstract class and register it to the RunManagerKernel.
// G4VUserPhysicsList - Particle types, Processes and Cuts
//
// G4MTRunManagerKernel does not have any eveny loop. Handling of events
// is managed by G4RunManager.
//
// This class re-implements only the method that require special treatment
// to implement worker behavior
// Author: M.Asai - July 2013
// --------------------------------------------------------------------
#ifndef G4MTRunManagerKernel_hh
#define G4MTRunManagerKernel_hh 1
#ifndef G4MTRunManagerKernel_h
#define G4MTRunManagerKernel_h 1
#include <vector>
#include "G4MTRunManager.hh"
#include "G4RunManagerKernel.hh"
@@ -60,43 +62,37 @@
class G4WorkerThread;
class G4WorkerRunManager;
#include <vector>
class G4MTRunManagerKernel : public G4RunManagerKernel
{
public:
G4MTRunManagerKernel();
virtual ~G4MTRunManagerKernel();
public:
protected:
void SetupShadowProcess() const;
G4MTRunManagerKernel();
virtual ~G4MTRunManagerKernel();
public: // with descroption
// This static method is used to start a worker thread.
// Virtual methods to be invoked from this methos are
// defined in G4UserWorkerInitialization class.
static void StartThread(G4WorkerThread* context);
static void StartThread(G4WorkerThread* context);
// Used to start a worker thread. Virtual methods to be invoked
// from this method are defined in G4UserWorkerInitialization class.
// private:
// static void ReinitializeGeometry();
private:
static G4ThreadLocal G4WorkerThread* wThreadContext;
static G4WorkerThread* GetWorkerThread();
public:
static G4WorkerThread* GetWorkerThread();
void SetUpDecayChannels();
// Fill decay tables with particle definition pointers of decay products.
// This method has to be invoked by G4MTRunManager before the event loop
// starts on workers.
public: // with descroption
// Fill decay tables with particle definition pointers of
// decay products. This method has to be invoked by
// MTRunManager before event loop starts on workers.
void SetUpDecayChannels();
void BroadcastAbortRun(G4bool softAbort);
// This method should be invoked by G4MTRunManager.
private:
static std::vector<G4WorkerRunManager*>* workerRMvector;
protected:
public:
// This method should be invoked by G4MTRunManager
void BroadcastAbortRun(G4bool softAbort);
void SetupShadowProcess() const;
private:
static G4ThreadLocal G4WorkerThread* wThreadContext;
static std::vector<G4WorkerRunManager*>* workerRMvector;
};
#endif // G4MTRunManagerKernel_h
#endif // G4MTRunManagerKernel_hh
+26 -22
View File
@@ -23,17 +23,19 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4MatScanMessenger
//
// Class description:
//
//
// Messenger class for materials scanner.
// class description:
//
#ifndef G4MatScanMessenger_HH
#define G4MatScanMessenger_HH 1
// Author: M.Asai, May 2006
// --------------------------------------------------------------------
#ifndef G4MatScanMessenger_hh
#define G4MatScanMessenger_hh 1
#include "G4UImessenger.hh"
class G4UIdirectory;
class G4UIcmdWithoutParameter;
class G4UIcommand;
@@ -45,25 +47,27 @@ class G4MaterialScanner;
class G4MatScanMessenger : public G4UImessenger
{
public:
G4MatScanMessenger(G4MaterialScanner* p1);
virtual ~G4MatScanMessenger();
public:
virtual G4String GetCurrentValue(G4UIcommand* command);
virtual void SetNewValue(G4UIcommand* command, G4String newValue);
G4MatScanMessenger(G4MaterialScanner* p1);
virtual ~G4MatScanMessenger();
private:
G4MaterialScanner* theScanner;
virtual G4String GetCurrentValue(G4UIcommand* command);
virtual void SetNewValue(G4UIcommand* command, G4String newValue);
G4UIdirectory* msDirectory;
G4UIcmdWithoutParameter* scanCmd;
G4UIcommand* thetaCmd;
G4UIcommand* phiCmd;
G4UIcommand* singleCmd;
G4UIcmdWith3Vector* single2Cmd;
G4UIcmdWithABool* regSenseCmd;
G4UIcmdWithAString* regionCmd;
G4UIcmdWith3VectorAndUnit* eyePosCmd;
private:
G4MaterialScanner* theScanner = nullptr;
G4UIdirectory* msDirectory = nullptr;
G4UIcmdWithoutParameter* scanCmd = nullptr;
G4UIcommand* thetaCmd = nullptr;
G4UIcommand* phiCmd = nullptr;
G4UIcommand* singleCmd = nullptr;
G4UIcmdWith3Vector* single2Cmd = nullptr;
G4UIcmdWithABool* regSenseCmd = nullptr;
G4UIcmdWithAString* regionCmd = nullptr;
G4UIcmdWith3VectorAndUnit* eyePosCmd = nullptr;
};
#endif
+65 -65
View File
@@ -23,17 +23,17 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
#ifndef G4MaterialScanner_H
#define G4MaterialScanner_H 1
// class description:
//
// G4MaterialScanner
//
// Class description:
//
// Utility class for scanning of materials through ray-tracing
// in a detector setup.
// Author: M.Asai, May 2006
// --------------------------------------------------------------------
#ifndef G4MaterialScanner_hh
#define G4MaterialScanner_hh 1
#include "G4ThreeVector.hh"
#include "globals.hh"
@@ -51,73 +51,73 @@ class G4Region;
class G4MaterialScanner
{
public: // with description
G4MaterialScanner();
public:
public:
~G4MaterialScanner();
G4MaterialScanner();
~G4MaterialScanner();
public: // with description
void Scan();
// The main entry point which triggers ray tracing.
// This method is available only if Geant4 is at Idle state.
void Scan();
// The main entry point which triggers ray tracing.
// This method is available only if Geant4 is in Idle state.
private:
void DoScan();
// Event loop
void StoreUserActions();
void RestoreUserActions();
// Store and restore user action classes if defined
inline void SetEyePosition(const G4ThreeVector& val) { eyePosition = val; }
inline G4ThreeVector GetEyePosition() const { return eyePosition; }
inline void SetNTheta(G4int val) { nTheta = val; }
inline G4int GetNTheta() const { return nTheta; }
inline void SetThetaMin(G4double val) { thetaMin = val; }
inline G4double GetThetaMin() const { return thetaMin; }
inline void SetThetaSpan(G4double val) { thetaSpan = val; }
inline G4double GetThetaSpan() const { return thetaSpan; }
inline void SetNPhi(G4int val) { nPhi = val; }
inline G4int GetNPhi() const { return nPhi; }
inline void SetPhiMin(G4double val) { phiMin = val; }
inline G4double GetPhiMin() const { return phiMin; }
inline void SetPhiSpan(G4double val) { phiSpan = val; }
inline G4double GetPhiSpan() const { return phiSpan; }
inline void SetRegionSensitive(G4bool val = true) { regionSensitive = val; }
inline G4bool GetRegionSensitive() const { return regionSensitive; }
G4bool SetRegionName(const G4String& val);
inline const G4String& GetRegionName() const { return regionName; }
private:
G4RayShooter* theRayShooter;
G4MatScanMessenger* theMessenger;
private:
G4EventManager* theEventManager;
void DoScan();
// Event loop
G4UserEventAction* theUserEventAction;
G4UserStackingAction* theUserStackingAction;
G4UserTrackingAction* theUserTrackingAction;
G4UserSteppingAction* theUserSteppingAction;
void StoreUserActions();
void RestoreUserActions();
// Store and restore user action classes if defined.
G4UserEventAction* theMatScannerEventAction;
G4UserStackingAction* theMatScannerStackingAction;
G4UserTrackingAction* theMatScannerTrackingAction;
G4MSSteppingAction* theMatScannerSteppingAction;
private:
G4ThreeVector eyePosition;
G4int nTheta;
G4double thetaMin;
G4double thetaSpan;
G4int nPhi;
G4double phiMin;
G4double phiSpan;
G4RayShooter* theRayShooter = nullptr;
G4MatScanMessenger* theMessenger = nullptr;
G4EventManager* theEventManager = nullptr;
G4ThreeVector eyeDirection;
G4UserEventAction* theUserEventAction = nullptr;
G4UserStackingAction* theUserStackingAction = nullptr;
G4UserTrackingAction* theUserTrackingAction = nullptr;
G4UserSteppingAction* theUserSteppingAction = nullptr;
G4bool regionSensitive;
G4String regionName;
G4Region* theRegion;
G4UserEventAction* theMatScannerEventAction = nullptr;
G4UserStackingAction* theMatScannerStackingAction = nullptr;
G4UserTrackingAction* theMatScannerTrackingAction = nullptr;
G4MSSteppingAction* theMatScannerSteppingAction = nullptr;
public:
inline void SetEyePosition(const G4ThreeVector& val) { eyePosition = val; }
inline G4ThreeVector GetEyePosition() const { return eyePosition; }
inline void SetNTheta(G4int val) { nTheta = val; }
inline G4int GetNTheta() const { return nTheta; }
inline void SetThetaMin(G4double val) { thetaMin = val; }
inline G4double GetThetaMin() const { return thetaMin; }
inline void SetThetaSpan(G4double val) { thetaSpan = val; }
inline G4double GetThetaSpan() const { return thetaSpan; }
inline void SetNPhi(G4int val) { nPhi = val; }
inline G4int GetNPhi() const { return nPhi; }
inline void SetPhiMin(G4double val) { phiMin = val; }
inline G4double GetPhiMin() const { return phiMin; }
inline void SetPhiSpan(G4double val) { phiSpan = val; }
inline G4double GetPhiSpan() const { return phiSpan; }
inline void SetRegionSensitive(G4bool val = true) { regionSensitive = val; }
inline G4bool GetRegionSensitive() const { return regionSensitive; }
G4bool SetRegionName(const G4String& val);
inline G4String GetRegionName() const { return regionName; }
G4ThreeVector eyePosition;
G4int nTheta = 91;
G4double thetaMin = 0.0;
G4double thetaSpan = 0.0;
G4int nPhi = 37;
G4double phiMin = 0.0;
G4double phiSpan = 0.0;
G4ThreeVector eyeDirection;
G4bool regionSensitive = false;
G4String regionName = "notDefined";
G4Region* theRegion = nullptr;
};
#endif
+30 -38
View File
@@ -23,54 +23,46 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4MultiRunAction
//
// Class description:
//
//---------------------------------------------------------------
//
// G4MultiRunAction.hh
//
// Created on: Jan 17, 2016
// Author: adotti
//
//
// class description:
// This class extends G4UserRunAction and allows multiple
// user-defined tracking actions to be used in the same job.
// The class is a vector of user-defined tracking actions.
// This class owns and manages the dependent user-actions.
// Usage:
// There is no need to explicitly use this class as long as the
// user actions are set via G4UserActionInitialization::SetUserAction
// that can be called several times. Explicitly this is what is happening:
// In user-defined action initialization:
// G4MultiRunAction* action = new G4MultiRunAction;
// action->push_back( G4UserRunActionUPtr( new MyUserRunAction );
// [... add as many as needed ...]
// SetUserAction( action );
// ---------------------------------------------------------------
//
// This class extends G4UserRunAction and allows multiple user-defined
// tracking actions to be used in the same job.
// The class is a vector of user-defined tracking actions.
// This class owns and manages the dependent user-actions.
// There is no need to explicitly use this class as long as the user-actions
// are set via G4UserActionInitialization::SetUserAction() that can be called
// several times. In particular, this is what is happening in a user-defined
// action initialization:
// G4MultiRunAction* action = new G4MultiRunAction;
// action->push_back( G4UserRunActionUPtr( new MyUserRunAction );
// [... add as many as needed ...]
// SetUserAction( action );
#ifndef G4MULTIRUNACTION_HH_
#define G4MULTIRUNACTION_HH_
// Author: A.Dotti, 17 January 2016
// --------------------------------------------------------------------
#ifndef G4MultiRunAction_hh
#define G4MultiRunAction_hh 1
#include "G4UserRunAction.hh"
#include <memory>
#include <vector>
#include "G4UserRunAction.hh"
using G4UserRunActionUPtr = std::unique_ptr<G4UserRunAction>;
using G4UserRunActionVector = std::vector<G4UserRunActionUPtr>;
class G4MultiRunAction
: public G4UserRunAction
, public G4UserRunActionVector
class G4MultiRunAction : public G4UserRunAction, public G4UserRunActionVector
{
public:
G4MultiRunAction() = default;
virtual ~G4MultiRunAction() = default;
virtual G4Run* GenerateRun() override;
virtual void BeginOfRunAction(const G4Run* aRun) override;
virtual void EndOfRunAction(const G4Run* aRun) override;
virtual void SetMaster(G4bool val = true) override;
public:
G4MultiRunAction() = default;
virtual ~G4MultiRunAction() = default;
virtual G4Run* GenerateRun() override;
virtual void BeginOfRunAction(const G4Run* aRun) override;
virtual void EndOfRunAction(const G4Run* aRun) override;
virtual void SetMaster(G4bool val = true) override;
};
#endif /* SOURCE_RUN_INCLUDE_G4MULTIRUNACTION_HH_ */
#endif
+40 -45
View File
@@ -22,60 +22,55 @@
// * use in resulting scientific publications, and indicate your *
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
////
//---------------------------------------------------------------
//
// G4BuilderInterface.hh
// G4BuilderInterface
//
// Class Description:
// Provides the common interface to all types of builders.
//
// Creation date: 09.04.2016 adotti
// Modifications:
//
//---------------------------------------------------------------
#ifndef G4BUILDERINTERFACE_HH
#define G4BUILDERINTERFACE_HH
// Provides the common interface to all types of builders.
// Author: A.Dotti, 9 April 2016
// --------------------------------------------------------------------
#ifndef G4PhysicsBuilderInterface_hh
#define G4PhysicsBuilderInterface_hh 1
#include "globals.hh"
class G4PhysicsBuilderInterface
{
public:
G4PhysicsBuilderInterface() = default;
virtual ~G4PhysicsBuilderInterface() {}
virtual void Build()
{
G4Exception("G4PhysicsBuilderInterface::Build", "PHYSBLD001",
FatalException,
"Called based class method. Should be implemented in"
" inherited class");
;
}
virtual void RegisterMe(G4PhysicsBuilderInterface*)
{
G4Exception("G4PhysicsBuilderInterface::RegisterMe", "PHYSBLD001",
FatalException,
"Called based class method. Should be implemented in"
" inherited class, or wrong type of parameter passed.");
;
}
virtual void SetMinEnergy(G4double)
{
G4Exception("G4PhysicsBuilderInterface::SetMinEnergy", "PHYSBLD001",
FatalException,
"Called based class method. Should be implemented in"
" inherited class");
;
}
virtual void SetMaxEnergy(G4double)
{
G4Exception("G4PhysicsBuilderInterface::SetMaxEnergy", "PHYSBLD001",
FatalException,
"Called based class method. Should be implemented in"
" inherited class");
;
}
public:
G4PhysicsBuilderInterface() = default;
virtual ~G4PhysicsBuilderInterface() {}
virtual void Build()
{
G4Exception("G4PhysicsBuilderInterface::Build", "PHYSBLD001",
FatalException,
"Called based class method. Should be implemented in"
" inherited class");
}
virtual void RegisterMe(G4PhysicsBuilderInterface*)
{
G4Exception("G4PhysicsBuilderInterface::RegisterMe", "PHYSBLD001",
FatalException,
"Called based class method. Should be implemented in"
" inherited class, or wrong type of parameter passed.");
}
virtual void SetMinEnergy(G4double)
{
G4Exception("G4PhysicsBuilderInterface::SetMinEnergy", "PHYSBLD001",
FatalException,
"Called based class method. Should be implemented in"
" inherited class");
}
virtual void SetMaxEnergy(G4double)
{
G4Exception("G4PhysicsBuilderInterface::SetMaxEnergy", "PHYSBLD001",
FatalException,
"Called based class method. Should be implemented in"
" inherited class");
}
};
#endif
+63 -68
View File
@@ -23,23 +23,22 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4PhysicsListHelper
//
// ------------------------------------------------------------
// GEANT 4 class header file
// Class Description:
// This class is a helper class for physics lists to register processes
// according to the ordering parameter table
// This class is a singleton
// -------------------------------------------
// History
// first version 29 Apr. 2011 by H.Kurashige
// ------------------------------------------------------------
// Class description:
//
// Helper class for physics lists, to register processes according
// to the ordering parameter table. This class is a singleton.
// Author: H.Kurashige, 29 April 2011
// --------------------------------------------------------------------
#ifndef G4PhysicsListHelper_hh
#define G4PhysicsListHelper_hh 1
#include <vector>
#ifndef G4PhysicsListHelper_h
#define G4PhysicsListHelper_h 1
#include "G4ios.hh"
#include "globals.hh"
#include <vector>
#include "G4ParticleDefinition.hh"
#include "G4ParticleTable.hh"
@@ -52,77 +51,73 @@ class G4PhysicsListHelper
{
friend class G4ThreadLocalSingleton<G4PhysicsListHelper>;
private:
// Hide constructor and destructor
G4PhysicsListHelper();
~G4PhysicsListHelper();
public:
public: // with description
// This method gives the ponter to the physics list helper
static G4PhysicsListHelper* GetPhysicsListHelper();
static G4PhysicsListHelper* GetPhysicsListHelper();
// Returns the pointer to the physics list helper
// Register a process to the particle type
// according to the ordering parameter table
// 'true' is returned if the process is registerd successfully
G4bool RegisterProcess(G4VProcess* process, G4ParticleDefinition* particle);
G4bool RegisterProcess(G4VProcess* process, G4ParticleDefinition* particle);
// Registers a process to the particle type according to the ordering
// parameter table. Returns 'true' if process is successfully registered.
// User must invoke this method in his ConstructProcess()
// implementation in order to insures particle transportation.
void AddTransportation();
void AddTransportation();
// User must invoke this method in his ConstructProcess() implementation
// in order to enable particle transportation.
// Set flag for using CoupledTransportation
void UseCoupledTransportation(G4bool vl = true);
void UseCoupledTransportation(G4bool vl = true);
// Set flag for using G4CoupledTransportation.
// Change the thresholds for killing looping tracks of the
// transportation (simple or coupled.)
void UseHighLooperThresholds() { theLooperThresholds = 2; }
void UseLowLooperThresholds() { theLooperThresholds = 0; }
void UseHighLooperThresholds() { theLooperThresholds = 2; }
void UseLowLooperThresholds() { theLooperThresholds = 0; }
// Change the thresholds for killing looping tracks in transportation.
/////////////////////////////////////////////////////////////////
public:
// check consistencies of list of particles
void CheckParticleList() const;
void CheckParticleList() const;
// Check consistencies of list of particles.
///////////////////////////////////////////////////////////////////////
public:
// Dump OrdingParameterTable
void DumpOrdingParameterTable(G4int subType = -1) const;
G4PhysicsListOrderingParameter GetOrdingParameter(G4int subType) const;
void DumpOrdingParameterTable(G4int subType = -1) const;
// Dump OrdingParameterTable.
private:
void ReadOrdingParameterTable();
void ReadInDefaultOrderingParameter();
G4PhysicsListOrderingParameter GetOrdingParameter(G4int subType) const;
///////////////////////////////////////////////////////////////////////
public: // with description
void SetVerboseLevel(G4int value);
G4int GetVerboseLevel() const;
// set/get controle flag for output message
// 0: Silent
// 1: Warning message
// 2: More
void SetVerboseLevel(G4int value);
G4int GetVerboseLevel() const;
// set/get controle flag for output message
// 0: Silent
// 1: Warning message
// 2: More
////////////////////////////////////////////////////////////////////////
private:
static G4ThreadLocal G4PhysicsListHelper* pPLHelper;
private:
// the particle table has the complete List of existing particle types
G4ParticleTable* theParticleTable;
G4ParticleTable::G4PTblDicIterator* aParticleIterator;
G4PhysicsListHelper();
~G4PhysicsListHelper();
// Hidden constructor and destructor.
G4bool useCoupledTransportation;
G4int theLooperThresholds = 1; // 0 = Low, 1 = default, 2 = high
G4VProcess* theTransportationProcess;
void ReadOrdingParameterTable();
void ReadInDefaultOrderingParameter();
G4int verboseLevel;
private:
private:
typedef std::vector<G4PhysicsListOrderingParameter> G4OrdParamTable;
G4OrdParamTable* theTable;
G4int sizeOfTable;
G4String ordParamFileName;
using G4OrdParamTable = std::vector<G4PhysicsListOrderingParameter>;
static G4ThreadLocal G4PhysicsListHelper* pPLHelper;
G4ParticleTable* theParticleTable = nullptr;
G4ParticleTable::G4PTblDicIterator* aParticleIterator = nullptr;
// The particle table has the complete List of existing particle types.
G4bool useCoupledTransportation = false;
G4int theLooperThresholds = 1; // 0 = Low, 1 = default, 2 = high
G4VProcess* theTransportationProcess = nullptr;
G4int verboseLevel = 1;
G4OrdParamTable* theTable = nullptr;
G4int sizeOfTable = 0;
G4String ordParamFileName = "";
};
// Inline methods implementations
inline void G4PhysicsListHelper::UseCoupledTransportation(G4bool vl)
{
useCoupledTransportation = vl;
@@ -23,18 +23,17 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4PhysicsListOrderingParameter
//
// Class description:
//
// ------------------------------------------------------------
// GEANT 4 class header file
// Class Description:
// This class is a ordering parameter only used by G4PhysicsListHelper
// -------------------------------------------
// History
// first version 29 Apr. 2011 by H.Kurashige
// ------------------------------------------------------------
// This class defins a parameter ordering used by G4PhysicsListHelper.
// Author: H.Kurashige, 29 April 2011
// --------------------------------------------------------------------
#ifndef G4PhysicsListOrderingParameter_hh
#define G4PhysicsListOrderingParameter_hh 1
#ifndef G4PhysicsListOrderingParameter_h
#define G4PhysicsListOrderingParameter_h 1
#include "G4ios.hh"
#include "globals.hh"
@@ -43,31 +42,27 @@ class G4PhysicsListOrderingParameter
{
friend class G4PhysicsListHelper;
public:
// Hide constructor and destructor
G4PhysicsListOrderingParameter();
virtual ~G4PhysicsListOrderingParameter();
public:
G4String GetTypeName() const { return processTypeName; }
G4int GetType() const { return processType; }
G4int GetSubType() const { return processSubType; }
G4int GetOrdering(int idx) const;
G4bool GetDuplicable() const { return isDuplicable; }
G4PhysicsListOrderingParameter();
virtual ~G4PhysicsListOrderingParameter();
private:
G4String processTypeName;
G4int processType;
G4int processSubType;
G4int ordering[3];
G4bool isDuplicable;
inline const G4String& GetTypeName() const { return processTypeName; }
inline G4int GetType() const { return processType; }
inline G4int GetSubType() const { return processSubType; }
inline G4int GetOrdering(G4int idx) const
{
return ((idx < -1) || (idx > 2)) ? -1 : ordering[idx];
}
inline G4bool GetDuplicable() const { return isDuplicable; }
private:
G4String processTypeName = "NONE";
G4int processType = -1;
G4int processSubType = -1;
G4int ordering[3];
G4bool isDuplicable = false;
};
inline G4int G4PhysicsListOrderingParameter::GetOrdering(int idx) const
{
if((idx < -1) || (idx > 2))
return -1;
else
return ordering[idx];
}
#endif
+45 -47
View File
@@ -23,29 +23,24 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// Description:
// Manage the per-thread state of solids - those which
// have a per-thread state and dependent classes (if any)
// In particular it
// - owns the arrays that implement 'split' classes
// - classes/objects which are owned by the split classes.
// Background: the classes/objects affected are
// - 'split' classes part of its state is per-thread,
// - per-thread objects, in particular those which are owned
// by the split classes.
// Goal: Take ownership and control of per-thread state of
// classes to work with multi-threading.
// Offshoot of G4GeometryWorkspace, to deal with PhysicsList.
// G4PhysicsListWorkspace
//
// Designed / created by John Apostolakis
// Interface design - review with Andrea Dotti.
// Class description:
//
// First version: 4th Oct 2013
// Created due to dependency issue with G4GeometryWorkspace
// Working version:
// Manage the per-thread state of lists - those which have a per-thread
// state and dependent classes (if any). In particular it
// - owns the arrays that implement 'split' classes
// - classes/objects which are owned by the split classes.
// The classes/objects affected are:
// - 'split' classes part of its state is per-thread,
// - per-thread objects, in particular those owned by the split classes.
// Goal: take ownership and control of per-thread state of classes
// to work with multi-threading.
#ifndef G4PHYSICSLISTWORKSPACE_HH
#define G4PHYSICSLISTWORKSPACE_HH
// Authors: J.Apostolakis, A.Dotti - 4 October 2013
// --------------------------------------------------------------------
#ifndef G4PhysicsListWorkspace_hh
#define G4PhysicsListWorkspace_hh 1
#include "G4TWorkspacePool.hh"
#include "G4VModularPhysicsList.hh"
@@ -54,40 +49,43 @@
class G4PhysicsListWorkspace
{
public:
typedef G4TWorkspacePool<G4PhysicsListWorkspace> pool_type;
G4PhysicsListWorkspace(G4bool verbose = false);
~G4PhysicsListWorkspace();
public:
void UseWorkspace(); // Take ownership
void ReleaseWorkspace(); // Release ownership
void DestroyWorkspace(); // Release ownership and destroy
using pool_type = G4TWorkspacePool<G4PhysicsListWorkspace>;
void InitialiseWorkspace();
// To be called at start of each run (especially 2nd and further runs)
G4PhysicsListWorkspace(G4bool verbose = false);
~G4PhysicsListWorkspace();
void SetVerbose(G4bool v) { fVerbose = v; }
G4bool GetVerbose() { return fVerbose; }
void UseWorkspace(); // Take ownership
void ReleaseWorkspace(); // Release ownership
void DestroyWorkspace(); // Release ownership and destroy
static pool_type* GetPool();
void InitialiseWorkspace();
// To be called at start of each run (especially 2nd and further runs)
protected: // Implementation methods
void InitialisePhysicsList();
inline void SetVerbose(G4bool v) { fVerbose = v; }
inline G4bool GetVerbose() { return fVerbose; }
private: // Helper pointers - can be per instance or shared
G4VUPLManager* fpVUPLSIM;
G4VPCManager* fpVPCSIM;
G4VMPLManager* fpVMPLSIM;
static pool_type* GetPool();
// Per Instance variables
// NOTE: the ownership of the Data Arrays is IN this object
private:
// Store SubInstanceManager object pointers (SIM pointers)
G4VUPLData* fpVUPLOffset;
G4VPCData* fpVPCOffset;
G4VMPLData* fpVMPLOffset;
protected: // Implementation methods
G4bool fVerbose;
void InitialisePhysicsList();
private: // Helper pointers - can be per instance or shared
G4VUPLManager* fpVUPLSIM = nullptr;
G4VPCManager* fpVPCSIM = nullptr;
G4VMPLManager* fpVMPLSIM = nullptr;
// Store SubInstanceManager object pointers (SIM pointers)
G4VUPLData* fpVUPLOffset = nullptr;
G4VPCData* fpVPCOffset = nullptr;
G4VMPLData* fpVMPLOffset = nullptr;
// Per Instance variables
// The ownership of the Data Arrays is IN this object
G4bool fVerbose = false;
};
#endif // G4PARTICLESWORKSPACE_HH
#endif
+81 -78
View File
@@ -23,113 +23,116 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4TemplateRNGHelper
//
// Class description:
//
// Helper class for RNG Engine seeds.
// Used in MT builds to guarantee reproducibility.
// The function of this class is to return a RNG Engine seed
// given its index. It is a simple templated container that
// Allows to add seeds (AddOneSeed) and retrieve a seed (GetSeed)
// by index.
// Used in MT builds to guarantee event reproducibility.
// The function of this class is to return a RNG Engine seed given its index.
// It is a simple templated container that allows to add seeds (AddOneSeed)
// and retrieve a seed (GetSeed) by index.
//
// The normal use is with G4RNGHelper where each element of th econtainer
// The normal use is with G4RNGHelper where each element of the container
// represents a seed. To enforce strong-reproducibility the variant with
// the RNG Engine status file names is avilable
// the RNG Engine status file names is available.
#ifndef G4RNGHELPER_HH
#define G4RNGHELPER_HH
// Author: A.Dotti (SLAC), 5 July 2013
// --------------------------------------------------------------------
#ifndef G4TemplateRNGHelper_hh
#define G4TemplateRNGHelper_hh 1
#include "globals.hh"
#include <queue>
#include <vector>
#include "globals.hh"
template <class T>
class G4TemplateRNGHelper
{
public:
// The container is modeled as a (shared) singleton
static G4TemplateRNGHelper<T>* GetInstance();
static G4TemplateRNGHelper<T>* GetInstanceIfExist();
typedef std::vector<T> SeedsQueue;
typedef typename SeedsQueue::size_type SeedsQueueSize_type;
public:
virtual ~G4TemplateRNGHelper();
// The container is modeled as a (shared) singleton
static G4TemplateRNGHelper<T>* GetInstance();
static G4TemplateRNGHelper<T>* GetInstanceIfExist();
using SeedsQueue = std::vector<T>;
using SeedsQueueSize_type = typename SeedsQueue::size_type;
// Returns seed given id
virtual const T GetSeed(const G4int& sdId)
{
G4int seedId = sdId - 2 * offset;
if(seedId < static_cast<G4int>(seeds.size()))
virtual ~G4TemplateRNGHelper();
// Returns seed given id
virtual const T GetSeed(const G4int& sdId)
{
T& seed = seeds[seedId];
return seed;
G4int seedId = sdId - 2 * offset;
if(seedId < static_cast<G4int>(seeds.size()))
{
T& seed = seeds[seedId];
return seed;
}
G4ExceptionDescription msg;
msg << "No seed number " << seedId << "(" << seeds.size() << " available)\n"
<< " Original seed number " << sdId << " filled so far " << offset;
G4Exception("G4RNGHelper::GetSeed", "Run0115", FatalException, msg);
return T();
}
G4ExceptionDescription msg;
msg << "No seed number " << seedId << "(" << seeds.size() << " available)\n"
<< " Original seed number " << sdId << " filled so far " << offset;
G4Exception("G4RNGHelper::GetSeed", "Run0115", FatalException, msg);
return T();
}
// Adds one seed to the collection
void AddOneSeed(const T& seed) { seeds.push_back(seed); }
// Adds one seed to the collection
void AddOneSeed(const T& seed) { seeds.push_back(seed); }
// Fills N primary seed pairs
void Fill(G4double* dbl, G4int nev, G4int nev_tot, G4int nrpe)
{
seeds.clear();
for(G4int i = 0; i < nrpe * nev; i++)
// Fills N primary seed pairs
void Fill(G4double* dbl, G4int nev, G4int nev_tot, G4int nrpe)
{
seeds.push_back((G4long)(100000000L * dbl[i]));
seeds.clear();
for(G4int i = 0; i < nrpe * nev; ++i)
{
seeds.push_back((G4long)(100000000L * dbl[i]));
}
offset = 0;
nev_filled = nev;
nev_total = nev_tot;
nRandParEvent = nrpe;
}
offset = 0;
nev_filled = nev;
nev_total = nev_tot;
nRandParEvent = nrpe;
}
void Refill(G4double* dbl, G4int nev)
{
if(nev == 0)
return;
seeds.clear();
for(G4int i = 0; i < nRandParEvent * nev; i++)
void Refill(G4double* dbl, G4int nev)
{
seeds.push_back((G4long)(100000000L * dbl[i]));
if(nev == 0)
return;
seeds.clear();
for(G4int i = 0; i < nRandParEvent * nev; ++i)
{
seeds.push_back((G4long)(100000000L * dbl[i]));
}
offset += nev_filled;
nev_filled = nev;
}
offset += nev_filled;
nev_filled = nev;
}
// Number of available seeds
const SeedsQueueSize_type GetNumberSeeds() const { return seeds.size(); }
// Number of available seeds
const SeedsQueueSize_type GetNumberSeeds() const { return seeds.size(); }
// Empty the seeds container
virtual void Clear() { seeds.clear(); }
// Empty the seeds container
virtual void Clear() { seeds.clear(); }
protected:
SeedsQueue seeds;
// Note: following numbers are number of events.
// seeds are generated for nRandParEvent times n_event
G4int offset;
G4int nev_filled;
G4int nev_total;
G4int nRandParEvent;
protected:
private:
G4TemplateRNGHelper()
{
offset = 0;
nev_filled = 0;
nev_total = 0;
nRandParEvent = 0;
}
SeedsQueue seeds;
// Note: following numbers are number of events.
// seeds are generated for nRandParEvent times n_event
G4int offset = 0;
G4int nev_filled = 0;
G4int nev_total = 0;
G4int nRandParEvent = 0;
private:
static G4TemplateRNGHelper<T>* instance;
private:
G4TemplateRNGHelper() {}
private:
static G4TemplateRNGHelper<T>* instance;
};
typedef G4TemplateRNGHelper<G4long> G4RNGHelper;
typedef G4TemplateRNGHelper<G4String> G4StringRNGHelper;
typedef std::queue<G4long> G4SeedsQueue;
using G4RNGHelper = G4TemplateRNGHelper<G4long>;
using G4StringRNGHelper = G4TemplateRNGHelper<G4String>;
using G4SeedsQueue = std::queue<G4long>;
#endif
+75 -79
View File
@@ -23,104 +23,100 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4Run
//
// Class description:
//
// This class represents a run. An object of this class is constructed
// and deleted by G4RunManager. Basically the user should use only the
// accessors (get methods). All properties are set by G4RunManager.
#ifndef G4Run_h
#define G4Run_h 1
// Author: M.Asai, 1996
// --------------------------------------------------------------------
#ifndef G4Run_hh
#define G4Run_hh 1
#include <vector>
#include "globals.hh"
#include "G4Profiler.hh"
#include <vector>
class G4Event;
class G4HCtable;
class G4DCtable;
// class description:
//
// This class represents a run. An object of this class is constructed
// and deleted by G4RunManager. Basically the user should use only the
// get methods. All properties are set by G4RunManager.
//
class G4Run
{
public:
using ProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>;
public:
public:
G4Run();
virtual ~G4Run();
using ProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>;
private:
// These copy constructor and = operator must not be used.
G4Run(const G4Run&) { ; }
G4Run& operator=(const G4Run&) { return *this; }
G4Run();
virtual ~G4Run();
protected:
G4int runID;
G4int numberOfEvent;
G4int numberOfEventToBeProcessed;
G4HCtable* HCtable;
G4DCtable* DCtable;
G4String randomNumberStatus;
std::vector<const G4Event*>* eventVector;
G4Run(const G4Run&) = delete;
G4Run& operator=(const G4Run&) = delete;
// Forbidden copy constructor and assignment operator.
public: // with description
virtual void RecordEvent(const G4Event*);
// Method to be overwritten by the user for recording events in this run.
// In such a case, it is the user's responsibility to increment
// numberOfEvent. Also, user's run class object must be instantiated in
// user's runAction.
virtual void Merge(const G4Run*);
// Method to be overwritten by the user for merging local G4Run object to
// the global G4Run object.
virtual void RecordEvent(const G4Event*);
// Method to be overwritten by the user for recording events in this run.
// In such a case, it is the user's responsibility to increment
// numberOfEvent. Also, user's run class object must be instantiated in
// user's runAction.
virtual void Merge(const G4Run*);
// Method to be overwritten by the user for merging local G4Run object
// to the global G4Run object.
void StoreEvent(G4Event* evt);
// Store a G4Event object until this run object is deleted.
// Given the potential large memory size of G4Event and its data-member
// objects stored in G4Event, the user must be careful and responsible
// for not storing too many G4Event objects. This method is invoked by
// G4RunManager if the user invokes G4EventManager::KeepTheCurrentEvent()
// or "/event/keepCurrentEvent" UI command while the particular event is
// in being processed (typically in EndOfEventAction).
public: // with description
inline G4int GetRunID() const { return runID; }
// Returns the run ID. Run ID is set by G4RunManager.
inline G4int GetNumberOfEvent() const { return numberOfEvent; }
// Returns number of events processed in this run. The number is
// incremented at the end of each event processing.
inline G4int GetNumberOfEventToBeProcessed() const
{
return numberOfEventToBeProcessed;
}
inline const G4HCtable* GetHCtable() const { return HCtable; }
// List of names of hits collection
inline const G4DCtable* GetDCtable() const { return DCtable; }
// List of names of digi collection
inline const G4String& GetRandomNumberStatus() const
{
return randomNumberStatus;
}
// Return random number status at the beginning of this run
public:
inline void SetRunID(G4int id) { runID = id; }
inline void SetNumberOfEventToBeProcessed(G4int n_ev)
{
numberOfEventToBeProcessed = n_ev;
}
inline void SetHCtable(G4HCtable* HCtbl) { HCtable = HCtbl; }
inline void SetDCtable(G4DCtable* DCtbl) { DCtable = DCtbl; }
inline void SetRandomNumberStatus(G4String& st) { randomNumberStatus = st; }
inline G4int GetRunID() const { return runID; }
// Returns the run ID. Run ID is set by G4RunManager.
inline G4int GetNumberOfEvent() const { return numberOfEvent; }
// Returns number of events processed in this run. The number is
// incremented at the end of each event processing.
inline G4int GetNumberOfEventToBeProcessed() const
{
return numberOfEventToBeProcessed;
}
inline const G4HCtable* GetHCtable() const { return HCtable; }
// List of names of hits collection.
inline const G4DCtable* GetDCtable() const { return DCtable; }
// List of names of digi collection.
inline const G4String& GetRandomNumberStatus() const
{
return randomNumberStatus;
}
// Returns random number status at the beginning of this run.
inline const std::vector<const G4Event*>* GetEventVector() const
{
return eventVector;
}
// Returns the event vector.
public: // with description
void StoreEvent(G4Event* evt);
// Store a G4Event object until this run object is deleted.
// Given the potential large memory size of G4Event and its datamember
// objects stored in G4Event, the user must be careful and responsible for
// not to store too many G4Event objects. This method is invoked by
// G4RunManager if the user invokes G4EventManager::KeepTheCurrentEvent() or
// /event/keepCurrentEvent UI command while the particular event is in process
// (typically in EndOfEventAction).
inline const std::vector<const G4Event*>* GetEventVector() const
{
return eventVector;
}
// Return the event vector
inline void SetRunID(G4int id) { runID = id; }
inline void SetNumberOfEventToBeProcessed(G4int n_ev)
{
numberOfEventToBeProcessed = n_ev;
}
inline void SetHCtable(G4HCtable* HCtbl) { HCtable = HCtbl; }
inline void SetDCtable(G4DCtable* DCtbl) { DCtable = DCtbl; }
inline void SetRandomNumberStatus(G4String& st) { randomNumberStatus = st; }
protected:
G4int runID = 0;
G4int numberOfEvent = 0;
G4int numberOfEventToBeProcessed = 0;
G4HCtable* HCtable = nullptr;
G4DCtable* DCtable = nullptr;
G4String randomNumberStatus = "";
std::vector<const G4Event*>* eventVector = nullptr;
};
#endif
File diff suppressed because it is too large Load Diff
+166 -176
View File
@@ -23,37 +23,37 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4RunManagerKernel
//
// Class description:
//
// This is a class for mandatory control of the Geant4 kernel.
//
// This class is constructed by G4RunManager. If a user adopts his/her own
// class instead of G4RunManager, this class must be instantiated by at the
// very beginning of the application and must be deleted at the very end.
// In addition, the following methods must be invoked in the proper order:
// DefineWorldVolume()
// InitializePhysics()
// RunInitialization()
// RunTermination()
//
// User must provide his/her own classes derived from the following abstract
// class and register it to G4RunManagerKernel:
// G4VUserPhysicsList - Particle types, Processes and Cuts
//
// G4RunManagerKernel does not have any event loop. Handling of events
// is managed by G4RunManager.
// class description:
//
// This is a class for mandatory control of GEANT4 kernel.
//
// This class is constructed by G4RunManager. If a user uses his/her own
// class instead of G4RunManager, this class must be instantiated by
// him/herself at the very beginning of the application and must be deleted
// at the very end of the application. Also, following methods must be
// invoked in the proper order.
// DefineWorldVolume
// InitializePhysics
// RunInitialization
// RunTermination
//
// User must provide his/her own classes derived from the following
// abstract class and register it to the RunManagerKernel.
// G4VUserPhysicsList - Particle types, Processes and Cuts
//
// G4RunManagerKernel does not have any eveny loop. Handling of events
// is managed by G4RunManager.
//
// Author: M.Asai, 1 August 2003
// --------------------------------------------------------------------
#ifndef G4RunManagerKernel_hh
#define G4RunManagerKernel_hh 1
#ifndef G4RunManagerKernel_h
#define G4RunManagerKernel_h 1
#include "globals.hh"
#include "G4EventManager.hh"
class G4VUserPhysicsList;
class G4VPhysicalVolume;
class G4Region;
class G4ExceptionHandler;
@@ -61,185 +61,175 @@ class G4StackManager;
class G4TrackingManager;
class G4PrimaryTransformer;
#include "G4EventManager.hh"
#include "globals.hh"
class G4RunManagerKernel
{
public: // with description
static G4RunManagerKernel* GetRunManagerKernel();
// Static method which returns the singleton pointer of G4RunManagerKernel or
// its derived class.
public:
private:
static G4ThreadLocal G4RunManagerKernel* fRunManagerKernel;
static G4RunManagerKernel* GetRunManagerKernel();
// Static method returning the singleton pointer of
// G4RunManagerKernel or its derived class.
public: // with description
G4RunManagerKernel();
virtual ~G4RunManagerKernel();
// The constructor and the destructor. The user must construct this class
// object at the beginning of his/her main() and must delete it at the
// bottom of the main(), unless he/she used G4RunManager.
public:
enum RMKType
{
sequentialRMK,
masterRMK,
workerRMK
};
G4RunManagerKernel();
virtual ~G4RunManagerKernel();
// The constructor and the destructor. The user must construct this class
// object at the beginning of his/her main() and must delete it at the
// bottom of the main(), unless he/she used G4RunManager.
protected:
// Constructor to be used by derived classes
G4RunManagerKernel(RMKType rmkType);
RMKType runManagerKernelType;
void DefineWorldVolume(G4VPhysicalVolume* worldVol,
G4bool topologyIsChanged = true);
public: // with description
void DefineWorldVolume(G4VPhysicalVolume* worldVol,
G4bool topologyIsChanged = true);
void WorkerDefineWorldVolume(G4VPhysicalVolume* worldVol,
G4bool topologyIsChanged = true);
// This method must be invoked if the geometry setup has been changed
// between runs. The flag "topologyIsChanged" will specify if the
// geometry topology is different from the original one used in the
// previous run; if not, it must be set to false, so that the original
// optimisation and navigation history is preserved. This method is
// invoked also at initialisation.
void WorkerDefineWorldVolume(G4VPhysicalVolume* worldVol,
G4bool topologyIsChanged = true);
void SetPhysics(G4VUserPhysicsList* uPhys);
// This method must be invoked at least once with a valid concrete
// implementation of user physics list.
// This method must be invoked if the geometry setup has been changed between
// runs. The flag 'topologyIsChanged' will specify if the geometry topology is
// different from the original one used in the previous run; if not, it must
// be set to false, so that the original optimisation and navigation history
// is preserved. This method is invoked also at initialisation.
void InitializePhysics();
// This method must be invoked at least once to build physics processes.
void SetPhysics(G4VUserPhysicsList* uPhys);
// This method must be invoked at least once by the user with a valid
// concrete implementation of user physics list.
G4bool RunInitialization(G4bool fakeRun = false);
// Trigger geometry closing and physics table constructions.
// It returns TRUE if all procedures went well.
void InitializePhysics();
// This method must be invoked at least once by the user to build physics
// processes.
void RunTermination();
// Set the application state to 'Idle' so that the user can modify
// physics/geometry.
G4bool RunInitialization(G4bool fakeRun = false);
// Trigger geometry closing and physics table constructions.
// It returns TRUE if all procedures went well.
void UpdateRegion();
// Update region list. This method is mandatory before invoking the
// following two dump methods.
// At RunInitialization(), this method is automatically invoked.
void RunTermination();
// Set the application state to G4State_Idle so that the user can modify
// physics/geometry.
void DumpRegion(const G4String& rname) const;
// Dump information of a region.
public:
void WorkerUpdateWorldVolume();
void DumpRegion(G4Region* region = nullptr) const;
// Dump information of a region.
// If the pointer is NULL, all regions are shown.
protected:
void SetupDefaultRegion();
// Called by DefineWorldVolume
void SetupPhysics();
void ResetNavigator();
void BuildPhysicsTables(G4bool fakeRun);
void CheckRegions();
void WorkerUpdateWorldVolume();
public: // with description
void UpdateRegion();
// Update region list.
// This method is mandatory before invoking following two dump methods.
// At RunInitialization(), this method is automatically invoked, and thus
// the user needs not invoke.
inline void GeometryHasBeenModified() { geometryNeedsToBeClosed = true; }
// This method must be invoked (or equivalent UI commands can be used)
// in case the user changes his/her detector geometry.
// This method is automatically invoked from DefineWorldVolume().
void DumpRegion(const G4String& rname) const;
// Dump information of a region.
inline void PhysicsHasBeenModified() { physicsNeedsToBeReBuilt = true; }
// This method must be invoked in case the user changes his/her physics
// process(es), e.g. (in)activate some processes. Once this method is
// invoked, regardless of cuts changed or not, BuildPhysicsTable() of
// a PhysicsList is invoked for refreshing all physics tables.
void DumpRegion(G4Region* region = 0) const;
// Dump information of a region.
// If the pointer is NULL, all regions are shown.
private:
G4VUserPhysicsList* physicsList;
G4VPhysicalVolume* currentWorld;
G4bool geometryInitialized;
G4bool physicsInitialized;
G4bool geometryToBeOptimized;
G4bool physicsNeedsToBeReBuilt;
G4int verboseLevel;
G4int numberOfParallelWorld;
G4EventManager* eventManager;
G4ExceptionHandler* defaultExceptionHandler;
G4String versionString;
protected:
G4Region* defaultRegion;
G4Region* defaultRegionForParallelWorld;
G4bool geometryNeedsToBeClosed;
public: // with description
inline void GeometryHasBeenModified() { geometryNeedsToBeClosed = true; }
// This method must be invoked (or equivalent UI commands can be used)
// in case the user changes his/her detector geometry.
// This method is automatically invoked from DefineWorldVolume() method.
inline void PhysicsHasBeenModified() { physicsNeedsToBeReBuilt = true; }
// This method must be invoked in case the user changes his/her physics
// process(es), e.g. (in)activate some processes. Once this method is
// invoked, regardless of cuts are changed or not, BuildPhysicsTable()
// of PhysicsList is invoked for refreshing all physics tables.
public:
inline G4EventManager* GetEventManager() const { return eventManager; }
inline G4StackManager* GetStackManager() const
{
return eventManager->GetStackManager();
}
inline G4TrackingManager* GetTrackingManager() const
{
return eventManager->GetTrackingManager();
}
inline void SetPrimaryTransformer(G4PrimaryTransformer* pt)
{
eventManager->SetPrimaryTransformer(pt);
}
inline G4PrimaryTransformer* GetPrimaryTransformer() const
{
return eventManager->GetPrimaryTransformer();
}
inline const G4String& GetVersionString() const { return versionString; }
inline void SetVerboseLevel(G4int vl) { verboseLevel = vl; }
inline void SetGeometryToBeOptimized(G4bool vl)
{
if(geometryToBeOptimized != vl)
inline G4EventManager* GetEventManager() const { return eventManager; }
inline G4StackManager* GetStackManager() const
{
geometryToBeOptimized = vl;
geometryNeedsToBeClosed = true;
return eventManager->GetStackManager();
}
inline G4TrackingManager* GetTrackingManager() const
{
return eventManager->GetTrackingManager();
}
inline void SetPrimaryTransformer(G4PrimaryTransformer* pt)
{
eventManager->SetPrimaryTransformer(pt);
}
inline G4PrimaryTransformer* GetPrimaryTransformer() const
{
return eventManager->GetPrimaryTransformer();
}
}
inline G4int GetNumberOfParallelWorld() const
{
return numberOfParallelWorld;
}
inline void SetNumberOfParallelWorld(G4int i) { numberOfParallelWorld = i; }
inline const G4String& GetVersionString() const { return versionString; }
inline G4VUserPhysicsList* GetPhysicsList() const { return physicsList; }
inline void SetVerboseLevel(G4int vl) { verboseLevel = vl; }
inline G4VPhysicalVolume* GetCurrentWorld() const { return currentWorld; }
inline void SetGeometryToBeOptimized(G4bool vl)
{
if(geometryToBeOptimized != vl)
{
geometryToBeOptimized = vl;
geometryNeedsToBeClosed = true;
}
}
private:
void CheckRegularGeometry();
G4bool ConfirmCoupledTransportation();
void SetScoreSplitter();
inline G4int GetNumberOfParallelWorld() const
{
return numberOfParallelWorld;
}
inline void SetNumberOfParallelWorld(G4int i) { numberOfParallelWorld = i; }
G4int numberOfStaticAllocators;
inline G4VUserPhysicsList* GetPhysicsList() const { return physicsList; }
public:
inline G4int GetNumberOfStaticAllocators() const
{
return numberOfStaticAllocators;
}
inline G4VPhysicalVolume* GetCurrentWorld() const { return currentWorld; }
protected:
virtual void SetupShadowProcess() const;
// This method will setup the G4VProcesses
// instances to have a reference to the process instance
// created by the master thread. See G4VProcess::GetMasterProcess
inline G4int GetNumberOfStaticAllocators() const
{
return numberOfStaticAllocators;
}
void PropagateGenericIonID();
enum RMKType
{
sequentialRMK,
masterRMK,
workerRMK
};
protected:
G4RunManagerKernel(RMKType rmkType);
// Constructor to be used by derived classes.
void SetupDefaultRegion();
// Called by DefineWorldVolume().
void SetupPhysics();
void ResetNavigator();
void BuildPhysicsTables(G4bool fakeRun);
void CheckRegions();
virtual void SetupShadowProcess() const;
// This method will setup the G4VProcesses instances to have a reference
// to the process instance created by the master thread.
// See G4VProcess::GetMasterProcess().
void PropagateGenericIonID();
private:
void CheckRegularGeometry();
G4bool ConfirmCoupledTransportation();
void SetScoreSplitter();
protected:
RMKType runManagerKernelType;
G4Region* defaultRegion = nullptr;
G4Region* defaultRegionForParallelWorld = nullptr;
G4bool geometryNeedsToBeClosed = true;
private:
G4VUserPhysicsList* physicsList = nullptr;
G4VPhysicalVolume* currentWorld = nullptr;
G4bool geometryInitialized = false;
G4bool physicsInitialized = false;
G4bool geometryToBeOptimized = true;
G4bool physicsNeedsToBeReBuilt = true;
G4int verboseLevel = 0;
G4int numberOfParallelWorld = 0;
G4EventManager* eventManager = nullptr;
G4ExceptionHandler* defaultExceptionHandler = nullptr;
G4String versionString = "";
static G4ThreadLocal G4RunManagerKernel* fRunManagerKernel;
G4int numberOfStaticAllocators = 0;
};
#endif
+66 -68
View File
@@ -23,34 +23,35 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4RunMessenger
//
// Class description:
//
// This is a messenger class for G4RunManager.
// Implemented commands are following;
//
// GEANT 4 class header file
// beamOn * Start a Run.
// verbose * Set the Verbose level of G4RunManager.
// printProgress * Set the frequency of printing out progress of a run.
// dumpRegion * Dump information of a region.
// dumpCouples * Dump information of material-cuts-couples.
// optimizeGeometry * Set the optimization flag of closing geometry.
// breakAtBeginOfEvent * Set a break point at the beginning of every event.
// breakAtEndOfEvent * Set a break point at the end of every event.
// abort * Abort current run processing.
// Initialize * Initialise G4 kernel.
// geometryModified * Force geometry to be closed again.
// physicsModified * Force cross-section tables to be calculated again
// (and rebuilding physics table will be invoked).
// constructScoringWorlds * Construct scoring world(s) if defined.
// class description:
//
// This is a messenger class for G4RunManager.
// Implemented commands are following;
//
// Commands :
// beamOn * Start a Run.
// verbose * Set the Verbose level of G4RunManager.
// printProgress * Set the frequency of printing out the progress of a
// run. dumpRegion * Dump information of a region. dumpCouples *
// Dump information of material-cuts-couples. optimizeGeometry * Set the
// optimization flag of closing geometry. breakAtBeginOfEvent * Set a break
// point at the beginning of every event. breakAtEndOfEvent * Set a break
// point at the end of every event. abort * Abort current run
// processing. Initialize * Initialize G4 kernel. geometryModified *
// Force geometry to be closed again. physicsModified * Force
// cross-section tables to be calculated again.
// (and rebuilding physics table will be invoked)
// constructScoringWorlds * Construct scoring world(s) if defined
//
// Original author: M.Asai, 1997
// --------------------------------------------------------------------
#ifndef G4RunMessenger_hh
#define G4RunMessenger_hh 1
#ifndef G4RunMessenger_h
#define G4RunMessenger_h 1
#include "globals.hh"
#include "G4UImessenger.hh"
class G4RunManager;
class G4UIdirectory;
@@ -61,59 +62,56 @@ class G4UIcmdWithABool;
class G4UIcommand;
class G4MaterialScanner;
#include "G4UImessenger.hh"
#include "globals.hh"
class G4RunMessenger : public G4UImessenger
{
public:
G4RunMessenger(G4RunManager* runMgr);
~G4RunMessenger();
public:
public:
void SetNewValue(G4UIcommand* command, G4String newValues);
G4String GetCurrentValue(G4UIcommand* command);
G4RunMessenger(G4RunManager* runMgr);
~G4RunMessenger();
private:
G4RunManager* runManager;
G4String macroFileName; // internal use only!!!
void SetNewValue(G4UIcommand* command, G4String newValues);
G4String GetCurrentValue(G4UIcommand* command);
private: // commands
G4UIdirectory* runDirectory;
G4UIcommand* beamOnCmd;
G4UIcmdWithAnInteger* verboseCmd;
G4UIcmdWithAnInteger* printProgCmd;
G4UIcmdWithAnInteger* nThreadsCmd;
G4UIcmdWithoutParameter* maxThreadsCmd;
G4UIcmdWithAnInteger* pinAffinityCmd;
G4UIcommand* evModCmd;
G4UIcmdWithAString* dumpRegCmd;
G4UIcmdWithoutParameter* dumpCoupleCmd;
G4UIcmdWithABool* optCmd;
G4UIcmdWithABool* brkBoECmd;
G4UIcmdWithABool* brkEoECmd;
G4UIcmdWithABool* abortCmd;
G4UIcmdWithoutParameter* abortEventCmd;
G4UIcmdWithoutParameter* initCmd;
G4UIcmdWithoutParameter* geomCmd;
G4UIcmdWithABool* geomRebCmd;
G4UIcmdWithoutParameter* physCmd;
G4UIcmdWithAnInteger* randEvtCmd;
G4UIcommand* procUICmds;
private:
G4UIdirectory* randomDirectory;
G4UIcmdWithAString* seedCmd;
G4UIcmdWithAString* randDirCmd;
G4UIcmdWithABool* savingFlagCmd;
G4UIcmdWithoutParameter* saveThisRunCmd;
G4UIcmdWithoutParameter* saveThisEventCmd;
G4UIcmdWithAString* restoreRandCmd;
G4UIcmdWithABool* saveEachEventCmd;
G4UIcmdWithABool* restoreRandCmdMT;
G4RunManager* runManager = nullptr;
G4String macroFileName = "***NULL***"; // internal use only!!!
G4UIcmdWithoutParameter* constScoreCmd;
G4UIdirectory* runDirectory = nullptr;
G4UIcommand* beamOnCmd = nullptr;
G4UIcmdWithAnInteger* verboseCmd = nullptr;
G4UIcmdWithAnInteger* printProgCmd = nullptr;
G4UIcmdWithAnInteger* nThreadsCmd = nullptr;
G4UIcmdWithoutParameter* maxThreadsCmd = nullptr;
G4UIcmdWithAnInteger* pinAffinityCmd = nullptr;
G4UIcommand* evModCmd = nullptr;
G4UIcmdWithAString* dumpRegCmd = nullptr;
G4UIcmdWithoutParameter* dumpCoupleCmd = nullptr;
G4UIcmdWithABool* optCmd = nullptr;
G4UIcmdWithABool* brkBoECmd = nullptr;
G4UIcmdWithABool* brkEoECmd = nullptr;
G4UIcmdWithABool* abortCmd = nullptr;
G4UIcmdWithoutParameter* abortEventCmd = nullptr;
G4UIcmdWithoutParameter* initCmd = nullptr;
G4UIcmdWithoutParameter* geomCmd = nullptr;
G4UIcmdWithABool* geomRebCmd = nullptr;
G4UIcmdWithoutParameter* physCmd = nullptr;
G4UIcmdWithAnInteger* randEvtCmd = nullptr;
G4UIcommand* procUICmds = nullptr;
G4MaterialScanner* materialScanner;
G4UIdirectory* randomDirectory = nullptr;
G4UIcmdWithAString* seedCmd = nullptr;
G4UIcmdWithAString* randDirCmd = nullptr;
G4UIcmdWithABool* savingFlagCmd = nullptr;
G4UIcmdWithoutParameter* saveThisRunCmd = nullptr;
G4UIcmdWithoutParameter* saveThisEventCmd = nullptr;
G4UIcmdWithAString* restoreRandCmd = nullptr;
G4UIcmdWithABool* saveEachEventCmd = nullptr;
G4UIcmdWithABool* restoreRandCmdMT = nullptr;
G4UIcmdWithoutParameter* constScoreCmd = nullptr;
G4MaterialScanner* materialScanner = nullptr;
};
#endif
@@ -23,47 +23,35 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UserPhysicsListMessenger
//
// Class description:
//
//
//---------------------------------------------------------------
//
// G4UserPhysicsListMessenger.hh
//
// Class Description:
// This is a messenger class to interface to exchange information
// between ParticleUserList and UI.
// --
// the List of Directory and Commands
// -
// /run/particle/ Paricle control commands.
// Commands :
// SetCuts * Set default cut value
// dumpList * Dump List of particles in G4VUserPhysicsList.
// verbose * Set the Verbose level of G4VUserPhysicsList.
// addProcessManager * add process manager
// buildPhysicsTable * build physics table
// storePhysicsTable * store physics table into files
// retreivePhysicsTable * retreive physics table from files
// setStoredInAscii * Switch on/off ascii mode in store/retreive Physics
// Table
// ------------------------------------------------------------
// History
// first version 09 Jan. 1998 by H.Kurashige
// second version 24 Jan. 1998 by H.Kurashige
// add buildPhysicsTable command 13 Apr. 1999 by H.Kurashige
// add store/retreivePhysicsTable 08 Nov. 2000 by H.Kurashige
// add setStoredInAscii command 12 Mar. 2001 by H.Kurashige
// add applyCuts command 2 Aug. 2001 by H.Kurashige
// add dumpOrderingParam command 3 May. 2011 by H.Kurashige
// add getCutForAGivenParticle 11 June 2011 by H.Kurashige
// ------------------------------------------------------------
// This is a messenger class to allow exchange of information
// between ParticleUserList and UI.
//
// Directory and list of commands:
//
// /run/particle/ Particle control commands.
// Commands :
// SetCuts * Set default cut value
// dumpList * Dump List of particles in G4VUserPhysicsList.
// verbose * Set the Verbose level of G4VUserPhysicsList.
// addProcessManager * add process manager
// buildPhysicsTable * build physics table
// storePhysicsTable * store physics table into files
// retreivePhysicsTable * retrieve physics table from files
// setStoredInAscii * Switch on/off ascii mode in store/retrieve Physics Table
#ifndef G4UserPhysicsListMessenger_h
#define G4UserPhysicsListMessenger_h 1
// Original author: H.Kurashige, 9 January 1998
// --------------------------------------------------------------------
#ifndef G4UserPhysicsListMessenger_hh
#define G4UserPhysicsListMessenger_hh 1
#include "globals.hh"
#include "G4UImessenger.hh"
class G4VUserPhysicsList;
class G4VUserPhysicsList;
class G4UIdirectory;
class G4UIcmdWithoutParameter;
@@ -72,42 +60,40 @@ class G4UIcmdWithADoubleAndUnit;
class G4UIcmdWithAString;
class G4UIcommand;
#include "G4UImessenger.hh"
#include "globals.hh"
class G4UserPhysicsListMessenger : public G4UImessenger
{
private:
// hide default constructor
G4UserPhysicsListMessenger() {}
public:
public:
G4UserPhysicsListMessenger(G4VUserPhysicsList* pParticleList);
virtual ~G4UserPhysicsListMessenger();
G4UserPhysicsListMessenger(G4VUserPhysicsList* pParticleList);
virtual ~G4UserPhysicsListMessenger();
public: // with description
virtual void SetNewValue(G4UIcommand* command, G4String newValues);
virtual G4String GetCurrentValue(G4UIcommand* command);
virtual void SetNewValue(G4UIcommand* command, G4String newValues);
virtual G4String GetCurrentValue(G4UIcommand* command);
protected:
G4VUserPhysicsList* thePhysicsList;
protected:
private: // commands
G4UIdirectory* theDirectory;
G4UIcmdWithADoubleAndUnit* setCutCmd;
G4UIcommand* setCutRCmd;
G4UIcommand* setCutForAGivenParticleCmd;
G4UIcmdWithAString* getCutForAGivenParticleCmd;
G4UIcmdWithAnInteger* verboseCmd;
G4UIcmdWithoutParameter* dumpListCmd;
G4UIcmdWithAString* addProcManCmd;
G4UIcmdWithAString* buildPTCmd;
G4UIcmdWithAString* storeCmd;
G4UIcmdWithAString* retrieveCmd;
G4UIcmdWithAnInteger* asciiCmd;
G4UIcommand* applyCutsCmd;
G4UIcmdWithAString* dumpCutValuesCmd;
G4UIcmdWithAnInteger* dumpOrdParamCmd;
G4VUserPhysicsList* thePhysicsList = nullptr;
private:
G4UserPhysicsListMessenger() {}
// Hidden default constructor.
G4UIdirectory* theDirectory = nullptr;
G4UIcmdWithADoubleAndUnit* setCutCmd = nullptr;
G4UIcommand* setCutRCmd = nullptr;
G4UIcommand* setCutForAGivenParticleCmd = nullptr;
G4UIcmdWithAString* getCutForAGivenParticleCmd = nullptr;
G4UIcmdWithAnInteger* verboseCmd = nullptr;
G4UIcmdWithoutParameter* dumpListCmd = nullptr;
G4UIcmdWithAString* addProcManCmd = nullptr;
G4UIcmdWithAString* buildPTCmd = nullptr;
G4UIcmdWithAString* storeCmd = nullptr;
G4UIcmdWithAString* retrieveCmd = nullptr;
G4UIcmdWithAnInteger* asciiCmd = nullptr;
G4UIcommand* applyCutsCmd = nullptr;
G4UIcmdWithAString* dumpCutValuesCmd = nullptr;
G4UIcmdWithAnInteger* dumpOrdParamCmd = nullptr;
};
#endif
+30 -29
View File
@@ -23,48 +23,49 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UserRunAction
//
// Class description:
//
#ifndef G4UserRunAction_h
#define G4UserRunAction_h 1
class G4Run;
// class description:
//
// This is the base class of a user's action class which defines the
// user's action at the begining and the end of each run. The user can
// override the following two methods but the user should not change
// any of the contents of G4Run object.
// This is the base class of a user's action class defining the user's
// action at the begining and the end of each run. The user can override
// the following two methods but should not change any of the contents of
// a G4Run object:
// virtual void BeginOfRunAction(const G4Run* aRun);
// virtual void EndOfRunAction(const G4Run* aRun);
// The user can override the following method to instanciate his/her own
// concrete Run class. G4Run has a virtual method RecordEvent, so that
// the user can store any information useful to him/her with event statistics.
// concrete Run class. G4Run has a virtual method RecordEvent(), so that
// one can store any information useful for event statistics:
// virtual G4Run* GenerateRun();
// The user's concrete class derived from this class must be set to
// G4RunManager via G4RunManager::SetUserAction() method.
//
// The user's concrete class derived from this class must be set to
// G4RunManager via the G4RunManager::SetUserAction() method.
// Original author: M.Asai, 1998
// --------------------------------------------------------------------
#ifndef G4UserRunAction_hh
#define G4UserRunAction_hh 1
#include "G4Types.hh"
class G4Run;
class G4UserRunAction
{
public:
G4UserRunAction();
virtual ~G4UserRunAction();
public:
public:
virtual G4Run* GenerateRun();
virtual void BeginOfRunAction(const G4Run* aRun);
virtual void EndOfRunAction(const G4Run* aRun);
G4UserRunAction();
virtual ~G4UserRunAction();
protected:
G4bool isMaster;
virtual G4Run* GenerateRun();
virtual void BeginOfRunAction(const G4Run* aRun);
virtual void EndOfRunAction(const G4Run* aRun);
public:
inline virtual void SetMaster(G4bool val = true) { isMaster = val; }
inline G4bool IsMaster() const { return isMaster; }
inline virtual void SetMaster(G4bool val = true) { isMaster = val; }
inline G4bool IsMaster() const { return isMaster; }
protected:
G4bool isMaster = true;
};
#endif
@@ -23,74 +23,75 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4UserWorkerInitialization
//
// 25 Feb 2013: Andrea Dotti, first implementation
// Class description:
//
// class description:
// This class is used for multi-threading.
// The object of this class can be set to G4MTRunManager, but not to
// G4RunManager. G4UserWorkerInitialization class has five virtual methods
// as the user hooks which are invoked at several occasions in the life
// cycle of each thread.
//
// This class is used for multi-threaded Geant4.
// The object of this class can be set to G4MTRunManager, but not to
// G4RunManager. G4UserWorkerInitialization class has five virtual methods
// as the user hooks which are invoked at several occasions of the life
// cycle of each thread.
//
// - virtual void WorkerInitialize() const
// This method is called after the tread is created but before the
// G4WorkerRunManager is instantiated.
// - virtual void WorkerStart() const
// This method is called once at the beginning of simulation job when
// kernel classes and user action classes have already instantiated but
// geometry and physics have not been yet initialized. This situation is
// identical to "PreInit" state in the sequential mode.
// - virtual void WorkerRunStart() const
// This method is called before an event loop. Geometry and physics have
// already been set up for the thread. All threads are synchronized and
// ready to start the local event loop. This situation is identical to
// "Idle" state in the sequential mode.
// - virtual void WorkerRunEnd() const
// This method is called for each thread when the local event loop is
// done, but before the synchronization over threads.
// - virtual void WorkerStop() const
// This method is called once at the end of simulation job.
//
// Note: This object should be instantiated only once and set to
// G4MTRunManager,
// while these five methods are invoked for each worker thread. Thus, to
// store thread-local objects, use G4ThreadLocal keyword.
// - virtual void WorkerInitialize() const
// This method is called after the tread is created but before the
// G4WorkerRunManager is instantiated.
// - virtual void WorkerStart() const
// This method is called once at the beginning of simulation job when
// kernel classes and user action classes have already instantiated but
// geometry and physics have not been yet initialised. This situation is
// identical to the 'PreInit' state in the sequential mode.
// - virtual void WorkerRunStart() const
// This method is called before an event loop. Geometry and physics have
// already been set up for the thread. All threads are synchronised and
// ready to start the local event loop. This situation is identical to
// 'Idle' state in the sequential mode.
// - virtual void WorkerRunEnd() const
// This method is called for each thread when the local event loop is
// done, but before the synchronisation over threads.
// - virtual void WorkerStop() const
// This method is called once at the end of the simulation job.
//
// Note: this object should be instantiated only once and set to
// G4MTRunManager, while the five methods above are invoked for each
// worker thread. Thus, to store thread-local objects, use the
// G4ThreadLocal keyword.
// Author: A.Dotti (SLAC), 25 February 2013
// --------------------------------------------------------------------
#ifndef G4UserWorkerInitialization_hh
#define G4UserWorkerInitialization_hh
#define G4UserWorkerInitialization_hh 1
class G4UserWorkerInitialization
{
public: // with description
G4UserWorkerInitialization();
virtual ~G4UserWorkerInitialization();
public:
virtual void WorkerInitialize() const;
// This method is called after the tread is created but before the
// G4WorkerRunManager is instantiated.
G4UserWorkerInitialization();
virtual ~G4UserWorkerInitialization();
virtual void WorkerStart() const;
// This method is called once at the beginning of simulation job
// when kernel classes and user action classes have already instantiated
// but geometry and physics have not been yet initialized. This situation
// is identical to "PreInit" state in the sequential mode.
virtual void WorkerInitialize() const;
// This method is called after the tread is created but before the
// G4WorkerRunManager is instantiated.
virtual void WorkerRunStart() const;
// This method is called before an event loop. Geometry and physics have
// already been set up for the thread. All threads are synchronized and
// ready to start the local event loop. This situation is identical to
// "Idle" state in the sequential mode.
virtual void WorkerStart() const;
// This method is called once at the beginning of simulation job
// when kernel classes and user action classes have already instantiated
// but geometry and physics have not been yet initialised. This situation
// is identical to 'PreInit' state in the sequential mode.
virtual void WorkerRunEnd() const;
// This method is called for each thread, when the local event loop has
// finished but before the synchronization over threads.
virtual void WorkerRunStart() const;
// This method is called before an event loop. Geometry and physics have
// already been set up for the thread. All threads are synchronised and
// ready to start the local event loop. This situation is identical to
// 'Idle' state in the sequential mode.
virtual void WorkerStop() const;
// This method is called once at the end of simulation job.
// Implement here a clean up action.
virtual void WorkerRunEnd() const;
// This method is called for each thread, when the local event loop has
// finished but before the synchronisation over threads.
virtual void WorkerStop() const;
// This method is called once at the end of simulation job.
// Implement here a clean up action.
};
#endif // G4UserWorkerInitialization_hh
#endif
@@ -23,13 +23,17 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// class description:
// G4UserWorkerThreadInitialization
//
// This class is used for multi-threaded Geant4.
// It encapsulates the mechanism of starting/stopping threads.
// Class description:
//
// This class is used for multi-threading.
// It encapsulates the mechanism of starting/stopping threads.
// Author: M.Asai, A.Dotti (SLAC), 16 September 2013
// --------------------------------------------------------------------
#ifndef G4UserWorkerThreadInitialization_hh
#define G4UserWorkerThreadInitialization_hh
#define G4UserWorkerThreadInitialization_hh 1
class G4VUserPrimaryGeneratorAction;
class G4UserRunAction;
@@ -37,7 +41,6 @@ class G4UserEventAction;
class G4UserStackingAction;
class G4UserTrackingAction;
class G4UserSteppingAction;
class G4WorkerThread;
class G4WorkerRunManager;
@@ -46,38 +49,38 @@ class G4WorkerRunManager;
class G4UserWorkerThreadInitialization
{
public: // with description
G4UserWorkerThreadInitialization();
virtual ~G4UserWorkerThreadInitialization();
public:
virtual G4Thread* CreateAndStartWorker(G4WorkerThread* workerThreadContext);
// Called by the kernel to create a new thread/worker
// and start work.
// Usere should not re-implement this function (in derived class), except only
// if he/she wants to verwrite the default threading model (see StartThread
// function)
G4UserWorkerThreadInitialization();
virtual ~G4UserWorkerThreadInitialization();
virtual void SetupRNGEngine(const CLHEP::HepRandomEngine* aRNGEngine) const;
// Called by worker threads to set the Random Number Generator Engine
// The default implementation "clones" the engine from the master thread
// User needs to re-implement this method if using a non-standard
// RNG Engine (i.e. a different one w.r.t. the one provided in the CLHEP
// version supported by G4.
// Important: this method is called by all threads at the same time
// if is user responsibilitiy to make it thread-safe
virtual G4Thread* CreateAndStartWorker(G4WorkerThread* workerThreadContext);
// Called by the kernel to create a new thread/worker and start work.
// User should not re-implement this function (in derived class), except
// only if he/she wants to rewrite the default threading model (see
// StartThread() function).
virtual void JoinWorker(G4Thread* aThread);
// Called by the kernel when threads need to be terminated. Implements logic
// of joining the aThread. Calling thread will wait for aThread to end. Usere
// should not re-implement this function (in derived class), except only if
// he/she wants to verwrite the default threading model (see StartThread
// function)
virtual void SetupRNGEngine(const CLHEP::HepRandomEngine* aRNGEngine) const;
// Called by worker threads to set the Random Number Generator Engine.
// The default implementation "clones" the engine from the master thread
// User needs to re-implement this method if using a non-standard
// RNG Engine (i.e. a different one w.r.t. the one provided in the CLHEP
// version supported by Geant4).
// Important: this method is called by all threads at the same time;
// it is user responsibilitiy to make it thread-safe.
virtual G4WorkerRunManager* CreateWorkerRunManager() const;
// Called by StartThread function to create a run-manager implementing worker
// behvior. User should re-implemtn this function in derived class to
// instantiate his/her user-defined WorkerRunManager. By default this method
// instantiates G4WorkerRunManager object.
virtual void JoinWorker(G4Thread* aThread);
// Called by the kernel when threads need to be terminated. Implements
// logic of joining the "aThread". Calling thread will wait for "aThread"
// to end. Users should not re-implement this function (in derived class),
// except only if he/she wants to rewrite the default threading model (see
// StartThread() function).
virtual G4WorkerRunManager* CreateWorkerRunManager() const;
// Called by StartThread() function to create a run-manager implementing
// worker behvior. User should re-implement this function in a derived
// class to instantiate his/her user-defined WorkerRunManager.
// By default this method instantiates a G4WorkerRunManager object.
};
#endif // G4UserWorkerThreadInitialization_hh
#endif
+73 -81
View File
@@ -23,32 +23,23 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VModularPhysicsList
//
// Class description:
//
// This class is a subclass of G4VUserPhysicsList.
// The user should register his/her physics constructors by using:
// G4VModularPhysicsList::RegsiterPhysics()
// to construt particles and processes.
//
// ------------------------------------------------------------
// GEANT 4 class header file
//
// Class Description:
// This class is a subclass of G4VUserPhysicsList.
// The user should register his/her physics constructors
// by using
// G4VModularPhysicsList::RegsiterPhysics()
// to construt particles and processes.
//
// Only one physics constructor can be registered for each "physics_type".
// Physics constructors with same "physics_type" can be replaced by
// G4VModularPhysicsList::ReplacePhysics() method
//
// ------------------------------------------------------------
// History
// - first version 12 Nov 2000 by H.Kurashige
// - Add ReplacePhysics 14 Mar 2011 by H.Kurashige
// - Add Worker cleanup 21 Apr 2017 by A.Dotti
//
// ------------------------------------------------------------
#ifndef G4VModularPhysicsList_h
#define G4VModularPhysicsList_h 1
// Only one physics constructor can be registered for each "physics_type".
// Physics constructors with same "physics_type" can be replaced using the
// G4VModularPhysicsList::ReplacePhysics() method.
// Original author: H.Kurashige (Kobe University), 12 November 2000
// --------------------------------------------------------------------
#ifndef G4VModularPhysicsList_hh
#define G4VModularPhysicsList_hh 1
#include <vector>
@@ -64,12 +55,13 @@ class G4VMPLData
{
// Encapsulate the fields of class G4VModularPhysicsList
// that are per-thread.
public:
void initialize();
typedef std::vector<G4VPhysicsConstructor*> G4PhysConstVectorData;
// TODO: understand this
// See: https://jira-geant4.kek.jp/browse/DEV-284
G4PhysConstVectorData* physicsVector;
public:
void initialize();
using G4PhysConstVectorData = std::vector<G4VPhysicsConstructor*>;
// See: https://jira-geant4.kek.jp/browse/DEV-284
G4PhysConstVectorData* physicsVector = nullptr;
};
// The type G4VMPLManager is introduced to encapsulate the methods used by
@@ -87,73 +79,72 @@ class G4VMPLData
// Both the master thread and worker threads change the length of the array
// for G44VUPLData instances mutually along with G4VUserPhysicsList
// instances are created.
typedef G4VUPLSplitter<G4VMPLData> G4VMPLManager;
typedef G4VMPLManager G4VModularPhysicsListSubInstanceManager;
//
using G4VMPLManager = G4VUPLSplitter<G4VMPLData>;
using G4VModularPhysicsListSubInstanceManager = G4VMPLManager;
class G4VModularPhysicsList : public virtual G4VUserPhysicsList
{
public:
G4VModularPhysicsList();
virtual ~G4VModularPhysicsList();
public:
protected:
// hide copy constructor and assignment operator
G4VModularPhysicsList(const G4VModularPhysicsList&);
G4VModularPhysicsList& operator=(const G4VModularPhysicsList&);
G4VModularPhysicsList();
virtual ~G4VModularPhysicsList();
public: // with description
// This method will be invoked in the Construct() method.
// each particle type will be instantiated
virtual void ConstructParticle() override;
virtual void ConstructParticle() override;
// This method will be invoked in the Construct() method.
// Each particle type will be instantiated.
// This method will be invoked in the Construct() method.
// each physics process will be instantiated and
// registered to the process manager of each particle type
virtual void ConstructProcess() override;
virtual void ConstructProcess() override;
// This method will be invoked in the Construct() method.
// Each physics process will be instantiated and
// registered to the process manager of each particle type.
public: // with description
// Register Physics Constructor
void RegisterPhysics(G4VPhysicsConstructor*);
void RegisterPhysics(G4VPhysicsConstructor*);
// Register Physics Constructor.
const G4VPhysicsConstructor* GetPhysics(G4int index) const;
const G4VPhysicsConstructor* GetPhysics(const G4String& name) const;
const G4VPhysicsConstructor* GetPhysicsWithType(G4int physics_type) const;
const G4VPhysicsConstructor* GetPhysics(G4int index) const;
const G4VPhysicsConstructor* GetPhysics(const G4String& name) const;
const G4VPhysicsConstructor* GetPhysicsWithType(G4int physics_type) const;
// Replace Physics Constructor
// The existing physics constructor with same physics_type as one of
// the given physics constructor is replaced
// (existing physics will be deleted)
// If a corresponding physics constructor is NOT found,
// the given physics constructor is just added
void ReplacePhysics(G4VPhysicsConstructor*);
void ReplacePhysics(G4VPhysicsConstructor*);
// Replace the Physics Constructor.
// The existing physics constructor with same physics_type as one of
// the given physics constructor is replaced (existing physics will be
// deleted). If a corresponding physics constructor is NOT found,
// the given physics constructor is just added.
// Remove Physics Constructor from the list
void RemovePhysics(G4VPhysicsConstructor*);
void RemovePhysics(G4int type);
void RemovePhysics(const G4String& name);
void RemovePhysics(G4VPhysicsConstructor*);
void RemovePhysics(G4int type);
void RemovePhysics(const G4String& name);
// Remove the Physics Constructor from the list.
/////////////////////////////////////
public: // with description
void SetVerboseLevel(G4int value);
G4int GetVerboseLevel() const;
// set/get controle flag for output message
// 0: Silent
// 1: Warning message
// 2: More
// given verbose level is set to all physics constructors
inline G4int GetInstanceID() const;
static const G4VMPLManager& GetSubInstanceManager();
virtual void TerminateWorker() override;
protected: // with description
G4int verboseLevel;
typedef G4VMPLData::G4PhysConstVectorData G4PhysConstVector;
G4int g4vmplInstanceID;
G4RUN_DLL static G4VMPLManager G4VMPLsubInstanceManager;
void SetVerboseLevel(G4int value);
G4int GetVerboseLevel() const;
// Set/get control flag for output message
// 0: Silent
// 1: Warning message
// 2: More
// given verbose level is set to all physics constructors.
public:
inline G4int GetInstanceID() const;
static const G4VMPLManager& GetSubInstanceManager();
virtual void TerminateWorker() override;
protected:
G4VModularPhysicsList(const G4VModularPhysicsList&);
G4VModularPhysicsList& operator=(const G4VModularPhysicsList&);
// Protected copy constructor and assignment operator.
using G4PhysConstVector = G4VMPLData::G4PhysConstVectorData;
G4int verboseLevel = 0;
G4int g4vmplInstanceID = 0;
G4RUN_DLL static G4VMPLManager G4VMPLsubInstanceManager;
};
// Inline methods implementations
inline G4int G4VModularPhysicsList::GetVerboseLevel() const
{
return verboseLevel;
@@ -168,4 +159,5 @@ inline const G4VMPLManager& G4VModularPhysicsList::GetSubInstanceManager()
{
return G4VMPLsubInstanceManager;
}
#endif
+37 -36
View File
@@ -23,11 +23,24 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VPersistencyManager
//
// Class description:
//
// This is an abstract base class for persistency management. The user's
// concrete class derived from this class must act as a singleton. The user
// must construct the object of his/her concrete persistency manager in
// the main().
// The virtual methods of Store() and Retrieve() will be invoked from
// G4RunManager if the persistency manager exists.
// Even if the user does not use any ODBMS system, the user can use this
// class especially for Store() methods. Writing an ASCII file for storing
// event information can be delegated to this class, for example.
#ifndef G4VPersistencyManager_h
#define G4VPersistencyManager_h 1
// Author: Youhei Morita, 2001
// --------------------------------------------------------------------
#ifndef G4VPersistencyManager_hh
#define G4VPersistencyManager_hh 1
#include "globals.hh"
@@ -35,47 +48,35 @@ class G4Event;
class G4Run;
class G4VPhysicalVolume;
// class description:
//
// This is an abstract base class for persistency management. The user's
// concrete class derived from this class must be a singleton. The user
// must construct the object of his/her concrete persistency manager at
// his/her main().
// The virtual methods of Store() and Retreive() will be invoked from
// G4RunManager if the persistency manager exists.
// Even if the user does not use any ODBMS, the user can use this class
// especially for Store() methods. Writing an ASCII file for storing
// event information can be delegated to this class, for example.
//
class G4VPersistencyManager
{
public: // with description
static G4VPersistencyManager* GetPersistencyManager();
// Static method to return the pointer to the singleton object.
// Note that this method does NOT create the singleton object.
public:
protected:
G4VPersistencyManager();
static G4VPersistencyManager* GetPersistencyManager();
// Static method to return the pointer to the singleton object.
// Note that this method does NOT create the singleton itself.
public:
virtual ~G4VPersistencyManager();
virtual ~G4VPersistencyManager();
private:
static G4ThreadLocal G4VPersistencyManager* fPersistencyManager;
virtual G4bool Store(const G4Event* anEvent) = 0;
virtual G4bool Store(const G4Run* aRun) = 0;
virtual G4bool Store(const G4VPhysicalVolume* world) = 0;
// Stores G4Event, G4Run, and geometry tree characterised
// by the world volume.
public: // with description
virtual G4bool Store(const G4Event* anEvent) = 0;
virtual G4bool Store(const G4Run* aRun) = 0;
virtual G4bool Store(const G4VPhysicalVolume* theWorld) = 0;
// Stores G4Event, G4Run, and geometry tree characterized by the world
// volume.
virtual G4bool Retrieve(G4Event*& anEvent) = 0;
virtual G4bool Retrieve(G4Run*& aRun) = 0;
virtual G4bool Retrieve(G4VPhysicalVolume*& theWorld) = 0;
// Restores G4Event, G4Run, and geometry tree characterised
// by the world volume.
virtual G4bool Retrieve(G4Event*& anEvent) = 0;
virtual G4bool Retrieve(G4Run*& aRun) = 0;
virtual G4bool Retrieve(G4VPhysicalVolume*& theWorld) = 0;
// Restore G4Event, G4Run, and geometry tree characterized by the world
// volume.
protected:
G4VPersistencyManager();
private:
static G4ThreadLocal G4VPersistencyManager* fPersistencyManager;
};
#endif
+92 -108
View File
@@ -23,42 +23,33 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VPhysicsConstructor
//
// Class description:
//
// This class is a virtual class for constructing particles and processes.
// This class objects is being registered to G4VPhysicsList.
//
// ------------------------------------------------------------
// GEANT 4 class header file
// Class Description:
// This class is an virtual class for constructing
// particles and processes. This class objects will be
// registered to G4VPhysicsList.
// User must implement following four virtual methods in the concrete class
// derived from this class:
//
// User must implement following four virtual methods
// in his own concrete class derived from this class.
// - virtual void ConstructParticle();
// All necessary particle type will be instantiated.
// - virtual void ConstructProcess();
// All physics processes will be instantiated and
// registered to the process manager of each particle type.
//
// all necessary particle type will be instantiated
// virtual void ConstructParticle();
//
// all physics processes will be instantiated and
// registered to the process manager of each particle type
// virtual void ConstructProcess();
//
// Only one physics constructor can be registered to
// Modular Physics List for each "physics_type".
// Physics constructors with same "physics_type" can be
// replaced by using the method of
// G4VModularPhysicsList::ReplacePhysics()
//
//
// -------------------------------------------
// History
// first version 12 Nov. 2000 by H.Kurashige
// Add physicsType 14 Mar. 2011 by H.Kurashige
// Add RegisterProcess 1 May 2011 by H.Kurashige
// Add G4PhysicsBuilderInterface 21 Apr 2017 by A.Dotti
// ------------------------------------------------------------
#ifndef G4VPhysicsConstructor_h
#define G4VPhysicsConstructor_h 1
// Only one physics constructor can be registered to a Modular Physics List
// for each "physics_type". Physics constructors with same "physics_type"
// can be replaced by using the method:
// G4VModularPhysicsList::ReplacePhysics().
// Original author: H.Kurashige (Kobe University), 12 November 2000
// --------------------------------------------------------------------
#ifndef G4VPhysicsConstructor_hh
#define G4VPhysicsConstructor_hh 1
#include <vector>
#include "G4ParticleTable.hh"
#include "G4PhysicsListHelper.hh"
@@ -66,7 +57,6 @@
#include "G4ios.hh"
#include "globals.hh"
#include "rundefs.hh"
#include <vector>
class G4PhysicsBuilderInterface;
@@ -74,11 +64,14 @@ class G4VPCData
{
// Encapsulate the fields of class G4VPhysicsConstructor
// that are per-thread.
public:
using PhysicsBuilders_V = std::vector<G4PhysicsBuilderInterface*>;
void initialize();
G4ParticleTable::G4PTblDicIterator* _aParticleIterator;
PhysicsBuilders_V* _builders;
public:
using PhysicsBuilders_V = std::vector<G4PhysicsBuilderInterface*>;
void initialize();
G4ParticleTable::G4PTblDicIterator* _aParticleIterator;
PhysicsBuilders_V* _builders = nullptr;
};
// The type G4VPCManager is introduced to encapsulate the methods used by
@@ -103,90 +96,82 @@ class G4VPCData
// Important Note: you may wonder why we are introducing this mechanism
// since there is only one PL for each application.
// This is true, in the sense that only one PL is allowed
// to be associated to a G4RunManager, however user can
// instantiate as many PLs are needed and at run-time select one
// of the PLs to be used we thus need this mechanism to
// to be associated to a G4RunManager, however a user can
// instantiate as many PLs are needed and at run-time select
// one of the PLs to be used we thus need this mechanism to
// guarantee that the system works without problems in case of
// this (unusual) case. This may be reviewed in the future
typedef G4VUPLSplitter<G4VPCData> G4VPCManager;
typedef G4VPCManager G4VPhyscicsConstructorManager;
// This macros change the references to fields that are now encapsulated
// in the class G4VPCData.
//
// Note1: the use of this-> this is needed to avoid compilation errors
// when using templated class with T=G4VUserPhysicsList. Don't know why.
// Note2: the name of the first #define is different, because otherwise
// we need to change its use in all classes that inherits from
// this base class (all examples). However one should note comment
// on JIRA task: http://jira-geant4.kek.jp/browse/DEV-27
//#define aParticleIterator
//((subInstanceManager.offset[g4vpcInstanceID])._aParticleIterator)
using G4VPCManager = G4VUPLSplitter<G4VPCData>;
using G4VPhyscicsConstructorManager = G4VPCManager;
class G4VPhysicsConstructor
{
public: // with description
G4VPhysicsConstructor(const G4String& = "");
G4VPhysicsConstructor(const G4String& name, G4int physics_type);
virtual ~G4VPhysicsConstructor();
public:
virtual void ConstructParticle() = 0;
// This method will be invoked in the Construct() method.
// each particle type will be instantiated
G4VPhysicsConstructor(const G4String& = "");
G4VPhysicsConstructor(const G4String& name, G4int physics_type);
virtual ~G4VPhysicsConstructor();
virtual void ConstructProcess() = 0;
// This method will be invoked in the Construct() method.
// each physics process will be instantiated and
// registered to the process manager of each particle type
virtual void ConstructParticle() = 0;
// This method will be invoked in the Construct() method.
// Each particle type will be instantiated.
inline void SetPhysicsName(const G4String& = "");
inline const G4String& GetPhysicsName() const;
virtual void ConstructProcess() = 0;
// This method will be invoked in the Construct() method.
// Each physics process will be instantiated and
// registered to the process manager of each particle type.
inline void SetPhysicsType(G4int);
inline G4int GetPhysicsType() const;
inline void SetPhysicsName(const G4String& = "");
inline const G4String& GetPhysicsName() const;
inline void SetVerboseLevel(G4int value);
inline G4int GetVerboseLevel() const;
// set/get controle flag for output message
// 0: Silent
// 1: Warning message
// 2: More
// verbose level is set equal to physics list when registered
inline void SetPhysicsType(G4int);
inline G4int GetPhysicsType() const;
protected:
inline G4bool RegisterProcess(G4VProcess* process,
G4ParticleDefinition* particle);
// Register a process to the particle type
// according to the ordering parameter table
// 'true' is returned if the process is registerd successfully
inline G4int GetInstanceID() const;
static const G4VPCManager& GetSubInstanceManager();
protected:
G4int verboseLevel;
G4String namePhysics;
G4int typePhysics;
virtual void TerminateWorker();
// Method called by kernel to destroy thread-local data, equivalent to
// destructor in sequential mode. Derived classes implementing this
// method, must also call this base class method.
G4ParticleTable* theParticleTable;
G4int g4vpcInstanceID;
G4RUN_DLL static G4VPCManager subInstanceManager;
G4ParticleTable::G4PTblDicIterator* GetParticleIterator() const;
using PhysicsBuilder_V = G4VPCData::PhysicsBuilders_V;
// This returns a copy of the vector of pointers
PhysicsBuilder_V GetBuilders() const;
void AddBuilder(G4PhysicsBuilderInterface* bld);
inline void SetVerboseLevel(G4int value);
inline G4int GetVerboseLevel() const;
// Set/get control flag for output message
// 0: Silent
// 1: Warning message
// 2: More
// verbose level is set equal to physics list when registered.
public:
inline G4int GetInstanceID() const;
static const G4VPCManager& GetSubInstanceManager();
protected:
// Method called by kernel to destroy thread-local
// data, equivalent to destructor in sequential mode
// Derived classes implementing this method, must also call
// this base class method.
virtual void TerminateWorker();
using PhysicsBuilder_V = G4VPCData::PhysicsBuilders_V;
inline G4bool RegisterProcess(G4VProcess* process,
G4ParticleDefinition* particle);
// Register a process to the particle type according to the ordering
// parameter table. 'true' is returned if the process is registered
// successfully.
G4ParticleTable::G4PTblDicIterator* GetParticleIterator() const;
PhysicsBuilder_V GetBuilders() const;
// This returns a copy of the vector of pointers.
void AddBuilder(G4PhysicsBuilderInterface* bld);
protected:
G4int verboseLevel = 0;
G4String namePhysics = "";
G4int typePhysics = 0;
G4ParticleTable* theParticleTable = nullptr;
G4int g4vpcInstanceID = 0;
G4RUN_DLL static G4VPCManager subInstanceManager;
};
// Inlined methods
// Inline methods implementations
inline void G4VPhysicsConstructor::SetVerboseLevel(G4int value)
{
@@ -210,8 +195,7 @@ inline const G4String& G4VPhysicsConstructor::GetPhysicsName() const
inline void G4VPhysicsConstructor::SetPhysicsType(G4int val)
{
if(val > 0)
typePhysics = val;
if(val > 0) { typePhysics = val; }
}
inline G4int G4VPhysicsConstructor::GetPhysicsType() const
@@ -222,13 +206,13 @@ inline G4int G4VPhysicsConstructor::GetPhysicsType() const
inline G4bool G4VPhysicsConstructor::RegisterProcess(
G4VProcess* process, G4ParticleDefinition* particle)
{
return G4PhysicsListHelper::GetPhysicsListHelper()->RegisterProcess(process,
particle);
// return aPLHelper->RegisterProcess(process, particle);
return G4PhysicsListHelper::GetPhysicsListHelper()
->RegisterProcess(process, particle);
}
inline const G4VPCManager& G4VPhysicsConstructor::GetSubInstanceManager()
{
return subInstanceManager;
}
#endif
+138 -147
View File
@@ -23,190 +23,181 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VUPLSplitter
//
// Class description:
//
//
// ------------------------------------------------------------
//
// GEANT 4 class header file
//
// ---------------- G4UPLSplitter ----------------
//
// Utility template class for splitting RW data for thread-safety from
// classes: G4UserPhysicsList, G4VPhysicsConstructor and G4CModularPhsyicsList
//
// ------------------------------------------------------------
// History:
// 01.25.2009 Xin Dong: First implementation from automatic MT conversion.
// ------------------------------------------------------------
#ifndef G4VUPLSPLITTER_HH
#define G4VUPLSPLITTER_HH
// Utility template class for splitting RW data for thread-safety from classes:
// G4UserPhysicsList, G4VPhysicsConstructor and G4VModularPhysicsList.
// This class implements the split-mechanism for shared objects.
// In the split-class we have an instance of this class and an 'instanceID'.
// Every time in the master thread a new instance of the split-class is
// created, the constructor calls:
// instanceID = g4vuplsplitter.CreateInstance();
// This creates in memory an "array", pointed by "sharedOffset" of capacity
// "totalspace". The array contains "totalobj" (<=totalspace) instances
// (i.e. the array has un-initialized spaces). Note that also the TLS variables
// "offset" and "workertotalspace" have also the same stuff. When a worker
// thread is started we can call g4vuplsplitter.NewSubInstances(). This will
// simply allocate enough space in the TLS space "offset" and call
// T::initialize() onto the new created methods. Alternatively one can call,
// when the worker thread start, g4vuplsplitter.workerCopySubInstanceArray(),
// that will copy the content of master thread "array" into the TLS one.
// To see this stuff in action see the G4VUserPhysicsList and G4WorkerThread
// classes.
// Author: Xin Dong, 25 January 2009 - First implementation from
// automatic MT conversion.
// --------------------------------------------------------------------
#ifndef G4VUPLSplitter_hh
#define G4VUPLSplitter_hh 1
#include <stdlib.h>
#include "G4AutoLock.hh"
#include "globals.hh"
#include "rundefs.hh"
//
// This class implements the split-mechanism for shared objects.
// Let's see how it works.
// In the split-class we have an instance of this class and an G4int instanceID
// Every time, in the master thread a new instance of the split-class
// is created the constructor calls:
// instanceID = g4vuplsplitter.CreateInstance();
// This creates in memory an "array", pointed by "sharedOffset" of capacity
// "totalspace" The array contains "totalobj" (<=totalspace) instances (i.e. the
// array has un-initialized spaces) Note that also the TLS variables "offset"
// and "workertotalspace" have also the same stuff When a worker thread is
// started we can call g4vuplsplitter.NewSubInstances() This will simply
// allocate enough space in the TLS space "offset" and call T::initialize() onto
// the new created methods. Alternatively one can call, when the worker thread
// start, g4vuplsplitter.workerCopySubInstanceArray() That will copy the content
// of master thread "array" into the TLS one
// To see this stuff in action see:
// G4VUserPhysicsList class and G4WorkerThread classes.
template <class T> // T is the private data from the object to be split
class G4VUPLSplitter
{
public:
G4VUPLSplitter()
: totalobj(0)
, totalspace(0)
, sharedOffset(0)
{
G4MUTEXINIT(mutex);
}
public:
G4int CreateSubInstance()
// Invoked by the master thread to create a new subinstance
// whenever a new split class instance is created.
// This is called by constructor of shared classes, thus only master thread
// calls this
{
G4AutoLock l(&mutex);
// One more instance
totalobj++;
// If the number of objects is larger than the available spaces,
// a re-allocation is needed
if(totalobj > workertotalspace)
G4VUPLSplitter()
{
l.unlock();
NewSubInstances();
l.lock();
G4MUTEXINIT(mutex);
}
// Since this is called by Master thread, we can remember this
totalspace = workertotalspace;
sharedOffset = offset;
return (totalobj - 1);
}
void NewSubInstances()
// Invoked by each worker thread to grow the subinstance array and
// initialize each new subinstance using a particular method defined
// by the subclass.
{
G4AutoLock l(&mutex);
if(workertotalspace >= totalobj)
G4int CreateSubInstance()
// Invoked by the master thread to create a new subinstance
// whenever a new split class instance is created.
// This is called by constructor of shared classes,
// thus only master thread calls this
{
return;
G4AutoLock l(&mutex);
// One more instance
++totalobj;
// If the number of objects is larger than the available spaces,
// a re-allocation is needed
if(totalobj > workertotalspace)
{
l.unlock();
NewSubInstances();
l.lock();
}
// Since this is called by Master thread, we can remember this
totalspace = workertotalspace;
sharedOffset = offset;
return (totalobj - 1);
}
// Remember current large size
G4int originaltotalspace = workertotalspace;
// Increase its size by some value (purely arbitrary)
workertotalspace = totalobj + 512;
// Now re-allocate new space
offset = (T*) realloc(offset, workertotalspace * sizeof(T));
if(offset == 0)
void NewSubInstances()
// Invoked by each worker thread to grow the subinstance array and
// initialize each new subinstance using a particular method defined
// by the subclass.
{
G4Exception("G4VUPLSplitter::NewSubInstances()", "OutOfMemory",
FatalException, "Cannot malloc space!");
return;
G4AutoLock l(&mutex);
if(workertotalspace >= totalobj)
{
return;
}
// Remember current large size
G4int originaltotalspace = workertotalspace;
// Increase its size by some value (purely arbitrary)
workertotalspace = totalobj + 512;
// Now re-allocate new space
offset = (T*) realloc(offset, workertotalspace * sizeof(T));
if(offset == nullptr)
{
G4Exception("G4VUPLSplitter::NewSubInstances()", "OutOfMemory",
FatalException, "Cannot malloc space!");
return;
}
// The newly created objects need to be initialized
for(G4int i = originaltotalspace; i < workertotalspace; ++i)
{
offset[i].initialize();
}
}
// The newly created objects need to be initialized
for(G4int i = originaltotalspace; i < workertotalspace; i++)
void FreeWorker()
// Invoked by all threads to free the subinstance array.
{
offset[i].initialize();
if(offset == nullptr)
{
return;
}
free(offset);
offset = nullptr;
}
}
void FreeWorker()
// Invoked by all threads to free the subinstance array.
{
if(!offset)
T* GetOffset() { return offset; }
void UseWorkArea(T* newOffset)
{
return;
// Use recycled work area - which was created previously
if(offset != nullptr && offset != newOffset)
{
G4Exception("G4VUPLSplitter::UseWorkspace()", "TwoWorkspaces",
FatalException,
"Thread already has workspace - cannot use another.");
}
offset = newOffset;
// totalobj= numObjects;
// totalspace= numSpace;
}
free(offset);
offset = 0;
}
T* GetOffset() { return offset; }
void UseWorkArea(T* newOffset)
{
// Use recycled work area - which was created previously
if(offset && offset != newOffset)
T* FreeWorkArea() // G4int* numObjects, G4int* numSpace)
{
G4Exception("G4VUPLSplitter::UseWorkspace()", "TwoWorkspaces",
FatalException,
"Thread already has workspace - cannot use another.");
// Detach this thread from this Location
// The object which calls this method is responsible for it.
//
T* offsetRet = offset;
offset = nullptr;
return offsetRet;
}
offset = newOffset;
// totalobj= numObjects;
// totalspace= numSpace;
}
T* FreeWorkArea() // G4int* numObjects, G4int* numSpace)
{
// Detach this thread from this Location
// The object which calls this method is responsible for it.
//
T* offsetRet = offset;
offset = 0;
return offsetRet;
}
void WorkerCopySubInstanceArray()
// Invoked by each worker thread to copy all subinstances array from
// the master thread
{
if(offset)
return;
// Since this is called by worker threds, totalspace is some valid number >
// 0 Remember totalspace is the number of availabel slots from master. We
// are sure that it has valid data
G4AutoLock l(&mutex);
offset = (T*) realloc(offset, totalspace * sizeof(T));
if(offset == 0)
void WorkerCopySubInstanceArray()
// Invoked by each worker thread to copy all subinstances array from
// the master thread
{
G4Exception("G4VUPLSplitter::WorkerCopySubInstanceArray()", "OutOfMemory",
FatalException, "Cannot malloc space!");
return;
if(offset != nullptr)
return;
// Since this is called by worker threds, totalspace is some valid
// number > 0. Remember totalspace is the number of available slots
// from master. We are sure that it has valid data
G4AutoLock l(&mutex);
offset = (T*) realloc(offset, totalspace * sizeof(T));
if(offset == nullptr)
{
G4Exception("G4VUPLSplitter::WorkerCopySubInstanceArray()",
"OutOfMemory", FatalException, "Cannot malloc space!");
return;
}
// Now just copy from master thread (sharedOffset)
std::memcpy(offset, sharedOffset, totalspace * sizeof(T));
}
// Now just copy from master thread (sharedOffset)
memcpy(offset, sharedOffset, totalspace * sizeof(T));
}
public:
G4RUN_DLL G4ThreadLocalStatic G4int workertotalspace; // Per-thread available
// number of slots
G4RUN_DLL G4ThreadLocalStatic
T* offset; // Pointer to first instance of an array
public:
private:
G4int totalobj; // Total number of instances from master thread
G4int totalspace; // Available number of "slots"
T* sharedOffset;
G4Mutex mutex;
G4RUN_DLL G4ThreadLocalStatic G4int workertotalspace;
// Per-thread available number of slots
G4RUN_DLL G4ThreadLocalStatic T* offset;
// Pointer to first instance of an array
private:
G4int totalobj = 0; // Total number of instances from master thread
G4int totalspace = 0; // Available number of "slots"
T* sharedOffset = nullptr;
G4Mutex mutex;
};
template <typename T>
G4ThreadLocal G4int G4VUPLSplitter<T>::workertotalspace = 0;
template <typename T>
G4ThreadLocal T* G4VUPLSplitter<T>::offset = 0;
G4ThreadLocal T* G4VUPLSplitter<T>::offset = nullptr;
#endif
@@ -23,32 +23,29 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VUserActionInitialization
//
// Class description:
//
#ifndef G4VUserActionInitialization_h
#define G4VUserActionInitialization_h 1
// class description:
//
// This is the abstract base class for instantiating all the user action
// classes.
// This is the abstract base class for instantiating all user action classes.
// It has a pure virtual method Build() which is invoked by G4RunManager for
// sequential execution and G4WorkerRunManager for multi-threaded execution.
// sequential execution, and G4WorkerRunManager for multi-threaded execution.
// The additional virtual method BuildForMaster() will be invoked from
// G4MTRunManager for multi-threaded execution.
//
// Note that these virtual methods are const. It means the user may construct
// Note that these virtual methods are const. It means the user may construct
// user action objects, but should not store the pointers of these objects as
// data members of the derived class.
//
// Note for multi-threaded mode:
// The only action class the user may set to G4MTRunManager is a run action. It
// is
// then used at the beginning and the end of a run. It may be the same class or
// a dedicated class different from the run action instantiated for
// G4WorkerRunManager.
//
// Note for multi-threaded mode: the only action class the user may set to
// G4MTRunManager is a run action. It is then used at the beginning and the
// end of a run. It may be the same class or a dedicated class different from
// the run action instantiated for G4WorkerRunManager.
// Author: M.Asai (SLAC), 17 April 2013
// --------------------------------------------------------------------
#ifndef G4VUserActionInitialization_hh
#define G4VUserActionInitialization_hh 1
class G4VUserPrimaryGeneratorAction;
class G4UserRunAction;
@@ -60,35 +57,39 @@ class G4VSteppingVerbose;
class G4VUserActionInitialization
{
public:
G4VUserActionInitialization();
virtual ~G4VUserActionInitialization();
public:
public: // with description
virtual void Build() const = 0;
// Virtual method to be implemented by the user to instantiate user action
// class objects.
virtual void BuildForMaster() const;
// Virtual method to be implemented by the user to instantiate user run action
// class object to be used by G4MTRunManager. This method is not invoked in
// the sequential mode. The user should not use this method to instantiate
// user action classes rather than user run action.
virtual G4VSteppingVerbose* InitializeSteppingVerbose() const;
// Virtual method to be implemented by the user if (s)he has a concrete
// SteppingVerbose class to be used by the worker thread. In this case
// (s)he should instantiate her/his SteppingVerbose in the concrete
// implementation of this method and return its pointer. If this method is
// not implemented, the default G4SteppingVerbose will be used. Please note
// that this method affects only for the worker thread.
G4VUserActionInitialization();
virtual ~G4VUserActionInitialization();
protected: // with description
void SetUserAction(G4VUserPrimaryGeneratorAction*) const;
void SetUserAction(G4UserRunAction*) const;
void SetUserAction(G4UserEventAction*) const;
void SetUserAction(G4UserStackingAction*) const;
void SetUserAction(G4UserTrackingAction*) const;
void SetUserAction(G4UserSteppingAction*) const;
// These methods should be used to define user's action classes.
virtual void Build() const = 0;
// Virtual method to be implemented by the user to instantiate
// user action class objects.
virtual void BuildForMaster() const;
// Virtual method to be implemented by the user to instantiate user
// run action class object to be used by G4MTRunManager. This method
// is not invoked in the sequential mode. The user should not use
// this method to instantiate user action classes except for user
// run action.
virtual G4VSteppingVerbose* InitializeSteppingVerbose() const;
// Virtual method to be implemented by the user if having a concrete
// SteppingVerbose class to be used by the worker thread. In this case
// one should instantiate a SteppingVerbose in the concrete
// implementation of this method and return its pointer. If this method
// is not implemented, the default G4SteppingVerbose will be used.
// Please note that this method affects only for the worker thread.
protected:
void SetUserAction(G4VUserPrimaryGeneratorAction*) const;
void SetUserAction(G4UserRunAction*) const;
void SetUserAction(G4UserEventAction*) const;
void SetUserAction(G4UserStackingAction*) const;
void SetUserAction(G4UserTrackingAction*) const;
void SetUserAction(G4UserSteppingAction*) const;
// These methods should be used to define user's action classes.
};
#endif
@@ -23,64 +23,63 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VUserDetectorConstruction
//
// Class description:
//
// This is the abstract base class for the user's mandatory initialization
// of the detector setup. It has only one pure virtual method Construct()
// which is invoked by G4RunManager when its Initialize() method is invoked.
// The Construct() method must return the G4VPhysicalVolume pointer which
// represents the world volume.
#ifndef G4VUserDetectorConstruction_h
#define G4VUserDetectorConstruction_h 1
// Original author: M.Asai, 1999
// --------------------------------------------------------------------
#ifndef G4VUserDetectorConstruction_hh
#define G4VUserDetectorConstruction_hh 1
#include <vector>
#include "globals.hh"
class G4VPhysicalVolume;
class G4LogicalVolume;
class G4VUserParallelWorld;
class G4VSensitiveDetector;
#include "globals.hh"
#include <vector>
// class description:
//
// This is the abstract base class of the user's mandatory initialization class
// for detector setup. It has only one pure virtual method Construct() which is
// invoked by G4RunManager when it's Initialize() method is invoked.
// The Construct() method must return the G4VPhysicalVolume pointer which
// represents
// the world volume.
//
class G4VUserDetectorConstruction
{
public:
G4VUserDetectorConstruction();
virtual ~G4VUserDetectorConstruction();
public:
public:
virtual G4VPhysicalVolume* Construct() = 0;
G4VUserDetectorConstruction();
virtual ~G4VUserDetectorConstruction();
virtual void ConstructSDandField();
// This method is used in multi-threaded applications to build
// per-worker non-shared objects: SensitiveDetectors and Field managers
virtual G4VPhysicalVolume* Construct() = 0;
virtual void CloneSD();
virtual void CloneF();
virtual void ConstructSDandField();
// This method is used in multi-threaded applications to build
// per-worker non-shared objects: SensitiveDetectors and Field managers.
public:
void RegisterParallelWorld(G4VUserParallelWorld*);
virtual void CloneSD();
virtual void CloneF();
public:
G4int ConstructParallelGeometries();
void ConstructParallelSD();
void RegisterParallelWorld(G4VUserParallelWorld*);
private:
std::vector<G4VUserParallelWorld*> parallelWorld;
G4int ConstructParallelGeometries();
void ConstructParallelSD();
public:
G4int GetNumberOfParallelWorld() const;
G4VUserParallelWorld* GetParallelWorld(G4int i) const;
G4int GetNumberOfParallelWorld() const;
G4VUserParallelWorld* GetParallelWorld(G4int i) const;
protected:
void SetSensitiveDetector(const G4String& logVolName,
G4VSensitiveDetector* aSD, G4bool multi = false);
void SetSensitiveDetector(G4LogicalVolume* logVol, G4VSensitiveDetector* aSD);
protected:
void SetSensitiveDetector(const G4String& logVolName,
G4VSensitiveDetector* aSD, G4bool multi = false);
void SetSensitiveDetector(G4LogicalVolume* logVol,
G4VSensitiveDetector* aSD);
private:
std::vector<G4VUserParallelWorld*> parallelWorld;
};
#endif
+30 -29
View File
@@ -23,50 +23,51 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VUserParallelWorld
//
// Class description:
//
// This is the abstract base class for a user's parallel world.
// The user MUST NOT create the world volume, and should either get it
// from GetWorld() protected method, and set inside the Construct() method.
// The constructor must take a unique name of the parallel world, which is
// used for the name of the world physical volume of this parallel world.
#ifndef G4VUserParallelWorld_h
#define G4VUserParallelWorld_h 1
// Author: M.Asai (SLAC), 9 June 2006
// --------------------------------------------------------------------
#ifndef G4VUserParallelWorld_hh
#define G4VUserParallelWorld_hh 1
#include "globals.hh"
class G4VPhysicalVolume;
class G4LogicalVolume;
class G4VSensitiveDetector;
#include "globals.hh"
// class description:
//
// This is the abstract base class of the user's parallel world.
// The user MUST NOT create the worls volume, but should get it from GetWorld()
// protected method, and fill inside as the Construct() method.
// The constructor must take a unique name of the parallel world, which is used
// for the name of the world physical volume of this parallel world.
//
class G4VUserParallelWorld
{
public:
G4VUserParallelWorld(G4String worldName);
virtual ~G4VUserParallelWorld();
public:
public:
virtual void Construct() = 0;
virtual void ConstructSD();
G4VUserParallelWorld(const G4String& worldName);
virtual ~G4VUserParallelWorld();
protected:
G4String fWorldName;
virtual void Construct() = 0;
virtual void ConstructSD();
protected:
G4VPhysicalVolume* GetWorld();
inline const G4String& GetName() { return fWorldName; }
public:
inline G4String GetName() { return fWorldName; }
protected:
protected:
void SetSensitiveDetector(const G4String& logVolName,
G4VSensitiveDetector* aSD, G4bool multi = false);
void SetSensitiveDetector(G4LogicalVolume* logVol, G4VSensitiveDetector* aSD);
G4VPhysicalVolume* GetWorld();
void SetSensitiveDetector(const G4String& logVolName,
G4VSensitiveDetector* aSD, G4bool multi = false);
void SetSensitiveDetector(G4LogicalVolume* logVol,
G4VSensitiveDetector* aSD);
protected:
G4String fWorldName = "ParallelWorld";
};
#endif
+199 -290
View File
@@ -23,66 +23,22 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VUserPhysicsList
//
// Class description:
//
//
// ------------------------------------------------------------
// GEANT 4 class header file
// Class Description:
// This class is an abstract class for
// constructing particles and processes.
// User must implement following three virtual methods
// in his/her own concrete class derived from this class.
// G4VUserPhysicsList::ConstructParticle()
// Construct particles
// G4VUserPhysicsList::ConstructProcess()
// Construct procesess and register them to particles
//
// -------------------------------------------
// History
// first version 09 Jan. 1998 by H.Kurashige
// modified 24 Jan. 1998 by H.Kurashige
// rename DumpCutValues/DumpCutValuesTable
// change SetCuts method
// add SetCutsWithDefault method
// modified 06 June 1998 by H.Kurashige
// add AddProcessManager
// add BuildPhysicsTable
// modified 29 June 1998 by H.Kurashige
// add AddProcessManager
// modified 05 Dec. 1998 by H.Kurashige
// add ConstructAllParticles()
// modified 14, Apr 1999 by H.Kurashige
// change BuildPhysicsTable as public
// removed ConstructAllParticles() and related methods
// changed SetCuts method argument
// modified 08, Nov 2000 by H.Kurashige
// added Retrieve/StorePhysicsTable and related methods
// modified 08, Mar 2001 by H.Kurashige
// added binary mode for Retrieve/StorePhysicsTable
// added RetrieveCutValues and related
// added Set/ResetStoredInAscii() to switch on ascii mode
// for Retrieve/StorePhysicsTable
// modified for CUTS per REGION 10, Oct 2002 by H.Kurashige
// removed following methods
// void ReCalcCutValue()
// void SetCutValueForOthers()
// void SetCutValueForOtherThan()
// void ReCalcCutValueForOthers()
// virtual G4bool StoreMaterialInfo()
// virtual G4bool StoreCutValues()
// virtual G4bool RetrieveCutValues()
// virtual G4bool CheckForRetrievePhysicsTable()
// virtual G4bool CheckMaterialInfo()
// added void BuildPhysicsTable()
// Added PhysicsListHelper 29 Apr. 2011 H.Kurashige
// Added default impelmentation of SetCuts 10 June 2011 H.Kurashige
// SetCuts is not 'pure virtual' any more
// Trasnformations for multi-threading 26 Mar. 2013 A. Dotti
// Added destructions 21 Apr 2017 A. Dotti
// ------------------------------------------------------------
#ifndef G4VUserPhysicsList_h
#define G4VUserPhysicsList_h 1
// This class is an abstract class for constructing particles and processes.
// User must implement the following two pure virtual methods in the concrete
// class derived from this class:
// - G4VUserPhysicsList::ConstructParticle()
// Construct particles
// - G4VUserPhysicsList::ConstructProcess()
// Construct procesess and register them to particles.
// Original author: H.Kurashige (Kobe University), 9 January 1998
// --------------------------------------------------------------------
#ifndef G4VUserPhysicsList_hh
#define G4VUserPhysicsList_hh 1
#include "G4ios.hh"
#include "globals.hh"
@@ -102,16 +58,19 @@ class G4VProcess;
class G4VUPLData
{
// Encapsulate the fields of class G4VUserPhysicsList
// that are per-thread.
public:
void initialize();
G4ParticleTable::G4PTblDicIterator* _theParticleIterator;
G4UserPhysicsListMessenger* _theMessenger;
G4PhysicsListHelper* _thePLHelper;
G4bool _fIsPhysicsTableBuilt;
G4int _fDisplayThreshold;
// Encapsulate the fields of class G4VUserPhysicsList that are per-thread.
public:
void initialize();
G4ParticleTable::G4PTblDicIterator* _theParticleIterator = nullptr;
G4UserPhysicsListMessenger* _theMessenger = nullptr;
G4PhysicsListHelper* _thePLHelper = nullptr;
G4bool _fIsPhysicsTableBuilt = false;
G4int _fDisplayThreshold = 0;
};
// The type G4VUPLManager is introduced to encapsulate the methods used by
// both the master thread and worker threads to allocate memory space for
// the fields encapsulated by the class G4VUPLData. When each thread
@@ -139,289 +98,232 @@ class G4VUPLData
// of the PLs to be used we thus need this mechanism to
// guarantee that the system works without problems in case of
// this (unusual) case. This may be reviewed in the future
typedef G4VUPLSplitter<G4VUPLData> G4VUPLManager;
typedef G4VUPLManager G4VUserPhysicsListSubInstanceManager;
// This macros change the references to fields that are now encapsulated
// in the class G4VUPLData.
//
// Note1: the use of this-> this is needed to avoid compilation errors
// when using templated class with T=G4VUserPhysicsList. Don't know why.
// Note2: the name of the first #define is different, because otherwise
// we need to change its use in all classes that inherits from
// this base class (all examples). However one should note comment
// on JIRA task: http://jira-geant4.kek.jp/browse/DEV-27
//#define theParticleIterator
//((this->subInstanceManager.offset[this->g4vuplInstanceID])._theParticleIterator)
using G4VUPLManager = G4VUPLSplitter<G4VUPLData>;
using G4VUserPhysicsListSubInstanceManager = G4VUPLManager;
class G4VUserPhysicsList
{
public:
G4VUserPhysicsList();
virtual ~G4VUserPhysicsList();
public:
// copy constructor and assignment operator
G4VUserPhysicsList(const G4VUserPhysicsList&);
G4VUserPhysicsList& operator=(const G4VUserPhysicsList&);
G4VUserPhysicsList();
virtual ~G4VUserPhysicsList();
public: // with description
// Each particle type will be instantiated
// This method is invoked by the RunManger
virtual void ConstructParticle() = 0;
G4VUserPhysicsList(const G4VUserPhysicsList&);
G4VUserPhysicsList& operator=(const G4VUserPhysicsList&);
// Copy constructor and assignment operator.
// By calling the "Construct" method,
// process manager and processes are created.
void Construct();
virtual void ConstructParticle() = 0;
// Each particle type will be instantiated.
// This method is invoked by the RunManger.
// Each physics process will be instantiated and
// registered to the process manager of each particle type
// This method is invoked in Construct method
virtual void ConstructProcess() = 0;
void Construct();
// By calling the "Construct" method,
// process manager and processes are created.
protected: // with description
// User must invoke this method in his ConstructProcess()
// implementation in order to insures particle transportation.
void AddTransportation();
virtual void ConstructProcess() = 0;
// Each physics process will be instantiated and
// registered to the process manager of each particle type.
// Invoked in the Construct() method.
// Register a process to the particle type
// according to the ordering parameter table
// 'true' is returned if the process is registerd successfully
G4bool RegisterProcess(G4VProcess* process, G4ParticleDefinition* particle);
virtual void SetCuts();
// Sets a cut value for all particle types in the particle table.
public:
void UseCoupledTransportation(G4bool vl = true);
void SetDefaultCutValue(G4double newCutValue);
G4double GetDefaultCutValue() const;
// Set/get the default cut value. Calling SetDefaultCutValue() causes
// re-calcuration of cut values and physics tables just before the
// next event loop.
/////////////////////////////////////////////////////////////////
public: // with description
// "SetCuts" method sets a cut value for all particle types
// in the particle table
virtual void SetCuts();
void BuildPhysicsTable();
// Invoke BuildPhysicsTable for all processes for all particles.
// In case of "Retrieve" flag is ON, PhysicsTable will be
// retrieved from files.
public: // with description
// set/get the default cut value
// Calling SetDefaultCutValue causes re-calcuration of cut values
// and physics tables just before the next event loop
void SetDefaultCutValue(G4double newCutValue);
G4double GetDefaultCutValue() const;
void PreparePhysicsTable(G4ParticleDefinition*);
// Prepare the PhysicsTable for specified particle type.
/////////////////////////////////////////////////////////////////////
public: // with description
// Invoke BuildPhysicsTable for all processes for all particles
// In case of "Retrieve" flag is ON, PhysicsTable will be
// retrieved from files
void BuildPhysicsTable();
void BuildPhysicsTable(G4ParticleDefinition*);
// Build the PhysicsTable for specified particle type.
// do PreparePhysicsTable for specified particle type
void PreparePhysicsTable(G4ParticleDefinition*);
G4bool StorePhysicsTable(const G4String& directory = ".");
// Store PhysicsTable together with both material and cut value
// information in files under the specified directory.
// Returns "true" if files are successfully created.
// do BuildPhysicsTable for specified particle type
void BuildPhysicsTable(G4ParticleDefinition*);
G4bool IsPhysicsTableRetrieved() const;
G4bool IsStoredInAscii() const;
// Return true if "Retrieve" flag is ON.
// (i.e. PhysicsTable will be retrieved from files).
// Store PhysicsTable together with both material and cut value
// information in files under the specified directory.
// (return true if files are successfully created)
G4bool StorePhysicsTable(const G4String& directory = ".");
const G4String& GetPhysicsTableDirectory() const;
// Get directory path for physics table files.
// Return true if "Retrieve" flag is ON.
// (i.e. PhysicsTable will be retrieved from files)
G4bool IsPhysicsTableRetrieved() const;
G4bool IsStoredInAscii() const;
void SetPhysicsTableRetrieved(const G4String& directory = "");
void SetStoredInAscii();
// Set "Retrieve" flag. Directory path can be set together.
// Null string (default) means directory is not changed
// from the current value.
// Get directory path for physics table files.
const G4String& GetPhysicsTableDirectory() const;
void ResetPhysicsTableRetrieved();
void ResetStoredInAscii();
// Reset "Retrieve" flag.
// Set "Retrieve" flag
// Directory path can be set together.
// Null string (default) means directory is not changed
// from the current value
void SetPhysicsTableRetrieved(const G4String& directory = "");
void SetStoredInAscii();
void DumpList() const;
// Print out the List of registered particles types.
// Reset "Retrieve" flag
void ResetPhysicsTableRetrieved();
void ResetStoredInAscii();
void DumpCutValuesTable(G4int flag = 1);
// Request to print out information of cut values.
// Printing will be performed when all tables are made.
///////////////////////////////////////////////////////////////////////
public: // with description
// Print out the List of registered particles types
void DumpList() const;
void DumpCutValuesTableIfRequested();
// Triggers the print-out requested by the above method.
// This method must be invoked by RunManager at the proper moment.
public: // with description
// Request to print out information of cut values
// Printing will be performed when all tables are made
void DumpCutValuesTable(G4int flag = 1);
void SetVerboseLevel(G4int value);
G4int GetVerboseLevel() const;
// Set/get control flag for output message
// 0: Silent
// 1: Warning message
// 2: More
// The following method actually trigger the print-out requested
// by the above method. This method must be invoked by RunManager
// at the proper moment.
void DumpCutValuesTableIfRequested();
void UseCoupledTransportation(G4bool vl = true);
public: // with description
void SetVerboseLevel(G4int value);
G4int GetVerboseLevel() const;
// set/get controle flag for output message
// 0: Silent
// 1: Warning message
// 2: More
void SetCutsWithDefault();
// Invokes default SetCuts() method.
// Note: cut values will not be overwritten.
// Use of default SetCuts() method is recommended.
///////////////////////////////////////////////////////////////////////////
public: // with description
// "SetCutsWithDefault" method invokes default SetCuts method
// Note: Cut values will not be overwriten with this method
// Using default SetCuts method is recommended
// (i.e You do not need to implement SetCuts method)
void SetCutsWithDefault();
void SetCutValue(G4double aCut, const G4String& pname);
// Sets a cut value for a particle type for the default region.
// Following are utility methods for SetCuts
G4double GetCutValue(const G4String& pname) const;
// Gets a cut value for a particle type for the default region.
// SetCutValue sets a cut value for a particle type for the default region
void SetCutValue(G4double aCut, const G4String& pname);
void SetCutValue(G4double aCut, const G4String& pname,
const G4String& rname);
// Sets a cut value for a particle type for a region.
// GetCutValue sets a cut value for a particle type for the default region
G4double GetCutValue(const G4String& pname) const;
void SetParticleCuts(G4double cut, G4ParticleDefinition* particle,
G4Region* region = nullptr);
void SetParticleCuts(G4double cut, const G4String& particleName,
G4Region* region = nullptr);
// Invoke SetCuts for specified particle for a region.
// If the pointer to the region is NULL, the default region is used
// In case of "Retrieve" flag is ON, cut values will be retrieved
// from files.
// SetCutValue sets a cut value for a particle type for a region
void SetCutValue(G4double aCut, const G4String& pname, const G4String& rname);
void SetCutsForRegion(G4double aCut, const G4String& rname);
// Invoke SetCuts() for all particles in a region.
// Invoke SetCuts for specified particle for a region
// If the pointer to the region is NULL, the default region is used
// In case of "Retrieve" flag is ON,
// Cut values will be retrieved from files
void SetParticleCuts(G4double cut, G4ParticleDefinition* particle,
G4Region* region = 0);
void SetParticleCuts(G4double cut, const G4String& particleName,
G4Region* region = 0);
void SetApplyCuts(G4bool value, const G4String& name);
G4bool GetApplyCuts(const G4String& name) const;
// Gets/sets the flag for ApplyCuts().
// Invoke SetCuts for all particles in a region
void SetCutsForRegion(G4double aCut, const G4String& rname);
void RemoveProcessManager();
// Remove and delete ProcessManagers for all particles in the
// Particle Table. Function invoked from RunManager.
// Following are utility methods are obsolete
void ResetCuts();
void AddProcessManager(G4ParticleDefinition* newParticle,
G4ProcessManager* newManager = nullptr);
// Add process manager for particles created on-the-fly.
///////////////////////////////////////////////////////////////////
public:
// Get/SetApplyCuts gets/sets the flag for ApplyCuts
void SetApplyCuts(G4bool value, const G4String& name);
G4bool GetApplyCuts(const G4String& name) const;
void CheckParticleList();
// Check consistencies of list of particles.
///////////////////////////////////////////////////////////////////////////////
protected:
// do BuildPhysicsTable for make the integral schema
void BuildIntegralPhysicsTable(G4VProcess*, G4ParticleDefinition*);
void DisableCheckParticleList();
protected:
// Retrieve PhysicsTable from files for proccess belongng the particle.
// Normal BuildPhysics procedure of processes will be invoked,
// if it fails (in case of Process's RetrievePhysicsTable returns false)
virtual void RetrievePhysicsTable(G4ParticleDefinition*,
const G4String& directory,
G4bool ascii = false);
inline G4int GetInstanceID() const;
static const G4VUPLManager& GetSubInstanceManager();
// Used by Worker threads on the shared instance of physics-list
// to initialise workers. Derived class re-implementing this method
// must also call this base class method.
virtual void InitializeWorker();
// Destroy thread-local data. Note that derived classes
// implementing this method should still call this base class one.
virtual void TerminateWorker();
/////////////////////////////////////////////////////////////////
protected:
// adds new ProcessManager to all particles in the Particle Table
// this routine is used in Construct()
void InitializeProcessManager();
protected:
public: // with description
// remove and delete ProcessManagers for all particles in tha Particle Table
// this routine is invoked from RunManager
void RemoveProcessManager();
void AddTransportation();
// User must invoke this method in his ConstructProcess()
// implementation in order to enable particle transportation.
public: // with description
// add process manager for particles created on-the-fly
void AddProcessManager(G4ParticleDefinition* newParticle,
G4ProcessManager* newManager = 0);
G4bool RegisterProcess(G4VProcess* process, G4ParticleDefinition* particle);
// Register a process to the particle type
// according to the ordering parameter table.
// 'true' is returned if the process is registerd successfully.
/////////////////////////////////////////////////////////////////
public:
// check consistencies of list of particles
void BuildIntegralPhysicsTable(G4VProcess*, G4ParticleDefinition*);
// Build PhysicsTable for making the integral schema.
void CheckParticleList();
virtual void RetrievePhysicsTable(G4ParticleDefinition*,
const G4String& directory,
G4bool ascii = false);
// Retrieve PhysicsTable from files for process belonging to the particle.
// Normal BuildPhysics procedure of processes will be invoked, if it
// fails (in case of process's RetrievePhysicsTable() returns false).
void DisableCheckParticleList();
void InitializeProcessManager();
// Adds new ProcessManager to all particles in the Particle Table.
// This function is used in Construct().
////////////////////////////////////////////////////////////////////////
protected:
// the particle table has the complete List of existing particle types
G4ParticleTable* theParticleTable;
// G4ParticleTable::G4PTblDicIterator* theParticleIterator; //AND
G4ParticleTable::G4PTblDicIterator* GetParticleIterator() const;
protected:
// pointer to G4UserPhysicsListMessenger
// G4UserPhysicsListMessenger* theMessenger;
protected:
protected:
G4int verboseLevel;
G4ParticleTable* theParticleTable = nullptr;
// The particle table has the complete List of existing particle types.
protected:
// this is the default cut value for all particles
G4double defaultCutValue;
G4bool isSetDefaultCutValue;
G4int verboseLevel = 1;
protected:
// pointer to ProductionCutsTable
G4ProductionCutsTable* fCutsTable;
G4double defaultCutValue = 1.0;
// Default cut value for all particles
G4bool isSetDefaultCutValue = false;
// flag to determine physics table will be build from file or not
G4bool fRetrievePhysicsTable;
G4bool fStoredInAscii;
G4ProductionCutsTable* fCutsTable = nullptr;
// Pointer to ProductionCutsTable.
G4bool fIsCheckedForRetrievePhysicsTable;
G4bool fIsRestoredCutValues;
G4bool fRetrievePhysicsTable = false;
// Flag to determine if physics table will be build from file or not.
G4bool fStoredInAscii = true;
// directory name for physics table files
G4String directoryPhysicsTable;
G4bool fIsCheckedForRetrievePhysicsTable = false;
G4bool fIsRestoredCutValues = false;
// flag for displaying the range cuts & energy thresholds
// G4int fDisplayThreshold;
G4String directoryPhysicsTable = ".";
// Directory name for physics table files.
// flag for Physics Table has been built
// G4bool fIsPhysicsTableBuilt;
G4bool fDisableCheckParticleList = false;
// Flag for CheckParticleList().
// flag for CheckParticleList
G4bool fDisableCheckParticleList;
G4int g4vuplInstanceID = 0;
G4RUN_DLL static G4VUPLManager subInstanceManager;
// MT data
// PhysicsListHelper
// G4PhysicsListHelper* thePLHelper;
private:
private:
enum
{
FixedStringLengthForStore = 32
};
// Changes for MT
protected:
G4int g4vuplInstanceID;
G4RUN_DLL static G4VUPLManager subInstanceManager;
G4ParticleTable::G4PTblDicIterator* GetParticleIterator() const;
public:
inline G4int GetInstanceID() const;
static const G4VUPLManager& GetSubInstanceManager();
// Used by Worker threads on the shared instance of
// PL to initialize workers. Derived class re-implementing this method
// must also call this base class method
virtual void InitializeWorker();
// Destroy thread-local data. Note that derived classes
// implementing this method should still call this base class one
virtual void TerminateWorker();
enum
{
FixedStringLengthForStore = 32
};
};
// Inline methods implementations
inline void G4VUserPhysicsList::Construct()
{
#ifdef G4VERBOSE
if(verboseLevel > 1)
G4cout << "G4VUserPhysicsList::Construct()" << G4endl;
#endif
#ifdef G4VERBOSE
if(verboseLevel > 1)
G4cout << "G4VUserPhysicsList::Construct()" << G4endl;
#endif
InitializeProcessManager();
#ifdef G4VERBOSE
if(verboseLevel > 1)
G4cout << "Construct processes " << G4endl;
#endif
#ifdef G4VERBOSE
if(verboseLevel > 1)
G4cout << "Construct processes " << G4endl;
#endif
ConstructProcess();
}
@@ -450,7 +352,10 @@ inline const G4String& G4VUserPhysicsList::GetPhysicsTableDirectory() const
return directoryPhysicsTable;
}
inline void G4VUserPhysicsList::SetStoredInAscii() { fStoredInAscii = true; }
inline void G4VUserPhysicsList::SetStoredInAscii()
{
fStoredInAscii = true;
}
inline void G4VUserPhysicsList::ResetPhysicsTableRetrieved()
{
@@ -459,7 +364,10 @@ inline void G4VUserPhysicsList::ResetPhysicsTableRetrieved()
fIsCheckedForRetrievePhysicsTable = false;
}
inline void G4VUserPhysicsList::ResetStoredInAscii() { fStoredInAscii = false; }
inline void G4VUserPhysicsList::ResetStoredInAscii()
{
fStoredInAscii = false;
}
inline void G4VUserPhysicsList::DisableCheckParticleList()
{
@@ -475,4 +383,5 @@ inline const G4VUPLManager& G4VUserPhysicsList::GetSubInstanceManager()
{
return subInstanceManager;
}
#endif
@@ -23,36 +23,35 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4VUserPrimaryGeneratorAction
//
// Class description:
//
// Abstract base class for user's mandatory action class for primary
// vertex/particle generation. This class has only one pure virtual
// method GeneratePrimaries() which is invoked from G4RunManager
// during the event loop.
// This class is NOT intended for generating primary vertex/particle
// by itself. This class should:
// - have one or more G4VPrimaryGenerator concrete classes such as G4ParticleGun
// - set/change properties of generator(s)
// - pass G4Event object so that the generator(s) can generate primaries.
#ifndef G4VUserPrimaryGeneratorAction_h
#define G4VUserPrimaryGeneratorAction_h 1
// Original author: M.Asai, 1999
// --------------------------------------------------------------------
#ifndef G4VUserPrimaryGeneratorAction_hh
#define G4VUserPrimaryGeneratorAction_hh 1
class G4Event;
// class description:
//
// This is the abstract base class of the user's mandatory action class
// for primary vertex/particle generation. This class has only one pure
// virtual method GeneratePrimaries() which is invoked from G4RunManager
// during the event loop.
// Note that this class is NOT intended for generating primary vertex/particle
// by itself. This class should
// - have one or more G4VPrimaryGenerator concrete classes such as
// G4ParticleGun
// - set/change properties of generator(s)
// - pass G4Event object so that the generator(s) can generate primaries.
//
class G4VUserPrimaryGeneratorAction
{
public:
G4VUserPrimaryGeneratorAction();
virtual ~G4VUserPrimaryGeneratorAction();
public:
public:
virtual void GeneratePrimaries(G4Event* anEvent) = 0;
G4VUserPrimaryGeneratorAction();
virtual ~G4VUserPrimaryGeneratorAction();
virtual void GeneratePrimaries(G4Event* anEvent) = 0;
};
#endif
+77 -82
View File
@@ -23,21 +23,22 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4WorkerRunManager
//
// Class description:
//
//
// class description:
//
// This is a class for run control in GEANT4 for multi-threaded runs
// This is a class for run control in GEANT4 for multi-threading.
// It extends G4RunManager re-implementing multi-threaded behavior in
// key methods. See documentation for G4RunManager
// key methods. See documentation for G4RunManager.
// User should never initialize instances of this class, that are usually
// handled by G4MTRunManager. There exists one instance of this class for each
// worker in a MT application.
// handled by G4MTRunManager. There exists one instance of this class for
// each worker in a MT application.
// Original authors: X.Dong, A.Dotti - 2013
// --------------------------------------------------------------------
#ifndef G4WorkerRunManager_hh
#define G4WorkerRunManager_hh 1
#ifndef G4WorkerRunManager_h
#define G4WorkerRunManager_h 1
#include "G4RNGHelper.hh"
#include "G4RunManager.hh"
@@ -46,85 +47,79 @@ class G4WorkerRunManagerKernel;
class G4WorkerRunManager : public G4RunManager
{
public:
using ProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>;
public:
public:
static G4WorkerRunManager* GetWorkerRunManager();
static G4WorkerRunManagerKernel* GetWorkerRunManagerKernel();
G4WorkerRunManager();
~G4WorkerRunManager();
// Modified for worker behavior
////////virtual void BeamOn(G4int n_event,const char* macroFile=0,G4int
///n_select=-1);
virtual void InitializeGeometry();
virtual void RunInitialization();
virtual void DoEventLoop(G4int n_event, const char* macroFile = 0,
G4int n_select = -1);
virtual void ProcessOneEvent(G4int i_event);
virtual G4Event* GenerateEvent(G4int i_event);
// G4int NewCommands( const std::vector<G4String>& newCmdsToExecute ,
// G4String& currentCmd ); Called by the MTRunManager when new UI commands are
// to be executed. It is not assumed method is not thread-safe: i.e. should be
// called sequentially Returns 0 if commands are executed corrected, otherwise
// returns error code (see G4UImanager::ApplyCommand) In case of error
// currentCmd is set to the command that gave the problem
virtual void RunTermination();
virtual void TerminateEventLoop();
using ProfilerConfig = G4ProfilerConfig<G4ProfileType::Run>;
// This function is called by the thread function: it should loop until some
// work is requested
virtual void DoWork();
static G4WorkerRunManager* GetWorkerRunManager();
static G4WorkerRunManagerKernel* GetWorkerRunManagerKernel();
protected:
virtual void ConstructScoringWorlds();
virtual void StoreRNGStatus(const G4String& filenamePrefix);
virtual void rndmSaveThisRun();
virtual void rndmSaveThisEvent();
virtual void MergePartialResults();
// This method will merge (reduce) the results of this run into the
// global run
public:
//! Sets the worker context
void SetWorkerThread(G4WorkerThread* wc) { workerContext = wc; }
G4WorkerRunManager();
~G4WorkerRunManager();
protected:
G4WorkerThread* workerContext;
#ifdef G4MULTITHREADED
G4bool visIsSetUp;
#endif
virtual void InitializeGeometry();
virtual void RunInitialization();
virtual void DoEventLoop(G4int n_event, const char* macroFile = 0,
G4int n_select = -1);
virtual void ProcessOneEvent(G4int i_event);
virtual G4Event* GenerateEvent(G4int i_event);
virtual void RunTermination();
virtual void TerminateEventLoop();
virtual void DoWork();
// This function is called by the thread function: it should
// loop until some work is requested.
inline void SetWorkerThread(G4WorkerThread* wc) { workerContext = wc; }
// Sets the worker context.
virtual void SetUserInitialization(G4VUserPhysicsList* userInit);
virtual void SetUserInitialization(G4VUserDetectorConstruction* userInit);
virtual void SetUserInitialization(G4VUserActionInitialization* userInit);
virtual void SetUserInitialization(G4UserWorkerInitialization* userInit);
virtual void SetUserInitialization(G4UserWorkerThreadInitialization* userInit);
virtual void SetUserAction(G4UserRunAction* userAction);
virtual void SetUserAction(G4VUserPrimaryGeneratorAction* userAction);
virtual void SetUserAction(G4UserEventAction* userAction);
virtual void SetUserAction(G4UserStackingAction* userAction);
virtual void SetUserAction(G4UserTrackingAction* userAction);
virtual void SetUserAction(G4UserSteppingAction* userAction);
virtual void RestoreRndmEachEvent(G4bool flag) { readStatusFromFile=flag; }
protected:
virtual void ConstructScoringWorlds();
virtual void StoreRNGStatus(const G4String& filenamePrefix);
virtual void rndmSaveThisRun();
virtual void rndmSaveThisEvent();
virtual void MergePartialResults();
// This method will merge (reduce) the results
// of this run into the global run
private:
void SetupDefaultRNGEngine();
protected:
G4WorkerThread* workerContext = nullptr;
#ifdef G4MULTITHREADED
G4bool visIsSetUp = false;
#endif
G4bool eventLoopOnGoing = false;
G4bool runIsSeeded = false;
G4int nevModulo = -1;
G4int currEvID = -1;
G4int luxury = -1;
G4SeedsQueue seedsQueue;
G4bool readStatusFromFile = false;
private:
void SetupDefaultRNGEngine();
public:
virtual void SetUserInitialization(G4VUserPhysicsList* userInit);
virtual void SetUserInitialization(G4VUserDetectorConstruction* userInit);
virtual void SetUserInitialization(G4VUserActionInitialization* userInit);
virtual void SetUserInitialization(G4UserWorkerInitialization* userInit);
virtual void SetUserInitialization(
G4UserWorkerThreadInitialization* userInit);
virtual void SetUserAction(G4UserRunAction* userAction);
virtual void SetUserAction(G4VUserPrimaryGeneratorAction* userAction);
virtual void SetUserAction(G4UserEventAction* userAction);
virtual void SetUserAction(G4UserStackingAction* userAction);
virtual void SetUserAction(G4UserTrackingAction* userAction);
virtual void SetUserAction(G4UserSteppingAction* userAction);
protected:
G4bool eventLoopOnGoing;
G4bool runIsSeeded;
G4int nevModulo;
G4int currEvID;
G4int luxury;
G4SeedsQueue seedsQueue;
G4bool readStatusFromFile;
private:
std::unique_ptr<ProfilerConfig> workerRunProfiler;
public:
virtual void RestoreRndmEachEvent(G4bool flag) { readStatusFromFile = flag; }
};
#endif // G4WorkerRunManager_h
#endif // G4WorkerRunManager_hh
+36 -35
View File
@@ -23,48 +23,49 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
////
// G4WorkerRunManagerKernel
//
// Class description:
//
// This is a class for mandatory control of the Geant4 kernel.
// Implements Worker behavior in a MT application.
// This class is constructed by G4WorkerRunManager. If a user uses his/her
// own class instead of G4WorkerRunManager, this class must be instantiated
// at the very beginning of the application and must be deleted at the very
// end. Also, following methods must be invoked in the proper order:
// DefineWorldVolume()
// InitializePhysics()
// RunInitialization()
// RunTermination()
//
// User must provide his/her own classes derived from the following
// abstract class and register it to the RunManagerKernel:
// G4VUserPhysicsList - Particle types, Processes and Cuts
//
// G4WorkerRunManagerKernel does not have any event loop. Handling of events
// is managed by G4RunManager.
//
// This class re-implements only the method that require special treatment
// to implement worker behavior
// class description:
//
// This is a class for mandatory control of GEANT4 kernel.
// This class implements Worker behavior in a MT application.
//
// This class is constructed by G4WorkerRunManager. If a user uses his/her
// own class instead of G4WorkerRunManager, this class must be instantiated
// by him/herself at the very beginning of the application and must be
// deleted at the very end of the application. Also, following methods must
// be invoked in the proper order.
// DefineWorldVolume
// InitializePhysics
// RunInitialization
// RunTermination
//
// User must provide his/her own classes derived from the following
// abstract class and register it to the RunManagerKernel.
// G4VUserPhysicsList - Particle types, Processes and Cuts
//
// G4WorkerRunManagerKernel does not have any eveny loop. Handling of events
// is managed by G4RunManager.
//
// This class re-implements only the method that require special treatment
// to implement worker behavior
#ifndef G4WorkerRunManagerKernel_h
#define G4WorkerRunManagerKernel_h 1
// Authors: M.Asai, A.Dotti (SLAC), 2013
// --------------------------------------------------------------------
#ifndef G4WorkerRunManagerKernel_hh
#define G4WorkerRunManagerKernel_hh 1
#include "G4RunManagerKernel.hh"
class G4WorkerRunManagerKernel : public G4RunManagerKernel
{
public:
G4WorkerRunManagerKernel();
virtual ~G4WorkerRunManagerKernel();
public:
protected:
// Overwrite default behavior
void SetupShadowProcess() const;
G4WorkerRunManagerKernel();
virtual ~G4WorkerRunManagerKernel();
protected:
void SetupShadowProcess() const;
// Overwrite default behavior.
};
#endif // G4WorkerRunManagerKernel_h
#endif
+26 -22
View File
@@ -23,17 +23,18 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// G4WorkerThread
//
// Class description:
//
//
// class description:
//
// This is a class to encapsulate thread-specific data
// Used by G4MTRunManager and G4WorkerRunManager classes
// This is a class to encapsulate thread-specific data.
// Used by G4MTRunManager and G4WorkerRunManager classes.
// Authors: X.Dong, A.Dotti, 2013
// --------------------------------------------------------------------
#ifndef G4WorkerThread_hh
#define G4WorkerThread_hh
#define G4WorkerThread_hh 1
#include "G4String.hh"
#include "G4Types.hh"
@@ -41,23 +42,26 @@
class G4WorkerThread
{
public:
void SetThreadId(G4int threadId);
G4int GetThreadId() const;
public:
void SetNumberThreads(G4int numnberThreads);
G4int GetNumberThreads() const;
void SetThreadId(G4int threadId);
G4int GetThreadId() const;
// Build geometry for workers
static void BuildGeometryAndPhysicsVector();
static void DestroyGeometryAndPhysicsVector();
static void UpdateGeometryAndPhysicsVectorFromMaster();
void SetNumberThreads(G4int numnberThreads);
G4int GetNumberThreads() const;
// Setting Pin Affinity
void SetPinAffinity(G4int aff) const;
static void BuildGeometryAndPhysicsVector();
// Build geometry for workers
static void DestroyGeometryAndPhysicsVector();
static void UpdateGeometryAndPhysicsVectorFromMaster();
private:
G4int threadId;
G4int numThreads;
void SetPinAffinity(G4int aff) const;
// Setting Pin Affinity
private:
G4int threadId = 0;
G4int numThreads = 0;
};
#endif // G4WorkerThread_hh
#endif
+4 -6
View File
@@ -23,14 +23,12 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
//
//
//
// Defines for Windows DLLs import/export
//
#ifndef RUNDEFS_HH
#define RUNDEFS_HH
// Author: G.Cosmo (CERN), 5 April 2013
// --------------------------------------------------------------------
#ifndef G4RUNDEFS_HH
#define G4RUNDEFS_HH 1
#include "G4Types.hh"