Import Geant4 10.7.0.beta source tree
This commit is contained in:
@@ -1,22 +1,9 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# CMakeLists.txt
|
||||
# Module : G4run
|
||||
# Package: Geant4.src.G4run
|
||||
#
|
||||
# CMakeLists.txt for single level library that may be build global or granular
|
||||
#
|
||||
# Generated on : 24/9/2010
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# Add allocation export symbol for the run category
|
||||
add_definitions(-DG4RUN_ALLOC_EXPORT)
|
||||
|
||||
include(Geant4MacroLibraryTargets)
|
||||
if(GEANT4_BUILD_GRANULAR_LIBS)
|
||||
GEANT4_GRANULAR_LIBRARY_TARGET(COMPONENT sources.cmake)
|
||||
else()
|
||||
GEANT4_GLOBAL_LIBRARY_TARGET(COMPONENTS sources.cmake)
|
||||
endif()
|
||||
|
||||
geant4_global_library_target(COMPONENTS sources.cmake)
|
||||
|
||||
@@ -16,6 +16,50 @@ committal in the CVS repository !
|
||||
* Reverse chronological order (last date on top), please *
|
||||
----------------------------------------------------------
|
||||
|
||||
June 17th Gunter Folger, included in run-V10-06-07
|
||||
- Fixes for windows.
|
||||
- G4MTRunManager:
|
||||
- inline static functions split into declaration and definition:
|
||||
GetMasterThreadId(), GetMasterScoringManager(), GetMasterWorlds(),
|
||||
addWorld(), SetSeedOncePerCommunication(), SetSeedOncePerCommunication()
|
||||
- add GetMasterTheadId()
|
||||
- G4RunManager:
|
||||
- impot/export static fGeometryHasBeenDestroyed using G4RUN_DLL, add
|
||||
include for rundef.hh
|
||||
|
||||
|
||||
June 4th, 2020 J.Madsen (run-V10-06-07)
|
||||
- Minor class access changes in G4MTRunManager to enable inheritance
|
||||
for G4TaskRunManager
|
||||
June 17th Gunter Folger, included in the above tag
|
||||
|
||||
May 26th, 2020 A.Howard (run-V10-06-06)
|
||||
- Added second wavelength shifter process to G4PhysicsListHelper.cc
|
||||
|
||||
May 20th, 2020 G.Cosmo (run-V10-06-05)
|
||||
- Re-applied clang-format after minor rules adaptations.
|
||||
|
||||
May 12th, 2020 A.Ribon (run-V10-06-04)
|
||||
- G4VPhysicsConstructor.cc : added in the constructors an harmless call
|
||||
to G4HadronicParameters (setting a default parameter), needed to create
|
||||
the instance of the G4HadronicParameters singleton before run
|
||||
initialization.
|
||||
|
||||
May 8th, 2020 J. Madsen (run-V10-06-03)
|
||||
- Applied clang-format
|
||||
|
||||
April 9th, 2020 M.Asai (run-V10-06-02)
|
||||
- G4RunManager.cc, G4WorkerRunManager.cc: Adding layered mass geometry
|
||||
option for the new "probe" scoring mesh.
|
||||
|
||||
February 18th, 2020 V.Ivanchenko (run-V10-06-01)
|
||||
- G4RunManager - does not call G4ParticleTable for Messenger
|
||||
deletion
|
||||
|
||||
December 9th, 2019 B. Morgan (run-V10-06-00)
|
||||
- Cleanup CMake build, removing obsolete granular library option and
|
||||
explicit include_directories.
|
||||
|
||||
November 22nd, 2019 J. Madsen (run-V10-05-11)
|
||||
- Updated sources.cmake to use ${timemory_LIBRARIES} instead of
|
||||
difficult to type ${TiMemory_LIBRARIES}
|
||||
|
||||
@@ -34,37 +34,48 @@
|
||||
//
|
||||
// CHANGE HISTORY
|
||||
// --------------
|
||||
// ChangeHistory:
|
||||
// 10-01-2007 creation by L. Desorgher
|
||||
// 1-11-2009 Splitting of G4AdjointPrimaryGeneratorAction in two classes G4AdjointPrimaryGeneratorAction and G4AdjointPrimaryGenerator L.Desorgher
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
//
|
||||
// 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"
|
||||
#include"G4ThreeVector.hh"
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <iterator>
|
||||
#include <map>
|
||||
#include <vector>
|
||||
|
||||
class G4AdjointPosOnPhysVolGenerator;
|
||||
class G4ParticleGun;
|
||||
@@ -76,79 +87,95 @@ class G4ParticleDefinition;
|
||||
//
|
||||
class G4AdjointPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
|
||||
{
|
||||
public: //constructor, destructor
|
||||
public: // constructor, destructor
|
||||
G4AdjointPrimaryGeneratorAction();
|
||||
~G4AdjointPrimaryGeneratorAction();
|
||||
|
||||
G4AdjointPrimaryGeneratorAction();
|
||||
~G4AdjointPrimaryGeneratorAction();
|
||||
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];
|
||||
}
|
||||
|
||||
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];}
|
||||
private: // private methods
|
||||
G4double ComputeEnergyDistWeight(G4double energy, G4double E1, G4double E2);
|
||||
|
||||
private: //private methods
|
||||
private: // attributes
|
||||
G4String rndmFlag; // flag for a rndm impact point
|
||||
|
||||
G4double ComputeEnergyDistWeight(G4double energy, G4double E1, G4double E2);
|
||||
|
||||
private: //attributes
|
||||
|
||||
G4String rndmFlag; //flag for a rndm impact point
|
||||
|
||||
//The generator of primary vertex except for weight
|
||||
G4AdjointPrimaryGenerator* theAdjointPrimaryGenerator;
|
||||
|
||||
//Emin and Emax energies of the adjoint source
|
||||
//---------------------------------------------
|
||||
G4double Emin;
|
||||
G4double Emax;
|
||||
G4double EminIon;
|
||||
G4double EmaxIon;
|
||||
// The generator of primary vertex except for weight
|
||||
G4AdjointPrimaryGenerator* theAdjointPrimaryGenerator;
|
||||
|
||||
//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
|
||||
// Emin and Emax energies of the adjoint source
|
||||
//---------------------------------------------
|
||||
G4double Emin;
|
||||
G4double Emax;
|
||||
G4double EminIon;
|
||||
G4double EmaxIon;
|
||||
|
||||
// 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
|
||||
|
||||
size_t index_particle;
|
||||
size_t index_particle;
|
||||
|
||||
G4ThreeVector pos, direction, p;
|
||||
|
||||
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;
|
||||
|
||||
//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&);
|
||||
G4ThreeVector pos, direction, p;
|
||||
|
||||
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;
|
||||
|
||||
// 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&);
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -34,101 +34,134 @@
|
||||
//
|
||||
// CHANGE HISTORY
|
||||
// --------------
|
||||
// ChangeHistory:
|
||||
// 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
|
||||
//
|
||||
//
|
||||
// -01-11-2009 Add the possibility to use user defined run, event, tracking,
|
||||
// stepping, and stacking actions during the adjoint tracking phase. L.
|
||||
// Desorgher
|
||||
//
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------
|
||||
// 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.
|
||||
// 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 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 in another type of adjoint paticle. During the reverse tracking the
|
||||
// G4SimulationManager replaces the user defined Primary, Run, ... actions, by its own actions.
|
||||
//
|
||||
// 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
|
||||
// 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.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// 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().
|
||||
// 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.
|
||||
//
|
||||
// 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().
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// G4bool GetAdjointSimMode() that return true if an adjoint
|
||||
//simulation
|
||||
// is running and false if not!
|
||||
//
|
||||
// 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
|
||||
//
|
||||
// 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 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
|
||||
//
|
||||
// G4AdjointSimManager* theAdjSimManager = G4AdjointSimManager::GetInstance();
|
||||
// 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
|
||||
// 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
|
||||
//
|
||||
// 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
|
||||
// //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 ....
|
||||
// }
|
||||
// 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.
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
|
||||
#ifndef G4AdjointSimManager_h
|
||||
#define G4AdjointSimManager_h 1
|
||||
#include "globals.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include <vector>
|
||||
#include "G4UserRunAction.hh"
|
||||
#include "globals.hh"
|
||||
#include <vector>
|
||||
|
||||
class G4UserEventAction;
|
||||
class G4VUserPrimaryGeneratorAction;
|
||||
@@ -146,214 +179,218 @@ class G4AdjointSimMessenger;
|
||||
class G4PhysicsLogVector;
|
||||
class G4Run;
|
||||
|
||||
class G4AdjointSimManager: public G4UserRunAction
|
||||
class G4AdjointSimManager : public G4UserRunAction
|
||||
{
|
||||
public:
|
||||
|
||||
static G4AdjointSimManager* GetInstance();
|
||||
public:
|
||||
static G4AdjointSimManager* GetInstance();
|
||||
|
||||
public: //public methods
|
||||
|
||||
virtual void BeginOfRunAction(const G4Run* aRun);
|
||||
virtual void EndOfRunAction(const G4Run* aRun);
|
||||
void RunAdjointSimulation(G4int nb_evt);
|
||||
|
||||
inline G4int GetNbEvtOfLastRun(){return nb_evt_of_last_run;}
|
||||
|
||||
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
|
||||
public: // public methods
|
||||
virtual void BeginOfRunAction(const G4Run* aRun);
|
||||
virtual void EndOfRunAction(const G4Run* aRun);
|
||||
void RunAdjointSimulation(G4int nb_evt);
|
||||
|
||||
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();
|
||||
inline G4int GetNbEvtOfLastRun() { return nb_evt_of_last_run; }
|
||||
|
||||
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
|
||||
|
||||
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();
|
||||
|
||||
|
||||
std::vector<G4ParticleDefinition*>* GetListOfPrimaryFwdParticles();
|
||||
size_t GetNbOfPrimaryFwdParticles();
|
||||
|
||||
G4bool DefineSphericalExtSource(G4double radius, G4ThreeVector pos);
|
||||
G4bool DefineSphericalExtSourceWithCentreAtTheCentreOfAVolume(G4double radius, const G4String& volume_name);
|
||||
G4bool DefineExtSourceOnTheExtSurfaceOfAVolume(const G4String& volume_name);
|
||||
void SetExtSourceEmax(G4double Emax);
|
||||
|
||||
//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();
|
||||
|
||||
inline void SetNormalisationMode(G4int n){normalisation_mode=n;};
|
||||
G4int GetNormalisationMode(){return normalisation_mode;};
|
||||
G4double GetNumberNucleonsInIon(){return nb_nuc;};
|
||||
std::vector<G4ParticleDefinition*>* GetListOfPrimaryFwdParticles();
|
||||
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);
|
||||
|
||||
//Set methods for user run actions
|
||||
//--------------------------------
|
||||
inline void UseUserStackingActionInFwdTrackingPhase(G4bool aBool){use_user_StackingAction=aBool;}
|
||||
inline void UseUserTrackingActionInFwdTrackingPhase(G4bool aBool){use_user_TrackingAction=aBool;}
|
||||
G4bool DefineSphericalExtSource(G4double radius, G4ThreeVector pos);
|
||||
G4bool DefineSphericalExtSourceWithCentreAtTheCentreOfAVolume(
|
||||
G4double radius, const G4String& volume_name);
|
||||
G4bool DefineExtSourceOnTheExtSurfaceOfAVolume(const G4String& volume_name);
|
||||
void SetExtSourceEmax(G4double Emax);
|
||||
|
||||
// Definition of adjoint source
|
||||
//----------------------------
|
||||
|
||||
//Set nb of primary fwd gamma
|
||||
//---------------------------
|
||||
void SetNbOfPrimaryFwdGammasPerEvent(G4int);
|
||||
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();
|
||||
|
||||
inline void SetNormalisationMode(G4int n) { normalisation_mode = n; };
|
||||
G4int GetNormalisationMode() { return normalisation_mode; };
|
||||
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;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
static G4ThreadLocal G4AdjointSimManager* instance;
|
||||
|
||||
// Set nb of primary fwd gamma
|
||||
//---------------------------
|
||||
void SetNbOfPrimaryFwdGammasPerEvent(G4int);
|
||||
|
||||
private: // methods
|
||||
|
||||
void SetRestOfAdjointActions();
|
||||
void SetAdjointPrimaryRunAndStackingActions();
|
||||
void SetAdjointActions();
|
||||
void ResetRestOfUserActions();
|
||||
void ResetUserPrimaryRunAndStackingActions();
|
||||
void ResetUserActions();
|
||||
void DefineUserActions();
|
||||
public:
|
||||
void SwitchToAdjointSimulationMode();
|
||||
void BackToFwdSimulationMode();
|
||||
|
||||
|
||||
private: //constructor and destructor
|
||||
|
||||
G4AdjointSimManager();
|
||||
~G4AdjointSimManager();
|
||||
|
||||
private ://attributes
|
||||
|
||||
//Messenger
|
||||
//----------
|
||||
G4AdjointSimMessenger* theMessenger;
|
||||
|
||||
//user defined actions for the normal fwd simulation. Taken from the G4RunManager
|
||||
// Set nb of adjoint primaries for reverse splitting
|
||||
//-------------------------------------------------
|
||||
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;
|
||||
|
||||
//action for adjoint simulation
|
||||
void SetNbAdjointPrimaryGammasPerEvent(G4int);
|
||||
void SetNbAdjointPrimaryElectronsPerEvent(G4int);
|
||||
|
||||
// Convergence test
|
||||
//-----------------------
|
||||
/*
|
||||
void RegisterSignalForConvergenceTest(G4double aSignal);
|
||||
void DefineExponentialPrimarySpectrumForConvergenceTest(G4ParticleDefinition*
|
||||
aPartDef, G4double E0); void
|
||||
DefinePowerLawPrimarySpectrumForConvergenceTest(G4ParticleDefinition*
|
||||
aPartDef, G4double alpha);
|
||||
|
||||
*/
|
||||
|
||||
private:
|
||||
static G4ThreadLocal G4AdjointSimManager* instance;
|
||||
|
||||
private: // methods
|
||||
void SetRestOfAdjointActions();
|
||||
void SetAdjointPrimaryRunAndStackingActions();
|
||||
void SetAdjointActions();
|
||||
void ResetRestOfUserActions();
|
||||
void ResetUserPrimaryRunAndStackingActions();
|
||||
void ResetUserActions();
|
||||
void DefineUserActions();
|
||||
|
||||
public:
|
||||
void SwitchToAdjointSimulationMode();
|
||||
void BackToFwdSimulationMode();
|
||||
|
||||
private: // constructor and destructor
|
||||
G4AdjointSimManager();
|
||||
~G4AdjointSimManager();
|
||||
|
||||
private: // attributes
|
||||
// Messenger
|
||||
//----------
|
||||
G4AdjointSimMessenger* theMessenger;
|
||||
|
||||
// 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;
|
||||
|
||||
// action for adjoint simulation
|
||||
//-----------------------------
|
||||
G4UserRunAction* theAdjointRunAction;
|
||||
G4UserEventAction* theAdjointEventAction;
|
||||
G4AdjointPrimaryGeneratorAction* theAdjointPrimaryGeneratorAction;
|
||||
G4AdjointTrackingAction* theAdjointTrackingAction;
|
||||
G4AdjointSteppingAction* theAdjointSteppingAction;
|
||||
G4AdjointStackingAction* theAdjointStackingAction;
|
||||
|
||||
//adjoint mode
|
||||
G4UserRunAction* theAdjointRunAction;
|
||||
G4UserEventAction* theAdjointEventAction;
|
||||
G4AdjointPrimaryGeneratorAction* theAdjointPrimaryGeneratorAction;
|
||||
G4AdjointTrackingAction* theAdjointTrackingAction;
|
||||
G4AdjointSteppingAction* theAdjointSteppingAction;
|
||||
G4AdjointStackingAction* theAdjointStackingAction;
|
||||
|
||||
// adjoint mode
|
||||
//-------------
|
||||
G4bool adjoint_tracking_mode;
|
||||
G4bool adjoint_sim_mode;
|
||||
G4bool adjoint_tracking_mode;
|
||||
G4bool adjoint_sim_mode;
|
||||
|
||||
//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;
|
||||
// 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;
|
||||
|
||||
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;
|
||||
|
||||
G4int nb_evt_of_last_run;
|
||||
G4int normalisation_mode;
|
||||
|
||||
|
||||
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;
|
||||
|
||||
G4int nb_evt_of_last_run;
|
||||
G4int normalisation_mode;
|
||||
|
||||
//Adjoint source
|
||||
// Adjoint source
|
||||
//--------------
|
||||
G4double area_of_the_adjoint_source;
|
||||
G4double nb_nuc;
|
||||
G4double theAdjointPrimaryWeight;
|
||||
G4double area_of_the_adjoint_source;
|
||||
G4double nb_nuc;
|
||||
G4double theAdjointPrimaryWeight;
|
||||
|
||||
//Weight Analysis
|
||||
//----------
|
||||
/*G4PhysicsLogVector* electron_last_weight_vector;
|
||||
G4PhysicsLogVector* proton_last_weight_vector;
|
||||
G4PhysicsLogVector* gamma_last_weight_vector;*/
|
||||
|
||||
G4bool welcome_message;
|
||||
|
||||
/* 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, ;
|
||||
G4ParticleDefinition* the_par_def_for_convergence_test;
|
||||
*/
|
||||
|
||||
// Weight Analysis
|
||||
//----------
|
||||
/*G4PhysicsLogVector* electron_last_weight_vector;
|
||||
G4PhysicsLogVector* proton_last_weight_vector;
|
||||
G4PhysicsLogVector* gamma_last_weight_vector;*/
|
||||
|
||||
G4bool welcome_message;
|
||||
|
||||
/* 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, ;
|
||||
G4ParticleDefinition* the_par_def_for_convergence_test;
|
||||
*/
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -34,78 +34,102 @@
|
||||
//
|
||||
// CHANGE HISTORY
|
||||
// --------------
|
||||
// ChangeHistory:
|
||||
// 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
|
||||
//
|
||||
// -November-December 2009 Some cleaning and adaptation for the first Release
|
||||
//in the
|
||||
// Geant4 toolkit, L. Desorgher
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------
|
||||
// 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
|
||||
// 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
|
||||
// -/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:
|
||||
// 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)
|
||||
//
|
||||
// -/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
|
||||
// The external source is set on a sphere with radius R and centered on
|
||||
// position (X,Y,Z)
|
||||
//
|
||||
// -/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:
|
||||
// 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
|
||||
// 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
|
||||
//
|
||||
// -/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)
|
||||
//
|
||||
//
|
||||
// -/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)
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef G4AdjointSimMessenger_h
|
||||
#define G4AdjointSimMessenger_h 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4UImessenger.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class G4AdjointSimManager;
|
||||
class G4UIdirectory;
|
||||
@@ -124,53 +148,50 @@ class G4MTAdjointSimManager;
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
class G4AdjointSimMessenger: public G4UImessenger
|
||||
class G4AdjointSimMessenger : public G4UImessenger
|
||||
{
|
||||
public:
|
||||
G4AdjointSimMessenger(G4AdjointSimManager* );
|
||||
/*
|
||||
#ifdef G4MULTITHREADED
|
||||
G4AdjointSimMessenger(G4MTAdjointSimManager* );
|
||||
#endif
|
||||
*/
|
||||
public:
|
||||
G4AdjointSimMessenger(G4AdjointSimManager*);
|
||||
/*
|
||||
#ifdef G4MULTITHREADED
|
||||
G4AdjointSimMessenger(G4MTAdjointSimManager* );
|
||||
#endif
|
||||
*/
|
||||
|
||||
~G4AdjointSimMessenger();
|
||||
|
||||
void SetNewValue(G4UIcommand*, G4String);
|
||||
|
||||
private:
|
||||
G4AdjointSimManager* theAdjointRunManager;
|
||||
/*
|
||||
#ifdef G4MULTITHREADED
|
||||
G4MTAdjointSimManager* theMTAdjointRunManager;
|
||||
#endif
|
||||
*/
|
||||
|
||||
G4UIdirectory* AdjointSimDir;
|
||||
G4UIcommand * beamOnCmd;
|
||||
|
||||
G4UIcommand * DefineSpherExtSourceCmd;
|
||||
G4UIcommand * DefineSpherExtSourceCenteredOnAVolumeCmd;
|
||||
G4UIcmdWithAString * DefineExtSourceOnAVolumeExtSurfaceCmd;
|
||||
G4UIcmdWithADoubleAndUnit* setExtSourceEMaxCmd;
|
||||
|
||||
G4UIcommand * DefineSpherAdjSourceCmd;
|
||||
G4UIcommand * DefineSpherAdjSourceCenteredOnAVolumeCmd;
|
||||
G4UIcmdWithAString * DefineAdjSourceOnAVolumeExtSurfaceCmd;
|
||||
|
||||
G4UIcmdWithADoubleAndUnit* setAdjSourceEminCmd;
|
||||
G4UIcmdWithADoubleAndUnit* setAdjSourceEmaxCmd;
|
||||
~G4AdjointSimMessenger();
|
||||
|
||||
|
||||
G4UIcmdWithAString* ConsiderParticleAsPrimaryCmd;
|
||||
G4UIcmdWithAString* NeglectParticleAsPrimaryCmd;
|
||||
void SetNewValue(G4UIcommand*, G4String);
|
||||
|
||||
G4UIcmdWithAnInteger* setNbOfPrimaryFwdGammasPerEventCmd;
|
||||
G4UIcmdWithAnInteger* setNbOfPrimaryAdjGammasPerEventCmd;
|
||||
G4UIcmdWithAnInteger* setNbOfPrimaryAdjElectronsPerEventCmd;
|
||||
private:
|
||||
G4AdjointSimManager* theAdjointRunManager;
|
||||
/*
|
||||
#ifdef G4MULTITHREADED
|
||||
G4MTAdjointSimManager* theMTAdjointRunManager;
|
||||
#endif
|
||||
*/
|
||||
|
||||
G4UIdirectory* AdjointSimDir;
|
||||
G4UIcommand* beamOnCmd;
|
||||
|
||||
G4UIcommand* DefineSpherExtSourceCmd;
|
||||
G4UIcommand* DefineSpherExtSourceCenteredOnAVolumeCmd;
|
||||
G4UIcmdWithAString* DefineExtSourceOnAVolumeExtSurfaceCmd;
|
||||
G4UIcmdWithADoubleAndUnit* setExtSourceEMaxCmd;
|
||||
|
||||
G4UIcommand* DefineSpherAdjSourceCmd;
|
||||
G4UIcommand* DefineSpherAdjSourceCenteredOnAVolumeCmd;
|
||||
G4UIcmdWithAString* DefineAdjSourceOnAVolumeExtSurfaceCmd;
|
||||
|
||||
G4UIcmdWithADoubleAndUnit* setAdjSourceEminCmd;
|
||||
G4UIcmdWithADoubleAndUnit* setAdjSourceEmaxCmd;
|
||||
|
||||
G4UIcmdWithAString* ConsiderParticleAsPrimaryCmd;
|
||||
G4UIcmdWithAString* NeglectParticleAsPrimaryCmd;
|
||||
|
||||
G4UIcmdWithAnInteger* setNbOfPrimaryFwdGammasPerEventCmd;
|
||||
G4UIcmdWithAnInteger* setNbOfPrimaryAdjGammasPerEventCmd;
|
||||
G4UIcmdWithAnInteger* setNbOfPrimaryAdjElectronsPerEventCmd;
|
||||
};
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
//
|
||||
// ---------------- G4ExceptionHandler ----------------
|
||||
@@ -39,8 +39,8 @@
|
||||
// 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
|
||||
// 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.
|
||||
|
||||
// ------------------------------------------------------------
|
||||
@@ -48,37 +48,32 @@
|
||||
#ifndef G4ExceptionHandler_h
|
||||
#define G4ExceptionHandler_h 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4VExceptionHandler.hh"
|
||||
#include "G4ExceptionSeverity.hh"
|
||||
#include "G4VExceptionHandler.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class G4ExceptionHandler : public G4VExceptionHandler
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
public:
|
||||
G4ExceptionHandler();
|
||||
virtual ~G4ExceptionHandler();
|
||||
G4bool operator==(const G4ExceptionHandler &right) const;
|
||||
G4bool operator!=(const G4ExceptionHandler &right) const;
|
||||
|
||||
public: // with description
|
||||
G4bool operator==(const G4ExceptionHandler& right) const;
|
||||
G4bool operator!=(const G4ExceptionHandler& right) const;
|
||||
|
||||
public: // with description
|
||||
virtual G4bool Notify(const char* originOfException,
|
||||
const char* exceptionCode,
|
||||
G4ExceptionSeverity severity,
|
||||
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.
|
||||
// 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.
|
||||
|
||||
private:
|
||||
private:
|
||||
G4ExceptionHandler(const G4ExceptionHandler& right);
|
||||
G4ExceptionHandler& operator=(const G4ExceptionHandler& right);
|
||||
|
||||
G4ExceptionHandler(const G4ExceptionHandler &right);
|
||||
G4ExceptionHandler& operator=(const G4ExceptionHandler &right);
|
||||
|
||||
private:
|
||||
private:
|
||||
void DumpTrackInfo();
|
||||
};
|
||||
|
||||
|
||||
@@ -31,10 +31,9 @@
|
||||
//
|
||||
|
||||
//////////////////////
|
||||
//G4MSSteppingAction
|
||||
// G4MSSteppingAction
|
||||
/////////////////////
|
||||
|
||||
|
||||
#ifndef G4MSSteppingAction_h
|
||||
#define G4MSSteppingAction_h 1
|
||||
|
||||
@@ -45,24 +44,24 @@ class G4Region;
|
||||
|
||||
class G4MSSteppingAction : public G4UserSteppingAction
|
||||
{
|
||||
public:
|
||||
G4MSSteppingAction();
|
||||
virtual ~G4MSSteppingAction();
|
||||
public:
|
||||
G4MSSteppingAction();
|
||||
virtual ~G4MSSteppingAction();
|
||||
|
||||
void Initialize(G4bool rSens,G4Region* reg);
|
||||
virtual void UserSteppingAction(const G4Step*);
|
||||
void Initialize(G4bool rSens, G4Region* reg);
|
||||
virtual void UserSteppingAction(const G4Step*);
|
||||
|
||||
private:
|
||||
G4bool regionSensitive;
|
||||
G4Region* theRegion;
|
||||
G4double length;
|
||||
G4double x0;
|
||||
G4double lambda;
|
||||
private:
|
||||
G4bool regionSensitive;
|
||||
G4Region* theRegion;
|
||||
G4double length;
|
||||
G4double x0;
|
||||
G4double lambda;
|
||||
|
||||
public:
|
||||
inline G4double GetTotalStepLength() const { return length; }
|
||||
inline G4double GetX0() const { return x0; }
|
||||
inline G4double GetLambda0() const { return lambda; }
|
||||
public:
|
||||
inline G4double GetTotalStepLength() const { return length; }
|
||||
inline G4double GetX0() const { return x0; }
|
||||
inline G4double GetLambda0() const { return lambda; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -34,10 +34,10 @@
|
||||
#ifndef G4MTRunManager_h
|
||||
#define G4MTRunManager_h 1
|
||||
|
||||
#include "G4MTBarrier.hh"
|
||||
#include "G4RNGHelper.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4Threading.hh"
|
||||
#include "G4RNGHelper.hh"
|
||||
#include "G4MTBarrier.hh"
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
@@ -46,221 +46,242 @@ class G4ScoringManager;
|
||||
class G4UserWorkerInitialization;
|
||||
class G4UserWorkerThreadInitialization;
|
||||
|
||||
//TODO: Split random number storage from this class
|
||||
// TODO: Split random number storage from this class
|
||||
|
||||
class G4MTRunManager : public G4RunManager {
|
||||
public:
|
||||
G4MTRunManager();
|
||||
virtual ~G4MTRunManager();
|
||||
//New method
|
||||
void SetNumberOfThreads( G4int n );
|
||||
G4int GetNumberOfThreads() const { return nworkers; }
|
||||
void SetPinAffinity(G4int n=1);
|
||||
G4int GetPinAffinity() const { return pinAffinity; }
|
||||
public:
|
||||
class G4MTRunManager : public G4RunManager
|
||||
{
|
||||
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; }
|
||||
|
||||
//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);
|
||||
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() {}
|
||||
|
||||
//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();
|
||||
// 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();
|
||||
|
||||
//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);
|
||||
|
||||
//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 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.
|
||||
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:
|
||||
// Number of worker threads. To be set by SetNumberOfThreads() method.
|
||||
G4int nworkers;
|
||||
// Force to use this number regardless of SetNumberOfThreads() method.
|
||||
G4int forcedNwokers;
|
||||
// Pin Affinity parameter
|
||||
G4int pinAffinity;
|
||||
// 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);
|
||||
|
||||
//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
|
||||
// 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 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();
|
||||
|
||||
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() { return masterScM; }
|
||||
static masterWorlds_t& GetMasterWorlds() { return masterWorlds; }
|
||||
static void addWorld( G4int counter, G4VPhysicalVolume* w) { masterWorlds.insert( std::make_pair(counter,w) ); }
|
||||
const CLHEP::HepRandomEngine* getMasterRandomEngine() const { return masterRNGEngine; }
|
||||
private:
|
||||
//Handling of master thread scoring worlds, access to it is needed by workers
|
||||
static G4ScoringManager* masterScM;
|
||||
static masterWorlds_t masterWorlds;
|
||||
//Singleton implementing master thread behavior
|
||||
static G4MTRunManager* fMasterRM;
|
||||
G4MTRunManagerKernel* MTkernel;
|
||||
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
|
||||
protected:
|
||||
// Number of worker threads. To be set by SetNumberOfThreads() method.
|
||||
G4int nworkers;
|
||||
// Force to use this number regardless of SetNumberOfThreads() method.
|
||||
G4int forcedNwokers;
|
||||
|
||||
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);
|
||||
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
|
||||
|
||||
public:
|
||||
// To be invoked solely from G4WorkerRunManager to merge the results
|
||||
void MergeScores(const G4ScoringManager* localScoringManager);
|
||||
void MergeRun(const G4Run* localRun);
|
||||
|
||||
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 );
|
||||
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);
|
||||
|
||||
protected:
|
||||
G4int eventModuloDef;
|
||||
G4int eventModulo;
|
||||
G4int nSeedsUsed;
|
||||
G4int nSeedsFilled;
|
||||
G4int nSeedsMax;
|
||||
G4int nSeedsPerEvent;
|
||||
double* randDbl;
|
||||
const CLHEP::HepRandomEngine* getMasterRandomEngine() const
|
||||
{
|
||||
return masterRNGEngine;
|
||||
}
|
||||
|
||||
void RefillSeeds();
|
||||
private:
|
||||
// Handling of master thread scoring worlds, access to it is needed by workers
|
||||
static G4ScoringManager* masterScM;
|
||||
static masterWorlds_t masterWorlds;
|
||||
// Singleton implementing master thread behavior
|
||||
static G4MTRunManager* fMasterRM;
|
||||
G4MTRunManagerKernel* MTkernel;
|
||||
|
||||
public:
|
||||
inline void SetEventModulo(G4int i=1) { eventModuloDef = i; }
|
||||
inline G4int GetEventModulo() const { return eventModuloDef; }
|
||||
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
|
||||
|
||||
public:
|
||||
virtual void AbortRun(G4bool softAbort=false);
|
||||
virtual void AbortEvent();
|
||||
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);
|
||||
|
||||
protected:
|
||||
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() { return seedOncePerCommunication; }
|
||||
static void SetSeedOncePerCommunication(G4int val) { seedOncePerCommunication = val; }
|
||||
protected:
|
||||
//Barriers: synch points between master and workers
|
||||
G4MTBarrier beginOfEventLoopBarrier;
|
||||
G4MTBarrier endOfEventLoopBarrier;
|
||||
G4MTBarrier nextActionRequestBarrier;
|
||||
G4MTBarrier processUIBarrier;
|
||||
public:
|
||||
// To be invoked solely from G4WorkerRunManager to merge the results
|
||||
void MergeScores(const G4ScoringManager* localScoringManager);
|
||||
void MergeRun(const G4Run* localRun);
|
||||
|
||||
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);
|
||||
|
||||
protected:
|
||||
G4int eventModuloDef;
|
||||
G4int eventModulo;
|
||||
G4int nSeedsUsed;
|
||||
G4int nSeedsFilled;
|
||||
G4int nSeedsMax;
|
||||
G4int nSeedsPerEvent;
|
||||
double* randDbl;
|
||||
|
||||
virtual void RefillSeeds();
|
||||
|
||||
public:
|
||||
inline void SetEventModulo(G4int i = 1) { eventModuloDef = i; }
|
||||
inline G4int GetEventModulo() const { return eventModuloDef; }
|
||||
|
||||
public:
|
||||
virtual void AbortRun(G4bool softAbort = false);
|
||||
virtual void AbortEvent();
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
#endif //G4MTRunManager_h
|
||||
#endif // G4MTRunManager_h
|
||||
|
||||
@@ -54,46 +54,49 @@
|
||||
#ifndef G4MTRunManagerKernel_h
|
||||
#define G4MTRunManagerKernel_h 1
|
||||
|
||||
#include "G4MTRunManager.hh"
|
||||
#include "G4RunManagerKernel.hh"
|
||||
#include "G4Threading.hh"
|
||||
#include "G4MTRunManager.hh"
|
||||
|
||||
class G4WorkerThread;
|
||||
class G4WorkerRunManager;
|
||||
#include <vector>
|
||||
|
||||
class G4MTRunManagerKernel : public G4RunManagerKernel {
|
||||
public:
|
||||
G4MTRunManagerKernel();
|
||||
virtual ~G4MTRunManagerKernel();
|
||||
protected:
|
||||
void SetupShadowProcess() const;
|
||||
class G4MTRunManagerKernel : public G4RunManagerKernel
|
||||
{
|
||||
public:
|
||||
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);
|
||||
protected:
|
||||
void SetupShadowProcess() const;
|
||||
|
||||
//private:
|
||||
// static void ReinitializeGeometry();
|
||||
private:
|
||||
static G4ThreadLocal G4WorkerThread* wThreadContext;
|
||||
public:
|
||||
static G4WorkerThread* GetWorkerThread();
|
||||
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);
|
||||
|
||||
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();
|
||||
// private:
|
||||
// static void ReinitializeGeometry();
|
||||
private:
|
||||
static G4ThreadLocal G4WorkerThread* wThreadContext;
|
||||
|
||||
private:
|
||||
static std::vector<G4WorkerRunManager*>* workerRMvector;
|
||||
public:
|
||||
static G4WorkerThread* GetWorkerThread();
|
||||
|
||||
public:
|
||||
// This method should be invoked by G4MTRunManager
|
||||
void BroadcastAbortRun(G4bool softAbort);
|
||||
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();
|
||||
|
||||
private:
|
||||
static std::vector<G4WorkerRunManager*>* workerRMvector;
|
||||
|
||||
public:
|
||||
// This method should be invoked by G4MTRunManager
|
||||
void BroadcastAbortRun(G4bool softAbort);
|
||||
};
|
||||
|
||||
#endif //G4MTRunManagerKernel_h
|
||||
#endif // G4MTRunManagerKernel_h
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
// class description:
|
||||
//
|
||||
|
||||
|
||||
#ifndef G4MatScanMessenger_HH
|
||||
#define G4MatScanMessenger_HH 1
|
||||
|
||||
@@ -46,28 +45,25 @@ class G4MaterialScanner;
|
||||
|
||||
class G4MatScanMessenger : public G4UImessenger
|
||||
{
|
||||
public:
|
||||
G4MatScanMessenger(G4MaterialScanner* p1);
|
||||
virtual ~G4MatScanMessenger();
|
||||
|
||||
virtual G4String GetCurrentValue(G4UIcommand * command);
|
||||
virtual void SetNewValue(G4UIcommand * command,G4String newValue);
|
||||
public:
|
||||
G4MatScanMessenger(G4MaterialScanner* p1);
|
||||
virtual ~G4MatScanMessenger();
|
||||
|
||||
private:
|
||||
G4MaterialScanner* theScanner;
|
||||
|
||||
G4UIdirectory* msDirectory;
|
||||
G4UIcmdWithoutParameter* scanCmd;
|
||||
G4UIcommand* thetaCmd;
|
||||
G4UIcommand* phiCmd;
|
||||
G4UIcommand* singleCmd;
|
||||
G4UIcmdWith3Vector* single2Cmd;
|
||||
G4UIcmdWithABool* regSenseCmd;
|
||||
G4UIcmdWithAString* regionCmd;
|
||||
G4UIcmdWith3VectorAndUnit* eyePosCmd;
|
||||
virtual G4String GetCurrentValue(G4UIcommand* command);
|
||||
virtual void SetNewValue(G4UIcommand* command, G4String newValue);
|
||||
|
||||
private:
|
||||
G4MaterialScanner* theScanner;
|
||||
|
||||
G4UIdirectory* msDirectory;
|
||||
G4UIcmdWithoutParameter* scanCmd;
|
||||
G4UIcommand* thetaCmd;
|
||||
G4UIcommand* phiCmd;
|
||||
G4UIcommand* singleCmd;
|
||||
G4UIcmdWith3Vector* single2Cmd;
|
||||
G4UIcmdWithABool* regSenseCmd;
|
||||
G4UIcmdWithAString* regionCmd;
|
||||
G4UIcmdWith3VectorAndUnit* eyePosCmd;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
#ifndef G4MaterialScanner_H
|
||||
#define G4MaterialScanner_H 1
|
||||
|
||||
@@ -36,8 +35,8 @@
|
||||
// G4MaterialScanner
|
||||
//
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class G4Event;
|
||||
class G4EventManager;
|
||||
@@ -52,74 +51,73 @@ class G4Region;
|
||||
|
||||
class G4MaterialScanner
|
||||
{
|
||||
public: // with description
|
||||
G4MaterialScanner();
|
||||
public: // with description
|
||||
G4MaterialScanner();
|
||||
|
||||
public:
|
||||
~G4MaterialScanner();
|
||||
public:
|
||||
~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.
|
||||
public: // with description
|
||||
void Scan();
|
||||
// The main entry point which triggers ray tracing.
|
||||
// This method is available only if Geant4 is at Idle state.
|
||||
|
||||
private:
|
||||
void DoScan();
|
||||
// Event loop
|
||||
void StoreUserActions();
|
||||
void RestoreUserActions();
|
||||
// Store and restore user action classes if defined
|
||||
private:
|
||||
void DoScan();
|
||||
// Event loop
|
||||
void StoreUserActions();
|
||||
void RestoreUserActions();
|
||||
// Store and restore user action classes if defined
|
||||
|
||||
private:
|
||||
G4RayShooter * theRayShooter;
|
||||
G4MatScanMessenger * theMessenger;
|
||||
private:
|
||||
G4RayShooter* theRayShooter;
|
||||
G4MatScanMessenger* theMessenger;
|
||||
|
||||
G4EventManager * theEventManager;
|
||||
G4EventManager* theEventManager;
|
||||
|
||||
G4UserEventAction * theUserEventAction;
|
||||
G4UserStackingAction * theUserStackingAction;
|
||||
G4UserTrackingAction * theUserTrackingAction;
|
||||
G4UserSteppingAction * theUserSteppingAction;
|
||||
G4UserEventAction* theUserEventAction;
|
||||
G4UserStackingAction* theUserStackingAction;
|
||||
G4UserTrackingAction* theUserTrackingAction;
|
||||
G4UserSteppingAction* theUserSteppingAction;
|
||||
|
||||
G4UserEventAction * theMatScannerEventAction;
|
||||
G4UserStackingAction * theMatScannerStackingAction;
|
||||
G4UserTrackingAction * theMatScannerTrackingAction;
|
||||
G4MSSteppingAction * theMatScannerSteppingAction;
|
||||
G4UserEventAction* theMatScannerEventAction;
|
||||
G4UserStackingAction* theMatScannerStackingAction;
|
||||
G4UserTrackingAction* theMatScannerTrackingAction;
|
||||
G4MSSteppingAction* theMatScannerSteppingAction;
|
||||
|
||||
G4ThreeVector eyePosition;
|
||||
G4int nTheta;
|
||||
G4double thetaMin;
|
||||
G4double thetaSpan;
|
||||
G4int nPhi;
|
||||
G4double phiMin;
|
||||
G4double phiSpan;
|
||||
G4ThreeVector eyePosition;
|
||||
G4int nTheta;
|
||||
G4double thetaMin;
|
||||
G4double thetaSpan;
|
||||
G4int nPhi;
|
||||
G4double phiMin;
|
||||
G4double phiSpan;
|
||||
|
||||
G4ThreeVector eyeDirection;
|
||||
G4ThreeVector eyeDirection;
|
||||
|
||||
G4bool regionSensitive;
|
||||
G4String regionName;
|
||||
G4Region* theRegion;
|
||||
|
||||
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; }
|
||||
G4bool regionSensitive;
|
||||
G4String regionName;
|
||||
G4Region* theRegion;
|
||||
|
||||
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; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -54,23 +54,23 @@
|
||||
#define G4MULTIRUNACTION_HH_
|
||||
|
||||
#include "G4UserRunAction.hh"
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
using G4UserRunActionUPtr=std::unique_ptr<G4UserRunAction>;
|
||||
using G4UserRunActionVector=std::vector<G4UserRunActionUPtr>;
|
||||
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;
|
||||
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;
|
||||
|
||||
virtual void SetMaster(G4bool val = true) override;
|
||||
};
|
||||
|
||||
#endif /* SOURCE_RUN_INCLUDE_G4MULTIRUNACTION_HH_ */
|
||||
|
||||
@@ -39,33 +39,43 @@
|
||||
|
||||
#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.");;
|
||||
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");
|
||||
;
|
||||
}
|
||||
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
|
||||
|
||||
@@ -25,125 +25,117 @@
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
// 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 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
|
||||
// first version 29 Apr. 2011 by H.Kurashige
|
||||
// ------------------------------------------------------------
|
||||
|
||||
#ifndef G4PhysicsListHelper_h
|
||||
#define G4PhysicsListHelper_h 1
|
||||
#include "globals.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "globals.hh"
|
||||
#include <vector>
|
||||
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4PhysicsListOrderingParameter.hh"
|
||||
#include "G4PhysicsListOrderingParameter.hh"
|
||||
#include "G4ThreadLocalSingleton.hh"
|
||||
|
||||
class G4VProcess;
|
||||
|
||||
class G4PhysicsListHelper
|
||||
{
|
||||
friend class G4ThreadLocalSingleton<G4PhysicsListHelper>;
|
||||
|
||||
friend class G4ThreadLocalSingleton<G4PhysicsListHelper>;
|
||||
private:
|
||||
// Hide constructor and destructor
|
||||
G4PhysicsListHelper();
|
||||
~G4PhysicsListHelper();
|
||||
|
||||
private:
|
||||
// Hide constructor and destructor
|
||||
G4PhysicsListHelper();
|
||||
~G4PhysicsListHelper();
|
||||
public: // with description
|
||||
// This method gives the ponter to the physics list helper
|
||||
static G4PhysicsListHelper* GetPhysicsListHelper();
|
||||
|
||||
public: // with description
|
||||
// This method gives the ponter to the physics list helper
|
||||
static G4PhysicsListHelper* GetPhysicsListHelper();
|
||||
|
||||
//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);
|
||||
// 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);
|
||||
|
||||
// User must invoke this method in his ConstructProcess()
|
||||
// implementation in order to insures particle transportation.
|
||||
void AddTransportation();
|
||||
|
||||
// Set flag for using CoupledTransportation
|
||||
void UseCoupledTransportation(G4bool vl=true);
|
||||
// User must invoke this method in his ConstructProcess()
|
||||
// implementation in order to insures particle transportation.
|
||||
void AddTransportation();
|
||||
|
||||
// Set flag for using CoupledTransportation
|
||||
void UseCoupledTransportation(G4bool vl = true);
|
||||
|
||||
// Change the thresholds for killing looping tracks of the
|
||||
// transportation (simple or coupled.)
|
||||
void UseHighLooperThresholds() { theLooperThresholds = 2; }
|
||||
void UseLowLooperThresholds() { theLooperThresholds = 0; }
|
||||
|
||||
// Change the thresholds for killing looping tracks of the
|
||||
// transportation (simple or coupled.)
|
||||
void UseHighLooperThresholds() { theLooperThresholds= 2;}
|
||||
void UseLowLooperThresholds() { theLooperThresholds= 0;}
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
public:
|
||||
// check consistencies of list of particles
|
||||
void CheckParticleList() const;
|
||||
public:
|
||||
// check consistencies of list of particles
|
||||
void CheckParticleList() const;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
public:
|
||||
public:
|
||||
// Dump OrdingParameterTable
|
||||
void DumpOrdingParameterTable(G4int subType = -1) const;
|
||||
G4PhysicsListOrderingParameter GetOrdingParameter(G4int subType) const;
|
||||
void DumpOrdingParameterTable(G4int subType = -1) const;
|
||||
G4PhysicsListOrderingParameter GetOrdingParameter(G4int subType) const;
|
||||
|
||||
private:
|
||||
void ReadOrdingParameterTable();
|
||||
void ReadInDefaultOrderingParameter();
|
||||
private:
|
||||
void ReadOrdingParameterTable();
|
||||
void ReadInDefaultOrderingParameter();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
public: // with description
|
||||
void SetVerboseLevel(G4int value);
|
||||
G4int GetVerboseLevel() const;
|
||||
// set/get controle flag for output message
|
||||
// 0: Silent
|
||||
// 1: Warning message
|
||||
// 2: More
|
||||
public: // with description
|
||||
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:
|
||||
static G4ThreadLocal G4PhysicsListHelper* pPLHelper;
|
||||
|
||||
// the particle table has the complete List of existing particle types
|
||||
G4ParticleTable* theParticleTable;
|
||||
G4ParticleTable::G4PTblDicIterator* aParticleIterator;
|
||||
// the particle table has the complete List of existing particle types
|
||||
G4ParticleTable* theParticleTable;
|
||||
G4ParticleTable::G4PTblDicIterator* aParticleIterator;
|
||||
|
||||
G4bool useCoupledTransportation;
|
||||
G4int theLooperThresholds= 1; // 0 = Low, 1 = default, 2 = high
|
||||
G4VProcess* theTransportationProcess;
|
||||
|
||||
G4int verboseLevel;
|
||||
G4bool useCoupledTransportation;
|
||||
G4int theLooperThresholds = 1; // 0 = Low, 1 = default, 2 = high
|
||||
G4VProcess* theTransportationProcess;
|
||||
|
||||
private:
|
||||
typedef std::vector<G4PhysicsListOrderingParameter> G4OrdParamTable;
|
||||
G4OrdParamTable* theTable;
|
||||
G4int sizeOfTable;
|
||||
G4String ordParamFileName;
|
||||
G4int verboseLevel;
|
||||
|
||||
private:
|
||||
typedef std::vector<G4PhysicsListOrderingParameter> G4OrdParamTable;
|
||||
G4OrdParamTable* theTable;
|
||||
G4int sizeOfTable;
|
||||
G4String ordParamFileName;
|
||||
};
|
||||
|
||||
|
||||
inline
|
||||
void G4PhysicsListHelper::UseCoupledTransportation(G4bool vl)
|
||||
{
|
||||
useCoupledTransportation = vl;
|
||||
inline void G4PhysicsListHelper::UseCoupledTransportation(G4bool vl)
|
||||
{
|
||||
useCoupledTransportation = vl;
|
||||
}
|
||||
|
||||
inline
|
||||
void G4PhysicsListHelper::SetVerboseLevel(G4int value)
|
||||
{
|
||||
inline void G4PhysicsListHelper::SetVerboseLevel(G4int value)
|
||||
{
|
||||
verboseLevel = value;
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4PhysicsListHelper::GetVerboseLevel() const
|
||||
|
||||
inline G4int G4PhysicsListHelper::GetVerboseLevel() const
|
||||
{
|
||||
return verboseLevel;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -25,49 +25,49 @@
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
// 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
|
||||
// first version 29 Apr. 2011 by H.Kurashige
|
||||
// ------------------------------------------------------------
|
||||
|
||||
#ifndef G4PhysicsListOrderingParameter_h
|
||||
#define G4PhysicsListOrderingParameter_h 1
|
||||
#include "globals.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class G4PhysicsListHelper;
|
||||
class G4PhysicsListHelper;
|
||||
class G4PhysicsListOrderingParameter
|
||||
{
|
||||
friend class G4PhysicsListHelper;
|
||||
|
||||
public:
|
||||
// Hide constructor and destructor
|
||||
friend class G4PhysicsListHelper;
|
||||
|
||||
public:
|
||||
// Hide constructor and destructor
|
||||
G4PhysicsListOrderingParameter();
|
||||
virtual ~G4PhysicsListOrderingParameter();
|
||||
|
||||
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;}
|
||||
|
||||
private:
|
||||
G4String processTypeName;
|
||||
G4int processType;
|
||||
G4int processSubType;
|
||||
G4int ordering[3];
|
||||
G4bool isDuplicable;
|
||||
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; }
|
||||
|
||||
private:
|
||||
G4String processTypeName;
|
||||
G4int processType;
|
||||
G4int processSubType;
|
||||
G4int ordering[3];
|
||||
G4bool isDuplicable;
|
||||
};
|
||||
|
||||
inline
|
||||
G4int G4PhysicsListOrderingParameter::GetOrdering(int idx) const
|
||||
inline G4int G4PhysicsListOrderingParameter::GetOrdering(int idx) const
|
||||
{
|
||||
if ((idx<-1)||(idx>2)) return -1;
|
||||
else return ordering[idx];
|
||||
if((idx < -1) || (idx > 2))
|
||||
return -1;
|
||||
else
|
||||
return ordering[idx];
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -24,70 +24,70 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
// Description:
|
||||
// Manage the per-thread state of solids - those which
|
||||
// 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
|
||||
// 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
|
||||
// Background: the classes/objects affected are
|
||||
// - 'split' classes part of its state is per-thread,
|
||||
// - per-thread objects, in particular those which are owned
|
||||
// - 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.
|
||||
// Goal: Take ownership and control of per-thread state of
|
||||
// classes to work with multi-threading.
|
||||
// Offshoot of G4GeometryWorkspace, to deal with PhysicsList.
|
||||
//
|
||||
//
|
||||
// Designed / created by John Apostolakis
|
||||
// Interface design - review with Andrea Dotti.
|
||||
//
|
||||
//
|
||||
// First version: 4th Oct 2013
|
||||
// Created due to dependency issue with G4GeometryWorkspace
|
||||
// Working version:
|
||||
// Created due to dependency issue with G4GeometryWorkspace
|
||||
// Working version:
|
||||
|
||||
#ifndef G4PHYSICSLISTWORKSPACE_HH
|
||||
#define G4PHYSICSLISTWORKSPACE_HH
|
||||
|
||||
|
||||
#include "G4TWorkspacePool.hh"
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
#include "G4VPhysicsConstructor.hh"
|
||||
#include "G4VModularPhysicsList.hh"
|
||||
#include "G4VPhysicsConstructor.hh"
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
|
||||
class G4PhysicsListWorkspace
|
||||
{
|
||||
public:
|
||||
typedef G4TWorkspacePool<G4PhysicsListWorkspace> pool_type;
|
||||
G4PhysicsListWorkspace(G4bool verbose=false);
|
||||
~G4PhysicsListWorkspace();
|
||||
public:
|
||||
typedef G4TWorkspacePool<G4PhysicsListWorkspace> pool_type;
|
||||
G4PhysicsListWorkspace(G4bool verbose = false);
|
||||
~G4PhysicsListWorkspace();
|
||||
|
||||
void UseWorkspace(); //Take ownership
|
||||
void ReleaseWorkspace(); //Release ownership
|
||||
void DestroyWorkspace(); //Release ownership and destroy
|
||||
void UseWorkspace(); // Take ownership
|
||||
void ReleaseWorkspace(); // Release ownership
|
||||
void DestroyWorkspace(); // Release ownership and destroy
|
||||
|
||||
void InitialiseWorkspace();
|
||||
// To be called at start of each run (especially 2nd and further runs)
|
||||
void InitialiseWorkspace();
|
||||
// To be called at start of each run (especially 2nd and further runs)
|
||||
|
||||
void SetVerbose(G4bool v) { fVerbose = v; }
|
||||
G4bool GetVerbose() { return fVerbose; }
|
||||
|
||||
static pool_type* GetPool();
|
||||
|
||||
void SetVerbose(G4bool v) { fVerbose=v; }
|
||||
G4bool GetVerbose() { return fVerbose; }
|
||||
|
||||
static pool_type* GetPool();
|
||||
protected: // Implementation methods
|
||||
void InitialisePhysicsList();
|
||||
void InitialisePhysicsList();
|
||||
|
||||
private: // Helper pointers - can be per instance or shared
|
||||
G4VUPLManager *fpVUPLSIM;
|
||||
G4VPCManager*fpVPCSIM;
|
||||
G4VMPLManager *fpVMPLSIM;
|
||||
private: // Helper pointers - can be per instance or shared
|
||||
G4VUPLManager* fpVUPLSIM;
|
||||
G4VPCManager* fpVPCSIM;
|
||||
G4VMPLManager* fpVMPLSIM;
|
||||
|
||||
// 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;
|
||||
// Store SubInstanceManager object pointers (SIM pointers)
|
||||
G4VUPLData* fpVUPLOffset;
|
||||
G4VPCData* fpVPCOffset;
|
||||
G4VMPLData* fpVMPLOffset;
|
||||
|
||||
G4bool fVerbose;
|
||||
G4bool fVerbose;
|
||||
};
|
||||
|
||||
#endif //G4PARTICLESWORKSPACE_HH
|
||||
#endif // G4PARTICLESWORKSPACE_HH
|
||||
|
||||
@@ -38,89 +38,94 @@
|
||||
#ifndef G4RNGHELPER_HH
|
||||
#define G4RNGHELPER_HH
|
||||
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include "globals.hh"
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
|
||||
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:
|
||||
// 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;
|
||||
|
||||
virtual ~G4TemplateRNGHelper();
|
||||
|
||||
//Returns seed given id
|
||||
virtual const T GetSeed(const G4int& sdId )
|
||||
virtual ~G4TemplateRNGHelper();
|
||||
|
||||
// Returns seed given id
|
||||
virtual const T GetSeed(const G4int& sdId)
|
||||
{
|
||||
G4int seedId = sdId - 2 * offset;
|
||||
if(seedId < static_cast<G4int>(seeds.size()))
|
||||
{
|
||||
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();
|
||||
T& seed = seeds[seedId];
|
||||
return seed;
|
||||
}
|
||||
|
||||
//Adds one seed to the collection
|
||||
void AddOneSeed( const T& seed ) { seeds.push_back(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();
|
||||
}
|
||||
|
||||
//Fills N primary seed pairs
|
||||
void Fill(G4double* dbl,G4int nev,G4int nev_tot,G4int nrpe)
|
||||
// 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++)
|
||||
{
|
||||
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;
|
||||
seeds.push_back((G4long)(100000000L * dbl[i]));
|
||||
}
|
||||
offset = 0;
|
||||
nev_filled = nev;
|
||||
nev_total = nev_tot;
|
||||
nRandParEvent = nrpe;
|
||||
}
|
||||
|
||||
void Refill(G4double* dbl, G4int nev)
|
||||
void Refill(G4double* dbl, G4int nev)
|
||||
{
|
||||
if(nev == 0)
|
||||
return;
|
||||
seeds.clear();
|
||||
for(G4int i = 0; i < nRandParEvent * nev; 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;
|
||||
seeds.push_back((G4long)(100000000L * dbl[i]));
|
||||
}
|
||||
|
||||
//Number of available seeds
|
||||
const SeedsQueueSize_type GetNumberSeeds() const { return seeds.size(); }
|
||||
|
||||
//Empty the seeds container
|
||||
virtual void Clear() { seeds.clear(); }
|
||||
offset += nev_filled;
|
||||
nev_filled = nev;
|
||||
}
|
||||
|
||||
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;
|
||||
// Number of available seeds
|
||||
const SeedsQueueSize_type GetNumberSeeds() const { return seeds.size(); }
|
||||
|
||||
private:
|
||||
G4TemplateRNGHelper()
|
||||
{
|
||||
offset=0;
|
||||
nev_filled=0;
|
||||
nev_total=0;
|
||||
nRandParEvent=0;
|
||||
}
|
||||
// Empty the seeds container
|
||||
virtual void Clear() { seeds.clear(); }
|
||||
|
||||
private:
|
||||
static G4TemplateRNGHelper<T>* instance;
|
||||
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;
|
||||
|
||||
private:
|
||||
G4TemplateRNGHelper()
|
||||
{
|
||||
offset = 0;
|
||||
nev_filled = 0;
|
||||
nev_total = 0;
|
||||
nRandParEvent = 0;
|
||||
}
|
||||
|
||||
private:
|
||||
static G4TemplateRNGHelper<T>* instance;
|
||||
};
|
||||
|
||||
typedef G4TemplateRNGHelper<G4long> G4RNGHelper;
|
||||
|
||||
+67
-68
@@ -40,82 +40,81 @@ class G4DCtable;
|
||||
// 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:
|
||||
G4Run();
|
||||
virtual ~G4Run();
|
||||
public:
|
||||
G4Run();
|
||||
virtual ~G4Run();
|
||||
|
||||
private:
|
||||
// These copy constructor and = operator must not be used.
|
||||
G4Run(const G4Run &) {;}
|
||||
G4Run& operator=(const G4Run &) { return *this; }
|
||||
private:
|
||||
// These copy constructor and = operator must not be used.
|
||||
G4Run(const G4Run&) { ; }
|
||||
G4Run& operator=(const G4Run&) { return *this; }
|
||||
|
||||
protected:
|
||||
G4int runID;
|
||||
G4int numberOfEvent;
|
||||
G4int numberOfEventToBeProcessed;
|
||||
G4HCtable* HCtable;
|
||||
G4DCtable* DCtable;
|
||||
G4String randomNumberStatus;
|
||||
std::vector<const G4Event*>* eventVector;
|
||||
protected:
|
||||
G4int runID;
|
||||
G4int numberOfEvent;
|
||||
G4int numberOfEventToBeProcessed;
|
||||
G4HCtable* HCtable;
|
||||
G4DCtable* DCtable;
|
||||
G4String randomNumberStatus;
|
||||
std::vector<const G4Event*>* eventVector;
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
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; }
|
||||
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; }
|
||||
|
||||
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
|
||||
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
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+518
-427
File diff suppressed because it is too large
Load Diff
@@ -25,12 +25,12 @@
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This is a class for mandatory control of GEANT4 kernel.
|
||||
//
|
||||
// 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
|
||||
@@ -40,11 +40,11 @@
|
||||
// InitializePhysics
|
||||
// RunInitialization
|
||||
// RunTermination
|
||||
//
|
||||
//
|
||||
// User must provide his/her own classes derived from the following
|
||||
// abstract class and register it to the RunManagerKernel.
|
||||
// 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.
|
||||
//
|
||||
@@ -61,173 +61,185 @@ class G4StackManager;
|
||||
class G4TrackingManager;
|
||||
class G4PrimaryTransformer;
|
||||
|
||||
#include "globals.hh"
|
||||
#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: // with description
|
||||
static G4RunManagerKernel* GetRunManagerKernel();
|
||||
// Static method which returns the singleton pointer of G4RunManagerKernel or
|
||||
// its derived class.
|
||||
|
||||
private:
|
||||
static G4ThreadLocal G4RunManagerKernel* fRunManagerKernel;
|
||||
private:
|
||||
static G4ThreadLocal G4RunManagerKernel* fRunManagerKernel;
|
||||
|
||||
public: // with description
|
||||
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.
|
||||
public:
|
||||
enum RMKType { sequentialRMK, masterRMK, workerRMK };
|
||||
protected:
|
||||
//Constructor to be used by derived classes
|
||||
G4RunManagerKernel(RMKType rmkType);
|
||||
RMKType runManagerKernelType;
|
||||
protected:
|
||||
// Constructor to be used by derived classes
|
||||
G4RunManagerKernel(RMKType rmkType);
|
||||
RMKType runManagerKernelType;
|
||||
|
||||
public: // with description
|
||||
void DefineWorldVolume(G4VPhysicalVolume * worldVol,
|
||||
G4bool topologyIsChanged=true);
|
||||
public: // with description
|
||||
void DefineWorldVolume(G4VPhysicalVolume* worldVol,
|
||||
G4bool topologyIsChanged = true);
|
||||
|
||||
void WorkerDefineWorldVolume(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.
|
||||
// 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 SetPhysics(G4VUserPhysicsList* uPhys);
|
||||
// This method must be invoked at least once by the user with a valid
|
||||
// concrete implementation of user physics list.
|
||||
void SetPhysics(G4VUserPhysicsList* uPhys);
|
||||
// This method must be invoked at least once by the user with a valid
|
||||
// concrete implementation of user physics list.
|
||||
|
||||
void InitializePhysics();
|
||||
// This method must be invoked at least once by the user to build physics
|
||||
// processes.
|
||||
void InitializePhysics();
|
||||
// This method must be invoked at least once by the user to build physics
|
||||
// processes.
|
||||
|
||||
G4bool RunInitialization(G4bool fakeRun=false);
|
||||
// Trigger geometry closing and physics table constructions.
|
||||
// It returns TRUE if all procedures went well.
|
||||
G4bool RunInitialization(G4bool fakeRun = false);
|
||||
// Trigger geometry closing and physics table constructions.
|
||||
// It returns TRUE if all procedures went well.
|
||||
|
||||
void RunTermination();
|
||||
// Set the application state to G4State_Idle so that the user can modify
|
||||
// physics/geometry.
|
||||
void RunTermination();
|
||||
// Set the application state to G4State_Idle so that the user can modify
|
||||
// physics/geometry.
|
||||
|
||||
public:
|
||||
void WorkerUpdateWorldVolume();
|
||||
public:
|
||||
void WorkerUpdateWorldVolume();
|
||||
|
||||
protected:
|
||||
void SetupDefaultRegion();
|
||||
//Called by DefineWorldVolume
|
||||
void SetupPhysics();
|
||||
void ResetNavigator();
|
||||
void BuildPhysicsTables(G4bool fakeRun);
|
||||
void CheckRegions();
|
||||
protected:
|
||||
void SetupDefaultRegion();
|
||||
// Called by DefineWorldVolume
|
||||
void SetupPhysics();
|
||||
void ResetNavigator();
|
||||
void BuildPhysicsTables(G4bool fakeRun);
|
||||
void CheckRegions();
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
void DumpRegion(const G4String& rname) const;
|
||||
// Dump information of a region.
|
||||
void DumpRegion(const G4String& rname) const;
|
||||
// Dump information of a region.
|
||||
|
||||
void DumpRegion(G4Region* region=0) const;
|
||||
// Dump information of a region.
|
||||
// If the pointer is NULL, all regions are shown.
|
||||
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;
|
||||
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.
|
||||
G4EventManager* eventManager;
|
||||
G4ExceptionHandler* defaultExceptionHandler;
|
||||
G4String versionString;
|
||||
|
||||
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.
|
||||
protected:
|
||||
G4Region* defaultRegion;
|
||||
G4Region* defaultRegionForParallelWorld;
|
||||
G4bool geometryNeedsToBeClosed;
|
||||
|
||||
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(); }
|
||||
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 const G4String& GetVersionString() const
|
||||
{ return versionString; }
|
||||
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.
|
||||
|
||||
inline void SetVerboseLevel(G4int vl)
|
||||
{ verboseLevel = vl; }
|
||||
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 void SetGeometryToBeOptimized(G4bool vl)
|
||||
{
|
||||
if(geometryToBeOptimized != vl)
|
||||
{
|
||||
geometryToBeOptimized = vl;
|
||||
geometryNeedsToBeClosed = true;
|
||||
}
|
||||
inline const G4String& GetVersionString() const { return versionString; }
|
||||
|
||||
inline void SetVerboseLevel(G4int vl) { verboseLevel = vl; }
|
||||
|
||||
inline void SetGeometryToBeOptimized(G4bool vl)
|
||||
{
|
||||
if(geometryToBeOptimized != vl)
|
||||
{
|
||||
geometryToBeOptimized = vl;
|
||||
geometryNeedsToBeClosed = true;
|
||||
}
|
||||
}
|
||||
|
||||
inline G4int GetNumberOfParallelWorld() const
|
||||
{ return numberOfParallelWorld; }
|
||||
inline void SetNumberOfParallelWorld(G4int i)
|
||||
{ numberOfParallelWorld = i; }
|
||||
inline G4int GetNumberOfParallelWorld() const
|
||||
{
|
||||
return numberOfParallelWorld;
|
||||
}
|
||||
inline void SetNumberOfParallelWorld(G4int i) { numberOfParallelWorld = i; }
|
||||
|
||||
inline G4VUserPhysicsList* GetPhysicsList() const
|
||||
{ return physicsList; }
|
||||
inline G4VUserPhysicsList* GetPhysicsList() const { return physicsList; }
|
||||
|
||||
inline G4VPhysicalVolume* GetCurrentWorld() const
|
||||
{ return currentWorld; }
|
||||
private:
|
||||
void CheckRegularGeometry();
|
||||
G4bool ConfirmCoupledTransportation();
|
||||
void SetScoreSplitter();
|
||||
inline G4VPhysicalVolume* GetCurrentWorld() const { return currentWorld; }
|
||||
|
||||
G4int numberOfStaticAllocators;
|
||||
private:
|
||||
void CheckRegularGeometry();
|
||||
G4bool ConfirmCoupledTransportation();
|
||||
void SetScoreSplitter();
|
||||
|
||||
public:
|
||||
inline G4int GetNumberOfStaticAllocators() const
|
||||
{ return numberOfStaticAllocators; }
|
||||
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
|
||||
G4int numberOfStaticAllocators;
|
||||
|
||||
void PropagateGenericIonID();
|
||||
public:
|
||||
inline G4int GetNumberOfStaticAllocators() const
|
||||
{
|
||||
return numberOfStaticAllocators;
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
void PropagateGenericIonID();
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -25,30 +25,29 @@
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// GEANT 4 class header file
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This is a messenger class for G4RunManager.
|
||||
// Implemented commands are following;
|
||||
//
|
||||
// Commands :
|
||||
// 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.
|
||||
// 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
|
||||
//
|
||||
//
|
||||
|
||||
#ifndef G4RunMessenger_h
|
||||
#define G4RunMessenger_h 1
|
||||
@@ -65,58 +64,56 @@ class G4MaterialScanner;
|
||||
#include "G4UImessenger.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class G4RunMessenger: public G4UImessenger
|
||||
class G4RunMessenger : public G4UImessenger
|
||||
{
|
||||
public:
|
||||
G4RunMessenger(G4RunManager* runMgr);
|
||||
~G4RunMessenger();
|
||||
public:
|
||||
G4RunMessenger(G4RunManager* runMgr);
|
||||
~G4RunMessenger();
|
||||
|
||||
public:
|
||||
void SetNewValue(G4UIcommand * command,G4String newValues);
|
||||
G4String GetCurrentValue(G4UIcommand * command);
|
||||
public:
|
||||
void SetNewValue(G4UIcommand* command, G4String newValues);
|
||||
G4String GetCurrentValue(G4UIcommand* command);
|
||||
|
||||
private:
|
||||
G4RunManager * runManager;
|
||||
G4String macroFileName; // internal use only!!!
|
||||
|
||||
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:
|
||||
G4RunManager* runManager;
|
||||
G4String macroFileName; // internal use only!!!
|
||||
|
||||
G4UIdirectory * randomDirectory;
|
||||
G4UIcmdWithAString * seedCmd;
|
||||
G4UIcmdWithAString * randDirCmd;
|
||||
G4UIcmdWithABool * savingFlagCmd;
|
||||
G4UIcmdWithoutParameter * saveThisRunCmd;
|
||||
G4UIcmdWithoutParameter * saveThisEventCmd;
|
||||
G4UIcmdWithAString * restoreRandCmd;
|
||||
G4UIcmdWithABool * saveEachEventCmd;
|
||||
G4UIcmdWithABool * restoreRandCmdMT;
|
||||
|
||||
G4UIcmdWithoutParameter * constScoreCmd;
|
||||
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;
|
||||
|
||||
G4MaterialScanner * materialScanner;
|
||||
G4UIdirectory* randomDirectory;
|
||||
G4UIcmdWithAString* seedCmd;
|
||||
G4UIcmdWithAString* randDirCmd;
|
||||
G4UIcmdWithABool* savingFlagCmd;
|
||||
G4UIcmdWithoutParameter* saveThisRunCmd;
|
||||
G4UIcmdWithoutParameter* saveThisEventCmd;
|
||||
G4UIcmdWithAString* restoreRandCmd;
|
||||
G4UIcmdWithABool* saveEachEventCmd;
|
||||
G4UIcmdWithABool* restoreRandCmdMT;
|
||||
|
||||
G4UIcmdWithoutParameter* constScoreCmd;
|
||||
|
||||
G4MaterialScanner* materialScanner;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4UserPhysicsListMessenger.hh
|
||||
@@ -35,9 +35,9 @@
|
||||
// between ParticleUserList and UI.
|
||||
// --
|
||||
// the List of Directory and Commands
|
||||
// -
|
||||
// -
|
||||
// /run/particle/ Paricle control commands.
|
||||
// Commands :
|
||||
// Commands :
|
||||
// SetCuts * Set default cut value
|
||||
// dumpList * Dump List of particles in G4VUserPhysicsList.
|
||||
// verbose * Set the Verbose level of G4VUserPhysicsList.
|
||||
@@ -45,11 +45,12 @@
|
||||
// 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
|
||||
// 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
|
||||
// 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
|
||||
@@ -68,47 +69,45 @@ class G4UIdirectory;
|
||||
class G4UIcmdWithoutParameter;
|
||||
class G4UIcmdWithAnInteger;
|
||||
class G4UIcmdWithADoubleAndUnit;
|
||||
class G4UIcmdWithAString;
|
||||
class G4UIcmdWithAString;
|
||||
class G4UIcommand;
|
||||
|
||||
#include "G4UImessenger.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
class G4UserPhysicsListMessenger: public G4UImessenger
|
||||
class G4UserPhysicsListMessenger : public G4UImessenger
|
||||
{
|
||||
private:
|
||||
private:
|
||||
// hide default constructor
|
||||
G4UserPhysicsListMessenger(){}
|
||||
G4UserPhysicsListMessenger() {}
|
||||
|
||||
public:
|
||||
G4UserPhysicsListMessenger(G4VUserPhysicsList* pParticleList);
|
||||
virtual ~G4UserPhysicsListMessenger();
|
||||
|
||||
public: // with description
|
||||
virtual void SetNewValue(G4UIcommand * command,G4String newValues);
|
||||
virtual G4String GetCurrentValue(G4UIcommand * command);
|
||||
public:
|
||||
G4UserPhysicsListMessenger(G4VUserPhysicsList* pParticleList);
|
||||
virtual ~G4UserPhysicsListMessenger();
|
||||
|
||||
protected:
|
||||
G4VUserPhysicsList* thePhysicsList;
|
||||
|
||||
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;
|
||||
public: // with description
|
||||
virtual void SetNewValue(G4UIcommand* command, G4String newValues);
|
||||
virtual G4String GetCurrentValue(G4UIcommand* command);
|
||||
|
||||
protected:
|
||||
G4VUserPhysicsList* thePhysicsList;
|
||||
|
||||
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;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ class G4Run;
|
||||
//
|
||||
// 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
|
||||
// override the following two methods but the user should not change
|
||||
// any of the contents of G4Run object.
|
||||
// virtual void BeginOfRunAction(const G4Run* aRun);
|
||||
// virtual void EndOfRunAction(const G4Run* aRun);
|
||||
@@ -50,25 +50,21 @@ class G4Run;
|
||||
|
||||
class G4UserRunAction
|
||||
{
|
||||
public:
|
||||
G4UserRunAction();
|
||||
virtual ~G4UserRunAction();
|
||||
public:
|
||||
G4UserRunAction();
|
||||
virtual ~G4UserRunAction();
|
||||
|
||||
public:
|
||||
virtual G4Run* GenerateRun();
|
||||
virtual void BeginOfRunAction(const G4Run* aRun);
|
||||
virtual void EndOfRunAction(const G4Run* aRun);
|
||||
public:
|
||||
virtual G4Run* GenerateRun();
|
||||
virtual void BeginOfRunAction(const G4Run* aRun);
|
||||
virtual void EndOfRunAction(const G4Run* aRun);
|
||||
|
||||
protected:
|
||||
G4bool isMaster;
|
||||
protected:
|
||||
G4bool isMaster;
|
||||
|
||||
public:
|
||||
inline virtual void SetMaster(G4bool val=true)
|
||||
{ isMaster = val; }
|
||||
inline G4bool IsMaster() const
|
||||
{ return isMaster; }
|
||||
public:
|
||||
inline virtual void SetMaster(G4bool val = true) { isMaster = val; }
|
||||
inline G4bool IsMaster() const { return isMaster; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -29,66 +29,68 @@
|
||||
// class description:
|
||||
//
|
||||
// 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.
|
||||
// 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.
|
||||
// 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.
|
||||
// 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.
|
||||
// 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.
|
||||
// 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.
|
||||
// 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.
|
||||
//
|
||||
|
||||
#ifndef G4UserWorkerInitialization_hh
|
||||
#define G4UserWorkerInitialization_hh
|
||||
|
||||
class G4UserWorkerInitialization {
|
||||
public: // with description
|
||||
G4UserWorkerInitialization();
|
||||
virtual ~G4UserWorkerInitialization();
|
||||
class G4UserWorkerInitialization
|
||||
{
|
||||
public: // with description
|
||||
G4UserWorkerInitialization();
|
||||
virtual ~G4UserWorkerInitialization();
|
||||
|
||||
virtual void WorkerInitialize() const;
|
||||
// This method is called after the tread is created but before the
|
||||
// G4WorkerRunManager is instantiated.
|
||||
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 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 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 has
|
||||
// finished but before the synchronization over threads.
|
||||
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 WorkerStop() const;
|
||||
// This method is called once at the end of simulation job.
|
||||
// Implement here a clean up action.
|
||||
|
||||
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 // G4UserWorkerInitialization_hh
|
||||
|
||||
@@ -44,39 +44,40 @@ class G4WorkerRunManager;
|
||||
#include "G4Threading.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
class G4UserWorkerThreadInitialization {
|
||||
public: // with description
|
||||
G4UserWorkerThreadInitialization();
|
||||
virtual ~G4UserWorkerThreadInitialization();
|
||||
class G4UserWorkerThreadInitialization
|
||||
{
|
||||
public: // with description
|
||||
G4UserWorkerThreadInitialization();
|
||||
virtual ~G4UserWorkerThreadInitialization();
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
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 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 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 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. 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 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.
|
||||
};
|
||||
|
||||
#endif //G4UserWorkerThreadInitialization_hh
|
||||
|
||||
#endif // G4UserWorkerThreadInitialization_hh
|
||||
|
||||
@@ -25,24 +25,24 @@
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
// 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()
|
||||
// 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
|
||||
// - 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
|
||||
//
|
||||
@@ -52,23 +52,24 @@
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include "G4ios.hh"
|
||||
#include "globals.hh"
|
||||
#include "rundefs.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
#include "G4VPhysicsConstructor.hh"
|
||||
#include "G4VUPLSplitter.hh"
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
|
||||
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;
|
||||
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;
|
||||
};
|
||||
|
||||
// The type G4VMPLManager is introduced to encapsulate the methods used by
|
||||
@@ -89,84 +90,82 @@ public:
|
||||
typedef G4VUPLSplitter<G4VMPLData> G4VMPLManager;
|
||||
typedef G4VMPLManager G4VModularPhysicsListSubInstanceManager;
|
||||
|
||||
class G4VModularPhysicsList: public virtual G4VUserPhysicsList
|
||||
class G4VModularPhysicsList : public virtual G4VUserPhysicsList
|
||||
{
|
||||
public:
|
||||
G4VModularPhysicsList();
|
||||
virtual ~G4VModularPhysicsList();
|
||||
|
||||
public:
|
||||
G4VModularPhysicsList();
|
||||
virtual ~G4VModularPhysicsList();
|
||||
|
||||
protected:
|
||||
// hide copy constructor and assignment operator
|
||||
G4VModularPhysicsList(const G4VModularPhysicsList&);
|
||||
G4VModularPhysicsList & operator=(const G4VModularPhysicsList&);
|
||||
// hide copy constructor and assignment operator
|
||||
G4VModularPhysicsList(const G4VModularPhysicsList&);
|
||||
G4VModularPhysicsList& operator=(const G4VModularPhysicsList&);
|
||||
|
||||
public: // with description
|
||||
// This method will be invoked in the Construct() method.
|
||||
// each particle type will be instantiated
|
||||
virtual void ConstructParticle() 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
|
||||
virtual void ConstructProcess() override;
|
||||
|
||||
public: // with description
|
||||
// Register Physics Constructor
|
||||
void RegisterPhysics(G4VPhysicsConstructor* );
|
||||
|
||||
const G4VPhysicsConstructor* GetPhysics(G4int index) const;
|
||||
const G4VPhysicsConstructor* GetPhysics(const G4String& name) const;
|
||||
const G4VPhysicsConstructor* GetPhysicsWithType(G4int physics_type) const;
|
||||
public: // with description
|
||||
// This method will be invoked in the Construct() method.
|
||||
// each particle type will be instantiated
|
||||
virtual void ConstructParticle() override;
|
||||
|
||||
// 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* );
|
||||
// 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;
|
||||
|
||||
public: // with description
|
||||
// Register Physics Constructor
|
||||
void RegisterPhysics(G4VPhysicsConstructor*);
|
||||
|
||||
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*);
|
||||
|
||||
// Remove Physics Constructor from the list
|
||||
void RemovePhysics(G4VPhysicsConstructor*);
|
||||
void RemovePhysics(G4int type);
|
||||
void RemovePhysics(const G4String& name);
|
||||
|
||||
// Remove Physics Constructor from the list
|
||||
void RemovePhysics(G4VPhysicsConstructor* );
|
||||
void RemovePhysics(G4int type);
|
||||
void RemovePhysics(const G4String& name);
|
||||
|
||||
/////////////////////////////////////
|
||||
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
|
||||
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
|
||||
|
||||
protected: // with description
|
||||
G4int verboseLevel;
|
||||
typedef G4VMPLData::G4PhysConstVectorData G4PhysConstVector;
|
||||
G4int g4vmplInstanceID;
|
||||
G4RUN_DLL static G4VMPLManager G4VMPLsubInstanceManager;
|
||||
public:
|
||||
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;
|
||||
|
||||
public:
|
||||
inline G4int GetInstanceID() const;
|
||||
static const G4VMPLManager& GetSubInstanceManager();
|
||||
virtual void TerminateWorker() override;
|
||||
};
|
||||
|
||||
inline
|
||||
G4int G4VModularPhysicsList::GetVerboseLevel() const
|
||||
|
||||
inline G4int G4VModularPhysicsList::GetVerboseLevel() const
|
||||
{
|
||||
return verboseLevel;
|
||||
return verboseLevel;
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4VModularPhysicsList::GetInstanceID() const
|
||||
inline G4int G4VModularPhysicsList::GetInstanceID() const
|
||||
{
|
||||
return g4vmplInstanceID;
|
||||
return g4vmplInstanceID;
|
||||
}
|
||||
|
||||
inline
|
||||
const G4VMPLManager& G4VModularPhysicsList::GetSubInstanceManager()
|
||||
inline const G4VMPLManager& G4VModularPhysicsList::GetSubInstanceManager()
|
||||
{
|
||||
return G4VMPLsubInstanceManager;
|
||||
return G4VMPLsubInstanceManager;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -48,37 +48,34 @@ class G4VPhysicalVolume;
|
||||
// event information can be delegated to this class, for example.
|
||||
//
|
||||
|
||||
class G4VPersistencyManager
|
||||
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: // 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.
|
||||
|
||||
protected:
|
||||
G4VPersistencyManager();
|
||||
protected:
|
||||
G4VPersistencyManager();
|
||||
|
||||
public:
|
||||
virtual ~G4VPersistencyManager();
|
||||
public:
|
||||
virtual ~G4VPersistencyManager();
|
||||
|
||||
private:
|
||||
static G4ThreadLocal G4VPersistencyManager * fPersistencyManager;
|
||||
private:
|
||||
static G4ThreadLocal G4VPersistencyManager* fPersistencyManager;
|
||||
|
||||
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;
|
||||
// Restore G4Event, G4Run, and geometry tree characterized 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;
|
||||
// Restore G4Event, G4Run, and geometry tree characterized by the world
|
||||
// volume.
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -25,34 +25,34 @@
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
// GEANT 4 class header file
|
||||
// Class Description:
|
||||
// This class is an virtual class for constructing
|
||||
// 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 his own concrete class derived from this class.
|
||||
// in his own concrete class derived from this class.
|
||||
//
|
||||
// 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
|
||||
// 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
|
||||
// replaced by using the method of
|
||||
// G4VModularPhysicsList::ReplacePhysics()
|
||||
//
|
||||
//
|
||||
// -------------------------------------------
|
||||
//
|
||||
// -------------------------------------------
|
||||
// History
|
||||
// first version 12 Nov. 2000 by H.Kurashige
|
||||
// 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
|
||||
@@ -60,25 +60,25 @@
|
||||
#ifndef G4VPhysicsConstructor_h
|
||||
#define G4VPhysicsConstructor_h 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "rundefs.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4PhysicsListHelper.hh"
|
||||
#include "G4VUPLSplitter.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "globals.hh"
|
||||
#include "rundefs.hh"
|
||||
#include <vector>
|
||||
|
||||
class G4PhysicsBuilderInterface;
|
||||
|
||||
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;
|
||||
// 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;
|
||||
};
|
||||
|
||||
// The type G4VPCManager is introduced to encapsulate the methods used by
|
||||
@@ -103,10 +103,11 @@ public:
|
||||
// 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 guarantee that the system works without
|
||||
// problems in case of this (unusual) case. This may be reviewed in the future
|
||||
// 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
|
||||
// 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;
|
||||
|
||||
@@ -120,69 +121,69 @@ typedef G4VPCManager G4VPhyscicsConstructorManager;
|
||||
// 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)
|
||||
//#define aParticleIterator
|
||||
//((subInstanceManager.offset[g4vpcInstanceID])._aParticleIterator)
|
||||
|
||||
class G4VPhysicsConstructor
|
||||
{
|
||||
public: // with description
|
||||
public: // with description
|
||||
G4VPhysicsConstructor(const G4String& = "");
|
||||
G4VPhysicsConstructor(const G4String& name, G4int physics_type);
|
||||
virtual ~G4VPhysicsConstructor();
|
||||
|
||||
G4VPhysicsConstructor(const G4String& ="");
|
||||
G4VPhysicsConstructor(const G4String& name, G4int physics_type);
|
||||
virtual ~G4VPhysicsConstructor();
|
||||
virtual void ConstructParticle() = 0;
|
||||
// This method will be invoked in the Construct() method.
|
||||
// each particle type will be instantiated
|
||||
|
||||
virtual void ConstructParticle()=0;
|
||||
// This method will be invoked in the Construct() method.
|
||||
// each particle type will be instantiated
|
||||
|
||||
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 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 SetPhysicsName(const G4String& ="");
|
||||
inline const G4String& GetPhysicsName() const;
|
||||
inline void SetPhysicsName(const G4String& = "");
|
||||
inline const G4String& GetPhysicsName() const;
|
||||
|
||||
inline void SetPhysicsType(G4int);
|
||||
inline G4int GetPhysicsType() const;
|
||||
inline void SetPhysicsType(G4int);
|
||||
inline G4int GetPhysicsType() 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 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
|
||||
|
||||
protected:
|
||||
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 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
|
||||
protected:
|
||||
G4int verboseLevel;
|
||||
G4String namePhysics;
|
||||
G4int typePhysics;
|
||||
|
||||
protected:
|
||||
G4int verboseLevel;
|
||||
G4String namePhysics;
|
||||
G4int typePhysics;
|
||||
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);
|
||||
|
||||
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);
|
||||
public:
|
||||
inline G4int GetInstanceID() const;
|
||||
static const G4VPCManager& GetSubInstanceManager();
|
||||
public:
|
||||
inline G4int GetInstanceID() const;
|
||||
static const G4VPCManager& GetSubInstanceManager();
|
||||
|
||||
//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();
|
||||
// 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();
|
||||
};
|
||||
|
||||
// Inlined methods
|
||||
@@ -192,9 +193,9 @@ inline void G4VPhysicsConstructor::SetVerboseLevel(G4int value)
|
||||
verboseLevel = value;
|
||||
}
|
||||
|
||||
inline G4int G4VPhysicsConstructor::GetVerboseLevel() const
|
||||
inline G4int G4VPhysicsConstructor::GetVerboseLevel() const
|
||||
{
|
||||
return verboseLevel;
|
||||
return verboseLevel;
|
||||
}
|
||||
|
||||
inline void G4VPhysicsConstructor::SetPhysicsName(const G4String& name)
|
||||
@@ -202,36 +203,32 @@ inline void G4VPhysicsConstructor::SetPhysicsName(const G4String& name)
|
||||
namePhysics = name;
|
||||
}
|
||||
|
||||
inline const G4String& G4VPhysicsConstructor::GetPhysicsName() const
|
||||
inline const G4String& G4VPhysicsConstructor::GetPhysicsName() const
|
||||
{
|
||||
return namePhysics;
|
||||
return namePhysics;
|
||||
}
|
||||
|
||||
inline void G4VPhysicsConstructor::SetPhysicsType(G4int val)
|
||||
{
|
||||
if (val>0) typePhysics = val;
|
||||
if(val > 0)
|
||||
typePhysics = val;
|
||||
}
|
||||
|
||||
inline G4int G4VPhysicsConstructor::GetPhysicsType() const
|
||||
{
|
||||
return typePhysics;
|
||||
return typePhysics;
|
||||
}
|
||||
|
||||
inline
|
||||
G4bool G4VPhysicsConstructor::RegisterProcess(G4VProcess* process,
|
||||
G4ParticleDefinition* particle)
|
||||
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);
|
||||
// return aPLHelper->RegisterProcess(process, particle);
|
||||
}
|
||||
|
||||
inline
|
||||
const G4VPCManager& G4VPhysicsConstructor::GetSubInstanceManager()
|
||||
inline const G4VPCManager& G4VPhysicsConstructor::GetSubInstanceManager()
|
||||
{
|
||||
return subInstanceManager;
|
||||
return subInstanceManager;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -25,10 +25,10 @@
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
//
|
||||
// GEANT 4 class header file
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// ---------------- G4UPLSplitter ----------------
|
||||
//
|
||||
@@ -44,9 +44,9 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "G4AutoLock.hh"
|
||||
#include "globals.hh"
|
||||
#include "rundefs.hh"
|
||||
#include "G4AutoLock.hh"
|
||||
//
|
||||
// This class implements the split-mechanism for shared objects.
|
||||
// Let's see how it works.
|
||||
@@ -54,15 +54,15 @@
|
||||
// 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
|
||||
// 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.
|
||||
@@ -70,130 +70,143 @@
|
||||
template <class T> // T is the private data from the object to be split
|
||||
class G4VUPLSplitter
|
||||
{
|
||||
public:
|
||||
public:
|
||||
G4VUPLSplitter()
|
||||
: totalobj(0)
|
||||
, totalspace(0)
|
||||
, sharedOffset(0)
|
||||
{
|
||||
G4MUTEXINIT(mutex);
|
||||
}
|
||||
|
||||
G4VUPLSplitter() : totalobj(0),totalspace(0),sharedOffset(0)
|
||||
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)
|
||||
{
|
||||
G4MUTEXINIT(mutex);
|
||||
l.unlock();
|
||||
NewSubInstances();
|
||||
l.lock();
|
||||
}
|
||||
// Since this is called by Master thread, we can remember this
|
||||
totalspace = workertotalspace;
|
||||
sharedOffset = offset;
|
||||
return (totalobj - 1);
|
||||
}
|
||||
|
||||
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
|
||||
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)
|
||||
{
|
||||
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);
|
||||
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 == 0)
|
||||
{
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
void FreeWorker()
|
||||
// Invoked by all threads to free the subinstance array.
|
||||
{
|
||||
if(!offset)
|
||||
{
|
||||
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 == 0)
|
||||
{
|
||||
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();
|
||||
}
|
||||
return;
|
||||
}
|
||||
free(offset);
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
void FreeWorker()
|
||||
// Invoked by all threads to free the subinstance array.
|
||||
{
|
||||
if (!offset) { return; }
|
||||
free( offset);
|
||||
offset = 0;
|
||||
}
|
||||
T* GetOffset() { return offset; }
|
||||
|
||||
T* GetOffset() { return offset; }
|
||||
|
||||
void UseWorkArea( T* newOffset )
|
||||
void UseWorkArea(T* newOffset)
|
||||
{
|
||||
// Use recycled work area - which was created previously
|
||||
if(offset && offset != newOffset)
|
||||
{
|
||||
// Use recycled work area - which was created previously
|
||||
if( offset && offset!=newOffset )
|
||||
{
|
||||
G4Exception("G4VUPLSplitter::UseWorkspace()",
|
||||
"TwoWorkspaces", FatalException,
|
||||
"Thread already has workspace - cannot use another.");
|
||||
}
|
||||
offset= newOffset;
|
||||
// totalobj= numObjects;
|
||||
// totalspace= numSpace;
|
||||
G4Exception("G4VUPLSplitter::UseWorkspace()", "TwoWorkspaces",
|
||||
FatalException,
|
||||
"Thread already has workspace - cannot use another.");
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
G4Exception("G4VUPLSplitter::WorkerCopySubInstanceArray()",
|
||||
"OutOfMemory", FatalException, "Cannot malloc space!");
|
||||
return;
|
||||
}
|
||||
//Now just copy from master thread (sharedOffset)
|
||||
memcpy(offset,sharedOffset,totalspace*sizeof(T));
|
||||
}
|
||||
public:
|
||||
offset = newOffset;
|
||||
// totalobj= numObjects;
|
||||
// totalspace= numSpace;
|
||||
}
|
||||
|
||||
G4RUN_DLL G4ThreadLocalStatic G4int workertotalspace; //Per-thread available number of slots
|
||||
G4RUN_DLL G4ThreadLocalStatic T* offset; //Pointer to first instance of an array
|
||||
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;
|
||||
|
||||
private:
|
||||
G4int totalobj; //Total number of instances from master thread
|
||||
G4int totalspace; // Available number of "slots"
|
||||
T* sharedOffset;
|
||||
G4Mutex mutex;
|
||||
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)
|
||||
{
|
||||
G4Exception("G4VUPLSplitter::WorkerCopySubInstanceArray()", "OutOfMemory",
|
||||
FatalException, "Cannot malloc space!");
|
||||
return;
|
||||
}
|
||||
// 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
|
||||
|
||||
private:
|
||||
G4int totalobj; // Total number of instances from master thread
|
||||
G4int totalspace; // Available number of "slots"
|
||||
T* sharedOffset;
|
||||
G4Mutex mutex;
|
||||
};
|
||||
|
||||
template<typename T> G4ThreadLocal G4int G4VUPLSplitter<T>::workertotalspace=0;
|
||||
template<typename T> G4ThreadLocal T* G4VUPLSplitter<T>::offset=0;
|
||||
template <typename T>
|
||||
G4ThreadLocal G4int G4VUPLSplitter<T>::workertotalspace = 0;
|
||||
template <typename T>
|
||||
G4ThreadLocal T* G4VUPLSplitter<T>::offset = 0;
|
||||
|
||||
#endif
|
||||
|
||||
@@ -31,20 +31,23 @@
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This is the abstract base class for instantiating all the user action classes.
|
||||
// This is the abstract base class for instantiating all the user action
|
||||
// classes.
|
||||
// It has a pure virtual method Build() which is invoked by G4RunManager for
|
||||
// sequential execution and G4WorkerRunManager for multi-threaded execution.
|
||||
// The additional virtual method BuildForMaster() will be invoked from G4MTRunManager
|
||||
// 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
|
||||
// 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.
|
||||
// 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.
|
||||
//
|
||||
|
||||
class G4VUserPrimaryGeneratorAction;
|
||||
@@ -57,37 +60,35 @@ class G4VSteppingVerbose;
|
||||
|
||||
class G4VUserActionInitialization
|
||||
{
|
||||
public:
|
||||
G4VUserActionInitialization();
|
||||
virtual ~G4VUserActionInitialization();
|
||||
public:
|
||||
G4VUserActionInitialization();
|
||||
virtual ~G4VUserActionInitialization();
|
||||
|
||||
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.
|
||||
|
||||
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.
|
||||
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.
|
||||
|
||||
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.
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -34,54 +34,53 @@ class G4LogicalVolume;
|
||||
class G4VUserParallelWorld;
|
||||
class G4VSensitiveDetector;
|
||||
|
||||
#include <vector>
|
||||
#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 Construct() method must return the G4VPhysicalVolume pointer which
|
||||
// represents
|
||||
// the world volume.
|
||||
//
|
||||
|
||||
class G4VUserDetectorConstruction
|
||||
{
|
||||
public:
|
||||
G4VUserDetectorConstruction();
|
||||
virtual ~G4VUserDetectorConstruction();
|
||||
public:
|
||||
G4VUserDetectorConstruction();
|
||||
virtual ~G4VUserDetectorConstruction();
|
||||
|
||||
public:
|
||||
virtual G4VPhysicalVolume* Construct() = 0;
|
||||
public:
|
||||
virtual G4VPhysicalVolume* Construct() = 0;
|
||||
|
||||
virtual void ConstructSDandField();
|
||||
//This method is used in multi-threaded applications to build
|
||||
//per-worker non-shared objects: SensitiveDetectors and Field managers
|
||||
virtual void ConstructSDandField();
|
||||
// This method is used in multi-threaded applications to build
|
||||
// per-worker non-shared objects: SensitiveDetectors and Field managers
|
||||
|
||||
virtual void CloneSD();
|
||||
virtual void CloneF();
|
||||
virtual void CloneSD();
|
||||
virtual void CloneF();
|
||||
|
||||
public:
|
||||
void RegisterParallelWorld(G4VUserParallelWorld*);
|
||||
public:
|
||||
void RegisterParallelWorld(G4VUserParallelWorld*);
|
||||
|
||||
public:
|
||||
G4int ConstructParallelGeometries();
|
||||
void ConstructParallelSD();
|
||||
public:
|
||||
G4int ConstructParallelGeometries();
|
||||
void ConstructParallelSD();
|
||||
|
||||
private:
|
||||
std::vector<G4VUserParallelWorld*> parallelWorld;
|
||||
private:
|
||||
std::vector<G4VUserParallelWorld*> parallelWorld;
|
||||
|
||||
public:
|
||||
G4int GetNumberOfParallelWorld() const;
|
||||
G4VUserParallelWorld* GetParallelWorld(G4int i) const;
|
||||
public:
|
||||
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);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -46,29 +46,27 @@ class G4VSensitiveDetector;
|
||||
|
||||
class G4VUserParallelWorld
|
||||
{
|
||||
public:
|
||||
G4VUserParallelWorld(G4String worldName);
|
||||
virtual ~G4VUserParallelWorld();
|
||||
public:
|
||||
G4VUserParallelWorld(G4String worldName);
|
||||
virtual ~G4VUserParallelWorld();
|
||||
|
||||
public:
|
||||
virtual void Construct() = 0;
|
||||
virtual void ConstructSD();
|
||||
public:
|
||||
virtual void Construct() = 0;
|
||||
virtual void ConstructSD();
|
||||
|
||||
protected:
|
||||
G4String fWorldName;
|
||||
|
||||
protected:
|
||||
G4VPhysicalVolume* GetWorld();
|
||||
protected:
|
||||
G4String fWorldName;
|
||||
|
||||
public:
|
||||
inline G4String GetName() { return fWorldName; }
|
||||
protected:
|
||||
G4VPhysicalVolume* GetWorld();
|
||||
|
||||
protected:
|
||||
void SetSensitiveDetector(const G4String& logVolName,
|
||||
G4VSensitiveDetector* aSD,G4bool multi=false);
|
||||
void SetSensitiveDetector(G4LogicalVolume* logVol,
|
||||
G4VSensitiveDetector* aSD);
|
||||
public:
|
||||
inline G4String GetName() { return fWorldName; }
|
||||
|
||||
protected:
|
||||
void SetSensitiveDetector(const G4String& logVolName,
|
||||
G4VSensitiveDetector* aSD, G4bool multi = false);
|
||||
void SetSensitiveDetector(G4LogicalVolume* logVol, G4VSensitiveDetector* aSD);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -25,24 +25,24 @@
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
// 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()
|
||||
// in his/her own concrete class derived from this class.
|
||||
// G4VUserPhysicsList::ConstructParticle()
|
||||
// Construct particles
|
||||
// G4VUserPhysicsList::ConstructProcess()
|
||||
// G4VUserPhysicsList::ConstructProcess()
|
||||
// Construct procesess and register them to particles
|
||||
//
|
||||
// -------------------------------------------
|
||||
// -------------------------------------------
|
||||
// History
|
||||
// first version 09 Jan. 1998 by H.Kurashige
|
||||
// first version 09 Jan. 1998 by H.Kurashige
|
||||
// modified 24 Jan. 1998 by H.Kurashige
|
||||
// rename DumpCutValues/DumpCutValuesTable
|
||||
// rename DumpCutValues/DumpCutValuesTable
|
||||
// change SetCuts method
|
||||
// add SetCutsWithDefault method
|
||||
// modified 06 June 1998 by H.Kurashige
|
||||
@@ -54,29 +54,29 @@
|
||||
// add ConstructAllParticles()
|
||||
// modified 14, Apr 1999 by H.Kurashige
|
||||
// change BuildPhysicsTable as public
|
||||
// removed ConstructAllParticles() and related methods
|
||||
// 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
|
||||
// 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()
|
||||
// modified for CUTS per REGION 10, Oct 2002 by H.Kurashige
|
||||
// removed following methods
|
||||
// void ReCalcCutValue()
|
||||
// void SetCutValueForOthers()
|
||||
// void SetCutValueForOtherThan()
|
||||
// void SetCutValueForOtherThan()
|
||||
// void ReCalcCutValueForOthers()
|
||||
// virtual G4bool StoreMaterialInfo()
|
||||
// virtual G4bool StoreCutValues()
|
||||
// virtual G4bool RetrieveCutValues()
|
||||
// virtual G4bool CheckForRetrievePhysicsTable()
|
||||
// virtual G4bool CheckMaterialInfo()
|
||||
// added void BuildPhysicsTable()
|
||||
// added void BuildPhysicsTable()
|
||||
// Added PhysicsListHelper 29 Apr. 2011 H.Kurashige
|
||||
// Added default impelmentation of SetCuts 10 June 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
|
||||
@@ -84,13 +84,13 @@
|
||||
#ifndef G4VUserPhysicsList_h
|
||||
#define G4VUserPhysicsList_h 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "tls.hh"
|
||||
#include "rundefs.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "globals.hh"
|
||||
#include "rundefs.hh"
|
||||
#include "tls.hh"
|
||||
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ProductionCutsTable.hh"
|
||||
#include "G4VUPLSplitter.hh"
|
||||
|
||||
@@ -102,15 +102,15 @@ 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;
|
||||
G4UserPhysicsListMessenger* _theMessenger;
|
||||
G4PhysicsListHelper* _thePLHelper;
|
||||
G4bool _fIsPhysicsTableBuilt;
|
||||
G4int _fDisplayThreshold;
|
||||
};
|
||||
// The type G4VUPLManager is introduced to encapsulate the methods used by
|
||||
// both the master thread and worker threads to allocate memory space for
|
||||
@@ -134,10 +134,11 @@ public:
|
||||
// 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 guarantee that the system works without
|
||||
// problems in case of this (unusual) case. This may be reviewed in the future
|
||||
// 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
|
||||
// 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;
|
||||
|
||||
@@ -150,273 +151,278 @@ typedef G4VUPLManager G4VUserPhysicsListSubInstanceManager;
|
||||
// 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)
|
||||
//#define theParticleIterator
|
||||
//((this->subInstanceManager.offset[this->g4vuplInstanceID])._theParticleIterator)
|
||||
|
||||
class G4VUserPhysicsList
|
||||
{
|
||||
public:
|
||||
G4VUserPhysicsList();
|
||||
virtual ~G4VUserPhysicsList();
|
||||
public:
|
||||
G4VUserPhysicsList();
|
||||
virtual ~G4VUserPhysicsList();
|
||||
|
||||
// copy constructor and assignment operator
|
||||
G4VUserPhysicsList(const G4VUserPhysicsList&);
|
||||
G4VUserPhysicsList & operator=(const G4VUserPhysicsList&);
|
||||
G4VUserPhysicsList(const G4VUserPhysicsList&);
|
||||
G4VUserPhysicsList& operator=(const G4VUserPhysicsList&);
|
||||
|
||||
public: // with description
|
||||
// Each particle type will be instantiated
|
||||
// This method is invoked by the RunManger
|
||||
virtual void ConstructParticle() = 0;
|
||||
public: // with description
|
||||
// Each particle type will be instantiated
|
||||
// This method is invoked by the RunManger
|
||||
virtual void ConstructParticle() = 0;
|
||||
|
||||
// By calling the "Construct" method,
|
||||
// process manager and processes are created.
|
||||
void Construct();
|
||||
|
||||
// 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;
|
||||
// By calling the "Construct" method,
|
||||
// process manager and processes are created.
|
||||
void Construct();
|
||||
|
||||
protected: // with description
|
||||
// User must invoke this method in his ConstructProcess()
|
||||
// implementation in order to insures particle transportation.
|
||||
void AddTransportation();
|
||||
// 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;
|
||||
|
||||
//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);
|
||||
protected: // with description
|
||||
// User must invoke this method in his ConstructProcess()
|
||||
// implementation in order to insures particle transportation.
|
||||
void AddTransportation();
|
||||
|
||||
// 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);
|
||||
|
||||
public:
|
||||
void UseCoupledTransportation(G4bool vl=true);
|
||||
public:
|
||||
void UseCoupledTransportation(G4bool vl = true);
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
public: // with description
|
||||
// "SetCuts" method sets a cut value for all particle types
|
||||
// in the particle table
|
||||
virtual void SetCuts();
|
||||
public: // with description
|
||||
// "SetCuts" method sets a cut value for all particle types
|
||||
// in the particle table
|
||||
virtual void SetCuts();
|
||||
|
||||
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;
|
||||
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;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
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();
|
||||
|
||||
// do PreparePhysicsTable for specified particle type
|
||||
void PreparePhysicsTable(G4ParticleDefinition* );
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
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();
|
||||
|
||||
// do BuildPhysicsTable for specified particle type
|
||||
void BuildPhysicsTable(G4ParticleDefinition* );
|
||||
// do PreparePhysicsTable for specified particle type
|
||||
void PreparePhysicsTable(G4ParticleDefinition*);
|
||||
|
||||
// Store PhysicsTable together with both material and cut value
|
||||
// information in files under the specified directory.
|
||||
// (return true if files are sucessfully created)
|
||||
G4bool StorePhysicsTable(const G4String& directory = ".");
|
||||
|
||||
// Return true if "Retrieve" flag is ON.
|
||||
// (i.e. PhysicsTable will be retrieved from files)
|
||||
G4bool IsPhysicsTableRetrieved() const;
|
||||
G4bool IsStoredInAscii() const;
|
||||
// do BuildPhysicsTable for specified particle type
|
||||
void BuildPhysicsTable(G4ParticleDefinition*);
|
||||
|
||||
// Get directory path for physics table files.
|
||||
const G4String& GetPhysicsTableDirectory() const;
|
||||
// Store PhysicsTable together with both material and cut value
|
||||
// information in files under the specified directory.
|
||||
// (return true if files are sucessfully created)
|
||||
G4bool StorePhysicsTable(const G4String& directory = ".");
|
||||
|
||||
// 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();
|
||||
|
||||
// Reset "Retrieve" flag
|
||||
void ResetPhysicsTableRetrieved();
|
||||
void ResetStoredInAscii();
|
||||
// Return true if "Retrieve" flag is ON.
|
||||
// (i.e. PhysicsTable will be retrieved from files)
|
||||
G4bool IsPhysicsTableRetrieved() const;
|
||||
G4bool IsStoredInAscii() const;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
public: // with description
|
||||
// Print out the List of registered particles types
|
||||
void DumpList() const;
|
||||
// Get directory path for physics table files.
|
||||
const G4String& GetPhysicsTableDirectory() const;
|
||||
|
||||
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);
|
||||
// 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();
|
||||
|
||||
// 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();
|
||||
// Reset "Retrieve" flag
|
||||
void ResetPhysicsTableRetrieved();
|
||||
void ResetStoredInAscii();
|
||||
|
||||
public: // with description
|
||||
void SetVerboseLevel(G4int value);
|
||||
G4int GetVerboseLevel() const;
|
||||
// set/get controle flag for output message
|
||||
// 0: Silent
|
||||
// 1: Warning message
|
||||
// 2: More
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
public: // with description
|
||||
// Print out the List of registered particles types
|
||||
void DumpList() const;
|
||||
|
||||
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);
|
||||
|
||||
// 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();
|
||||
|
||||
public: // with description
|
||||
void SetVerboseLevel(G4int value);
|
||||
G4int GetVerboseLevel() const;
|
||||
// set/get controle flag for output message
|
||||
// 0: Silent
|
||||
// 1: Warning message
|
||||
// 2: More
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
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();
|
||||
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();
|
||||
|
||||
// Following are utility methods for SetCuts
|
||||
|
||||
// SetCutValue sets a cut value for a particle type for the default region
|
||||
void SetCutValue(G4double aCut, const G4String& pname);
|
||||
// Following are utility methods for SetCuts
|
||||
|
||||
// GetCutValue sets a cut value for a particle type for the default region
|
||||
G4double GetCutValue(const G4String& pname) const;
|
||||
// SetCutValue sets a cut value for a particle type for the default region
|
||||
void SetCutValue(G4double aCut, const G4String& pname);
|
||||
|
||||
// SetCutValue sets a cut value for a particle type for a region
|
||||
void SetCutValue(G4double aCut, const G4String& pname, const G4String& rname);
|
||||
// GetCutValue sets a cut value for a particle type for the default region
|
||||
G4double GetCutValue(const G4String& pname) const;
|
||||
|
||||
// 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);
|
||||
// SetCutValue sets a cut value for a particle type for a region
|
||||
void SetCutValue(G4double aCut, const G4String& pname, const G4String& rname);
|
||||
|
||||
// Invoke SetCuts for all particles in a region
|
||||
void SetCutsForRegion(G4double aCut, const G4String& rname);
|
||||
// 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);
|
||||
|
||||
// Following are utility methods are obsolete
|
||||
void ResetCuts();
|
||||
// Invoke SetCuts for all particles in a region
|
||||
void SetCutsForRegion(G4double aCut, const G4String& rname);
|
||||
|
||||
///////////////////////////////////////////////////////////////////
|
||||
public:
|
||||
// Get/SetApplyCuts gets/sets the flag for ApplyCuts
|
||||
void SetApplyCuts(G4bool value, const G4String& name);
|
||||
G4bool GetApplyCuts(const G4String& name) const;
|
||||
// Following are utility methods are obsolete
|
||||
void ResetCuts();
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
// do BuildPhysicsTable for make the integral schema
|
||||
void BuildIntegralPhysicsTable(G4VProcess* ,G4ParticleDefinition* );
|
||||
///////////////////////////////////////////////////////////////////
|
||||
public:
|
||||
// Get/SetApplyCuts gets/sets the flag for ApplyCuts
|
||||
void SetApplyCuts(G4bool value, const G4String& name);
|
||||
G4bool GetApplyCuts(const G4String& name) const;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
// do BuildPhysicsTable for make the integral schema
|
||||
void BuildIntegralPhysicsTable(G4VProcess*, G4ParticleDefinition*);
|
||||
|
||||
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);
|
||||
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);
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
// adds new ProcessManager to all particles in the Particle Table
|
||||
// this routine is used in Construct()
|
||||
void InitializeProcessManager();
|
||||
/////////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
// adds new ProcessManager to all particles in the Particle Table
|
||||
// this routine is used in Construct()
|
||||
void InitializeProcessManager();
|
||||
|
||||
public: // with description
|
||||
// remove and delete ProcessManagers for all particles in tha Particle Table
|
||||
// this routine is invoked from RunManager
|
||||
void RemoveProcessManager();
|
||||
public: // with description
|
||||
// remove and delete ProcessManagers for all particles in tha Particle Table
|
||||
// this routine is invoked from RunManager
|
||||
void RemoveProcessManager();
|
||||
|
||||
public: // with description
|
||||
// add process manager for particles created on-the-fly
|
||||
void AddProcessManager(G4ParticleDefinition* newParticle,
|
||||
G4ProcessManager* newManager = 0 );
|
||||
|
||||
/////////////////////////////////////////////////////////////////
|
||||
public:
|
||||
// check consistencies of list of particles
|
||||
public: // with description
|
||||
// add process manager for particles created on-the-fly
|
||||
void AddProcessManager(G4ParticleDefinition* newParticle,
|
||||
G4ProcessManager* newManager = 0);
|
||||
|
||||
void CheckParticleList();
|
||||
/////////////////////////////////////////////////////////////////
|
||||
public:
|
||||
// check consistencies of list of particles
|
||||
|
||||
void CheckParticleList();
|
||||
|
||||
void DisableCheckParticleList();
|
||||
|
||||
void DisableCheckParticleList();
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
protected:
|
||||
// the particle table has the complete List of existing particle types
|
||||
G4ParticleTable* theParticleTable;
|
||||
//G4ParticleTable::G4PTblDicIterator* theParticleIterator; //AND
|
||||
protected:
|
||||
// the particle table has the complete List of existing particle types
|
||||
G4ParticleTable* theParticleTable;
|
||||
// G4ParticleTable::G4PTblDicIterator* theParticleIterator; //AND
|
||||
|
||||
protected:
|
||||
// pointer to G4UserPhysicsListMessenger
|
||||
//G4UserPhysicsListMessenger* theMessenger;
|
||||
protected:
|
||||
// pointer to G4UserPhysicsListMessenger
|
||||
// G4UserPhysicsListMessenger* theMessenger;
|
||||
|
||||
protected:
|
||||
G4int verboseLevel;
|
||||
protected:
|
||||
G4int verboseLevel;
|
||||
|
||||
protected:
|
||||
// this is the default cut value for all particles
|
||||
G4double defaultCutValue;
|
||||
G4bool isSetDefaultCutValue;
|
||||
protected:
|
||||
// this is the default cut value for all particles
|
||||
G4double defaultCutValue;
|
||||
G4bool isSetDefaultCutValue;
|
||||
|
||||
protected:
|
||||
// pointer to ProductionCutsTable
|
||||
G4ProductionCutsTable* fCutsTable;
|
||||
protected:
|
||||
// pointer to ProductionCutsTable
|
||||
G4ProductionCutsTable* fCutsTable;
|
||||
|
||||
// flag to determine physics table will be build from file or not
|
||||
G4bool fRetrievePhysicsTable;
|
||||
G4bool fStoredInAscii;
|
||||
|
||||
G4bool fIsCheckedForRetrievePhysicsTable;
|
||||
G4bool fIsRestoredCutValues;
|
||||
// flag to determine physics table will be build from file or not
|
||||
G4bool fRetrievePhysicsTable;
|
||||
G4bool fStoredInAscii;
|
||||
|
||||
// directory name for physics table files
|
||||
G4String directoryPhysicsTable;
|
||||
G4bool fIsCheckedForRetrievePhysicsTable;
|
||||
G4bool fIsRestoredCutValues;
|
||||
|
||||
// flag for displaying the range cuts & energy thresholds
|
||||
//G4int fDisplayThreshold;
|
||||
// directory name for physics table files
|
||||
G4String directoryPhysicsTable;
|
||||
|
||||
// flag for Physics Table has been built
|
||||
//G4bool fIsPhysicsTableBuilt;
|
||||
// flag for displaying the range cuts & energy thresholds
|
||||
// G4int fDisplayThreshold;
|
||||
|
||||
// flag for CheckParticleList
|
||||
G4bool fDisableCheckParticleList;
|
||||
// flag for Physics Table has been built
|
||||
// G4bool fIsPhysicsTableBuilt;
|
||||
|
||||
// flag for CheckParticleList
|
||||
G4bool fDisableCheckParticleList;
|
||||
|
||||
// PhysicsListHelper
|
||||
//G4PhysicsListHelper* thePLHelper;
|
||||
// G4PhysicsListHelper* thePLHelper;
|
||||
|
||||
private:
|
||||
enum { FixedStringLengthForStore = 32 };
|
||||
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();
|
||||
// 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();
|
||||
};
|
||||
|
||||
inline void G4VUserPhysicsList::Construct()
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel >1) G4cout << "G4VUserPhysicsList::Construct()" << G4endl;
|
||||
#ifdef G4VERBOSE
|
||||
if(verboseLevel > 1)
|
||||
G4cout << "G4VUserPhysicsList::Construct()" << G4endl;
|
||||
#endif
|
||||
|
||||
InitializeProcessManager();
|
||||
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel >1) G4cout << "Construct processes " << G4endl;
|
||||
#ifdef G4VERBOSE
|
||||
if(verboseLevel > 1)
|
||||
G4cout << "Construct processes " << G4endl;
|
||||
#endif
|
||||
ConstructProcess();
|
||||
|
||||
}
|
||||
|
||||
inline G4double G4VUserPhysicsList::GetDefaultCutValue() const
|
||||
@@ -424,68 +430,49 @@ inline G4double G4VUserPhysicsList::GetDefaultCutValue() const
|
||||
return defaultCutValue;
|
||||
}
|
||||
|
||||
|
||||
inline G4int G4VUserPhysicsList::GetVerboseLevel() const
|
||||
inline G4int G4VUserPhysicsList::GetVerboseLevel() const
|
||||
{
|
||||
return verboseLevel;
|
||||
return verboseLevel;
|
||||
}
|
||||
|
||||
inline
|
||||
G4bool G4VUserPhysicsList::IsPhysicsTableRetrieved() const
|
||||
inline G4bool G4VUserPhysicsList::IsPhysicsTableRetrieved() const
|
||||
{
|
||||
return fRetrievePhysicsTable;
|
||||
return fRetrievePhysicsTable;
|
||||
}
|
||||
|
||||
inline
|
||||
G4bool G4VUserPhysicsList::IsStoredInAscii() const
|
||||
inline G4bool G4VUserPhysicsList::IsStoredInAscii() const
|
||||
{
|
||||
return fStoredInAscii;
|
||||
}
|
||||
|
||||
inline
|
||||
const G4String& G4VUserPhysicsList::GetPhysicsTableDirectory() const
|
||||
inline const G4String& G4VUserPhysicsList::GetPhysicsTableDirectory() const
|
||||
{
|
||||
return directoryPhysicsTable;
|
||||
return directoryPhysicsTable;
|
||||
}
|
||||
|
||||
inline
|
||||
void G4VUserPhysicsList::SetStoredInAscii()
|
||||
inline void G4VUserPhysicsList::SetStoredInAscii() { fStoredInAscii = true; }
|
||||
|
||||
inline void G4VUserPhysicsList::ResetPhysicsTableRetrieved()
|
||||
{
|
||||
fStoredInAscii = true;
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
void G4VUserPhysicsList::ResetPhysicsTableRetrieved()
|
||||
{
|
||||
fRetrievePhysicsTable = false;
|
||||
fIsRestoredCutValues = false;
|
||||
fIsCheckedForRetrievePhysicsTable=false;
|
||||
fRetrievePhysicsTable = false;
|
||||
fIsRestoredCutValues = false;
|
||||
fIsCheckedForRetrievePhysicsTable = false;
|
||||
}
|
||||
|
||||
inline void G4VUserPhysicsList::ResetStoredInAscii() { fStoredInAscii = false; }
|
||||
|
||||
inline
|
||||
void G4VUserPhysicsList::ResetStoredInAscii()
|
||||
{
|
||||
fStoredInAscii = false;
|
||||
}
|
||||
|
||||
inline
|
||||
void G4VUserPhysicsList::DisableCheckParticleList()
|
||||
inline void G4VUserPhysicsList::DisableCheckParticleList()
|
||||
{
|
||||
fDisableCheckParticleList = true;
|
||||
}
|
||||
|
||||
inline
|
||||
G4int G4VUserPhysicsList::GetInstanceID() const
|
||||
inline G4int G4VUserPhysicsList::GetInstanceID() const
|
||||
{
|
||||
return g4vuplInstanceID;
|
||||
return g4vuplInstanceID;
|
||||
}
|
||||
|
||||
inline
|
||||
const G4VUPLManager& G4VUserPhysicsList::GetSubInstanceManager()
|
||||
inline const G4VUPLManager& G4VUserPhysicsList::GetSubInstanceManager()
|
||||
{
|
||||
return subInstanceManager;
|
||||
return subInstanceManager;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -38,22 +38,21 @@ class G4Event;
|
||||
// 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
|
||||
// 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:
|
||||
G4VUserPrimaryGeneratorAction();
|
||||
virtual ~G4VUserPrimaryGeneratorAction();
|
||||
|
||||
public:
|
||||
virtual void GeneratePrimaries(G4Event* anEvent) = 0;
|
||||
public:
|
||||
virtual void GeneratePrimaries(G4Event* anEvent) = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -32,9 +32,9 @@
|
||||
// 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
|
||||
// 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.
|
||||
// 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.
|
||||
|
||||
#ifndef G4WorkerRunManager_h
|
||||
#define G4WorkerRunManager_h 1
|
||||
@@ -44,71 +44,79 @@
|
||||
class G4WorkerThread;
|
||||
class G4WorkerRunManagerKernel;
|
||||
|
||||
class G4WorkerRunManager : public G4RunManager {
|
||||
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();
|
||||
class G4WorkerRunManager : public G4RunManager
|
||||
{
|
||||
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();
|
||||
|
||||
//This function is called by the thread function: it should loop until some
|
||||
//work is requested
|
||||
virtual void DoWork();
|
||||
protected:
|
||||
virtual void ConstructScoringWorlds();
|
||||
virtual void StoreRNGStatus(const G4String& filenamePrefix );
|
||||
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; }
|
||||
private:
|
||||
G4WorkerThread* workerContext;
|
||||
void SetupDefaultRNGEngine();
|
||||
// This function is called by the thread function: it should loop until some
|
||||
// work is requested
|
||||
virtual void DoWork();
|
||||
|
||||
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:
|
||||
virtual void ConstructScoringWorlds();
|
||||
virtual void StoreRNGStatus(const G4String& filenamePrefix);
|
||||
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; }
|
||||
|
||||
protected:
|
||||
G4bool eventLoopOnGoing;
|
||||
G4bool runIsSeeded;
|
||||
G4int nevModulo;
|
||||
G4int currEvID;
|
||||
G4int luxury;
|
||||
G4SeedsQueue seedsQueue;
|
||||
G4bool readStatusFromFile;
|
||||
|
||||
public:
|
||||
virtual void RestoreRndmEachEvent(G4bool flag) { readStatusFromFile = flag; }
|
||||
protected:
|
||||
G4WorkerThread* workerContext;
|
||||
#ifdef G4MULTITHREADED
|
||||
private:
|
||||
G4bool visIsSetUp;
|
||||
G4bool visIsSetUp;
|
||||
#endif
|
||||
|
||||
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;
|
||||
|
||||
public:
|
||||
virtual void RestoreRndmEachEvent(G4bool flag) { readStatusFromFile = flag; }
|
||||
};
|
||||
|
||||
#endif //G4WorkerRunManager_h
|
||||
#endif // G4WorkerRunManager_h
|
||||
|
||||
@@ -31,11 +31,11 @@
|
||||
// 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.
|
||||
// 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
|
||||
@@ -56,13 +56,15 @@
|
||||
|
||||
#include "G4RunManagerKernel.hh"
|
||||
|
||||
class G4WorkerRunManagerKernel : public G4RunManagerKernel {
|
||||
public:
|
||||
G4WorkerRunManagerKernel();
|
||||
virtual ~G4WorkerRunManagerKernel();
|
||||
protected:
|
||||
//Overwrite default behavior
|
||||
void SetupShadowProcess() const;
|
||||
class G4WorkerRunManagerKernel : public G4RunManagerKernel
|
||||
{
|
||||
public:
|
||||
G4WorkerRunManagerKernel();
|
||||
virtual ~G4WorkerRunManagerKernel();
|
||||
|
||||
protected:
|
||||
// Overwrite default behavior
|
||||
void SetupShadowProcess() const;
|
||||
};
|
||||
|
||||
#endif //G4WorkerRunManagerKernel_h
|
||||
#endif // G4WorkerRunManagerKernel_h
|
||||
|
||||
@@ -34,31 +34,30 @@
|
||||
|
||||
#ifndef G4WorkerThread_hh
|
||||
#define G4WorkerThread_hh
|
||||
#include "G4Types.hh"
|
||||
#include "G4String.hh"
|
||||
#include "G4Types.hh"
|
||||
|
||||
#include "G4Threading.hh"
|
||||
|
||||
class G4WorkerThread {
|
||||
public:
|
||||
void SetThreadId( G4int threadId );
|
||||
G4int GetThreadId() const;
|
||||
|
||||
void SetNumberThreads( G4int numnberThreads );
|
||||
G4int GetNumberThreads() const;
|
||||
|
||||
//Build geometry for workers
|
||||
static void BuildGeometryAndPhysicsVector();
|
||||
static void DestroyGeometryAndPhysicsVector();
|
||||
static void UpdateGeometryAndPhysicsVectorFromMaster();
|
||||
class G4WorkerThread
|
||||
{
|
||||
public:
|
||||
void SetThreadId(G4int threadId);
|
||||
G4int GetThreadId() const;
|
||||
|
||||
//Setting Pin Affinity
|
||||
void SetPinAffinity(G4int aff) const;
|
||||
void SetNumberThreads(G4int numnberThreads);
|
||||
G4int GetNumberThreads() const;
|
||||
|
||||
private:
|
||||
G4int threadId;
|
||||
G4int numThreads;
|
||||
|
||||
// Build geometry for workers
|
||||
static void BuildGeometryAndPhysicsVector();
|
||||
static void DestroyGeometryAndPhysicsVector();
|
||||
static void UpdateGeometryAndPhysicsVectorFromMaster();
|
||||
|
||||
// Setting Pin Affinity
|
||||
void SetPinAffinity(G4int aff) const;
|
||||
|
||||
private:
|
||||
G4int threadId;
|
||||
G4int numThreads;
|
||||
};
|
||||
#endif //G4WorkerThread_hh
|
||||
|
||||
#endif // G4WorkerThread_hh
|
||||
|
||||
@@ -35,16 +35,16 @@
|
||||
#include "G4Types.hh"
|
||||
|
||||
#ifdef WIN32
|
||||
//
|
||||
// Unique identifier for global module
|
||||
//
|
||||
#if defined G4RUN_ALLOC_EXPORT
|
||||
#define G4RUN_DLL G4DLLEXPORT
|
||||
#else
|
||||
#define G4RUN_DLL G4DLLIMPORT
|
||||
#endif
|
||||
//
|
||||
// Unique identifier for global module
|
||||
//
|
||||
# if defined G4RUN_ALLOC_EXPORT
|
||||
# define G4RUN_DLL G4DLLEXPORT
|
||||
# else
|
||||
# define G4RUN_DLL G4DLLIMPORT
|
||||
# endif
|
||||
#else
|
||||
#define G4RUN_DLL
|
||||
# define G4RUN_DLL
|
||||
#endif
|
||||
|
||||
#endif /* G4RUNDEFS_HH */
|
||||
|
||||
+112
-172
@@ -1,184 +1,124 @@
|
||||
#------------------------------------------------------------------------------
|
||||
# sources.cmake
|
||||
# Module : G4run
|
||||
# Package: Geant4.src.G4run
|
||||
#
|
||||
# Sources description for a library.
|
||||
# Lists the sources and headers of the code explicitely.
|
||||
# Lists include paths needed.
|
||||
# Lists the internal granular and global dependencies of the library.
|
||||
# Source specific properties should be added at the end.
|
||||
#
|
||||
# Generated on : 24/9/2010
|
||||
#
|
||||
#
|
||||
#------------------------------------------------------------------------------
|
||||
|
||||
# List external includes needed.
|
||||
include_directories(${CLHEP_INCLUDE_DIRS})
|
||||
|
||||
# List internal includes needed.
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/digits_hits/detector/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/digits_hits/digits/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/digits_hits/hits/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/digits_hits/utils/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/event/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/biasing/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/magneticfield/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/management/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/navigation/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/volumes/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPGeometry/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPRandom/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/global/HEPNumerics/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/global/management/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/graphics_reps/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/intercoms/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/materials/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/particles/management/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/processes/cuts/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/processes/decay/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/processes/electromagnetic/utils/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/processes/management/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/processes/scoring/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/processes/transportation/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/track/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/tracking/include)
|
||||
#TODO ANDREA: TODO REMOVE THIS DEPENDENCY AFTER REFACTORING G4WorkerThread and removing explicit BERT initialization
|
||||
# Check also granula dependency
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/geometry/solids/specific/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/processes/hadronic/models/cascade/cascade/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/processes/hadronic/models/management/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/processes/hadronic/models/util/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/processes/hadronic/util/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/particles/bosons/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/particles/leptons/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/particles/hadrons/mesons/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/particles/hadrons/barions/include)
|
||||
include_directories(${CMAKE_SOURCE_DIR}/source/particles/hadrons/ions/include)
|
||||
|
||||
#Will need this when we'll enable tpmalloc
|
||||
#if(GEANT4_BUILD_MULTITHREADED)
|
||||
#include_directories(${CMAKE_SOURCE_DIR}/source/externals/tpmalloc/include)
|
||||
#endif()
|
||||
|
||||
#
|
||||
# Define the Geant4 Module.
|
||||
#
|
||||
include(Geant4MacroDefineModule)
|
||||
GEANT4_DEFINE_MODULE(NAME G4run
|
||||
HEADERS
|
||||
G4AdjointPrimaryGeneratorAction.hh
|
||||
G4AdjointSimManager.hh
|
||||
G4AdjointSimMessenger.hh
|
||||
G4ExceptionHandler.hh
|
||||
G4MSSteppingAction.hh
|
||||
G4MatScanMessenger.hh
|
||||
G4MaterialScanner.hh
|
||||
G4PhysicsListHelper.hh
|
||||
G4PhysicsListOrderingParameter.hh
|
||||
G4PhysicsListWorkspace.hh
|
||||
G4Run.hh
|
||||
G4RunManager.hh
|
||||
G4MTRunManager.hh
|
||||
G4WorkerRunManager.hh
|
||||
G4RunManagerKernel.hh
|
||||
G4MTRunManagerKernel.hh
|
||||
G4WorkerRunManagerKernel.hh
|
||||
G4RunMessenger.hh
|
||||
G4UserPhysicsListMessenger.hh
|
||||
G4UserRunAction.hh
|
||||
G4MultiRunAction.hh
|
||||
G4UserWorkerInitialization.hh
|
||||
G4UserWorkerThreadInitialization.hh
|
||||
G4VModularPhysicsList.hh
|
||||
G4VPersistencyManager.hh
|
||||
G4VPhysicsConstructor.hh
|
||||
G4VUserActionInitialization.hh
|
||||
G4VUserDetectorConstruction.hh
|
||||
G4VUserParallelWorld.hh
|
||||
G4VUserPhysicsList.hh
|
||||
G4VUserPrimaryGeneratorAction.hh
|
||||
G4WorkerThread.hh
|
||||
G4VUPLSplitter.hh
|
||||
rundefs.hh
|
||||
G4RNGHelper.hh
|
||||
G4PhysicsBuilderInterface.hh
|
||||
SOURCES
|
||||
G4AdjointPrimaryGeneratorAction.cc
|
||||
G4AdjointSimManager.cc
|
||||
G4AdjointSimMessenger.cc
|
||||
G4ExceptionHandler.cc
|
||||
G4MSSteppingAction.cc
|
||||
G4MatScanMessenger.cc
|
||||
G4MaterialScanner.cc
|
||||
G4PhysicsListHelper.cc
|
||||
G4PhysicsListOrderingParamater.cc
|
||||
G4PhysicsListWorkspace.cc
|
||||
G4Run.cc
|
||||
G4RunManager.cc
|
||||
G4MTRunManager.cc
|
||||
G4WorkerRunManager.cc
|
||||
G4RunManagerKernel.cc
|
||||
G4MTRunManagerKernel.cc
|
||||
G4WorkerRunManagerKernel.cc
|
||||
G4RunMessenger.cc
|
||||
G4UserPhysicsListMessenger.cc
|
||||
G4UserRunAction.cc
|
||||
G4MultiRunAction.cc
|
||||
G4UserWorkerInitialization.cc
|
||||
G4UserWorkerThreadInitialization.cc
|
||||
G4VModularPhysicsList.cc
|
||||
G4VPersistencyManager.cc
|
||||
G4VUserActionInitialization.cc
|
||||
G4VUserDetectorConstruction.cc
|
||||
G4VUserParallelWorld.cc
|
||||
G4VPhysicsConstructor.cc
|
||||
G4VUserPhysicsList.cc
|
||||
G4VUserPrimaryGeneratorAction.cc
|
||||
geant4_define_module(NAME G4run
|
||||
HEADERS
|
||||
G4AdjointPrimaryGeneratorAction.hh
|
||||
G4AdjointSimManager.hh
|
||||
G4AdjointSimMessenger.hh
|
||||
G4ExceptionHandler.hh
|
||||
G4MSSteppingAction.hh
|
||||
G4MatScanMessenger.hh
|
||||
G4MaterialScanner.hh
|
||||
G4PhysicsListHelper.hh
|
||||
G4PhysicsListOrderingParameter.hh
|
||||
G4PhysicsListWorkspace.hh
|
||||
G4Run.hh
|
||||
G4RunManager.hh
|
||||
G4MTRunManager.hh
|
||||
G4WorkerRunManager.hh
|
||||
G4RunManagerKernel.hh
|
||||
G4MTRunManagerKernel.hh
|
||||
G4WorkerRunManagerKernel.hh
|
||||
G4RunMessenger.hh
|
||||
G4UserPhysicsListMessenger.hh
|
||||
G4UserRunAction.hh
|
||||
G4MultiRunAction.hh
|
||||
G4UserWorkerInitialization.hh
|
||||
G4UserWorkerThreadInitialization.hh
|
||||
G4VModularPhysicsList.hh
|
||||
G4VPersistencyManager.hh
|
||||
G4VPhysicsConstructor.hh
|
||||
G4VUserActionInitialization.hh
|
||||
G4VUserDetectorConstruction.hh
|
||||
G4VUserParallelWorld.hh
|
||||
G4VUserPhysicsList.hh
|
||||
G4VUserPrimaryGeneratorAction.hh
|
||||
G4WorkerThread.hh
|
||||
G4VUPLSplitter.hh
|
||||
rundefs.hh
|
||||
G4RNGHelper.hh
|
||||
G4PhysicsBuilderInterface.hh
|
||||
SOURCES
|
||||
G4AdjointPrimaryGeneratorAction.cc
|
||||
G4AdjointSimManager.cc
|
||||
G4AdjointSimMessenger.cc
|
||||
G4ExceptionHandler.cc
|
||||
G4MSSteppingAction.cc
|
||||
G4MatScanMessenger.cc
|
||||
G4MaterialScanner.cc
|
||||
G4PhysicsListHelper.cc
|
||||
G4PhysicsListOrderingParamater.cc
|
||||
G4PhysicsListWorkspace.cc
|
||||
G4Run.cc
|
||||
G4RunManager.cc
|
||||
G4MTRunManager.cc
|
||||
G4WorkerRunManager.cc
|
||||
G4RunManagerKernel.cc
|
||||
G4MTRunManagerKernel.cc
|
||||
G4WorkerRunManagerKernel.cc
|
||||
G4RunMessenger.cc
|
||||
G4UserPhysicsListMessenger.cc
|
||||
G4UserRunAction.cc
|
||||
G4MultiRunAction.cc
|
||||
G4UserWorkerInitialization.cc
|
||||
G4UserWorkerThreadInitialization.cc
|
||||
G4VModularPhysicsList.cc
|
||||
G4VPersistencyManager.cc
|
||||
G4VUserActionInitialization.cc
|
||||
G4VUserDetectorConstruction.cc
|
||||
G4VUserParallelWorld.cc
|
||||
G4VPhysicsConstructor.cc
|
||||
G4VUserPhysicsList.cc
|
||||
G4VUserPrimaryGeneratorAction.cc
|
||||
G4WorkerThread.cc
|
||||
G4RNGHelper.cc
|
||||
GRANULAR_DEPENDENCIES
|
||||
G4cuts
|
||||
G4decay
|
||||
G4detector
|
||||
G4detutils
|
||||
G4digits
|
||||
G4emutils
|
||||
G4event
|
||||
G4geombias
|
||||
G4geometrymng
|
||||
G4globman
|
||||
G4graphics_reps
|
||||
G4hepnumerics
|
||||
G4hits
|
||||
G4intercoms
|
||||
G4magneticfield
|
||||
G4materials
|
||||
G4navigation
|
||||
G4partman
|
||||
G4procman
|
||||
G4scoring
|
||||
G4track
|
||||
G4tracking
|
||||
G4transportation
|
||||
G4volumes
|
||||
G4specsolids
|
||||
GLOBAL_DEPENDENCIES
|
||||
G4digits_hits
|
||||
G4event
|
||||
G4geometry
|
||||
G4global
|
||||
G4graphics_reps
|
||||
G4intercoms
|
||||
G4materials
|
||||
G4particles
|
||||
G4processes
|
||||
G4track
|
||||
G4tracking
|
||||
LINK_LIBRARIES
|
||||
${timemory_LIBRARIES}
|
||||
G4RNGHelper.cc
|
||||
GRANULAR_DEPENDENCIES
|
||||
G4cuts
|
||||
G4decay
|
||||
G4detector
|
||||
G4detutils
|
||||
G4digits
|
||||
G4emutils
|
||||
G4event
|
||||
G4geombias
|
||||
G4geometrymng
|
||||
G4globman
|
||||
G4graphics_reps
|
||||
G4hepnumerics
|
||||
G4hits
|
||||
G4intercoms
|
||||
G4magneticfield
|
||||
G4materials
|
||||
G4navigation
|
||||
G4partman
|
||||
G4procman
|
||||
G4scoring
|
||||
G4track
|
||||
G4tracking
|
||||
G4transportation
|
||||
G4volumes
|
||||
G4specsolids
|
||||
GLOBAL_DEPENDENCIES
|
||||
G4digits_hits
|
||||
G4event
|
||||
G4geometry
|
||||
G4global
|
||||
G4graphics_reps
|
||||
G4intercoms
|
||||
G4materials
|
||||
G4particles
|
||||
G4processes
|
||||
G4ptl
|
||||
G4track
|
||||
G4tracking
|
||||
LINK_LIBRARIES
|
||||
${timemory_LIBRARIES}
|
||||
)
|
||||
|
||||
# List any source specific properties here
|
||||
|
||||
|
||||
@@ -34,36 +34,39 @@
|
||||
|
||||
#include "G4AdjointPrimaryGeneratorAction.hh"
|
||||
|
||||
#include "G4PhysicalConstants.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4AdjointSimManager.hh"
|
||||
#include "G4AdjointPrimaryGenerator.hh"
|
||||
#include "G4AdjointSimManager.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4Gamma.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4PhysicalConstants.hh"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4AdjointPrimaryGeneratorAction::G4AdjointPrimaryGeneratorAction()
|
||||
: Emin(0.), Emax(0.), EminIon(0.), EmaxIon(0.),
|
||||
index_particle(100000),
|
||||
radius_spherical_source(0.), fwd_ion(0), adj_ion(0),
|
||||
ion_name("not_defined")
|
||||
: Emin(0.)
|
||||
, Emax(0.)
|
||||
, EminIon(0.)
|
||||
, EmaxIon(0.)
|
||||
, index_particle(100000)
|
||||
, radius_spherical_source(0.)
|
||||
, fwd_ion(0)
|
||||
, adj_ion(0)
|
||||
, ion_name("not_defined")
|
||||
{
|
||||
theAdjointPrimaryGenerator= new G4AdjointPrimaryGenerator();
|
||||
theAdjointPrimaryGenerator = new G4AdjointPrimaryGenerator();
|
||||
|
||||
PrimariesConsideredInAdjointSim[G4String("e-")]=false;
|
||||
PrimariesConsideredInAdjointSim[G4String("gamma")]=false;
|
||||
PrimariesConsideredInAdjointSim[G4String("proton")]=false;
|
||||
PrimariesConsideredInAdjointSim[G4String("ion")]=false;
|
||||
PrimariesConsideredInAdjointSim[G4String("e-")] = false;
|
||||
PrimariesConsideredInAdjointSim[G4String("gamma")] = false;
|
||||
PrimariesConsideredInAdjointSim[G4String("proton")] = false;
|
||||
PrimariesConsideredInAdjointSim[G4String("ion")] = false;
|
||||
|
||||
ListOfPrimaryFwdParticles.clear();
|
||||
ListOfPrimaryAdjParticles.clear();
|
||||
nb_fwd_gammas_per_event = 1;
|
||||
nb_adj_primary_gammas_per_event = 1;
|
||||
nb_fwd_gammas_per_event = 1;
|
||||
nb_adj_primary_gammas_per_event = 1;
|
||||
nb_adj_primary_electrons_per_event = 1;
|
||||
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -75,253 +78,287 @@ G4AdjointPrimaryGeneratorAction::~G4AdjointPrimaryGeneratorAction()
|
||||
//
|
||||
void G4AdjointPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
|
||||
{
|
||||
G4int evt_id = anEvent->GetEventID();
|
||||
size_t n = ListOfPrimaryAdjParticles.size();
|
||||
index_particle = size_t(evt_id) - n * (size_t(evt_id) / n);
|
||||
|
||||
G4int evt_id=anEvent->GetEventID();
|
||||
size_t n=ListOfPrimaryAdjParticles.size();
|
||||
index_particle=size_t(evt_id)-n*(size_t(evt_id)/n);
|
||||
G4double E1 = Emin;
|
||||
G4double E2 = Emax;
|
||||
if(!ListOfPrimaryAdjParticles[index_particle])
|
||||
UpdateListOfPrimaryParticles(); // ion has not been created yet
|
||||
|
||||
if(ListOfPrimaryAdjParticles[index_particle]->GetParticleName() ==
|
||||
"adj_proton")
|
||||
{
|
||||
E1 = EminIon;
|
||||
E2 = EmaxIon;
|
||||
}
|
||||
if(ListOfPrimaryAdjParticles[index_particle]->GetParticleType() ==
|
||||
"adjoint_nucleus")
|
||||
{
|
||||
G4int A = ListOfPrimaryAdjParticles[index_particle]->GetAtomicMass();
|
||||
E1 = EminIon * A;
|
||||
E2 = EmaxIon * A;
|
||||
}
|
||||
// Generate first the forwrad primaries
|
||||
theAdjointPrimaryGenerator->GenerateFwdPrimaryVertex(
|
||||
anEvent, ListOfPrimaryFwdParticles[index_particle], E1, E2);
|
||||
G4PrimaryVertex* fwdPrimVertex = anEvent->GetPrimaryVertex();
|
||||
|
||||
p = fwdPrimVertex->GetPrimary()->GetMomentum();
|
||||
pos = fwdPrimVertex->GetPosition();
|
||||
G4double pmag = p.mag();
|
||||
G4double m0 = ListOfPrimaryFwdParticles[index_particle]->GetPDGMass();
|
||||
G4double ekin = std::sqrt(m0 * m0 + pmag * pmag) - m0;
|
||||
|
||||
G4double weight_correction = 1.;
|
||||
// For gamma generate the particle along the backward ray
|
||||
G4ThreeVector dir = -p / p.mag();
|
||||
|
||||
/*if (ListOfPrimaryAdjParticles[index_particle]->GetParticleName() ==
|
||||
"adj_gamma"){
|
||||
|
||||
theAdjointPrimaryGenerator
|
||||
->ComputeAccumulatedDepthVectorAlongBackRay(pos,dir,ekin,ListOfPrimaryAdjParticles[index_particle]);
|
||||
|
||||
|
||||
G4double E1=Emin;
|
||||
G4double E2=Emax;
|
||||
if (!ListOfPrimaryAdjParticles[index_particle]) UpdateListOfPrimaryParticles();//ion has not been created yet
|
||||
G4double distance = theAdjointPrimaryGenerator
|
||||
->SampleDistanceAlongBackRayAndComputeWeightCorrection(weight_correction);
|
||||
|
||||
if (ListOfPrimaryAdjParticles[index_particle]->GetParticleName() == "adj_proton") {
|
||||
E1=EminIon;
|
||||
E2=EmaxIon;
|
||||
}
|
||||
if (ListOfPrimaryAdjParticles[index_particle]->GetParticleType() == "adjoint_nucleus") {
|
||||
G4int A= ListOfPrimaryAdjParticles[index_particle]->GetAtomicMass();
|
||||
E1=EminIon*A;
|
||||
E2=EmaxIon*A;
|
||||
}
|
||||
//Generate first the forwrad primaries
|
||||
theAdjointPrimaryGenerator->GenerateFwdPrimaryVertex(anEvent,ListOfPrimaryFwdParticles[index_particle],E1,E2);
|
||||
G4PrimaryVertex* fwdPrimVertex = anEvent->GetPrimaryVertex();
|
||||
//pos=pos+dir*distance;
|
||||
//fwdPrimVertex->SetPosition(pos[0],pos[1],pos[2]);
|
||||
}
|
||||
*/
|
||||
weight_correction = 1.;
|
||||
|
||||
p=fwdPrimVertex->GetPrimary()->GetMomentum();
|
||||
pos=fwdPrimVertex->GetPosition();
|
||||
G4double pmag=p.mag();
|
||||
G4double m0=ListOfPrimaryFwdParticles[index_particle]->GetPDGMass();
|
||||
G4double ekin=std::sqrt( m0*m0 + pmag*pmag) -m0;
|
||||
if(ListOfPrimaryFwdParticles[index_particle] == G4Gamma::Gamma() &&
|
||||
nb_fwd_gammas_per_event > 1)
|
||||
{
|
||||
G4double weight = (1. / nb_fwd_gammas_per_event);
|
||||
fwdPrimVertex->SetWeight(weight);
|
||||
for(int i = 0; i < nb_fwd_gammas_per_event - 1; i++)
|
||||
{
|
||||
G4PrimaryVertex* newFwdPrimVertex = new G4PrimaryVertex();
|
||||
newFwdPrimVertex->SetPosition(pos.x(), pos.y(), pos.z());
|
||||
newFwdPrimVertex->SetT0(0.);
|
||||
G4PrimaryParticle* aPrimParticle = new G4PrimaryParticle(
|
||||
ListOfPrimaryFwdParticles[index_particle], p.x(), p.y(), p.z());
|
||||
newFwdPrimVertex->SetPrimary(aPrimParticle);
|
||||
newFwdPrimVertex->SetWeight(weight);
|
||||
anEvent->AddPrimaryVertex(newFwdPrimVertex);
|
||||
}
|
||||
}
|
||||
|
||||
G4double weight_correction=1.;
|
||||
//For gamma generate the particle along the backward ray
|
||||
G4ThreeVector dir=-p/p.mag();
|
||||
// Now generate the adjoint primaries
|
||||
G4PrimaryVertex* adjPrimVertex = new G4PrimaryVertex();
|
||||
adjPrimVertex->SetPosition(pos.x(), pos.y(), pos.z());
|
||||
adjPrimVertex->SetT0(0.);
|
||||
G4PrimaryParticle* aPrimParticle = new G4PrimaryParticle(
|
||||
ListOfPrimaryAdjParticles[index_particle], -p.x(), -p.y(), -p.z());
|
||||
|
||||
/*if (ListOfPrimaryAdjParticles[index_particle]->GetParticleName() == "adj_gamma"){
|
||||
adjPrimVertex->SetPrimary(aPrimParticle);
|
||||
anEvent->AddPrimaryVertex(adjPrimVertex);
|
||||
|
||||
theAdjointPrimaryGenerator
|
||||
->ComputeAccumulatedDepthVectorAlongBackRay(pos,dir,ekin,ListOfPrimaryAdjParticles[index_particle]);
|
||||
// The factor pi is to normalise the weight to the directional flux
|
||||
G4double adjoint_source_area =
|
||||
G4AdjointSimManager::GetInstance()->GetAdjointSourceArea();
|
||||
G4double adjoint_weight = weight_correction *
|
||||
ComputeEnergyDistWeight(ekin, E1, E2) *
|
||||
adjoint_source_area * pi;
|
||||
// if (ListOfPrimaryFwdParticles[index_particle] ==G4Gamma::Gamma())
|
||||
// adjoint_weight = adjoint_weight/3.;
|
||||
if(ListOfPrimaryAdjParticles[index_particle]->GetParticleName() ==
|
||||
"adj_gamma")
|
||||
{
|
||||
// The weight will be corrected at the end of the track if splitted tracks
|
||||
// are used
|
||||
adjoint_weight = adjoint_weight / nb_adj_primary_gammas_per_event;
|
||||
for(int i = 0; i < nb_adj_primary_gammas_per_event - 1; i++)
|
||||
{
|
||||
G4PrimaryVertex* newAdjPrimVertex = new G4PrimaryVertex();
|
||||
newAdjPrimVertex->SetPosition(pos.x(), pos.y(), pos.z());
|
||||
newAdjPrimVertex->SetT0(0.);
|
||||
aPrimParticle = new G4PrimaryParticle(
|
||||
ListOfPrimaryAdjParticles[index_particle], -p.x(), -p.y(), -p.z());
|
||||
newAdjPrimVertex->SetPrimary(aPrimParticle);
|
||||
newAdjPrimVertex->SetWeight(adjoint_weight);
|
||||
anEvent->AddPrimaryVertex(newAdjPrimVertex);
|
||||
}
|
||||
}
|
||||
else if(ListOfPrimaryAdjParticles[index_particle]->GetParticleName() ==
|
||||
"adj_electron")
|
||||
{
|
||||
// The weight will be corrected at the end of the track if splitted tracks
|
||||
// are used
|
||||
adjoint_weight = adjoint_weight / nb_adj_primary_electrons_per_event;
|
||||
for(int i = 0; i < nb_adj_primary_electrons_per_event - 1; i++)
|
||||
{
|
||||
G4PrimaryVertex* newAdjPrimVertex = new G4PrimaryVertex();
|
||||
newAdjPrimVertex->SetPosition(pos.x(), pos.y(), pos.z());
|
||||
newAdjPrimVertex->SetT0(0.);
|
||||
aPrimParticle = new G4PrimaryParticle(
|
||||
ListOfPrimaryAdjParticles[index_particle], -p.x(), -p.y(), -p.z());
|
||||
newAdjPrimVertex->SetPrimary(aPrimParticle);
|
||||
newAdjPrimVertex->SetWeight(adjoint_weight);
|
||||
anEvent->AddPrimaryVertex(newAdjPrimVertex);
|
||||
}
|
||||
}
|
||||
adjPrimVertex->SetWeight(adjoint_weight);
|
||||
|
||||
|
||||
G4double distance = theAdjointPrimaryGenerator
|
||||
->SampleDistanceAlongBackRayAndComputeWeightCorrection(weight_correction);
|
||||
|
||||
//pos=pos+dir*distance;
|
||||
//fwdPrimVertex->SetPosition(pos[0],pos[1],pos[2]);
|
||||
}
|
||||
*/
|
||||
weight_correction=1.;
|
||||
|
||||
if (ListOfPrimaryFwdParticles[index_particle] ==G4Gamma::Gamma() && nb_fwd_gammas_per_event>1 ){
|
||||
G4double weight = (1./nb_fwd_gammas_per_event);
|
||||
fwdPrimVertex->SetWeight(weight);
|
||||
for (int i=0;i<nb_fwd_gammas_per_event-1;i++){
|
||||
G4PrimaryVertex* newFwdPrimVertex = new G4PrimaryVertex();
|
||||
newFwdPrimVertex->SetPosition(pos.x(),pos.y(),pos.z());
|
||||
newFwdPrimVertex->SetT0(0.);
|
||||
G4PrimaryParticle* aPrimParticle = new G4PrimaryParticle(ListOfPrimaryFwdParticles[index_particle],
|
||||
p.x(),p.y(),p.z());
|
||||
newFwdPrimVertex->SetPrimary(aPrimParticle);
|
||||
newFwdPrimVertex->SetWeight(weight);
|
||||
anEvent->AddPrimaryVertex(newFwdPrimVertex);
|
||||
}
|
||||
}
|
||||
|
||||
//Now generate the adjoint primaries
|
||||
G4PrimaryVertex* adjPrimVertex = new G4PrimaryVertex();
|
||||
adjPrimVertex->SetPosition(pos.x(),pos.y(),pos.z());
|
||||
adjPrimVertex->SetT0(0.);
|
||||
G4PrimaryParticle* aPrimParticle = new G4PrimaryParticle(ListOfPrimaryAdjParticles[index_particle],
|
||||
-p.x(),-p.y(),-p.z());
|
||||
|
||||
adjPrimVertex->SetPrimary(aPrimParticle);
|
||||
anEvent->AddPrimaryVertex(adjPrimVertex);
|
||||
|
||||
//The factor pi is to normalise the weight to the directional flux
|
||||
G4double adjoint_source_area = G4AdjointSimManager::GetInstance()->GetAdjointSourceArea();
|
||||
G4double adjoint_weight = weight_correction*ComputeEnergyDistWeight(ekin,E1,E2)*adjoint_source_area*pi;
|
||||
//if (ListOfPrimaryFwdParticles[index_particle] ==G4Gamma::Gamma()) adjoint_weight = adjoint_weight/3.;
|
||||
if (ListOfPrimaryAdjParticles[index_particle]->GetParticleName() == "adj_gamma") {
|
||||
//The weight will be corrected at the end of the track if splitted tracks are used
|
||||
adjoint_weight = adjoint_weight/nb_adj_primary_gammas_per_event;
|
||||
for (int i=0;i<nb_adj_primary_gammas_per_event-1;i++){
|
||||
G4PrimaryVertex* newAdjPrimVertex = new G4PrimaryVertex();
|
||||
newAdjPrimVertex->SetPosition(pos.x(),pos.y(),pos.z());
|
||||
newAdjPrimVertex->SetT0(0.);
|
||||
aPrimParticle = new G4PrimaryParticle(ListOfPrimaryAdjParticles[index_particle],
|
||||
-p.x(),-p.y(),-p.z());
|
||||
newAdjPrimVertex->SetPrimary(aPrimParticle);
|
||||
newAdjPrimVertex->SetWeight(adjoint_weight);
|
||||
anEvent->AddPrimaryVertex(newAdjPrimVertex);
|
||||
}
|
||||
}
|
||||
else if (ListOfPrimaryAdjParticles[index_particle]->GetParticleName() == "adj_electron") {
|
||||
//The weight will be corrected at the end of the track if splitted tracks are used
|
||||
adjoint_weight = adjoint_weight/nb_adj_primary_electrons_per_event;
|
||||
for (int i=0;i<nb_adj_primary_electrons_per_event-1;i++){
|
||||
G4PrimaryVertex* newAdjPrimVertex = new G4PrimaryVertex();
|
||||
newAdjPrimVertex->SetPosition(pos.x(),pos.y(),pos.z());
|
||||
newAdjPrimVertex->SetT0(0.);
|
||||
aPrimParticle = new G4PrimaryParticle(ListOfPrimaryAdjParticles[index_particle],
|
||||
-p.x(),-p.y(),-p.z());
|
||||
newAdjPrimVertex->SetPrimary(aPrimParticle);
|
||||
newAdjPrimVertex->SetWeight(adjoint_weight);
|
||||
anEvent->AddPrimaryVertex(newAdjPrimVertex);
|
||||
}
|
||||
}
|
||||
adjPrimVertex->SetWeight(adjoint_weight);
|
||||
|
||||
//Call some methods of G4AdjointSimManager
|
||||
G4AdjointSimManager::GetInstance()->SetAdjointTrackingMode(true);
|
||||
G4AdjointSimManager::GetInstance()->ClearEndOfAdjointTrackInfoVectors();
|
||||
G4AdjointSimManager::GetInstance()->ResetDidOneAdjPartReachExtSourceDuringEvent();
|
||||
// Call some methods of G4AdjointSimManager
|
||||
G4AdjointSimManager::GetInstance()->SetAdjointTrackingMode(true);
|
||||
G4AdjointSimManager::GetInstance()->ClearEndOfAdjointTrackInfoVectors();
|
||||
G4AdjointSimManager::GetInstance()
|
||||
->ResetDidOneAdjPartReachExtSourceDuringEvent();
|
||||
|
||||
/* if ( !last_generated_part_was_adjoint ) {
|
||||
|
||||
index_particle++;
|
||||
if (index_particle >= ListOfPrimaryAdjParticles.size()) index_particle =0;
|
||||
|
||||
|
||||
G4double E1=Emin;
|
||||
G4double E2=Emax;
|
||||
if (!ListOfPrimaryAdjParticles[index_particle]) UpdateListOfPrimaryParticles();//ion has not been created yet
|
||||
|
||||
if (ListOfPrimaryAdjParticles[index_particle]->GetParticleName() == "adj_proton") {
|
||||
E1=EminIon;
|
||||
E2=EmaxIon;
|
||||
}
|
||||
if (ListOfPrimaryAdjParticles[index_particle]->GetParticleType() == "adjoint_nucleus") {
|
||||
G4int A= ListOfPrimaryAdjParticles[index_particle]->GetAtomicMass();
|
||||
E1=EminIon*A;
|
||||
E2=EmaxIon*A;
|
||||
}
|
||||
theAdjointPrimaryGenerator->GenerateAdjointPrimaryVertex(anEvent,
|
||||
ListOfPrimaryAdjParticles[index_particle],
|
||||
E1,E2);
|
||||
G4PrimaryVertex* aPrimVertex = anEvent->GetPrimaryVertex();
|
||||
|
||||
|
||||
p=aPrimVertex->GetPrimary()->GetMomentum();
|
||||
pos=aPrimVertex->GetPosition();
|
||||
G4double pmag=p.mag();
|
||||
|
||||
G4double m0=ListOfPrimaryAdjParticles[index_particle]->GetPDGMass();
|
||||
G4double ekin=std::sqrt( m0*m0 + pmag*pmag) -m0;
|
||||
|
||||
|
||||
//The factor pi is to normalise the weight to the directional flux
|
||||
G4double adjoint_source_area = G4AdjointSimManager::GetInstance()->GetAdjointSourceArea();
|
||||
G4double adjoint_weight = ComputeEnergyDistWeight(ekin,E1,E2)*adjoint_source_area*pi;
|
||||
|
||||
aPrimVertex->SetWeight(adjoint_weight);
|
||||
index_particle++;
|
||||
if (index_particle >= ListOfPrimaryAdjParticles.size()) index_particle =0;
|
||||
|
||||
last_generated_part_was_adjoint =true;
|
||||
G4AdjointSimManager::GetInstance()->SetAdjointTrackingMode(true);
|
||||
G4AdjointSimManager::GetInstance()->RegisterAdjointPrimaryWeight(adjoint_weight);
|
||||
|
||||
G4double E1=Emin;
|
||||
G4double E2=Emax;
|
||||
if (!ListOfPrimaryAdjParticles[index_particle])
|
||||
UpdateListOfPrimaryParticles();//ion has not been created yet
|
||||
|
||||
if (ListOfPrimaryAdjParticles[index_particle]->GetParticleName() ==
|
||||
"adj_proton") { E1=EminIon; E2=EmaxIon;
|
||||
}
|
||||
if (ListOfPrimaryAdjParticles[index_particle]->GetParticleType() ==
|
||||
"adjoint_nucleus") { G4int A=
|
||||
ListOfPrimaryAdjParticles[index_particle]->GetAtomicMass(); E1=EminIon*A;
|
||||
E2=EmaxIon*A;
|
||||
}
|
||||
theAdjointPrimaryGenerator->GenerateAdjointPrimaryVertex(anEvent,
|
||||
ListOfPrimaryAdjParticles[index_particle],
|
||||
E1,E2);
|
||||
G4PrimaryVertex* aPrimVertex = anEvent->GetPrimaryVertex();
|
||||
|
||||
|
||||
p=aPrimVertex->GetPrimary()->GetMomentum();
|
||||
pos=aPrimVertex->GetPosition();
|
||||
G4double pmag=p.mag();
|
||||
|
||||
G4double m0=ListOfPrimaryAdjParticles[index_particle]->GetPDGMass();
|
||||
G4double ekin=std::sqrt( m0*m0 + pmag*pmag) -m0;
|
||||
|
||||
|
||||
//The factor pi is to normalise the weight to the directional flux
|
||||
G4double adjoint_source_area =
|
||||
G4AdjointSimManager::GetInstance()->GetAdjointSourceArea(); G4double
|
||||
adjoint_weight = ComputeEnergyDistWeight(ekin,E1,E2)*adjoint_source_area*pi;
|
||||
|
||||
aPrimVertex->SetWeight(adjoint_weight);
|
||||
|
||||
last_generated_part_was_adjoint =true;
|
||||
G4AdjointSimManager::GetInstance()->SetAdjointTrackingMode(true);
|
||||
G4AdjointSimManager::GetInstance()->RegisterAdjointPrimaryWeight(adjoint_weight);
|
||||
}
|
||||
else {
|
||||
//fwd particle equivalent to the last generated adjoint particle ios generated
|
||||
G4PrimaryVertex* aPrimVertex = new G4PrimaryVertex();
|
||||
aPrimVertex->SetPosition(pos.x(),pos.y(),pos.z());
|
||||
aPrimVertex->SetT0(0.);
|
||||
G4PrimaryParticle* aPrimParticle = new G4PrimaryParticle(ListOfPrimaryFwdParticles[index_particle],
|
||||
-p.x(),-p.y(),-p.z());
|
||||
|
||||
aPrimVertex->SetPrimary(aPrimParticle);
|
||||
anEvent->AddPrimaryVertex(aPrimVertex);
|
||||
last_generated_part_was_adjoint =false;
|
||||
G4AdjointSimManager::GetInstance()->SetAdjointTrackingMode(false);
|
||||
*/
|
||||
//fwd particle equivalent to the last generated adjoint particle ios
|
||||
generated G4PrimaryVertex* aPrimVertex = new G4PrimaryVertex();
|
||||
aPrimVertex->SetPosition(pos.x(),pos.y(),pos.z());
|
||||
aPrimVertex->SetT0(0.);
|
||||
G4PrimaryParticle* aPrimParticle = new
|
||||
G4PrimaryParticle(ListOfPrimaryFwdParticles[index_particle],
|
||||
-p.x(),-p.y(),-p.z());
|
||||
|
||||
aPrimVertex->SetPrimary(aPrimParticle);
|
||||
anEvent->AddPrimaryVertex(aPrimVertex);
|
||||
last_generated_part_was_adjoint =false;
|
||||
G4AdjointSimManager::GetInstance()->SetAdjointTrackingMode(false);
|
||||
*/
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointPrimaryGeneratorAction::SetEmin(G4double val)
|
||||
{
|
||||
Emin=val;
|
||||
EminIon=val;
|
||||
Emin = val;
|
||||
EminIon = val;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointPrimaryGeneratorAction::SetEmax(G4double val)
|
||||
{
|
||||
Emax=val;
|
||||
EmaxIon=val;
|
||||
Emax = val;
|
||||
EmaxIon = val;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointPrimaryGeneratorAction::SetEminIon(G4double val)
|
||||
{
|
||||
EminIon=val;
|
||||
EminIon = val;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointPrimaryGeneratorAction::SetEmaxIon(G4double val)
|
||||
{
|
||||
EmaxIon=val;
|
||||
EmaxIon = val;
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4double G4AdjointPrimaryGeneratorAction::ComputeEnergyDistWeight(G4double E ,G4double E1, G4double E2)
|
||||
G4double G4AdjointPrimaryGeneratorAction::ComputeEnergyDistWeight(G4double E,
|
||||
G4double E1,
|
||||
G4double E2)
|
||||
{
|
||||
// We generate N numbers of primaries with a 1/E energy law distribution.
|
||||
// We have therefore an energy distribution function
|
||||
// f(E)=C/E (1)
|
||||
// with C a constant that is such that
|
||||
// N=Integral(f(E),E1,E2)=C.std::log(E2/E1) (2)
|
||||
// Therefore from (2) we get
|
||||
// C=N/ std::log(E2/E1) (3)
|
||||
// and
|
||||
// f(E)=N/ std::log(E2/E1)/E (4)
|
||||
//For the adjoint simulation we need a energy distribution f'(E)=1..
|
||||
//To get that we need therefore to apply a weight to the primary
|
||||
// W=1/f(E)=E*std::log(E2/E1)/N
|
||||
//
|
||||
return std::log(E2/E1)*E/G4AdjointSimManager::GetInstance()->GetNbEvtOfLastRun();
|
||||
|
||||
// We generate N numbers of primaries with a 1/E energy law distribution.
|
||||
// We have therefore an energy distribution function
|
||||
// f(E)=C/E (1)
|
||||
// with C a constant that is such that
|
||||
// N=Integral(f(E),E1,E2)=C.std::log(E2/E1) (2)
|
||||
// Therefore from (2) we get
|
||||
// C=N/ std::log(E2/E1) (3)
|
||||
// and
|
||||
// f(E)=N/ std::log(E2/E1)/E (4)
|
||||
// For the adjoint simulation we need a energy distribution f'(E)=1..
|
||||
// To get that we need therefore to apply a weight to the primary
|
||||
// W=1/f(E)=E*std::log(E2/E1)/N
|
||||
//
|
||||
return std::log(E2 / E1) * E /
|
||||
G4AdjointSimManager::GetInstance()->GetNbEvtOfLastRun();
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointPrimaryGeneratorAction::SetSphericalAdjointPrimarySource(G4double radius, G4ThreeVector center_pos)
|
||||
{
|
||||
void G4AdjointPrimaryGeneratorAction::SetSphericalAdjointPrimarySource(
|
||||
G4double radius, G4ThreeVector center_pos)
|
||||
{
|
||||
radius_spherical_source = radius;
|
||||
center_spherical_source = center_pos;
|
||||
type_of_adjoint_source ="Spherical";
|
||||
theAdjointPrimaryGenerator->SetSphericalAdjointPrimarySource(radius,center_pos);
|
||||
type_of_adjoint_source = "Spherical";
|
||||
theAdjointPrimaryGenerator->SetSphericalAdjointPrimarySource(radius,
|
||||
center_pos);
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointPrimaryGeneratorAction::SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(const G4String& volume_name)
|
||||
void G4AdjointPrimaryGeneratorAction::
|
||||
SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(const G4String& volume_name)
|
||||
{
|
||||
type_of_adjoint_source ="ExternalSurfaceOfAVolume";
|
||||
theAdjointPrimaryGenerator->SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(volume_name);
|
||||
type_of_adjoint_source = "ExternalSurfaceOfAVolume";
|
||||
theAdjointPrimaryGenerator->SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(
|
||||
volume_name);
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointPrimaryGeneratorAction::ConsiderParticleAsPrimary(const G4String& particle_name)
|
||||
void G4AdjointPrimaryGeneratorAction::ConsiderParticleAsPrimary(
|
||||
const G4String& particle_name)
|
||||
{
|
||||
if (PrimariesConsideredInAdjointSim.find(particle_name) != PrimariesConsideredInAdjointSim.end()){
|
||||
PrimariesConsideredInAdjointSim[particle_name]=true;
|
||||
if(PrimariesConsideredInAdjointSim.find(particle_name) !=
|
||||
PrimariesConsideredInAdjointSim.end())
|
||||
{
|
||||
PrimariesConsideredInAdjointSim[particle_name] = true;
|
||||
}
|
||||
UpdateListOfPrimaryParticles();
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointPrimaryGeneratorAction::NeglectParticleAsPrimary(const G4String& particle_name)
|
||||
void G4AdjointPrimaryGeneratorAction::NeglectParticleAsPrimary(
|
||||
const G4String& particle_name)
|
||||
{
|
||||
if (PrimariesConsideredInAdjointSim.find(particle_name) != PrimariesConsideredInAdjointSim.end()){
|
||||
PrimariesConsideredInAdjointSim[particle_name]= false;
|
||||
if(PrimariesConsideredInAdjointSim.find(particle_name) !=
|
||||
PrimariesConsideredInAdjointSim.end())
|
||||
{
|
||||
PrimariesConsideredInAdjointSim[particle_name] = false;
|
||||
}
|
||||
UpdateListOfPrimaryParticles();
|
||||
}
|
||||
@@ -329,48 +366,56 @@ void G4AdjointPrimaryGeneratorAction::NeglectParticleAsPrimary(const G4String& p
|
||||
//
|
||||
void G4AdjointPrimaryGeneratorAction::UpdateListOfPrimaryParticles()
|
||||
{
|
||||
G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
|
||||
ListOfPrimaryFwdParticles.clear();
|
||||
ListOfPrimaryAdjParticles.clear();
|
||||
std::map<G4String, G4bool>::iterator iter;
|
||||
for( iter = PrimariesConsideredInAdjointSim.begin(); iter != PrimariesConsideredInAdjointSim.end(); ++iter ) {
|
||||
if(iter->second) {
|
||||
G4String fwd_particle_name = iter->first;
|
||||
if ( fwd_particle_name != "ion") {
|
||||
G4String adj_particle_name = G4String("adj_") + fwd_particle_name;
|
||||
ListOfPrimaryFwdParticles.push_back(theParticleTable->FindParticle(fwd_particle_name));
|
||||
ListOfPrimaryAdjParticles.push_back(theParticleTable->FindParticle(adj_particle_name));
|
||||
/*
|
||||
if ( fwd_particle_name == "gamma") {
|
||||
for (G4int i=0;i<2;i++){
|
||||
ListOfPrimaryFwdParticles.push_back(theParticleTable->FindParticle(fwd_particle_name));
|
||||
ListOfPrimaryAdjParticles.push_back(theParticleTable->FindParticle(adj_particle_name));
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
else {
|
||||
if (fwd_ion ){
|
||||
ion_name=fwd_ion->GetParticleName();
|
||||
G4String adj_ion_name=G4String("adj_") +ion_name;
|
||||
ListOfPrimaryFwdParticles.push_back(fwd_ion);
|
||||
ListOfPrimaryAdjParticles.push_back(adj_ion);
|
||||
}
|
||||
else {
|
||||
ListOfPrimaryFwdParticles.push_back(0);
|
||||
ListOfPrimaryAdjParticles.push_back(0);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
|
||||
ListOfPrimaryFwdParticles.clear();
|
||||
ListOfPrimaryAdjParticles.clear();
|
||||
std::map<G4String, G4bool>::iterator iter;
|
||||
for(iter = PrimariesConsideredInAdjointSim.begin();
|
||||
iter != PrimariesConsideredInAdjointSim.end(); ++iter)
|
||||
{
|
||||
if(iter->second)
|
||||
{
|
||||
G4String fwd_particle_name = iter->first;
|
||||
if(fwd_particle_name != "ion")
|
||||
{
|
||||
G4String adj_particle_name = G4String("adj_") + fwd_particle_name;
|
||||
ListOfPrimaryFwdParticles.push_back(
|
||||
theParticleTable->FindParticle(fwd_particle_name));
|
||||
ListOfPrimaryAdjParticles.push_back(
|
||||
theParticleTable->FindParticle(adj_particle_name));
|
||||
/*
|
||||
if ( fwd_particle_name == "gamma") {
|
||||
for (G4int i=0;i<2;i++){
|
||||
ListOfPrimaryFwdParticles.push_back(theParticleTable->FindParticle(fwd_particle_name));
|
||||
ListOfPrimaryAdjParticles.push_back(theParticleTable->FindParticle(adj_particle_name));
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
if(fwd_ion)
|
||||
{
|
||||
ion_name = fwd_ion->GetParticleName();
|
||||
G4String adj_ion_name = G4String("adj_") + ion_name;
|
||||
ListOfPrimaryFwdParticles.push_back(fwd_ion);
|
||||
ListOfPrimaryAdjParticles.push_back(adj_ion);
|
||||
}
|
||||
else
|
||||
{
|
||||
ListOfPrimaryFwdParticles.push_back(0);
|
||||
ListOfPrimaryAdjParticles.push_back(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointPrimaryGeneratorAction::SetPrimaryIon(G4ParticleDefinition* adjointIon, G4ParticleDefinition* fwdIon)
|
||||
void G4AdjointPrimaryGeneratorAction::SetPrimaryIon(
|
||||
G4ParticleDefinition* adjointIon, G4ParticleDefinition* fwdIon)
|
||||
{
|
||||
fwd_ion = fwdIon;
|
||||
adj_ion = adjointIon;
|
||||
UpdateListOfPrimaryParticles();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,15 +37,15 @@
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
#include "G4UserEventAction.hh"
|
||||
#include "G4VUserPrimaryGeneratorAction.hh"
|
||||
#include "G4UserTrackingAction.hh"
|
||||
#include "G4UserSteppingAction.hh"
|
||||
#include "G4UserStackingAction.hh"
|
||||
#include "G4UserRunAction.hh"
|
||||
#include "G4UserStackingAction.hh"
|
||||
#include "G4UserSteppingAction.hh"
|
||||
#include "G4UserTrackingAction.hh"
|
||||
#include "G4VUserPrimaryGeneratorAction.hh"
|
||||
|
||||
#include "G4AdjointPrimaryGeneratorAction.hh"
|
||||
#include "G4AdjointSteppingAction.hh"
|
||||
#include "G4AdjointStackingAction.hh"
|
||||
#include "G4AdjointSteppingAction.hh"
|
||||
#include "G4AdjointTrackingAction.hh"
|
||||
|
||||
#include "G4AdjointSimMessenger.hh"
|
||||
@@ -66,101 +66,133 @@ G4ThreadLocal G4AdjointSimManager* G4AdjointSimManager::instance = 0;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4AdjointSimManager::G4AdjointSimManager():
|
||||
fUserRunAction(0), fUserEventAction(0),fUserPrimaryGeneratorAction(0),
|
||||
fUserTrackingAction(0), fUserSteppingAction(0), fUserStackingAction(0),
|
||||
theAdjointRunAction(0), theAdjointEventAction(0),
|
||||
adjoint_tracking_mode(false),last_ekin(0),last_ekin_nuc(0),
|
||||
last_cos_th(0),last_fwd_part_PDGEncoding(0),last_fwd_part_index(0),
|
||||
last_weight(0), ID_of_last_particle_that_reach_the_ext_source(0),
|
||||
nb_evt_of_last_run(0),area_of_the_adjoint_source(0),theAdjointPrimaryWeight(0)
|
||||
{
|
||||
//Create adjoint actions;
|
||||
//----------------------
|
||||
theAdjointPrimaryGeneratorAction = new G4AdjointPrimaryGeneratorAction();
|
||||
theAdjointSteppingAction = new G4AdjointSteppingAction();
|
||||
theAdjointTrackingAction = new G4AdjointTrackingAction(theAdjointSteppingAction);
|
||||
theAdjointStackingAction = new G4AdjointStackingAction(theAdjointTrackingAction);
|
||||
theAdjointTrackingAction->SetListOfPrimaryFwdParticles(
|
||||
theAdjointPrimaryGeneratorAction->GetListOfPrimaryFwdParticles());
|
||||
//Create messenger
|
||||
//----------------
|
||||
G4AdjointSimManager::G4AdjointSimManager()
|
||||
: fUserRunAction(0)
|
||||
, fUserEventAction(0)
|
||||
, fUserPrimaryGeneratorAction(0)
|
||||
, fUserTrackingAction(0)
|
||||
, fUserSteppingAction(0)
|
||||
, fUserStackingAction(0)
|
||||
, theAdjointRunAction(0)
|
||||
, theAdjointEventAction(0)
|
||||
, adjoint_tracking_mode(false)
|
||||
, last_ekin(0)
|
||||
, last_ekin_nuc(0)
|
||||
, last_cos_th(0)
|
||||
, last_fwd_part_PDGEncoding(0)
|
||||
, last_fwd_part_index(0)
|
||||
, last_weight(0)
|
||||
, ID_of_last_particle_that_reach_the_ext_source(0)
|
||||
, nb_evt_of_last_run(0)
|
||||
, area_of_the_adjoint_source(0)
|
||||
, theAdjointPrimaryWeight(0)
|
||||
{
|
||||
// Create adjoint actions;
|
||||
//----------------------
|
||||
theAdjointPrimaryGeneratorAction = new G4AdjointPrimaryGeneratorAction();
|
||||
theAdjointSteppingAction = new G4AdjointSteppingAction();
|
||||
theAdjointTrackingAction =
|
||||
new G4AdjointTrackingAction(theAdjointSteppingAction);
|
||||
theAdjointStackingAction =
|
||||
new G4AdjointStackingAction(theAdjointTrackingAction);
|
||||
theAdjointTrackingAction->SetListOfPrimaryFwdParticles(
|
||||
theAdjointPrimaryGeneratorAction->GetListOfPrimaryFwdParticles());
|
||||
// Create messenger
|
||||
//----------------
|
||||
theMessenger = new G4AdjointSimMessenger(this);
|
||||
|
||||
user_action_already_defined=false;
|
||||
use_user_StackingAction = false;
|
||||
use_user_TrackingAction =true;
|
||||
|
||||
user_action_already_defined = false;
|
||||
use_user_StackingAction = false;
|
||||
use_user_TrackingAction = true;
|
||||
|
||||
adjoint_sim_mode = false;
|
||||
|
||||
normalisation_mode=3;
|
||||
|
||||
nb_nuc=1.;
|
||||
|
||||
welcome_message =true;
|
||||
|
||||
//Define user action and set this class instance as RunAction
|
||||
|
||||
normalisation_mode = 3;
|
||||
|
||||
nb_nuc = 1.;
|
||||
|
||||
welcome_message = true;
|
||||
|
||||
// Define user action and set this class instance as RunAction
|
||||
//----------------
|
||||
//DefineUserActions();
|
||||
//G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
// DefineUserActions();
|
||||
// G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
|
||||
//theRunManager->G4RunManager::SetUserAction(this);
|
||||
/*
|
||||
#ifdef G4MULTITHREADED
|
||||
// theRunManager->G4RunManager::SetUserAction(this);
|
||||
/*
|
||||
#ifdef G4MULTITHREADED
|
||||
|
||||
if (theRunManager->GetRunManagerType() == G4RunManager::workerRM){
|
||||
G4cout<<"Here"<<std::endl;
|
||||
//G4MTAdjointSimManager::GetInstance()->RegisterLocalManager(this);
|
||||
G4cout<<"Here1"<<std::endl;
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
if (theRunManager->GetRunManagerType() == G4RunManager::workerRM){
|
||||
G4cout<<"Here"<<std::endl;
|
||||
//G4MTAdjointSimManager::GetInstance()->RegisterLocalManager(this);
|
||||
G4cout<<"Here1"<<std::endl;
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4AdjointSimManager::~G4AdjointSimManager()
|
||||
{
|
||||
if (theAdjointRunAction) delete theAdjointRunAction;
|
||||
if (theAdjointPrimaryGeneratorAction) delete theAdjointPrimaryGeneratorAction;
|
||||
if (theAdjointSteppingAction) delete theAdjointSteppingAction;
|
||||
if (theAdjointEventAction) delete theAdjointEventAction;
|
||||
if (theAdjointTrackingAction) delete theAdjointTrackingAction;
|
||||
if (theAdjointStackingAction) delete theAdjointStackingAction;
|
||||
if (theMessenger) delete theMessenger;
|
||||
{
|
||||
if(theAdjointRunAction)
|
||||
delete theAdjointRunAction;
|
||||
if(theAdjointPrimaryGeneratorAction)
|
||||
delete theAdjointPrimaryGeneratorAction;
|
||||
if(theAdjointSteppingAction)
|
||||
delete theAdjointSteppingAction;
|
||||
if(theAdjointEventAction)
|
||||
delete theAdjointEventAction;
|
||||
if(theAdjointTrackingAction)
|
||||
delete theAdjointTrackingAction;
|
||||
if(theAdjointStackingAction)
|
||||
delete theAdjointStackingAction;
|
||||
if(theMessenger)
|
||||
delete theMessenger;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4AdjointSimManager* G4AdjointSimManager::GetInstance()
|
||||
{
|
||||
if (instance == 0) instance = new G4AdjointSimManager;
|
||||
if(instance == 0)
|
||||
instance = new G4AdjointSimManager;
|
||||
return instance;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::RunAdjointSimulation(G4int nb_evt)
|
||||
{ if (G4RunManager::GetRunManager()->GetRunManagerType() != G4RunManager::sequentialRM) return; //only for sequential mode
|
||||
if (welcome_message) {
|
||||
G4cout<<"****************************************************************"<<std::endl;
|
||||
G4cout<<"*** Geant4 Reverse/Adjoint Monte Carlo mode ***"<<std::endl;
|
||||
G4cout<<"*** Author: L.Desorgher ***"<<std::endl;
|
||||
G4cout<<"*** Company: SpaceIT GmbH, Bern, Switzerland ***"<<std::endl;
|
||||
G4cout<<"*** Sponsored by: ESA/ESTEC contract contract 21435/08/NL/AT ***"<<std::endl;
|
||||
G4cout<<"****************************************************************"<<std::endl;
|
||||
welcome_message=false;
|
||||
}
|
||||
|
||||
//Switch to adjoint simulation mode
|
||||
{
|
||||
if(G4RunManager::GetRunManager()->GetRunManagerType() !=
|
||||
G4RunManager::sequentialRM)
|
||||
return; // only for sequential mode
|
||||
if(welcome_message)
|
||||
{
|
||||
G4cout << "****************************************************************"
|
||||
<< std::endl;
|
||||
G4cout << "*** Geant4 Reverse/Adjoint Monte Carlo mode ***"
|
||||
<< std::endl;
|
||||
G4cout << "*** Author: L.Desorgher ***" << std::endl;
|
||||
G4cout << "*** Company: SpaceIT GmbH, Bern, Switzerland ***"
|
||||
<< std::endl;
|
||||
G4cout << "*** Sponsored by: ESA/ESTEC contract contract 21435/08/NL/AT ***"
|
||||
<< std::endl;
|
||||
G4cout << "****************************************************************"
|
||||
<< std::endl;
|
||||
welcome_message = false;
|
||||
}
|
||||
|
||||
// Switch to adjoint simulation mode
|
||||
//---------------------------------------------------------
|
||||
SwitchToAdjointSimulationMode();
|
||||
|
||||
//Make the run
|
||||
//------------
|
||||
|
||||
nb_evt_of_last_run =nb_evt;
|
||||
G4RunManager::GetRunManager()->BeamOn(nb_evt*theAdjointPrimaryGeneratorAction->GetNbOfAdjointPrimaryTypes());
|
||||
//G4RunManager::GetRunManager()->BeamOn(theAdjointPrimaryGeneratorAction->GetNbOfAdjointPrimaryTypes()*2*nb_evt);
|
||||
|
||||
//Back to Fwd Simulation Mode
|
||||
// Make the run
|
||||
//------------
|
||||
|
||||
nb_evt_of_last_run = nb_evt;
|
||||
G4RunManager::GetRunManager()->BeamOn(
|
||||
nb_evt * theAdjointPrimaryGeneratorAction->GetNbOfAdjointPrimaryTypes());
|
||||
// G4RunManager::GetRunManager()->BeamOn(theAdjointPrimaryGeneratorAction->GetNbOfAdjointPrimaryTypes()*2*nb_evt);
|
||||
|
||||
// Back to Fwd Simulation Mode
|
||||
//--------------------------------
|
||||
BackToFwdSimulationMode();
|
||||
|
||||
@@ -170,106 +202,113 @@ void G4AdjointSimManager::RunAdjointSimulation(G4int nb_evt)
|
||||
std::ofstream FileOutputElectronWeight("ElectronWeight.txt", std::ios::out);
|
||||
FileOutputElectronWeight<<std::setiosflags(std::ios::scientific);
|
||||
FileOutputElectronWeight<<std::setprecision(6);
|
||||
G4bool aBool = electron_last_weight_vector->Store(FileOutputElectronWeight, true);
|
||||
FileOutputElectronWeight.close();
|
||||
|
||||
G4bool aBool = electron_last_weight_vector->Store(FileOutputElectronWeight,
|
||||
true); FileOutputElectronWeight.close();
|
||||
|
||||
std::ofstream FileOutputProtonWeight("ProtonWeight.txt", std::ios::out);
|
||||
FileOutputProtonWeight<<std::setiosflags(std::ios::scientific);
|
||||
FileOutputProtonWeight<<std::setprecision(6);
|
||||
aBool = proton_last_weight_vector->Store(FileOutputProtonWeight, true);
|
||||
FileOutputProtonWeight.close();
|
||||
|
||||
|
||||
std::ofstream FileOutputGammaWeight("GammaWeight.txt", std::ios::out);
|
||||
FileOutputGammaWeight<<std::setiosflags(std::ios::scientific);
|
||||
FileOutputGammaWeight<<std::setprecision(6);
|
||||
aBool = gamma_last_weight_vector->Store(FileOutputGammaWeight, true);
|
||||
FileOutputGammaWeight.close();
|
||||
*/
|
||||
*/
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::SetRestOfAdjointActions()
|
||||
{
|
||||
G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
|
||||
if (!user_action_already_defined) DefineUserActions();
|
||||
if(!user_action_already_defined)
|
||||
DefineUserActions();
|
||||
|
||||
//Replace the user action by the adjoint actions
|
||||
//-------------------------------------------------
|
||||
// Replace the user action by the adjoint actions
|
||||
//-------------------------------------------------
|
||||
|
||||
theRunManager->G4RunManager::SetUserAction(theAdjointEventAction);
|
||||
theRunManager->G4RunManager::SetUserAction(theAdjointSteppingAction);
|
||||
theRunManager->G4RunManager::SetUserAction(theAdjointTrackingAction);
|
||||
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::SwitchToAdjointSimulationMode()
|
||||
{ //Replace the user defined actions by the adjoint actions
|
||||
{ // Replace the user defined actions by the adjoint actions
|
||||
//---------------------------------------------------------
|
||||
SetAdjointActions();
|
||||
|
||||
//Update the list of primaries
|
||||
// Update the list of primaries
|
||||
//-----------------------------
|
||||
theAdjointPrimaryGeneratorAction->UpdateListOfPrimaryParticles();
|
||||
adjoint_sim_mode=true;
|
||||
ID_of_last_particle_that_reach_the_ext_source=0;
|
||||
adjoint_sim_mode = true;
|
||||
ID_of_last_particle_that_reach_the_ext_source = 0;
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::BackToFwdSimulationMode()
|
||||
{ //Restore the user defined actions
|
||||
//--------------------------------
|
||||
ResetUserActions();
|
||||
adjoint_sim_mode=false;
|
||||
{ // Restore the user defined actions
|
||||
//--------------------------------
|
||||
ResetUserActions();
|
||||
adjoint_sim_mode = false;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::SetAdjointActions()
|
||||
{
|
||||
G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
|
||||
if (!user_action_already_defined) DefineUserActions();
|
||||
{
|
||||
G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
|
||||
if(!user_action_already_defined)
|
||||
DefineUserActions();
|
||||
|
||||
//Replace the user action by the adjoint actions
|
||||
//-------------------------------------------------
|
||||
// Replace the user action by the adjoint actions
|
||||
//-------------------------------------------------
|
||||
theRunManager->G4RunManager::SetUserAction(this);
|
||||
theRunManager->G4RunManager::SetUserAction(theAdjointPrimaryGeneratorAction);
|
||||
theRunManager->G4RunManager::SetUserAction(theAdjointStackingAction);
|
||||
if (use_user_StackingAction) theAdjointStackingAction->SetUserFwdStackingAction(fUserStackingAction);
|
||||
else theAdjointStackingAction->SetUserFwdStackingAction(0);
|
||||
if(use_user_StackingAction)
|
||||
theAdjointStackingAction->SetUserFwdStackingAction(fUserStackingAction);
|
||||
else
|
||||
theAdjointStackingAction->SetUserFwdStackingAction(0);
|
||||
theRunManager->G4RunManager::SetUserAction(theAdjointEventAction);
|
||||
theRunManager->G4RunManager::SetUserAction(theAdjointSteppingAction);
|
||||
theRunManager->G4RunManager::SetUserAction(theAdjointTrackingAction);
|
||||
if (use_user_TrackingAction) theAdjointTrackingAction->SetUserForwardTrackingAction(fUserTrackingAction);
|
||||
else theAdjointTrackingAction->SetUserForwardTrackingAction(0);
|
||||
if(use_user_TrackingAction)
|
||||
theAdjointTrackingAction->SetUserForwardTrackingAction(fUserTrackingAction);
|
||||
else
|
||||
theAdjointTrackingAction->SetUserForwardTrackingAction(0);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::SetAdjointPrimaryRunAndStackingActions()
|
||||
{
|
||||
G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
|
||||
if (!user_action_already_defined) DefineUserActions();
|
||||
|
||||
//Replace the user action by the adjoint actions
|
||||
//-------------------------------------------------
|
||||
|
||||
{
|
||||
G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
|
||||
if(!user_action_already_defined)
|
||||
DefineUserActions();
|
||||
|
||||
// Replace the user action by the adjoint actions
|
||||
//-------------------------------------------------
|
||||
|
||||
theRunManager->G4RunManager::SetUserAction(theAdjointRunAction);
|
||||
theRunManager->G4RunManager::SetUserAction(theAdjointPrimaryGeneratorAction);
|
||||
theRunManager->G4RunManager::SetUserAction(theAdjointStackingAction);
|
||||
if (use_user_StackingAction) theAdjointStackingAction->SetUserFwdStackingAction(fUserStackingAction);
|
||||
else theAdjointStackingAction->SetUserFwdStackingAction(0);
|
||||
if(use_user_StackingAction)
|
||||
theAdjointStackingAction->SetUserFwdStackingAction(fUserStackingAction);
|
||||
else
|
||||
theAdjointStackingAction->SetUserFwdStackingAction(0);
|
||||
}
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::ResetUserActions()
|
||||
{
|
||||
G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
|
||||
//Restore the user defined actions
|
||||
// Restore the user defined actions
|
||||
//-------------------------------
|
||||
theRunManager->G4RunManager::SetUserAction(fUserRunAction);
|
||||
theRunManager->G4RunManager::SetUserAction(fUserEventAction);
|
||||
@@ -282,11 +321,11 @@ void G4AdjointSimManager::ResetUserActions()
|
||||
//
|
||||
void G4AdjointSimManager::ResetRestOfUserActions()
|
||||
{
|
||||
G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
|
||||
//Restore the user defined actions
|
||||
G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
|
||||
// Restore the user defined actions
|
||||
//-------------------------------
|
||||
|
||||
|
||||
theRunManager->G4RunManager::SetUserAction(fUserEventAction);
|
||||
theRunManager->G4RunManager::SetUserAction(fUserSteppingAction);
|
||||
theRunManager->G4RunManager::SetUserAction(fUserTrackingAction);
|
||||
@@ -295,9 +334,9 @@ void G4AdjointSimManager::ResetRestOfUserActions()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::ResetUserPrimaryRunAndStackingActions()
|
||||
{
|
||||
G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
//Restore the user defined actions
|
||||
{
|
||||
G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
// Restore the user defined actions
|
||||
//-------------------------------
|
||||
theRunManager->G4RunManager::SetUserAction(fUserRunAction);
|
||||
theRunManager->G4RunManager::SetUserAction(fUserPrimaryGeneratorAction);
|
||||
@@ -306,55 +345,66 @@ void G4AdjointSimManager::ResetUserPrimaryRunAndStackingActions()
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::DefineUserActions()
|
||||
{
|
||||
G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
fUserTrackingAction= const_cast<G4UserTrackingAction* >( theRunManager->GetUserTrackingAction() );
|
||||
fUserEventAction= const_cast<G4UserEventAction* >( theRunManager->GetUserEventAction() );
|
||||
fUserSteppingAction= const_cast<G4UserSteppingAction* >( theRunManager->GetUserSteppingAction() );
|
||||
theAdjointSteppingAction->SetUserForwardSteppingAction(fUserSteppingAction);
|
||||
fUserPrimaryGeneratorAction= const_cast<G4VUserPrimaryGeneratorAction* >( theRunManager->GetUserPrimaryGeneratorAction() );
|
||||
fUserRunAction= const_cast<G4UserRunAction*>( theRunManager->GetUserRunAction() );
|
||||
fUserStackingAction= const_cast<G4UserStackingAction* >( theRunManager->GetUserStackingAction() );
|
||||
user_action_already_defined=true;
|
||||
{
|
||||
G4RunManager* theRunManager = G4RunManager::GetRunManager();
|
||||
fUserTrackingAction =
|
||||
const_cast<G4UserTrackingAction*>(theRunManager->GetUserTrackingAction());
|
||||
fUserEventAction =
|
||||
const_cast<G4UserEventAction*>(theRunManager->GetUserEventAction());
|
||||
fUserSteppingAction =
|
||||
const_cast<G4UserSteppingAction*>(theRunManager->GetUserSteppingAction());
|
||||
theAdjointSteppingAction->SetUserForwardSteppingAction(fUserSteppingAction);
|
||||
fUserPrimaryGeneratorAction = const_cast<G4VUserPrimaryGeneratorAction*>(
|
||||
theRunManager->GetUserPrimaryGeneratorAction());
|
||||
fUserRunAction =
|
||||
const_cast<G4UserRunAction*>(theRunManager->GetUserRunAction());
|
||||
fUserStackingAction =
|
||||
const_cast<G4UserStackingAction*>(theRunManager->GetUserStackingAction());
|
||||
user_action_already_defined = true;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointSimManager::GetAdjointTrackingMode(){
|
||||
return theAdjointTrackingAction->GetIsAdjointTrackingMode();
|
||||
G4bool G4AdjointSimManager::GetAdjointTrackingMode()
|
||||
{
|
||||
return theAdjointTrackingAction->GetIsAdjointTrackingMode();
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::SetAdjointTrackingMode(G4bool aBool)//could be removed
|
||||
void G4AdjointSimManager::SetAdjointTrackingMode(
|
||||
G4bool aBool) // could be removed
|
||||
{
|
||||
adjoint_tracking_mode = aBool;
|
||||
|
||||
if (adjoint_tracking_mode) {
|
||||
SetRestOfAdjointActions();
|
||||
theAdjointStackingAction->SetAdjointMode(true);
|
||||
theAdjointStackingAction->SetKillTracks(false);
|
||||
|
||||
}
|
||||
else {
|
||||
|
||||
ResetRestOfUserActions();
|
||||
theAdjointStackingAction->SetAdjointMode(false);
|
||||
if (GetDidAdjParticleReachTheExtSource()){
|
||||
theAdjointStackingAction->SetKillTracks(false);
|
||||
RegisterAtEndOfAdjointTrack();
|
||||
}
|
||||
else theAdjointStackingAction->SetKillTracks(true);
|
||||
}
|
||||
|
||||
if(adjoint_tracking_mode)
|
||||
{
|
||||
SetRestOfAdjointActions();
|
||||
theAdjointStackingAction->SetAdjointMode(true);
|
||||
theAdjointStackingAction->SetKillTracks(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
ResetRestOfUserActions();
|
||||
theAdjointStackingAction->SetAdjointMode(false);
|
||||
if(GetDidAdjParticleReachTheExtSource())
|
||||
{
|
||||
theAdjointStackingAction->SetKillTracks(false);
|
||||
RegisterAtEndOfAdjointTrack();
|
||||
}
|
||||
else
|
||||
theAdjointStackingAction->SetKillTracks(true);
|
||||
}
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointSimManager::GetDidAdjParticleReachTheExtSource()
|
||||
{
|
||||
return (GetNbOfAdointTracksReachingTheExternalSurface()>0);
|
||||
return (GetNbOfAdointTracksReachingTheExternalSurface() > 0);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
std::vector<G4ParticleDefinition*>* G4AdjointSimManager::GetListOfPrimaryFwdParticles()
|
||||
std::vector<G4ParticleDefinition*>*
|
||||
G4AdjointSimManager::GetListOfPrimaryFwdParticles()
|
||||
{
|
||||
return theAdjointPrimaryGeneratorAction->GetListOfPrimaryFwdParticles();
|
||||
}
|
||||
@@ -362,102 +412,120 @@ std::vector<G4ParticleDefinition*>* G4AdjointSimManager::GetListOfPrimaryFwdPar
|
||||
//
|
||||
size_t G4AdjointSimManager::GetNbOfPrimaryFwdParticles()
|
||||
{
|
||||
return theAdjointPrimaryGeneratorAction->GetListOfPrimaryFwdParticles()->size();
|
||||
return theAdjointPrimaryGeneratorAction->GetListOfPrimaryFwdParticles()
|
||||
->size();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4ThreeVector G4AdjointSimManager::GetPositionAtEndOfLastAdjointTrack(size_t i){
|
||||
return theAdjointTrackingAction->GetPositionAtEndOfLastAdjointTrack(i);
|
||||
G4ThreeVector G4AdjointSimManager::GetPositionAtEndOfLastAdjointTrack(size_t i)
|
||||
{
|
||||
return theAdjointTrackingAction->GetPositionAtEndOfLastAdjointTrack(i);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4ThreeVector G4AdjointSimManager::GetDirectionAtEndOfLastAdjointTrack(size_t i){
|
||||
return theAdjointTrackingAction->GetDirectionAtEndOfLastAdjointTrack(i);
|
||||
G4ThreeVector G4AdjointSimManager::GetDirectionAtEndOfLastAdjointTrack(size_t i)
|
||||
{
|
||||
return theAdjointTrackingAction->GetDirectionAtEndOfLastAdjointTrack(i);
|
||||
}
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4double G4AdjointSimManager::GetEkinAtEndOfLastAdjointTrack(size_t i){
|
||||
return theAdjointTrackingAction->GetEkinAtEndOfLastAdjointTrack(i);
|
||||
G4double G4AdjointSimManager::GetEkinAtEndOfLastAdjointTrack(size_t i)
|
||||
{
|
||||
return theAdjointTrackingAction->GetEkinAtEndOfLastAdjointTrack(i);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4double G4AdjointSimManager::GetEkinNucAtEndOfLastAdjointTrack(size_t i){
|
||||
return theAdjointTrackingAction->GetEkinNucAtEndOfLastAdjointTrack(i);
|
||||
G4double G4AdjointSimManager::GetEkinNucAtEndOfLastAdjointTrack(size_t i)
|
||||
{
|
||||
return theAdjointTrackingAction->GetEkinNucAtEndOfLastAdjointTrack(i);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4double G4AdjointSimManager::GetWeightAtEndOfLastAdjointTrack(size_t i){
|
||||
return theAdjointTrackingAction->GetWeightAtEndOfLastAdjointTrack(i);
|
||||
G4double G4AdjointSimManager::GetWeightAtEndOfLastAdjointTrack(size_t i)
|
||||
{
|
||||
return theAdjointTrackingAction->GetWeightAtEndOfLastAdjointTrack(i);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4double G4AdjointSimManager::GetCosthAtEndOfLastAdjointTrack(size_t i){
|
||||
return theAdjointTrackingAction->GetCosthAtEndOfLastAdjointTrack(i);
|
||||
G4double G4AdjointSimManager::GetCosthAtEndOfLastAdjointTrack(size_t i)
|
||||
{
|
||||
return theAdjointTrackingAction->GetCosthAtEndOfLastAdjointTrack(i);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
const G4String& G4AdjointSimManager::GetFwdParticleNameAtEndOfLastAdjointTrack()
|
||||
{return theAdjointTrackingAction->GetFwdParticleNameAtEndOfLastAdjointTrack();
|
||||
{
|
||||
return theAdjointTrackingAction->GetFwdParticleNameAtEndOfLastAdjointTrack();
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4int G4AdjointSimManager::GetFwdParticlePDGEncodingAtEndOfLastAdjointTrack(size_t i){
|
||||
return theAdjointTrackingAction->GetFwdParticlePDGEncodingAtEndOfLastAdjointTrack(i);
|
||||
G4int G4AdjointSimManager::GetFwdParticlePDGEncodingAtEndOfLastAdjointTrack(
|
||||
size_t i)
|
||||
{
|
||||
return theAdjointTrackingAction
|
||||
->GetFwdParticlePDGEncodingAtEndOfLastAdjointTrack(i);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4int G4AdjointSimManager::GetFwdParticleIndexAtEndOfLastAdjointTrack(size_t i)
|
||||
{return theAdjointTrackingAction->GetLastFwdParticleIndex(i);
|
||||
{
|
||||
return theAdjointTrackingAction->GetLastFwdParticleIndex(i);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
size_t G4AdjointSimManager::GetNbOfAdointTracksReachingTheExternalSurface()
|
||||
{
|
||||
return theAdjointTrackingAction->GetNbOfAdointTracksReachingTheExternalSurface();
|
||||
return theAdjointTrackingAction
|
||||
->GetNbOfAdointTracksReachingTheExternalSurface();
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::ClearEndOfAdjointTrackInfoVectors()
|
||||
{theAdjointTrackingAction->ClearEndOfAdjointTrackInfoVectors();
|
||||
{
|
||||
theAdjointTrackingAction->ClearEndOfAdjointTrackInfoVectors();
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::RegisterAtEndOfAdjointTrack()
|
||||
{
|
||||
last_pos = theAdjointSteppingAction->GetLastPosition();
|
||||
last_pos = theAdjointSteppingAction->GetLastPosition();
|
||||
last_direction = theAdjointSteppingAction->GetLastMomentum();
|
||||
last_direction /=last_direction.mag();
|
||||
last_cos_th = last_direction.z();
|
||||
G4ParticleDefinition* aPartDef= theAdjointSteppingAction->GetLastPartDef();
|
||||
|
||||
last_fwd_part_name= aPartDef->GetParticleName();
|
||||
|
||||
last_fwd_part_name.remove(0,4);
|
||||
|
||||
last_fwd_part_PDGEncoding=G4ParticleTable::GetParticleTable()->FindParticle(last_fwd_part_name)->GetPDGEncoding();
|
||||
|
||||
std::vector<G4ParticleDefinition*>* aList = theAdjointPrimaryGeneratorAction->GetListOfPrimaryFwdParticles();
|
||||
last_fwd_part_index=-1;
|
||||
size_t i=0;
|
||||
while(i<aList->size() && last_fwd_part_index<0) {
|
||||
if ((*aList)[i]->GetParticleName() == last_fwd_part_name) last_fwd_part_index=i;
|
||||
i++;
|
||||
last_direction /= last_direction.mag();
|
||||
last_cos_th = last_direction.z();
|
||||
G4ParticleDefinition* aPartDef = theAdjointSteppingAction->GetLastPartDef();
|
||||
|
||||
last_fwd_part_name = aPartDef->GetParticleName();
|
||||
|
||||
last_fwd_part_name.remove(0, 4);
|
||||
|
||||
last_fwd_part_PDGEncoding = G4ParticleTable::GetParticleTable()
|
||||
->FindParticle(last_fwd_part_name)
|
||||
->GetPDGEncoding();
|
||||
|
||||
std::vector<G4ParticleDefinition*>* aList =
|
||||
theAdjointPrimaryGeneratorAction->GetListOfPrimaryFwdParticles();
|
||||
last_fwd_part_index = -1;
|
||||
size_t i = 0;
|
||||
while(i < aList->size() && last_fwd_part_index < 0)
|
||||
{
|
||||
if((*aList)[i]->GetParticleName() == last_fwd_part_name)
|
||||
last_fwd_part_index = i;
|
||||
i++;
|
||||
}
|
||||
|
||||
last_ekin = theAdjointSteppingAction->GetLastEkin();
|
||||
|
||||
last_ekin = theAdjointSteppingAction->GetLastEkin();
|
||||
last_ekin_nuc = last_ekin;
|
||||
if (aPartDef->GetParticleType() == "adjoint_nucleus") {
|
||||
nb_nuc=double(aPartDef->GetBaryonNumber());
|
||||
last_ekin_nuc /=nb_nuc;
|
||||
if(aPartDef->GetParticleType() == "adjoint_nucleus")
|
||||
{
|
||||
nb_nuc = double(aPartDef->GetBaryonNumber());
|
||||
last_ekin_nuc /= nb_nuc;
|
||||
}
|
||||
|
||||
last_weight = theAdjointSteppingAction->GetLastWeight();
|
||||
|
||||
|
||||
last_weight = theAdjointSteppingAction->GetLastWeight();
|
||||
|
||||
last_pos_vec.push_back(last_pos);
|
||||
last_direction_vec.push_back(last_direction);
|
||||
@@ -468,100 +536,116 @@ void G4AdjointSimManager::RegisterAtEndOfAdjointTrack()
|
||||
last_fwd_part_PDGEncoding_vec.push_back(last_fwd_part_PDGEncoding);
|
||||
last_fwd_part_index_vec.push_back(last_fwd_part_index);
|
||||
ID_of_last_particle_that_reach_the_ext_source++;
|
||||
ID_of_last_particle_that_reach_the_ext_source_vec.push_back(ID_of_last_particle_that_reach_the_ext_source);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
ID_of_last_particle_that_reach_the_ext_source_vec.push_back(
|
||||
ID_of_last_particle_that_reach_the_ext_source);
|
||||
|
||||
/* G4PhysicsLogVector* theWeightVector=0;
|
||||
if (last_fwd_part_name =="e-") theWeightVector=electron_last_weight_vector;
|
||||
else if (last_fwd_part_name =="gamma") theWeightVector=gamma_last_weight_vector;
|
||||
else if (last_fwd_part_name =="proton") theWeightVector=proton_last_weight_vector;
|
||||
|
||||
else if (last_fwd_part_name =="gamma")
|
||||
theWeightVector=gamma_last_weight_vector; else if (last_fwd_part_name
|
||||
=="proton") theWeightVector=proton_last_weight_vector;
|
||||
|
||||
if (theWeightVector){
|
||||
|
||||
size_t ind = size_t(std::log10(last_weight/theAdjointPrimaryWeight)*10. + 200);
|
||||
G4double low_val =theWeightVector->GetLowEdgeEnergy(ind);
|
||||
G4bool aBool = true;
|
||||
G4double bin_weight = theWeightVector->GetValue(low_val, aBool)+1.;
|
||||
theWeightVector->PutValue(ind, bin_weight);
|
||||
size_t ind = size_t(std::log10(last_weight/theAdjointPrimaryWeight)*10. +
|
||||
200); G4double low_val =theWeightVector->GetLowEdgeEnergy(ind); G4bool aBool =
|
||||
true; G4double bin_weight = theWeightVector->GetValue(low_val, aBool)+1.;
|
||||
theWeightVector->PutValue(ind, bin_weight);
|
||||
}
|
||||
*/
|
||||
/*if ((last_weight/theAdjointPrimaryWeight)>1.) last_weight*=1000. ;
|
||||
else if ( (last_weight/theAdjointPrimaryWeight)>0.1) last_weight*=100. ;
|
||||
else if ( (last_weight/theAdjointPrimaryWeight)>0.01) last_weight*=10. ;*/
|
||||
|
||||
|
||||
//G4cout <<"Last Weight "<<last_weight<<'\t'<<theAdjointPrimaryWeight<<'\t'<<last_weight/theAdjointPrimaryWeight<<std::endl;
|
||||
|
||||
// G4cout <<"Last Weight
|
||||
// "<<last_weight<<'\t'<<theAdjointPrimaryWeight<<'\t'<<last_weight/theAdjointPrimaryWeight<<std::endl;
|
||||
/*if (last_weight/theAdjointPrimaryWeight >10.) {
|
||||
G4cout<<"Warning a weight increase by a factor : "<<last_weight/theAdjointPrimaryWeight<<std::endl;
|
||||
G4cout<<"Warning a weight increase by a factor :
|
||||
"<<last_weight/theAdjointPrimaryWeight<<std::endl;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointSimManager::DefineSphericalExtSource(G4double radius, G4ThreeVector pos)
|
||||
{
|
||||
G4double area;
|
||||
return G4AdjointCrossSurfChecker::GetInstance()->AddaSphericalSurface("ExternalSource", radius, pos, area);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointSimManager::DefineSphericalExtSourceWithCentreAtTheCentreOfAVolume(G4double radius, const G4String& volume_name)
|
||||
G4bool G4AdjointSimManager::DefineSphericalExtSource(G4double radius,
|
||||
G4ThreeVector pos)
|
||||
{
|
||||
G4double area;
|
||||
G4ThreeVector center;
|
||||
return G4AdjointCrossSurfChecker::GetInstance()->AddaSphericalSurfaceWithCenterAtTheCenterOfAVolume( "ExternalSource", radius, volume_name,center, area);
|
||||
G4double area;
|
||||
return G4AdjointCrossSurfChecker::GetInstance()->AddaSphericalSurface(
|
||||
"ExternalSource", radius, pos, area);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointSimManager::DefineExtSourceOnTheExtSurfaceOfAVolume(const G4String& volume_name)
|
||||
G4bool
|
||||
G4AdjointSimManager::DefineSphericalExtSourceWithCentreAtTheCentreOfAVolume(
|
||||
G4double radius, const G4String& volume_name)
|
||||
{
|
||||
G4double area;
|
||||
return G4AdjointCrossSurfChecker::GetInstance()->AddanExtSurfaceOfAvolume( "ExternalSource", volume_name,area);
|
||||
G4double area;
|
||||
G4ThreeVector center;
|
||||
return G4AdjointCrossSurfChecker::GetInstance()
|
||||
->AddaSphericalSurfaceWithCenterAtTheCenterOfAVolume(
|
||||
"ExternalSource", radius, volume_name, center, area);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::SetExtSourceEmax(G4double Emax)
|
||||
G4bool G4AdjointSimManager::DefineExtSourceOnTheExtSurfaceOfAVolume(
|
||||
const G4String& volume_name)
|
||||
{
|
||||
G4double area;
|
||||
return G4AdjointCrossSurfChecker::GetInstance()->AddanExtSurfaceOfAvolume(
|
||||
"ExternalSource", volume_name, area);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::SetExtSourceEmax(G4double Emax)
|
||||
{
|
||||
theAdjointSteppingAction->SetExtSourceEMax(Emax);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointSimManager::DefineSphericalAdjointSource(G4double radius, G4ThreeVector pos)
|
||||
{
|
||||
G4double area;
|
||||
G4bool aBool = G4AdjointCrossSurfChecker::GetInstance()->AddaSphericalSurface("AdjointSource", radius, pos, area);
|
||||
theAdjointPrimaryGeneratorAction->SetSphericalAdjointPrimarySource(radius, pos);
|
||||
area_of_the_adjoint_source=area;
|
||||
return aBool;
|
||||
G4bool G4AdjointSimManager::DefineSphericalAdjointSource(G4double radius,
|
||||
G4ThreeVector pos)
|
||||
{
|
||||
G4double area;
|
||||
G4bool aBool = G4AdjointCrossSurfChecker::GetInstance()->AddaSphericalSurface(
|
||||
"AdjointSource", radius, pos, area);
|
||||
theAdjointPrimaryGeneratorAction->SetSphericalAdjointPrimarySource(radius,
|
||||
pos);
|
||||
area_of_the_adjoint_source = area;
|
||||
return aBool;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointSimManager::DefineSphericalAdjointSourceWithCentreAtTheCentreOfAVolume(G4double radius, const G4String& volume_name)
|
||||
G4bool
|
||||
G4AdjointSimManager::DefineSphericalAdjointSourceWithCentreAtTheCentreOfAVolume(
|
||||
G4double radius, const G4String& volume_name)
|
||||
{
|
||||
G4double area;
|
||||
G4ThreeVector center;
|
||||
G4bool aBool = G4AdjointCrossSurfChecker::GetInstance()->AddaSphericalSurfaceWithCenterAtTheCenterOfAVolume( "AdjointSource", radius, volume_name,center, area);
|
||||
theAdjointPrimaryGeneratorAction->SetSphericalAdjointPrimarySource(radius, center);
|
||||
area_of_the_adjoint_source=area;
|
||||
return aBool;
|
||||
G4double area;
|
||||
G4ThreeVector center;
|
||||
G4bool aBool = G4AdjointCrossSurfChecker::GetInstance()
|
||||
->AddaSphericalSurfaceWithCenterAtTheCenterOfAVolume(
|
||||
"AdjointSource", radius, volume_name, center, area);
|
||||
theAdjointPrimaryGeneratorAction->SetSphericalAdjointPrimarySource(radius,
|
||||
center);
|
||||
area_of_the_adjoint_source = area;
|
||||
return aBool;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4bool G4AdjointSimManager::DefineAdjointSourceOnTheExtSurfaceOfAVolume(const G4String& volume_name)
|
||||
G4bool G4AdjointSimManager::DefineAdjointSourceOnTheExtSurfaceOfAVolume(
|
||||
const G4String& volume_name)
|
||||
{
|
||||
G4double area;
|
||||
G4bool aBool = G4AdjointCrossSurfChecker::GetInstance()->AddanExtSurfaceOfAvolume( "AdjointSource", volume_name,area);
|
||||
area_of_the_adjoint_source=area;
|
||||
if (aBool) {
|
||||
theAdjointPrimaryGeneratorAction->SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(volume_name);
|
||||
}
|
||||
return aBool;
|
||||
G4double area;
|
||||
G4bool aBool =
|
||||
G4AdjointCrossSurfChecker::GetInstance()->AddanExtSurfaceOfAvolume(
|
||||
"AdjointSource", volume_name, area);
|
||||
area_of_the_adjoint_source = area;
|
||||
if(aBool)
|
||||
{
|
||||
theAdjointPrimaryGeneratorAction
|
||||
->SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(volume_name);
|
||||
}
|
||||
return aBool;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -577,13 +661,15 @@ void G4AdjointSimManager::SetAdjointSourceEmax(G4double Emax)
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::ConsiderParticleAsPrimary(const G4String& particle_name)
|
||||
void G4AdjointSimManager::ConsiderParticleAsPrimary(
|
||||
const G4String& particle_name)
|
||||
{
|
||||
theAdjointPrimaryGeneratorAction->ConsiderParticleAsPrimary(particle_name);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::NeglectParticleAsPrimary(const G4String& particle_name)
|
||||
void G4AdjointSimManager::NeglectParticleAsPrimary(
|
||||
const G4String& particle_name)
|
||||
{
|
||||
theAdjointPrimaryGeneratorAction->NeglectParticleAsPrimary(particle_name);
|
||||
}
|
||||
@@ -596,7 +682,8 @@ void G4AdjointSimManager::NeglectParticleAsPrimary(const G4String& particle_name
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::SetPrimaryIon(G4ParticleDefinition* adjointIon, G4ParticleDefinition* fwdIon)
|
||||
void G4AdjointSimManager::SetPrimaryIon(G4ParticleDefinition* adjointIon,
|
||||
G4ParticleDefinition* fwdIon)
|
||||
{
|
||||
theAdjointPrimaryGeneratorAction->SetPrimaryIon(adjointIon, fwdIon);
|
||||
}
|
||||
@@ -612,7 +699,7 @@ void G4AdjointSimManager::RegisterAdjointPrimaryWeight(G4double aWeight)
|
||||
{
|
||||
theAdjointPrimaryWeight = aWeight;
|
||||
theAdjointSteppingAction->SetPrimWeight(aWeight);
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
@@ -622,13 +709,15 @@ void G4AdjointSimManager::SetAdjointEventAction(G4UserEventAction* anAction)
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::SetAdjointSteppingAction(G4UserSteppingAction* anAction)
|
||||
void G4AdjointSimManager::SetAdjointSteppingAction(
|
||||
G4UserSteppingAction* anAction)
|
||||
{
|
||||
theAdjointSteppingAction->SetUserAdjointSteppingAction(anAction);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::SetAdjointStackingAction(G4UserStackingAction* anAction)
|
||||
void G4AdjointSimManager::SetAdjointStackingAction(
|
||||
G4UserStackingAction* anAction)
|
||||
{
|
||||
theAdjointStackingAction->SetUserAdjointStackingAction(anAction);
|
||||
}
|
||||
@@ -637,8 +726,8 @@ void G4AdjointSimManager::SetAdjointStackingAction(G4UserStackingAction* anActio
|
||||
//
|
||||
void G4AdjointSimManager::SetAdjointRunAction(G4UserRunAction* anAction)
|
||||
{
|
||||
theAdjointRunAction=anAction;
|
||||
}
|
||||
theAdjointRunAction = anAction;
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::SetNbOfPrimaryFwdGammasPerEvent(G4int nb)
|
||||
@@ -661,41 +750,44 @@ void G4AdjointSimManager::SetNbAdjointPrimaryElectronsPerEvent(G4int nb)
|
||||
//
|
||||
void G4AdjointSimManager::BeginOfRunAction(const G4Run* aRun)
|
||||
{
|
||||
/*
|
||||
if (!adjoint_sim_mode){
|
||||
if(fUserRunAction) fUserRunAction->BeginOfRunAction(aRun);
|
||||
}
|
||||
else {
|
||||
if (theAdjointRunAction) theAdjointRunAction->BeginOfRunAction(aRun);
|
||||
}
|
||||
*/
|
||||
fUserRunAction->BeginOfRunAction(aRun);
|
||||
/*
|
||||
if (!adjoint_sim_mode){
|
||||
if(fUserRunAction) fUserRunAction->BeginOfRunAction(aRun);
|
||||
}
|
||||
else {
|
||||
if (theAdjointRunAction) theAdjointRunAction->BeginOfRunAction(aRun);
|
||||
}
|
||||
*/
|
||||
fUserRunAction->BeginOfRunAction(aRun);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::EndOfRunAction(const G4Run* aRun)
|
||||
{if (!adjoint_sim_mode){
|
||||
if(fUserRunAction) fUserRunAction->EndOfRunAction(aRun);
|
||||
}
|
||||
else if (theAdjointRunAction) theAdjointRunAction->EndOfRunAction(aRun);
|
||||
/*
|
||||
#ifdef G4MULTITHREADED
|
||||
if (G4RunManager::GetRunManager()->GetRunManagerType() == G4RunManager::workerRM){
|
||||
if (adjoint_sim_mode) BackToFwdSimulationMode();
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
|
||||
{
|
||||
if(!adjoint_sim_mode)
|
||||
{
|
||||
if(fUserRunAction)
|
||||
fUserRunAction->EndOfRunAction(aRun);
|
||||
}
|
||||
else if(theAdjointRunAction)
|
||||
theAdjointRunAction->EndOfRunAction(aRun);
|
||||
/*
|
||||
#ifdef G4MULTITHREADED
|
||||
if (G4RunManager::GetRunManager()->GetRunManagerType() ==
|
||||
G4RunManager::workerRM){ if (adjoint_sim_mode) BackToFwdSimulationMode();
|
||||
}
|
||||
#endif
|
||||
*/
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4ParticleDefinition* G4AdjointSimManager::GetLastGeneratedFwdPrimaryParticle(){
|
||||
return theAdjointPrimaryGeneratorAction->GetLastGeneratedFwdPrimaryParticle();
|
||||
G4ParticleDefinition* G4AdjointSimManager::GetLastGeneratedFwdPrimaryParticle()
|
||||
{
|
||||
return theAdjointPrimaryGeneratorAction->GetLastGeneratedFwdPrimaryParticle();
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
void G4AdjointSimManager::ResetDidOneAdjPartReachExtSourceDuringEvent()
|
||||
{theAdjointSteppingAction->ResetDidOneAdjPartReachExtSourceDuringEvent();
|
||||
{
|
||||
theAdjointSteppingAction->ResetDidOneAdjPartReachExtSourceDuringEvent();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -34,18 +34,18 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "G4AdjointSimManager.hh"
|
||||
#include "G4AdjointSimMessenger.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4AdjointSimManager.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithABool.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithADouble.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4UIcmdWith3VectorAndUnit.hh"
|
||||
#include "G4UIcmdWithABool.hh"
|
||||
#include "G4UIcmdWithADouble.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
/*
|
||||
#ifdef G4MULTITHREADED
|
||||
#include "G4MTAdjointSimManager.hh"
|
||||
@@ -53,7 +53,8 @@
|
||||
*/
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
G4AdjointSimMessenger::G4AdjointSimMessenger(G4AdjointSimManager* pAdjointRunManager)
|
||||
G4AdjointSimMessenger::G4AdjointSimMessenger(
|
||||
G4AdjointSimManager* pAdjointRunManager)
|
||||
: theAdjointRunManager(pAdjointRunManager)
|
||||
/*
|
||||
#ifdef G4MULTITHREADED
|
||||
@@ -61,40 +62,42 @@ G4AdjointSimMessenger::G4AdjointSimMessenger(G4AdjointSimManager* pAdjointRunMan
|
||||
#endif
|
||||
*/
|
||||
|
||||
{
|
||||
{
|
||||
AdjointSimDir = new G4UIdirectory("/adjoint/");
|
||||
AdjointSimDir->SetGuidance("Control of the adjoint or reverse monte carlo simulation");
|
||||
AdjointSimDir->SetGuidance(
|
||||
"Control of the adjoint or reverse monte carlo simulation");
|
||||
|
||||
|
||||
//Start and adjoint Run
|
||||
// Start and adjoint Run
|
||||
//---------------------
|
||||
//if (G4RunManager::GetRunManager()->GetRunManagerType() == G4RunManager::sequentialRM){
|
||||
beamOnCmd = new G4UIcommand("/adjoint/start_run",this);
|
||||
beamOnCmd->SetGuidance("Start an adjoint Run.");
|
||||
beamOnCmd->SetGuidance("Default number of events to be processed is 1.");
|
||||
beamOnCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
G4UIparameter* p1 = new G4UIparameter("numberOfEvent",'i',true);
|
||||
p1->SetDefaultValue(1);
|
||||
p1->SetParameterRange("numberOfEvent >= 0");
|
||||
beamOnCmd->SetParameter(p1);
|
||||
// if (G4RunManager::GetRunManager()->GetRunManagerType() ==
|
||||
// G4RunManager::sequentialRM){
|
||||
beamOnCmd = new G4UIcommand("/adjoint/start_run", this);
|
||||
beamOnCmd->SetGuidance("Start an adjoint Run.");
|
||||
beamOnCmd->SetGuidance("Default number of events to be processed is 1.");
|
||||
beamOnCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
G4UIparameter* p1 = new G4UIparameter("numberOfEvent", 'i', true);
|
||||
p1->SetDefaultValue(1);
|
||||
p1->SetParameterRange("numberOfEvent >= 0");
|
||||
beamOnCmd->SetParameter(p1);
|
||||
//}
|
||||
|
||||
//Commands to define parameters relative to the external source
|
||||
// Commands to define parameters relative to the external source
|
||||
//------------------------------------------------------------
|
||||
|
||||
G4UIparameter* pos_x_par = new G4UIparameter("X",'d',true);
|
||||
|
||||
G4UIparameter* pos_y_par = new G4UIparameter("Y",'d',true);
|
||||
|
||||
G4UIparameter* pos_z_par = new G4UIparameter("Z",'d',true);
|
||||
|
||||
G4UIparameter* radius_par = new G4UIparameter("R",'d',true);
|
||||
|
||||
radius_par->SetParameterRange("R >= 0");
|
||||
|
||||
G4UIparameter* unit_par = new G4UIparameter("unit",'s',true);
|
||||
|
||||
DefineSpherExtSourceCmd = new G4UIcommand("/adjoint/DefineSphericalExtSource",this);
|
||||
G4UIparameter* pos_x_par = new G4UIparameter("X", 'd', true);
|
||||
|
||||
G4UIparameter* pos_y_par = new G4UIparameter("Y", 'd', true);
|
||||
|
||||
G4UIparameter* pos_z_par = new G4UIparameter("Z", 'd', true);
|
||||
|
||||
G4UIparameter* radius_par = new G4UIparameter("R", 'd', true);
|
||||
|
||||
radius_par->SetParameterRange("R >= 0");
|
||||
|
||||
G4UIparameter* unit_par = new G4UIparameter("unit", 's', true);
|
||||
|
||||
DefineSpherExtSourceCmd =
|
||||
new G4UIcommand("/adjoint/DefineSphericalExtSource", this);
|
||||
DefineSpherExtSourceCmd->SetGuidance("Define a spherical external source.");
|
||||
DefineSpherExtSourceCmd->SetParameter(pos_x_par);
|
||||
DefineSpherExtSourceCmd->SetParameter(pos_y_par);
|
||||
@@ -102,28 +105,39 @@ G4AdjointSimMessenger::G4AdjointSimMessenger(G4AdjointSimManager* pAdjointRunMan
|
||||
DefineSpherExtSourceCmd->SetParameter(radius_par);
|
||||
DefineSpherExtSourceCmd->SetParameter(unit_par);
|
||||
|
||||
G4UIparameter* phys_vol_name_par = new G4UIparameter("phys_vol_name",'s',true);
|
||||
G4UIparameter* phys_vol_name_par =
|
||||
new G4UIparameter("phys_vol_name", 's', true);
|
||||
|
||||
DefineSpherExtSourceCenteredOnAVolumeCmd= new G4UIcommand("/adjoint/DefineSphericalExtSourceCenteredOnAVolume",this);
|
||||
DefineSpherExtSourceCenteredOnAVolumeCmd->SetGuidance("Define a spherical external source with the center located at the center of a physical volume");
|
||||
DefineSpherExtSourceCenteredOnAVolumeCmd =
|
||||
new G4UIcommand("/adjoint/DefineSphericalExtSourceCenteredOnAVolume", this);
|
||||
DefineSpherExtSourceCenteredOnAVolumeCmd->SetGuidance(
|
||||
"Define a spherical external source with the center located at the center "
|
||||
"of a "
|
||||
"physical volume");
|
||||
DefineSpherExtSourceCenteredOnAVolumeCmd->SetParameter(phys_vol_name_par);
|
||||
DefineSpherExtSourceCenteredOnAVolumeCmd->SetParameter(radius_par);
|
||||
DefineSpherExtSourceCenteredOnAVolumeCmd->SetParameter(unit_par);
|
||||
|
||||
DefineExtSourceOnAVolumeExtSurfaceCmd= new G4UIcmdWithAString("/adjoint/DefineExtSourceOnExtSurfaceOfAVolume",this);
|
||||
DefineExtSourceOnAVolumeExtSurfaceCmd->SetGuidance("Set the external source on the external surface of a physical volume");
|
||||
DefineExtSourceOnAVolumeExtSurfaceCmd->SetParameterName("phys_vol_name",false);
|
||||
|
||||
setExtSourceEMaxCmd = new G4UIcmdWithADoubleAndUnit("/adjoint/SetExtSourceEmax",this);
|
||||
setExtSourceEMaxCmd->SetGuidance("Set the maximum energy of the external source");
|
||||
setExtSourceEMaxCmd->SetParameterName("Emax",false);
|
||||
setExtSourceEMaxCmd->SetUnitCategory("Energy");
|
||||
setExtSourceEMaxCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
DefineExtSourceOnAVolumeExtSurfaceCmd = new G4UIcmdWithAString(
|
||||
"/adjoint/DefineExtSourceOnExtSurfaceOfAVolume", this);
|
||||
DefineExtSourceOnAVolumeExtSurfaceCmd->SetGuidance(
|
||||
"Set the external source on the external surface of a physical volume");
|
||||
DefineExtSourceOnAVolumeExtSurfaceCmd->SetParameterName("phys_vol_name",
|
||||
false);
|
||||
|
||||
//Commands to define the adjoint source
|
||||
setExtSourceEMaxCmd =
|
||||
new G4UIcmdWithADoubleAndUnit("/adjoint/SetExtSourceEmax", this);
|
||||
setExtSourceEMaxCmd->SetGuidance(
|
||||
"Set the maximum energy of the external source");
|
||||
setExtSourceEMaxCmd->SetParameterName("Emax", false);
|
||||
setExtSourceEMaxCmd->SetUnitCategory("Energy");
|
||||
setExtSourceEMaxCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
// Commands to define the adjoint source
|
||||
//------------------------------------------------------------
|
||||
|
||||
DefineSpherAdjSourceCmd = new G4UIcommand("/adjoint/DefineSphericalAdjSource",this);
|
||||
DefineSpherAdjSourceCmd =
|
||||
new G4UIcommand("/adjoint/DefineSphericalAdjSource", this);
|
||||
DefineSpherAdjSourceCmd->SetGuidance("Define a spherical adjoint source.");
|
||||
DefineSpherAdjSourceCmd->SetParameter(pos_x_par);
|
||||
DefineSpherAdjSourceCmd->SetParameter(pos_y_par);
|
||||
@@ -131,74 +145,94 @@ G4AdjointSimMessenger::G4AdjointSimMessenger(G4AdjointSimManager* pAdjointRunMan
|
||||
DefineSpherAdjSourceCmd->SetParameter(radius_par);
|
||||
DefineSpherAdjSourceCmd->SetParameter(unit_par);
|
||||
|
||||
DefineSpherAdjSourceCenteredOnAVolumeCmd= new G4UIcommand("/adjoint/DefineSphericalAdjSourceCenteredOnAVolume",this);
|
||||
DefineSpherAdjSourceCenteredOnAVolumeCmd->SetGuidance("Define a spherical adjoint source with the center located at the center of a physical volume");
|
||||
DefineSpherAdjSourceCenteredOnAVolumeCmd =
|
||||
new G4UIcommand("/adjoint/DefineSphericalAdjSourceCenteredOnAVolume", this);
|
||||
DefineSpherAdjSourceCenteredOnAVolumeCmd->SetGuidance(
|
||||
"Define a spherical adjoint source with the center located at the center "
|
||||
"of a "
|
||||
"physical volume");
|
||||
DefineSpherAdjSourceCenteredOnAVolumeCmd->SetParameter(phys_vol_name_par);
|
||||
DefineSpherAdjSourceCenteredOnAVolumeCmd->SetParameter(radius_par);
|
||||
DefineSpherAdjSourceCenteredOnAVolumeCmd->SetParameter(unit_par);
|
||||
|
||||
DefineAdjSourceOnAVolumeExtSurfaceCmd= new G4UIcmdWithAString("/adjoint/DefineAdjSourceOnExtSurfaceOfAVolume",this);
|
||||
DefineAdjSourceOnAVolumeExtSurfaceCmd->SetGuidance("Set the adjoint source on the external surface of physical volume");
|
||||
DefineAdjSourceOnAVolumeExtSurfaceCmd->SetParameterName("phys_vol_name",false);
|
||||
|
||||
setAdjSourceEminCmd = new G4UIcmdWithADoubleAndUnit("/adjoint/SetAdjSourceEmin",this);
|
||||
setAdjSourceEminCmd->SetGuidance("Set the minimum energy of the adjoint source");
|
||||
setAdjSourceEminCmd->SetParameterName("Emin",false);
|
||||
setAdjSourceEminCmd->SetUnitCategory("Energy");
|
||||
setAdjSourceEminCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
setAdjSourceEmaxCmd = new G4UIcmdWithADoubleAndUnit("/adjoint/SetAdjSourceEmax",this);
|
||||
setAdjSourceEmaxCmd->SetGuidance("Set the maximum energy of the adjoint source");
|
||||
setAdjSourceEmaxCmd->SetParameterName("Emax",false);
|
||||
setAdjSourceEmaxCmd->SetUnitCategory("Energy");
|
||||
setAdjSourceEmaxCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
ConsiderParticleAsPrimaryCmd = new G4UIcmdWithAString("/adjoint/ConsiderAsPrimary",this);
|
||||
ConsiderParticleAsPrimaryCmd->SetGuidance("Set the selected particle as primary");
|
||||
ConsiderParticleAsPrimaryCmd->SetParameterName("particle",false);
|
||||
DefineAdjSourceOnAVolumeExtSurfaceCmd = new G4UIcmdWithAString(
|
||||
"/adjoint/DefineAdjSourceOnExtSurfaceOfAVolume", this);
|
||||
DefineAdjSourceOnAVolumeExtSurfaceCmd->SetGuidance(
|
||||
"Set the adjoint source on the external surface of physical volume");
|
||||
DefineAdjSourceOnAVolumeExtSurfaceCmd->SetParameterName("phys_vol_name",
|
||||
false);
|
||||
|
||||
setAdjSourceEminCmd =
|
||||
new G4UIcmdWithADoubleAndUnit("/adjoint/SetAdjSourceEmin", this);
|
||||
setAdjSourceEminCmd->SetGuidance(
|
||||
"Set the minimum energy of the adjoint source");
|
||||
setAdjSourceEminCmd->SetParameterName("Emin", false);
|
||||
setAdjSourceEminCmd->SetUnitCategory("Energy");
|
||||
setAdjSourceEminCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
setAdjSourceEmaxCmd =
|
||||
new G4UIcmdWithADoubleAndUnit("/adjoint/SetAdjSourceEmax", this);
|
||||
setAdjSourceEmaxCmd->SetGuidance(
|
||||
"Set the maximum energy of the adjoint source");
|
||||
setAdjSourceEmaxCmd->SetParameterName("Emax", false);
|
||||
setAdjSourceEmaxCmd->SetUnitCategory("Energy");
|
||||
setAdjSourceEmaxCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
ConsiderParticleAsPrimaryCmd =
|
||||
new G4UIcmdWithAString("/adjoint/ConsiderAsPrimary", this);
|
||||
ConsiderParticleAsPrimaryCmd->SetGuidance(
|
||||
"Set the selected particle as primary");
|
||||
ConsiderParticleAsPrimaryCmd->SetParameterName("particle", false);
|
||||
ConsiderParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
|
||||
|
||||
NeglectParticleAsPrimaryCmd= new G4UIcmdWithAString("/adjoint/NeglectAsPrimary",this);
|
||||
NeglectParticleAsPrimaryCmd->SetGuidance("Remove the selected particle from the list of primaries");
|
||||
NeglectParticleAsPrimaryCmd->SetParameterName("particle",false);
|
||||
NeglectParticleAsPrimaryCmd =
|
||||
new G4UIcmdWithAString("/adjoint/NeglectAsPrimary", this);
|
||||
NeglectParticleAsPrimaryCmd->SetGuidance(
|
||||
"Remove the selected particle from the list of primaries");
|
||||
NeglectParticleAsPrimaryCmd->SetParameterName("particle", false);
|
||||
NeglectParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
|
||||
|
||||
|
||||
setNbOfPrimaryFwdGammasPerEventCmd =
|
||||
new G4UIcmdWithAnInteger("/adjoint/SetNbOfPrimaryFwdGammasPerEvent",this);
|
||||
setNbOfPrimaryFwdGammasPerEventCmd->SetGuidance("Set the nb of primary fwd gamm generated on the adjoint source");
|
||||
setNbOfPrimaryFwdGammasPerEventCmd->SetParameterName("Nb_gammas",false);
|
||||
setNbOfPrimaryFwdGammasPerEventCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
new G4UIcmdWithAnInteger("/adjoint/SetNbOfPrimaryFwdGammasPerEvent", this);
|
||||
setNbOfPrimaryFwdGammasPerEventCmd->SetGuidance(
|
||||
"Set the nb of primary fwd gamm generated on the adjoint source");
|
||||
setNbOfPrimaryFwdGammasPerEventCmd->SetParameterName("Nb_gammas", false);
|
||||
setNbOfPrimaryFwdGammasPerEventCmd->AvailableForStates(G4State_PreInit,
|
||||
G4State_Idle);
|
||||
|
||||
setNbOfPrimaryAdjGammasPerEventCmd =
|
||||
new G4UIcmdWithAnInteger("/adjoint/SetNbOfPrimaryAdjGammasPerEvent",this);
|
||||
setNbOfPrimaryAdjGammasPerEventCmd->SetGuidance("Set the nb of primary fwd gamm generated on the adjoint source");
|
||||
setNbOfPrimaryAdjGammasPerEventCmd->SetParameterName("Nb_gammas",false);
|
||||
setNbOfPrimaryAdjGammasPerEventCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
setNbOfPrimaryAdjElectronsPerEventCmd =
|
||||
new G4UIcmdWithAnInteger("/adjoint/SetNbOfPrimaryAdjElectronsPerEvent",this);
|
||||
setNbOfPrimaryAdjElectronsPerEventCmd->SetGuidance("Set the nb of primary fwd gamm generated on the adjoint source");
|
||||
setNbOfPrimaryAdjElectronsPerEventCmd->SetParameterName("Nb_gammas",false);
|
||||
setNbOfPrimaryAdjElectronsPerEventCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
|
||||
|
||||
|
||||
new G4UIcmdWithAnInteger("/adjoint/SetNbOfPrimaryAdjGammasPerEvent", this);
|
||||
setNbOfPrimaryAdjGammasPerEventCmd->SetGuidance(
|
||||
"Set the nb of primary fwd gamm generated on the adjoint source");
|
||||
setNbOfPrimaryAdjGammasPerEventCmd->SetParameterName("Nb_gammas", false);
|
||||
setNbOfPrimaryAdjGammasPerEventCmd->AvailableForStates(G4State_PreInit,
|
||||
G4State_Idle);
|
||||
|
||||
setNbOfPrimaryAdjElectronsPerEventCmd = new G4UIcmdWithAnInteger(
|
||||
"/adjoint/SetNbOfPrimaryAdjElectronsPerEvent", this);
|
||||
setNbOfPrimaryAdjElectronsPerEventCmd->SetGuidance(
|
||||
"Set the nb of primary fwd gamm generated on the adjoint source");
|
||||
setNbOfPrimaryAdjElectronsPerEventCmd->SetParameterName("Nb_gammas", false);
|
||||
setNbOfPrimaryAdjElectronsPerEventCmd->AvailableForStates(G4State_PreInit,
|
||||
G4State_Idle);
|
||||
}
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
/*
|
||||
#ifdef G4MULTITHREADED
|
||||
G4AdjointSimMessenger::G4AdjointSimMessenger(G4MTAdjointSimManager* pAdjointRunManager)
|
||||
: theAdjointRunManager(0),theMTAdjointRunManager(pAdjointRunManager),DefineSpherExtSourceCmd(0),
|
||||
DefineSpherExtSourceCenteredOnAVolumeCmd(0), DefineExtSourceOnAVolumeExtSurfaceCmd(0),
|
||||
G4AdjointSimMessenger::G4AdjointSimMessenger(G4MTAdjointSimManager*
|
||||
pAdjointRunManager)
|
||||
:
|
||||
theAdjointRunManager(0),theMTAdjointRunManager(pAdjointRunManager),DefineSpherExtSourceCmd(0),
|
||||
DefineSpherExtSourceCenteredOnAVolumeCmd(0),
|
||||
DefineExtSourceOnAVolumeExtSurfaceCmd(0),
|
||||
setExtSourceEMaxCmd(0),DefineSpherAdjSourceCmd(0),DefineSpherAdjSourceCenteredOnAVolumeCmd(0),
|
||||
DefineAdjSourceOnAVolumeExtSurfaceCmd(0),setAdjSourceEminCmd(0),setAdjSourceEmaxCmd(0),
|
||||
ConsiderParticleAsPrimaryCmd(0),NeglectParticleAsPrimaryCmd(0)
|
||||
{
|
||||
AdjointSimDir = new G4UIdirectory("/adjoint/");
|
||||
AdjointSimDir->SetGuidance("Control of the adjoint or reverse monte carlo simulation");
|
||||
AdjointSimDir->SetGuidance("Control of the adjoint or reverse monte carlo
|
||||
simulation");
|
||||
|
||||
|
||||
//Start and adjoint Run
|
||||
@@ -213,14 +247,17 @@ G4AdjointSimMessenger::G4AdjointSimMessenger(G4MTAdjointSimManager* pAdjointRunM
|
||||
beamOnCmd->SetParameter(p1);
|
||||
|
||||
|
||||
ConsiderParticleAsPrimaryCmd = new G4UIcmdWithAString("/adjoint/ConsiderAsPrimary",this);
|
||||
ConsiderParticleAsPrimaryCmd->SetGuidance("Set the selected particle as primary");
|
||||
ConsiderParticleAsPrimaryCmd->SetParameterName("particle",false);
|
||||
ConsiderParticleAsPrimaryCmd = new
|
||||
G4UIcmdWithAString("/adjoint/ConsiderAsPrimary",this);
|
||||
ConsiderParticleAsPrimaryCmd->SetGuidance("Set the selected particle as
|
||||
primary"); ConsiderParticleAsPrimaryCmd->SetParameterName("particle",false);
|
||||
ConsiderParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
|
||||
|
||||
NeglectParticleAsPrimaryCmd= new G4UIcmdWithAString("/adjoint/NeglectAsPrimary",this);
|
||||
NeglectParticleAsPrimaryCmd->SetGuidance("Remove the selected particle from the lits of primaries");
|
||||
NeglectParticleAsPrimaryCmd->SetParameterName("particle",false);
|
||||
NeglectParticleAsPrimaryCmd= new
|
||||
G4UIcmdWithAString("/adjoint/NeglectAsPrimary",this);
|
||||
NeglectParticleAsPrimaryCmd->SetGuidance("Remove the selected particle from
|
||||
the lits of primaries");
|
||||
NeglectParticleAsPrimaryCmd->SetParameterName("particle",false);
|
||||
NeglectParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
|
||||
|
||||
|
||||
@@ -233,118 +270,135 @@ G4AdjointSimMessenger::G4AdjointSimMessenger(G4MTAdjointSimManager* pAdjointRunM
|
||||
|
||||
G4AdjointSimMessenger::~G4AdjointSimMessenger()
|
||||
{
|
||||
if (beamOnCmd) delete beamOnCmd;
|
||||
if(beamOnCmd)
|
||||
delete beamOnCmd;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
|
||||
void G4AdjointSimMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
|
||||
void G4AdjointSimMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
{
|
||||
if (!command) return;
|
||||
if( command==beamOnCmd )
|
||||
if(!command)
|
||||
return;
|
||||
if(command == beamOnCmd)
|
||||
{
|
||||
G4int nev;
|
||||
const char* nv = (const char*)newValue;
|
||||
const char* nv = (const char*) newValue;
|
||||
std::istringstream is(nv);
|
||||
is >> nev ;
|
||||
if (G4RunManager::GetRunManager()->GetRunManagerType() == G4RunManager::sequentialRM) theAdjointRunManager->RunAdjointSimulation(nev);
|
||||
/*
|
||||
#ifdef G4MULTITHREADED
|
||||
else if (theMTAdjointRunManager) theMTAdjointRunManager->RunAdjointSimulation(nev);
|
||||
else if (theAdjointRunManager) theAdjointRunManager->SwitchToAdjointSimulationMode();
|
||||
#endif
|
||||
*/
|
||||
//G4cout<<"G4AdjointSimMessenger::SetNewValue BeamOnCmd out"<<std::endl;
|
||||
is >> nev;
|
||||
if(G4RunManager::GetRunManager()->GetRunManagerType() ==
|
||||
G4RunManager::sequentialRM)
|
||||
theAdjointRunManager->RunAdjointSimulation(nev);
|
||||
/*
|
||||
#ifdef G4MULTITHREADED
|
||||
else if (theMTAdjointRunManager)
|
||||
theMTAdjointRunManager->RunAdjointSimulation(nev); else if
|
||||
(theAdjointRunManager)
|
||||
theAdjointRunManager->SwitchToAdjointSimulationMode(); #endif
|
||||
*/
|
||||
// G4cout<<"G4AdjointSimMessenger::SetNewValue BeamOnCmd out"<<std::endl;
|
||||
}
|
||||
else if ( command==ConsiderParticleAsPrimaryCmd){
|
||||
theAdjointRunManager->ConsiderParticleAsPrimary(newValue);
|
||||
else if(command == ConsiderParticleAsPrimaryCmd)
|
||||
{
|
||||
theAdjointRunManager->ConsiderParticleAsPrimary(newValue);
|
||||
}
|
||||
else if ( command==NeglectParticleAsPrimaryCmd){
|
||||
theAdjointRunManager->NeglectParticleAsPrimary(newValue);
|
||||
else if(command == NeglectParticleAsPrimaryCmd)
|
||||
{
|
||||
theAdjointRunManager->NeglectParticleAsPrimary(newValue);
|
||||
}
|
||||
/*
|
||||
#ifdef G4MULTITHREADED
|
||||
if (G4RunManager::GetRunManager()->GetRunManagerType() == G4RunManager::masterRM) return;
|
||||
#endif
|
||||
*/
|
||||
if ( command==DefineSpherExtSourceCmd){
|
||||
|
||||
G4double x,y,z,r;
|
||||
/*
|
||||
#ifdef G4MULTITHREADED
|
||||
if (G4RunManager::GetRunManager()->GetRunManagerType() ==
|
||||
G4RunManager::masterRM) return; #endif
|
||||
*/
|
||||
if(command == DefineSpherExtSourceCmd)
|
||||
{
|
||||
G4double x, y, z, r;
|
||||
G4String unit;
|
||||
const char* nv = (const char*)newValue;
|
||||
const char* nv = (const char*) newValue;
|
||||
std::istringstream is(nv);
|
||||
is >> x>>y>>z>>r>>unit;
|
||||
|
||||
x*=G4UnitDefinition::GetValueOf(unit);
|
||||
y*=G4UnitDefinition::GetValueOf(unit);
|
||||
z*=G4UnitDefinition::GetValueOf(unit);
|
||||
r*=G4UnitDefinition::GetValueOf(unit);
|
||||
theAdjointRunManager->DefineSphericalExtSource(r,G4ThreeVector(x,y,z));
|
||||
is >> x >> y >> z >> r >> unit;
|
||||
|
||||
x *= G4UnitDefinition::GetValueOf(unit);
|
||||
y *= G4UnitDefinition::GetValueOf(unit);
|
||||
z *= G4UnitDefinition::GetValueOf(unit);
|
||||
r *= G4UnitDefinition::GetValueOf(unit);
|
||||
theAdjointRunManager->DefineSphericalExtSource(r, G4ThreeVector(x, y, z));
|
||||
}
|
||||
else if ( command==DefineSpherExtSourceCenteredOnAVolumeCmd){
|
||||
|
||||
else if(command == DefineSpherExtSourceCenteredOnAVolumeCmd)
|
||||
{
|
||||
G4double r;
|
||||
G4String vol_name, unit;
|
||||
const char* nv = (const char*)newValue;
|
||||
const char* nv = (const char*) newValue;
|
||||
std::istringstream is(nv);
|
||||
is >>vol_name>>r>>unit;
|
||||
r*=G4UnitDefinition::GetValueOf(unit);
|
||||
theAdjointRunManager->DefineSphericalExtSourceWithCentreAtTheCentreOfAVolume(r,vol_name);
|
||||
}
|
||||
else if ( command==DefineExtSourceOnAVolumeExtSurfaceCmd){
|
||||
is >> vol_name >> r >> unit;
|
||||
r *= G4UnitDefinition::GetValueOf(unit);
|
||||
theAdjointRunManager
|
||||
->DefineSphericalExtSourceWithCentreAtTheCentreOfAVolume(r, vol_name);
|
||||
}
|
||||
else if(command == DefineExtSourceOnAVolumeExtSurfaceCmd)
|
||||
{
|
||||
theAdjointRunManager->DefineExtSourceOnTheExtSurfaceOfAVolume(newValue);
|
||||
}
|
||||
else if ( command== setExtSourceEMaxCmd){
|
||||
|
||||
theAdjointRunManager->SetExtSourceEmax(setExtSourceEMaxCmd->GetNewDoubleValue(newValue));
|
||||
else if(command == setExtSourceEMaxCmd)
|
||||
{
|
||||
theAdjointRunManager->SetExtSourceEmax(
|
||||
setExtSourceEMaxCmd->GetNewDoubleValue(newValue));
|
||||
}
|
||||
else if ( command==DefineSpherAdjSourceCmd){
|
||||
|
||||
G4double x,y,z,r;
|
||||
else if(command == DefineSpherAdjSourceCmd)
|
||||
{
|
||||
G4double x, y, z, r;
|
||||
G4String unit;
|
||||
const char* nv = (const char*)newValue;
|
||||
const char* nv = (const char*) newValue;
|
||||
std::istringstream is(nv);
|
||||
is >> x>>y>>z>>r>>unit;
|
||||
|
||||
x*=G4UnitDefinition::GetValueOf(unit);
|
||||
y*=G4UnitDefinition::GetValueOf(unit);
|
||||
z*=G4UnitDefinition::GetValueOf(unit);
|
||||
r*=G4UnitDefinition::GetValueOf(unit);
|
||||
theAdjointRunManager->DefineSphericalAdjointSource(r,G4ThreeVector(x,y,z));
|
||||
is >> x >> y >> z >> r >> unit;
|
||||
|
||||
x *= G4UnitDefinition::GetValueOf(unit);
|
||||
y *= G4UnitDefinition::GetValueOf(unit);
|
||||
z *= G4UnitDefinition::GetValueOf(unit);
|
||||
r *= G4UnitDefinition::GetValueOf(unit);
|
||||
theAdjointRunManager->DefineSphericalAdjointSource(r,
|
||||
G4ThreeVector(x, y, z));
|
||||
}
|
||||
else if ( command==DefineSpherAdjSourceCenteredOnAVolumeCmd){
|
||||
|
||||
else if(command == DefineSpherAdjSourceCenteredOnAVolumeCmd)
|
||||
{
|
||||
G4double r;
|
||||
G4String vol_name, unit;
|
||||
const char* nv = (const char*)newValue;
|
||||
const char* nv = (const char*) newValue;
|
||||
std::istringstream is(nv);
|
||||
is >>vol_name>>r>>unit;
|
||||
r*=G4UnitDefinition::GetValueOf(unit);
|
||||
theAdjointRunManager->DefineSphericalAdjointSourceWithCentreAtTheCentreOfAVolume(r,vol_name);
|
||||
is >> vol_name >> r >> unit;
|
||||
r *= G4UnitDefinition::GetValueOf(unit);
|
||||
theAdjointRunManager
|
||||
->DefineSphericalAdjointSourceWithCentreAtTheCentreOfAVolume(r, vol_name);
|
||||
}
|
||||
else if ( command==DefineAdjSourceOnAVolumeExtSurfaceCmd){
|
||||
|
||||
else if(command == DefineAdjSourceOnAVolumeExtSurfaceCmd)
|
||||
{
|
||||
theAdjointRunManager->DefineAdjointSourceOnTheExtSurfaceOfAVolume(newValue);
|
||||
}
|
||||
else if ( command== setAdjSourceEminCmd){
|
||||
|
||||
theAdjointRunManager->SetAdjointSourceEmin(setAdjSourceEminCmd->GetNewDoubleValue(newValue));
|
||||
else if(command == setAdjSourceEminCmd)
|
||||
{
|
||||
theAdjointRunManager->SetAdjointSourceEmin(
|
||||
setAdjSourceEminCmd->GetNewDoubleValue(newValue));
|
||||
}
|
||||
else if ( command== setAdjSourceEmaxCmd){
|
||||
|
||||
theAdjointRunManager->SetAdjointSourceEmax(setAdjSourceEmaxCmd->GetNewDoubleValue(newValue));
|
||||
else if(command == setAdjSourceEmaxCmd)
|
||||
{
|
||||
theAdjointRunManager->SetAdjointSourceEmax(
|
||||
setAdjSourceEmaxCmd->GetNewDoubleValue(newValue));
|
||||
}
|
||||
else if ( command== setNbOfPrimaryFwdGammasPerEventCmd){
|
||||
theAdjointRunManager->SetNbOfPrimaryFwdGammasPerEvent(setNbOfPrimaryFwdGammasPerEventCmd->GetNewIntValue(newValue));
|
||||
else if(command == setNbOfPrimaryFwdGammasPerEventCmd)
|
||||
{
|
||||
theAdjointRunManager->SetNbOfPrimaryFwdGammasPerEvent(
|
||||
setNbOfPrimaryFwdGammasPerEventCmd->GetNewIntValue(newValue));
|
||||
}
|
||||
else if ( command== setNbOfPrimaryAdjGammasPerEventCmd){
|
||||
theAdjointRunManager->SetNbAdjointPrimaryGammasPerEvent(setNbOfPrimaryAdjGammasPerEventCmd->GetNewIntValue(newValue));
|
||||
else if(command == setNbOfPrimaryAdjGammasPerEventCmd)
|
||||
{
|
||||
theAdjointRunManager->SetNbAdjointPrimaryGammasPerEvent(
|
||||
setNbOfPrimaryAdjGammasPerEventCmd->GetNewIntValue(newValue));
|
||||
}
|
||||
else if ( command== setNbOfPrimaryAdjElectronsPerEventCmd){
|
||||
theAdjointRunManager->SetNbAdjointPrimaryElectronsPerEvent(setNbOfPrimaryAdjElectronsPerEventCmd->GetNewIntValue(newValue));
|
||||
else if(command == setNbOfPrimaryAdjElectronsPerEventCmd)
|
||||
{
|
||||
theAdjointRunManager->SetNbAdjointPrimaryElectronsPerEvent(
|
||||
setNbOfPrimaryAdjElectronsPerEventCmd->GetNewIntValue(newValue));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -25,208 +25,240 @@
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// GEANT 4 class implementation file
|
||||
//
|
||||
// ---------------- G4ExceptionHandler ----------------
|
||||
// by Makoto Asai (August 2002)
|
||||
// ------------------------------------------------------------
|
||||
|
||||
#include "G4ExceptionHandler.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4RunManager.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4String.hh"
|
||||
#include "G4ios.hh"
|
||||
#include <stdlib.h>
|
||||
#include "G4String.hh"
|
||||
|
||||
G4ExceptionHandler::G4ExceptionHandler()
|
||||
G4ExceptionHandler::G4ExceptionHandler() {}
|
||||
|
||||
G4ExceptionHandler::~G4ExceptionHandler() {}
|
||||
|
||||
G4ExceptionHandler::G4ExceptionHandler(const G4ExceptionHandler&)
|
||||
: G4VExceptionHandler()
|
||||
{}
|
||||
|
||||
G4ExceptionHandler& G4ExceptionHandler::operator=(const G4ExceptionHandler&)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4ExceptionHandler::~G4ExceptionHandler()
|
||||
G4bool G4ExceptionHandler::operator==(const G4ExceptionHandler& right) const
|
||||
{
|
||||
return (this == &right);
|
||||
}
|
||||
|
||||
G4ExceptionHandler::G4ExceptionHandler(const G4ExceptionHandler &)
|
||||
:G4VExceptionHandler()
|
||||
G4bool G4ExceptionHandler::operator!=(const G4ExceptionHandler& right) const
|
||||
{
|
||||
}
|
||||
|
||||
G4ExceptionHandler& G4ExceptionHandler::operator=(const G4ExceptionHandler &)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
G4bool G4ExceptionHandler::operator==(const G4ExceptionHandler &right) const
|
||||
{
|
||||
return (this == &right);
|
||||
}
|
||||
|
||||
G4bool G4ExceptionHandler::operator!=(const G4ExceptionHandler &right) const
|
||||
{
|
||||
return (this != &right);
|
||||
return (this != &right);
|
||||
}
|
||||
|
||||
G4bool G4ExceptionHandler::Notify(const char* originOfException,
|
||||
const char* exceptionCode,
|
||||
G4ExceptionSeverity severity,
|
||||
const char* description)
|
||||
const char* exceptionCode,
|
||||
G4ExceptionSeverity severity,
|
||||
const char* description)
|
||||
{
|
||||
static const G4String es_banner
|
||||
= "\n-------- EEEE ------- G4Exception-START -------- EEEE -------\n";
|
||||
static const G4String ee_banner
|
||||
= "\n-------- EEEE -------- G4Exception-END --------- EEEE -------\n";
|
||||
static const G4String ws_banner
|
||||
= "\n-------- WWWW ------- G4Exception-START -------- WWWW -------\n";
|
||||
static const G4String we_banner
|
||||
= "\n-------- WWWW -------- G4Exception-END --------- WWWW -------\n";
|
||||
static const G4String es_banner =
|
||||
"\n-------- EEEE ------- G4Exception-START -------- EEEE -------\n";
|
||||
static const G4String ee_banner =
|
||||
"\n-------- EEEE -------- G4Exception-END --------- EEEE -------\n";
|
||||
static const G4String ws_banner =
|
||||
"\n-------- WWWW ------- G4Exception-START -------- WWWW -------\n";
|
||||
static const G4String we_banner =
|
||||
"\n-------- WWWW -------- G4Exception-END --------- WWWW -------\n";
|
||||
std::ostringstream message;
|
||||
message << "*** G4Exception : " << exceptionCode << G4endl
|
||||
<< " issued by : " << originOfException << G4endl
|
||||
<< description << G4endl;
|
||||
<< " issued by : " << originOfException << G4endl << description
|
||||
<< G4endl;
|
||||
G4bool abortionForCoreDump = false;
|
||||
G4ApplicationState aps = G4StateManager::GetStateManager()->GetCurrentState();
|
||||
switch(severity)
|
||||
{
|
||||
case FatalException:
|
||||
G4cerr << es_banner << message.str() << "*** Fatal Exception *** core dump ***" << G4endl;
|
||||
DumpTrackInfo();
|
||||
G4cerr << ee_banner << G4endl;
|
||||
abortionForCoreDump = true;
|
||||
break;
|
||||
case FatalErrorInArgument:
|
||||
G4cerr << es_banner << message.str() << "*** Fatal Error In Argument *** core dump ***" << G4endl;
|
||||
DumpTrackInfo();
|
||||
G4cerr << ee_banner << G4endl;
|
||||
abortionForCoreDump = true;
|
||||
break;
|
||||
case RunMustBeAborted:
|
||||
if(aps==G4State_GeomClosed || aps==G4State_EventProc)
|
||||
{
|
||||
G4cerr << es_banner << message.str() << "*** Run Must Be Aborted ***" << G4endl;
|
||||
case FatalException:
|
||||
G4cerr << es_banner << message.str()
|
||||
<< "*** Fatal Exception *** core dump ***" << G4endl;
|
||||
DumpTrackInfo();
|
||||
G4cerr << ee_banner << G4endl;
|
||||
G4RunManager::GetRunManager()->AbortRun(false);
|
||||
}
|
||||
abortionForCoreDump = false;
|
||||
break;
|
||||
case EventMustBeAborted:
|
||||
if(aps==G4State_EventProc)
|
||||
{
|
||||
G4cerr << es_banner << message.str() << "*** Event Must Be Aborted ***" << G4endl;
|
||||
abortionForCoreDump = true;
|
||||
break;
|
||||
case FatalErrorInArgument:
|
||||
G4cerr << es_banner << message.str()
|
||||
<< "*** Fatal Error In Argument *** core dump ***" << G4endl;
|
||||
DumpTrackInfo();
|
||||
G4cerr << ee_banner << G4endl;
|
||||
G4RunManager::GetRunManager()->AbortEvent();
|
||||
}
|
||||
abortionForCoreDump = false;
|
||||
break;
|
||||
default:
|
||||
G4cout << ws_banner << message.str() << "*** This is just a warning message. ***"
|
||||
<< we_banner << G4endl;
|
||||
abortionForCoreDump = false;
|
||||
break;
|
||||
abortionForCoreDump = true;
|
||||
break;
|
||||
case RunMustBeAborted:
|
||||
if(aps == G4State_GeomClosed || aps == G4State_EventProc)
|
||||
{
|
||||
G4cerr << es_banner << message.str() << "*** Run Must Be Aborted ***"
|
||||
<< G4endl;
|
||||
DumpTrackInfo();
|
||||
G4cerr << ee_banner << G4endl;
|
||||
G4RunManager::GetRunManager()->AbortRun(false);
|
||||
}
|
||||
abortionForCoreDump = false;
|
||||
break;
|
||||
case EventMustBeAborted:
|
||||
if(aps == G4State_EventProc)
|
||||
{
|
||||
G4cerr << es_banner << message.str() << "*** Event Must Be Aborted ***"
|
||||
<< G4endl;
|
||||
DumpTrackInfo();
|
||||
G4cerr << ee_banner << G4endl;
|
||||
G4RunManager::GetRunManager()->AbortEvent();
|
||||
}
|
||||
abortionForCoreDump = false;
|
||||
break;
|
||||
default:
|
||||
G4cout << ws_banner << message.str()
|
||||
<< "*** This is just a warning message. ***" << we_banner
|
||||
<< G4endl;
|
||||
abortionForCoreDump = false;
|
||||
break;
|
||||
}
|
||||
return abortionForCoreDump;
|
||||
}
|
||||
|
||||
#include "G4RunManagerKernel.hh"
|
||||
#include "G4EventManager.hh"
|
||||
#include "G4TrackingManager.hh"
|
||||
#include "G4SteppingManager.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4RunManagerKernel.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4StepPoint.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4VProcess.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4SteppingManager.hh"
|
||||
#include "G4Track.hh"
|
||||
#include "G4TrackingManager.hh"
|
||||
#include "G4UnitsTable.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4VProcess.hh"
|
||||
|
||||
void G4ExceptionHandler::DumpTrackInfo()
|
||||
{
|
||||
G4ApplicationState aps = G4StateManager::GetStateManager()->GetCurrentState();
|
||||
G4SteppingManager* steppingMgr = G4RunManagerKernel::GetRunManagerKernel()
|
||||
->GetTrackingManager()->GetSteppingManager();
|
||||
->GetTrackingManager()
|
||||
->GetSteppingManager();
|
||||
const G4Track* theTrack = steppingMgr->GetfTrack();
|
||||
const G4Step* theStep = steppingMgr->GetfStep();
|
||||
const G4Step* theStep = steppingMgr->GetfStep();
|
||||
|
||||
if(aps!=G4State_EventProc || !theTrack)
|
||||
{
|
||||
G4cerr << " **** Track information is not available at this moment" << G4endl;
|
||||
if(aps != G4State_EventProc || !theTrack)
|
||||
{
|
||||
G4cerr << " **** Track information is not available at this moment"
|
||||
<< G4endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cerr << "G4Track (" << theTrack << ") - track ID = " << theTrack->GetTrackID()
|
||||
<< ", parent ID = " << theTrack->GetParentID() << G4endl;
|
||||
G4cerr << " Particle type : " << theTrack->GetParticleDefinition()->GetParticleName();
|
||||
G4cerr << "G4Track (" << theTrack
|
||||
<< ") - track ID = " << theTrack->GetTrackID()
|
||||
<< ", parent ID = " << theTrack->GetParentID() << G4endl;
|
||||
G4cerr << " Particle type : "
|
||||
<< theTrack->GetParticleDefinition()->GetParticleName();
|
||||
if(theTrack->GetCreatorProcess())
|
||||
{ G4cerr
|
||||
<< " - creator process : " << theTrack->GetCreatorProcess()->GetProcessName()
|
||||
<< ", creator model : " << theTrack->GetCreatorModelName() << G4endl;
|
||||
{
|
||||
G4cerr << " - creator process : "
|
||||
<< theTrack->GetCreatorProcess()->GetProcessName()
|
||||
<< ", creator model : " << theTrack->GetCreatorModelName()
|
||||
<< G4endl;
|
||||
}
|
||||
else
|
||||
{ G4cerr << " - creator process : not available" << G4endl; }
|
||||
G4cerr << " Kinetic energy : " << G4BestUnit(theTrack->GetKineticEnergy(),"Energy")
|
||||
<< " - Momentum direction : " << theTrack->GetMomentumDirection() << G4endl;
|
||||
{
|
||||
G4cerr << " - creator process : not available" << G4endl;
|
||||
}
|
||||
G4cerr << " Kinetic energy : "
|
||||
<< G4BestUnit(theTrack->GetKineticEnergy(), "Energy")
|
||||
<< " - Momentum direction : " << theTrack->GetMomentumDirection()
|
||||
<< G4endl;
|
||||
}
|
||||
|
||||
if(aps!=G4State_EventProc || !theStep)
|
||||
{
|
||||
G4cerr << " **** Step information is not available at this moment" << G4endl;
|
||||
if(aps != G4State_EventProc || !theStep)
|
||||
{
|
||||
G4cerr << " **** Step information is not available at this moment"
|
||||
<< G4endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cerr << " Step length : " << G4BestUnit(theStep->GetStepLength(),"Length")
|
||||
<< " - total energy deposit : " << G4BestUnit(theStep->GetTotalEnergyDeposit(),"Energy")
|
||||
<< G4endl;
|
||||
G4cerr << " Step length : "
|
||||
<< G4BestUnit(theStep->GetStepLength(), "Length")
|
||||
<< " - total energy deposit : "
|
||||
<< G4BestUnit(theStep->GetTotalEnergyDeposit(), "Energy") << G4endl;
|
||||
G4cerr << " Pre-step point : " << theStep->GetPreStepPoint()->GetPosition();
|
||||
G4cerr << " - Physical volume : ";
|
||||
if(theStep->GetPreStepPoint()->GetPhysicalVolume())
|
||||
{
|
||||
G4cerr << theStep->GetPreStepPoint()->GetPhysicalVolume()->GetName();
|
||||
if(theStep->GetPreStepPoint()->GetMaterial())
|
||||
{ G4cerr << " (" << theStep->GetPreStepPoint()->GetMaterial()->GetName() << ")"; }
|
||||
{
|
||||
G4cerr << " (" << theStep->GetPreStepPoint()->GetMaterial()->GetName()
|
||||
<< ")";
|
||||
}
|
||||
else
|
||||
{ G4cerr << " (material not available)"; }
|
||||
{
|
||||
G4cerr << " (material not available)";
|
||||
}
|
||||
}
|
||||
else
|
||||
{ G4cerr << "not available"; }
|
||||
{
|
||||
G4cerr << "not available";
|
||||
}
|
||||
G4cerr << G4endl;
|
||||
if(theStep->GetPreStepPoint()->GetProcessDefinedStep())
|
||||
{
|
||||
G4cerr << " - defined by : "
|
||||
G4cerr
|
||||
<< " - defined by : "
|
||||
<< theStep->GetPreStepPoint()->GetProcessDefinedStep()->GetProcessName()
|
||||
<< " - step status : " << theStep->GetPreStepPoint()->GetStepStatus() << G4endl;
|
||||
<< " - step status : " << theStep->GetPreStepPoint()->GetStepStatus()
|
||||
<< G4endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cerr << " - defined by : not available" << G4endl;
|
||||
}
|
||||
G4cerr << " Post-step point : " << theStep->GetPostStepPoint()->GetPosition();
|
||||
G4cerr << " Post-step point : "
|
||||
<< theStep->GetPostStepPoint()->GetPosition();
|
||||
G4cerr << " - Physical volume : ";
|
||||
if(theStep->GetPostStepPoint()->GetPhysicalVolume())
|
||||
{
|
||||
G4cerr << theStep->GetPostStepPoint()->GetPhysicalVolume()->GetName();
|
||||
if(theStep->GetPostStepPoint()->GetMaterial())
|
||||
{ G4cerr << " (" << theStep->GetPostStepPoint()->GetMaterial()->GetName() << ")"; }
|
||||
{
|
||||
G4cerr << " (" << theStep->GetPostStepPoint()->GetMaterial()->GetName()
|
||||
<< ")";
|
||||
}
|
||||
else
|
||||
{ G4cerr << " (material not available)"; }
|
||||
{
|
||||
G4cerr << " (material not available)";
|
||||
}
|
||||
}
|
||||
else
|
||||
{ G4cerr << "not available"; }
|
||||
{
|
||||
G4cerr << "not available";
|
||||
}
|
||||
G4cerr << G4endl;
|
||||
if(theStep->GetPostStepPoint()->GetProcessDefinedStep())
|
||||
{
|
||||
G4cerr << " - defined by : "
|
||||
<< theStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName()
|
||||
<< " - step status : " << theStep->GetPostStepPoint()->GetStepStatus() << G4endl;
|
||||
<< theStep->GetPostStepPoint()
|
||||
->GetProcessDefinedStep()
|
||||
->GetProcessName()
|
||||
<< " - step status : "
|
||||
<< theStep->GetPostStepPoint()->GetStepStatus() << G4endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
G4cerr << " - defined by : not available" << G4endl;
|
||||
}
|
||||
G4cerr << " *** Note: Step information might not be properly updated." << G4endl;
|
||||
G4cerr << " *** Note: Step information might not be properly updated."
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,43 +28,39 @@
|
||||
//
|
||||
//
|
||||
|
||||
|
||||
#include "G4MSSteppingAction.hh"
|
||||
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4Region.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4Region.hh"
|
||||
#include "G4Material.hh"
|
||||
|
||||
G4MSSteppingAction::G4MSSteppingAction()
|
||||
{
|
||||
Initialize(false,0);
|
||||
}
|
||||
G4MSSteppingAction::G4MSSteppingAction() { Initialize(false, 0); }
|
||||
|
||||
G4MSSteppingAction::~G4MSSteppingAction()
|
||||
{;}
|
||||
|
||||
void G4MSSteppingAction::Initialize(G4bool rSens,G4Region* reg)
|
||||
G4MSSteppingAction::~G4MSSteppingAction() { ; }
|
||||
|
||||
void G4MSSteppingAction::Initialize(G4bool rSens, G4Region* reg)
|
||||
{
|
||||
regionSensitive = rSens;
|
||||
theRegion = reg;
|
||||
length = 0.;
|
||||
x0 = 0.;
|
||||
lambda = 0.;
|
||||
theRegion = reg;
|
||||
length = 0.;
|
||||
x0 = 0.;
|
||||
lambda = 0.;
|
||||
}
|
||||
|
||||
|
||||
void G4MSSteppingAction::UserSteppingAction(const G4Step* aStep)
|
||||
{
|
||||
G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
|
||||
G4Region* region = preStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetRegion();
|
||||
G4Region* region =
|
||||
preStepPoint->GetPhysicalVolume()->GetLogicalVolume()->GetRegion();
|
||||
|
||||
if(regionSensitive && (region!=theRegion)) return;
|
||||
if(regionSensitive && (region != theRegion))
|
||||
return;
|
||||
|
||||
G4double stlen = aStep->GetStepLength();
|
||||
G4double stlen = aStep->GetStepLength();
|
||||
G4Material* material = preStepPoint->GetMaterial();
|
||||
length += stlen;
|
||||
x0 += stlen/(material->GetRadlen());
|
||||
lambda += stlen/(material->GetNuclearInterLength());
|
||||
x0 += stlen / (material->GetRadlen());
|
||||
lambda += stlen / (material->GetNuclearInterLength());
|
||||
}
|
||||
|
||||
|
||||
+405
-317
@@ -26,181 +26,222 @@
|
||||
//
|
||||
|
||||
#include "G4MTRunManager.hh"
|
||||
#include "G4AutoLock.hh"
|
||||
#include "G4MTRunManagerKernel.hh"
|
||||
#include "G4Timer.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4ProductionCutsTable.hh"
|
||||
#include "G4Run.hh"
|
||||
#include "G4ScoringManager.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4TiMemory.hh"
|
||||
#include "G4Timer.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4VUserActionInitialization.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4UserRunAction.hh"
|
||||
#include "G4UserWorkerInitialization.hh"
|
||||
#include "G4UserWorkerThreadInitialization.hh"
|
||||
#include "G4WorkerThread.hh"
|
||||
#include "G4Run.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4AutoLock.hh"
|
||||
#include "G4VUserActionInitialization.hh"
|
||||
#include "G4WorkerRunManager.hh"
|
||||
#include "G4UserRunAction.hh"
|
||||
#include "G4ProductionCutsTable.hh"
|
||||
#include "G4Timer.hh"
|
||||
#include "G4TiMemory.hh"
|
||||
#include "G4WorkerThread.hh"
|
||||
|
||||
G4ScoringManager* G4MTRunManager::masterScM = 0;
|
||||
G4MTRunManager::masterWorlds_t G4MTRunManager::masterWorlds = G4MTRunManager::masterWorlds_t();
|
||||
G4MTRunManager* G4MTRunManager::fMasterRM = 0;
|
||||
G4MTRunManager::masterWorlds_t G4MTRunManager::masterWorlds =
|
||||
G4MTRunManager::masterWorlds_t();
|
||||
G4MTRunManager* G4MTRunManager::fMasterRM = 0;
|
||||
G4int G4MTRunManager::seedOncePerCommunication = 0;
|
||||
G4ThreadId G4MTRunManager::masterThreadId = G4ThisThread::get_id();
|
||||
|
||||
namespace {
|
||||
G4Mutex cmdHandlingMutex = G4MUTEX_INITIALIZER;
|
||||
G4Mutex scorerMergerMutex = G4MUTEX_INITIALIZER;
|
||||
G4Mutex runMergerMutex = G4MUTEX_INITIALIZER;
|
||||
G4Mutex setUpEventMutex = G4MUTEX_INITIALIZER;
|
||||
}
|
||||
namespace
|
||||
{
|
||||
G4Mutex cmdHandlingMutex = G4MUTEX_INITIALIZER;
|
||||
G4Mutex scorerMergerMutex = G4MUTEX_INITIALIZER;
|
||||
G4Mutex runMergerMutex = G4MUTEX_INITIALIZER;
|
||||
G4Mutex setUpEventMutex = G4MUTEX_INITIALIZER;
|
||||
} // namespace
|
||||
|
||||
G4MTRunManager* G4MTRunManager::GetMasterRunManager()
|
||||
{
|
||||
////////#ifdef G4MULTITHREADED
|
||||
return fMasterRM;
|
||||
////////#else
|
||||
//////// return G4RunManager::GetRunManager();
|
||||
////////#endif
|
||||
////////#ifdef G4MULTITHREADED
|
||||
return fMasterRM;
|
||||
////////#else
|
||||
//////// return G4RunManager::GetRunManager();
|
||||
////////#endif
|
||||
}
|
||||
|
||||
G4RunManagerKernel* G4MTRunManager::GetMasterRunManagerKernel()
|
||||
{
|
||||
return fMasterRM->kernel;
|
||||
return fMasterRM->kernel;
|
||||
}
|
||||
|
||||
G4MTRunManagerKernel* G4MTRunManager::GetMTMasterRunManagerKernel()
|
||||
{
|
||||
return fMasterRM->MTkernel;
|
||||
return fMasterRM->MTkernel;
|
||||
}
|
||||
G4ScoringManager* G4MTRunManager::GetMasterScoringManager()
|
||||
{
|
||||
return masterScM;
|
||||
}
|
||||
|
||||
G4MTRunManager::G4MTRunManager() : G4RunManager(masterRM),
|
||||
nworkers(2),forcedNwokers(-1),pinAffinity(0),
|
||||
masterRNGEngine(0),
|
||||
nextActionRequest(WorkerActionRequest::UNDEFINED),
|
||||
eventModuloDef(0),eventModulo(1),
|
||||
nSeedsUsed(0),nSeedsFilled(0),
|
||||
nSeedsMax(10000),nSeedsPerEvent(2)
|
||||
G4MTRunManager::masterWorlds_t& G4MTRunManager::GetMasterWorlds()
|
||||
{
|
||||
if ( fMasterRM )
|
||||
{
|
||||
G4Exception("G4MTRunManager::G4MTRunManager", "Run0110",FatalException,
|
||||
"Another instance of a G4MTRunManager already exists.");
|
||||
}
|
||||
fMasterRM = this;
|
||||
MTkernel = static_cast<G4MTRunManagerKernel*>(kernel);
|
||||
return masterWorlds;
|
||||
}
|
||||
void G4MTRunManager::addWorld(G4int counter, G4VPhysicalVolume* w)
|
||||
{
|
||||
masterWorlds.insert(std::make_pair(counter, w));
|
||||
}
|
||||
G4ThreadId G4MTRunManager::GetMasterThreadId() {
|
||||
return masterThreadId;
|
||||
}
|
||||
G4int G4MTRunManager::SeedOncePerCommunication()
|
||||
{
|
||||
return seedOncePerCommunication;
|
||||
}
|
||||
void G4MTRunManager::SetSeedOncePerCommunication(G4int val)
|
||||
{
|
||||
seedOncePerCommunication = val;
|
||||
}
|
||||
|
||||
G4MTRunManager::G4MTRunManager()
|
||||
: G4RunManager(masterRM)
|
||||
, nworkers(2)
|
||||
, forcedNwokers(-1)
|
||||
, pinAffinity(0)
|
||||
, masterRNGEngine(0)
|
||||
, nextActionRequest(WorkerActionRequest::UNDEFINED)
|
||||
, eventModuloDef(0)
|
||||
, eventModulo(1)
|
||||
, nSeedsUsed(0)
|
||||
, nSeedsFilled(0)
|
||||
, nSeedsMax(10000)
|
||||
, nSeedsPerEvent(2)
|
||||
{
|
||||
if(fMasterRM)
|
||||
{
|
||||
G4Exception("G4MTRunManager::G4MTRunManager", "Run0110", FatalException,
|
||||
"Another instance of a G4MTRunManager already exists.");
|
||||
}
|
||||
fMasterRM = this;
|
||||
masterThreadId = G4ThisThread::get_id();
|
||||
MTkernel = static_cast<G4MTRunManagerKernel*>(kernel);
|
||||
#ifndef G4MULTITHREADED
|
||||
G4ExceptionDescription msg;
|
||||
msg << "Geant4 code is compiled without multi-threading support"
|
||||
<< "(-DG4MULTITHREADED is set to off).\n";
|
||||
msg << "G4MTRunManager can only be used in multi-threaded applications.";
|
||||
G4Exception("G4MTRunManager::G4MTRunManager","Run0111",FatalException,msg);
|
||||
G4ExceptionDescription msg;
|
||||
msg << "Geant4 code is compiled without multi-threading support"
|
||||
<< "(-DG4MULTITHREADED is set to off).\n";
|
||||
msg << "G4MTRunManager can only be used in multi-threaded applications.";
|
||||
G4Exception("G4MTRunManager::G4MTRunManager", "Run0111", FatalException, msg);
|
||||
#endif
|
||||
|
||||
G4int numberOfStaticAllocators = kernel->GetNumberOfStaticAllocators();
|
||||
if(numberOfStaticAllocators>0)
|
||||
G4int numberOfStaticAllocators = kernel->GetNumberOfStaticAllocators();
|
||||
if(numberOfStaticAllocators > 0)
|
||||
{
|
||||
G4ExceptionDescription msg1;
|
||||
msg1 << "There are " << numberOfStaticAllocators
|
||||
<< " static G4Allocator objects detected.\n"
|
||||
<< "In multi-threaded mode, all G4Allocator objects must be dynamicly "
|
||||
"instantiated.";
|
||||
G4Exception("G4MTRunManager::G4MTRunManager", "Run1035", FatalException,
|
||||
msg1);
|
||||
}
|
||||
G4UImanager::GetUIpointer()->SetMasterUIManager(true);
|
||||
masterScM = G4ScoringManager::GetScoringManagerIfExist();
|
||||
|
||||
// Check if a default RandomNumberGenerator has been created by user,
|
||||
// if not create default one
|
||||
// Note this call forces creation of defaults if not already there
|
||||
// G4Random::getTheEngine(); //User did not specify RNG, create defaults
|
||||
// Now remember the master instance of the RNG Engine
|
||||
masterRNGEngine = G4Random::getTheEngine();
|
||||
|
||||
numberOfEventToBeProcessed = 0;
|
||||
randDbl = new double[nSeedsPerEvent * nSeedsMax];
|
||||
|
||||
char* env = std::getenv("G4FORCENUMBEROFTHREADS");
|
||||
if(env)
|
||||
{
|
||||
G4String envS = env;
|
||||
if(envS == "MAX" || envS == "max")
|
||||
{
|
||||
G4ExceptionDescription msg1;
|
||||
msg1 << "There are " << numberOfStaticAllocators
|
||||
<< " static G4Allocator objects detected.\n"
|
||||
<< "In multi-threaded mode, all G4Allocator objects must be dynamicly instantiated.";
|
||||
G4Exception("G4MTRunManager::G4MTRunManager","Run1035",FatalException,msg1);
|
||||
forcedNwokers = G4Threading::G4GetNumberOfCores();
|
||||
}
|
||||
G4UImanager::GetUIpointer()->SetMasterUIManager(true);
|
||||
masterScM = G4ScoringManager::GetScoringManagerIfExist();
|
||||
|
||||
//Check if a default RandomNumberGenerator has been created by user,
|
||||
// if not create default one
|
||||
//Note this call forces creation of defaults if not already there
|
||||
//G4Random::getTheEngine(); //User did not specify RNG, create defaults
|
||||
//Now remember the master instance of the RNG Engine
|
||||
masterRNGEngine = G4Random::getTheEngine();
|
||||
|
||||
numberOfEventToBeProcessed = 0;
|
||||
randDbl = new double[nSeedsPerEvent*nSeedsMax];
|
||||
|
||||
char* env = std::getenv("G4FORCENUMBEROFTHREADS");
|
||||
if(env)
|
||||
else
|
||||
{
|
||||
G4String envS = env;
|
||||
if(envS=="MAX"||envS=="max")
|
||||
{ forcedNwokers = G4Threading::G4GetNumberOfCores(); }
|
||||
std::istringstream is(env);
|
||||
G4int val = -1;
|
||||
is >> val;
|
||||
if(val > 0)
|
||||
{
|
||||
forcedNwokers = val;
|
||||
}
|
||||
else
|
||||
{
|
||||
std::istringstream is(env);
|
||||
G4int val = -1;
|
||||
is >> val;
|
||||
if(val>0)
|
||||
{ forcedNwokers = val; }
|
||||
else
|
||||
{
|
||||
G4ExceptionDescription msg2;
|
||||
msg2 << "Environment variable G4FORCENUMBEROFTHREADS has an invalid value <"
|
||||
<< envS << ">. It has to be an integer or a word \"max\".\n"
|
||||
<< "G4FORCENUMBEROFTHREADS is ignored.";
|
||||
G4Exception("G4MTRunManager::G4MTRunManager","Run1039",JustWarning,msg2);
|
||||
}
|
||||
}
|
||||
if(forcedNwokers>0)
|
||||
{
|
||||
nworkers = forcedNwokers;
|
||||
G4cout << "### Number of threads is forced to " << forcedNwokers
|
||||
<< " by Environment variable G4FORCENUMBEROFTHREADS." << G4endl;
|
||||
G4ExceptionDescription msg2;
|
||||
msg2 << "Environment variable G4FORCENUMBEROFTHREADS has an invalid "
|
||||
"value <"
|
||||
<< envS << ">. It has to be an integer or a word \"max\".\n"
|
||||
<< "G4FORCENUMBEROFTHREADS is ignored.";
|
||||
G4Exception("G4MTRunManager::G4MTRunManager", "Run1039", JustWarning,
|
||||
msg2);
|
||||
}
|
||||
}
|
||||
if(forcedNwokers > 0)
|
||||
{
|
||||
nworkers = forcedNwokers;
|
||||
G4cout << "### Number of threads is forced to " << forcedNwokers
|
||||
<< " by Environment variable G4FORCENUMBEROFTHREADS." << G4endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
G4MTRunManager::~G4MTRunManager()
|
||||
{
|
||||
//TODO: Currently does not work due to concurrent deletion of something
|
||||
// that is shared:
|
||||
//G4ProcessTable::DeleteMessenger from ~G4RunManager
|
||||
//G4cout<<"Destroy MTRunManager"<<G4endl;//ANDREA
|
||||
TerminateWorkers();
|
||||
delete [] randDbl;
|
||||
// TODO: Currently does not work due to concurrent deletion of something
|
||||
// that is shared:
|
||||
// G4ProcessTable::DeleteMessenger from ~G4RunManager
|
||||
// G4cout<<"Destroy MTRunManager"<<G4endl;//ANDREA
|
||||
TerminateWorkers();
|
||||
delete[] randDbl;
|
||||
}
|
||||
|
||||
void G4MTRunManager::StoreRNGStatus(const G4String& fn )
|
||||
void G4MTRunManager::StoreRNGStatus(const G4String& fn)
|
||||
{
|
||||
std::ostringstream os;
|
||||
os << randomNumberStatusDir << "G4Master_"<<fn <<".rndm";
|
||||
G4Random::saveEngineStatus(os.str().c_str());
|
||||
std::ostringstream os;
|
||||
os << randomNumberStatusDir << "G4Master_" << fn << ".rndm";
|
||||
G4Random::saveEngineStatus(os.str().c_str());
|
||||
}
|
||||
|
||||
void G4MTRunManager::SetNumberOfThreads(G4int n )
|
||||
void G4MTRunManager::SetNumberOfThreads(G4int n)
|
||||
{
|
||||
if ( threads.size() != 0 )
|
||||
{
|
||||
G4ExceptionDescription msg;
|
||||
msg << "Number of threads cannot be changed at this moment \n"
|
||||
<< "(old threads are still alive). Method ignored.";
|
||||
G4Exception("G4MTRunManager::SetNumberOfThreads(G4int)",
|
||||
"Run0112", JustWarning, msg);
|
||||
}
|
||||
else if ( forcedNwokers > 0 )
|
||||
{
|
||||
G4ExceptionDescription msg;
|
||||
msg << "Number of threads is forced to " << forcedNwokers
|
||||
<< " by G4FORCENUMBEROFTHREADS shell variable.\n"
|
||||
<< "Method ignored.";
|
||||
G4Exception("G4MTRunManager::SetNumberOfThreads(G4int)",
|
||||
"Run0113", JustWarning, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
nworkers = n;
|
||||
}
|
||||
if(threads.size() != 0)
|
||||
{
|
||||
G4ExceptionDescription msg;
|
||||
msg << "Number of threads cannot be changed at this moment \n"
|
||||
<< "(old threads are still alive). Method ignored.";
|
||||
G4Exception("G4MTRunManager::SetNumberOfThreads(G4int)", "Run0112",
|
||||
JustWarning, msg);
|
||||
}
|
||||
else if(forcedNwokers > 0)
|
||||
{
|
||||
G4ExceptionDescription msg;
|
||||
msg << "Number of threads is forced to " << forcedNwokers
|
||||
<< " by G4FORCENUMBEROFTHREADS shell variable.\n"
|
||||
<< "Method ignored.";
|
||||
G4Exception("G4MTRunManager::SetNumberOfThreads(G4int)", "Run0113",
|
||||
JustWarning, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
nworkers = n;
|
||||
}
|
||||
}
|
||||
|
||||
void G4MTRunManager::Initialize()
|
||||
{
|
||||
G4RunManager::Initialize();
|
||||
G4RunManager::Initialize();
|
||||
|
||||
// make sure all worker threads are set up.
|
||||
BeamOn(0);
|
||||
SetRunIDCounter(0);
|
||||
///G4UImanager::GetUIpointer()->SetIgnoreCmdNotFound(true);
|
||||
// make sure all worker threads are set up.
|
||||
BeamOn(0);
|
||||
SetRunIDCounter(0);
|
||||
/// G4UImanager::GetUIpointer()->SetIgnoreCmdNotFound(true);
|
||||
}
|
||||
|
||||
////void G4MTRunManager::TerminateEventLoop()
|
||||
@@ -209,200 +250,218 @@ void G4MTRunManager::Initialize()
|
||||
////}
|
||||
void G4MTRunManager::ProcessOneEvent(G4int)
|
||||
{
|
||||
//Nothing to do
|
||||
// Nothing to do
|
||||
}
|
||||
void G4MTRunManager::TerminateOneEvent()
|
||||
{
|
||||
//Nothing to do
|
||||
// Nothing to do
|
||||
}
|
||||
|
||||
void G4MTRunManager::PrepareCommandsStack() {
|
||||
G4AutoLock l(&cmdHandlingMutex);
|
||||
uiCmdsForWorkers.clear();
|
||||
std::vector<G4String>* cmdCopy = G4UImanager::GetUIpointer()->GetCommandStack();
|
||||
for ( std::vector<G4String>::const_iterator it = cmdCopy->begin() ;
|
||||
it != cmdCopy->end(); ++it )
|
||||
uiCmdsForWorkers.push_back(*it);
|
||||
cmdCopy->clear();
|
||||
delete cmdCopy;
|
||||
void G4MTRunManager::PrepareCommandsStack()
|
||||
{
|
||||
G4AutoLock l(&cmdHandlingMutex);
|
||||
uiCmdsForWorkers.clear();
|
||||
std::vector<G4String>* cmdCopy =
|
||||
G4UImanager::GetUIpointer()->GetCommandStack();
|
||||
for(std::vector<G4String>::const_iterator it = cmdCopy->begin();
|
||||
it != cmdCopy->end(); ++it)
|
||||
uiCmdsForWorkers.push_back(*it);
|
||||
cmdCopy->clear();
|
||||
delete cmdCopy;
|
||||
}
|
||||
|
||||
std::vector<G4String> G4MTRunManager::GetCommandStack()
|
||||
{
|
||||
G4AutoLock l(&cmdHandlingMutex);
|
||||
return uiCmdsForWorkers;
|
||||
G4AutoLock l(&cmdHandlingMutex);
|
||||
return uiCmdsForWorkers;
|
||||
}
|
||||
|
||||
void G4MTRunManager::CreateAndStartWorkers()
|
||||
{
|
||||
//Now loop on requested number of workers
|
||||
//This will also start the workers
|
||||
//Currently we do not allow to change the
|
||||
//number of threads: threads area created once
|
||||
if ( threads.size() == 0 ) {
|
||||
for ( G4int nw = 0 ; nw<nworkers; ++nw) {
|
||||
//Create a new worker and remember it
|
||||
G4WorkerThread* context = new G4WorkerThread;
|
||||
context->SetNumberThreads(nworkers);
|
||||
context->SetThreadId(nw);
|
||||
G4Thread* thread = userWorkerThreadInitialization->CreateAndStartWorker(context);
|
||||
threads.push_back(thread);
|
||||
}
|
||||
// Now loop on requested number of workers
|
||||
// This will also start the workers
|
||||
// Currently we do not allow to change the
|
||||
// number of threads: threads area created once
|
||||
if(threads.size() == 0)
|
||||
{
|
||||
for(G4int nw = 0; nw < nworkers; ++nw)
|
||||
{
|
||||
// Create a new worker and remember it
|
||||
G4WorkerThread* context = new G4WorkerThread;
|
||||
context->SetNumberThreads(nworkers);
|
||||
context->SetThreadId(nw);
|
||||
G4Thread* thread =
|
||||
userWorkerThreadInitialization->CreateAndStartWorker(context);
|
||||
threads.push_back(thread);
|
||||
}
|
||||
//Signal to threads they can start a new run
|
||||
NewActionRequest(WorkerActionRequest::NEXTITERATION);
|
||||
}
|
||||
// Signal to threads they can start a new run
|
||||
NewActionRequest(WorkerActionRequest::NEXTITERATION);
|
||||
}
|
||||
|
||||
|
||||
void G4MTRunManager::InitializeEventLoop(G4int n_event, const char* macroFile, G4int n_select)
|
||||
void G4MTRunManager::InitializeEventLoop(G4int n_event, const char* macroFile,
|
||||
G4int n_select)
|
||||
{
|
||||
TIMEMORY_AUTO_TIMER("");
|
||||
TIMEMORY_AUTO_TIMER("");
|
||||
MTkernel->SetUpDecayChannels();
|
||||
numberOfEventToBeProcessed = n_event;
|
||||
numberOfEventProcessed = 0;
|
||||
numberOfEventProcessed = 0;
|
||||
|
||||
if(!fakeRun)
|
||||
{
|
||||
nSeedsUsed = 0;
|
||||
nSeedsUsed = 0;
|
||||
nSeedsFilled = 0;
|
||||
|
||||
if(verboseLevel>0)
|
||||
{ timer->Start(); }
|
||||
|
||||
n_select_msg = n_select;
|
||||
if(macroFile!=0)
|
||||
if(verboseLevel > 0)
|
||||
{
|
||||
if(n_select_msg<0) n_select_msg = n_event;
|
||||
msgText = "/control/execute ";
|
||||
msgText += macroFile;
|
||||
selectMacro = macroFile;
|
||||
timer->Start();
|
||||
}
|
||||
|
||||
n_select_msg = n_select;
|
||||
if(macroFile != 0)
|
||||
{
|
||||
if(n_select_msg < 0)
|
||||
n_select_msg = n_event;
|
||||
msgText = "/control/execute ";
|
||||
msgText += macroFile;
|
||||
selectMacro = macroFile;
|
||||
}
|
||||
else
|
||||
{
|
||||
n_select_msg = -1;
|
||||
selectMacro = "";
|
||||
n_select_msg = -1;
|
||||
selectMacro = "";
|
||||
}
|
||||
|
||||
//initialize seeds
|
||||
//If user did not implement InitializeSeeds,
|
||||
// use default: nSeedsPerEvent seeds per event
|
||||
if( eventModuloDef > 0 )
|
||||
// initialize seeds
|
||||
// If user did not implement InitializeSeeds,
|
||||
// use default: nSeedsPerEvent seeds per event
|
||||
if(eventModuloDef > 0)
|
||||
{
|
||||
eventModulo = eventModuloDef;
|
||||
if(eventModulo > numberOfEventToBeProcessed/nworkers)
|
||||
if(eventModulo > numberOfEventToBeProcessed / nworkers)
|
||||
{
|
||||
eventModulo = numberOfEventToBeProcessed/nworkers;
|
||||
if(eventModulo<1) eventModulo =1;
|
||||
eventModulo = numberOfEventToBeProcessed / nworkers;
|
||||
if(eventModulo < 1)
|
||||
eventModulo = 1;
|
||||
G4ExceptionDescription msgd;
|
||||
msgd << "Event modulo is reduced to " << eventModulo
|
||||
<< " to distribute events to all threads.";
|
||||
G4Exception("G4MTRunManager::InitializeEventLoop()",
|
||||
"Run10035", JustWarning, msgd);
|
||||
<< " to distribute events to all threads.";
|
||||
G4Exception("G4MTRunManager::InitializeEventLoop()", "Run10035",
|
||||
JustWarning, msgd);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
eventModulo = int(std::sqrt(double(numberOfEventToBeProcessed/nworkers)));
|
||||
if(eventModulo<1) eventModulo =1;
|
||||
eventModulo =
|
||||
int(std::sqrt(double(numberOfEventToBeProcessed / nworkers)));
|
||||
if(eventModulo < 1)
|
||||
eventModulo = 1;
|
||||
}
|
||||
if ( InitializeSeeds(n_event) == false && n_event>0 )
|
||||
if(InitializeSeeds(n_event) == false && n_event > 0)
|
||||
{
|
||||
G4RNGHelper* helper = G4RNGHelper::GetInstance();
|
||||
switch(seedOncePerCommunication)
|
||||
{
|
||||
case 0:
|
||||
G4RNGHelper* helper = G4RNGHelper::GetInstance();
|
||||
switch(seedOncePerCommunication)
|
||||
{
|
||||
case 0:
|
||||
nSeedsFilled = n_event;
|
||||
break;
|
||||
case 1:
|
||||
case 1:
|
||||
nSeedsFilled = nworkers;
|
||||
break;
|
||||
case 2:
|
||||
nSeedsFilled = n_event/eventModulo + 1;
|
||||
case 2:
|
||||
nSeedsFilled = n_event / eventModulo + 1;
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
G4ExceptionDescription msgd;
|
||||
msgd << "Parameter value <" << seedOncePerCommunication
|
||||
<< "> of seedOncePerCommunication is invalid. It is reset to 0." ;
|
||||
G4Exception("G4MTRunManager::InitializeEventLoop()",
|
||||
"Run10036", JustWarning, msgd);
|
||||
<< "> of seedOncePerCommunication is invalid. It is reset to 0.";
|
||||
G4Exception("G4MTRunManager::InitializeEventLoop()", "Run10036",
|
||||
JustWarning, msgd);
|
||||
seedOncePerCommunication = 0;
|
||||
nSeedsFilled = n_event;
|
||||
}
|
||||
nSeedsFilled = n_event;
|
||||
}
|
||||
|
||||
// Generates up to nSeedsMax seed pairs only.
|
||||
if(nSeedsFilled>nSeedsMax) nSeedsFilled=nSeedsMax;
|
||||
masterRNGEngine->flatArray(nSeedsPerEvent*nSeedsFilled,randDbl);
|
||||
helper->Fill(randDbl,nSeedsFilled,n_event,nSeedsPerEvent);
|
||||
// Generates up to nSeedsMax seed pairs only.
|
||||
if(nSeedsFilled > nSeedsMax)
|
||||
nSeedsFilled = nSeedsMax;
|
||||
masterRNGEngine->flatArray(nSeedsPerEvent * nSeedsFilled, randDbl);
|
||||
helper->Fill(randDbl, nSeedsFilled, n_event, nSeedsPerEvent);
|
||||
}
|
||||
}
|
||||
|
||||
//Now initialize workers. Check if user defined a WorkerThreadInitialization
|
||||
if ( userWorkerThreadInitialization == 0 )
|
||||
{ userWorkerThreadInitialization = new G4UserWorkerThreadInitialization(); }
|
||||
|
||||
//Prepare UI commands for threads
|
||||
|
||||
// Now initialize workers. Check if user defined a WorkerThreadInitialization
|
||||
if(userWorkerThreadInitialization == 0)
|
||||
{
|
||||
userWorkerThreadInitialization = new G4UserWorkerThreadInitialization();
|
||||
}
|
||||
|
||||
// Prepare UI commands for threads
|
||||
PrepareCommandsStack();
|
||||
|
||||
//Start worker threads
|
||||
// Start worker threads
|
||||
CreateAndStartWorkers();
|
||||
|
||||
|
||||
// We need a barrier here. Wait for workers to start event loop.
|
||||
//This will return only when all workers have started processing events.
|
||||
// This will return only when all workers have started processing events.
|
||||
WaitForReadyWorkers();
|
||||
}
|
||||
|
||||
void G4MTRunManager::RefillSeeds()
|
||||
{
|
||||
G4RNGHelper* helper = G4RNGHelper::GetInstance();
|
||||
G4int nFill = 0;
|
||||
G4int nFill = 0;
|
||||
switch(seedOncePerCommunication)
|
||||
{
|
||||
case 0:
|
||||
nFill = numberOfEventToBeProcessed - nSeedsFilled;
|
||||
break;
|
||||
case 1:
|
||||
nFill = nworkers - nSeedsFilled;
|
||||
break;
|
||||
case 2:
|
||||
default:
|
||||
nFill = (numberOfEventToBeProcessed - nSeedsFilled*eventModulo)/eventModulo + 1;
|
||||
case 0:
|
||||
nFill = numberOfEventToBeProcessed - nSeedsFilled;
|
||||
break;
|
||||
case 1:
|
||||
nFill = nworkers - nSeedsFilled;
|
||||
break;
|
||||
case 2:
|
||||
default:
|
||||
nFill = (numberOfEventToBeProcessed - nSeedsFilled * eventModulo) /
|
||||
eventModulo +
|
||||
1;
|
||||
}
|
||||
// Generates up to nSeedsMax seed pairs only.
|
||||
if(nFill>nSeedsMax) nFill=nSeedsMax;
|
||||
masterRNGEngine->flatArray(nSeedsPerEvent*nFill,randDbl);
|
||||
helper->Refill(randDbl,nFill);
|
||||
if(nFill > nSeedsMax)
|
||||
nFill = nSeedsMax;
|
||||
masterRNGEngine->flatArray(nSeedsPerEvent * nFill, randDbl);
|
||||
helper->Refill(randDbl, nFill);
|
||||
nSeedsFilled += nFill;
|
||||
//G4cout<<"helper->Refill() for "<<nFill<<" events."<<G4endl;
|
||||
// G4cout<<"helper->Refill() for "<<nFill<<" events."<<G4endl;
|
||||
}
|
||||
|
||||
|
||||
void G4MTRunManager::RunTermination()
|
||||
{
|
||||
//Wait for all worker threads to have finished the run
|
||||
//i.e. wait for them to return from RunTermination()
|
||||
//This guarantee that userrunaction for workers has been called
|
||||
// Wait for all worker threads to have finished the run
|
||||
// i.e. wait for them to return from RunTermination()
|
||||
// This guarantee that userrunaction for workers has been called
|
||||
|
||||
// Wait now for all threads to finish event-loop
|
||||
WaitForEndEventLoopWorkers();
|
||||
//Now call base-class methof
|
||||
// Now call base-class methof
|
||||
G4RunManager::TerminateEventLoop();
|
||||
G4RunManager::RunTermination();
|
||||
}
|
||||
|
||||
void G4MTRunManager::ConstructScoringWorlds()
|
||||
{
|
||||
masterScM = G4ScoringManager::GetScoringManagerIfExist();
|
||||
//Call base class stuff...
|
||||
G4RunManager::ConstructScoringWorlds();
|
||||
|
||||
masterWorlds.clear();
|
||||
size_t nWorlds = G4TransportationManager::GetTransportationManager()->GetNoWorlds();
|
||||
std::vector<G4VPhysicalVolume*>::iterator itrW
|
||||
= G4TransportationManager::GetTransportationManager()->GetWorldsIterator();
|
||||
for(size_t iWorld=0;iWorld<nWorlds;iWorld++)
|
||||
{
|
||||
addWorld(iWorld,*itrW);
|
||||
itrW++;
|
||||
}
|
||||
masterScM = G4ScoringManager::GetScoringManagerIfExist();
|
||||
// Call base class stuff...
|
||||
G4RunManager::ConstructScoringWorlds();
|
||||
|
||||
masterWorlds.clear();
|
||||
size_t nWorlds =
|
||||
G4TransportationManager::GetTransportationManager()->GetNoWorlds();
|
||||
std::vector<G4VPhysicalVolume*>::iterator itrW =
|
||||
G4TransportationManager::GetTransportationManager()->GetWorldsIterator();
|
||||
for(size_t iWorld = 0; iWorld < nWorlds; iWorld++)
|
||||
{
|
||||
addWorld(iWorld, *itrW);
|
||||
itrW++;
|
||||
}
|
||||
}
|
||||
|
||||
void G4MTRunManager::SetUserInitialization(G4UserWorkerInitialization* userInit)
|
||||
@@ -410,91 +469,106 @@ void G4MTRunManager::SetUserInitialization(G4UserWorkerInitialization* userInit)
|
||||
userWorkerInitialization = userInit;
|
||||
}
|
||||
|
||||
void G4MTRunManager::SetUserInitialization(G4UserWorkerThreadInitialization* userInit)
|
||||
void G4MTRunManager::SetUserInitialization(
|
||||
G4UserWorkerThreadInitialization* userInit)
|
||||
{
|
||||
userWorkerThreadInitialization = userInit;
|
||||
}
|
||||
|
||||
void G4MTRunManager::SetUserInitialization(G4VUserActionInitialization* userInit)
|
||||
void G4MTRunManager::SetUserInitialization(
|
||||
G4VUserActionInitialization* userInit)
|
||||
{
|
||||
userActionInitialization = userInit;
|
||||
userActionInitialization->BuildForMaster();
|
||||
}
|
||||
|
||||
void G4MTRunManager::SetUserInitialization(G4VUserPhysicsList *userPL)
|
||||
void G4MTRunManager::SetUserInitialization(G4VUserPhysicsList* userPL)
|
||||
{
|
||||
G4RunManager::SetUserInitialization(userPL);
|
||||
//Needed for MT, to be moved in kernel
|
||||
G4RunManager::SetUserInitialization(userPL);
|
||||
// Needed for MT, to be moved in kernel
|
||||
}
|
||||
|
||||
void G4MTRunManager::SetUserInitialization(G4VUserDetectorConstruction *userDC)
|
||||
void G4MTRunManager::SetUserInitialization(G4VUserDetectorConstruction* userDC)
|
||||
{
|
||||
G4RunManager::SetUserInitialization(userDC);
|
||||
G4RunManager::SetUserInitialization(userDC);
|
||||
}
|
||||
|
||||
void G4MTRunManager::SetUserAction(G4UserRunAction* userAction)
|
||||
{
|
||||
G4RunManager::SetUserAction(userAction);
|
||||
if(userAction) userAction->SetMaster();
|
||||
G4RunManager::SetUserAction(userAction);
|
||||
if(userAction)
|
||||
userAction->SetMaster();
|
||||
}
|
||||
|
||||
void G4MTRunManager::SetUserAction(G4VUserPrimaryGeneratorAction* /*userAction*/)
|
||||
void G4MTRunManager::SetUserAction(
|
||||
G4VUserPrimaryGeneratorAction* /*userAction*/)
|
||||
{
|
||||
G4Exception("G4MTRunManager::SetUserAction()", "Run0123", FatalException,
|
||||
"For multi-threaded version, define G4VUserPrimaryGeneratorAction in G4VUserActionInitialization.");
|
||||
G4Exception(
|
||||
"G4MTRunManager::SetUserAction()", "Run0123", FatalException,
|
||||
"For multi-threaded version, define G4VUserPrimaryGeneratorAction in "
|
||||
"G4VUserActionInitialization.");
|
||||
}
|
||||
|
||||
void G4MTRunManager::SetUserAction(G4UserEventAction* /*userAction*/)
|
||||
{
|
||||
G4Exception("G4MTRunManager::SetUserAction()", "Run0124", FatalException,
|
||||
"For multi-threaded version, define G4UserEventAction in G4VUserActionInitialization.");
|
||||
"For multi-threaded version, define G4UserEventAction in "
|
||||
"G4VUserActionInitialization.");
|
||||
}
|
||||
|
||||
void G4MTRunManager::SetUserAction(G4UserStackingAction* /*userAction*/)
|
||||
{
|
||||
G4Exception("G4MTRunManager::SetUserAction()", "Run0125", FatalException,
|
||||
"For multi-threaded version, define G4UserStackingAction in G4VUserActionInitialization.");
|
||||
"For multi-threaded version, define G4UserStackingAction in "
|
||||
"G4VUserActionInitialization.");
|
||||
}
|
||||
|
||||
void G4MTRunManager::SetUserAction(G4UserTrackingAction* /*userAction*/)
|
||||
{
|
||||
G4Exception("G4MTRunManager::SetUserAction()", "Run0126", FatalException,
|
||||
"For multi-threaded version, define G4UserTrackingAction in G4VUserActionInitialization.");
|
||||
"For multi-threaded version, define G4UserTrackingAction in "
|
||||
"G4VUserActionInitialization.");
|
||||
}
|
||||
|
||||
void G4MTRunManager::SetUserAction(G4UserSteppingAction* /*userAction*/)
|
||||
{
|
||||
G4Exception("G4MTRunManager::SetUserAction()", "Run0127", FatalException,
|
||||
"For multi-threaded version, define G4UserSteppingAction in G4VUserActionInitialization.");
|
||||
"For multi-threaded version, define G4UserSteppingAction in "
|
||||
"G4VUserActionInitialization.");
|
||||
}
|
||||
|
||||
void G4MTRunManager::MergeScores(const G4ScoringManager* localScoringManager)
|
||||
{
|
||||
G4AutoLock l(&scorerMergerMutex);
|
||||
if(masterScM) masterScM->Merge(localScoringManager);
|
||||
if(masterScM && localScoringManager)
|
||||
masterScM->Merge(localScoringManager);
|
||||
}
|
||||
|
||||
void G4MTRunManager::MergeRun(const G4Run* localRun)
|
||||
{
|
||||
G4AutoLock l(&runMergerMutex);
|
||||
if(currentRun) currentRun->Merge(localRun);
|
||||
if(currentRun && localRun)
|
||||
currentRun->Merge(localRun);
|
||||
}
|
||||
|
||||
G4bool G4MTRunManager::SetUpAnEvent(G4Event* evt,long& s1,long& s2,long& s3,G4bool reseedRequired)
|
||||
G4bool G4MTRunManager::SetUpAnEvent(G4Event* evt, long& s1, long& s2, long& s3,
|
||||
G4bool reseedRequired)
|
||||
{
|
||||
G4AutoLock l(&setUpEventMutex);
|
||||
if( numberOfEventProcessed < numberOfEventToBeProcessed )
|
||||
if(numberOfEventProcessed < numberOfEventToBeProcessed)
|
||||
{
|
||||
evt->SetEventID(numberOfEventProcessed);
|
||||
if(reseedRequired)
|
||||
{
|
||||
G4RNGHelper* helper = G4RNGHelper::GetInstance();
|
||||
G4int idx_rndm = nSeedsPerEvent*nSeedsUsed;
|
||||
s1 = helper->GetSeed(idx_rndm);
|
||||
s2 = helper->GetSeed(idx_rndm+1);
|
||||
if(nSeedsPerEvent==3) s3 = helper->GetSeed(idx_rndm+2);
|
||||
G4int idx_rndm = nSeedsPerEvent * nSeedsUsed;
|
||||
s1 = helper->GetSeed(idx_rndm);
|
||||
s2 = helper->GetSeed(idx_rndm + 1);
|
||||
if(nSeedsPerEvent == 3)
|
||||
s3 = helper->GetSeed(idx_rndm + 2);
|
||||
nSeedsUsed++;
|
||||
if(nSeedsUsed==nSeedsFilled) RefillSeeds();
|
||||
if(nSeedsUsed == nSeedsFilled)
|
||||
RefillSeeds();
|
||||
}
|
||||
numberOfEventProcessed++;
|
||||
return true;
|
||||
@@ -502,28 +576,33 @@ G4bool G4MTRunManager::SetUpAnEvent(G4Event* evt,long& s1,long& s2,long& s3,G4bo
|
||||
return false;
|
||||
}
|
||||
|
||||
G4int G4MTRunManager::SetUpNEvents(G4Event* evt, G4SeedsQueue* seedsQueue,G4bool reseedRequired)
|
||||
G4int G4MTRunManager::SetUpNEvents(G4Event* evt, G4SeedsQueue* seedsQueue,
|
||||
G4bool reseedRequired)
|
||||
{
|
||||
G4AutoLock l(&setUpEventMutex);
|
||||
if( numberOfEventProcessed < numberOfEventToBeProcessed && !runAborted )
|
||||
if(numberOfEventProcessed < numberOfEventToBeProcessed && !runAborted)
|
||||
{
|
||||
G4int nev = eventModulo;
|
||||
if(numberOfEventProcessed + nev > numberOfEventToBeProcessed)
|
||||
{ nev = numberOfEventToBeProcessed - numberOfEventProcessed; }
|
||||
{
|
||||
nev = numberOfEventToBeProcessed - numberOfEventProcessed;
|
||||
}
|
||||
evt->SetEventID(numberOfEventProcessed);
|
||||
if(reseedRequired)
|
||||
{
|
||||
G4RNGHelper* helper = G4RNGHelper::GetInstance();
|
||||
G4int nevRnd = nev;
|
||||
if(seedOncePerCommunication>0) nevRnd = 1;
|
||||
for(int i=0;i<nevRnd;i++)
|
||||
G4int nevRnd = nev;
|
||||
if(seedOncePerCommunication > 0)
|
||||
nevRnd = 1;
|
||||
for(int i = 0; i < nevRnd; i++)
|
||||
{
|
||||
seedsQueue->push(helper->GetSeed(nSeedsPerEvent*nSeedsUsed));
|
||||
seedsQueue->push(helper->GetSeed(nSeedsPerEvent*nSeedsUsed+1));
|
||||
if(nSeedsPerEvent==3)
|
||||
seedsQueue->push(helper->GetSeed(nSeedsPerEvent*nSeedsUsed+2));
|
||||
seedsQueue->push(helper->GetSeed(nSeedsPerEvent * nSeedsUsed));
|
||||
seedsQueue->push(helper->GetSeed(nSeedsPerEvent * nSeedsUsed + 1));
|
||||
if(nSeedsPerEvent == 3)
|
||||
seedsQueue->push(helper->GetSeed(nSeedsPerEvent * nSeedsUsed + 2));
|
||||
nSeedsUsed++;
|
||||
if(nSeedsUsed==nSeedsFilled) RefillSeeds();
|
||||
if(nSeedsUsed == nSeedsFilled)
|
||||
RefillSeeds();
|
||||
}
|
||||
}
|
||||
numberOfEventProcessed += nev;
|
||||
@@ -534,22 +613,22 @@ G4int G4MTRunManager::SetUpNEvents(G4Event* evt, G4SeedsQueue* seedsQueue,G4bool
|
||||
|
||||
void G4MTRunManager::TerminateWorkers()
|
||||
{
|
||||
//Force workers to execute (if any) all UI commands left in the stack
|
||||
RequestWorkersProcessCommandsStack();
|
||||
//Ask workers to exit
|
||||
NewActionRequest( WorkerActionRequest::ENDWORKER );
|
||||
//Now join threads.
|
||||
#ifdef G4MULTITHREADED //protect here to prevent warning in compilation
|
||||
while ( ! threads.empty() )
|
||||
{
|
||||
G4Thread* t = * ( threads.begin() );
|
||||
threads.pop_front();
|
||||
userWorkerThreadInitialization->JoinWorker(t);
|
||||
//G4THREADJOIN(*t);
|
||||
delete t;
|
||||
}
|
||||
// Force workers to execute (if any) all UI commands left in the stack
|
||||
RequestWorkersProcessCommandsStack();
|
||||
// Ask workers to exit
|
||||
NewActionRequest(WorkerActionRequest::ENDWORKER);
|
||||
// Now join threads.
|
||||
#ifdef G4MULTITHREADED // protect here to prevent warning in compilation
|
||||
while(!threads.empty())
|
||||
{
|
||||
G4Thread* t = *(threads.begin());
|
||||
threads.pop_front();
|
||||
userWorkerThreadInitialization->JoinWorker(t);
|
||||
// G4THREADJOIN(*t);
|
||||
delete t;
|
||||
}
|
||||
#endif
|
||||
threads.clear();
|
||||
threads.clear();
|
||||
}
|
||||
|
||||
void G4MTRunManager::AbortRun(G4bool softAbort)
|
||||
@@ -557,7 +636,7 @@ void G4MTRunManager::AbortRun(G4bool softAbort)
|
||||
// This method is valid only for GeomClosed or EventProc state
|
||||
G4ApplicationState currentState =
|
||||
G4StateManager::GetStateManager()->GetCurrentState();
|
||||
if(currentState==G4State_GeomClosed || currentState==G4State_EventProc)
|
||||
if(currentState == G4State_GeomClosed || currentState == G4State_EventProc)
|
||||
{
|
||||
runAborted = true;
|
||||
MTkernel->BroadcastAbortRun(softAbort);
|
||||
@@ -573,57 +652,66 @@ void G4MTRunManager::AbortEvent()
|
||||
// nothing to do in the master thread
|
||||
}
|
||||
|
||||
void G4MTRunManager::WaitForReadyWorkers() {
|
||||
beginOfEventLoopBarrier.Wait( GetNumberActiveThreads() );
|
||||
void G4MTRunManager::WaitForReadyWorkers()
|
||||
{
|
||||
beginOfEventLoopBarrier.Wait(GetNumberActiveThreads());
|
||||
endOfEventLoopBarrier.ResetCounter();
|
||||
beginOfEventLoopBarrier.ReleaseBarrier();
|
||||
}
|
||||
|
||||
void G4MTRunManager::ThisWorkerReady() {
|
||||
void G4MTRunManager::ThisWorkerReady()
|
||||
{
|
||||
beginOfEventLoopBarrier.ThisWorkerReady();
|
||||
}
|
||||
|
||||
void G4MTRunManager::WaitForEndEventLoopWorkers() {
|
||||
endOfEventLoopBarrier.Wait( GetNumberActiveThreads() );
|
||||
void G4MTRunManager::WaitForEndEventLoopWorkers()
|
||||
{
|
||||
endOfEventLoopBarrier.Wait(GetNumberActiveThreads());
|
||||
beginOfEventLoopBarrier.ResetCounter();
|
||||
endOfEventLoopBarrier.ReleaseBarrier();
|
||||
}
|
||||
|
||||
void G4MTRunManager::ThisWorkerEndEventLoop() {
|
||||
void G4MTRunManager::ThisWorkerEndEventLoop()
|
||||
{
|
||||
endOfEventLoopBarrier.ThisWorkerReady();
|
||||
}
|
||||
|
||||
void G4MTRunManager::NewActionRequest(G4MTRunManager::WorkerActionRequest newRequest) {
|
||||
nextActionRequestBarrier.Wait( GetNumberActiveThreads() );
|
||||
//nextActionRequest is a shared resource, but there is no
|
||||
//data-race thanks to the barrier: all threads are waiting
|
||||
nextActionRequest = newRequest;
|
||||
nextActionRequestBarrier.ReleaseBarrier();
|
||||
void G4MTRunManager::NewActionRequest(
|
||||
G4MTRunManager::WorkerActionRequest newRequest)
|
||||
{
|
||||
nextActionRequestBarrier.Wait(GetNumberActiveThreads());
|
||||
// nextActionRequest is a shared resource, but there is no
|
||||
// data-race thanks to the barrier: all threads are waiting
|
||||
nextActionRequest = newRequest;
|
||||
nextActionRequestBarrier.ReleaseBarrier();
|
||||
}
|
||||
|
||||
G4MTRunManager::WorkerActionRequest G4MTRunManager::ThisWorkerWaitForNextAction() {
|
||||
G4MTRunManager::WorkerActionRequest
|
||||
G4MTRunManager::ThisWorkerWaitForNextAction()
|
||||
{
|
||||
nextActionRequestBarrier.ThisWorkerReady();
|
||||
return nextActionRequest;
|
||||
}
|
||||
|
||||
void G4MTRunManager::RequestWorkersProcessCommandsStack() {
|
||||
void G4MTRunManager::RequestWorkersProcessCommandsStack()
|
||||
{
|
||||
PrepareCommandsStack();
|
||||
NewActionRequest(WorkerActionRequest::PROCESSUI);
|
||||
processUIBarrier.SetActiveThreads( GetNumberActiveThreads() );
|
||||
processUIBarrier.SetActiveThreads(GetNumberActiveThreads());
|
||||
processUIBarrier.WaitForReadyWorkers();
|
||||
}
|
||||
|
||||
void G4MTRunManager::ThisWorkerProcessCommandsStackDone() {
|
||||
void G4MTRunManager::ThisWorkerProcessCommandsStackDone()
|
||||
{
|
||||
processUIBarrier.ThisWorkerReady();
|
||||
}
|
||||
void G4MTRunManager::SetPinAffinity(G4int n)
|
||||
{
|
||||
if ( n == 0 )
|
||||
{
|
||||
G4Exception("G4MTRunManager::SetPinAffinity",
|
||||
"Run0114",FatalException,
|
||||
"Pin affinity must be >0 or <0.");
|
||||
}
|
||||
pinAffinity = n;
|
||||
return;
|
||||
if(n == 0)
|
||||
{
|
||||
G4Exception("G4MTRunManager::SetPinAffinity", "Run0114", FatalException,
|
||||
"Pin affinity must be >0 or <0.");
|
||||
}
|
||||
pinAffinity = n;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,82 +25,91 @@
|
||||
//
|
||||
|
||||
#include "G4MTRunManagerKernel.hh"
|
||||
#include "G4AutoLock.hh"
|
||||
#include "G4RegionStore.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4AutoLock.hh"
|
||||
|
||||
std::vector<G4WorkerRunManager*>* G4MTRunManagerKernel::workerRMvector = 0;
|
||||
|
||||
namespace {
|
||||
G4Mutex workerRMMutex = G4MUTEX_INITIALIZER;
|
||||
namespace
|
||||
{
|
||||
G4Mutex workerRMMutex = G4MUTEX_INITIALIZER;
|
||||
}
|
||||
|
||||
G4MTRunManagerKernel::G4MTRunManagerKernel() : G4RunManagerKernel(masterRMK)
|
||||
G4MTRunManagerKernel::G4MTRunManagerKernel()
|
||||
: G4RunManagerKernel(masterRMK)
|
||||
{
|
||||
//This version of the constructor should never be called in sequential mode!
|
||||
// This version of the constructor should never be called in sequential mode!
|
||||
#ifndef G4MULTITHREADED
|
||||
G4ExceptionDescription msg;
|
||||
msg<<"Geant4 code is compiled without multi-threading support (-DG4MULTITHREADED is set to off).";
|
||||
msg<<" This type of RunManager can only be used in mult-threaded applications.";
|
||||
G4Exception("G4RunManagerKernel::G4RunManagerKernel()","Run0109",FatalException,msg);
|
||||
G4ExceptionDescription msg;
|
||||
msg << "Geant4 code is compiled without multi-threading support "
|
||||
"(-DG4MULTITHREADED "
|
||||
"is set to off).";
|
||||
msg << " This type of RunManager can only be used in mult-threaded "
|
||||
"applications.";
|
||||
G4Exception("G4RunManagerKernel::G4RunManagerKernel()", "Run0109",
|
||||
FatalException, msg);
|
||||
#endif
|
||||
G4AutoLock l(&workerRMMutex);
|
||||
if(!workerRMvector) workerRMvector = new std::vector<G4WorkerRunManager*>;
|
||||
l.unlock();
|
||||
//Set flag that a MT-type kernel has been instantiated
|
||||
G4Threading::SetMultithreadedApplication(true);
|
||||
G4AutoLock l(&workerRMMutex);
|
||||
if(!workerRMvector)
|
||||
workerRMvector = new std::vector<G4WorkerRunManager*>;
|
||||
l.unlock();
|
||||
// Set flag that a MT-type kernel has been instantiated
|
||||
G4Threading::SetMultithreadedApplication(true);
|
||||
}
|
||||
|
||||
G4MTRunManagerKernel::~G4MTRunManagerKernel()
|
||||
{
|
||||
G4AutoLock l(&workerRMMutex);
|
||||
if(workerRMvector)
|
||||
if(workerRMvector)
|
||||
{
|
||||
if(workerRMvector->size() > 0)
|
||||
{
|
||||
if(workerRMvector->size()>0)
|
||||
{
|
||||
G4ExceptionDescription msg;
|
||||
msg<<"G4MTRunManagerKernel is to be deleted while "
|
||||
<<workerRMvector->size()<<" G4WorkerRunManager are still alive.";
|
||||
G4Exception("G4RunManagerKernel::~G4RunManagerKernel()",
|
||||
"Run10035",FatalException,msg);
|
||||
}
|
||||
delete workerRMvector;
|
||||
workerRMvector = 0;
|
||||
}
|
||||
G4ExceptionDescription msg;
|
||||
msg << "G4MTRunManagerKernel is to be deleted while "
|
||||
<< workerRMvector->size() << " G4WorkerRunManager are still alive.";
|
||||
G4Exception("G4RunManagerKernel::~G4RunManagerKernel()", "Run10035",
|
||||
FatalException, msg);
|
||||
}
|
||||
delete workerRMvector;
|
||||
workerRMvector = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void G4MTRunManagerKernel::SetupShadowProcess() const
|
||||
{
|
||||
//Behavior is the same as base class (sequential mode)
|
||||
//ShadowProcess pointer == process poitner
|
||||
G4RunManagerKernel::SetupShadowProcess();
|
||||
// Behavior is the same as base class (sequential mode)
|
||||
// ShadowProcess pointer == process poitner
|
||||
G4RunManagerKernel::SetupShadowProcess();
|
||||
}
|
||||
|
||||
#include "G4WorkerRunManager.hh"
|
||||
#include "G4UserWorkerInitialization.hh"
|
||||
#include "G4UserWorkerThreadInitialization.hh"
|
||||
#include "G4VUserActionInitialization.hh"
|
||||
#include "G4WorkerThread.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4PVReplica.hh"
|
||||
#include "G4Region.hh"
|
||||
#include "G4Material.hh"
|
||||
#include "G4PhysicsVector.hh"
|
||||
#include "G4VDecayChannel.hh"
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
#include "G4MaterialTable.hh"
|
||||
#include "G4PVParameterised.hh"
|
||||
#include "G4PVReplica.hh"
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
#include "G4PhysicsVector.hh"
|
||||
#include "G4PolyconeSide.hh"
|
||||
#include "G4PolyhedraSide.hh"
|
||||
#include "G4PVParameterised.hh"
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
#include "G4VPhysicsConstructor.hh"
|
||||
#include "G4Region.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4UserWorkerInitialization.hh"
|
||||
#include "G4UserWorkerThreadInitialization.hh"
|
||||
#include "G4VDecayChannel.hh"
|
||||
#include "G4VModularPhysicsList.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4VPhysicsConstructor.hh"
|
||||
#include "G4VUserActionInitialization.hh"
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
#include "G4WorkerRunManager.hh"
|
||||
#include "G4WorkerThread.hh"
|
||||
|
||||
G4ThreadLocal G4WorkerThread* G4MTRunManagerKernel::wThreadContext = 0;
|
||||
G4WorkerThread* G4MTRunManagerKernel::GetWorkerThread()
|
||||
{ return wThreadContext; }
|
||||
G4WorkerThread* G4MTRunManagerKernel::GetWorkerThread()
|
||||
{
|
||||
return wThreadContext;
|
||||
}
|
||||
|
||||
void G4MTRunManagerKernel::StartThread(G4WorkerThread* context)
|
||||
{
|
||||
@@ -114,93 +123,107 @@ void G4MTRunManagerKernel::StartThread(G4WorkerThread* context)
|
||||
// All the rest that is not invariant should be incapsualted into
|
||||
// the context (or, as for wThreadContext be G4ThreadLocal)
|
||||
//!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
//#ifdef G4MULTITHREADED
|
||||
// turnontpmalloc();
|
||||
//#endif
|
||||
//#ifdef G4MULTITHREADED
|
||||
// turnontpmalloc();
|
||||
//#endif
|
||||
G4Threading::WorkerThreadJoinsPool();
|
||||
wThreadContext = context;
|
||||
wThreadContext = context;
|
||||
G4MTRunManager* masterRM = G4MTRunManager::GetMasterRunManager();
|
||||
|
||||
|
||||
//============================
|
||||
//Step-0: Thread ID
|
||||
// Step-0: Thread ID
|
||||
//============================
|
||||
//Initliazie per-thread stream-output
|
||||
//The following line is needed before we actually do IO initialization
|
||||
//becasue the constructor of UI manager resets the IO destination.
|
||||
// Initliazie per-thread stream-output
|
||||
// The following line is needed before we actually do IO initialization
|
||||
// becasue the constructor of UI manager resets the IO destination.
|
||||
G4int thisID = wThreadContext->GetThreadId();
|
||||
G4Threading::G4SetThreadId(thisID);
|
||||
G4UImanager::GetUIpointer()->SetUpForAThread(thisID);
|
||||
|
||||
//============================
|
||||
//Optimization: optional
|
||||
// Optimization: optional
|
||||
//============================
|
||||
//Enforce thread affinity if requested
|
||||
// Enforce thread affinity if requested
|
||||
wThreadContext->SetPinAffinity(masterRM->GetPinAffinity());
|
||||
|
||||
//============================
|
||||
//Step-1: Random number engine
|
||||
// Step-1: Random number engine
|
||||
//============================
|
||||
//RNG Engine needs to be initialized by "cloning" the master one.
|
||||
const CLHEP::HepRandomEngine* masterEngine = masterRM->getMasterRandomEngine();
|
||||
// RNG Engine needs to be initialized by "cloning" the master one.
|
||||
const CLHEP::HepRandomEngine* masterEngine =
|
||||
masterRM->getMasterRandomEngine();
|
||||
masterRM->GetUserWorkerThreadInitialization()->SetupRNGEngine(masterEngine);
|
||||
|
||||
//============================
|
||||
//Step-2: Initialize worker thread
|
||||
// Step-2: Initialize worker thread
|
||||
//============================
|
||||
if(masterRM->GetUserWorkerInitialization())
|
||||
{ masterRM->GetUserWorkerInitialization()->WorkerInitialize(); }
|
||||
{
|
||||
masterRM->GetUserWorkerInitialization()->WorkerInitialize();
|
||||
}
|
||||
if(masterRM->GetUserActionInitialization())
|
||||
{
|
||||
G4VSteppingVerbose* sv = masterRM->GetUserActionInitialization()->InitializeSteppingVerbose();
|
||||
if ( sv ) { G4VSteppingVerbose::SetInstance(sv); }
|
||||
G4VSteppingVerbose* sv =
|
||||
masterRM->GetUserActionInitialization()->InitializeSteppingVerbose();
|
||||
if(sv)
|
||||
{
|
||||
G4VSteppingVerbose::SetInstance(sv);
|
||||
}
|
||||
}
|
||||
//Now initialize worker part of shared objects (geometry/physics)
|
||||
// Now initialize worker part of shared objects (geometry/physics)
|
||||
wThreadContext->BuildGeometryAndPhysicsVector();
|
||||
G4WorkerRunManager* wrm
|
||||
= masterRM->GetUserWorkerThreadInitialization()->CreateWorkerRunManager();
|
||||
G4WorkerRunManager* wrm =
|
||||
masterRM->GetUserWorkerThreadInitialization()->CreateWorkerRunManager();
|
||||
wrm->SetWorkerThread(wThreadContext);
|
||||
G4AutoLock wrmm(&workerRMMutex);
|
||||
workerRMvector->push_back(wrm);
|
||||
wrmm.unlock();
|
||||
|
||||
//================================
|
||||
//Step-3: Setup worker run manager
|
||||
// Step-3: Setup worker run manager
|
||||
//================================
|
||||
// Set the detector and physics list to the worker thread. Share with master
|
||||
const G4VUserDetectorConstruction* detector = masterRM->GetUserDetectorConstruction();
|
||||
wrm->G4RunManager::SetUserInitialization(const_cast<G4VUserDetectorConstruction*>(detector));
|
||||
const G4VUserDetectorConstruction* detector =
|
||||
masterRM->GetUserDetectorConstruction();
|
||||
wrm->G4RunManager::SetUserInitialization(
|
||||
const_cast<G4VUserDetectorConstruction*>(detector));
|
||||
const G4VUserPhysicsList* physicslist = masterRM->GetUserPhysicsList();
|
||||
wrm->SetUserInitialization(const_cast<G4VUserPhysicsList*>(physicslist));
|
||||
|
||||
//================================
|
||||
//Step-4: Initialize worker run manager
|
||||
// Step-4: Initialize worker run manager
|
||||
//================================
|
||||
if(masterRM->GetUserActionInitialization())
|
||||
{ masterRM->GetNonConstUserActionInitialization()->Build(); }
|
||||
{
|
||||
masterRM->GetNonConstUserActionInitialization()->Build();
|
||||
}
|
||||
if(masterRM->GetUserWorkerInitialization())
|
||||
{ masterRM->GetUserWorkerInitialization()->WorkerStart(); }
|
||||
{
|
||||
masterRM->GetUserWorkerInitialization()->WorkerStart();
|
||||
}
|
||||
wrm->Initialize();
|
||||
|
||||
//================================
|
||||
//Step5: Loop over requests from the master thread
|
||||
// Step5: Loop over requests from the master thread
|
||||
//================================
|
||||
//This function should enter a loop processing new runs and actions
|
||||
//requests from master. It should block until thread is ready
|
||||
//to terminate
|
||||
// This function should enter a loop processing new runs and actions
|
||||
// requests from master. It should block until thread is ready
|
||||
// to terminate
|
||||
wrm->DoWork();
|
||||
|
||||
//===============================
|
||||
//Step-6: Terminate worker thread
|
||||
// Step-6: Terminate worker thread
|
||||
//===============================
|
||||
if(masterRM->GetUserWorkerInitialization())
|
||||
{ masterRM->GetUserWorkerInitialization()->WorkerStop(); }
|
||||
{
|
||||
masterRM->GetUserWorkerInitialization()->WorkerStop();
|
||||
}
|
||||
|
||||
wrmm.lock();
|
||||
std::vector<G4WorkerRunManager*>::iterator itrWrm = workerRMvector->begin();
|
||||
for(;itrWrm!=workerRMvector->end();itrWrm++)
|
||||
for(; itrWrm != workerRMvector->end(); itrWrm++)
|
||||
{
|
||||
if((*itrWrm)==wrm)
|
||||
if((*itrWrm) == wrm)
|
||||
{
|
||||
workerRMvector->erase(itrWrm);
|
||||
break;
|
||||
@@ -210,7 +233,7 @@ void G4MTRunManagerKernel::StartThread(G4WorkerThread* context)
|
||||
delete wrm;
|
||||
|
||||
//===============================
|
||||
//Step-7: Cleanup split classes
|
||||
// Step-7: Cleanup split classes
|
||||
//===============================
|
||||
wThreadContext->DestroyGeometryAndPhysicsVector();
|
||||
wThreadContext = 0;
|
||||
@@ -218,16 +241,16 @@ void G4MTRunManagerKernel::StartThread(G4WorkerThread* context)
|
||||
G4Threading::WorkerThreadLeavesPool();
|
||||
}
|
||||
|
||||
#include "G4DecayTable.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4ParticleTableIterator.hh"
|
||||
#include "G4DecayTable.hh"
|
||||
#include "G4VDecayChannel.hh"
|
||||
|
||||
void G4MTRunManagerKernel::SetUpDecayChannels()
|
||||
{
|
||||
G4ParticleTable::G4PTblDicIterator* pItr
|
||||
= G4ParticleTable::GetParticleTable()->GetIterator();
|
||||
G4ParticleTable::G4PTblDicIterator* pItr =
|
||||
G4ParticleTable::GetParticleTable()->GetIterator();
|
||||
pItr->reset();
|
||||
while((*pItr)())
|
||||
{
|
||||
@@ -235,8 +258,10 @@ void G4MTRunManagerKernel::SetUpDecayChannels()
|
||||
if(dt)
|
||||
{
|
||||
G4int nCh = dt->entries();
|
||||
for(G4int i=0;i<nCh;i++)
|
||||
{ dt->GetDecayChannel(i)->GetDaughter(0); }
|
||||
for(G4int i = 0; i < nCh; i++)
|
||||
{
|
||||
dt->GetDecayChannel(i)->GetDaughter(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -245,7 +270,8 @@ void G4MTRunManagerKernel::BroadcastAbortRun(G4bool softAbort)
|
||||
{
|
||||
G4AutoLock wrmm(&workerRMMutex);
|
||||
std::vector<G4WorkerRunManager*>::iterator itr = workerRMvector->begin();
|
||||
for(;itr!=workerRMvector->end();itr++)
|
||||
{ (*itr)->AbortRun(softAbort); }
|
||||
for(; itr != workerRMvector->end(); itr++)
|
||||
{
|
||||
(*itr)->AbortRun(softAbort);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -30,18 +30,18 @@
|
||||
|
||||
#include "G4MatScanMessenger.hh"
|
||||
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIparameter.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIcmdWithABool.hh"
|
||||
#include "G4UIcmdWith3VectorAndUnit.hh"
|
||||
#include "G4UIcmdWith3Vector.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4MaterialScanner.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4Tokenizer.hh"
|
||||
#include "G4UIcmdWith3Vector.hh"
|
||||
#include "G4UIcmdWith3VectorAndUnit.hh"
|
||||
#include "G4UIcmdWithABool.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIcommand.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIparameter.hh"
|
||||
|
||||
G4MatScanMessenger::G4MatScanMessenger(G4MaterialScanner* p1)
|
||||
{
|
||||
@@ -50,87 +50,100 @@ G4MatScanMessenger::G4MatScanMessenger(G4MaterialScanner* p1)
|
||||
msDirectory = new G4UIdirectory("/control/matScan/");
|
||||
msDirectory->SetGuidance("Material scanner commands.");
|
||||
|
||||
scanCmd = new G4UIcmdWithoutParameter("/control/matScan/scan",this);
|
||||
scanCmd = new G4UIcmdWithoutParameter("/control/matScan/scan", this);
|
||||
scanCmd->SetGuidance("Start material scanning.");
|
||||
scanCmd->SetGuidance("Scanning range should be defined with");
|
||||
scanCmd->SetGuidance("/control/matScan/theta and /control/matSca/phi commands.");
|
||||
scanCmd->SetGuidance(
|
||||
"/control/matScan/theta and /control/matSca/phi commands.");
|
||||
scanCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
thetaCmd = new G4UIcommand("/control/matScan/theta",this);
|
||||
thetaCmd = new G4UIcommand("/control/matScan/theta", this);
|
||||
thetaCmd->SetGuidance("Define theta range.");
|
||||
thetaCmd->SetGuidance("Usage : /control/matScan/theta [nbin] [thetaMin] [thetaSpan] [unit]");
|
||||
thetaCmd->SetGuidance(
|
||||
"Usage : /control/matScan/theta [nbin] [thetaMin] [thetaSpan] [unit]");
|
||||
thetaCmd->SetGuidance("Notation of angles :");
|
||||
thetaCmd->SetGuidance(" theta --- +Z axis : +90 deg. / X-Y plane : 0 deg. / -Z axis : -90 deg.");
|
||||
par = new G4UIparameter("nbin",'i',false);
|
||||
thetaCmd->SetGuidance(
|
||||
" theta --- +Z axis : +90 deg. / X-Y plane : 0 deg. / -Z axis : -90 deg.");
|
||||
par = new G4UIparameter("nbin", 'i', false);
|
||||
par->SetParameterRange("nbin>0");
|
||||
thetaCmd->SetParameter(par);
|
||||
par = new G4UIparameter("thetaMin",'d',false);
|
||||
par = new G4UIparameter("thetaMin", 'd', false);
|
||||
thetaCmd->SetParameter(par);
|
||||
par = new G4UIparameter("thetaSpan",'d',true);
|
||||
par = new G4UIparameter("thetaSpan", 'd', true);
|
||||
par->SetParameterRange("thetaSpan>=0.");
|
||||
par->SetDefaultValue(0.);
|
||||
thetaCmd->SetParameter(par);
|
||||
par = new G4UIparameter("unit",'c',true);
|
||||
par = new G4UIparameter("unit", 'c', true);
|
||||
par->SetDefaultValue("deg");
|
||||
par->SetParameterCandidates(thetaCmd->UnitsList(thetaCmd->CategoryOf("deg")));
|
||||
thetaCmd->SetParameter(par);
|
||||
|
||||
phiCmd = new G4UIcommand("/control/matScan/phi",this);
|
||||
phiCmd = new G4UIcommand("/control/matScan/phi", this);
|
||||
phiCmd->SetGuidance("Define phi range.");
|
||||
phiCmd->SetGuidance("Usage : /control/matScan/phi [nbin] [phiMin] [phiSpan] [unit]");
|
||||
phiCmd->SetGuidance(
|
||||
"Usage : /control/matScan/phi [nbin] [phiMin] [phiSpan] [unit]");
|
||||
phiCmd->SetGuidance("Notation of angles :");
|
||||
phiCmd->SetGuidance(" phi --- +X axis : 0 deg. / +Y axis : 90 deg. / -X axis : 180 deg. / -Y axis : 270 deg.");
|
||||
par = new G4UIparameter("nbin",'i',false);
|
||||
phiCmd->SetGuidance(
|
||||
" phi --- +X axis : 0 deg. / +Y axis : 90 deg. / -X axis : 180 "
|
||||
"deg. / -Y axis : 270 deg.");
|
||||
par = new G4UIparameter("nbin", 'i', false);
|
||||
par->SetParameterRange("nbin>0");
|
||||
phiCmd->SetParameter(par);
|
||||
par = new G4UIparameter("phiMin",'d',false);
|
||||
par = new G4UIparameter("phiMin", 'd', false);
|
||||
phiCmd->SetParameter(par);
|
||||
par = new G4UIparameter("phiSpan",'d',true);
|
||||
par = new G4UIparameter("phiSpan", 'd', true);
|
||||
par->SetParameterRange("phiSpan>=0.");
|
||||
par->SetDefaultValue(0.);
|
||||
phiCmd->SetParameter(par);
|
||||
par = new G4UIparameter("unit",'c',true);
|
||||
par = new G4UIparameter("unit", 'c', true);
|
||||
par->SetDefaultValue("deg");
|
||||
par->SetParameterCandidates(phiCmd->UnitsList(phiCmd->CategoryOf("deg")));
|
||||
phiCmd->SetParameter(par);
|
||||
|
||||
singleCmd = new G4UIcommand("/control/matScan/singleMeasure",this);
|
||||
singleCmd = new G4UIcommand("/control/matScan/singleMeasure", this);
|
||||
singleCmd->SetGuidance("Measure thickness for one particular direction.");
|
||||
singleCmd->SetGuidance("Notation of angles :");
|
||||
singleCmd->SetGuidance(" theta --- +Z axis : +90 deg. / X-Y plane : 0 deg. / -Z axis : -90 deg.");
|
||||
singleCmd->SetGuidance(" phi --- +X axis : 0 deg. / +Y axis : 90 deg. / -X axis : 180 deg. / -Y axis : 270 deg.");
|
||||
singleCmd->SetGuidance(
|
||||
" theta --- +Z axis : +90 deg. / X-Y plane : 0 deg. / -Z axis : -90 deg.");
|
||||
singleCmd->SetGuidance(
|
||||
" phi --- +X axis : 0 deg. / +Y axis : 90 deg. / -X axis : "
|
||||
"180 deg. / -Y axis : 270 deg.");
|
||||
singleCmd->AvailableForStates(G4State_Idle);
|
||||
par = new G4UIparameter("theta",'d',false);
|
||||
par = new G4UIparameter("theta", 'd', false);
|
||||
singleCmd->SetParameter(par);
|
||||
par = new G4UIparameter("phi",'d',false);
|
||||
par = new G4UIparameter("phi", 'd', false);
|
||||
singleCmd->SetParameter(par);
|
||||
par = new G4UIparameter("unit",'c',true);
|
||||
par = new G4UIparameter("unit", 'c', true);
|
||||
par->SetDefaultValue("deg");
|
||||
par->SetParameterCandidates(singleCmd->UnitsList(singleCmd->CategoryOf("deg")));
|
||||
par->SetParameterCandidates(
|
||||
singleCmd->UnitsList(singleCmd->CategoryOf("deg")));
|
||||
singleCmd->SetParameter(par);
|
||||
|
||||
single2Cmd = new G4UIcmdWith3Vector("/control/matScan/singleTo",this);
|
||||
single2Cmd->SetGuidance("Measure thickness for one direction defined by a unit vector.");
|
||||
single2Cmd->SetParameterName("X","Y","Z",false);
|
||||
single2Cmd = new G4UIcmdWith3Vector("/control/matScan/singleTo", this);
|
||||
single2Cmd->SetGuidance(
|
||||
"Measure thickness for one direction defined by a unit vector.");
|
||||
single2Cmd->SetParameterName("X", "Y", "Z", false);
|
||||
|
||||
eyePosCmd = new G4UIcmdWith3VectorAndUnit("/control/matScan/eyePosition",this);
|
||||
eyePosCmd =
|
||||
new G4UIcmdWith3VectorAndUnit("/control/matScan/eyePosition", this);
|
||||
eyePosCmd->SetGuidance("Define the eye position.");
|
||||
eyePosCmd->SetParameterName("X","Y","Z",true);
|
||||
eyePosCmd->SetDefaultValue(G4ThreeVector(0.,0.,0.));
|
||||
eyePosCmd->SetParameterName("X", "Y", "Z", true);
|
||||
eyePosCmd->SetDefaultValue(G4ThreeVector(0., 0., 0.));
|
||||
eyePosCmd->SetDefaultUnit("m");
|
||||
|
||||
regSenseCmd = new G4UIcmdWithABool("/control/matScan/regionSensitive",this);
|
||||
regSenseCmd = new G4UIcmdWithABool("/control/matScan/regionSensitive", this);
|
||||
regSenseCmd->SetGuidance("Set region sensitivity.");
|
||||
regSenseCmd->SetGuidance("This command is automatically set to TRUE");
|
||||
regSenseCmd->SetGuidance(" if /control/matScan/region command is issued.");
|
||||
regSenseCmd->SetParameterName("senseFlag",true);
|
||||
regSenseCmd->SetParameterName("senseFlag", true);
|
||||
regSenseCmd->SetDefaultValue(false);
|
||||
|
||||
regionCmd = new G4UIcmdWithAString("/control/matScan/region",this);
|
||||
regionCmd = new G4UIcmdWithAString("/control/matScan/region", this);
|
||||
regionCmd->SetGuidance("Define region name to be scanned.");
|
||||
regionCmd->SetGuidance("/control/matScan/regionSensitive command is automatically");
|
||||
regionCmd->SetGuidance(
|
||||
"/control/matScan/regionSensitive command is automatically");
|
||||
regionCmd->SetGuidance("set to TRUE with this command.");
|
||||
regionCmd->SetParameterName("region",true);
|
||||
regionCmd->SetParameterName("region", true);
|
||||
regionCmd->SetDefaultValue("DefaultRegionForTheWorld");
|
||||
}
|
||||
|
||||
@@ -147,95 +160,114 @@ G4MatScanMessenger::~G4MatScanMessenger()
|
||||
delete msDirectory;
|
||||
}
|
||||
|
||||
G4String G4MatScanMessenger::GetCurrentValue(G4UIcommand * command)
|
||||
G4String G4MatScanMessenger::GetCurrentValue(G4UIcommand* command)
|
||||
{
|
||||
G4String currentValue;
|
||||
if(command==thetaCmd)
|
||||
if(command == thetaCmd)
|
||||
{
|
||||
currentValue = thetaCmd->ConvertToString(theScanner->GetNTheta());
|
||||
currentValue += " ";
|
||||
currentValue += thetaCmd->ConvertToString((theScanner->GetThetaMin())/deg);
|
||||
currentValue += " ";
|
||||
currentValue += thetaCmd->ConvertToString((theScanner->GetThetaSpan())/deg);
|
||||
currentValue = thetaCmd->ConvertToString(theScanner->GetNTheta());
|
||||
currentValue += " ";
|
||||
currentValue +=
|
||||
thetaCmd->ConvertToString((theScanner->GetThetaMin()) / deg);
|
||||
currentValue += " ";
|
||||
currentValue +=
|
||||
thetaCmd->ConvertToString((theScanner->GetThetaSpan()) / deg);
|
||||
}
|
||||
else if(command==phiCmd)
|
||||
else if(command == phiCmd)
|
||||
{
|
||||
currentValue = phiCmd->ConvertToString(theScanner->GetNPhi());
|
||||
currentValue += " ";
|
||||
currentValue += phiCmd->ConvertToString((theScanner->GetPhiMin())/deg);
|
||||
currentValue += " ";
|
||||
currentValue += phiCmd->ConvertToString((theScanner->GetPhiSpan())/deg);
|
||||
currentValue = phiCmd->ConvertToString(theScanner->GetNPhi());
|
||||
currentValue += " ";
|
||||
currentValue += phiCmd->ConvertToString((theScanner->GetPhiMin()) / deg);
|
||||
currentValue += " ";
|
||||
currentValue += phiCmd->ConvertToString((theScanner->GetPhiSpan()) / deg);
|
||||
}
|
||||
else if(command == eyePosCmd)
|
||||
{
|
||||
currentValue =
|
||||
eyePosCmd->ConvertToString(theScanner->GetEyePosition(), "m");
|
||||
}
|
||||
else if(command == regSenseCmd)
|
||||
{
|
||||
currentValue =
|
||||
regSenseCmd->ConvertToString(theScanner->GetRegionSensitive());
|
||||
}
|
||||
else if(command == regionCmd)
|
||||
{
|
||||
currentValue = theScanner->GetRegionName();
|
||||
}
|
||||
else if(command==eyePosCmd)
|
||||
{ currentValue = eyePosCmd->ConvertToString(theScanner->GetEyePosition(),"m"); }
|
||||
else if(command==regSenseCmd)
|
||||
{ currentValue = regSenseCmd->ConvertToString(theScanner->GetRegionSensitive()); }
|
||||
else if(command==regionCmd)
|
||||
{ currentValue = theScanner->GetRegionName(); }
|
||||
return currentValue;
|
||||
}
|
||||
|
||||
void G4MatScanMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
|
||||
void G4MatScanMessenger::SetNewValue(G4UIcommand* command, G4String newValue)
|
||||
{
|
||||
if(command==scanCmd)
|
||||
{ theScanner->Scan(); }
|
||||
else if(command==thetaCmd)
|
||||
if(command == scanCmd)
|
||||
{
|
||||
G4Tokenizer next( newValue );
|
||||
G4int nbin = StoI(next());
|
||||
G4double thetaMin = StoD(next());
|
||||
theScanner->Scan();
|
||||
}
|
||||
else if(command == thetaCmd)
|
||||
{
|
||||
G4Tokenizer next(newValue);
|
||||
G4int nbin = StoI(next());
|
||||
G4double thetaMin = StoD(next());
|
||||
G4double thetaSpan = StoD(next());
|
||||
G4String unit = next();
|
||||
G4String unit = next();
|
||||
thetaMin *= thetaCmd->ValueOf(unit);
|
||||
thetaSpan *= thetaCmd->ValueOf(unit);
|
||||
theScanner->SetNTheta(nbin);
|
||||
theScanner->SetThetaMin(thetaMin);
|
||||
theScanner->SetThetaSpan(thetaSpan);
|
||||
}
|
||||
else if(command==phiCmd)
|
||||
else if(command == phiCmd)
|
||||
{
|
||||
G4Tokenizer next( newValue );
|
||||
G4int nbin = StoI(next());
|
||||
G4double phiMin = StoD(next());
|
||||
G4Tokenizer next(newValue);
|
||||
G4int nbin = StoI(next());
|
||||
G4double phiMin = StoD(next());
|
||||
G4double phiSpan = StoD(next());
|
||||
G4String unit = next();
|
||||
G4String unit = next();
|
||||
phiMin *= phiCmd->ValueOf(unit);
|
||||
phiSpan *= phiCmd->ValueOf(unit);
|
||||
theScanner->SetNPhi(nbin);
|
||||
theScanner->SetPhiMin(phiMin);
|
||||
theScanner->SetPhiSpan(phiSpan);
|
||||
}
|
||||
else if(command==eyePosCmd)
|
||||
{ theScanner->SetEyePosition(eyePosCmd->GetNew3VectorValue(newValue)); }
|
||||
else if(command==regSenseCmd)
|
||||
{ theScanner->SetRegionSensitive(regSenseCmd->GetNewBoolValue(newValue)); }
|
||||
else if(command==regionCmd)
|
||||
{ if(theScanner->SetRegionName(newValue)) theScanner->SetRegionSensitive(true); }
|
||||
else if(command==singleCmd || command==single2Cmd)
|
||||
else if(command == eyePosCmd)
|
||||
{
|
||||
G4int ntheta = theScanner->GetNTheta();
|
||||
G4double thetaMin = theScanner->GetThetaMin();
|
||||
theScanner->SetEyePosition(eyePosCmd->GetNew3VectorValue(newValue));
|
||||
}
|
||||
else if(command == regSenseCmd)
|
||||
{
|
||||
theScanner->SetRegionSensitive(regSenseCmd->GetNewBoolValue(newValue));
|
||||
}
|
||||
else if(command == regionCmd)
|
||||
{
|
||||
if(theScanner->SetRegionName(newValue))
|
||||
theScanner->SetRegionSensitive(true);
|
||||
}
|
||||
else if(command == singleCmd || command == single2Cmd)
|
||||
{
|
||||
G4int ntheta = theScanner->GetNTheta();
|
||||
G4double thetaMin = theScanner->GetThetaMin();
|
||||
G4double thetaSpan = theScanner->GetThetaSpan();
|
||||
G4int nphi = theScanner->GetNPhi();
|
||||
G4double phiMin = theScanner->GetPhiMin();
|
||||
G4double phiSpan = theScanner->GetPhiSpan();
|
||||
G4int nphi = theScanner->GetNPhi();
|
||||
G4double phiMin = theScanner->GetPhiMin();
|
||||
G4double phiSpan = theScanner->GetPhiSpan();
|
||||
|
||||
G4double theta = 0.;
|
||||
G4double phi = 0.;
|
||||
if(command==singleCmd)
|
||||
G4double phi = 0.;
|
||||
if(command == singleCmd)
|
||||
{
|
||||
G4Tokenizer next( newValue );
|
||||
theta = StoD(next());
|
||||
phi = StoD(next());
|
||||
G4Tokenizer next(newValue);
|
||||
theta = StoD(next());
|
||||
phi = StoD(next());
|
||||
G4String unit = next();
|
||||
theta *= singleCmd->ValueOf(unit);
|
||||
phi *= singleCmd->ValueOf(unit);
|
||||
}
|
||||
else if(command==single2Cmd)
|
||||
else if(command == single2Cmd)
|
||||
{
|
||||
G4ThreeVector v = single2Cmd->GetNew3VectorValue(newValue);
|
||||
theta = 90.*deg - v.theta();
|
||||
phi = v.phi();
|
||||
theta = 90. * deg - v.theta();
|
||||
phi = v.phi();
|
||||
}
|
||||
theScanner->SetNTheta(1);
|
||||
theScanner->SetThetaMin(theta);
|
||||
@@ -252,10 +284,4 @@ void G4MatScanMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
|
||||
theScanner->SetPhiMin(phiMin);
|
||||
theScanner->SetPhiSpan(phiSpan);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -30,50 +30,49 @@
|
||||
|
||||
#include "G4MaterialScanner.hh"
|
||||
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4EventManager.hh"
|
||||
#include "G4MatScanMessenger.hh"
|
||||
#include "G4RayShooter.hh"
|
||||
#include "G4MSSteppingAction.hh"
|
||||
#include "G4GeometryManager.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4Event.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4RunManagerKernel.hh"
|
||||
#include "G4Region.hh"
|
||||
#include "G4RegionStore.hh"
|
||||
#include "G4EventManager.hh"
|
||||
#include "G4GeometryManager.hh"
|
||||
#include "G4MSSteppingAction.hh"
|
||||
#include "G4MatScanMessenger.hh"
|
||||
#include "G4ProcessManager.hh"
|
||||
#include "G4ProcessVector.hh"
|
||||
#include "G4RayShooter.hh"
|
||||
#include "G4Region.hh"
|
||||
#include "G4RegionStore.hh"
|
||||
#include "G4RunManagerKernel.hh"
|
||||
#include "G4SDManager.hh"
|
||||
|
||||
#include "G4StateManager.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
|
||||
G4MaterialScanner::G4MaterialScanner()
|
||||
{
|
||||
theRayShooter = new G4RayShooter();
|
||||
theMessenger = new G4MatScanMessenger(this);
|
||||
theRayShooter = new G4RayShooter();
|
||||
theMessenger = new G4MatScanMessenger(this);
|
||||
theEventManager = G4EventManager::GetEventManager();
|
||||
|
||||
theUserEventAction = 0;
|
||||
theUserEventAction = 0;
|
||||
theUserStackingAction = 0;
|
||||
theUserTrackingAction = 0;
|
||||
theUserSteppingAction = 0;
|
||||
|
||||
theMatScannerEventAction = 0;
|
||||
theMatScannerEventAction = 0;
|
||||
theMatScannerStackingAction = 0;
|
||||
theMatScannerTrackingAction = 0;
|
||||
theMatScannerSteppingAction = 0;
|
||||
|
||||
eyePosition = G4ThreeVector(0.,0.,0.);
|
||||
nTheta = 91;
|
||||
thetaMin = 0.*deg;
|
||||
thetaSpan = 90.*deg;
|
||||
nPhi = 37;
|
||||
phiMin = 0.*deg;
|
||||
phiSpan = 360.*deg;
|
||||
eyePosition = G4ThreeVector(0., 0., 0.);
|
||||
nTheta = 91;
|
||||
thetaMin = 0. * deg;
|
||||
thetaSpan = 90. * deg;
|
||||
nPhi = 37;
|
||||
phiMin = 0. * deg;
|
||||
phiSpan = 360. * deg;
|
||||
|
||||
regionSensitive = false;
|
||||
regionName = "notDefined";
|
||||
theRegion = 0;
|
||||
regionName = "notDefined";
|
||||
theRegion = 0;
|
||||
}
|
||||
|
||||
G4MaterialScanner::~G4MaterialScanner()
|
||||
@@ -85,24 +84,26 @@ G4MaterialScanner::~G4MaterialScanner()
|
||||
|
||||
void G4MaterialScanner::Scan()
|
||||
{
|
||||
G4StateManager* theStateMan = G4StateManager::GetStateManager();
|
||||
G4StateManager* theStateMan = G4StateManager::GetStateManager();
|
||||
G4ApplicationState currentState = theStateMan->GetCurrentState();
|
||||
if(currentState!=G4State_Idle)
|
||||
if(currentState != G4State_Idle)
|
||||
{
|
||||
G4cerr << "Illegal application state - Scan() ignored." << G4endl;
|
||||
return;
|
||||
}
|
||||
|
||||
if(!theMatScannerSteppingAction)
|
||||
{ theMatScannerSteppingAction = new G4MSSteppingAction(); }
|
||||
{
|
||||
theMatScannerSteppingAction = new G4MSSteppingAction();
|
||||
}
|
||||
StoreUserActions();
|
||||
DoScan();
|
||||
RestoreUserActions();
|
||||
}
|
||||
|
||||
void G4MaterialScanner::StoreUserActions()
|
||||
{
|
||||
theUserEventAction = theEventManager->GetUserEventAction();
|
||||
{
|
||||
theUserEventAction = theEventManager->GetUserEventAction();
|
||||
theUserStackingAction = theEventManager->GetUserStackingAction();
|
||||
theUserTrackingAction = theEventManager->GetUserTrackingAction();
|
||||
theUserSteppingAction = theEventManager->GetUserSteppingAction();
|
||||
@@ -114,7 +115,9 @@ void G4MaterialScanner::StoreUserActions()
|
||||
|
||||
G4SDManager* theSDMan = G4SDManager::GetSDMpointerIfExist();
|
||||
if(theSDMan)
|
||||
{ theSDMan->Activate("/",false); }
|
||||
{
|
||||
theSDMan->Activate("/", false);
|
||||
}
|
||||
|
||||
G4GeometryManager* theGeomMan = G4GeometryManager::GetInstance();
|
||||
theGeomMan->OpenGeometry();
|
||||
@@ -130,82 +133,87 @@ void G4MaterialScanner::RestoreUserActions()
|
||||
|
||||
G4SDManager* theSDMan = G4SDManager::GetSDMpointerIfExist();
|
||||
if(theSDMan)
|
||||
{ theSDMan->Activate("/",true); }
|
||||
{
|
||||
theSDMan->Activate("/", true);
|
||||
}
|
||||
}
|
||||
|
||||
void G4MaterialScanner::DoScan()
|
||||
{
|
||||
// Confirm material table is updated
|
||||
// Confirm material table is updated
|
||||
G4RunManagerKernel::GetRunManagerKernel()->UpdateRegion();
|
||||
|
||||
///// // Make sure Geantino has been initialized
|
||||
///// G4ProcessVector* pVector
|
||||
///// = G4Geantino::GeantinoDefinition()->GetProcessManager()->GetProcessList();
|
||||
///// for (G4int j=0; j < pVector->size(); ++j) {
|
||||
///// (*pVector)[j]->BuildPhysicsTable(*(G4Geantino::GeantinoDefinition()));
|
||||
///// }
|
||||
///// // Make sure Geantino has been initialized
|
||||
///// G4ProcessVector* pVector
|
||||
///// =
|
||||
///G4Geantino::GeantinoDefinition()->GetProcessManager()->GetProcessList();
|
||||
///// for (G4int j=0; j < pVector->size(); ++j) {
|
||||
///// (*pVector)[j]->BuildPhysicsTable(*(G4Geantino::GeantinoDefinition()));
|
||||
///// }
|
||||
|
||||
// Close geometry and set the application state
|
||||
// Close geometry and set the application state
|
||||
G4GeometryManager* geomManager = G4GeometryManager::GetInstance();
|
||||
geomManager->OpenGeometry();
|
||||
geomManager->CloseGeometry(1,0);
|
||||
|
||||
G4ThreeVector center(0,0,0);
|
||||
G4Navigator* navigator =
|
||||
G4TransportationManager::GetTransportationManager()->GetNavigatorForTracking();
|
||||
navigator->LocateGlobalPointAndSetup(center,0,false);
|
||||
geomManager->CloseGeometry(1, 0);
|
||||
|
||||
G4ThreeVector center(0, 0, 0);
|
||||
G4Navigator* navigator = G4TransportationManager::GetTransportationManager()
|
||||
->GetNavigatorForTracking();
|
||||
navigator->LocateGlobalPointAndSetup(center, 0, false);
|
||||
|
||||
G4StateManager* theStateMan = G4StateManager::GetStateManager();
|
||||
theStateMan->SetNewState(G4State_GeomClosed);
|
||||
theStateMan->SetNewState(G4State_GeomClosed);
|
||||
|
||||
// Event loop
|
||||
// Event loop
|
||||
G4int iEvent = 0;
|
||||
for(G4int iTheta=0;iTheta<nTheta;iTheta++)
|
||||
for(G4int iTheta = 0; iTheta < nTheta; iTheta++)
|
||||
{
|
||||
G4double theta = thetaMin;
|
||||
if(iTheta>0) theta += G4double(iTheta)*thetaSpan/G4double(nTheta-1);
|
||||
G4double aveLength = 0.;
|
||||
G4double aveX0 = 0.;
|
||||
G4double aveLambda = 0.;
|
||||
G4cout << G4endl;
|
||||
G4cout << " Theta(deg) Phi(deg) Length(mm) x0 lambda0" << G4endl;
|
||||
G4cout << G4endl;
|
||||
for(G4int iPhi=0;iPhi<nPhi;iPhi++)
|
||||
{
|
||||
G4Event* anEvent = new G4Event(iEvent++);
|
||||
G4double phi = phiMin;
|
||||
if(iPhi>0) phi += G4double(iPhi)*phiSpan/G4double(nPhi-1);
|
||||
eyeDirection = G4ThreeVector(std::cos(theta)*std::cos(phi),
|
||||
std::cos(theta)*std::sin(phi),
|
||||
std::sin(theta));
|
||||
theRayShooter->Shoot(anEvent,eyePosition,eyeDirection);
|
||||
theMatScannerSteppingAction->Initialize(regionSensitive,theRegion);
|
||||
theEventManager->ProcessOneEvent(anEvent);
|
||||
G4double length = theMatScannerSteppingAction->GetTotalStepLength();
|
||||
G4double x0 = theMatScannerSteppingAction->GetX0();
|
||||
G4double lambda = theMatScannerSteppingAction->GetLambda0();
|
||||
|
||||
G4cout << " "
|
||||
<< std::setw(11) << theta/deg << " "
|
||||
<< std::setw(11) << phi/deg << " "
|
||||
<< std::setw(11) << length/mm << " "
|
||||
<< std::setw(11) << x0 << " "
|
||||
<< std::setw(11) << lambda << G4endl;
|
||||
aveLength += length/mm;
|
||||
aveX0 += x0;
|
||||
aveLambda += lambda;
|
||||
}
|
||||
if(nPhi>1)
|
||||
{
|
||||
G4double theta = thetaMin;
|
||||
if(iTheta > 0)
|
||||
theta += G4double(iTheta) * thetaSpan / G4double(nTheta - 1);
|
||||
G4double aveLength = 0.;
|
||||
G4double aveX0 = 0.;
|
||||
G4double aveLambda = 0.;
|
||||
G4cout << G4endl;
|
||||
G4cout << " ave. for theta = " << std::setw(11) << theta/deg << " : "
|
||||
<< std::setw(11) << aveLength/nPhi << " "
|
||||
<< std::setw(11) << aveX0/nPhi << " "
|
||||
<< std::setw(11) << aveLambda/nPhi << G4endl;
|
||||
}
|
||||
G4cout
|
||||
<< " Theta(deg) Phi(deg) Length(mm) x0 lambda0"
|
||||
<< G4endl;
|
||||
G4cout << G4endl;
|
||||
for(G4int iPhi = 0; iPhi < nPhi; iPhi++)
|
||||
{
|
||||
G4Event* anEvent = new G4Event(iEvent++);
|
||||
G4double phi = phiMin;
|
||||
if(iPhi > 0)
|
||||
phi += G4double(iPhi) * phiSpan / G4double(nPhi - 1);
|
||||
eyeDirection =
|
||||
G4ThreeVector(std::cos(theta) * std::cos(phi),
|
||||
std::cos(theta) * std::sin(phi), std::sin(theta));
|
||||
theRayShooter->Shoot(anEvent, eyePosition, eyeDirection);
|
||||
theMatScannerSteppingAction->Initialize(regionSensitive, theRegion);
|
||||
theEventManager->ProcessOneEvent(anEvent);
|
||||
G4double length = theMatScannerSteppingAction->GetTotalStepLength();
|
||||
G4double x0 = theMatScannerSteppingAction->GetX0();
|
||||
G4double lambda = theMatScannerSteppingAction->GetLambda0();
|
||||
|
||||
G4cout << " " << std::setw(11) << theta / deg << " "
|
||||
<< std::setw(11) << phi / deg << " " << std::setw(11)
|
||||
<< length / mm << " " << std::setw(11) << x0 << " "
|
||||
<< std::setw(11) << lambda << G4endl;
|
||||
aveLength += length / mm;
|
||||
aveX0 += x0;
|
||||
aveLambda += lambda;
|
||||
}
|
||||
if(nPhi > 1)
|
||||
{
|
||||
G4cout << G4endl;
|
||||
G4cout << " ave. for theta = " << std::setw(11) << theta / deg << " : "
|
||||
<< std::setw(11) << aveLength / nPhi << " " << std::setw(11)
|
||||
<< aveX0 / nPhi << " " << std::setw(11) << aveLambda / nPhi
|
||||
<< G4endl;
|
||||
}
|
||||
}
|
||||
|
||||
theStateMan->SetNewState(G4State_Idle);
|
||||
theStateMan->SetNewState(G4State_Idle);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -214,7 +222,7 @@ G4bool G4MaterialScanner::SetRegionName(const G4String& val)
|
||||
G4Region* aRegion = G4RegionStore::GetInstance()->GetRegion(val);
|
||||
if(aRegion)
|
||||
{
|
||||
theRegion = aRegion;
|
||||
theRegion = aRegion;
|
||||
regionName = val;
|
||||
return true;
|
||||
}
|
||||
@@ -222,8 +230,10 @@ G4bool G4MaterialScanner::SetRegionName(const G4String& val)
|
||||
{
|
||||
G4cerr << "Region <" << val << "> not found. Command ignored." << G4endl;
|
||||
G4cerr << "Defined regions are : " << G4endl;
|
||||
for(size_t i=0;i<G4RegionStore::GetInstance()->size();i++)
|
||||
{ G4cerr << " " << (*(G4RegionStore::GetInstance()))[i]->GetName(); }
|
||||
for(size_t i = 0; i < G4RegionStore::GetInstance()->size(); i++)
|
||||
{
|
||||
G4cerr << " " << (*(G4RegionStore::GetInstance()))[i]->GetName();
|
||||
}
|
||||
G4cerr << G4endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -39,38 +39,40 @@
|
||||
#include "G4Run.hh"
|
||||
#include <algorithm>
|
||||
|
||||
G4Run* G4MultiRunAction::GenerateRun() {
|
||||
G4Run* G4MultiRunAction::GenerateRun()
|
||||
{
|
||||
G4Run* aRun = nullptr;
|
||||
for ( auto& ru : *this ) {
|
||||
auto anotherRun = ru->GenerateRun();
|
||||
if ( aRun != nullptr && anotherRun != nullptr ) {
|
||||
G4Exception("G4MultiRunAction::GenerateRun()","Run0036",FatalException,
|
||||
"More than one registered UserRunAction return an instance"\
|
||||
" of G4Run, not allowed.");
|
||||
return nullptr;
|
||||
}
|
||||
if( anotherRun != nullptr) aRun = anotherRun;
|
||||
for(auto& ru : *this)
|
||||
{
|
||||
auto anotherRun = ru->GenerateRun();
|
||||
if(aRun != nullptr && anotherRun != nullptr)
|
||||
{
|
||||
G4Exception("G4MultiRunAction::GenerateRun()", "Run0036", FatalException,
|
||||
"More than one registered UserRunAction return an instance"
|
||||
" of G4Run, not allowed.");
|
||||
return nullptr;
|
||||
}
|
||||
if(anotherRun != nullptr)
|
||||
aRun = anotherRun;
|
||||
}
|
||||
return aRun;
|
||||
}
|
||||
|
||||
void G4MultiRunAction::BeginOfRunAction(const G4Run* run) {
|
||||
std::for_each( begin() , end() ,
|
||||
[run](G4UserRunActionUPtr& e) { e->BeginOfRunAction(run); }
|
||||
);
|
||||
void G4MultiRunAction::BeginOfRunAction(const G4Run* run)
|
||||
{
|
||||
std::for_each(begin(), end(),
|
||||
[run](G4UserRunActionUPtr& e) { e->BeginOfRunAction(run); });
|
||||
}
|
||||
|
||||
void G4MultiRunAction::EndOfRunAction(const G4Run* run) {
|
||||
std::for_each( begin() , end() ,
|
||||
[run](G4UserRunActionUPtr& e) { e->EndOfRunAction(run); }
|
||||
);
|
||||
void G4MultiRunAction::EndOfRunAction(const G4Run* run)
|
||||
{
|
||||
std::for_each(begin(), end(),
|
||||
[run](G4UserRunActionUPtr& e) { e->EndOfRunAction(run); });
|
||||
}
|
||||
|
||||
void G4MultiRunAction::SetMaster(G4bool val) {
|
||||
void G4MultiRunAction::SetMaster(G4bool val)
|
||||
{
|
||||
G4UserRunAction::SetMaster(val);
|
||||
std::for_each( begin() , end() ,
|
||||
[val](G4UserRunActionUPtr& e) { e->SetMaster(val); }
|
||||
);
|
||||
|
||||
std::for_each(begin(), end(),
|
||||
[val](G4UserRunActionUPtr& e) { e->SetMaster(val); });
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -25,24 +25,24 @@
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
// 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
|
||||
// first version 29 Apr. 2011 by H.Kurashige
|
||||
// ------------------------------------------------------------
|
||||
|
||||
#include "G4PhysicsListOrderingParameter.hh"
|
||||
|
||||
G4PhysicsListOrderingParameter::G4PhysicsListOrderingParameter()
|
||||
: processTypeName("NONE"),
|
||||
processType(-1),
|
||||
processSubType(-1),
|
||||
isDuplicable(false)
|
||||
: processTypeName("NONE")
|
||||
, processType(-1)
|
||||
, processSubType(-1)
|
||||
, isDuplicable(false)
|
||||
{
|
||||
for(size_t i=0; i<3; i++) ordering[i] = -1;
|
||||
for(size_t i = 0; i < 3; i++)
|
||||
ordering[i] = -1;
|
||||
}
|
||||
|
||||
G4PhysicsListOrderingParameter::~G4PhysicsListOrderingParameter()
|
||||
{}
|
||||
G4PhysicsListOrderingParameter::~G4PhysicsListOrderingParameter() {}
|
||||
|
||||
@@ -27,23 +27,24 @@
|
||||
|
||||
namespace
|
||||
{
|
||||
G4PhysicsListWorkspace::pool_type thePool;
|
||||
G4PhysicsListWorkspace::pool_type thePool;
|
||||
}
|
||||
|
||||
G4PhysicsListWorkspace::pool_type*
|
||||
G4PhysicsListWorkspace::GetPool() { return &thePool; }
|
||||
G4PhysicsListWorkspace::pool_type* G4PhysicsListWorkspace::GetPool()
|
||||
{
|
||||
return &thePool;
|
||||
}
|
||||
|
||||
G4PhysicsListWorkspace::G4PhysicsListWorkspace(G4bool verbose)
|
||||
: fVerbose(verbose)
|
||||
: fVerbose(verbose)
|
||||
{
|
||||
|
||||
fpVUPLSIM =
|
||||
&const_cast<G4VUPLManager&>(G4VUserPhysicsList::GetSubInstanceManager());
|
||||
fpVPCSIM =
|
||||
&const_cast<G4VPCManager&>(G4VPhysicsConstructor::GetSubInstanceManager());
|
||||
fpVMPLSIM =
|
||||
&const_cast<G4VMPLManager&>(G4VModularPhysicsList::GetSubInstanceManager());
|
||||
|
||||
|
||||
// Copy information from master into PolyCone/Gon Sides in this thread.
|
||||
InitialiseWorkspace();
|
||||
|
||||
@@ -53,65 +54,59 @@ G4PhysicsListWorkspace::G4PhysicsListWorkspace(G4bool verbose)
|
||||
fpVMPLOffset = fpVMPLSIM->GetOffset();
|
||||
}
|
||||
|
||||
G4PhysicsListWorkspace::~G4PhysicsListWorkspace()
|
||||
{
|
||||
}
|
||||
G4PhysicsListWorkspace::~G4PhysicsListWorkspace() {}
|
||||
|
||||
void
|
||||
G4PhysicsListWorkspace::UseWorkspace()
|
||||
void G4PhysicsListWorkspace::UseWorkspace()
|
||||
{
|
||||
if( fVerbose )
|
||||
G4cout << "G4PhysicsListWorkspace::UseWorkspace: "
|
||||
<< "Copying particles-definition Split-Class - Start " << G4endl;
|
||||
if(fVerbose)
|
||||
G4cout << "G4PhysicsListWorkspace::UseWorkspace: "
|
||||
<< "Copying particles-definition Split-Class - Start " << G4endl;
|
||||
|
||||
// Implementation copied from
|
||||
// G4WorkerThread::BuildGeometryAndPhysicsVector()
|
||||
|
||||
// Physics List related, split classes mechanism:
|
||||
// instantiate sub-instance for this thread
|
||||
fpVUPLSIM->UseWorkArea(fpVUPLOffset);
|
||||
fpVPCSIM->UseWorkArea(fpVPCOffset);
|
||||
fpVMPLSIM->UseWorkArea(fpVMPLOffset);
|
||||
// Implementation copied from
|
||||
// G4WorkerThread::BuildGeometryAndPhysicsVector()
|
||||
|
||||
// Physics List related, split classes mechanism:
|
||||
// instantiate sub-instance for this thread
|
||||
fpVUPLSIM->UseWorkArea(fpVUPLOffset);
|
||||
fpVPCSIM->UseWorkArea(fpVPCOffset);
|
||||
fpVMPLSIM->UseWorkArea(fpVMPLOffset);
|
||||
}
|
||||
|
||||
void G4PhysicsListWorkspace::ReleaseWorkspace()
|
||||
{
|
||||
fpVUPLSIM->UseWorkArea(0);
|
||||
fpVPCSIM->UseWorkArea(0);
|
||||
fpVMPLSIM->UseWorkArea(0);
|
||||
fpVUPLSIM->UseWorkArea(0);
|
||||
fpVPCSIM->UseWorkArea(0);
|
||||
fpVMPLSIM->UseWorkArea(0);
|
||||
}
|
||||
|
||||
void G4PhysicsListWorkspace::InitialisePhysicsList()
|
||||
{
|
||||
}
|
||||
void G4PhysicsListWorkspace::InitialisePhysicsList() {}
|
||||
|
||||
void
|
||||
G4PhysicsListWorkspace::InitialiseWorkspace()
|
||||
void G4PhysicsListWorkspace::InitialiseWorkspace()
|
||||
{
|
||||
if( fVerbose )
|
||||
G4cout << "G4PhysicsListWorkspace::InitialiseWorkspace: "
|
||||
<< "Copying particles-definition Split-Class - Start " << G4endl;
|
||||
|
||||
// PhysicsList related, split classes mechanism:
|
||||
// Do *NOT* instantiate sub-instance for this thread,
|
||||
// just copy the contents !!
|
||||
fpVUPLSIM->NewSubInstances();
|
||||
fpVPCSIM->NewSubInstances();
|
||||
// The following line is fundamental! If we call NewSubInstances it will not work
|
||||
// See: https://jira-geant4.kek.jp/browse/DEV-284
|
||||
fpVMPLSIM->WorkerCopySubInstanceArray();
|
||||
if(fVerbose)
|
||||
G4cout << "G4PhysicsListWorkspace::InitialiseWorkspace: "
|
||||
<< "Copying particles-definition Split-Class - Start " << G4endl;
|
||||
|
||||
// Additional initialization if needed - beyond copying memory
|
||||
InitialisePhysicsList();
|
||||
|
||||
if( fVerbose )
|
||||
G4cout << "G4PhysicsListWorkspace::CreateAndUseWorkspace: "
|
||||
<< "Copying particles-definition Split-Class - Done!" << G4endl;
|
||||
// PhysicsList related, split classes mechanism:
|
||||
// Do *NOT* instantiate sub-instance for this thread,
|
||||
// just copy the contents !!
|
||||
fpVUPLSIM->NewSubInstances();
|
||||
fpVPCSIM->NewSubInstances();
|
||||
// The following line is fundamental! If we call NewSubInstances it will not
|
||||
// work See: https://jira-geant4.kek.jp/browse/DEV-284
|
||||
fpVMPLSIM->WorkerCopySubInstanceArray();
|
||||
|
||||
// Additional initialization if needed - beyond copying memory
|
||||
InitialisePhysicsList();
|
||||
|
||||
if(fVerbose)
|
||||
G4cout << "G4PhysicsListWorkspace::CreateAndUseWorkspace: "
|
||||
<< "Copying particles-definition Split-Class - Done!" << G4endl;
|
||||
}
|
||||
|
||||
void G4PhysicsListWorkspace::DestroyWorkspace()
|
||||
{
|
||||
fpVUPLSIM->FreeWorker();
|
||||
fpVPCSIM->FreeWorker();
|
||||
fpVMPLSIM->FreeWorker();
|
||||
fpVUPLSIM->FreeWorker();
|
||||
fpVPCSIM->FreeWorker();
|
||||
fpVMPLSIM->FreeWorker();
|
||||
}
|
||||
|
||||
@@ -27,58 +27,59 @@
|
||||
#include "G4RNGHelper.hh"
|
||||
#include "Randomize.hh"
|
||||
|
||||
template<>
|
||||
template <>
|
||||
G4TemplateRNGHelper<G4long>* G4TemplateRNGHelper<G4long>::instance = 0;
|
||||
|
||||
template<>
|
||||
template <>
|
||||
G4TemplateRNGHelper<G4String>* G4TemplateRNGHelper<G4String>::instance = 0;
|
||||
|
||||
template<class T>
|
||||
template <class T>
|
||||
G4TemplateRNGHelper<T>* G4TemplateRNGHelper<T>::GetInstance()
|
||||
{
|
||||
if (!instance)
|
||||
if(!instance)
|
||||
{
|
||||
instance = new G4TemplateRNGHelper<T>();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
template<class T>
|
||||
template <class T>
|
||||
G4TemplateRNGHelper<T>* G4TemplateRNGHelper<T>::GetInstanceIfExist()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
template<>
|
||||
template <>
|
||||
G4TemplateRNGHelper<G4long>* G4TemplateRNGHelper<G4long>::GetInstance()
|
||||
{
|
||||
if (!instance)
|
||||
if(!instance)
|
||||
{
|
||||
instance = new G4TemplateRNGHelper<G4long>();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
template<>
|
||||
template <>
|
||||
G4TemplateRNGHelper<G4long>* G4TemplateRNGHelper<G4long>::GetInstanceIfExist()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
template<>
|
||||
template <>
|
||||
G4TemplateRNGHelper<G4String>* G4TemplateRNGHelper<G4String>::GetInstance()
|
||||
{
|
||||
if (!instance)
|
||||
if(!instance)
|
||||
{
|
||||
instance = new G4TemplateRNGHelper<G4String>();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
template<>
|
||||
G4TemplateRNGHelper<G4String>* G4TemplateRNGHelper<G4String>::GetInstanceIfExist()
|
||||
template <>
|
||||
G4TemplateRNGHelper<G4String>*
|
||||
G4TemplateRNGHelper<G4String>::GetInstanceIfExist()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
template <class T>
|
||||
G4TemplateRNGHelper<T>::~G4TemplateRNGHelper()
|
||||
{
|
||||
Clear();
|
||||
|
||||
+21
-15
@@ -32,37 +32,43 @@
|
||||
#include "G4StatAnalysis.hh"
|
||||
|
||||
G4Run::G4Run()
|
||||
:runID(0),numberOfEvent(0),numberOfEventToBeProcessed(0),HCtable(0),DCtable(0)
|
||||
: runID(0)
|
||||
, numberOfEvent(0)
|
||||
, numberOfEventToBeProcessed(0)
|
||||
, HCtable(0)
|
||||
, DCtable(0)
|
||||
{
|
||||
eventVector = new std::vector<const G4Event*>;
|
||||
// this is for FOM in G4StatAnalysis
|
||||
G4StatAnalysis::ResetCpuClock();
|
||||
eventVector = new std::vector<const G4Event*>;
|
||||
// this is for FOM in G4StatAnalysis
|
||||
G4StatAnalysis::ResetCpuClock();
|
||||
}
|
||||
|
||||
G4Run::~G4Run()
|
||||
{
|
||||
// Objects made by local thread should not be deleted by the master thread
|
||||
G4RunManager::RMType rmType = G4RunManager::GetRunManager()->GetRunManagerType();
|
||||
G4RunManager::RMType rmType =
|
||||
G4RunManager::GetRunManager()->GetRunManagerType();
|
||||
if(rmType != G4RunManager::masterRM)
|
||||
{
|
||||
std::vector<const G4Event*>::iterator itr = eventVector->begin();
|
||||
for(;itr!=eventVector->end();itr++)
|
||||
{ delete *itr; }
|
||||
for(; itr != eventVector->end(); itr++)
|
||||
{
|
||||
delete *itr;
|
||||
}
|
||||
}
|
||||
delete eventVector;
|
||||
}
|
||||
|
||||
void G4Run::RecordEvent(const G4Event*)
|
||||
{ numberOfEvent++; }
|
||||
void G4Run::RecordEvent(const G4Event*) { numberOfEvent++; }
|
||||
|
||||
void G4Run::Merge(const G4Run* right)
|
||||
{
|
||||
numberOfEvent += right->numberOfEvent;
|
||||
numberOfEvent += right->numberOfEvent;
|
||||
std::vector<const G4Event*>::iterator itr = right->eventVector->begin();
|
||||
for(;itr!=right->eventVector->end();itr++)
|
||||
{ eventVector->push_back(*itr); }
|
||||
for(; itr != right->eventVector->end(); itr++)
|
||||
{
|
||||
eventVector->push_back(*itr);
|
||||
}
|
||||
}
|
||||
|
||||
void G4Run::StoreEvent(G4Event* evt)
|
||||
{ eventVector->push_back(evt); }
|
||||
|
||||
void G4Run::StoreEvent(G4Event* evt) { eventVector->push_back(evt); }
|
||||
|
||||
+553
-366
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
+463
-301
File diff suppressed because it is too large
Load Diff
@@ -25,13 +25,13 @@
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4UserPhysicsListMessenger.cc
|
||||
// ------------------------------------------------------------
|
||||
// History
|
||||
// first version 09 Jan. 1998 by H.Kurashige
|
||||
// first version 09 Jan. 1998 by H.Kurashige
|
||||
// add buildPhysicsTable command 13 Apr. 1999 by H.Kurashige
|
||||
// add setStoredInAscii command 12 Mar. 2001 by H.Kurashige
|
||||
// add dumpOrderingParam command 3 May. 2011 by H.Kurashige
|
||||
@@ -41,20 +41,22 @@
|
||||
|
||||
#include "G4UserPhysicsListMessenger.hh"
|
||||
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4PhysicsListHelper.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4SystemOfUnits.hh"
|
||||
#include "G4Tokenizer.hh"
|
||||
#include "G4UIcmdWithADoubleAndUnit.hh"
|
||||
#include "G4UIcmdWithAString.hh"
|
||||
#include "G4UIcmdWithAnInteger.hh"
|
||||
#include "G4UIcmdWithoutParameter.hh"
|
||||
#include "G4UIdirectory.hh"
|
||||
#include "G4UIparameter.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
#include "G4ios.hh"
|
||||
#include "G4Tokenizer.hh"
|
||||
|
||||
G4UserPhysicsListMessenger::G4UserPhysicsListMessenger(G4VUserPhysicsList* pParticleList):thePhysicsList(pParticleList)
|
||||
G4UserPhysicsListMessenger::G4UserPhysicsListMessenger(
|
||||
G4VUserPhysicsList* pParticleList)
|
||||
: thePhysicsList(pParticleList)
|
||||
{
|
||||
G4UIparameter* param = 0;
|
||||
// /run/particle directory
|
||||
@@ -62,64 +64,72 @@ G4UserPhysicsListMessenger::G4UserPhysicsListMessenger(G4VUserPhysicsList* pPart
|
||||
theDirectory->SetGuidance("Commands for G4VUserPhysicsList.");
|
||||
|
||||
// /run/particle/Verbose command
|
||||
verboseCmd = new G4UIcmdWithAnInteger("/run/particle/verbose",this);
|
||||
verboseCmd = new G4UIcmdWithAnInteger("/run/particle/verbose", this);
|
||||
verboseCmd->SetGuidance("Set the Verbose level of G4VUserPhysicsList.");
|
||||
verboseCmd->SetGuidance(" 0 : Silent (default)");
|
||||
verboseCmd->SetGuidance(" 1 : Display warning messages");
|
||||
verboseCmd->SetGuidance(" 2 : Display more");
|
||||
verboseCmd->SetParameterName("level",true);
|
||||
verboseCmd->SetParameterName("level", true);
|
||||
verboseCmd->SetDefaultValue(0);
|
||||
verboseCmd->SetRange("level >=0 && level <=3");
|
||||
|
||||
|
||||
// /run/setCut command
|
||||
setCutCmd = new G4UIcmdWithADoubleAndUnit("/run/setCut",this);
|
||||
setCutCmd = new G4UIcmdWithADoubleAndUnit("/run/setCut", this);
|
||||
setCutCmd->SetGuidance("Set default cut value ");
|
||||
setCutCmd->SetParameterName("cut",false);
|
||||
setCutCmd->SetParameterName("cut", false);
|
||||
setCutCmd->SetDefaultValue(1.0);
|
||||
setCutCmd->SetRange("cut >=0.0");
|
||||
setCutCmd->SetDefaultUnit("mm");
|
||||
setCutCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
setCutCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
// /run/setCutForAGivenParticle command
|
||||
setCutForAGivenParticleCmd = new G4UIcommand("/run/setCutForAGivenParticle",this) ;
|
||||
setCutForAGivenParticleCmd->SetGuidance("Set a cut value to a specific particle ") ;
|
||||
setCutForAGivenParticleCmd->SetGuidance("Usage: /run/setCutForAGivenParticle gamma 1. mm") ;
|
||||
param = new G4UIparameter("particleName",'s',false) ;
|
||||
setCutForAGivenParticleCmd =
|
||||
new G4UIcommand("/run/setCutForAGivenParticle", this);
|
||||
setCutForAGivenParticleCmd->SetGuidance(
|
||||
"Set a cut value to a specific particle ");
|
||||
setCutForAGivenParticleCmd->SetGuidance(
|
||||
"Usage: /run/setCutForAGivenParticle gamma 1. mm");
|
||||
param = new G4UIparameter("particleName", 's', false);
|
||||
param->SetParameterCandidates("e- e+ gamma proton");
|
||||
setCutForAGivenParticleCmd->SetParameter(param) ;
|
||||
param = new G4UIparameter("cut",'d',false) ;
|
||||
param->SetDefaultValue("1.") ;
|
||||
param->SetParameterRange("cut>=0.0") ;
|
||||
setCutForAGivenParticleCmd->SetParameter(param) ;
|
||||
param = new G4UIparameter("unit",'s',false) ;
|
||||
setCutForAGivenParticleCmd->SetParameter(param);
|
||||
param = new G4UIparameter("cut", 'd', false);
|
||||
param->SetDefaultValue("1.");
|
||||
param->SetParameterRange("cut>=0.0");
|
||||
setCutForAGivenParticleCmd->SetParameter(param);
|
||||
param = new G4UIparameter("unit", 's', false);
|
||||
param->SetDefaultUnit("mm");
|
||||
setCutForAGivenParticleCmd->SetParameter(param) ;
|
||||
setCutForAGivenParticleCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
setCutForAGivenParticleCmd->SetParameter(param);
|
||||
setCutForAGivenParticleCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
// /run/getCutForAGivenParticle command
|
||||
getCutForAGivenParticleCmd = new G4UIcmdWithAString("/run/getCutForAGivenParticle",this) ;
|
||||
getCutForAGivenParticleCmd->SetGuidance("Get a cut value to a specific particle ") ;
|
||||
getCutForAGivenParticleCmd->SetGuidance("Usage: /run/getCutForAGivenParticle gamma ") ;
|
||||
getCutForAGivenParticleCmd->SetParameterName("particleName",false,false) ;
|
||||
getCutForAGivenParticleCmd =
|
||||
new G4UIcmdWithAString("/run/getCutForAGivenParticle", this);
|
||||
getCutForAGivenParticleCmd->SetGuidance(
|
||||
"Get a cut value to a specific particle ");
|
||||
getCutForAGivenParticleCmd->SetGuidance(
|
||||
"Usage: /run/getCutForAGivenParticle gamma ");
|
||||
getCutForAGivenParticleCmd->SetParameterName("particleName", false, false);
|
||||
getCutForAGivenParticleCmd->SetCandidates("e- e+ gamma proton");
|
||||
getCutForAGivenParticleCmd->AvailableForStates(G4State_PreInit,G4State_Idle,G4State_GeomClosed,G4State_EventProc);
|
||||
getCutForAGivenParticleCmd->AvailableForStates(
|
||||
G4State_PreInit, G4State_Idle, G4State_GeomClosed, G4State_EventProc);
|
||||
|
||||
// /run/setCutForRegion command
|
||||
setCutRCmd = new G4UIcommand("/run/setCutForRegion",this);
|
||||
setCutRCmd = new G4UIcommand("/run/setCutForRegion", this);
|
||||
setCutRCmd->SetGuidance("Set cut value for a region");
|
||||
param = new G4UIparameter("Region",'s',false);
|
||||
param = new G4UIparameter("Region", 's', false);
|
||||
setCutRCmd->SetParameter(param);
|
||||
param = new G4UIparameter("cut",'d',false);
|
||||
param = new G4UIparameter("cut", 'd', false);
|
||||
param->SetParameterRange("cut >=0.0");
|
||||
setCutRCmd->SetParameter(param);
|
||||
param = new G4UIparameter("Unit",'s',true);
|
||||
param = new G4UIparameter("Unit", 's', true);
|
||||
param->SetDefaultValue("mm");
|
||||
param->SetParameterCandidates(setCutRCmd->UnitsList(setCutRCmd->CategoryOf("mm")));
|
||||
param->SetParameterCandidates(
|
||||
setCutRCmd->UnitsList(setCutRCmd->CategoryOf("mm")));
|
||||
setCutRCmd->SetParameter(param);
|
||||
setCutRCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
// /run/particle/DumpList command
|
||||
dumpListCmd = new G4UIcmdWithoutParameter("/run/particle/dumpList",this);
|
||||
dumpListCmd = new G4UIcmdWithoutParameter("/run/particle/dumpList", this);
|
||||
dumpListCmd->SetGuidance("Dump List of particles in G4VUserPhysicsList. ");
|
||||
|
||||
// /run/particle/addProcManager command
|
||||
@@ -128,87 +138,109 @@ G4UserPhysicsListMessenger::G4UserPhysicsListMessenger(G4VUserPhysicsList* pPart
|
||||
addProcManCmd->SetGuidance("add process manager to specified particle type");
|
||||
addProcManCmd->SetParameterName("particleType", true);
|
||||
addProcManCmd->SetDefaultValue("");
|
||||
addProcManCmd->AvailableForStates(G4State_PreInit,G4State_Init,G4State_Idle,G4State_GeomClosed,G4State_EventProc);
|
||||
addProcManCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle,
|
||||
G4State_GeomClosed, G4State_EventProc);
|
||||
|
||||
// /run/particle/buildPhysicsTable command
|
||||
buildPTCmd = new G4UIcmdWithAString("/run/particle/buildPhysicsTable", this);
|
||||
buildPTCmd->SetGuidance("build physics table of specified particle type");
|
||||
buildPTCmd->SetParameterName("particleType", true);
|
||||
buildPTCmd->SetDefaultValue("");
|
||||
buildPTCmd->AvailableForStates(G4State_Init,G4State_Idle,G4State_GeomClosed,G4State_EventProc);
|
||||
buildPTCmd->AvailableForStates(G4State_Init, G4State_Idle, G4State_GeomClosed,
|
||||
G4State_EventProc);
|
||||
|
||||
// /run/particle/storePhysicsTable command
|
||||
storeCmd = new G4UIcmdWithAString("/run/particle/storePhysicsTable",this);
|
||||
storeCmd = new G4UIcmdWithAString("/run/particle/storePhysicsTable", this);
|
||||
storeCmd->SetGuidance("Store Physics Table");
|
||||
storeCmd->SetGuidance(" Enter directory name");
|
||||
storeCmd->SetParameterName("dirName",true);
|
||||
storeCmd->SetParameterName("dirName", true);
|
||||
storeCmd->SetDefaultValue("");
|
||||
storeCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
// /run/particle/retrievePhysicsTable command
|
||||
retrieveCmd = new G4UIcmdWithAString("/run/particle/retrievePhysicsTable",this);
|
||||
retrieveCmd =
|
||||
new G4UIcmdWithAString("/run/particle/retrievePhysicsTable", this);
|
||||
retrieveCmd->SetGuidance("Retrieve Physics Table");
|
||||
retrieveCmd->SetGuidance(" Enter directory name or OFF to switch off");
|
||||
retrieveCmd->SetParameterName("dirName",true);
|
||||
retrieveCmd->SetParameterName("dirName", true);
|
||||
retrieveCmd->SetDefaultValue("");
|
||||
retrieveCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
retrieveCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
|
||||
// /run/particle/setStoredInAscii command
|
||||
asciiCmd = new G4UIcmdWithAnInteger("/run/particle/setStoredInAscii",this);
|
||||
asciiCmd->SetGuidance("Switch on/off ascii mode in store/retrieve Physics Table");
|
||||
asciiCmd = new G4UIcmdWithAnInteger("/run/particle/setStoredInAscii", this);
|
||||
asciiCmd->SetGuidance(
|
||||
"Switch on/off ascii mode in store/retrieve Physics Table");
|
||||
asciiCmd->SetGuidance(" Enter 0(binary) or 1(ascii)");
|
||||
asciiCmd->SetParameterName("ascii",true);
|
||||
asciiCmd->SetParameterName("ascii", true);
|
||||
asciiCmd->SetDefaultValue(0);
|
||||
asciiCmd->AvailableForStates(G4State_PreInit,G4State_Idle);
|
||||
asciiCmd->AvailableForStates(G4State_PreInit, G4State_Idle);
|
||||
asciiCmd->SetRange("ascii ==0 || ascii ==1");
|
||||
|
||||
//Commnad /run/particle/applyCuts command
|
||||
applyCutsCmd = new G4UIcommand("/run/particle/applyCuts",this);
|
||||
// Commnad /run/particle/applyCuts command
|
||||
applyCutsCmd = new G4UIcommand("/run/particle/applyCuts", this);
|
||||
applyCutsCmd->SetGuidance("Set applyCuts flag for a particle.");
|
||||
applyCutsCmd->SetGuidance(" Some EM processes which do not have infrared divergence");
|
||||
applyCutsCmd->SetGuidance("may generate gamma, e- and/or e+ with kinetic energies");
|
||||
applyCutsCmd->SetGuidance("below the production threshold. By setting this flag,");
|
||||
applyCutsCmd->SetGuidance("such secondaries below threshold are eliminated and");
|
||||
applyCutsCmd->SetGuidance("kinetic energies of such secondaries are accumulated");
|
||||
applyCutsCmd->SetGuidance(
|
||||
" Some EM processes which do not have infrared divergence");
|
||||
applyCutsCmd->SetGuidance(
|
||||
"may generate gamma, e- and/or e+ with kinetic energies");
|
||||
applyCutsCmd->SetGuidance(
|
||||
"below the production threshold. By setting this flag,");
|
||||
applyCutsCmd->SetGuidance(
|
||||
"such secondaries below threshold are eliminated and");
|
||||
applyCutsCmd->SetGuidance(
|
||||
"kinetic energies of such secondaries are accumulated");
|
||||
applyCutsCmd->SetGuidance("to the energy deposition of their mother.");
|
||||
applyCutsCmd->SetGuidance(" Note that 'applyCuts' makes sense only for gamma,");
|
||||
applyCutsCmd->SetGuidance("e- and e+. If this command is issued for other particle,");
|
||||
applyCutsCmd->SetGuidance("a warning message is displayed and the command is");
|
||||
applyCutsCmd->SetGuidance(
|
||||
" Note that 'applyCuts' makes sense only for gamma,");
|
||||
applyCutsCmd->SetGuidance(
|
||||
"e- and e+. If this command is issued for other particle,");
|
||||
applyCutsCmd->SetGuidance(
|
||||
"a warning message is displayed and the command is");
|
||||
applyCutsCmd->SetGuidance("ignored.");
|
||||
applyCutsCmd->SetGuidance(" If particle name is 'all', this command affects on");
|
||||
applyCutsCmd->SetGuidance(
|
||||
" If particle name is 'all', this command affects on");
|
||||
applyCutsCmd->SetGuidance("gamma, e- and e+.");
|
||||
param = new G4UIparameter("Flag",'s',true);
|
||||
param = new G4UIparameter("Flag", 's', true);
|
||||
param->SetDefaultValue("true");
|
||||
applyCutsCmd->SetParameter(param);
|
||||
param = new G4UIparameter("Particle",'s',true);
|
||||
param = new G4UIparameter("Particle", 's', true);
|
||||
param->SetDefaultValue("all");
|
||||
applyCutsCmd->SetParameter(param);
|
||||
applyCutsCmd->AvailableForStates(G4State_PreInit,G4State_Init,G4State_Idle);
|
||||
applyCutsCmd->AvailableForStates(G4State_PreInit, G4State_Init, G4State_Idle);
|
||||
|
||||
// /run/particle/dumpCutValues command
|
||||
dumpCutValuesCmd = new G4UIcmdWithAString("/run/particle/dumpCutValues",this);
|
||||
dumpCutValuesCmd->SetGuidance("Dump a list of production threshold values in range and energy");
|
||||
dumpCutValuesCmd =
|
||||
new G4UIcmdWithAString("/run/particle/dumpCutValues", this);
|
||||
dumpCutValuesCmd->SetGuidance(
|
||||
"Dump a list of production threshold values in range and energy");
|
||||
dumpCutValuesCmd->SetGuidance("for all registered material-cuts-couples.");
|
||||
dumpCutValuesCmd->SetGuidance("Dumping a list takes place when you issue 'beamOn' and");
|
||||
dumpCutValuesCmd->SetGuidance("actual conversion tables from range to energy are available.");
|
||||
dumpCutValuesCmd->SetGuidance("If you want a list 'immediately', use '/run/dumpRegion' for threshold");
|
||||
dumpCutValuesCmd->SetGuidance("list given in range only. Also, '/run/dumpCouples' gives you the");
|
||||
dumpCutValuesCmd->SetGuidance("current list if you have already issued 'run/beamOn' at least once.");
|
||||
dumpCutValuesCmd->SetParameterName("particle",true);
|
||||
dumpCutValuesCmd->SetGuidance(
|
||||
"Dumping a list takes place when you issue 'beamOn' and");
|
||||
dumpCutValuesCmd->SetGuidance(
|
||||
"actual conversion tables from range to energy are available.");
|
||||
dumpCutValuesCmd->SetGuidance(
|
||||
"If you want a list 'immediately', use '/run/dumpRegion' for threshold");
|
||||
dumpCutValuesCmd->SetGuidance(
|
||||
"list given in range only. Also, '/run/dumpCouples' gives you the");
|
||||
dumpCutValuesCmd->SetGuidance(
|
||||
"current list if you have already issued 'run/beamOn' at least once.");
|
||||
dumpCutValuesCmd->SetParameterName("particle", true);
|
||||
dumpCutValuesCmd->SetDefaultValue("all");
|
||||
dumpCutValuesCmd->AvailableForStates(G4State_Idle);
|
||||
|
||||
// /run/particle/dumpCutValues command
|
||||
dumpOrdParamCmd = new G4UIcmdWithAnInteger("/run/particle/dumpOrderingParam",this);
|
||||
dumpOrdParamCmd =
|
||||
new G4UIcmdWithAnInteger("/run/particle/dumpOrderingParam", this);
|
||||
dumpOrdParamCmd->SetGuidance("Dump a list of ordering parameter ");
|
||||
dumpOrdParamCmd->SetParameterName("subtype",true);
|
||||
dumpOrdParamCmd->SetParameterName("subtype", true);
|
||||
dumpOrdParamCmd->SetDefaultValue(-1);
|
||||
dumpOrdParamCmd->AvailableForStates(G4State_PreInit,G4State_Init,G4State_Idle);
|
||||
dumpOrdParamCmd->AvailableForStates(G4State_PreInit, G4State_Init,
|
||||
G4State_Idle);
|
||||
}
|
||||
|
||||
G4UserPhysicsListMessenger::~G4UserPhysicsListMessenger()
|
||||
{
|
||||
delete setCutCmd;
|
||||
delete setCutCmd;
|
||||
delete setCutRCmd;
|
||||
delete setCutForAGivenParticleCmd;
|
||||
delete getCutForAGivenParticleCmd;
|
||||
@@ -216,7 +248,7 @@ G4UserPhysicsListMessenger::~G4UserPhysicsListMessenger()
|
||||
delete dumpListCmd;
|
||||
delete addProcManCmd;
|
||||
delete buildPTCmd;
|
||||
delete storeCmd;
|
||||
delete storeCmd;
|
||||
delete retrieveCmd;
|
||||
delete asciiCmd;
|
||||
delete applyCutsCmd;
|
||||
@@ -225,65 +257,81 @@ G4UserPhysicsListMessenger::~G4UserPhysicsListMessenger()
|
||||
delete theDirectory;
|
||||
}
|
||||
|
||||
void G4UserPhysicsListMessenger::SetNewValue(G4UIcommand * command,G4String newValue)
|
||||
void G4UserPhysicsListMessenger::SetNewValue(G4UIcommand* command,
|
||||
G4String newValue)
|
||||
{
|
||||
G4ExceptionDescription ed;
|
||||
if( command==setCutCmd ){
|
||||
G4double newCut = setCutCmd->GetNewDoubleValue(newValue);
|
||||
if(command == setCutCmd)
|
||||
{
|
||||
G4double newCut = setCutCmd->GetNewDoubleValue(newValue);
|
||||
thePhysicsList->SetDefaultCutValue(newCut);
|
||||
thePhysicsList->SetCuts();
|
||||
|
||||
} else if( command==setCutForAGivenParticleCmd ){
|
||||
G4String particleName, unit ; G4double cut ;
|
||||
std::istringstream str (newValue) ;
|
||||
str >> particleName >> cut >> unit ;
|
||||
thePhysicsList->SetCutValue(cut*G4UIcommand::ValueOf(unit), particleName) ;
|
||||
|
||||
} else if( command==getCutForAGivenParticleCmd ){
|
||||
G4cout << thePhysicsList->GetCutValue(newValue)/mm <<"[mm]" << G4endl ;
|
||||
|
||||
} else if( command==setCutRCmd ){
|
||||
}
|
||||
else if(command == setCutForAGivenParticleCmd)
|
||||
{
|
||||
G4String particleName, unit;
|
||||
G4double cut;
|
||||
std::istringstream str(newValue);
|
||||
str >> particleName >> cut >> unit;
|
||||
thePhysicsList->SetCutValue(cut * G4UIcommand::ValueOf(unit), particleName);
|
||||
}
|
||||
else if(command == getCutForAGivenParticleCmd)
|
||||
{
|
||||
G4cout << thePhysicsList->GetCutValue(newValue) / mm << "[mm]" << G4endl;
|
||||
}
|
||||
else if(command == setCutRCmd)
|
||||
{
|
||||
std::istringstream is(newValue);
|
||||
G4String regName;
|
||||
G4String uniName;
|
||||
G4double cVal = -1.0;
|
||||
is >> regName >> cVal >> uniName;
|
||||
if (is.fail()) {
|
||||
if(is.fail())
|
||||
{
|
||||
ed << "illegal arguments : " << newValue;
|
||||
command->CommandFailed(ed);
|
||||
return;
|
||||
}
|
||||
thePhysicsList->SetCutsForRegion(cVal*(setCutRCmd->ValueOf(uniName)),regName);
|
||||
|
||||
} else if( command==verboseCmd ) {
|
||||
thePhysicsList->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue));
|
||||
|
||||
} else if( command==dumpListCmd ){
|
||||
thePhysicsList->SetCutsForRegion(cVal * (setCutRCmd->ValueOf(uniName)),
|
||||
regName);
|
||||
}
|
||||
else if(command == verboseCmd)
|
||||
{
|
||||
thePhysicsList->SetVerboseLevel(verboseCmd->GetNewIntValue(newValue));
|
||||
}
|
||||
else if(command == dumpListCmd)
|
||||
{
|
||||
thePhysicsList->DumpList();
|
||||
|
||||
} else if( command==dumpOrdParamCmd ){
|
||||
}
|
||||
else if(command == dumpOrdParamCmd)
|
||||
{
|
||||
G4int stype = dumpOrdParamCmd->GetNewIntValue(newValue);
|
||||
G4PhysicsListHelper::GetPhysicsListHelper()->DumpOrdingParameterTable(stype);
|
||||
|
||||
} else if( command == addProcManCmd ){
|
||||
G4ParticleDefinition* particle = (G4ParticleTable::GetParticleTable())->FindParticle(newValue);
|
||||
if (particle == 0)
|
||||
G4PhysicsListHelper::GetPhysicsListHelper()->DumpOrdingParameterTable(
|
||||
stype);
|
||||
}
|
||||
else if(command == addProcManCmd)
|
||||
{
|
||||
G4ParticleDefinition* particle =
|
||||
(G4ParticleTable::GetParticleTable())->FindParticle(newValue);
|
||||
if(particle == 0)
|
||||
{
|
||||
ed << " Particle is not found : " << newValue;
|
||||
command->CommandFailed(ed);
|
||||
return;
|
||||
}
|
||||
else if (particle->GetProcessManager() != 0)
|
||||
else if(particle->GetProcessManager() != 0)
|
||||
{
|
||||
ed << " Particle is not initialized : " << newValue;
|
||||
command->CommandFailed(ed);
|
||||
return;
|
||||
}
|
||||
thePhysicsList->AddProcessManager(particle);
|
||||
|
||||
} else if( command == buildPTCmd ){
|
||||
G4ParticleDefinition* particle = (G4ParticleTable::GetParticleTable())->FindParticle(newValue);
|
||||
if (particle == 0)
|
||||
}
|
||||
else if(command == buildPTCmd)
|
||||
{
|
||||
G4ParticleDefinition* particle =
|
||||
(G4ParticleTable::GetParticleTable())->FindParticle(newValue);
|
||||
if(particle == 0)
|
||||
{
|
||||
ed << " Particle is not found : " << newValue;
|
||||
command->CommandFailed(ed);
|
||||
@@ -291,98 +339,124 @@ void G4UserPhysicsListMessenger::SetNewValue(G4UIcommand * command,G4String newV
|
||||
}
|
||||
thePhysicsList->PreparePhysicsTable(particle);
|
||||
thePhysicsList->BuildPhysicsTable(particle);
|
||||
|
||||
} else if ( command == storeCmd ){
|
||||
}
|
||||
else if(command == storeCmd)
|
||||
{
|
||||
thePhysicsList->StorePhysicsTable(newValue);
|
||||
|
||||
} else if( command == retrieveCmd ) {
|
||||
if ((newValue == "OFF") || (newValue == "off") ){
|
||||
}
|
||||
else if(command == retrieveCmd)
|
||||
{
|
||||
if((newValue == "OFF") || (newValue == "off"))
|
||||
{
|
||||
thePhysicsList->ResetPhysicsTableRetrieved();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
thePhysicsList->SetPhysicsTableRetrieved(newValue);
|
||||
}
|
||||
|
||||
} else if( command == asciiCmd ) {
|
||||
if (asciiCmd->GetNewIntValue(newValue) == 0) {
|
||||
}
|
||||
else if(command == asciiCmd)
|
||||
{
|
||||
if(asciiCmd->GetNewIntValue(newValue) == 0)
|
||||
{
|
||||
thePhysicsList->ResetStoredInAscii();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
thePhysicsList->SetStoredInAscii();
|
||||
}
|
||||
|
||||
} else if( command == applyCutsCmd ) {
|
||||
G4Tokenizer next( newValue );
|
||||
}
|
||||
else if(command == applyCutsCmd)
|
||||
{
|
||||
G4Tokenizer next(newValue);
|
||||
|
||||
// check 1st argument
|
||||
G4String temp = G4String(next());
|
||||
G4bool flag = (temp =="true" || temp=="TRUE");
|
||||
G4bool flag = (temp == "true" || temp == "TRUE");
|
||||
|
||||
// check 2nd argument
|
||||
G4String name = G4String(next());
|
||||
|
||||
thePhysicsList->SetApplyCuts(flag, name);
|
||||
|
||||
} else if( command == dumpCutValuesCmd ) {
|
||||
thePhysicsList->DumpCutValuesTable(1);
|
||||
|
||||
}
|
||||
}
|
||||
else if(command == dumpCutValuesCmd)
|
||||
{
|
||||
thePhysicsList->DumpCutValuesTable(1);
|
||||
}
|
||||
}
|
||||
|
||||
G4String G4UserPhysicsListMessenger::GetCurrentValue(G4UIcommand * command)
|
||||
G4String G4UserPhysicsListMessenger::GetCurrentValue(G4UIcommand* command)
|
||||
{
|
||||
G4String cv;
|
||||
G4String candidates("none");
|
||||
G4ParticleTable::G4PTblDicIterator *piter = (G4ParticleTable::GetParticleTable())->GetIterator();
|
||||
|
||||
if( command==setCutCmd ) {
|
||||
cv = setCutCmd->ConvertToString( thePhysicsList->GetDefaultCutValue(), "mm" );
|
||||
|
||||
} else if( command==verboseCmd ){
|
||||
cv = verboseCmd->ConvertToString(thePhysicsList->GetVerboseLevel());
|
||||
|
||||
} else if( command== addProcManCmd ){
|
||||
// set candidate list
|
||||
piter -> reset();
|
||||
while( (*piter)() ){
|
||||
G4ParticleDefinition *particle = piter->value();
|
||||
candidates += " " + particle->GetParticleName();
|
||||
}
|
||||
addProcManCmd->SetCandidates(candidates);
|
||||
cv = "";
|
||||
|
||||
} else if( command== buildPTCmd ){
|
||||
// set candidate list
|
||||
piter -> reset();
|
||||
while( (*piter)() ){
|
||||
G4ParticleDefinition *particle = piter->value();
|
||||
candidates += " " + particle->GetParticleName();
|
||||
}
|
||||
addProcManCmd->SetCandidates(candidates);
|
||||
cv = "";
|
||||
|
||||
} else if ( command == storeCmd ){
|
||||
cv = thePhysicsList->GetPhysicsTableDirectory();
|
||||
G4ParticleTable::G4PTblDicIterator* piter =
|
||||
(G4ParticleTable::GetParticleTable())->GetIterator();
|
||||
|
||||
}else if( command == retrieveCmd ) {
|
||||
if (thePhysicsList->IsPhysicsTableRetrieved()) {
|
||||
if(command == setCutCmd)
|
||||
{
|
||||
cv = setCutCmd->ConvertToString(thePhysicsList->GetDefaultCutValue(), "mm");
|
||||
}
|
||||
else if(command == verboseCmd)
|
||||
{
|
||||
cv = verboseCmd->ConvertToString(thePhysicsList->GetVerboseLevel());
|
||||
}
|
||||
else if(command == addProcManCmd)
|
||||
{
|
||||
// set candidate list
|
||||
piter->reset();
|
||||
while((*piter)())
|
||||
{
|
||||
G4ParticleDefinition* particle = piter->value();
|
||||
candidates += " " + particle->GetParticleName();
|
||||
}
|
||||
addProcManCmd->SetCandidates(candidates);
|
||||
cv = "";
|
||||
}
|
||||
else if(command == buildPTCmd)
|
||||
{
|
||||
// set candidate list
|
||||
piter->reset();
|
||||
while((*piter)())
|
||||
{
|
||||
G4ParticleDefinition* particle = piter->value();
|
||||
candidates += " " + particle->GetParticleName();
|
||||
}
|
||||
addProcManCmd->SetCandidates(candidates);
|
||||
cv = "";
|
||||
}
|
||||
else if(command == storeCmd)
|
||||
{
|
||||
cv = thePhysicsList->GetPhysicsTableDirectory();
|
||||
}
|
||||
else if(command == retrieveCmd)
|
||||
{
|
||||
if(thePhysicsList->IsPhysicsTableRetrieved())
|
||||
{
|
||||
cv = thePhysicsList->GetPhysicsTableDirectory();
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
cv = "OFF";
|
||||
}
|
||||
|
||||
} else if( command==asciiCmd ){
|
||||
if (thePhysicsList->IsStoredInAscii()){
|
||||
}
|
||||
else if(command == asciiCmd)
|
||||
{
|
||||
if(thePhysicsList->IsStoredInAscii())
|
||||
{
|
||||
cv = "1";
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
cv = "0";
|
||||
}
|
||||
|
||||
// } else if( command == applyCutsCmd ) {
|
||||
// if (thePhysicsList->GetApplyCuts("gamma")){
|
||||
// cv = "true";
|
||||
// } else {
|
||||
// cv = "false";
|
||||
// }
|
||||
// } else if( command == applyCutsCmd ) {
|
||||
// if (thePhysicsList->GetApplyCuts("gamma")){
|
||||
// cv = "true";
|
||||
// } else {
|
||||
// cv = "false";
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
return cv;
|
||||
}
|
||||
|
||||
@@ -30,33 +30,32 @@
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
|
||||
G4UserRunAction::G4UserRunAction()
|
||||
:isMaster(true)
|
||||
: isMaster(true)
|
||||
{
|
||||
if(!(G4ParticleTable::GetParticleTable()->GetReadiness()))
|
||||
{
|
||||
G4String msg;
|
||||
msg = " You are instantiating G4UserRunAction BEFORE your G4VUserPhysicsList is\n";
|
||||
msg += "instantiated and assigned to G4RunManager.\n";
|
||||
msg += " Such an instantiation is prohibited by Geant4 version 8.0. To fix this problem,\n";
|
||||
msg += "please make sure that your main() instantiates G4VUserPhysicsList AND\n";
|
||||
msg += "set it to G4RunManager before instantiating other user action classes\n";
|
||||
msg += "such as G4UserRunAction.";
|
||||
G4Exception("G4UserRunAction::G4UserRunAction()",
|
||||
"Run0041",FatalException,msg);
|
||||
}
|
||||
if(!(G4ParticleTable::GetParticleTable()->GetReadiness()))
|
||||
{
|
||||
G4String msg;
|
||||
msg = " You are instantiating G4UserRunAction BEFORE your "
|
||||
"G4VUserPhysicsList is\n";
|
||||
msg += "instantiated and assigned to G4RunManager.\n";
|
||||
msg +=
|
||||
" Such an instantiation is prohibited by Geant4 version 8.0. To fix this "
|
||||
"problem,\n";
|
||||
msg +=
|
||||
"please make sure that your main() instantiates G4VUserPhysicsList AND\n";
|
||||
msg +=
|
||||
"set it to G4RunManager before instantiating other user action classes\n";
|
||||
msg += "such as G4UserRunAction.";
|
||||
G4Exception("G4UserRunAction::G4UserRunAction()", "Run0041", FatalException,
|
||||
msg);
|
||||
}
|
||||
}
|
||||
|
||||
G4UserRunAction::~G4UserRunAction()
|
||||
{;}
|
||||
G4UserRunAction::~G4UserRunAction() { ; }
|
||||
|
||||
G4Run* G4UserRunAction::GenerateRun()
|
||||
{ return 0; }
|
||||
G4Run* G4UserRunAction::GenerateRun() { return 0; }
|
||||
|
||||
void G4UserRunAction::BeginOfRunAction(const G4Run*)
|
||||
{;}
|
||||
|
||||
void G4UserRunAction::EndOfRunAction(const G4Run*)
|
||||
{;}
|
||||
void G4UserRunAction::BeginOfRunAction(const G4Run*) { ; }
|
||||
|
||||
void G4UserRunAction::EndOfRunAction(const G4Run*) { ; }
|
||||
|
||||
@@ -25,24 +25,16 @@
|
||||
//
|
||||
#include "G4UserWorkerInitialization.hh"
|
||||
|
||||
G4UserWorkerInitialization::G4UserWorkerInitialization()
|
||||
{;}
|
||||
G4UserWorkerInitialization::G4UserWorkerInitialization() { ; }
|
||||
|
||||
G4UserWorkerInitialization::~G4UserWorkerInitialization()
|
||||
{;}
|
||||
G4UserWorkerInitialization::~G4UserWorkerInitialization() { ; }
|
||||
|
||||
void G4UserWorkerInitialization::WorkerInitialize() const
|
||||
{;}
|
||||
void G4UserWorkerInitialization::WorkerInitialize() const { ; }
|
||||
|
||||
void G4UserWorkerInitialization::WorkerStart() const
|
||||
{;}
|
||||
void G4UserWorkerInitialization::WorkerStart() const { ; }
|
||||
|
||||
void G4UserWorkerInitialization::WorkerRunStart() const
|
||||
{;}
|
||||
void G4UserWorkerInitialization::WorkerRunStart() const { ; }
|
||||
|
||||
void G4UserWorkerInitialization::WorkerRunEnd() const
|
||||
{;}
|
||||
|
||||
void G4UserWorkerInitialization::WorkerStop() const
|
||||
{;}
|
||||
void G4UserWorkerInitialization::WorkerRunEnd() const { ; }
|
||||
|
||||
void G4UserWorkerInitialization::WorkerStop() const { ; }
|
||||
|
||||
@@ -24,117 +24,127 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
#include "G4UserWorkerThreadInitialization.hh"
|
||||
#include "G4WorkerThread.hh"
|
||||
#include "G4WorkerRunManager.hh"
|
||||
#include "G4MTRunManagerKernel.hh"
|
||||
#include "G4VUserActionInitialization.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
#include "G4AutoLock.hh"
|
||||
#include "G4MTRunManagerKernel.hh"
|
||||
#include "G4UImanager.hh"
|
||||
#include "G4VUserActionInitialization.hh"
|
||||
#include "G4VUserPhysicsList.hh"
|
||||
#include "G4WorkerRunManager.hh"
|
||||
#include "G4WorkerThread.hh"
|
||||
#include <sstream>
|
||||
|
||||
//Will need this for TPMalloc
|
||||
// Will need this for TPMalloc
|
||||
//#ifdef G4MULTITHREADED
|
||||
//#define TPMALLOCDEFINESTUB
|
||||
//#include "tpmalloc/tpmallocstub.h"
|
||||
//#endif
|
||||
|
||||
#ifdef G4MULTITHREADED
|
||||
G4Thread* G4UserWorkerThreadInitialization::CreateAndStartWorker(G4WorkerThread* wTC)
|
||||
G4Thread* G4UserWorkerThreadInitialization::CreateAndStartWorker(
|
||||
G4WorkerThread* wTC)
|
||||
{
|
||||
//Note: this method is called by G4MTRunManager, here we are still sequential
|
||||
//Create a new thread/worker structure
|
||||
G4Thread* worker = new G4Thread;
|
||||
G4THREADCREATE(worker, &G4MTRunManagerKernel::StartThread, wTC );
|
||||
return worker;
|
||||
// Note: this method is called by G4MTRunManager, here we are still sequential
|
||||
// Create a new thread/worker structure
|
||||
G4Thread* worker = new G4Thread;
|
||||
G4THREADCREATE(worker, &G4MTRunManagerKernel::StartThread, wTC);
|
||||
return worker;
|
||||
}
|
||||
#else
|
||||
G4Thread* G4UserWorkerThreadInitialization::CreateAndStartWorker(G4WorkerThread*)
|
||||
G4Thread* G4UserWorkerThreadInitialization::CreateAndStartWorker(
|
||||
G4WorkerThread*)
|
||||
{
|
||||
return new G4Thread;
|
||||
return new G4Thread;
|
||||
}
|
||||
#endif
|
||||
|
||||
//Avoid compilation warning in sequential
|
||||
// Avoid compilation warning in sequential
|
||||
#ifdef G4MULTITHREADED
|
||||
void G4UserWorkerThreadInitialization::JoinWorker(G4Thread* aThread)
|
||||
{
|
||||
G4THREADJOIN(*aThread);
|
||||
G4THREADJOIN(*aThread);
|
||||
}
|
||||
#else
|
||||
void G4UserWorkerThreadInitialization::JoinWorker(G4Thread*)
|
||||
{
|
||||
}
|
||||
void G4UserWorkerThreadInitialization::JoinWorker(G4Thread*) {}
|
||||
#endif
|
||||
|
||||
G4UserWorkerThreadInitialization::G4UserWorkerThreadInitialization()
|
||||
{;}
|
||||
G4UserWorkerThreadInitialization::G4UserWorkerThreadInitialization() { ; }
|
||||
|
||||
G4UserWorkerThreadInitialization::~G4UserWorkerThreadInitialization()
|
||||
{;}
|
||||
G4UserWorkerThreadInitialization::~G4UserWorkerThreadInitialization() { ; }
|
||||
|
||||
namespace {
|
||||
G4Mutex rngCreateMutex = G4MUTEX_INITIALIZER;
|
||||
namespace
|
||||
{
|
||||
G4Mutex rngCreateMutex = G4MUTEX_INITIALIZER;
|
||||
}
|
||||
|
||||
#include "globals.hh"
|
||||
void G4UserWorkerThreadInitialization::SetupRNGEngine(const CLHEP::HepRandomEngine* aNewRNG) const
|
||||
void G4UserWorkerThreadInitialization::SetupRNGEngine(
|
||||
const CLHEP::HepRandomEngine* aNewRNG) const
|
||||
{
|
||||
G4AutoLock l(&rngCreateMutex);
|
||||
//No default available, let's create the instance of random stuff
|
||||
//A Call to this just forces the creation to defaults
|
||||
G4Random::getTheEngine();
|
||||
//Poor man's solution to check which RNG Engine is used in master thread
|
||||
CLHEP::HepRandomEngine* retRNG= 0;
|
||||
G4AutoLock l(&rngCreateMutex);
|
||||
// No default available, let's create the instance of random stuff
|
||||
// A Call to this just forces the creation to defaults
|
||||
G4Random::getTheEngine();
|
||||
// Poor man's solution to check which RNG Engine is used in master thread
|
||||
CLHEP::HepRandomEngine* retRNG = 0;
|
||||
|
||||
// Need to make these calls thread safe
|
||||
if ( dynamic_cast<const CLHEP::HepJamesRandom*>(aNewRNG) ) {
|
||||
retRNG= new CLHEP::HepJamesRandom;
|
||||
}
|
||||
if ( dynamic_cast<const CLHEP::MixMaxRng*>(aNewRNG) ) {
|
||||
retRNG= new CLHEP::MixMaxRng;
|
||||
}
|
||||
if ( dynamic_cast<const CLHEP::RanecuEngine*>(aNewRNG) ) {
|
||||
retRNG= new CLHEP::RanecuEngine;
|
||||
}
|
||||
if ( dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG) ) {
|
||||
const CLHEP::Ranlux64Engine* theRNG = dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG);
|
||||
retRNG= new CLHEP::Ranlux64Engine(123,theRNG->getLuxury());
|
||||
}
|
||||
if ( dynamic_cast<const CLHEP::MTwistEngine*>(aNewRNG) ) {
|
||||
retRNG= new CLHEP::MTwistEngine;
|
||||
}
|
||||
if ( dynamic_cast<const CLHEP::DualRand*>(aNewRNG) ) {
|
||||
retRNG= new CLHEP::DualRand;
|
||||
}
|
||||
if ( dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG) ) {
|
||||
const CLHEP::RanluxEngine* theRNG = dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG);
|
||||
retRNG= new CLHEP::RanluxEngine(123,theRNG->getLuxury());
|
||||
}
|
||||
if ( dynamic_cast<const CLHEP::RanshiEngine*>(aNewRNG) ) {
|
||||
retRNG= new CLHEP::RanshiEngine;
|
||||
}
|
||||
|
||||
if( retRNG != 0 ) {
|
||||
G4Random::setTheEngine( retRNG );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Does a new method, such as aNewRng->newEngine() exist to clone it ?
|
||||
G4ExceptionDescription msg;
|
||||
msg<< " Unknown type of RNG Engine - " << G4endl
|
||||
<< " Can cope only with HepJamesRandom, MixMaxRng, Ranecu, Ranlux64,"
|
||||
<< " MTwistEngine, DualRand, Ranlux or Ranshi."
|
||||
<< G4endl
|
||||
<< " Cannot clone this type of RNG engine, as required for this thread" << G4endl
|
||||
<< " Aborting " << G4endl;
|
||||
G4Exception("G4UserWorkerInitializition::SetupRNGEngine()",
|
||||
"Run0122",FatalException,msg);
|
||||
}
|
||||
// Need to make these calls thread safe
|
||||
if(dynamic_cast<const CLHEP::HepJamesRandom*>(aNewRNG))
|
||||
{
|
||||
retRNG = new CLHEP::HepJamesRandom;
|
||||
}
|
||||
if(dynamic_cast<const CLHEP::MixMaxRng*>(aNewRNG))
|
||||
{
|
||||
retRNG = new CLHEP::MixMaxRng;
|
||||
}
|
||||
if(dynamic_cast<const CLHEP::RanecuEngine*>(aNewRNG))
|
||||
{
|
||||
retRNG = new CLHEP::RanecuEngine;
|
||||
}
|
||||
if(dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG))
|
||||
{
|
||||
const CLHEP::Ranlux64Engine* theRNG =
|
||||
dynamic_cast<const CLHEP::Ranlux64Engine*>(aNewRNG);
|
||||
retRNG = new CLHEP::Ranlux64Engine(123, theRNG->getLuxury());
|
||||
}
|
||||
if(dynamic_cast<const CLHEP::MTwistEngine*>(aNewRNG))
|
||||
{
|
||||
retRNG = new CLHEP::MTwistEngine;
|
||||
}
|
||||
if(dynamic_cast<const CLHEP::DualRand*>(aNewRNG))
|
||||
{
|
||||
retRNG = new CLHEP::DualRand;
|
||||
}
|
||||
if(dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG))
|
||||
{
|
||||
const CLHEP::RanluxEngine* theRNG =
|
||||
dynamic_cast<const CLHEP::RanluxEngine*>(aNewRNG);
|
||||
retRNG = new CLHEP::RanluxEngine(123, theRNG->getLuxury());
|
||||
}
|
||||
if(dynamic_cast<const CLHEP::RanshiEngine*>(aNewRNG))
|
||||
{
|
||||
retRNG = new CLHEP::RanshiEngine;
|
||||
}
|
||||
|
||||
if(retRNG != 0)
|
||||
{
|
||||
G4Random::setTheEngine(retRNG);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Does a new method, such as aNewRng->newEngine() exist to clone it ?
|
||||
G4ExceptionDescription msg;
|
||||
msg << " Unknown type of RNG Engine - " << G4endl
|
||||
<< " Can cope only with HepJamesRandom, MixMaxRng, Ranecu, Ranlux64,"
|
||||
<< " MTwistEngine, DualRand, Ranlux or Ranshi." << G4endl
|
||||
<< " Cannot clone this type of RNG engine, as required for this thread"
|
||||
<< G4endl << " Aborting " << G4endl;
|
||||
G4Exception("G4UserWorkerInitializition::SetupRNGEngine()", "Run0122",
|
||||
FatalException, msg);
|
||||
}
|
||||
}
|
||||
|
||||
G4WorkerRunManager* G4UserWorkerThreadInitialization::CreateWorkerRunManager() const
|
||||
G4WorkerRunManager* G4UserWorkerThreadInitialization::CreateWorkerRunManager()
|
||||
const
|
||||
{
|
||||
return new G4WorkerRunManager();
|
||||
return new G4WorkerRunManager();
|
||||
}
|
||||
|
||||
|
||||
@@ -25,75 +25,90 @@
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class implementation file
|
||||
// GEANT 4 class implementation file
|
||||
// ------------------------------------------------------------
|
||||
// - Add ReplacePhysics 14 Mar 2011 by H.Kurashige
|
||||
// - Add RemovePhysics 2 May 2011 by H.Kurashige
|
||||
//
|
||||
//
|
||||
#include "G4VModularPhysicsList.hh"
|
||||
#include "G4StateManager.hh"
|
||||
#include <algorithm>
|
||||
|
||||
// This macros change the references to fields that are now encapsulated
|
||||
// in the class G4VMPLData.
|
||||
#define G4MT_physicsVector ((G4VMPLsubInstanceManager.offset[g4vmplInstanceID]).physicsVector)
|
||||
#define G4MT_physicsVector \
|
||||
((G4VMPLsubInstanceManager.offset[g4vmplInstanceID]).physicsVector)
|
||||
|
||||
G4VMPLManager G4VModularPhysicsList::G4VMPLsubInstanceManager;
|
||||
|
||||
void G4VMPLData::initialize()
|
||||
{
|
||||
physicsVector = new G4PhysConstVectorData();
|
||||
}
|
||||
void G4VMPLData::initialize() { physicsVector = new G4PhysConstVectorData(); }
|
||||
|
||||
//G4ThreadLocal G4VModularPhysicsList::G4PhysConstVector* G4VModularPhysicsList::physicsVector = 0;
|
||||
// G4ThreadLocal G4VModularPhysicsList::G4PhysConstVector*
|
||||
// G4VModularPhysicsList::physicsVector = 0;
|
||||
|
||||
G4VModularPhysicsList::G4VModularPhysicsList()
|
||||
: G4VUserPhysicsList(),
|
||||
verboseLevel(0)
|
||||
: G4VUserPhysicsList()
|
||||
, verboseLevel(0)
|
||||
{
|
||||
g4vmplInstanceID = G4VMPLsubInstanceManager.CreateSubInstance();
|
||||
g4vmplInstanceID = G4VMPLsubInstanceManager.CreateSubInstance();
|
||||
}
|
||||
|
||||
G4VModularPhysicsList::~G4VModularPhysicsList()
|
||||
{
|
||||
for (auto itr = G4MT_physicsVector->begin(); itr!= G4MT_physicsVector->end(); ++itr) {
|
||||
delete (*itr);
|
||||
for(auto itr = G4MT_physicsVector->begin(); itr != G4MT_physicsVector->end();
|
||||
++itr)
|
||||
{
|
||||
delete(*itr);
|
||||
}
|
||||
G4MT_physicsVector->clear();
|
||||
delete G4MT_physicsVector;
|
||||
}
|
||||
|
||||
G4VModularPhysicsList::G4VModularPhysicsList(const G4VModularPhysicsList& right) : G4VUserPhysicsList(right),
|
||||
verboseLevel(0)
|
||||
G4VModularPhysicsList::G4VModularPhysicsList(const G4VModularPhysicsList& right)
|
||||
: G4VUserPhysicsList(right)
|
||||
, verboseLevel(0)
|
||||
{
|
||||
g4vmplInstanceID = G4VMPLsubInstanceManager.CreateSubInstance();
|
||||
g4vmplInstanceID = G4VMPLsubInstanceManager.CreateSubInstance();
|
||||
}
|
||||
|
||||
G4VModularPhysicsList & G4VModularPhysicsList::operator=(const G4VModularPhysicsList& right)
|
||||
G4VModularPhysicsList& G4VModularPhysicsList::operator=(
|
||||
const G4VModularPhysicsList& right)
|
||||
{
|
||||
if (this != &right) {
|
||||
defaultCutValue = right.defaultCutValue;
|
||||
isSetDefaultCutValue = right.isSetDefaultCutValue;
|
||||
fRetrievePhysicsTable = right.fRetrievePhysicsTable;
|
||||
fStoredInAscii = right.fStoredInAscii;
|
||||
if(this != &right)
|
||||
{
|
||||
defaultCutValue = right.defaultCutValue;
|
||||
isSetDefaultCutValue = right.isSetDefaultCutValue;
|
||||
fRetrievePhysicsTable = right.fRetrievePhysicsTable;
|
||||
fStoredInAscii = right.fStoredInAscii;
|
||||
fIsCheckedForRetrievePhysicsTable = right.fIsCheckedForRetrievePhysicsTable;
|
||||
fIsRestoredCutValues = right.fIsRestoredCutValues;
|
||||
directoryPhysicsTable = right.directoryPhysicsTable;
|
||||
//fDisplayThreshold = static_cast<const G4VUserPhysicsList&>(right).GetSubInstanceManager().offset[right.GetInstanceID()]._fDisplayThreshold;
|
||||
(this->subInstanceManager.offset[this->g4vuplInstanceID])._fDisplayThreshold=
|
||||
static_cast<const G4VUserPhysicsList&>(right).GetSubInstanceManager().offset[right.GetInstanceID()]._fDisplayThreshold;
|
||||
//fIsPhysicsTableBuilt = static_cast<const G4VUserPhysicsList&>(right).GetSubInstanceManager().offset[right.GetInstanceID()]._fIsPhysicsTableBuilt;
|
||||
(this->subInstanceManager.offset[this->g4vuplInstanceID])._fDisplayThreshold=
|
||||
static_cast<const G4VUserPhysicsList&>(right).GetSubInstanceManager().offset[right.GetInstanceID()]._fIsPhysicsTableBuilt;
|
||||
//fDisplayThreshold = right.fDisplayThreshold;
|
||||
fIsRestoredCutValues = right.fIsRestoredCutValues;
|
||||
directoryPhysicsTable = right.directoryPhysicsTable;
|
||||
// fDisplayThreshold = static_cast<const
|
||||
// G4VUserPhysicsList&>(right).GetSubInstanceManager().offset[right.GetInstanceID()]._fDisplayThreshold;
|
||||
(this->subInstanceManager.offset[this->g4vuplInstanceID])
|
||||
._fDisplayThreshold = static_cast<const G4VUserPhysicsList&>(right)
|
||||
.GetSubInstanceManager()
|
||||
.offset[right.GetInstanceID()]
|
||||
._fDisplayThreshold;
|
||||
// fIsPhysicsTableBuilt = static_cast<const
|
||||
// G4VUserPhysicsList&>(right).GetSubInstanceManager().offset[right.GetInstanceID()]._fIsPhysicsTableBuilt;
|
||||
(this->subInstanceManager.offset[this->g4vuplInstanceID])
|
||||
._fDisplayThreshold = static_cast<const G4VUserPhysicsList&>(right)
|
||||
.GetSubInstanceManager()
|
||||
.offset[right.GetInstanceID()]
|
||||
._fIsPhysicsTableBuilt;
|
||||
// fDisplayThreshold = right.fDisplayThreshold;
|
||||
fDisableCheckParticleList = right.fDisableCheckParticleList;
|
||||
verboseLevel = right.verboseLevel;
|
||||
|
||||
if(G4MT_physicsVector !=0) {
|
||||
for (auto itr = G4MT_physicsVector->begin(); itr!= G4MT_physicsVector->end(); ++itr) {
|
||||
delete (*itr);
|
||||
verboseLevel = right.verboseLevel;
|
||||
|
||||
if(G4MT_physicsVector != 0)
|
||||
{
|
||||
for(auto itr = G4MT_physicsVector->begin();
|
||||
itr != G4MT_physicsVector->end(); ++itr)
|
||||
{
|
||||
delete(*itr);
|
||||
}
|
||||
G4MT_physicsVector->clear();
|
||||
delete G4MT_physicsVector;
|
||||
@@ -106,235 +121,254 @@ G4VModularPhysicsList & G4VModularPhysicsList::operator=(const G4VModularPhysics
|
||||
void G4VModularPhysicsList::ConstructParticle()
|
||||
{
|
||||
// create particles
|
||||
for (auto itr = G4MT_physicsVector->begin(); itr!= G4MT_physicsVector->end(); ++itr) {
|
||||
(*itr)->ConstructParticle();;
|
||||
for(auto itr = G4MT_physicsVector->begin(); itr != G4MT_physicsVector->end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->ConstructParticle();
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Andrea Dotti: May 6 2013
|
||||
//Current limitation being debugged: Construction of physics processes
|
||||
//needs to be sequential (there is at least one HAD processes creating problems)
|
||||
//This is not yet understood and needs to be debugged since we do not want
|
||||
//this part to be sequential (imagine when one has 100 threads)
|
||||
//TODO: Remove this lock
|
||||
// Andrea Dotti: May 6 2013
|
||||
// Current limitation being debugged: Construction of physics processes
|
||||
// needs to be sequential (there is at least one HAD processes creating
|
||||
// problems) This is not yet understood and needs to be debugged since we do not
|
||||
// want this part to be sequential (imagine when one has 100 threads)
|
||||
// TODO: Remove this lock
|
||||
#include "G4AutoLock.hh"
|
||||
namespace {
|
||||
G4Mutex constructProcessMutex = G4MUTEX_INITIALIZER;
|
||||
namespace
|
||||
{
|
||||
G4Mutex constructProcessMutex = G4MUTEX_INITIALIZER;
|
||||
}
|
||||
|
||||
void G4VModularPhysicsList::ConstructProcess()
|
||||
{
|
||||
G4AutoLock l(&constructProcessMutex); //Protection to be removed (A.Dotti)
|
||||
AddTransportation();
|
||||
|
||||
for (auto itr = G4MT_physicsVector->begin(); itr!= G4MT_physicsVector->end(); ++itr) {
|
||||
G4AutoLock l(&constructProcessMutex); // Protection to be removed (A.Dotti)
|
||||
AddTransportation();
|
||||
|
||||
for(auto itr = G4MT_physicsVector->begin(); itr != G4MT_physicsVector->end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->ConstructProcess();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void G4VModularPhysicsList::RegisterPhysics(G4VPhysicsConstructor* fPhysics)
|
||||
{
|
||||
G4StateManager* stateManager = G4StateManager::GetStateManager();
|
||||
G4StateManager* stateManager = G4StateManager::GetStateManager();
|
||||
G4ApplicationState currentState = stateManager->GetCurrentState();
|
||||
if(!(currentState==G4State_PreInit)){
|
||||
G4Exception("G4VModularPhysicsList::RegisterPhysics",
|
||||
"Run0201", JustWarning,
|
||||
if(!(currentState == G4State_PreInit))
|
||||
{
|
||||
G4Exception("G4VModularPhysicsList::RegisterPhysics", "Run0201",
|
||||
JustWarning,
|
||||
"Geant4 kernel is not PreInit state : Method ignored.");
|
||||
return;
|
||||
}
|
||||
|
||||
G4String pName = fPhysics->GetPhysicsName();
|
||||
G4int pType = fPhysics->GetPhysicsType();
|
||||
// If physics_type is equal to 0,
|
||||
// following duplication check is omitted
|
||||
G4String pName = fPhysics->GetPhysicsName();
|
||||
G4int pType = fPhysics->GetPhysicsType();
|
||||
// If physics_type is equal to 0,
|
||||
// following duplication check is omitted
|
||||
// This is TEMPORAL treatment.
|
||||
if (pType == 0) {
|
||||
if(pType == 0)
|
||||
{
|
||||
G4MT_physicsVector->push_back(fPhysics);
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel >1){
|
||||
G4cout << "G4VModularPhysicsList::RegisterPhysics: "
|
||||
<< pName << "with type : " << pType
|
||||
<< " is added"
|
||||
<< G4endl;
|
||||
if(verboseLevel > 1)
|
||||
{
|
||||
G4cout << "G4VModularPhysicsList::RegisterPhysics: " << pName
|
||||
<< "with type : " << pType << " is added" << G4endl;
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if physics with the physics_type same as one of given physics
|
||||
|
||||
// Check if physics with the physics_type same as one of given physics
|
||||
auto itr = G4MT_physicsVector->begin();
|
||||
for (; itr!= G4MT_physicsVector->end(); ++itr) {
|
||||
if ( pType == (*itr)->GetPhysicsType()) break;
|
||||
for(; itr != G4MT_physicsVector->end(); ++itr)
|
||||
{
|
||||
if(pType == (*itr)->GetPhysicsType())
|
||||
break;
|
||||
}
|
||||
if (itr!= G4MT_physicsVector->end()) {
|
||||
if(itr != G4MT_physicsVector->end())
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel >0){
|
||||
if(verboseLevel > 0)
|
||||
{
|
||||
G4cout << "G4VModularPhysicsList::RegisterPhysics: "
|
||||
<< "a physics with given type already exists "
|
||||
<< G4endl;
|
||||
G4cout << " Type = " << pType << " : "
|
||||
<< " existing physics is " << (*itr)->GetPhysicsName()
|
||||
<< G4endl;
|
||||
G4cout << pName << " can not be registered "<<G4endl;
|
||||
<< "a physics with given type already exists " << G4endl;
|
||||
G4cout << " Type = " << pType << " : "
|
||||
<< " existing physics is " << (*itr)->GetPhysicsName() << G4endl;
|
||||
G4cout << pName << " can not be registered " << G4endl;
|
||||
}
|
||||
#endif
|
||||
G4String comment ="Duplicate type for ";
|
||||
G4String comment = "Duplicate type for ";
|
||||
comment += pName;
|
||||
G4Exception("G4VModularPhysicsList::RegisterPhysics",
|
||||
"Run0202", JustWarning, comment);
|
||||
G4Exception("G4VModularPhysicsList::RegisterPhysics", "Run0202",
|
||||
JustWarning, comment);
|
||||
return;
|
||||
}
|
||||
|
||||
// register
|
||||
// register
|
||||
G4MT_physicsVector->push_back(fPhysics);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void G4VModularPhysicsList::ReplacePhysics(G4VPhysicsConstructor* fPhysics)
|
||||
{
|
||||
G4StateManager* stateManager = G4StateManager::GetStateManager();
|
||||
G4StateManager* stateManager = G4StateManager::GetStateManager();
|
||||
G4ApplicationState currentState = stateManager->GetCurrentState();
|
||||
if(!(currentState==G4State_PreInit)){
|
||||
G4Exception("G4VModularPhysicsList::ReplacePhysics",
|
||||
"Run0203", JustWarning,
|
||||
if(!(currentState == G4State_PreInit))
|
||||
{
|
||||
G4Exception("G4VModularPhysicsList::ReplacePhysics", "Run0203", JustWarning,
|
||||
"Geant4 kernel is not PreInit state : Method ignored.");
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
G4String pName = fPhysics->GetPhysicsName();
|
||||
G4int pType = fPhysics->GetPhysicsType();
|
||||
// If physics_type is equal to 0,
|
||||
// duplication check is omitted and just added.
|
||||
G4String pName = fPhysics->GetPhysicsName();
|
||||
G4int pType = fPhysics->GetPhysicsType();
|
||||
// If physics_type is equal to 0,
|
||||
// duplication check is omitted and just added.
|
||||
// This is TEMPORAL treatment.
|
||||
if (pType == 0) {
|
||||
// register
|
||||
if(pType == 0)
|
||||
{
|
||||
// register
|
||||
G4MT_physicsVector->push_back(fPhysics);
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel >0){
|
||||
G4cout << "G4VModularPhysicsList::ReplacePhysics: "
|
||||
<< pName << "with type : " << pType
|
||||
<< " is added"
|
||||
<< G4endl;
|
||||
if(verboseLevel > 0)
|
||||
{
|
||||
G4cout << "G4VModularPhysicsList::ReplacePhysics: " << pName
|
||||
<< "with type : " << pType << " is added" << G4endl;
|
||||
}
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if physics with the physics_type same as one of given physics
|
||||
auto itr= G4MT_physicsVector->begin();
|
||||
for (itr = G4MT_physicsVector->begin(); itr!= G4MT_physicsVector->end(); ++itr) {
|
||||
if ( pType == (*itr)->GetPhysicsType()) break;
|
||||
// Check if physics with the physics_type same as one of given physics
|
||||
auto itr = G4MT_physicsVector->begin();
|
||||
for(itr = G4MT_physicsVector->begin(); itr != G4MT_physicsVector->end();
|
||||
++itr)
|
||||
{
|
||||
if(pType == (*itr)->GetPhysicsType())
|
||||
break;
|
||||
}
|
||||
if (itr == G4MT_physicsVector->end()) {
|
||||
// register
|
||||
if(itr == G4MT_physicsVector->end())
|
||||
{
|
||||
// register
|
||||
G4MT_physicsVector->push_back(fPhysics);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel >0){
|
||||
if(verboseLevel > 0)
|
||||
{
|
||||
G4cout << "G4VModularPhysicsList::ReplacePhysics: "
|
||||
<< (*itr)->GetPhysicsName() << "with type : " << pType
|
||||
<< " is replaces with " << pName
|
||||
<< G4endl;
|
||||
<< (*itr)->GetPhysicsName() << "with type : " << pType
|
||||
<< " is replaces with " << pName << G4endl;
|
||||
}
|
||||
#endif
|
||||
|
||||
// delete exsiting one
|
||||
delete (*itr);
|
||||
// delete exsiting one
|
||||
delete(*itr);
|
||||
// replace with given one
|
||||
(*itr) = fPhysics;
|
||||
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
void G4VModularPhysicsList::RemovePhysics(G4int pType)
|
||||
void G4VModularPhysicsList::RemovePhysics(G4int pType)
|
||||
{
|
||||
G4StateManager* stateManager = G4StateManager::GetStateManager();
|
||||
G4StateManager* stateManager = G4StateManager::GetStateManager();
|
||||
G4ApplicationState currentState = stateManager->GetCurrentState();
|
||||
if(!(currentState==G4State_PreInit)){
|
||||
G4Exception("G4VModularPhysicsList::RemovePhysics",
|
||||
"Run0204", JustWarning,
|
||||
if(!(currentState == G4State_PreInit))
|
||||
{
|
||||
G4Exception("G4VModularPhysicsList::RemovePhysics", "Run0204", JustWarning,
|
||||
"Geant4 kernel is not PreInit state : Method ignored.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto itr = G4MT_physicsVector->begin();
|
||||
itr!= G4MT_physicsVector->end();) {
|
||||
if ( pType == (*itr)->GetPhysicsType()) {
|
||||
G4String pName = (*itr)->GetPhysicsName();
|
||||
for(auto itr = G4MT_physicsVector->begin(); itr != G4MT_physicsVector->end();)
|
||||
{
|
||||
if(pType == (*itr)->GetPhysicsType())
|
||||
{
|
||||
G4String pName = (*itr)->GetPhysicsName();
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel > 0){
|
||||
G4cout << "G4VModularPhysicsList::RemovePhysics: "
|
||||
<< pName << " is removed"
|
||||
<< G4endl;
|
||||
}
|
||||
#endif
|
||||
G4MT_physicsVector->erase(itr);
|
||||
break;
|
||||
} else {
|
||||
itr++;
|
||||
if(verboseLevel > 0)
|
||||
{
|
||||
G4cout << "G4VModularPhysicsList::RemovePhysics: " << pName
|
||||
<< " is removed" << G4endl;
|
||||
}
|
||||
#endif
|
||||
G4MT_physicsVector->erase(itr);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
itr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void G4VModularPhysicsList::RemovePhysics(G4VPhysicsConstructor* fPhysics)
|
||||
{
|
||||
G4StateManager* stateManager = G4StateManager::GetStateManager();
|
||||
G4StateManager* stateManager = G4StateManager::GetStateManager();
|
||||
G4ApplicationState currentState = stateManager->GetCurrentState();
|
||||
if(!(currentState==G4State_PreInit)){
|
||||
G4Exception("G4VModularPhysicsList::RemovePhysics",
|
||||
"Run0205", JustWarning,
|
||||
if(!(currentState == G4State_PreInit))
|
||||
{
|
||||
G4Exception("G4VModularPhysicsList::RemovePhysics", "Run0205", JustWarning,
|
||||
"Geant4 kernel is not PreInit state : Method ignored.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto itr = G4MT_physicsVector->begin();
|
||||
itr!= G4MT_physicsVector->end();) {
|
||||
if ( fPhysics == (*itr)) {
|
||||
G4String pName = (*itr)->GetPhysicsName();
|
||||
for(auto itr = G4MT_physicsVector->begin(); itr != G4MT_physicsVector->end();)
|
||||
{
|
||||
if(fPhysics == (*itr))
|
||||
{
|
||||
G4String pName = (*itr)->GetPhysicsName();
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel > 0 ){
|
||||
G4cout << "G4VModularPhysicsList::RemovePhysics: "
|
||||
<< pName << " is removed"
|
||||
<< G4endl;
|
||||
}
|
||||
if(verboseLevel > 0)
|
||||
{
|
||||
G4cout << "G4VModularPhysicsList::RemovePhysics: " << pName
|
||||
<< " is removed" << G4endl;
|
||||
}
|
||||
#endif
|
||||
G4MT_physicsVector->erase(itr);
|
||||
break;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
itr++;
|
||||
}
|
||||
}
|
||||
}
|
||||
void G4VModularPhysicsList::RemovePhysics(const G4String& name)
|
||||
{
|
||||
G4StateManager* stateManager = G4StateManager::GetStateManager();
|
||||
G4StateManager* stateManager = G4StateManager::GetStateManager();
|
||||
G4ApplicationState currentState = stateManager->GetCurrentState();
|
||||
if(!(currentState==G4State_PreInit)){
|
||||
G4Exception("G4VModularPhysicsList::RemovePhysics",
|
||||
"Run0206", JustWarning,
|
||||
if(!(currentState == G4State_PreInit))
|
||||
{
|
||||
G4Exception("G4VModularPhysicsList::RemovePhysics", "Run0206", JustWarning,
|
||||
"Geant4 kernel is not PreInit state : Method ignored.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (auto itr = G4MT_physicsVector->begin();
|
||||
itr!= G4MT_physicsVector->end();) {
|
||||
G4String pName = (*itr)->GetPhysicsName();
|
||||
if ( name == pName) {
|
||||
for(auto itr = G4MT_physicsVector->begin(); itr != G4MT_physicsVector->end();)
|
||||
{
|
||||
G4String pName = (*itr)->GetPhysicsName();
|
||||
if(name == pName)
|
||||
{
|
||||
#ifdef G4VERBOSE
|
||||
if (verboseLevel > 0){
|
||||
G4cout << "G4VModularPhysicsList::RemovePhysics: "
|
||||
<< pName << " is removed"
|
||||
<< G4endl;
|
||||
}
|
||||
if(verboseLevel > 0)
|
||||
{
|
||||
G4cout << "G4VModularPhysicsList::RemovePhysics: " << pName
|
||||
<< " is removed" << G4endl;
|
||||
}
|
||||
#endif
|
||||
G4MT_physicsVector->erase(itr);
|
||||
break;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
itr++;
|
||||
}
|
||||
}
|
||||
@@ -343,47 +377,61 @@ void G4VModularPhysicsList::RemovePhysics(const G4String& name)
|
||||
const G4VPhysicsConstructor* G4VModularPhysicsList::GetPhysics(G4int idx) const
|
||||
{
|
||||
G4int i;
|
||||
auto itr= G4MT_physicsVector->begin();
|
||||
for (i=0; i<idx && itr!= G4MT_physicsVector->end() ; ++i) ++itr;
|
||||
if (itr!= G4MT_physicsVector->end()) return (*itr);
|
||||
else return 0;
|
||||
auto itr = G4MT_physicsVector->begin();
|
||||
for(i = 0; i < idx && itr != G4MT_physicsVector->end(); ++i)
|
||||
++itr;
|
||||
if(itr != G4MT_physicsVector->end())
|
||||
return (*itr);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
const G4VPhysicsConstructor* G4VModularPhysicsList::GetPhysics(const G4String& name) const
|
||||
const G4VPhysicsConstructor* G4VModularPhysicsList::GetPhysics(
|
||||
const G4String& name) const
|
||||
{
|
||||
auto itr = G4MT_physicsVector->begin();
|
||||
for (; itr!= G4MT_physicsVector->end(); ++itr) {
|
||||
if ( name == (*itr)->GetPhysicsName()) break;
|
||||
for(; itr != G4MT_physicsVector->end(); ++itr)
|
||||
{
|
||||
if(name == (*itr)->GetPhysicsName())
|
||||
break;
|
||||
}
|
||||
if (itr!= G4MT_physicsVector->end()) return (*itr);
|
||||
else return 0;
|
||||
if(itr != G4MT_physicsVector->end())
|
||||
return (*itr);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
const G4VPhysicsConstructor* G4VModularPhysicsList::GetPhysicsWithType(G4int pType) const
|
||||
const G4VPhysicsConstructor* G4VModularPhysicsList::GetPhysicsWithType(
|
||||
G4int pType) const
|
||||
{
|
||||
auto itr = G4MT_physicsVector->begin();
|
||||
for (; itr!= G4MT_physicsVector->end(); ++itr) {
|
||||
if ( pType == (*itr)->GetPhysicsType()) break;
|
||||
for(; itr != G4MT_physicsVector->end(); ++itr)
|
||||
{
|
||||
if(pType == (*itr)->GetPhysicsType())
|
||||
break;
|
||||
}
|
||||
if (itr!= G4MT_physicsVector->end()) return (*itr);
|
||||
else return 0;
|
||||
if(itr != G4MT_physicsVector->end())
|
||||
return (*itr);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void G4VModularPhysicsList::SetVerboseLevel(G4int value)
|
||||
{
|
||||
verboseLevel = value;
|
||||
// Loop over constructors
|
||||
for (auto itr = G4MT_physicsVector->begin(); itr!= G4MT_physicsVector->end(); ++itr) {
|
||||
for(auto itr = G4MT_physicsVector->begin(); itr != G4MT_physicsVector->end();
|
||||
++itr)
|
||||
{
|
||||
(*itr)->SetVerboseLevel(verboseLevel);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void G4VModularPhysicsList::TerminateWorker()
|
||||
{
|
||||
//See https://jira-geant4.kek.jp/browse/DEV-284
|
||||
std::for_each( G4MT_physicsVector->begin() , G4MT_physicsVector->end() ,
|
||||
[](G4PhysConstVector::value_type el) { el->TerminateWorker();});
|
||||
// See https://jira-geant4.kek.jp/browse/DEV-284
|
||||
std::for_each(
|
||||
G4MT_physicsVector->begin(), G4MT_physicsVector->end(),
|
||||
[](G4PhysConstVector::value_type el) { el->TerminateWorker(); });
|
||||
G4VUserPhysicsList::TerminateWorker();
|
||||
}
|
||||
|
||||
@@ -28,21 +28,14 @@
|
||||
|
||||
#include "G4VPersistencyManager.hh"
|
||||
|
||||
G4ThreadLocal G4VPersistencyManager* G4VPersistencyManager::fPersistencyManager = 0;
|
||||
G4ThreadLocal G4VPersistencyManager*
|
||||
G4VPersistencyManager::fPersistencyManager = 0;
|
||||
|
||||
G4VPersistencyManager* G4VPersistencyManager::GetPersistencyManager()
|
||||
{
|
||||
return fPersistencyManager;
|
||||
}
|
||||
|
||||
G4VPersistencyManager::G4VPersistencyManager()
|
||||
{
|
||||
fPersistencyManager = this;
|
||||
}
|
||||
|
||||
G4VPersistencyManager::~G4VPersistencyManager()
|
||||
{
|
||||
fPersistencyManager = 0;
|
||||
}
|
||||
|
||||
G4VPersistencyManager::G4VPersistencyManager() { fPersistencyManager = this; }
|
||||
|
||||
G4VPersistencyManager::~G4VPersistencyManager() { fPersistencyManager = 0; }
|
||||
|
||||
@@ -25,13 +25,14 @@
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
// GEANT 4 class header file
|
||||
// GEANT 4 class header file
|
||||
//
|
||||
// ------------------------------------------------------------
|
||||
|
||||
#include "G4VPhysicsConstructor.hh"
|
||||
#include "G4HadronicParameters.hh"
|
||||
#include "G4PhysicsBuilderInterface.hh"
|
||||
#include <algorithm>
|
||||
// This field helps to use the class G4VPCManager
|
||||
@@ -40,54 +41,73 @@ G4VPCManager G4VPhysicsConstructor::subInstanceManager;
|
||||
|
||||
void G4VPCData::initialize()
|
||||
{
|
||||
_aParticleIterator = G4ParticleTable::GetParticleTable()->GetIterator();
|
||||
_builders = new PhysicsBuilders_V;
|
||||
_aParticleIterator = G4ParticleTable::GetParticleTable()->GetIterator();
|
||||
_builders = new PhysicsBuilders_V;
|
||||
}
|
||||
|
||||
|
||||
G4VPhysicsConstructor::G4VPhysicsConstructor(const G4String& name)
|
||||
: verboseLevel(0), namePhysics(name), typePhysics(0)
|
||||
: verboseLevel(0)
|
||||
, namePhysics(name)
|
||||
, typePhysics(0)
|
||||
{
|
||||
g4vpcInstanceID = subInstanceManager.CreateSubInstance();
|
||||
// pointer to the particle table
|
||||
theParticleTable = G4ParticleTable::GetParticleTable();
|
||||
//aParticleIterator = theParticleTable->GetIterator();
|
||||
// aParticleIterator = theParticleTable->GetIterator();
|
||||
|
||||
// PhysicsListHelper
|
||||
//aPLHelper = G4PhysicsListHelper::GetPhysicsListHelper();
|
||||
// aPLHelper = G4PhysicsListHelper::GetPhysicsListHelper();
|
||||
|
||||
// Harmless call (setting a default value) needed to build the
|
||||
// G4HadronicParameters instance before run initialization.
|
||||
if(G4HadronicParameters::Instance())
|
||||
G4HadronicParameters::Instance()->SetVerboseLevel(1);
|
||||
}
|
||||
|
||||
G4VPhysicsConstructor::G4VPhysicsConstructor(const G4String& name, G4int type)
|
||||
: verboseLevel(0), namePhysics(name), typePhysics(type)
|
||||
: verboseLevel(0)
|
||||
, namePhysics(name)
|
||||
, typePhysics(type)
|
||||
{
|
||||
g4vpcInstanceID = subInstanceManager.CreateSubInstance();
|
||||
g4vpcInstanceID = subInstanceManager.CreateSubInstance();
|
||||
// pointer to the particle table
|
||||
theParticleTable = G4ParticleTable::GetParticleTable();
|
||||
//aParticleIterator = theParticleTable->GetIterator();
|
||||
// aParticleIterator = theParticleTable->GetIterator();
|
||||
|
||||
if (type<0) typePhysics = 0;
|
||||
if(type < 0)
|
||||
typePhysics = 0;
|
||||
|
||||
// PhysicsListHelper
|
||||
//aPLHelper = G4PhysicsListHelper::GetPhysicsListHelper();
|
||||
// aPLHelper = G4PhysicsListHelper::GetPhysicsListHelper();
|
||||
|
||||
// Harmless call (setting a default value) needed to build the
|
||||
// G4HadronicParameters instance before run initialization.
|
||||
if(G4HadronicParameters::Instance())
|
||||
G4HadronicParameters::Instance()->SetVerboseLevel(1);
|
||||
}
|
||||
|
||||
G4VPhysicsConstructor::~G4VPhysicsConstructor()
|
||||
{
|
||||
//Master/Sequential needs to cleanup too
|
||||
// Master/Sequential needs to cleanup too
|
||||
G4VPhysicsConstructor::TerminateWorker();
|
||||
}
|
||||
|
||||
G4ParticleTable::G4PTblDicIterator* G4VPhysicsConstructor::GetParticleIterator() const
|
||||
G4ParticleTable::G4PTblDicIterator* G4VPhysicsConstructor::GetParticleIterator()
|
||||
const
|
||||
{
|
||||
return (subInstanceManager.offset[g4vpcInstanceID])._aParticleIterator;
|
||||
return (subInstanceManager.offset[g4vpcInstanceID])._aParticleIterator;
|
||||
}
|
||||
|
||||
G4VPhysicsConstructor::PhysicsBuilder_V G4VPhysicsConstructor::GetBuilders() const
|
||||
G4VPhysicsConstructor::PhysicsBuilder_V G4VPhysicsConstructor::GetBuilders()
|
||||
const
|
||||
{
|
||||
const auto& tls = *((subInstanceManager.offset[g4vpcInstanceID])._builders);
|
||||
PhysicsBuilder_V copy(tls.size());
|
||||
int i = 0;
|
||||
for ( const auto& el : tls ) { copy[i++] = el; }
|
||||
for(const auto& el : tls)
|
||||
{
|
||||
copy[i++] = el;
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
@@ -98,11 +118,11 @@ void G4VPhysicsConstructor::AddBuilder(G4PhysicsBuilderInterface* bld)
|
||||
|
||||
void G4VPhysicsConstructor::TerminateWorker()
|
||||
{
|
||||
if ( subInstanceManager.offset[g4vpcInstanceID]._builders != nullptr ) {
|
||||
std::for_each( subInstanceManager.offset[g4vpcInstanceID]._builders->begin() ,
|
||||
subInstanceManager.offset[g4vpcInstanceID]._builders->end() ,
|
||||
[](PhysicsBuilder_V::value_type bld) { delete bld;});
|
||||
subInstanceManager.offset[g4vpcInstanceID]._builders->clear();
|
||||
if(subInstanceManager.offset[g4vpcInstanceID]._builders != nullptr)
|
||||
{
|
||||
std::for_each(subInstanceManager.offset[g4vpcInstanceID]._builders->begin(),
|
||||
subInstanceManager.offset[g4vpcInstanceID]._builders->end(),
|
||||
[](PhysicsBuilder_V::value_type bld) { delete bld; });
|
||||
subInstanceManager.offset[g4vpcInstanceID]._builders->clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -26,34 +26,48 @@
|
||||
#include "G4VUserActionInitialization.hh"
|
||||
#include "G4RunManager.hh"
|
||||
|
||||
G4VUserActionInitialization::G4VUserActionInitialization()
|
||||
{;}
|
||||
G4VUserActionInitialization::G4VUserActionInitialization() { ; }
|
||||
|
||||
G4VUserActionInitialization::~G4VUserActionInitialization()
|
||||
{;}
|
||||
G4VUserActionInitialization::~G4VUserActionInitialization() { ; }
|
||||
|
||||
void G4VUserActionInitialization::BuildForMaster() const
|
||||
{;}
|
||||
void G4VUserActionInitialization::BuildForMaster() const { ; }
|
||||
|
||||
void G4VUserActionInitialization::SetUserAction(G4VUserPrimaryGeneratorAction* action) const
|
||||
{ G4RunManager::GetRunManager()->SetUserAction(action); }
|
||||
void G4VUserActionInitialization::SetUserAction(
|
||||
G4VUserPrimaryGeneratorAction* action) const
|
||||
{
|
||||
G4RunManager::GetRunManager()->SetUserAction(action);
|
||||
}
|
||||
|
||||
void G4VUserActionInitialization::SetUserAction(G4UserRunAction* action) const
|
||||
{ G4RunManager::GetRunManager()->SetUserAction(action); }
|
||||
{
|
||||
G4RunManager::GetRunManager()->SetUserAction(action);
|
||||
}
|
||||
|
||||
void G4VUserActionInitialization::SetUserAction(G4UserEventAction* action) const
|
||||
{ G4RunManager::GetRunManager()->SetUserAction(action); }
|
||||
{
|
||||
G4RunManager::GetRunManager()->SetUserAction(action);
|
||||
}
|
||||
|
||||
void G4VUserActionInitialization::SetUserAction(G4UserStackingAction* action) const
|
||||
{ G4RunManager::GetRunManager()->SetUserAction(action); }
|
||||
void G4VUserActionInitialization::SetUserAction(
|
||||
G4UserStackingAction* action) const
|
||||
{
|
||||
G4RunManager::GetRunManager()->SetUserAction(action);
|
||||
}
|
||||
|
||||
void G4VUserActionInitialization::SetUserAction(G4UserTrackingAction* action) const
|
||||
{ G4RunManager::GetRunManager()->SetUserAction(action); }
|
||||
|
||||
void G4VUserActionInitialization::SetUserAction(G4UserSteppingAction* action) const
|
||||
{ G4RunManager::GetRunManager()->SetUserAction(action); }
|
||||
|
||||
G4VSteppingVerbose* G4VUserActionInitialization::InitializeSteppingVerbose() const
|
||||
{ return static_cast<G4VSteppingVerbose*>(0); }
|
||||
void G4VUserActionInitialization::SetUserAction(
|
||||
G4UserTrackingAction* action) const
|
||||
{
|
||||
G4RunManager::GetRunManager()->SetUserAction(action);
|
||||
}
|
||||
|
||||
void G4VUserActionInitialization::SetUserAction(
|
||||
G4UserSteppingAction* action) const
|
||||
{
|
||||
G4RunManager::GetRunManager()->SetUserAction(action);
|
||||
}
|
||||
|
||||
G4VSteppingVerbose* G4VUserActionInitialization::InitializeSteppingVerbose()
|
||||
const
|
||||
{
|
||||
return static_cast<G4VSteppingVerbose*>(0);
|
||||
}
|
||||
|
||||
@@ -27,35 +27,34 @@
|
||||
//
|
||||
|
||||
#include "G4VUserDetectorConstruction.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4VUserParallelWorld.hh"
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
#include "G4VSensitiveDetector.hh"
|
||||
#include "G4FieldManager.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4MultiSensitiveDetector.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4VSensitiveDetector.hh"
|
||||
#include "G4VUserParallelWorld.hh"
|
||||
#include <assert.h>
|
||||
#include <sstream>
|
||||
|
||||
G4VUserDetectorConstruction::G4VUserDetectorConstruction()
|
||||
{;}
|
||||
G4VUserDetectorConstruction::G4VUserDetectorConstruction() { ; }
|
||||
|
||||
G4VUserDetectorConstruction::~G4VUserDetectorConstruction()
|
||||
{;}
|
||||
G4VUserDetectorConstruction::~G4VUserDetectorConstruction() { ; }
|
||||
|
||||
void G4VUserDetectorConstruction::RegisterParallelWorld(G4VUserParallelWorld* aPW)
|
||||
void G4VUserDetectorConstruction::RegisterParallelWorld(
|
||||
G4VUserParallelWorld* aPW)
|
||||
{
|
||||
std::vector<G4VUserParallelWorld*>::iterator pwItr;
|
||||
for(pwItr=parallelWorld.begin();pwItr!=parallelWorld.end();pwItr++)
|
||||
for(pwItr = parallelWorld.begin(); pwItr != parallelWorld.end(); pwItr++)
|
||||
{
|
||||
if((*pwItr)->GetName()==aPW->GetName())
|
||||
if((*pwItr)->GetName() == aPW->GetName())
|
||||
{
|
||||
G4String eM = "A parallel world <";
|
||||
eM += aPW->GetName();
|
||||
eM += "> is already registered to the user detector construction.";
|
||||
G4Exception("G4VUserDetectorConstruction::RegisterParallelWorld",
|
||||
"Run0051",FatalErrorInArgument,eM);
|
||||
"Run0051", FatalErrorInArgument, eM);
|
||||
}
|
||||
}
|
||||
parallelWorld.push_back(aPW);
|
||||
@@ -65,7 +64,7 @@ G4int G4VUserDetectorConstruction::ConstructParallelGeometries()
|
||||
{
|
||||
G4int nP = 0;
|
||||
std::vector<G4VUserParallelWorld*>::iterator pwItr;
|
||||
for(pwItr=parallelWorld.begin();pwItr!=parallelWorld.end();pwItr++)
|
||||
for(pwItr = parallelWorld.begin(); pwItr != parallelWorld.end(); pwItr++)
|
||||
{
|
||||
(*pwItr)->Construct();
|
||||
nP++;
|
||||
@@ -76,16 +75,22 @@ G4int G4VUserDetectorConstruction::ConstructParallelGeometries()
|
||||
void G4VUserDetectorConstruction::ConstructParallelSD()
|
||||
{
|
||||
std::vector<G4VUserParallelWorld*>::iterator pwItr;
|
||||
for(pwItr=parallelWorld.begin();pwItr!=parallelWorld.end();pwItr++)
|
||||
{ (*pwItr)->ConstructSD(); }
|
||||
for(pwItr = parallelWorld.begin(); pwItr != parallelWorld.end(); pwItr++)
|
||||
{
|
||||
(*pwItr)->ConstructSD();
|
||||
}
|
||||
}
|
||||
|
||||
G4int G4VUserDetectorConstruction::GetNumberOfParallelWorld() const
|
||||
{ return parallelWorld.size(); }
|
||||
|
||||
G4VUserParallelWorld* G4VUserDetectorConstruction::GetParallelWorld(G4int i) const
|
||||
{
|
||||
if(i<0||i>=GetNumberOfParallelWorld()) return 0;
|
||||
return parallelWorld.size();
|
||||
}
|
||||
|
||||
G4VUserParallelWorld* G4VUserDetectorConstruction::GetParallelWorld(
|
||||
G4int i) const
|
||||
{
|
||||
if(i < 0 || i >= GetNumberOfParallelWorld())
|
||||
return 0;
|
||||
return parallelWorld[i];
|
||||
}
|
||||
|
||||
@@ -93,122 +98,133 @@ G4VUserParallelWorld* G4VUserDetectorConstruction::GetParallelWorld(G4int i) con
|
||||
|
||||
void G4VUserDetectorConstruction::ConstructSDandField()
|
||||
{
|
||||
// G4RunManager::RMType rmtype = G4RunManager::GetRunManager()->GetRunManagerType();
|
||||
// if(rmtype != G4RunManager::sequentialRM)
|
||||
// {
|
||||
// G4cout
|
||||
// << "User-derived detector construction class does not implement \n"
|
||||
// << "ConstructSDandFiled method: i.e. workers will not have SD and fields!\n"
|
||||
// << "The user can safely ignore this message if (s)he has no sensitive\n"
|
||||
// << "detector or field in her/his application." << G4endl;
|
||||
// }
|
||||
// G4RunManager::RMType rmtype =
|
||||
// G4RunManager::GetRunManager()->GetRunManagerType(); if(rmtype !=
|
||||
// G4RunManager::sequentialRM)
|
||||
// {
|
||||
// G4cout
|
||||
// << "User-derived detector construction class does not implement \n"
|
||||
// << "ConstructSDandFiled method: i.e. workers will not have SD and
|
||||
// fields!\n"
|
||||
// << "The user can safely ignore this message if (s)he has no sensitive\n"
|
||||
// << "detector or field in her/his application." << G4endl;
|
||||
// }
|
||||
}
|
||||
|
||||
#include <map>
|
||||
void G4VUserDetectorConstruction::CloneF()
|
||||
{
|
||||
typedef std::map<G4FieldManager*,G4FieldManager*> FMtoFMmap;
|
||||
typedef std::pair<G4FieldManager*,G4FieldManager*> FMpair;
|
||||
FMtoFMmap masterToWorker;
|
||||
G4LogicalVolumeStore* const logVolStore = G4LogicalVolumeStore::GetInstance();
|
||||
assert( logVolStore != NULL );
|
||||
for ( G4LogicalVolumeStore::const_iterator it = logVolStore->begin() ; it != logVolStore->end() ; ++it )
|
||||
typedef std::map<G4FieldManager*, G4FieldManager*> FMtoFMmap;
|
||||
typedef std::pair<G4FieldManager*, G4FieldManager*> FMpair;
|
||||
FMtoFMmap masterToWorker;
|
||||
G4LogicalVolumeStore* const logVolStore = G4LogicalVolumeStore::GetInstance();
|
||||
assert(logVolStore != NULL);
|
||||
for(G4LogicalVolumeStore::const_iterator it = logVolStore->begin();
|
||||
it != logVolStore->end(); ++it)
|
||||
{
|
||||
G4LogicalVolume* g4LogicalVolume = *it;
|
||||
// Use shadow of master to get instance of FM
|
||||
G4FieldManager* masterFM = 0; // g4LogicalVolume->fFieldManager;
|
||||
G4FieldManager* clonedFM = 0;
|
||||
if(masterFM)
|
||||
{
|
||||
G4LogicalVolume *g4LogicalVolume = *it;
|
||||
//Use shadow of master to get instance of FM
|
||||
G4FieldManager* masterFM = 0;//g4LogicalVolume->fFieldManager;
|
||||
G4FieldManager* clonedFM = 0;
|
||||
if ( masterFM )
|
||||
FMtoFMmap::iterator fmFound = masterToWorker.find(masterFM);
|
||||
if(fmFound == masterToWorker.end())
|
||||
{
|
||||
// First time we see this SD, let's clone and remember...
|
||||
try
|
||||
{
|
||||
FMtoFMmap::iterator fmFound = masterToWorker.find(masterFM);
|
||||
if ( fmFound == masterToWorker.end() )
|
||||
{
|
||||
//First time we see this SD, let's clone and remember...
|
||||
try {
|
||||
std::pair<FMtoFMmap::iterator,bool> insertedEl = masterToWorker.insert( FMpair(masterFM, masterFM->Clone()) );
|
||||
clonedFM = (insertedEl.first)->second;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
G4ExceptionDescription msg;
|
||||
msg << "Cloning of G4FieldManager failed."
|
||||
<< " But derived class does not implement cloning. Cannot continue.";
|
||||
G4Exception("G4VUserDetectorConstruction::CloneSD", "Run0053", FatalException,msg);
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We have already seen this SD attached to a fifferent LogicalVolume, let's re-use previous clone
|
||||
clonedFM = (*fmFound).second;
|
||||
}
|
||||
}// masterFM != 0
|
||||
//Note that we do not push FM to doughters (false argument), however, since we area looping on all
|
||||
//logical volumes and we implemented the "trick" of the map master<->cloned the final
|
||||
//effect is the same as using here the correct boolean flag: log-volumes that originally were sharing
|
||||
//the same FM they will have cloned ones
|
||||
g4LogicalVolume->SetFieldManager(clonedFM, false);
|
||||
}
|
||||
std::pair<FMtoFMmap::iterator, bool> insertedEl =
|
||||
masterToWorker.insert(FMpair(masterFM, masterFM->Clone()));
|
||||
clonedFM = (insertedEl.first)->second;
|
||||
} catch(...)
|
||||
{
|
||||
G4ExceptionDescription msg;
|
||||
msg << "Cloning of G4FieldManager failed."
|
||||
<< " But derived class does not implement cloning. Cannot "
|
||||
"continue.";
|
||||
G4Exception("G4VUserDetectorConstruction::CloneSD", "Run0053",
|
||||
FatalException, msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We have already seen this SD attached to a fifferent LogicalVolume,
|
||||
// let's re-use previous clone
|
||||
clonedFM = (*fmFound).second;
|
||||
}
|
||||
} // masterFM != 0
|
||||
// Note that we do not push FM to doughters (false argument), however, since
|
||||
// we area looping on all logical volumes and we implemented the "trick" of
|
||||
// the map master<->cloned the final effect is the same as using here the
|
||||
// correct boolean flag: log-volumes that originally were sharing the same
|
||||
// FM they will have cloned ones
|
||||
g4LogicalVolume->SetFieldManager(clonedFM, false);
|
||||
}
|
||||
}
|
||||
|
||||
void G4VUserDetectorConstruction::CloneSD()
|
||||
{
|
||||
//Loop on ALL logial volumes to search for attached SD
|
||||
G4LogicalVolumeStore* const logVolStore = G4LogicalVolumeStore::GetInstance();
|
||||
assert( logVolStore != NULL );
|
||||
|
||||
typedef std::map<G4VSensitiveDetector*,G4VSensitiveDetector*> SDtoSDmap;
|
||||
typedef std::pair<G4VSensitiveDetector*,G4VSensitiveDetector*> SDpair;
|
||||
SDtoSDmap masterToWorker;
|
||||
// Loop on ALL logial volumes to search for attached SD
|
||||
G4LogicalVolumeStore* const logVolStore = G4LogicalVolumeStore::GetInstance();
|
||||
assert(logVolStore != NULL);
|
||||
|
||||
for ( G4LogicalVolumeStore::const_iterator it = logVolStore->begin() ; it != logVolStore->end() ; ++it )
|
||||
typedef std::map<G4VSensitiveDetector*, G4VSensitiveDetector*> SDtoSDmap;
|
||||
typedef std::pair<G4VSensitiveDetector*, G4VSensitiveDetector*> SDpair;
|
||||
SDtoSDmap masterToWorker;
|
||||
|
||||
for(G4LogicalVolumeStore::const_iterator it = logVolStore->begin();
|
||||
it != logVolStore->end(); ++it)
|
||||
{
|
||||
G4LogicalVolume* g4LogicalVolume = *it;
|
||||
// Use shadow of master to get the instance of SD
|
||||
G4VSensitiveDetector* masterSD = 0; // g4LogicalVolume->fSensitiveDetector;
|
||||
G4VSensitiveDetector* clonedSD = 0;
|
||||
if(masterSD)
|
||||
{
|
||||
G4LogicalVolume *g4LogicalVolume = *it;
|
||||
//Use shadow of master to get the instance of SD
|
||||
G4VSensitiveDetector* masterSD = 0;//g4LogicalVolume->fSensitiveDetector;
|
||||
G4VSensitiveDetector* clonedSD = 0;
|
||||
if ( masterSD )
|
||||
SDtoSDmap::iterator sdFound = masterToWorker.find(masterSD);
|
||||
if(sdFound == masterToWorker.end())
|
||||
{
|
||||
// First time we see this SD, let's clone and remember...
|
||||
try
|
||||
{
|
||||
SDtoSDmap::iterator sdFound = masterToWorker.find(masterSD);
|
||||
if ( sdFound == masterToWorker.end() )
|
||||
{
|
||||
//First time we see this SD, let's clone and remember...
|
||||
try {
|
||||
std::pair<SDtoSDmap::iterator,bool> insertedEl = masterToWorker.insert( SDpair(masterSD,masterSD->Clone()) );
|
||||
clonedSD = (insertedEl.first)->second;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
G4ExceptionDescription msg;
|
||||
msg << "Cloning of G4VSensitiveDetector requested for:" << masterSD->GetName() << "\n"
|
||||
std::pair<SDtoSDmap::iterator, bool> insertedEl =
|
||||
masterToWorker.insert(SDpair(masterSD, masterSD->Clone()));
|
||||
clonedSD = (insertedEl.first)->second;
|
||||
} catch(...)
|
||||
{
|
||||
G4ExceptionDescription msg;
|
||||
msg << "Cloning of G4VSensitiveDetector requested for:"
|
||||
<< masterSD->GetName() << "\n"
|
||||
#ifndef WIN32
|
||||
<< " (full path name: " << masterSD->GetFullPathName() << ").\n"
|
||||
<< " (full path name: " << masterSD->GetFullPathName() << ").\n"
|
||||
#endif
|
||||
<< " But derived class does not implement cloning. Cannot continue.";
|
||||
G4Exception("G4VUserDetectorConstruction::CloneSD", "Run0053", FatalException,msg);
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// We have already seen this SD attached to a fifferent LogicalVolume, let's re-use previous clone
|
||||
clonedSD = (*sdFound).second;
|
||||
|
||||
}
|
||||
}// masterSD!=0
|
||||
g4LogicalVolume->SetSensitiveDetector(clonedSD);
|
||||
|
||||
}
|
||||
<< " But derived class does not implement cloning. Cannot "
|
||||
"continue.";
|
||||
G4Exception("G4VUserDetectorConstruction::CloneSD", "Run0053",
|
||||
FatalException, msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We have already seen this SD attached to a fifferent LogicalVolume,
|
||||
// let's re-use previous clone
|
||||
clonedSD = (*sdFound).second;
|
||||
}
|
||||
} // masterSD!=0
|
||||
g4LogicalVolume->SetSensitiveDetector(clonedSD);
|
||||
}
|
||||
}
|
||||
|
||||
void G4VUserDetectorConstruction::SetSensitiveDetector
|
||||
(const G4String& logVolName, G4VSensitiveDetector* aSD, G4bool multi)
|
||||
{
|
||||
G4bool found = false;
|
||||
void G4VUserDetectorConstruction::SetSensitiveDetector(
|
||||
const G4String& logVolName, G4VSensitiveDetector* aSD, G4bool multi)
|
||||
{
|
||||
G4bool found = false;
|
||||
G4LogicalVolumeStore* store = G4LogicalVolumeStore::GetInstance();
|
||||
for(G4LogicalVolumeStore::iterator pos=store->begin(); pos!=store->end(); pos++)
|
||||
for(G4LogicalVolumeStore::iterator pos = store->begin(); pos != store->end();
|
||||
pos++)
|
||||
{
|
||||
if((*pos)->GetName()==logVolName)
|
||||
if((*pos)->GetName() == logVolName)
|
||||
{
|
||||
if(found && !multi)
|
||||
{
|
||||
@@ -218,12 +234,12 @@ void G4VUserDetectorConstruction::SetSensitiveDetector
|
||||
eM += aSD->GetName();
|
||||
eM += "> cannot be uniquely assigned.";
|
||||
G4Exception("G4VUserDetectorConstruction::SetSensitiveDetector",
|
||||
"Run0052",FatalErrorInArgument,eM);
|
||||
"Run0052", FatalErrorInArgument, eM);
|
||||
}
|
||||
found = true;
|
||||
SetSensitiveDetector(*pos,aSD);
|
||||
SetSensitiveDetector(*pos, aSD);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!found)
|
||||
{
|
||||
G4String eM2 = "No logical volume of the name <";
|
||||
@@ -231,49 +247,56 @@ void G4VUserDetectorConstruction::SetSensitiveDetector
|
||||
eM2 += "> is found. The specified sensitive detector <";
|
||||
eM2 += aSD->GetName();
|
||||
eM2 += "> couldn't be assigned to any volume.";
|
||||
G4Exception("G4VUserDetectorConstruction::SetSensitiveDetector",
|
||||
"Run0053",FatalErrorInArgument,eM2);
|
||||
}
|
||||
}
|
||||
|
||||
void G4VUserDetectorConstruction::SetSensitiveDetector
|
||||
(G4LogicalVolume* logVol, G4VSensitiveDetector* aSD)
|
||||
{
|
||||
assert(logVol!=nullptr&&aSD!=nullptr);
|
||||
|
||||
//The aSD has already been added by user to the manager if needed
|
||||
//G4SDManager::GetSDMpointer()->AddNewDetector(aSD);
|
||||
|
||||
//New Logic: allow for "multiple" SDs being attached to a single LV.
|
||||
//To do that we use a special proxy SD called G4MultiSensitiveDetector
|
||||
|
||||
//Get existing SD if already set and check if it is of the special type
|
||||
G4VSensitiveDetector* originalSD = logVol->GetSensitiveDetector();
|
||||
if ( originalSD == aSD ) {
|
||||
G4ExceptionDescription msg;
|
||||
msg << "Attempting to add multiple times the same sensitive detector (\"";
|
||||
msg << originalSD->GetName()<<"\") is not allowed, skipping.";
|
||||
G4Exception("G4VUserDetectorConstruction::SetSensitiveDetector",
|
||||
"Run0054",JustWarning,msg);
|
||||
return;
|
||||
|
||||
}
|
||||
if ( originalSD == nullptr ) {
|
||||
logVol->SetSensitiveDetector(aSD);
|
||||
} else {
|
||||
G4MultiSensitiveDetector* msd = dynamic_cast<G4MultiSensitiveDetector*>(originalSD);
|
||||
if ( msd != nullptr ) {
|
||||
msd->AddSD(aSD);
|
||||
} else {
|
||||
std::ostringstream mn;
|
||||
mn<<"/MultiSD_"<<logVol->GetName()<<"_"<<logVol;
|
||||
const G4String msdname = mn.str();
|
||||
msd = new G4MultiSensitiveDetector(msdname);
|
||||
//We need to register the proxy to have correct handling of IDs
|
||||
G4SDManager::GetSDMpointer()->AddNewDetector(msd);
|
||||
msd->AddSD(originalSD);
|
||||
msd->AddSD(aSD);
|
||||
logVol->SetSensitiveDetector(msd);
|
||||
}
|
||||
G4Exception("G4VUserDetectorConstruction::SetSensitiveDetector", "Run0053",
|
||||
FatalErrorInArgument, eM2);
|
||||
}
|
||||
}
|
||||
|
||||
void G4VUserDetectorConstruction::SetSensitiveDetector(
|
||||
G4LogicalVolume* logVol, G4VSensitiveDetector* aSD)
|
||||
{
|
||||
assert(logVol != nullptr && aSD != nullptr);
|
||||
|
||||
// The aSD has already been added by user to the manager if needed
|
||||
// G4SDManager::GetSDMpointer()->AddNewDetector(aSD);
|
||||
|
||||
// New Logic: allow for "multiple" SDs being attached to a single LV.
|
||||
// To do that we use a special proxy SD called G4MultiSensitiveDetector
|
||||
|
||||
// Get existing SD if already set and check if it is of the special type
|
||||
G4VSensitiveDetector* originalSD = logVol->GetSensitiveDetector();
|
||||
if(originalSD == aSD)
|
||||
{
|
||||
G4ExceptionDescription msg;
|
||||
msg << "Attempting to add multiple times the same sensitive detector (\"";
|
||||
msg << originalSD->GetName() << "\") is not allowed, skipping.";
|
||||
G4Exception("G4VUserDetectorConstruction::SetSensitiveDetector", "Run0054",
|
||||
JustWarning, msg);
|
||||
return;
|
||||
}
|
||||
if(originalSD == nullptr)
|
||||
{
|
||||
logVol->SetSensitiveDetector(aSD);
|
||||
}
|
||||
else
|
||||
{
|
||||
G4MultiSensitiveDetector* msd =
|
||||
dynamic_cast<G4MultiSensitiveDetector*>(originalSD);
|
||||
if(msd != nullptr)
|
||||
{
|
||||
msd->AddSD(aSD);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::ostringstream mn;
|
||||
mn << "/MultiSD_" << logVol->GetName() << "_" << logVol;
|
||||
const G4String msdname = mn.str();
|
||||
msd = new G4MultiSensitiveDetector(msdname);
|
||||
// We need to register the proxy to have correct handling of IDs
|
||||
G4SDManager::GetSDMpointer()->AddNewDetector(msd);
|
||||
msd->AddSD(originalSD);
|
||||
msd->AddSD(aSD);
|
||||
logVol->SetSensitiveDetector(msd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,39 +28,41 @@
|
||||
|
||||
#include "G4VUserParallelWorld.hh"
|
||||
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
#include "G4VSensitiveDetector.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4TransportationManager.hh"
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4VSensitiveDetector.hh"
|
||||
|
||||
G4VUserParallelWorld::G4VUserParallelWorld(G4String worldName)
|
||||
{ fWorldName = worldName; }
|
||||
{
|
||||
fWorldName = worldName;
|
||||
}
|
||||
|
||||
G4VUserParallelWorld::~G4VUserParallelWorld()
|
||||
{ ; }
|
||||
G4VUserParallelWorld::~G4VUserParallelWorld() { ; }
|
||||
|
||||
void G4VUserParallelWorld::ConstructSD()
|
||||
{ ; }
|
||||
void G4VUserParallelWorld::ConstructSD() { ; }
|
||||
|
||||
G4VPhysicalVolume* G4VUserParallelWorld::GetWorld()
|
||||
{
|
||||
G4VPhysicalVolume* pWorld
|
||||
= G4TransportationManager::GetTransportationManager()
|
||||
->GetParallelWorld(fWorldName);
|
||||
G4VPhysicalVolume* pWorld =
|
||||
G4TransportationManager::GetTransportationManager()->GetParallelWorld(
|
||||
fWorldName);
|
||||
pWorld->SetName(fWorldName);
|
||||
return pWorld;
|
||||
}
|
||||
|
||||
void G4VUserParallelWorld::SetSensitiveDetector
|
||||
(const G4String& logVolName, G4VSensitiveDetector* aSD, G4bool multi)
|
||||
void G4VUserParallelWorld::SetSensitiveDetector(const G4String& logVolName,
|
||||
G4VSensitiveDetector* aSD,
|
||||
G4bool multi)
|
||||
{
|
||||
G4bool found = false;
|
||||
G4bool found = false;
|
||||
G4LogicalVolumeStore* store = G4LogicalVolumeStore::GetInstance();
|
||||
for(G4LogicalVolumeStore::iterator pos=store->begin(); pos!=store->end(); pos++)
|
||||
for(G4LogicalVolumeStore::iterator pos = store->begin(); pos != store->end();
|
||||
pos++)
|
||||
{
|
||||
if((*pos)->GetName()==logVolName)
|
||||
if((*pos)->GetName() == logVolName)
|
||||
{
|
||||
if(found && !multi)
|
||||
{
|
||||
@@ -69,11 +71,11 @@ void G4VUserParallelWorld::SetSensitiveDetector
|
||||
eM += "> are found and thus the sensitive detector <";
|
||||
eM += aSD->GetName();
|
||||
eM += "> cannot be uniquely assigned.";
|
||||
G4Exception("G4VUserParallelWorld::SetSensitiveDetector",
|
||||
"Run5052",FatalErrorInArgument,eM);
|
||||
G4Exception("G4VUserParallelWorld::SetSensitiveDetector", "Run5052",
|
||||
FatalErrorInArgument, eM);
|
||||
}
|
||||
found = true;
|
||||
SetSensitiveDetector(*pos,aSD);
|
||||
SetSensitiveDetector(*pos, aSD);
|
||||
}
|
||||
}
|
||||
if(!found)
|
||||
@@ -83,15 +85,14 @@ void G4VUserParallelWorld::SetSensitiveDetector
|
||||
eM2 += "> is found. The specified sensitive detector <";
|
||||
eM2 += aSD->GetName();
|
||||
eM2 += "> couldn't be assigned to any volume.";
|
||||
G4Exception("G4VUserParallelWorld::SetSensitiveDetector",
|
||||
"Run5053",FatalErrorInArgument,eM2);
|
||||
G4Exception("G4VUserParallelWorld::SetSensitiveDetector", "Run5053",
|
||||
FatalErrorInArgument, eM2);
|
||||
}
|
||||
}
|
||||
|
||||
void G4VUserParallelWorld::SetSensitiveDetector
|
||||
(G4LogicalVolume* logVol, G4VSensitiveDetector* aSD)
|
||||
void G4VUserParallelWorld::SetSensitiveDetector(G4LogicalVolume* logVol,
|
||||
G4VSensitiveDetector* aSD)
|
||||
{
|
||||
G4SDManager::GetSDMpointer()->AddNewDetector(aSD);
|
||||
logVol->SetSensitiveDetector(aSD);
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -32,21 +32,23 @@
|
||||
|
||||
G4VUserPrimaryGeneratorAction::G4VUserPrimaryGeneratorAction()
|
||||
{
|
||||
if(!(G4ParticleTable::GetParticleTable()->GetReadiness()))
|
||||
{
|
||||
G4String msg;
|
||||
msg = " You are instantiating G4VUserPrimaryGeneratorAction BEFORE your\n";
|
||||
msg += "G4VUserPhysicsList is instantiated and assigned to G4RunManager.\n";
|
||||
msg += " Such an instantiation is prohibited by Geant4 version 8.0. To fix this problem,\n";
|
||||
msg += "please make sure that your main() instantiates G4VUserPhysicsList AND\n";
|
||||
msg += "set it to G4RunManager before instantiating other user action classes\n";
|
||||
msg += "such as G4VUserPrimaryParticleGeneratorAction.";
|
||||
G4Exception("G4VUserPrimaryGeneratorAction::G4VUserPrimaryGeneratorAction()",
|
||||
"Run0061",FatalException,msg);
|
||||
}
|
||||
if(!(G4ParticleTable::GetParticleTable()->GetReadiness()))
|
||||
{
|
||||
G4String msg;
|
||||
msg = " You are instantiating G4VUserPrimaryGeneratorAction BEFORE your\n";
|
||||
msg += "G4VUserPhysicsList is instantiated and assigned to G4RunManager.\n";
|
||||
msg +=
|
||||
" Such an instantiation is prohibited by Geant4 version 8.0. To fix this "
|
||||
"problem,\n";
|
||||
msg +=
|
||||
"please make sure that your main() instantiates G4VUserPhysicsList AND\n";
|
||||
msg +=
|
||||
"set it to G4RunManager before instantiating other user action classes\n";
|
||||
msg += "such as G4VUserPrimaryParticleGeneratorAction.";
|
||||
G4Exception(
|
||||
"G4VUserPrimaryGeneratorAction::G4VUserPrimaryGeneratorAction()",
|
||||
"Run0061", FatalException, msg);
|
||||
}
|
||||
}
|
||||
|
||||
G4VUserPrimaryGeneratorAction::~G4VUserPrimaryGeneratorAction()
|
||||
{;}
|
||||
|
||||
|
||||
G4VUserPrimaryGeneratorAction::~G4VUserPrimaryGeneratorAction() { ; }
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -27,16 +27,20 @@
|
||||
#include "G4WorkerRunManagerKernel.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
|
||||
G4WorkerRunManagerKernel::G4WorkerRunManagerKernel() : G4RunManagerKernel(workerRMK)
|
||||
G4WorkerRunManagerKernel::G4WorkerRunManagerKernel()
|
||||
: G4RunManagerKernel(workerRMK)
|
||||
{
|
||||
//This version of the constructor should never be called in sequential mode!
|
||||
// This version of the constructor should never be called in sequential mode!
|
||||
#ifndef G4MULTITHREADED
|
||||
G4ExceptionDescription msg;
|
||||
msg<<"Geant4 code is compiled without multi-threading support (-DG4MULTITHREADED is set to off).";
|
||||
msg<<" This type of RunManager can only be used in mult-threaded applications.";
|
||||
G4Exception("G4RunManagerKernel::G4RunManagerKernel()","Run0102",FatalException,msg);
|
||||
G4ExceptionDescription msg;
|
||||
msg << "Geant4 code is compiled without multi-threading support "
|
||||
"(-DG4MULTITHREADED "
|
||||
"is set to off).";
|
||||
msg << " This type of RunManager can only be used in mult-threaded "
|
||||
"applications.";
|
||||
G4Exception("G4RunManagerKernel::G4RunManagerKernel()", "Run0102",
|
||||
FatalException, msg);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
G4WorkerRunManagerKernel::~G4WorkerRunManagerKernel()
|
||||
@@ -46,54 +50,69 @@ G4WorkerRunManagerKernel::~G4WorkerRunManagerKernel()
|
||||
|
||||
void G4WorkerRunManagerKernel::SetupShadowProcess() const
|
||||
{
|
||||
//Master thread has created processes and setup a pointer
|
||||
//to the master process, get it and copy it in this instance
|
||||
G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
|
||||
G4ParticleTable::G4PTblDicIterator* theParticleIterator = theParticleTable->GetIterator();
|
||||
theParticleIterator->reset();
|
||||
//loop on particles and get process manager from there list of processes
|
||||
while((*theParticleIterator)())
|
||||
// Master thread has created processes and setup a pointer
|
||||
// to the master process, get it and copy it in this instance
|
||||
G4ParticleTable* theParticleTable = G4ParticleTable::GetParticleTable();
|
||||
G4ParticleTable::G4PTblDicIterator* theParticleIterator =
|
||||
theParticleTable->GetIterator();
|
||||
theParticleIterator->reset();
|
||||
// loop on particles and get process manager from there list of processes
|
||||
while((*theParticleIterator)())
|
||||
{
|
||||
G4ParticleDefinition* pd = theParticleIterator->value();
|
||||
G4ProcessManager* pm = pd->GetProcessManager();
|
||||
G4ProcessManager* pmM = pd->GetMasterProcessManager();
|
||||
if(!pm || !pmM)
|
||||
{
|
||||
G4ParticleDefinition* pd = theParticleIterator->value();
|
||||
G4ProcessManager* pm = pd->GetProcessManager();
|
||||
G4ProcessManager* pmM= pd->GetMasterProcessManager();
|
||||
if ( !pm || !pmM )
|
||||
{
|
||||
G4ExceptionDescription msg;
|
||||
msg << "Process manager or process manager shadow to master are not set.\n";
|
||||
msg << "Particle : "<<pd->GetParticleName()<<" ("<<pd<<"), proc-manager: "<<pm;
|
||||
msg << " proc-manager-shadow: "<<pmM;
|
||||
G4Exception("G4WorkerRunManagerKernel::SetupShadowProcess()","Run0116",FatalException,
|
||||
msg);
|
||||
return;
|
||||
}
|
||||
G4ProcessVector& procs = *(pm->GetProcessList());
|
||||
G4ProcessVector& procsM= *(pmM->GetProcessList());
|
||||
if( procs.size() != procsM.size() )
|
||||
{
|
||||
G4cout << "G4WorkerRunManagerKernel::SetupShadowProcess() for particle <"
|
||||
<< pd->GetParticleName() << ">" << G4endl;
|
||||
G4cout << " ProcessManager : " << pm << " ProcessManagerShadow : " << pmM << G4endl;
|
||||
for(std::size_t iv1=0;iv1<procs.size();++iv1)
|
||||
{ G4cout << " " << iv1 << " - " << procs[iv1]->GetProcessName() << G4endl; }
|
||||
G4cout << "--------------------------------------------------------------" << G4endl;
|
||||
for(std::size_t iv2=0;iv2<procsM.size();++iv2)
|
||||
{ G4cout << " " << iv2 << " - " << procsM[iv2]->GetProcessName() << G4endl; }
|
||||
G4cout << "--------------------------------------------------------------" << G4endl;
|
||||
G4ExceptionDescription msg;
|
||||
msg<<" Size of G4ProcessVector is inconsistent between master and worker threads ";
|
||||
msg<<" for the particle <"<<pd->GetParticleName()<<">. \n";
|
||||
msg<<" size of G4ProcessVector for worker thread is "<<procs.size();
|
||||
msg<<" while master thread is "<<procsM.size()<<".";
|
||||
G4Exception("G4WorkerRunManagerKernel::SetupShadowProcess()","Run0117",FatalException,msg);
|
||||
}
|
||||
//To each process add the reference to the same
|
||||
//process from master. Note that we rely on
|
||||
//processes being in the correct order!
|
||||
// We could use some checking using process name or type
|
||||
for ( std::size_t idx = 0 ; idx < procs.size() ; ++idx )
|
||||
{
|
||||
procs[idx]->SetMasterProcess(procsM[idx]);
|
||||
}
|
||||
G4ExceptionDescription msg;
|
||||
msg
|
||||
<< "Process manager or process manager shadow to master are not set.\n";
|
||||
msg << "Particle : " << pd->GetParticleName() << " (" << pd
|
||||
<< "), proc-manager: " << pm;
|
||||
msg << " proc-manager-shadow: " << pmM;
|
||||
G4Exception("G4WorkerRunManagerKernel::SetupShadowProcess()", "Run0116",
|
||||
FatalException, msg);
|
||||
return;
|
||||
}
|
||||
G4ProcessVector& procs = *(pm->GetProcessList());
|
||||
G4ProcessVector& procsM = *(pmM->GetProcessList());
|
||||
if(procs.size() != procsM.size())
|
||||
{
|
||||
G4cout << "G4WorkerRunManagerKernel::SetupShadowProcess() for particle <"
|
||||
<< pd->GetParticleName() << ">" << G4endl;
|
||||
G4cout << " ProcessManager : " << pm << " ProcessManagerShadow : " << pmM
|
||||
<< G4endl;
|
||||
for(std::size_t iv1 = 0; iv1 < procs.size(); ++iv1)
|
||||
{
|
||||
G4cout << " " << iv1 << " - " << procs[iv1]->GetProcessName()
|
||||
<< G4endl;
|
||||
}
|
||||
G4cout << "--------------------------------------------------------------"
|
||||
<< G4endl;
|
||||
for(std::size_t iv2 = 0; iv2 < procsM.size(); ++iv2)
|
||||
{
|
||||
G4cout << " " << iv2 << " - " << procsM[iv2]->GetProcessName()
|
||||
<< G4endl;
|
||||
}
|
||||
G4cout << "--------------------------------------------------------------"
|
||||
<< G4endl;
|
||||
G4ExceptionDescription msg;
|
||||
msg
|
||||
<< " Size of G4ProcessVector is inconsistent between master and worker "
|
||||
"threads ";
|
||||
msg << " for the particle <" << pd->GetParticleName() << ">. \n";
|
||||
msg << " size of G4ProcessVector for worker thread is " << procs.size();
|
||||
msg << " while master thread is " << procsM.size() << ".";
|
||||
G4Exception("G4WorkerRunManagerKernel::SetupShadowProcess()", "Run0117",
|
||||
FatalException, msg);
|
||||
}
|
||||
// To each process add the reference to the same
|
||||
// process from master. Note that we rely on
|
||||
// processes being in the correct order!
|
||||
// We could use some checking using process name or type
|
||||
for(std::size_t idx = 0; idx < procs.size(); ++idx)
|
||||
{
|
||||
procs[idx]->SetMasterProcess(procsM[idx]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+151
-160
@@ -24,219 +24,210 @@
|
||||
// ********************************************************************
|
||||
//
|
||||
#include "G4WorkerThread.hh"
|
||||
#include "G4WorkerRunManager.hh"
|
||||
#include "G4MTRunManager.hh"
|
||||
#include "G4WorkerRunManager.hh"
|
||||
|
||||
#include "G4GeometryWorkspace.hh"
|
||||
#include "G4SolidsWorkspace.hh"
|
||||
#include "G4ParticlesWorkspace.hh"
|
||||
#include "G4PhysicsListWorkspace.hh"
|
||||
#include "G4SolidsWorkspace.hh"
|
||||
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
#include "G4Region.hh"
|
||||
#include "G4RegionStore.hh"
|
||||
#include "G4LogicalVolume.hh"
|
||||
#include "G4Region.hh"
|
||||
#include "G4PhysicalVolumeStore.hh"
|
||||
#include "G4LogicalVolumeStore.hh"
|
||||
|
||||
void G4WorkerThread::SetThreadId(G4int tid)
|
||||
{
|
||||
threadId = tid;
|
||||
}
|
||||
void G4WorkerThread::SetThreadId(G4int tid) { threadId = tid; }
|
||||
|
||||
G4int G4WorkerThread::GetThreadId() const
|
||||
{
|
||||
return threadId;
|
||||
}
|
||||
G4int G4WorkerThread::GetThreadId() const { return threadId; }
|
||||
|
||||
void G4WorkerThread::SetNumberThreads(G4int nw)
|
||||
{
|
||||
numThreads = nw;
|
||||
}
|
||||
void G4WorkerThread::SetNumberThreads(G4int nw) { numThreads = nw; }
|
||||
|
||||
G4int G4WorkerThread::GetNumberThreads() const
|
||||
{
|
||||
return numThreads;
|
||||
}
|
||||
G4int G4WorkerThread::GetNumberThreads() const { return numThreads; }
|
||||
|
||||
void G4WorkerThread::BuildGeometryAndPhysicsVector()
|
||||
{
|
||||
// Initialise all split classes
|
||||
// with copy of data from master thread
|
||||
// Initialise all split classes
|
||||
// with copy of data from master thread
|
||||
|
||||
G4GeometryWorkspace::GetPool()->CreateAndUseWorkspace();
|
||||
G4SolidsWorkspace::GetPool()->CreateAndUseWorkspace();
|
||||
G4ParticlesWorkspace::GetPool()->CreateAndUseWorkspace();
|
||||
G4PhysicsListWorkspace::GetPool()->CreateAndUseWorkspace();
|
||||
G4GeometryWorkspace::GetPool()->CreateAndUseWorkspace();
|
||||
G4SolidsWorkspace::GetPool()->CreateAndUseWorkspace();
|
||||
G4ParticlesWorkspace::GetPool()->CreateAndUseWorkspace();
|
||||
G4PhysicsListWorkspace::GetPool()->CreateAndUseWorkspace();
|
||||
}
|
||||
|
||||
void G4WorkerThread::DestroyGeometryAndPhysicsVector()
|
||||
{
|
||||
// Clear all split classes
|
||||
// Clear all split classes
|
||||
|
||||
G4GeometryWorkspace::GetPool()->CleanUpAndDestroyAllWorkspaces();
|
||||
G4SolidsWorkspace::GetPool()->CleanUpAndDestroyAllWorkspaces();
|
||||
G4ParticlesWorkspace::GetPool()->CleanUpAndDestroyAllWorkspaces();
|
||||
G4PhysicsListWorkspace::GetPool()->CleanUpAndDestroyAllWorkspaces();
|
||||
G4GeometryWorkspace::GetPool()->CleanUpAndDestroyAllWorkspaces();
|
||||
G4SolidsWorkspace::GetPool()->CleanUpAndDestroyAllWorkspaces();
|
||||
G4ParticlesWorkspace::GetPool()->CleanUpAndDestroyAllWorkspaces();
|
||||
G4PhysicsListWorkspace::GetPool()->CleanUpAndDestroyAllWorkspaces();
|
||||
}
|
||||
|
||||
void G4WorkerThread::UpdateGeometryAndPhysicsVectorFromMaster()
|
||||
{
|
||||
// =================================================
|
||||
// Step-0: keep sensitive detector and field manager
|
||||
// =================================================
|
||||
// First remember SD and Filed Associated with worker
|
||||
// in order to re-use it
|
||||
// (note that all the stuff after this will reset SD and Field)
|
||||
typedef std::map<G4LogicalVolume*,
|
||||
std::pair<G4VSensitiveDetector*,G4FieldManager*> > LV2SDFM;
|
||||
LV2SDFM lvmap;
|
||||
// =================================================
|
||||
// Step-0: keep sensitive detector and field manager
|
||||
// =================================================
|
||||
// First remember SD and Filed Associated with worker
|
||||
// in order to re-use it
|
||||
// (note that all the stuff after this will reset SD and Field)
|
||||
typedef std::map<G4LogicalVolume*,
|
||||
std::pair<G4VSensitiveDetector*, G4FieldManager*>>
|
||||
LV2SDFM;
|
||||
LV2SDFM lvmap;
|
||||
|
||||
typedef std::map<G4Region*,
|
||||
std::pair<G4FastSimulationManager*,G4UserSteppingAction*> > R2FSM;
|
||||
R2FSM rgnmap;
|
||||
typedef std::map<G4Region*,
|
||||
std::pair<G4FastSimulationManager*, G4UserSteppingAction*>>
|
||||
R2FSM;
|
||||
R2FSM rgnmap;
|
||||
|
||||
G4LogicalVolumeStore* mLogVolStore = G4LogicalVolumeStore::GetInstance();
|
||||
for(size_t ip=0; ip<mLogVolStore->size(); ip++)
|
||||
{
|
||||
G4LogicalVolume *lv = (*mLogVolStore)[ip];
|
||||
G4LogicalVolumeStore* mLogVolStore = G4LogicalVolumeStore::GetInstance();
|
||||
for(size_t ip = 0; ip < mLogVolStore->size(); ip++)
|
||||
{
|
||||
G4LogicalVolume* lv = (*mLogVolStore)[ip];
|
||||
|
||||
// The following needs an explanation.
|
||||
// Consider the case in which the user adds one LogVolume between
|
||||
// the runs. The problem is that the thread-local part (split class)
|
||||
// of the G4LogicalVolume object is not initialized for workers
|
||||
// because the initialization is done once when the thread starts
|
||||
// (see G4MTRunManagerKernel::StartThread Step-2 that calls
|
||||
// G4WorkerThread::BuildGeometryAndPhysicsVector in this class).
|
||||
// The problem is that pointers of SD and FM for these newly added LV
|
||||
// may be invalid pointers (because never initialized, we have seen
|
||||
// this behavior in our testing). If now we remember them and re-use
|
||||
// them in Step-4 below we set invalid pointers to LV for this thread.
|
||||
// Thus we need a way to know if for a given LV we need to remember
|
||||
// or not the SD and FM pointers.
|
||||
// To solve this problem: We assume that the ConstructSDandField() is
|
||||
// called also by Master thread, thus for newly added LV the shadow
|
||||
// pointers of SD and Fields are correct.
|
||||
// (LIMITATION: this assumption may be too stringent, a user to save
|
||||
// memory could instantiate SD only for workers, but we require this
|
||||
// not to happen!).
|
||||
// Thus if a SD and FieldMgr are needed for this particular LV, and
|
||||
// shadow are !=0 it means that user wants an SD and FM to be
|
||||
// associated with LV, we get the values and we remember them.
|
||||
//
|
||||
G4VSensitiveDetector* sd = 0;
|
||||
G4FieldManager* fmgr = 0;
|
||||
if ( lv->GetMasterSensitiveDetector() != 0 )
|
||||
{
|
||||
sd = lv->GetSensitiveDetector();
|
||||
}
|
||||
if ( lv->GetMasterFieldManager() != 0 )
|
||||
{
|
||||
fmgr = lv->GetFieldManager();
|
||||
}
|
||||
if ( sd || fmgr )
|
||||
{
|
||||
lvmap[lv] = std::make_pair(sd,fmgr);
|
||||
}
|
||||
}
|
||||
G4RegionStore* mRegStore = G4RegionStore::GetInstance();
|
||||
for(size_t ir=0; ir<mRegStore->size(); ir++)
|
||||
// The following needs an explanation.
|
||||
// Consider the case in which the user adds one LogVolume between
|
||||
// the runs. The problem is that the thread-local part (split class)
|
||||
// of the G4LogicalVolume object is not initialized for workers
|
||||
// because the initialization is done once when the thread starts
|
||||
// (see G4MTRunManagerKernel::StartThread Step-2 that calls
|
||||
// G4WorkerThread::BuildGeometryAndPhysicsVector in this class).
|
||||
// The problem is that pointers of SD and FM for these newly added LV
|
||||
// may be invalid pointers (because never initialized, we have seen
|
||||
// this behavior in our testing). If now we remember them and re-use
|
||||
// them in Step-4 below we set invalid pointers to LV for this thread.
|
||||
// Thus we need a way to know if for a given LV we need to remember
|
||||
// or not the SD and FM pointers.
|
||||
// To solve this problem: We assume that the ConstructSDandField() is
|
||||
// called also by Master thread, thus for newly added LV the shadow
|
||||
// pointers of SD and Fields are correct.
|
||||
// (LIMITATION: this assumption may be too stringent, a user to save
|
||||
// memory could instantiate SD only for workers, but we require this
|
||||
// not to happen!).
|
||||
// Thus if a SD and FieldMgr are needed for this particular LV, and
|
||||
// shadow are !=0 it means that user wants an SD and FM to be
|
||||
// associated with LV, we get the values and we remember them.
|
||||
//
|
||||
G4VSensitiveDetector* sd = 0;
|
||||
G4FieldManager* fmgr = 0;
|
||||
if(lv->GetMasterSensitiveDetector() != 0)
|
||||
{
|
||||
G4Region* reg = (*mRegStore)[ir];
|
||||
G4FastSimulationManager* fsm = reg->GetFastSimulationManager();
|
||||
G4UserSteppingAction* usa = reg->GetRegionalSteppingAction();
|
||||
if ( reg || usa )
|
||||
{
|
||||
rgnmap[reg] = std::make_pair(fsm,usa);
|
||||
}
|
||||
sd = lv->GetSensitiveDetector();
|
||||
}
|
||||
if(lv->GetMasterFieldManager() != 0)
|
||||
{
|
||||
fmgr = lv->GetFieldManager();
|
||||
}
|
||||
if(sd || fmgr)
|
||||
{
|
||||
lvmap[lv] = std::make_pair(sd, fmgr);
|
||||
}
|
||||
}
|
||||
G4RegionStore* mRegStore = G4RegionStore::GetInstance();
|
||||
for(size_t ir = 0; ir < mRegStore->size(); ir++)
|
||||
{
|
||||
G4Region* reg = (*mRegStore)[ir];
|
||||
G4FastSimulationManager* fsm = reg->GetFastSimulationManager();
|
||||
G4UserSteppingAction* usa = reg->GetRegionalSteppingAction();
|
||||
if(reg || usa)
|
||||
{
|
||||
rgnmap[reg] = std::make_pair(fsm, usa);
|
||||
}
|
||||
}
|
||||
|
||||
//===========================
|
||||
// Step-1: Clean the workspace
|
||||
//===========================
|
||||
G4GeometryWorkspace* geomWorkspace =
|
||||
G4GeometryWorkspace::GetPool()->GetWorkspace();
|
||||
geomWorkspace->DestroyWorkspace();
|
||||
G4SolidsWorkspace* solidWorkspace =
|
||||
G4SolidsWorkspace::GetPool()->GetWorkspace();
|
||||
solidWorkspace->DestroyWorkspace();
|
||||
|
||||
//===========================
|
||||
// Step-2: Re-create and initialize workspace
|
||||
//===========================
|
||||
geomWorkspace->InitialiseWorkspace();
|
||||
solidWorkspace->InitialiseWorkspace();
|
||||
|
||||
//===================================================
|
||||
// Step-4: Restore sensitive detector and field manaer
|
||||
//===================================================
|
||||
for ( LV2SDFM::const_iterator it = lvmap.begin() ;
|
||||
it != lvmap.end() ; ++it )
|
||||
{
|
||||
G4LogicalVolume* lv = it->first;
|
||||
G4VSensitiveDetector* sd = (it->second).first;
|
||||
G4FieldManager* fmgr = (it->second).second;
|
||||
if (fmgr) // What should be the second parameter?
|
||||
{ // We use always false for MT mode
|
||||
lv->SetFieldManager(fmgr, false);
|
||||
}
|
||||
if (sd)
|
||||
{
|
||||
lv->SetSensitiveDetector(sd);
|
||||
}
|
||||
//===========================
|
||||
// Step-1: Clean the workspace
|
||||
//===========================
|
||||
G4GeometryWorkspace* geomWorkspace =
|
||||
G4GeometryWorkspace::GetPool()->GetWorkspace();
|
||||
geomWorkspace->DestroyWorkspace();
|
||||
G4SolidsWorkspace* solidWorkspace =
|
||||
G4SolidsWorkspace::GetPool()->GetWorkspace();
|
||||
solidWorkspace->DestroyWorkspace();
|
||||
|
||||
//===========================
|
||||
// Step-2: Re-create and initialize workspace
|
||||
//===========================
|
||||
geomWorkspace->InitialiseWorkspace();
|
||||
solidWorkspace->InitialiseWorkspace();
|
||||
|
||||
//===================================================
|
||||
// Step-4: Restore sensitive detector and field manaer
|
||||
//===================================================
|
||||
for(LV2SDFM::const_iterator it = lvmap.begin(); it != lvmap.end(); ++it)
|
||||
{
|
||||
G4LogicalVolume* lv = it->first;
|
||||
G4VSensitiveDetector* sd = (it->second).first;
|
||||
G4FieldManager* fmgr = (it->second).second;
|
||||
if(fmgr) // What should be the second parameter?
|
||||
{ // We use always false for MT mode
|
||||
lv->SetFieldManager(fmgr, false);
|
||||
}
|
||||
for ( R2FSM::const_iterator it3 = rgnmap.begin() ;
|
||||
it3 != rgnmap.end() ; it3++ )
|
||||
if(sd)
|
||||
{
|
||||
G4Region* reg = it3->first;
|
||||
G4FastSimulationManager* fsm = (it3->second).first;
|
||||
if(fsm) reg->SetFastSimulationManager(fsm);
|
||||
G4UserSteppingAction* usa = (it3->second).second;
|
||||
if(usa) reg->SetRegionalSteppingAction(usa);
|
||||
lv->SetSensitiveDetector(sd);
|
||||
}
|
||||
}
|
||||
for(R2FSM::const_iterator it3 = rgnmap.begin(); it3 != rgnmap.end(); it3++)
|
||||
{
|
||||
G4Region* reg = it3->first;
|
||||
G4FastSimulationManager* fsm = (it3->second).first;
|
||||
if(fsm)
|
||||
reg->SetFastSimulationManager(fsm);
|
||||
G4UserSteppingAction* usa = (it3->second).second;
|
||||
if(usa)
|
||||
reg->SetRegionalSteppingAction(usa);
|
||||
}
|
||||
}
|
||||
|
||||
void G4WorkerThread::SetPinAffinity(G4int affinity) const
|
||||
{
|
||||
if ( affinity == 0 ) return;
|
||||
if(affinity == 0)
|
||||
return;
|
||||
|
||||
#if !defined(WIN32)
|
||||
G4cout << "AFFINITY SET" << G4endl;
|
||||
// Assign this thread to cpus in a round robin way
|
||||
G4int offset = affinity;
|
||||
G4int offset = affinity;
|
||||
G4int cpuindex = 0;
|
||||
if ( std::abs(offset)>G4Threading::G4GetNumberOfCores() )
|
||||
if(std::abs(offset) > G4Threading::G4GetNumberOfCores())
|
||||
{
|
||||
G4Exception("G4WorkerThread::SetPinAffinity()","Run0100", JustWarning,
|
||||
"Cannot set thread affinity, affinity parameter larger than number of cores");
|
||||
return;
|
||||
G4Exception("G4WorkerThread::SetPinAffinity()", "Run0100", JustWarning,
|
||||
"Cannot set thread affinity, affinity parameter larger than "
|
||||
"number of cores");
|
||||
return;
|
||||
}
|
||||
if (offset>0) // Start assigning affinity to given CPU
|
||||
if(offset > 0) // Start assigning affinity to given CPU
|
||||
{
|
||||
--offset;
|
||||
cpuindex = (GetThreadId()+offset) % G4Threading::G4GetNumberOfCores();
|
||||
// Round robin
|
||||
--offset;
|
||||
cpuindex = (GetThreadId() + offset) % G4Threading::G4GetNumberOfCores();
|
||||
// Round robin
|
||||
}
|
||||
else // Exclude the given CPU
|
||||
{
|
||||
offset *= -1;
|
||||
--offset;
|
||||
G4int myidx = GetThreadId()%(G4Threading::G4GetNumberOfCores()-1);
|
||||
cpuindex = myidx + (myidx>=offset);
|
||||
offset *= -1;
|
||||
--offset;
|
||||
G4int myidx = GetThreadId() % (G4Threading::G4GetNumberOfCores() - 1);
|
||||
cpuindex = myidx + (myidx >= offset);
|
||||
}
|
||||
G4cout << "Setting affinity to:" << cpuindex << G4endl;
|
||||
|
||||
#if defined(G4MULTITHREADED)
|
||||
// Avoid compilation warning in C90 standard w/o MT
|
||||
G4NativeThread t = pthread_self();
|
||||
#else
|
||||
G4NativeThread t;
|
||||
#endif
|
||||
G4bool success = G4Threading::G4SetPinAffinity(cpuindex,t);
|
||||
if ( ! success )
|
||||
# if defined(G4MULTITHREADED)
|
||||
// Avoid compilation warning in C90 standard w/o MT
|
||||
G4NativeThread t = pthread_self();
|
||||
# else
|
||||
G4NativeThread t;
|
||||
# endif
|
||||
G4bool success = G4Threading::G4SetPinAffinity(cpuindex, t);
|
||||
if(!success)
|
||||
{
|
||||
G4Exception("G4MTRunManagerKernel::StarThread()", "Run0101",
|
||||
JustWarning, "Cannot set thread affinity.");
|
||||
G4Exception("G4MTRunManagerKernel::StarThread()", "Run0101", JustWarning,
|
||||
"Cannot set thread affinity.");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user