Import Geant4 10.3.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-12-09 12:35:28 +01:00
parent 4ec577e5c4
commit a3452e42ac
3514 changed files with 210500 additions and 89628 deletions
+2 -1
View File
@@ -1,4 +1,4 @@
# $Id: GNUmakefile 70423 2013-05-30 09:09:21Z gcosmo $
# $Id: GNUmakefile 99173 2016-09-07 09:36:59Z gcosmo $
# ----------------------------------------------------------
# GNUmakefile for run library. Gabriele Cosmo, 3/4/1997.
# ----------------------------------------------------------
@@ -26,6 +26,7 @@ CPPFLAGS += \
-I$(G4BASE)/global/management/include \
-I$(G4BASE)/global/HEPRandom/include \
-I$(G4BASE)/global/HEPGeometry/include \
-I$(G4BASE)/global/HEPNumerics/include \
-I$(G4BASE)/processes/management/include \
-I$(G4BASE)/materials/include \
-I$(G4BASE)/particles/management/include \
+100 -1
View File
@@ -1,4 +1,4 @@
$Id: History 97386 2016-06-02 10:01:40Z gcosmo $
$Id: History 101679 2016-11-21 09:30:00Z gcosmo $
-------------------------------------------------------------------
=========================================================
@@ -17,6 +17,105 @@ committal in the CVS repository !
* Reverse chronological order (last date on top), please *
----------------------------------------------------------
November 15, 2016 A. Dotti (run-V10-02-38,-39)
- Fix bug #1908: create unique names with logVol pointer value
for G4MultiSD and avoid to register target SD implictly
November 7, 2016, G.Folger (run-V10-02-37)
- remove #define for aParticleIterator from G4VPhysicsConstructor.hh
Move the #define for theParticleIterator to G4VUserPhysicsList.cc
October 21, 2016, A.Dotti (run-V10-02-36)
- Partially revert back previous tag to solve deadlocks.
G4MTRunManager::GetNumberOfActiveThreads() returns size of the
threads pool. This number may be different from
G4Threading::GetNumberOfWorkerThreads() that instead returns the
number of threads currently in running state (during start
of threads)
October 21, 2016 G.Cosmo (run-V10-02-35)
- Moved initialisation of G4VUPLSplitter thread-local data to be inline
along with generic template type. Removed explicit initialisation of
thread-local data from workspaces, as now happening inline in
G4TWorkspacePool.
Fixing compilation/linking errors on clang-3.9 and XCode-8 on MacOS.
- Requires tags "global-V10-02-30" and "particles-V10-02-30".
October 12, 2016, A.Dotti (run-V10-02-34)
- Use G4Threading::GetNumberOfWorkerThreads method.
Requires global-V10-02-28
October 14, 2016, G.Cosmo (run-V10-02-33, 32)
- Again trying fixing G4RNGHelper inlining issue.
October 13, 2016, G.Cosmo (run-V10-02-31)
- Explicitly initialise G4VUPLSplitter data in G4PhysicsListWorkspace.
- Moved static GetInstance() method in G4RNGHelper to be not inline.
- Grouped #include statements in G4WorkerThread.cc.
October 12, 2016, G.Folger (run-V10-02-30)
- Add method GetParticleIterator in G4VUserPhysicsList
and make these methods const and protected in both classes
... fix for compilation/linking errors on clang-3.9 and XCode-8 on MacOS.
October 11, 2016, G.Folger (run-V10-02-29)
- Add method GetParticleIterator in G4VPhysicsConstructor
Start to fix for compilation/linking errors on clang-3.9 and XCode-8 on MacOS.
October 3, 2016, M.Asai (run-V10-02-27, -28)
- G4GunManagerKernel: G4Exception is replaced with G4cout when the world
volume is assigned at PreInit or Idle state.
September 21, 2016, G.Cosmo
- Restored trunk to "run-V10-02-25".
Modifications done in previous tags cause duplicate symbols in generation
of the dynamic library on Mac... A cleaner solution needs to be applied in
order to take also into account improper use of splitters symbols by
derived physics-lists and custom physics-lists in examples and tests.
September 20, 2016, G.Cosmo (run-V10-02-26)
- Explicitly initialise templated data in G4PhysicsListWorkspace,
G4VUserPhysicsList, G4WorkerThread, G4WorkerRunManager and
G4MTRunManager translation units.
Fixing compilation/linking errors on clang-3.9 and XCode-8 on MacOS.
September 14, 2016, M.Asai (run-V10-02-25)
- Geant4 is now in G4State_Init state while initialization phase.
This is enforced even if the user uses only the G4GunManagerKernel.
September 13, 2016, M.Asai (run-V10-02-24)
- Geant4 is now in G4State_Init state while G4RunManager::Initialize().
September 7, 2016, G.Cosmo (run-V10-02-23)
- Fixed GNUmakefile for missing dependency on global/HEPNumerics, now required.
September 2, 2016 M.Asai (run-V10-02-22)
- sources.cmake : add global/HEPNumerics
August 4, 2016 M.Asai (run-V10-02-21)
- G4WorkerRunManager.cc : minor printout improvement.
July 29, 30, 2016 M.Asai (run-V10-02-19, -20)
- Fix G4UnitDefinition to be properly shared by all threads.
Addressed to Bug report #1869.
July 22, 2016 M.Asai (run-V10-02-16, -17 and -18)
- Fix G4UnitsTable to be properly shared by all threads.
Addressed to Bug report #1869.
July 21, 2016 L.Desorgher (run-V10-02-15)
- Remove compilation warnings in G4AdjointPrimaryGeneratorAction.
July 21, 2016 L.Desorgher (run-V10-02-14)
- Modification of G4AdjointSimManager, G4AdjointPrimaryGeneratorAction
and G4AdjointSimMessenger for the implementation of the
splitting of the reverse MC tracking.
July 7, 2016 G.Cosmo (run-V10-02-13)
- Removed redundant check in G4VUPLSplitter::UseWorkArea().
Addressing problem report #1876.
June 1, 2016 M.Asai (run-V10-02-12)
- G4PhysicsListHelper.cc: Fix the default process ordering parameters
for G4UnknownDecay that should not have AtRest.
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4AdjointPrimaryGeneratorAction.hh 86968 2014-11-21 11:52:04Z gcosmo $
// $Id: G4AdjointPrimaryGeneratorAction.hh 98735 2016-08-09 10:54:06Z gcosmo $
//
/////////////////////////////////////////////////////////////////////////////////
// Class Name: G4AdjointPrimaryGeneratorAction
@@ -101,6 +101,9 @@ class G4AdjointPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
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
@@ -135,6 +138,8 @@ class G4AdjointPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
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
//--------------------------
+34 -9
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4AdjointSimManager.hh 81773 2014-06-05 08:35:38Z gcosmo $
// $Id: G4AdjointSimManager.hh 98735 2016-08-09 10:54:06Z gcosmo $
//
/////////////////////////////////////////////////////////////////////////////////
// Class Name: G4AdjointSimManager.hh
@@ -170,15 +170,21 @@ class G4AdjointSimManager: public G4UserRunAction
void RegisterAdjointPrimaryWeight(G4double aWeight);
//to continue here
inline G4int GetIDOfLastAdjParticleReachingExtSource(){return ID_of_last_particle_that_reach_the_ext_source;};
G4ThreeVector GetPositionAtEndOfLastAdjointTrack();
G4ThreeVector GetDirectionAtEndOfLastAdjointTrack();
G4double GetEkinAtEndOfLastAdjointTrack();
G4double GetEkinNucAtEndOfLastAdjointTrack();
G4double GetWeightAtEndOfLastAdjointTrack();
G4double GetCosthAtEndOfLastAdjointTrack();
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();
G4int GetFwdParticleIndexAtEndOfLastAdjointTrack();
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();
@@ -223,6 +229,12 @@ class G4AdjointSimManager: public G4UserRunAction
//---------------------------
void SetNbOfPrimaryFwdGammasPerEvent(G4int);
//Set nb of adjoint primaries for reverse splitting
//-------------------------------------------------
void SetNbAdjointPrimaryGammasPerEvent(G4int);
void SetNbAdjointPrimaryElectronsPerEvent(G4int);
//Convergence test
//-----------------------
/*
@@ -289,6 +301,19 @@ class G4AdjointSimManager: public G4UserRunAction
//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
+3 -1
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4AdjointSimMessenger.hh 81773 2014-06-05 08:35:38Z gcosmo $
// $Id: G4AdjointSimMessenger.hh 98735 2016-08-09 10:54:06Z gcosmo $
//
/////////////////////////////////////////////////////////////////////////////////
// Class Name: G4AdjointSimMessenger.hh
@@ -167,6 +167,8 @@ class G4AdjointSimMessenger: public G4UImessenger
G4UIcmdWithAString* NeglectParticleAsPrimaryCmd;
G4UIcmdWithAnInteger* setNbOfPrimaryFwdGammasPerEventCmd;
G4UIcmdWithAnInteger* setNbOfPrimaryAdjGammasPerEventCmd;
G4UIcmdWithAnInteger* setNbOfPrimaryAdjElectronsPerEventCmd;
};
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
+4 -1
View File
@@ -102,7 +102,10 @@ public:
//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
//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;
+46 -48
View File
@@ -44,72 +44,57 @@
#include "globals.hh"
template <class T>
class G4TemplateRNGHelper {
private:
static G4TemplateRNGHelper* instance;
public:
class G4TemplateRNGHelper
{
public:
// The container is modeled as a (shared) singleton
static G4TemplateRNGHelper* GetInstance() {
if (!instance)
{
instance = new G4TemplateRNGHelper();
}
return instance;
}
static G4TemplateRNGHelper<T>* GetInstance();
typedef std::vector<T> SeedsQueue;
typedef typename SeedsQueue::size_type SeedsQueueSize_type;
private:
G4TemplateRNGHelper()
virtual ~G4TemplateRNGHelper()
{
offset=0;
nev_filled=0;
nev_total=0;
nRandParEvent=0;
}
public:
virtual ~G4TemplateRNGHelper() {
Clear();
instance = 0;
Clear();
instance = 0;
}
//Returns seed given id
virtual const T GetSeed(const G4int& sdId ) {
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();
virtual const T GetSeed(const G4int& sdId )
{
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();
}
//Adds one seed to the collection
void AddOneSeed( const T& seed ) { seeds.push_back(seed); }
//Fills N primary seed pairs
void Fill(double* dbl,int nev,int nev_tot,int nrpe)
void Fill(G4double* dbl,G4int nev,G4int nev_tot,G4int nrpe)
{
seeds.clear();
for(int i=0;i<nrpe*nev;i++)
{ seeds.push_back((long)(100000000L*dbl[i])); }
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;
}
void Refill(double* dbl, int nev)
void Refill(G4double* dbl, G4int nev)
{
if(nev==0) return;
seeds.clear();
for(int i=0;i<nRandParEvent*nev;i++)
{ seeds.push_back((long)(100000000L*dbl[i])); }
for(G4int i=0;i<nRandParEvent*nev;i++)
{ seeds.push_back((G4long)(100000000L*dbl[i])); }
offset += nev_filled;
nev_filled = nev;
}
@@ -119,18 +104,31 @@ public:
//Empty the seeds container
virtual void Clear() { seeds.clear(); }
protected:
protected:
SeedsQueue seeds;
// Note: following numbers are number of events.
// seeds are generated for nRandParEvent times n_event
int offset;
int nev_filled;
int nev_total;
int nRandParEvent;
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<long> G4RNGHelper;
typedef G4TemplateRNGHelper<G4long> G4RNGHelper;
typedef G4TemplateRNGHelper<G4String> G4StringRNGHelper;
typedef std::queue<long> G4SeedsQueue;
typedef std::queue<G4long> G4SeedsQueue;
#endif
+3 -2
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VPhysicsConstructor.hh 68802 2013-04-05 13:54:41Z gcosmo $
// $Id: G4VPhysicsConstructor.hh 101155 2016-11-08 08:21:41Z gcosmo $
//
//
// ------------------------------------------------------------
@@ -116,7 +116,7 @@ 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
{
@@ -165,6 +165,7 @@ class G4VPhysicsConstructor
G4ParticleTable* theParticleTable;
G4int g4vpcInstanceID;
G4RUN_DLL static G4VPCManager subInstanceManager;
G4ParticleTable::G4PTblDicIterator* GetParticleIterator() const;
public:
inline G4int GetInstanceID() const;
static const G4VPCManager& GetSubInstanceManager();
+10 -14
View File
@@ -73,7 +73,8 @@ class G4VUPLSplitter
{
public:
G4VUPLSplitter() : totalobj(0),totalspace(0),sharedOffset(0) {
G4VUPLSplitter() : totalobj(0),totalspace(0),sharedOffset(0)
{
G4MUTEXINIT(mutex);
}
@@ -88,7 +89,8 @@ class G4VUPLSplitter
totalobj++;
//If the number of objects is larger than the available spaces,
//a re-allocation is needed
if (totalobj > workertotalspace) {
if (totalobj > workertotalspace)
{
l.unlock();
NewSubInstances();
l.lock();
@@ -140,18 +142,9 @@ class G4VUPLSplitter
// Use recycled work area - which was created previously
if( offset && offset!=newOffset )
{
if( newOffset != offset )
{
G4Exception("G4VUPLSplitter::UseWorkspace()",
"TwoWorkspaces", FatalException,
"Thread already has workspace - cannot use another.");
}
else
{
G4Exception("G4VUPLSplitter::UseWorkspace()",
"TwoWorkspaces", JustWarning,
"Thread already has a workspace - trying to set the same again.");
}
G4Exception("G4VUPLSplitter::UseWorkspace()",
"TwoWorkspaces", FatalException,
"Thread already has workspace - cannot use another.");
}
offset= newOffset;
// totalobj= numObjects;
@@ -201,4 +194,7 @@ class G4VUPLSplitter
G4Mutex mutex;
};
template<typename T> G4ThreadLocal G4int G4VUPLSplitter<T>::workertotalspace=0;
template<typename T> G4ThreadLocal T* G4VUPLSplitter<T>::offset=0;
#endif
+4 -6
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VUserPhysicsList.hh 73123 2013-08-19 07:52:00Z gcosmo $
// $Id: G4VUserPhysicsList.hh 101155 2016-11-08 08:21:41Z gcosmo $
//
//
// ------------------------------------------------------------
@@ -150,11 +150,7 @@ 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 G4MT_theMessenger ((this->subInstanceManager.offset[this->g4vuplInstanceID])._theMessenger)
#define G4MT_thePLHelper ((this->subInstanceManager.offset[this->g4vuplInstanceID])._thePLHelper)
#define fIsPhysicsTableBuilt ((this->subInstanceManager.offset[this->g4vuplInstanceID])._fIsPhysicsTableBuilt)
#define fDisplayThreshold ((this->subInstanceManager.offset[this->g4vuplInstanceID])._fDisplayThreshold)
//#define theParticleIterator ((this->subInstanceManager.offset[this->g4vuplInstanceID])._theParticleIterator)
class G4VUserPhysicsList
{
@@ -191,6 +187,7 @@ class G4VUserPhysicsList
G4bool RegisterProcess(G4VProcess* process,
G4ParticleDefinition* particle);
public:
void UseCoupledTransportation(G4bool vl=true);
@@ -394,6 +391,7 @@ class G4VUserPhysicsList
protected:
G4int g4vuplInstanceID;
G4RUN_DLL static G4VUPLManager subInstanceManager;
G4ParticleTable::G4PTblDicIterator* GetParticleIterator() const;
public:
inline G4int GetInstanceID() const;
static const G4VUPLManager& GetSubInstanceManager();
+3 -1
View File
@@ -11,7 +11,7 @@
#
# Generated on : 24/9/2010
#
# $Id: sources.cmake 95232 2016-02-01 14:31:22Z gcosmo $
# $Id: sources.cmake 99173 2016-09-07 09:36:59Z gcosmo $
#
#------------------------------------------------------------------------------
@@ -31,6 +31,7 @@ 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)
@@ -149,6 +150,7 @@ GEANT4_DEFINE_MODULE(NAME G4run
G4geometrymng
G4globman
G4graphics_reps
G4hepnumerics
G4hits
G4intercoms
G4magneticfield
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4AdjointPrimaryGeneratorAction.cc 97327 2016-06-01 14:24:40Z gcosmo $
// $Id: G4AdjointPrimaryGeneratorAction.cc 98735 2016-08-09 10:54:06Z gcosmo $
//
/////////////////////////////////////////////////////////////////////////////
// Class Name: G4AdjointPrimaryGeneratorAction
@@ -62,6 +62,9 @@ G4AdjointPrimaryGeneratorAction::G4AdjointPrimaryGeneratorAction()
ListOfPrimaryFwdParticles.clear();
ListOfPrimaryAdjParticles.clear();
nb_fwd_gammas_per_event = 1;
nb_adj_primary_gammas_per_event = 1;
nb_adj_primary_electrons_per_event = 1;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//
@@ -92,6 +95,7 @@ void G4AdjointPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
E1=EminIon*A;
E2=EmaxIon*A;
}
//Generate first the forwrad primaries
theAdjointPrimaryGenerator->GenerateFwdPrimaryVertex(anEvent,ListOfPrimaryFwdParticles[index_particle],E1,E2);
G4PrimaryVertex* fwdPrimVertex = anEvent->GetPrimaryVertex();
@@ -135,7 +139,7 @@ void G4AdjointPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
}
}
//Now generate the adjoint primaries
G4PrimaryVertex* adjPrimVertex = new G4PrimaryVertex();
adjPrimVertex->SetPosition(pos.x(),pos.y(),pos.z());
adjPrimVertex->SetT0(0.);
@@ -149,13 +153,39 @@ void G4AdjointPrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
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();
/* if ( !last_generated_part_was_adjoint ) {
+69 -23
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4AdjointSimManager.cc 97327 2016-06-01 14:24:40Z gcosmo $
// $Id: G4AdjointSimManager.cc 98735 2016-08-09 10:54:06Z gcosmo $
//
/////////////////////////////////////////////////////////////////////////////
// Class Name: G4AdjointCrossSurfChecker
@@ -80,8 +80,8 @@ G4AdjointSimManager::G4AdjointSimManager():
//----------------------
theAdjointPrimaryGeneratorAction = new G4AdjointPrimaryGeneratorAction();
theAdjointSteppingAction = new G4AdjointSteppingAction();
theAdjointStackingAction = new G4AdjointStackingAction();
theAdjointTrackingAction = new G4AdjointTrackingAction(theAdjointSteppingAction);
theAdjointStackingAction = new G4AdjointStackingAction(theAdjointTrackingAction);
theAdjointTrackingAction->SetListOfPrimaryFwdParticles(
theAdjointPrimaryGeneratorAction->GetListOfPrimaryFwdParticles());
//Create messenger
@@ -158,7 +158,6 @@ void G4AdjointSimManager::RunAdjointSimulation(G4int nb_evt)
//------------
nb_evt_of_last_run =nb_evt;
G4cout<<"Test Sim Adjoint1"<<std::endl;
G4RunManager::GetRunManager()->BeamOn(nb_evt*theAdjointPrimaryGeneratorAction->GetNbOfAdjointPrimaryTypes());
//G4RunManager::GetRunManager()->BeamOn(theAdjointPrimaryGeneratorAction->GetNbOfAdjointPrimaryTypes()*2*nb_evt);
@@ -351,8 +350,9 @@ void G4AdjointSimManager::SetAdjointTrackingMode(G4bool aBool)//could be removed
//
G4bool G4AdjointSimManager::GetDidAdjParticleReachTheExtSource()
{
return theAdjointSteppingAction->GetDidAdjParticleReachTheExtSource();
return (GetNbOfAdointTracksReachingTheExternalSurface()>0);
}
///////////////////////////////////////////////////////////////////////////////
//
std::vector<G4ParticleDefinition*>* G4AdjointSimManager::GetListOfPrimaryFwdParticles()
@@ -368,34 +368,34 @@ size_t G4AdjointSimManager::GetNbOfPrimaryFwdParticles()
///////////////////////////////////////////////////////////////////////////////
//
G4ThreeVector G4AdjointSimManager::GetPositionAtEndOfLastAdjointTrack(){
return theAdjointTrackingAction->GetPositionAtEndOfLastAdjointTrack();
G4ThreeVector G4AdjointSimManager::GetPositionAtEndOfLastAdjointTrack(size_t i){
return theAdjointTrackingAction->GetPositionAtEndOfLastAdjointTrack(i);
}
///////////////////////////////////////////////////////////////////////////////
//
G4ThreeVector G4AdjointSimManager::GetDirectionAtEndOfLastAdjointTrack(){
return theAdjointTrackingAction->GetDirectionAtEndOfLastAdjointTrack();
G4ThreeVector G4AdjointSimManager::GetDirectionAtEndOfLastAdjointTrack(size_t i){
return theAdjointTrackingAction->GetDirectionAtEndOfLastAdjointTrack(i);
}
//////////////////////////////////////////////////////////////////////////////
//
G4double G4AdjointSimManager::GetEkinAtEndOfLastAdjointTrack(){
return theAdjointTrackingAction->GetEkinAtEndOfLastAdjointTrack();
G4double G4AdjointSimManager::GetEkinAtEndOfLastAdjointTrack(size_t i){
return theAdjointTrackingAction->GetEkinAtEndOfLastAdjointTrack(i);
}
///////////////////////////////////////////////////////////////////////////////
//
G4double G4AdjointSimManager::GetEkinNucAtEndOfLastAdjointTrack(){
return theAdjointTrackingAction->GetEkinNucAtEndOfLastAdjointTrack();
G4double G4AdjointSimManager::GetEkinNucAtEndOfLastAdjointTrack(size_t i){
return theAdjointTrackingAction->GetEkinNucAtEndOfLastAdjointTrack(i);
}
///////////////////////////////////////////////////////////////////////////////
//
G4double G4AdjointSimManager::GetWeightAtEndOfLastAdjointTrack(){
return theAdjointTrackingAction->GetWeightAtEndOfLastAdjointTrack();
G4double G4AdjointSimManager::GetWeightAtEndOfLastAdjointTrack(size_t i){
return theAdjointTrackingAction->GetWeightAtEndOfLastAdjointTrack(i);
}
///////////////////////////////////////////////////////////////////////////////
//
G4double G4AdjointSimManager::GetCosthAtEndOfLastAdjointTrack(){
return theAdjointTrackingAction->GetCosthAtEndOfLastAdjointTrack();
G4double G4AdjointSimManager::GetCosthAtEndOfLastAdjointTrack(size_t i){
return theAdjointTrackingAction->GetCosthAtEndOfLastAdjointTrack(i);
}
///////////////////////////////////////////////////////////////////////////////
//
@@ -404,14 +404,25 @@ const G4String& G4AdjointSimManager::GetFwdParticleNameAtEndOfLastAdjointTrack()
}
///////////////////////////////////////////////////////////////////////////////
//
G4int G4AdjointSimManager::GetFwdParticlePDGEncodingAtEndOfLastAdjointTrack(){
return theAdjointTrackingAction->GetFwdParticlePDGEncodingAtEndOfLastAdjointTrack();
G4int G4AdjointSimManager::GetFwdParticlePDGEncodingAtEndOfLastAdjointTrack(size_t i){
return theAdjointTrackingAction->GetFwdParticlePDGEncodingAtEndOfLastAdjointTrack(i);
}
///////////////////////////////////////////////////////////////////////////////
//
G4int G4AdjointSimManager::GetFwdParticleIndexAtEndOfLastAdjointTrack()
{return theAdjointTrackingAction->GetLastFwdParticleIndex();
G4int G4AdjointSimManager::GetFwdParticleIndexAtEndOfLastAdjointTrack(size_t i)
{return theAdjointTrackingAction->GetLastFwdParticleIndex(i);
}
///////////////////////////////////////////////////////////////////////////////
//
size_t G4AdjointSimManager::GetNbOfAdointTracksReachingTheExternalSurface()
{
return theAdjointTrackingAction->GetNbOfAdointTracksReachingTheExternalSurface();
}
///////////////////////////////////////////////////////////////////////////////
//
void G4AdjointSimManager::ClearEndOfAdjointTrackInfoVectors()
{theAdjointTrackingAction->ClearEndOfAdjointTrackInfoVectors();
}
///////////////////////////////////////////////////////////////////////////////
@@ -447,6 +458,24 @@ void G4AdjointSimManager::RegisterAtEndOfAdjointTrack()
last_weight = theAdjointSteppingAction->GetLastWeight();
last_pos_vec.push_back(last_pos);
last_direction_vec.push_back(last_direction);
last_ekin_vec.push_back(last_ekin);
last_ekin_nuc_vec.push_back(last_ekin_nuc);
last_cos_th_vec.push_back(last_cos_th);
last_weight_vec.push_back(last_weight);
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);
/* 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;
@@ -472,7 +501,7 @@ void G4AdjointSimManager::RegisterAtEndOfAdjointTrack()
}
*/
ID_of_last_particle_that_reach_the_ext_source++;
}
///////////////////////////////////////////////////////////////////////////////
//
@@ -619,9 +648,20 @@ void G4AdjointSimManager::SetNbOfPrimaryFwdGammasPerEvent(G4int nb)
}
///////////////////////////////////////////////////////////////////////////////
//
void G4AdjointSimManager::SetNbAdjointPrimaryGammasPerEvent(G4int nb)
{
theAdjointPrimaryGeneratorAction->SetNbAdjointPrimaryGammasPerEvent(nb);
}
///////////////////////////////////////////////////////////////////////////////
//
void G4AdjointSimManager::SetNbAdjointPrimaryElectronsPerEvent(G4int nb)
{
theAdjointPrimaryGeneratorAction->SetNbAdjointPrimaryElectronsPerEvent(nb);
}
///////////////////////////////////////////////////////////////////////////////
//
void G4AdjointSimManager::BeginOfRunAction(const G4Run* aRun)
{
/*
if (!adjoint_sim_mode){
if(fUserRunAction) fUserRunAction->BeginOfRunAction(aRun);
@@ -631,7 +671,6 @@ void G4AdjointSimManager::BeginOfRunAction(const G4Run* aRun)
}
*/
fUserRunAction->BeginOfRunAction(aRun);
}
///////////////////////////////////////////////////////////////////////////////
//
@@ -649,3 +688,10 @@ void G4AdjointSimManager::EndOfRunAction(const G4Run* aRun)
*/
}
///////////////////////////////////////////////////////////////////////////////
//
G4ParticleDefinition* G4AdjointSimManager::GetLastGeneratedFwdPrimaryParticle(){
return theAdjointPrimaryGeneratorAction->GetLastGeneratedFwdPrimaryParticle();
}
+21 -2
View File
@@ -23,7 +23,7 @@
// * acceptance of all terms of the Geant4 Software license. *
// ********************************************************************
//
// $Id: G4AdjointSimMessenger.cc 81773 2014-06-05 08:35:38Z gcosmo $
// $Id: G4AdjointSimMessenger.cc 98735 2016-08-09 10:54:06Z gcosmo $
//
/////////////////////////////////////////////////////////////////////////////
// Class Name: G4AdjointCrossSurfChecker
@@ -160,7 +160,7 @@ G4AdjointSimMessenger::G4AdjointSimMessenger(G4AdjointSimManager* pAdjointRunMan
ConsiderParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
NeglectParticleAsPrimaryCmd= new G4UIcmdWithAString("/adjoint/NeglectAsPrimary",this);
NeglectParticleAsPrimaryCmd->SetGuidance("Remove the selected particle from the lits of primaries");
NeglectParticleAsPrimaryCmd->SetGuidance("Remove the selected particle from the list of primaries");
NeglectParticleAsPrimaryCmd->SetParameterName("particle",false);
NeglectParticleAsPrimaryCmd->SetCandidates("e- gamma proton ion");
@@ -171,6 +171,19 @@ G4AdjointSimMessenger::G4AdjointSimMessenger(G4AdjointSimManager* pAdjointRunMan
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);
}
@@ -326,6 +339,12 @@ void G4AdjointSimMessenger::SetNewValue(G4UIcommand* command,G4String newValue)
else if ( command== setNbOfPrimaryFwdGammasPerEventCmd){
theAdjointRunManager->SetNbOfPrimaryFwdGammasPerEvent(setNbOfPrimaryFwdGammasPerEventCmd->GetNewIntValue(newValue));
}
else if ( command== setNbOfPrimaryAdjGammasPerEventCmd){
theAdjointRunManager->SetNbAdjointPrimaryGammasPerEvent(setNbOfPrimaryAdjGammasPerEventCmd->GetNewIntValue(newValue));
}
else if ( command== setNbOfPrimaryAdjElectronsPerEventCmd){
theAdjointRunManager->SetNbAdjointPrimaryElectronsPerEvent(setNbOfPrimaryAdjElectronsPerEventCmd->GetNewIntValue(newValue));
}
}
+2 -1
View File
@@ -117,7 +117,7 @@ void* G4MTRunManagerKernel::StartThread(void* context)
//#ifdef G4MULTITHREADED
// turnontpmalloc();
//#endif
G4Threading::WorkerThreadJoinsPool();
wThreadContext = static_cast<G4WorkerThread*>(context);
G4MTRunManager* masterRM = G4MTRunManager::GetMasterRunManager();
@@ -215,6 +215,7 @@ void* G4MTRunManagerKernel::StartThread(void* context)
wThreadContext->DestroyGeometryAndPhysicsVector();
wThreadContext = 0;
G4Threading::WorkerThreadLeavesPool();
return static_cast<void*>(0);
}
+20 -25
View File
@@ -25,10 +25,8 @@
//
#include "G4PhysicsListWorkspace.hh"
//Note: G4PhysicsListWorkspacePool is typedef to G4TWorkspacePool<G4PhysicsListWorkspace>
template<> G4ThreadLocal G4PhysicsListWorkspace* G4PhysicsListWorkspace::pool_type::fMyWorkspace = 0;
namespace {
namespace
{
G4PhysicsListWorkspace::pool_type thePool;
}
@@ -40,46 +38,43 @@ G4PhysicsListWorkspace::G4PhysicsListWorkspace(G4bool verbose)
{
fpVUPLSIM =
&const_cast<G4VUPLManager&>(G4VUserPhysicsList::GetSubInstanceManager());//.NewSubInstances();
&const_cast<G4VUPLManager&>(G4VUserPhysicsList::GetSubInstanceManager());
fpVPCSIM =
&const_cast<G4VPCManager&>(G4VPhysicsConstructor::GetSubInstanceManager());//.NewSubInstances();
&const_cast<G4VPCManager&>(G4VPhysicsConstructor::GetSubInstanceManager());
fpVMPLSIM =
&const_cast<G4VMPLManager&>(G4VModularPhysicsList::GetSubInstanceManager());//.SlaveCopySubInstanceArray();
&const_cast<G4VMPLManager&>(G4VModularPhysicsList::GetSubInstanceManager());
// Copy information from master into PolyCone/Gon Sides in this thread.
InitialiseWorkspace();
// Capture its address of ParticleDefinition split-class in this thread
//fpPDefOffset = fpPDefSIM->GetOffset();
fpVUPLOffset = fpVUPLSIM->GetOffset();
fpVPCOffset = fpVPCSIM->GetOffset();
fpVMPLOffset = fpVMPLSIM->GetOffset();
fpVUPLOffset = fpVUPLSIM->GetOffset();
fpVPCOffset = fpVPCSIM->GetOffset();
fpVMPLOffset = fpVMPLSIM->GetOffset();
}
G4PhysicsListWorkspace::~G4PhysicsListWorkspace()
{
}
// Static methods
// For with current (original) G4WorkerThread -- which uses static methods
void
G4PhysicsListWorkspace::UseWorkspace()
{
if( fVerbose )
G4cout << "G4PhysicsListWorkspace::UseWorkspace: Copying particles-definition Split-Class - Start " << G4endl;
G4cout << "G4PhysicsListWorkspace::UseWorkspace: "
<< "Copying particles-definition Split-Class - Start " << G4endl;
// Implementation copied from G4WorkerThread::BuildGeometryAndPhysicsVector()
// Implementation copied from
// G4WorkerThread::BuildGeometryAndPhysicsVector()
//Physics List related, split classes mechanism: instantiate sub-instance for this thread
// Physics List related, split classes mechanism:
// instantiate sub-instance for this thread
fpVUPLSIM->UseWorkArea(fpVUPLOffset);
fpVPCSIM->UseWorkArea(fpVPCOffset);
fpVMPLSIM->UseWorkArea(fpVMPLOffset);
}
void G4PhysicsListWorkspace::ReleaseWorkspace()
// The opposite of Use Workspace - let go of it.
{
fpVUPLSIM->UseWorkArea(0);
fpVPCSIM->UseWorkArea(0);
@@ -94,12 +89,12 @@ void
G4PhysicsListWorkspace::InitialiseWorkspace()
{
if( fVerbose )
G4cout << "G4PhysicsListWorkspace::InitialiseWorkspace: "
<< "Copying particles-definition Split-Class - Start " << G4endl;
G4cout << "G4PhysicsListWorkspace::InitialiseWorkspace: "
<< "Copying particles-definition Split-Class - Start " << G4endl;
//PhysicsList related, split classes mechanism:
// PhysicsList related, split classes mechanism:
// Do *NOT* instantiate sub-instance for this thread,
// just copy the contents !!
// just copy the contents !!
fpVUPLSIM->NewSubInstances();
fpVPCSIM->NewSubInstances();
fpVMPLSIM->WorkerCopySubInstanceArray();
@@ -108,8 +103,8 @@ G4PhysicsListWorkspace::InitialiseWorkspace()
InitialisePhysicsList();
if( fVerbose )
G4cout << "G4PhysicsListWorkspace::CreateAndUseWorkspace: "
<< "Copying particles-definition Split-Class - Done!" << G4endl;
G4cout << "G4PhysicsListWorkspace::CreateAndUseWorkspace: "
<< "Copying particles-definition Split-Class - Done!" << G4endl;
}
void G4PhysicsListWorkspace::DestroyWorkspace()
+30 -1
View File
@@ -28,8 +28,37 @@
#include "Randomize.hh"
template<>
G4TemplateRNGHelper<long>* G4TemplateRNGHelper<long>::instance = 0;
G4TemplateRNGHelper<G4long>* G4TemplateRNGHelper<G4long>::instance = 0;
template<>
G4TemplateRNGHelper<G4String>* G4TemplateRNGHelper<G4String>::instance = 0;
template<class T>
G4TemplateRNGHelper<T>* G4TemplateRNGHelper<T>::GetInstance()
{
if (!instance)
{
instance = new G4TemplateRNGHelper<T>();
}
return instance;
}
template<>
G4TemplateRNGHelper<G4long>* G4TemplateRNGHelper<G4long>::GetInstance()
{
if (!instance)
{
instance = new G4TemplateRNGHelper<G4long>();
}
return instance;
}
template<>
G4TemplateRNGHelper<G4String>* G4TemplateRNGHelper<G4String>::GetInstance()
{
if (!instance)
{
instance = new G4TemplateRNGHelper<G4String>();
}
return instance;
}
+14 -1
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4RunManager.cc 95232 2016-02-01 14:31:22Z gcosmo $
// $Id: G4RunManager.cc 99345 2016-09-19 06:51:23Z gcosmo $
//
//
@@ -562,9 +562,12 @@ void G4RunManager::Initialize()
return;
}
stateManager->SetNewState(G4State_Init);
if(!geometryInitialized) InitializeGeometry();
if(!physicsInitialized) InitializePhysics();
initializedAtLeastOnce = true;
if(stateManager->GetCurrentState()!=G4State_Idle)
{ stateManager->SetNewState(G4State_Idle); }
}
void G4RunManager::InitializeGeometry()
@@ -578,16 +581,25 @@ void G4RunManager::InitializeGeometry()
if(verboseLevel>1) G4cout << "userDetector->Construct() start." << G4endl;
G4StateManager* stateManager = G4StateManager::GetStateManager();
G4ApplicationState currentState = stateManager->GetCurrentState();
if(currentState==G4State_PreInit || currentState==G4State_Idle)
{ stateManager->SetNewState(G4State_Init); }
kernel->DefineWorldVolume(userDetector->Construct(),false);
userDetector->ConstructSDandField();
nParallelWorlds = userDetector->ConstructParallelGeometries();
userDetector->ConstructParallelSD();
kernel->SetNumberOfParallelWorld(nParallelWorlds);
geometryInitialized = true;
stateManager->SetNewState(currentState);
}
void G4RunManager::InitializePhysics()
{
G4StateManager* stateManager = G4StateManager::GetStateManager();
G4ApplicationState currentState = stateManager->GetCurrentState();
if(currentState==G4State_PreInit || currentState==G4State_Idle)
{ stateManager->SetNewState(G4State_Init); }
if(physicsList)
{
kernel->InitializePhysics();
@@ -598,6 +610,7 @@ void G4RunManager::InitializePhysics()
FatalException, "G4VUserPhysicsList is not defined!");
}
physicsInitialized = true;
stateManager->SetNewState(currentState);
}
+76 -22
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4RunManagerKernel.cc 95232 2016-02-01 14:31:22Z gcosmo $
// $Id: G4RunManagerKernel.cc 99767 2016-10-05 08:54:01Z gcosmo $
//
//
@@ -233,6 +233,10 @@ numberOfParallelWorld(0),geometryNeedsToBeClosed(true),
<< "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^" << G4endl
<< G4endl;
}
#ifdef G4MULTITHREADED
G4UnitDefinition::GetUnitsTable().Synchronize();
#endif
}
void G4RunManagerKernel::SetupDefaultRegion()
@@ -339,15 +343,26 @@ void G4RunManagerKernel::WorkerDefineWorldVolume(G4VPhysicalVolume* worldVol,
{
G4StateManager* stateManager = G4StateManager::GetStateManager();
G4ApplicationState currentState = stateManager->GetCurrentState();
if(!(currentState==G4State_Idle||currentState==G4State_PreInit))
if(currentState!=G4State_Init)
{
G4Exception("G4RunManagerKernel::DefineWorldVolume",
G4cout << "Current application state is "
<< stateManager->GetStateString(currentState) << G4endl;
if(!(currentState==G4State_Idle||currentState==G4State_PreInit))
{
G4Exception("G4RunManagerKernel::DefineWorldVolume",
"DefineWorldVolumeAtIncorrectState",
JustWarning,
"Geant4 kernel is not PreInit or Idle state : Method ignored.");
if(verboseLevel>1) G4cerr << "Current application state is "
<< stateManager->GetStateString(currentState) << G4endl;
return;
FatalException,
"Geant4 kernel is not Init state : Method ignored.");
return;
} else {
//G4Exception("G4RunManagerKernel::DefineWorldVolume",
// "DefineWorldVolumeAtIncorrectState",
// JustWarning,
// "Geant4 kernel is not Init state : Assuming Init state.");
G4cout<<"Warning : Geant4 kernel is not Init state : Assuming Init state."
<<G4endl;
stateManager->SetNewState(G4State_Init);
}
}
currentWorld = worldVol;
@@ -382,6 +397,7 @@ void G4RunManagerKernel::WorkerDefineWorldVolume(G4VPhysicalVolume* worldVol,
}
geometryInitialized = true;
stateManager->SetNewState(currentState);
if(physicsInitialized && currentState!=G4State_Idle)
{ stateManager->SetNewState(G4State_Idle); }
}
@@ -391,13 +407,26 @@ void G4RunManagerKernel::DefineWorldVolume(G4VPhysicalVolume* worldVol,
{
G4StateManager* stateManager = G4StateManager::GetStateManager();
G4ApplicationState currentState = stateManager->GetCurrentState();
if(!(currentState==G4State_Idle||currentState==G4State_PreInit))
{
G4Exception("G4RunManagerKernel::DefineWorldVolume",
"Run00031",
JustWarning,
"Geant4 kernel is not PreInit or Idle state : Method ignored.");
return;
if(currentState!=G4State_Init)
{
G4cout << "Current application state is "
<< stateManager->GetStateString(currentState) << G4endl;
if(!(currentState==G4State_Idle||currentState==G4State_PreInit))
{
G4Exception("G4RunManagerKernel::DefineWorldVolume",
"DefineWorldVolumeAtIncorrectState",
FatalException,
"Geant4 kernel is not Init state : Method ignored.");
return;
} else {
//G4Exception("G4RunManagerKernel::DefineWorldVolume",
// "DefineWorldVolumeAtIncorrectState",
// JustWarning,
// "Geant4 kernel is not Init state : Assuming Init state.");
G4cout<<"Warning : Geant4 kernel is not Init state : Assuming Init state."
<<G4endl;
stateManager->SetNewState(G4State_Init);
}
}
// The world volume MUST NOT have a region defined by the user
@@ -442,6 +471,7 @@ void G4RunManagerKernel::DefineWorldVolume(G4VPhysicalVolume* worldVol,
}
geometryInitialized = true;
stateManager->SetNewState(currentState);
if(physicsInitialized && currentState!=G4State_Idle)
{ stateManager->SetNewState(G4State_Idle); }
}
@@ -475,7 +505,7 @@ void G4RunManagerKernel::SetPhysics(G4VUserPhysicsList* uPhys)
void G4RunManagerKernel::SetupPhysics()
{
G4ParticleTable::GetParticleTable()->SetReadiness();
G4ParticleTable::GetParticleTable()->SetReadiness();
physicsList->ConstructParticle();
@@ -504,6 +534,9 @@ void G4RunManagerKernel::SetupPhysics()
if(particle->IsGeneralIon()) particle->SetParticleDefinitionID(gionId);
}
}
#ifdef G4MULTITHREADED
G4UnitDefinition::GetUnitsTable().Synchronize();
#endif
}
namespace {
@@ -514,12 +547,26 @@ void G4RunManagerKernel::InitializePhysics()
{
G4StateManager* stateManager = G4StateManager::GetStateManager();
G4ApplicationState currentState = stateManager->GetCurrentState();
if(!(currentState==G4State_Idle||currentState==G4State_PreInit))
{
G4Exception("G4RunManagerKernel::InitializePhysics",
"Run0011", JustWarning,
"Geant4 kernel is not PreInit or Idle state : Method ignored.");
return;
if(currentState!=G4State_Init)
{
G4cout << "Current application state is "
<< stateManager->GetStateString(currentState) << G4endl;
if(!(currentState==G4State_Idle||currentState==G4State_PreInit))
{
G4Exception("G4RunManagerKernel::InitializePhysics",
"InitializePhysicsIncorrectState",
FatalException,
"Geant4 kernel is not Init state : Method ignored.");
return;
} else {
//G4Exception("G4RunManagerKernel::DefineWorldVolume",
//"DefineWorldVolumeAtIncorrectState",
//JustWarning,
//"Geant4 kernel is not Init state : Assuming Init state.");
G4cout<<"Warning : Geant4 kernel is not Init state : Assuming Init state."
<<G4endl;
stateManager->SetNewState(G4State_Init);
}
}
if(!physicsList)
@@ -565,6 +612,10 @@ void G4RunManagerKernel::InitializePhysics()
*********************/
physicsInitialized = true;
#ifdef G4MULTITHREADED
G4UnitDefinition::GetUnitsTable().Synchronize();
#endif
stateManager->SetNewState(currentState);
if(geometryInitialized && currentState!=G4State_Idle)
{ stateManager->SetNewState(G4State_Idle); }
}
@@ -622,6 +673,9 @@ G4bool G4RunManagerKernel::RunInitialization(G4bool fakeRun)
GetPrimaryTransformer()->CheckUnknown();
#ifdef G4MULTITHREADED
G4UnitDefinition::GetUnitsTable().Synchronize();
#endif
stateManager->SetNewState(G4State_GeomClosed);
return true;
}
+7 -9
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VModularPhysicsList.cc 85358 2014-10-28 10:02:44Z gcosmo $
// $Id: G4VModularPhysicsList.cc 100421 2016-10-21 12:49:57Z gcosmo $
//
//
// ------------------------------------------------------------
@@ -40,12 +40,6 @@
// in the class G4VMPLData.
#define G4MT_physicsVector ((G4VMPLsubInstanceManager.offset[g4vmplInstanceID]).physicsVector)
template <class G4VMPLData> G4ThreadLocal
G4int G4VUPLSplitter<G4VMPLData>::workertotalspace = 0;
template <class G4VMPLData> G4ThreadLocal
G4VMPLData* G4VUPLSplitter<G4VMPLData>::offset = 0;
G4VMPLManager G4VModularPhysicsList::G4VMPLsubInstanceManager;
void G4VMPLData::initialize()
@@ -88,8 +82,12 @@ G4VModularPhysicsList & G4VModularPhysicsList::operator=(const G4VModularPhysics
fIsCheckedForRetrievePhysicsTable = right.fIsCheckedForRetrievePhysicsTable;
fIsRestoredCutValues = right.fIsRestoredCutValues;
directoryPhysicsTable = right.directoryPhysicsTable;
fDisplayThreshold = static_cast<const G4VUserPhysicsList&>(right).GetSubInstanceManager().offset[right.GetInstanceID()]._fDisplayThreshold;
fIsPhysicsTableBuilt = static_cast<const G4VUserPhysicsList&>(right).GetSubInstanceManager().offset[right.GetInstanceID()]._fIsPhysicsTableBuilt;
//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;
+6 -12
View File
@@ -35,18 +35,6 @@
#include "G4VPhysicsConstructor.hh"
// This static member is thread local. For each thread, it holds the array
// size of G4VPCData instances.
//
template <class G4VPCData> G4ThreadLocal
G4int G4VUPLSplitter<G4VPCData>::workertotalspace = 0;
// This static member is thread local. For each thread, it points to the
// array of G4VPCData instances.
//
template <class G4VPCData> G4ThreadLocal
G4VPCData* G4VUPLSplitter<G4VPCData>::offset = 0;
// This field helps to use the class G4VPCManager
//
G4VPCManager G4VPhysicsConstructor::subInstanceManager;
@@ -86,3 +74,9 @@ G4VPhysicsConstructor::G4VPhysicsConstructor(const G4String& name, G4int type)
G4VPhysicsConstructor::~G4VPhysicsConstructor()
{
}
G4ParticleTable::G4PTblDicIterator* G4VPhysicsConstructor::GetParticleIterator() const
{
return (subInstanceManager.offset[g4vpcInstanceID])._aParticleIterator;
}
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VUserDetectorConstruction.cc 92599 2015-09-07 07:11:43Z gcosmo $
// $Id: G4VUserDetectorConstruction.cc 101679 2016-11-21 09:30:00Z gcosmo $
//
#include "G4VUserDetectorConstruction.hh"
@@ -37,6 +37,7 @@
#include "G4SDManager.hh"
#include "G4MultiSensitiveDetector.hh"
#include <assert.h>
#include <sstream>
G4VUserDetectorConstruction::G4VUserDetectorConstruction()
{;}
@@ -241,7 +242,8 @@ void G4VUserDetectorConstruction::SetSensitiveDetector
{
assert(logVol!=nullptr&&aSD!=nullptr);
G4SDManager::GetSDMpointer()->AddNewDetector(aSD);
//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
@@ -255,7 +257,9 @@ void G4VUserDetectorConstruction::SetSensitiveDetector
if ( msd != nullptr ) {
msd->AddSD(aSD);
} else {
const G4String msdname = "/MultiSD_"+logVol->GetName();
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);
+12 -9
View File
@@ -24,7 +24,7 @@
// ********************************************************************
//
//
// $Id: G4VUserPhysicsList.cc 89244 2015-03-27 16:27:51Z gcosmo $
// $Id: G4VUserPhysicsList.cc 101155 2016-11-08 08:21:41Z gcosmo $
//
//
// ------------------------------------------------------------
@@ -81,14 +81,11 @@
// This static member is thread local. For each thread, it holds the array
// size of G4VUPLData instances.
//
template <class G4VUPLData> G4ThreadLocal
G4int G4VUPLSplitter<G4VUPLData>::workertotalspace = 0;
// This static member is thread local. For each thread, it points to the
// array of G4VUPLData instances.
//
template <class G4VUPLData> G4ThreadLocal
G4VUPLData* G4VUPLSplitter<G4VUPLData>::offset = 0;
#define G4MT_theMessenger ((this->subInstanceManager.offset[this->g4vuplInstanceID])._theMessenger)
#define G4MT_thePLHelper ((this->subInstanceManager.offset[this->g4vuplInstanceID])._thePLHelper)
#define fIsPhysicsTableBuilt ((this->subInstanceManager.offset[this->g4vuplInstanceID])._fIsPhysicsTableBuilt)
#define fDisplayThreshold ((this->subInstanceManager.offset[this->g4vuplInstanceID])._fDisplayThreshold)
#define theParticleIterator ((this->subInstanceManager.offset[this->g4vuplInstanceID])._theParticleIterator)
// This field helps to use the class G4VUPLManager
//
@@ -971,6 +968,12 @@ G4bool G4VUserPhysicsList::RegisterProcess(G4VProcess* process,
return G4MT_thePLHelper->RegisterProcess(process, particle);
}
////////////////////////////////////////////////////////
G4ParticleTable::G4PTblDicIterator* G4VUserPhysicsList::GetParticleIterator() const
{
return (subInstanceManager.offset[g4vuplInstanceID])._theParticleIterator;
}
////////////////////////////////////////////////////////
void G4VUserPhysicsList::SetVerboseLevel(G4int value)
{
+4 -2
View File
@@ -370,8 +370,10 @@ G4Event* G4WorkerRunManager::GenerateEvent(G4int i_event)
if(printModulo > 0 && anEvent->GetEventID()%printModulo == 0 )
{
G4cout << "--> Event " << anEvent->GetEventID() << " starts with initial seeds ("
<< s1 << "," << s2 << ")." << G4endl;
G4cout << "--> Event " << anEvent->GetEventID() << " starts";
if(eventHasToBeSeeded)
{ G4cout << " with initial seeds (" << s1 << "," << s2 << ")"; }
G4cout << "." << G4endl;
}
userPrimaryGeneratorAction->GeneratePrimaries(anEvent);
return anEvent;
+7 -7
View File
@@ -27,6 +27,13 @@
#include "G4WorkerRunManager.hh"
#include "G4MTRunManager.hh"
#include "G4GeometryWorkspace.hh"
#include "G4GeometryWorkspacePool.hh"
#include "G4SolidsWorkspace.hh"
#include "G4SolidsWorkspacePool.hh"
#include "G4ParticlesWorkspace.hh"
#include "G4PhysicsListWorkspace.hh"
void G4WorkerThread::SetThreadId(G4int tid)
{
threadId = tid;
@@ -47,13 +54,6 @@ G4int G4WorkerThread::GetNumberThreads() const
return numThreads;
}
#include "G4GeometryWorkspace.hh"
#include "G4GeometryWorkspacePool.hh"
#include "G4SolidsWorkspace.hh"
#include "G4SolidsWorkspacePool.hh"
#include "G4ParticlesWorkspace.hh"
#include "G4PhysicsListWorkspace.hh"
void G4WorkerThread::BuildGeometryAndPhysicsVector()
{
// Initialise all split classes in the geometry with copy of data from master thread