Import Geant4 10.2.0 source tree

This commit is contained in:
Gabriele Cosmo
2016-06-10 14:11:04 +02:00
parent c9b32a6c0a
commit d4af681f38
4886 changed files with 420149 additions and 1023309 deletions
+56 -26
View File
@@ -156,6 +156,26 @@
class G4SingleParticleSource;
/** Andrea Dotti Feb 2015
* GPS messenger design requires some explanation for what distributions
* parameters are concerned : Each thread has its own GPS
* since primary generation is a user action.
* However to save memory the underlying structures that provide the
* GPS functionalities ( the G4SPS*Distribution classes and the
* G4SPSRandomGenerator class)
* are shared among threads. This implies that modifying parameters of sources
* requires some attention:
* 1- Only one thread should change source parameters.
* 2- Changing of parameters can happen only between runs, when is guaranteed
* that no thread is accessing them
* 2- UI commands require that even if messenger is instantiated in a thread
* the commands are executed in the master (this is possible since V10.1)
* The simplest solution is to use UI commands to change GPS parameters and
* avoid C++ APIs. If this is inevitable a simple solution is to instantiate
* an instance of G4GeneralParticleSource explicitly in the master thread
* (for example in G4VUserActionInitialization::BuildForMaster() and set the
* defaults parameter there).
*/
class G4GeneralParticleSource : public G4VPrimaryGenerator
{
//
@@ -170,62 +190,72 @@ class G4GeneralParticleSource : public G4VPrimaryGenerator
void ListSource();
void SetCurrentSourceto(G4int) ;
void SetCurrentSourceIntensity(G4double);
G4SingleParticleSource* GetCurrentSource() {return currentSource;};
G4int GetCurrentSourceIndex() { return currentSourceIdx; };
G4double GetCurrentSourceIntensity() { return GPSData->GetIntensity(currentSourceIdx); };
G4SingleParticleSource* GetCurrentSource() const
{return GPSData->GetCurrentSource();}
G4int GetCurrentSourceIndex() const
{ return GPSData->GetCurrentSourceIdx(); }
G4double GetCurrentSourceIntensity() const
{ return GPSData->GetIntensity(GetCurrentSourceIndex()); }
void ClearAll();
void AddaSource (G4double);
void DeleteaSource(G4int);
// Set the verbosity level.
void SetVerbosity(G4int i) {currentSource->SetVerbosity(i);} ;
void SetVerbosity(G4int i) {GPSData->SetVerbosityAllSources(i);} ;
// Set if multiple vertex per event.
void SetMultipleVertex(G4bool av) {multiple_vertex = av;} ;
void SetMultipleVertex(G4bool av) { GPSData->SetMultipleVertex(av);} ;
// set if flat_sampling is applied in multiple source case
void SetFlatSampling(G4bool av) {flat_sampling = av; GPSData->SetFlatSampling(av); normalised = false;} ;
void SetFlatSampling(G4bool av) { GPSData->SetFlatSampling(av); normalised = false;} ;
// Set the particle species
void SetParticleDefinition (G4ParticleDefinition * aParticleDefinition)
{currentSource->SetParticleDefinition(aParticleDefinition); } ;
{GPSData->GetCurrentSource()->SetParticleDefinition(aParticleDefinition); } ;
G4ParticleDefinition * GetParticleDefinition () { return currentSource->GetParticleDefinition();} ;
G4ParticleDefinition * GetParticleDefinition () const
{ return GPSData->GetCurrentSource()->GetParticleDefinition();} ;
void SetParticleCharge(G4double aCharge) { currentSource->SetParticleCharge(aCharge); } ;
void SetParticleCharge(G4double aCharge)
{ GPSData->GetCurrentSource()->SetParticleCharge(aCharge); } ;
// Set polarization
void SetParticlePolarization (G4ThreeVector aVal) {currentSource->SetParticlePolarization(aVal);};
G4ThreeVector GetParticlePolarization () {return currentSource->GetParticlePolarization();};
void SetParticlePolarization (G4ThreeVector aVal)
{GPSData->GetCurrentSource()->SetParticlePolarization(aVal);};
G4ThreeVector GetParticlePolarization () const
{return GPSData->GetCurrentSource()->GetParticlePolarization();};
// Set Time.
void SetParticleTime(G4double aTime) { currentSource->SetParticleTime(aTime); };
G4double GetParticleTime() { return currentSource->GetParticleTime(); };
void SetParticleTime(G4double aTime)
{ GPSData->GetCurrentSource()->SetParticleTime(aTime); };
G4double GetParticleTime() const
{ return GPSData->GetCurrentSource()->GetParticleTime(); };
void SetNumberOfParticles(G4int i) { currentSource->SetNumberOfParticles(i); };
void SetNumberOfParticles(G4int i)
{ GPSData->GetCurrentSource()->SetNumberOfParticles(i); };
//
G4int GetNumberOfParticles() { return currentSource->GetNumberOfParticles(); };
G4ThreeVector GetParticlePosition() { return currentSource->GetParticlePosition();};
G4ThreeVector GetParticleMomentumDirection() { return currentSource->GetParticleMomentumDirection();};
G4double GetParticleEnergy() {return currentSource->GetParticleEnergy();};
G4int GetNumberOfParticles() const
{ return GPSData->GetCurrentSource()->GetNumberOfParticles(); };
G4ThreeVector GetParticlePosition() const
{ return GPSData->GetCurrentSource()->GetParticlePosition();};
G4ThreeVector GetParticleMomentumDirection() const
{ return GPSData->GetCurrentSource()->GetParticleMomentumDirection();};
G4double GetParticleEnergy() const
{return GPSData->GetCurrentSource()->GetParticleEnergy();};
private:
void IntensityNormalization();
private:
G4bool multiple_vertex;
G4bool flat_sampling;
//Helper boolean, used to reduce number of locks
//at run time (see GeneratePrimaryVertex)
G4bool normalised;
G4int currentSourceIdx;
G4SingleParticleSource* currentSource;
std::vector <G4SingleParticleSource*> sourceVector;
std::vector <G4double> sourceIntensity;
std::vector <G4double> sourceProbability;
//Note this is a shared resource among MT workers
G4GeneralParticleSourceMessenger* theMessenger;
//Note this will be a shared resource among MT
//Note this is a shared resource among MT workers
G4GeneralParticleSourceData* GPSData;
};
@@ -68,7 +68,6 @@ class G4GeneralParticleSourceData
void AddASource(G4double intensity);
void DeleteASource(G4int idx);
void ClearSources();
void SetSourceVerbosity(G4int verb);
void IntensityNormalise();
@@ -76,15 +75,23 @@ class G4GeneralParticleSourceData
G4SingleParticleSource* GetCurrentSource(G4int idx);
G4SingleParticleSource* GetCurrentSource() const {return currentSource;}
G4int GetSourceVectorSize() const {return G4int(sourceVector.size());}
G4int GetIntensityVectorSize() const {return G4int(sourceIntensity.size());}
G4double GetIntensity(G4int idx)const {return sourceIntensity.at(idx);}
G4double GetSourceProbability(G4int idx) const {return sourceProbability.at(idx);}
void SetCurrentSourceIntensity(G4double);
void SetFlatSampling(G4bool fSamp){flat_sampling = fSamp;}
void SetFlatSampling(G4bool fSamp){flat_sampling = fSamp;}
G4bool GetFlatSampling() const { return flat_sampling; }
void SetMultipleVertex(G4bool flag) { multiple_vertex = flag; }
G4bool GetMultipleVertex() const { return multiple_vertex; }
G4int GetCurrentSourceIdx() const { return currentSourceIdx; }
void SetVerbosityAllSources(G4int vl);
//Lock/Unlock shared mutex
void Lock();
void Unlock();
@@ -96,12 +103,11 @@ class G4GeneralParticleSourceData
private:
//static G4GeneralParticleSourceData* theInstance;
std::vector<G4SingleParticleSource*> sourceVector;
std::vector <G4double> sourceIntensity;
std::vector <G4double> sourceProbability;
G4bool multiple_vertex;
G4bool flat_sampling;
G4bool normalised;
@@ -106,6 +106,27 @@ class G4UIcmdWithoutParameter;
class G4SingleParticleSource;
class G4GeneralParticleSource;
/** Andrea Dotti Feb 2015
* GPS messenger design requires some explanation for what distributions
* parameters are concerned : Each thread has its own GPS
* since primary generation is a user action.
* However to save memory the underlying structures that provide the
* GPS functionalities ( the G4SPS*Distribution classes and the
* G4SPSRandomGenerator class)
* are shared among threads. This implies that modifying parameters of sources
* requires some attention:
* 1- Only one thread should change source parameters.
* 2- Changing of parameters can happen only between runs, when is guaranteed
* that no thread is accessing them
* 2- UI commands require that even if messenger is instantiated in a thread
* the commands are executed in the master (this is possible since V10.1)
* The simplest solution is to use UI commands to change GPS parameters and
* avoid C++ APIs. If this is inevitable a simple solution is to instantiate
* an instance of G4GeneralParticleSource explicitly in the master thread
* (for example in G4VUserActionInitialization::BuildForMaster() and set the
* defaults parameter there).
*/
class G4GeneralParticleSourceMessenger: public G4UImessenger
{
public:
@@ -170,25 +191,25 @@ class G4GeneralParticleSourceMessenger: public G4UImessenger
G4UIcmdWithADoubleAndUnit *parphiCmd1;
G4UIcmdWithAString *confineCmd1;
//old ones, will be reomved soon
G4UIcmdWithAString *typeCmd;
G4UIcmdWithAString *shapeCmd;
G4UIcmdWith3VectorAndUnit *centreCmd;
G4UIcmdWith3Vector *posrot1Cmd;
G4UIcmdWith3Vector *posrot2Cmd;
G4UIcmdWithADoubleAndUnit *halfxCmd;
G4UIcmdWithADoubleAndUnit *halfyCmd;
G4UIcmdWithADoubleAndUnit *halfzCmd;
G4UIcmdWithADoubleAndUnit *radiusCmd;
G4UIcmdWithADoubleAndUnit *radius0Cmd;
G4UIcmdWithADoubleAndUnit *possigmarCmd;
G4UIcmdWithADoubleAndUnit *possigmaxCmd;
G4UIcmdWithADoubleAndUnit *possigmayCmd;
G4UIcmdWithADoubleAndUnit *paralpCmd;
G4UIcmdWithADoubleAndUnit *partheCmd;
G4UIcmdWithADoubleAndUnit *parphiCmd;
G4UIcmdWithAString *confineCmd;
// //old ones, will be reomved soon
// G4UIcmdWithAString *typeCmd;
// G4UIcmdWithAString *shapeCmd;
// G4UIcmdWith3VectorAndUnit *centreCmd;
// G4UIcmdWith3Vector *posrot1Cmd;
// G4UIcmdWith3Vector *posrot2Cmd;
// G4UIcmdWithADoubleAndUnit *halfxCmd;
// G4UIcmdWithADoubleAndUnit *halfyCmd;
// G4UIcmdWithADoubleAndUnit *halfzCmd;
// G4UIcmdWithADoubleAndUnit *radiusCmd;
// G4UIcmdWithADoubleAndUnit *radius0Cmd;
// G4UIcmdWithADoubleAndUnit *possigmarCmd;
// G4UIcmdWithADoubleAndUnit *possigmaxCmd;
// G4UIcmdWithADoubleAndUnit *possigmayCmd;
// G4UIcmdWithADoubleAndUnit *paralpCmd;
// G4UIcmdWithADoubleAndUnit *partheCmd;
// G4UIcmdWithADoubleAndUnit *parphiCmd;
// G4UIcmdWithAString *confineCmd;
// angular commands
G4UIdirectory* angularDirectory;
G4UIcmdWithAString *angtypeCmd1;
@@ -206,18 +227,18 @@ class G4GeneralParticleSourceMessenger: public G4UImessenger
G4UIcmdWithABool *surfnormCmd1;
// old ones, will be removed soon
G4UIcmdWithAString *angtypeCmd;
G4UIcmdWith3Vector *angrot1Cmd;
G4UIcmdWith3Vector *angrot2Cmd;
G4UIcmdWithADoubleAndUnit *minthetaCmd;
G4UIcmdWithADoubleAndUnit *maxthetaCmd;
G4UIcmdWithADoubleAndUnit *minphiCmd;
G4UIcmdWithADoubleAndUnit *maxphiCmd;
G4UIcmdWithADoubleAndUnit *angsigmarCmd;
G4UIcmdWithADoubleAndUnit *angsigmaxCmd;
G4UIcmdWithADoubleAndUnit *angsigmayCmd;
G4UIcmdWithABool *useuserangaxisCmd;
G4UIcmdWithABool *surfnormCmd;
// G4UIcmdWithAString *angtypeCmd;
// G4UIcmdWith3Vector *angrot1Cmd;
// G4UIcmdWith3Vector *angrot2Cmd;
// G4UIcmdWithADoubleAndUnit *minthetaCmd;
// G4UIcmdWithADoubleAndUnit *maxthetaCmd;
// G4UIcmdWithADoubleAndUnit *minphiCmd;
// G4UIcmdWithADoubleAndUnit *maxphiCmd;
// G4UIcmdWithADoubleAndUnit *angsigmarCmd;
// G4UIcmdWithADoubleAndUnit *angsigmaxCmd;
// G4UIcmdWithADoubleAndUnit *angsigmayCmd;
// G4UIcmdWithABool *useuserangaxisCmd;
// G4UIcmdWithABool *surfnormCmd;
// energy commands
G4UIdirectory* energyDirectory;
@@ -237,27 +258,27 @@ class G4GeneralParticleSourceMessenger: public G4UImessenger
G4UIcmdWithABool *diffspecCmd1;
// old ones, will be removed soon
G4UIcmdWithAString *energytypeCmd;
G4UIcmdWithADoubleAndUnit *eminCmd;
G4UIcmdWithADoubleAndUnit *emaxCmd;
G4UIcmdWithADoubleAndUnit *monoenergyCmd;
G4UIcmdWithADoubleAndUnit *engsigmaCmd;
G4UIcmdWithADouble *alphaCmd;
G4UIcmdWithADouble *tempCmd;
G4UIcmdWithADouble *ezeroCmd;
G4UIcmdWithADouble *gradientCmd;
G4UIcmdWithADouble *interceptCmd;
G4UIcmdWithoutParameter *calculateCmd;
G4UIcmdWithABool *energyspecCmd;
G4UIcmdWithABool *diffspecCmd;
// G4UIcmdWithAString *energytypeCmd;
// G4UIcmdWithADoubleAndUnit *eminCmd;
// G4UIcmdWithADoubleAndUnit *emaxCmd;
// G4UIcmdWithADoubleAndUnit *monoenergyCmd;
// G4UIcmdWithADoubleAndUnit *engsigmaCmd;
// G4UIcmdWithADouble *alphaCmd;
// G4UIcmdWithADouble *tempCmd;
// G4UIcmdWithADouble *ezeroCmd;
// G4UIcmdWithADouble *gradientCmd;
// G4UIcmdWithADouble *interceptCmd;
// G4UIcmdWithoutParameter *calculateCmd;
// G4UIcmdWithABool *energyspecCmd;
// G4UIcmdWithABool *diffspecCmd;
// histogram commands
G4UIdirectory *histDirectory;
G4UIcmdWith3Vector *histpointCmd;
G4UIcmdWithAString *histnameCmd;
G4UIcmdWithAString *arbintCmd;
G4UIcmdWithAString *resethistCmd;
// old ones, will be removed soon
//G4UIcmdWith3Vector *histpointCmd;
//G4UIcmdWithAString *histnameCmd;
//G4UIcmdWithAString *arbintCmd;
//G4UIcmdWithAString *resethistCmd;
G4UIcmdWith3Vector *histpointCmd1;
G4UIcmdWithAString *histfileCmd1;
G4UIcmdWithAString *histnameCmd1;
@@ -161,6 +161,16 @@
#include "G4Threading.hh"
#include "G4AutoLock.hh"
/** Andrea Dotti Feb 2015
* Important: This is a shared class between threads.
* Only one thread should use the set-methods here.
* Note that this is exactly what is achieved using UI commands.
* If you use the set methods to set defaults in your
* application take care that only one thread is executing them.
* In addition take care of calling these methods before the run is started
* Do not use these setters during the event loop
*/
class G4SPSAngDistribution
{
public:
@@ -197,6 +207,7 @@ public:
G4double GetMaxTheta();
G4double GetMinPhi();
G4double GetMaxPhi();
G4ThreeVector GetDirection();
//
G4ParticleMomentum GenerateOne();
@@ -158,6 +158,16 @@
#include "G4SPSRandomGenerator.hh"
/** Andrea Dotti Feb 2015
* Important: This is a shared class between threads.
* Only one thread should use the set-methods here.
* Note that this is exactly what is achieved using UI commands.
* If you use the set methods to set defaults in your
* application take care that only one thread is executing them.
* In addition take care of calling these methods before the run is started
* Do not use these setters during the event loop
*/
class G4SPSEneDistribution {
public:
G4SPSEneDistribution();//
+76 -35
View File
@@ -142,31 +142,44 @@
#include "G4Threading.hh"
#include "G4Cache.hh"
/** Andrea Dotti Feb 2015
* Important: This is a shared class between threads.
* Only one thread should use the set-methods here.
* Note that this is exactly what is achieved using UI commands.
* If you use the set methods to set defaults in your
* application take care that only one thread is executing them.
* In addition take care of calling these methods before the run is started
* Do not use these setters during the event loop
*/
class G4SPSPosDistribution
{
public:
G4SPSPosDistribution ();
~G4SPSPosDistribution ();
/**
* Important: This is a shared class between threads.
* Only one thread should use the set-methods here.
* Note that this is achieved by UI commands.
* If you use these methods to set defaults in your
* application take care that only one thread is executing them.
* In addition take care of calling these methods before the run is started
* Do not use these setters during the event loop
*/
// methods to create source position dist.
void SetPosDisType(G4String); // Point, Plane, Surface, Volume
G4String GetPosDisType();
void SetPosDisShape(G4String);
G4String GetPosDisShape();
// SetPosDisShape - Square, Circle, Annulus, Ellipse, Rectangle, Sphere,
// Ellipsoid, Cylinder, Right (parallelepiped).
void SetCentreCoords(G4ThreeVector);
G4ThreeVector GetCentreCoords();
void SetPosRot1(G4ThreeVector);
void SetPosRot2(G4ThreeVector);
void SetHalfX(G4double);
G4double GetHalfX();
void SetHalfY(G4double);
G4double GetHalfY();
void SetHalfZ(G4double);
G4double GetHalfZ();
void SetRadius(G4double);
G4double GetRadius();
void SetRadius0(G4double);
void SetBeamSigmaInR(G4double);
void SetBeamSigmaInX(G4double);
@@ -181,11 +194,19 @@ public:
void SetVerbosity(G4int a);
//
G4ThreeVector GenerateOne();
G4String GetPosDisType() const;
G4String GetPosDisShape() const;
G4ThreeVector GetCentreCoords() const;
G4double GetHalfX() const;
G4double GetHalfY() const;
G4double GetHalfZ() const;
G4double GetRadius() const;
G4ThreeVector GetSideRefVec1() const;
G4ThreeVector GetSideRefVec2() const;
G4ThreeVector GetSideRefVec3() const;
G4String GetSourcePosType();
G4String GetSourcePosType() const;
G4ThreeVector GetParticlePos() const;
private:
@@ -200,38 +221,58 @@ private:
G4bool IsSourceConfined(G4ThreeVector& outputPos);
void InitThreadLocalCache() const;
void HandleThreadLocalCache( const G4ThreeVector& v1 , const G4ThreeVector& v2, const G4ThreeVector& v3 );
private:
// Position distribution Variables
G4String SourcePosType; //Point,Plane,Surface,Volume
G4String Shape; //Circle,Square,Rectangle etc..
G4double halfx, halfy, halfz; //half lengths
G4double Radius; //Radius for circles or spheres
G4double Radius0; // The inner radius of an annulus
G4double SR,SX,SY; // Standard deviation in raduial, x, y for beam type source
G4ThreeVector CentreCoords; // Coords of centre of input shape
G4ThreeVector Rotx, Roty, Rotz; // Unit vectors defining rotation matrix
G4double ParAlpha, ParTheta, ParPhi; //Angle for Right Parallellepipeds
G4bool Confine; //If true confines source distribution to VolName
//VERY IMPORTANT:
//This is a shared resource, however setters that
//changes the parameters via UI commands are by design
//thread-safe because only one thread will call these methods
//See G4GeneralParticleSourceMessenger constructor for an explanation
struct thread_data_t {
//Caching of some data
G4ThreeVector CSideRefVec1;
G4ThreeVector CSideRefVec2;
G4ThreeVector CSideRefVec3;
G4ThreeVector CParticlePos;
thread_data_t();
};
//Point,Plane,Surface,Volume
G4String SourcePosType;
//Circle,Square,Rectangle etc..
G4String Shape;
// Coords of centre of input shape
G4ThreeVector CentreCoords;
// Unit vectors defining rotation matrix
G4ThreeVector Rotx;
G4ThreeVector Roty;
G4ThreeVector Rotz;
//half lengths
G4double halfx;
G4double halfy;
G4double halfz;
//Radius for circles or spheres
G4double Radius;
// The inner radius of an annulus
G4double Radius0;
// Standard deviation in raduial, x, y for beam type source
G4double SR;
G4double SX;
G4double SY;
//Angle for Right Parallellepipeds
G4double ParAlpha;
G4double ParTheta;
G4double ParPhi;
//If true confines source distribution to VolName
G4bool Confine;
G4String VolName;
//Thread local caches
G4Cache<G4ThreeVector*> CSideRefVec1, CSideRefVec2, CSideRefVec3;
G4Cache<G4ThreeVector> CParticlePos;
G4ThreeVector particle_position; // the final particle position
//
//G4Navigator *gNavigator;
//
G4SPSRandomGenerator* posRndm; // biased random generator
// Verbosity
G4int verbosityLevel;
G4Mutex mutex; // protect access to shared resources
G4Cache<thread_data_t> ThreadData;
// biased random generator
G4Mutex a_mutex;
G4SPSRandomGenerator* PosRndm;
};
#endif
+35 -7
View File
@@ -141,6 +141,17 @@
#include "G4PhysicsOrderedFreeVector.hh"
#include "G4DataInterpolation.hh"
#include "G4Threading.hh"
#include "G4Cache.hh"
/** Andrea Dotti Feb 2015
* Important: This is a shared class between threads.
* Only one thread should use the set-methods here.
* Note that this is exactly what is achieved using UI commands.
* If you use the set methods to set defaults in your
* application take care that only one thread is executing them.
* In addition take care of calling these methods before the run is started
* Do not use these setters during the event loop
*/
class G4SPSRandomGenerator {
public:
@@ -178,43 +189,60 @@ public:
void SetVerbosity(G4int a);
private:
// static G4SPSRandomGenerator *instance;
//Encapsulate in a struct
//to gurantee that correct
//initial state is set via constructor
struct a_check {
G4bool val;
a_check() { val = false; }
};
//See .cc for an explanation of this
//in method GenRandX()
G4Cache<a_check> local_IPDFXBias;
G4bool XBias, IPDFXBias;
G4PhysicsOrderedFreeVector XBiasH;
G4PhysicsOrderedFreeVector IPDFXBiasH;
G4Cache<a_check> local_IPDFYBias;
G4bool YBias, IPDFYBias;
G4PhysicsOrderedFreeVector YBiasH;
G4PhysicsOrderedFreeVector IPDFYBiasH;
G4Cache<a_check> local_IPDFZBias;
G4bool ZBias, IPDFZBias;
G4PhysicsOrderedFreeVector ZBiasH;
G4PhysicsOrderedFreeVector IPDFZBiasH;
G4Cache<a_check> local_IPDFThetaBias;
G4bool ThetaBias, IPDFThetaBias;
G4PhysicsOrderedFreeVector ThetaBiasH;
G4PhysicsOrderedFreeVector IPDFThetaBiasH;
G4Cache<a_check> local_IPDFPhiBias;
G4bool PhiBias, IPDFPhiBias;
G4PhysicsOrderedFreeVector PhiBiasH;
G4PhysicsOrderedFreeVector IPDFPhiBiasH;
G4Cache<a_check> local_IPDFEnergyBias;
G4bool EnergyBias, IPDFEnergyBias;
G4PhysicsOrderedFreeVector EnergyBiasH;
G4PhysicsOrderedFreeVector IPDFEnergyBiasH;
G4Cache<a_check> local_IPDFPosThetaBias;
G4bool PosThetaBias, IPDFPosThetaBias;
G4PhysicsOrderedFreeVector PosThetaBiasH;
G4PhysicsOrderedFreeVector IPDFPosThetaBiasH;
G4Cache<a_check> local_IPDFPosPhiBias;
G4bool PosPhiBias, IPDFPosPhiBias;
G4PhysicsOrderedFreeVector PosPhiBiasH;
G4PhysicsOrderedFreeVector IPDFPosPhiBiasH;
//G4double alpha; // for biasing energy
G4double bweights[9]; //record x,y,z,theta,phi,energy,posThet,posPhi,intensity weights
struct bweights_t {
G4double w[9];
bweights_t();
G4double& operator[] (const int i);
};
G4Cache<bweights_t> bweights;
//G4double bweights[9]; //record x,y,z,theta,phi,energy,posThet,posPhi,intensity weights
// Verbosity
G4int verbosityLevel;
G4PhysicsOrderedFreeVector ZeroPhysVector; // for re-set only
G4Mutex mutex; //protect shared resources
};
+49 -30
View File
@@ -126,26 +126,39 @@
#include "G4SPSEneDistribution.hh"
#include "G4SPSRandomGenerator.hh"
#include "G4Threading.hh"
#include "G4Cache.hh"
/** Andrea Dotti Feb 2015
* Important: This is a shared class between threads.
* Only one thread should use the set-methods here.
* Note that this is exactly what is achieved using UI commands.
* If you use the set methods to set defaults in your
* application take care that only one thread is executing them.
* In addition take care of calling these methods before the run is started
* Do not use these setters during the event loop
*/
class G4SingleParticleSource: public G4VPrimaryGenerator {
public:
G4SingleParticleSource();
~G4SingleParticleSource();
void GeneratePrimaryVertex(G4Event *evt);
//
G4SPSPosDistribution* GetPosDist() {
G4SPSPosDistribution* GetPosDist() const {
return posGenerator;
}
;
G4SPSAngDistribution* GetAngDist() {
G4SPSAngDistribution* GetAngDist() const {
return angGenerator;
}
;
G4SPSEneDistribution* GetEneDist() {
G4SPSEneDistribution* GetEneDist() const {
return eneGenerator;
}
;
G4SPSRandomGenerator* GetBiasRndm() {
G4SPSRandomGenerator* GetBiasRndm() const {
return biasRndm;
}
;
@@ -155,55 +168,55 @@ public:
// Set the particle species
void SetParticleDefinition(G4ParticleDefinition * aParticleDefinition);
inline G4ParticleDefinition * GetParticleDefinition() {
return particle_definition;
inline G4ParticleDefinition * GetParticleDefinition() const {
return definition;
}
;
inline void SetParticleCharge(G4double aCharge) {
particle_charge = aCharge;
charge = aCharge;
}
;
// Set polarization
inline void SetParticlePolarization(G4ThreeVector aVal) {
particle_polarization = aVal;
polarization = aVal;
}
;
inline G4ThreeVector GetParticlePolarization() {
return particle_polarization;
inline G4ThreeVector GetParticlePolarization() const {
return polarization;
}
;
// Set Time.
inline void SetParticleTime(G4double aTime) {
particle_time = aTime;
time = aTime;
}
;
inline G4double GetParticleTime() {
return particle_time;
inline G4double GetParticleTime() const {
return time;
}
;
inline void SetNumberOfParticles(G4int i) {
NumberOfParticlesToBeGenerated = i;
NumberOfParticlesToBeGenerated = i;
}
;
//
inline G4int GetNumberOfParticles() {
inline G4int GetNumberOfParticles() const {
return NumberOfParticlesToBeGenerated;
}
;
inline G4ThreeVector GetParticlePosition() {
return particle_position;
inline G4ThreeVector GetParticlePosition() const {
return ParticleProperties.Get().position;
}
;
inline G4ThreeVector GetParticleMomentumDirection() {
return particle_momentum_direction;
inline G4ThreeVector GetParticleMomentumDirection() const {
return ParticleProperties.Get().momentum_direction;
}
;
inline G4double GetParticleEnergy() {
return particle_energy;
inline G4double GetParticleEnergy() const {
return ParticleProperties.Get().energy;
}
;
@@ -215,15 +228,21 @@ private:
G4SPSRandomGenerator* biasRndm;
//
// Other particle properties
G4int NumberOfParticlesToBeGenerated;
G4ParticleDefinition * particle_definition;
G4ParticleMomentum particle_momentum_direction;
G4double particle_energy;
G4double particle_charge;
G4ThreeVector particle_position;
G4double particle_time;
G4ThreeVector particle_polarization;
G4double particle_weight;
//These need to be thread-local because
//a getter for them exits
struct part_prop_t {
G4ParticleMomentum momentum_direction; ////////<<<<<<<
G4double energy; /////<<<<<
G4ThreeVector position; //////////<<<<<<<<<
//G4double weight;
part_prop_t();
};
G4Cache<part_prop_t> ParticleProperties;
G4int NumberOfParticlesToBeGenerated;
G4ParticleDefinition * definition;
G4double charge;
G4double time;
G4ThreeVector polarization;
// Verbosity
G4int verbosityLevel;