Import Geant4 10.7.0.beta source tree
This commit is contained in:
@@ -23,34 +23,31 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4AdjointPosOnPhysVolGenerator
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Class Name: G4AdjointPosOnPhysVolGenerator
|
||||
// Author: L. Desorgher
|
||||
// Organisation: SpaceIT GmbH
|
||||
// Contract: ESA contract 21435/08/NL/AT
|
||||
// Customer: ESA/ESTEC
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Class description:
|
||||
//
|
||||
// CHANGE HISTORY
|
||||
// --------------
|
||||
// ChangeHistory:
|
||||
// 1st June 2006 creation by L. Desorgher
|
||||
//
|
||||
//-------------------------------------------------------------
|
||||
// Documentation:
|
||||
// This class is responsible for the generation of primary adjoint particle on the external surface of a user selected volume.
|
||||
// The particle are generated uniformly on the surface with the angular distribution set to a cosine law relative to normal of the surface.
|
||||
// It is equivalent to the flux going in from the surface if an isotropic flux is considered outside.
|
||||
// It uses ray tracking technique and can be applied to all kind of convex volume. Uisng the ray tracking technique the area
|
||||
// of the external surface is also computed. The area is needed to fix the weight of the primary adjoint particle.
|
||||
// At the time of the development of this class, generation of particle on volume surface and computation of surface was limited in G4,
|
||||
// therfore the general ray tracking technique was adopted. It could be now (2009) that direct method of G4VSolid could be used instead. To be checked!
|
||||
//
|
||||
//
|
||||
//
|
||||
#ifndef G4AdjointPosOnPhysVolGenerator_h
|
||||
#define G4AdjointPosOnPhysVolGenerator_h 1
|
||||
// This class is responsible for the generation of primary adjoint particles
|
||||
// on the external surface of a user selected volume.
|
||||
// The particles are generated uniformly on the surface with the angular
|
||||
// distribution set to a cosine law relative to normal of the surface.
|
||||
// It is equivalent to the flux going in from the surface if an isotropic flux
|
||||
// is considered outside.
|
||||
// It uses ray tracking technique and can be applied to all kind of convex
|
||||
// volumes. Using the ray tracking technique the area of the external surface
|
||||
// is also computed. The area is needed to fix the weight of the primary
|
||||
// adjoint particle.
|
||||
// At the time of the development of this class, generation of points on
|
||||
// volume surface and computation of surface was limited in Geant4, therefore
|
||||
// the general ray tracking technique was adopted. The direct method in
|
||||
// G4VSolid could be now (2009) used instead.
|
||||
|
||||
// Author: L. Desorgher, SpaceIT GmbH - 01.06.2006
|
||||
// Contract: ESA contract 21435/08/NL/AT
|
||||
// Customer: ESA/ESTEC
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4AdjointPosOnPhysVolGenerator_hh
|
||||
#define G4AdjointPosOnPhysVolGenerator_hh 1
|
||||
|
||||
#include "G4VPhysicalVolume.hh"
|
||||
#include "G4AffineTransform.hh"
|
||||
@@ -59,57 +56,68 @@
|
||||
class G4VSolid;
|
||||
|
||||
class G4AdjointPosOnPhysVolGenerator
|
||||
///////////////////////
|
||||
{
|
||||
//---------
|
||||
public:
|
||||
//---------
|
||||
|
||||
//--------
|
||||
public: //without description
|
||||
//--------
|
||||
|
||||
static G4AdjointPosOnPhysVolGenerator* GetInstance();
|
||||
static G4AdjointPosOnPhysVolGenerator* GetInstance();
|
||||
|
||||
//--------
|
||||
public: //public methods
|
||||
//--------
|
||||
G4VPhysicalVolume* DefinePhysicalVolume(const G4String& aName);
|
||||
void DefinePhysicalVolume1(const G4String& aName);
|
||||
G4double ComputeAreaOfExtSurface();
|
||||
G4double ComputeAreaOfExtSurface(G4int NStat);
|
||||
G4double ComputeAreaOfExtSurface(G4double epsilon);
|
||||
G4double ComputeAreaOfExtSurface(G4VSolid* aSolid);
|
||||
G4double ComputeAreaOfExtSurface(G4VSolid* aSolid,G4int NStat);
|
||||
G4double ComputeAreaOfExtSurface(G4VSolid* aSolid,G4double epsilon);
|
||||
G4VPhysicalVolume* DefinePhysicalVolume(const G4String& aName);
|
||||
void DefinePhysicalVolume1(const G4String& aName);
|
||||
G4double ComputeAreaOfExtSurface();
|
||||
G4double ComputeAreaOfExtSurface(G4int NStat);
|
||||
G4double ComputeAreaOfExtSurface(G4double epsilon);
|
||||
G4double ComputeAreaOfExtSurface(G4VSolid* aSolid);
|
||||
G4double ComputeAreaOfExtSurface(G4VSolid* aSolid,G4int NStat);
|
||||
G4double ComputeAreaOfExtSurface(G4VSolid* aSolid,G4double epsilon);
|
||||
|
||||
void GenerateAPositionOnTheExtSurfaceOfASolid(G4VSolid* aSolid,G4ThreeVector& p, G4ThreeVector& direction);
|
||||
void GenerateAPositionOnTheExtSurfaceOfTheSolid(G4ThreeVector& p, G4ThreeVector& direction);
|
||||
void GenerateAPositionOnTheExtSurfaceOfThePhysicalVolume(G4ThreeVector& p, G4ThreeVector& direction);
|
||||
void GenerateAPositionOnTheExtSurfaceOfThePhysicalVolume(G4ThreeVector& p, G4ThreeVector& direction,
|
||||
G4double& costh_to_normal);
|
||||
void GenerateAPositionOnTheExtSurfaceOfASolid(G4VSolid* aSolid,
|
||||
G4ThreeVector& p,
|
||||
G4ThreeVector& direction);
|
||||
void GenerateAPositionOnTheExtSurfaceOfTheSolid(G4ThreeVector& p,
|
||||
G4ThreeVector& direction);
|
||||
void GenerateAPositionOnTheExtSurfaceOfThePhysicalVolume(G4ThreeVector& p,
|
||||
G4ThreeVector& direction);
|
||||
void GenerateAPositionOnTheExtSurfaceOfThePhysicalVolume(G4ThreeVector& p,
|
||||
G4ThreeVector& direction,
|
||||
G4double& costh_to_normal);
|
||||
|
||||
//inline public methods
|
||||
|
||||
inline void SetSolid(G4VSolid* aSolid){theSolid=aSolid;}
|
||||
inline G4double GetAreaOfExtSurfaceOfThePhysicalVolume(){return AreaOfExtSurfaceOfThePhysicalVolume;}
|
||||
inline G4double GetCosThDirComparedToNormal(){return CosThDirComparedToNormal;}
|
||||
inline void SetSolid(G4VSolid* aSolid)
|
||||
{ theSolid=aSolid; }
|
||||
inline G4double GetAreaOfExtSurfaceOfThePhysicalVolume()
|
||||
{ return AreaOfExtSurfaceOfThePhysicalVolume; }
|
||||
inline G4double GetCosThDirComparedToNormal()
|
||||
{ return CosThDirComparedToNormal; }
|
||||
|
||||
//---------
|
||||
private: //private methods
|
||||
private: // private methods
|
||||
//---------
|
||||
G4AdjointPosOnPhysVolGenerator();
|
||||
~G4AdjointPosOnPhysVolGenerator();
|
||||
G4double ComputeAreaOfExtSurfaceStartingFromSphere(G4VSolid* aSolid,G4int NStat);
|
||||
G4double ComputeAreaOfExtSurfaceStartingFromBox(G4VSolid* aSolid,G4int NStat);
|
||||
void GenerateAPositionOnASolidBoundary(G4VSolid* aSolid,G4ThreeVector& p, G4ThreeVector& direction);
|
||||
G4double GenerateAPositionOnASphereBoundary(G4VSolid* aSolid,G4ThreeVector& p, G4ThreeVector& direction);
|
||||
G4double GenerateAPositionOnABoxBoundary(G4VSolid* aSolid,G4ThreeVector& p, G4ThreeVector& direction);
|
||||
void ComputeTransformationFromPhysVolToWorld();
|
||||
|
||||
G4AdjointPosOnPhysVolGenerator();
|
||||
~G4AdjointPosOnPhysVolGenerator();
|
||||
G4double ComputeAreaOfExtSurfaceStartingFromSphere(G4VSolid* aSolid,
|
||||
G4int NStat);
|
||||
G4double ComputeAreaOfExtSurfaceStartingFromBox(G4VSolid* aSolid,
|
||||
G4int NStat);
|
||||
void GenerateAPositionOnASolidBoundary(G4VSolid* aSolid,
|
||||
G4ThreeVector& p,
|
||||
G4ThreeVector& direction);
|
||||
G4double GenerateAPositionOnASphereBoundary(G4VSolid* aSolid,
|
||||
G4ThreeVector& p,
|
||||
G4ThreeVector& direction);
|
||||
G4double GenerateAPositionOnABoxBoundary(G4VSolid* aSolid,
|
||||
G4ThreeVector& p,
|
||||
G4ThreeVector& direction);
|
||||
void ComputeTransformationFromPhysVolToWorld();
|
||||
|
||||
//---------
|
||||
private: //attributes
|
||||
private: // attributes
|
||||
//---------
|
||||
|
||||
static G4ThreadLocal G4AdjointPosOnPhysVolGenerator* theInstance;
|
||||
G4VSolid* theSolid;
|
||||
G4VPhysicalVolume* thePhysicalVolume;
|
||||
G4VSolid* theSolid = nullptr;
|
||||
G4VPhysicalVolume* thePhysicalVolume = nullptr;
|
||||
|
||||
G4bool UseSphere;
|
||||
G4String ModelOfSurfaceSource;
|
||||
@@ -119,4 +127,3 @@ class G4AdjointPosOnPhysVolGenerator
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,37 +23,31 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4AdjointPrimaryGenerator
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Module: G4AdjointPrimaryGenerator
|
||||
// Author: L. Desorgher
|
||||
// Organisation: SpaceIT GmbH
|
||||
// Contract: ESA contract 21435/08/NL/AT
|
||||
// Customer: ESA/ESTEC
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Class description:
|
||||
//
|
||||
// CHANGE HISTORY
|
||||
// --------------
|
||||
// ChangeHistory:
|
||||
// November 2009 creation by L. Desorgher, Splitting of G4AdjointPrimaryGeneratorAction in two classes G4AdjointPrimaryGeneratorAction and G4AdjointPrimaryGenerator
|
||||
//
|
||||
//-------------------------------------------------------------
|
||||
// Documentation:
|
||||
// This class represents the Primary Generator that generate vertex (energy,position and direction) of primary adjoint particles.
|
||||
// It is used by G4AdjointPrimaryGeneratorAction. If the adjoint source is selected by the user as being on the external boundary of a volume
|
||||
// it uses the class G4AdjointPosOnPhysVolGenerator to generate the vertex positions and directions. Otherwise G4SingleParticleSource is used.
|
||||
//
|
||||
//
|
||||
//
|
||||
#ifndef G4AdjointPrimaryGenerator_h
|
||||
#define G4AdjointPrimaryGenerator_h 1
|
||||
#include "globals.hh"
|
||||
#include"G4ThreeVector.hh"
|
||||
// This class represents the Primary Generator that generates vertex
|
||||
// (energy, position and direction) of primary adjoint particles.
|
||||
// It is used by G4AdjointPrimaryGeneratorAction. If the adjoint source is
|
||||
// selected by the user as being on the external boundary of a volume,
|
||||
// it uses the class G4AdjointPosOnPhysVolGenerator to generate the vertex
|
||||
// positions and directions. Otherwise G4SingleParticleSource is used.
|
||||
|
||||
// Author: L. Desorgher, SpaceIT GmbH - November 2009
|
||||
// Contract: ESA contract 21435/08/NL/AT
|
||||
// Customer: ESA/ESTEC
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4AdjointPrimaryGenerator_hh
|
||||
#define G4AdjointPrimaryGenerator_hh 1
|
||||
|
||||
#include <vector>
|
||||
#include <map>
|
||||
#include <iterator>
|
||||
#include"G4PhysicsOrderedFreeVector.hh"
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include"G4PhysicsOrderedFreeVector.hh"
|
||||
|
||||
class G4AdjointPosOnPhysVolGenerator;
|
||||
class G4Event;
|
||||
@@ -61,49 +55,50 @@ class G4SingleParticleSource;
|
||||
class G4ParticleDefinition;
|
||||
class G4Navigator;
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
class G4AdjointPrimaryGenerator
|
||||
{ public:
|
||||
{
|
||||
public:
|
||||
|
||||
G4AdjointPrimaryGenerator();
|
||||
~G4AdjointPrimaryGenerator();
|
||||
|
||||
public: //public methods
|
||||
G4AdjointPrimaryGenerator(const G4AdjointPrimaryGenerator&) = delete;
|
||||
G4AdjointPrimaryGenerator& operator=(const G4AdjointPrimaryGenerator&) = delete;
|
||||
|
||||
public:
|
||||
|
||||
void GenerateAdjointPrimaryVertex(G4Event* anEvt,G4ParticleDefinition* adj_part,G4double E1,G4double E2);
|
||||
void GenerateFwdPrimaryVertex(G4Event* anEvt,G4ParticleDefinition* adj_part,G4double E1,G4double E2);
|
||||
void GenerateAdjointPrimaryVertex(G4Event* anEvt,
|
||||
G4ParticleDefinition* adj_part,
|
||||
G4double E1, G4double E2);
|
||||
void GenerateFwdPrimaryVertex(G4Event* anEvt,
|
||||
G4ParticleDefinition* adj_part,
|
||||
G4double E1, G4double E2);
|
||||
void SetSphericalAdjointPrimarySource(G4double radius, G4ThreeVector pos);
|
||||
void SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(const G4String& volume_name);
|
||||
void SetAdjointPrimarySourceOnAnExtSurfaceOfAVolume(const G4String& v_name);
|
||||
void ComputeAccumulatedDepthVectorAlongBackRay(G4ThreeVector glob_pos,
|
||||
G4ThreeVector direction,
|
||||
G4double ekin,
|
||||
G4ParticleDefinition* aPartDef);
|
||||
G4ParticleDefinition* aPDef);
|
||||
G4double SampleDistanceAlongBackRayAndComputeWeightCorrection(G4double& weight_corr);
|
||||
|
||||
|
||||
private: //attributes
|
||||
private: // attributes
|
||||
|
||||
//The class responsible for the random generation of positions and direction of primaries for adjoint source set on the external surface of
|
||||
//a G4 volume
|
||||
G4AdjointPosOnPhysVolGenerator* theG4AdjointPosOnPhysVolGenerator;
|
||||
// The class responsible for the random generation of positions
|
||||
// and direction of primaries for adjoint source set on the external
|
||||
// surface of a G4 volume
|
||||
//
|
||||
G4AdjointPosOnPhysVolGenerator* theG4AdjointPosOnPhysVolGenerator = nullptr;
|
||||
|
||||
G4SingleParticleSource* theSingleParticleSource;
|
||||
G4SingleParticleSource* theSingleParticleSource = nullptr;
|
||||
|
||||
//Type of adjoint source
|
||||
//--------------------
|
||||
G4String type_of_adjoint_source; //Spherical ExtSurfaceOfAVolume
|
||||
G4double radius_spherical_source;
|
||||
// Type of adjoint source
|
||||
// ----------------------
|
||||
G4String type_of_adjoint_source; // Spherical ExtSurfaceOfAVolume
|
||||
G4double radius_spherical_source = 0.0;
|
||||
G4ThreeVector center_spherical_source;
|
||||
G4Navigator* fLinearNavigator;
|
||||
G4PhysicsOrderedFreeVector* theAccumulatedDepthVector;
|
||||
//G4PhysicsOrderedFreeVector* theAccumulatedCSDepthVector;
|
||||
|
||||
//Disable copy constructor and assignement operator
|
||||
G4AdjointPrimaryGenerator(const G4AdjointPrimaryGenerator&);
|
||||
G4AdjointPrimaryGenerator& operator=(const G4AdjointPrimaryGenerator&);
|
||||
|
||||
|
||||
|
||||
G4Navigator* fLinearNavigator = nullptr;
|
||||
G4PhysicsOrderedFreeVector* theAccumulatedDepthVector = nullptr;
|
||||
};
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,37 +23,25 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4AdjointStackingAction
|
||||
//
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Class Name: G4AdjointStackingAction
|
||||
// Author: L. Desorgher
|
||||
// Organisation: SpaceIT GmbH
|
||||
// Contract: ESA contract 21435/08/NL/AT
|
||||
// Customer: ESA/ESTEC
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
// Class description:
|
||||
//
|
||||
// CHANGE HISTORY
|
||||
// --------------
|
||||
// ChangeHistory:
|
||||
// -April 2008 First implementation by L. Desorgher
|
||||
// -4-11-2009 Adding the possibility to use user adjoint stacking action, L. Desorgher
|
||||
//
|
||||
//
|
||||
//-------------------------------------------------------------
|
||||
// Documentation:
|
||||
// Stacking action used in the adjoint simulation. It is responsible to kill a primary forward particle before it is traked in the forwrad phase
|
||||
// if the last adjoint particle did not reach the adjoint surface. Was needed for the new design where the G4AdjointSimManager is no more an extension
|
||||
// of the G4RunManager. If the primary particles is not killed before being tracked in the sensitive geometry, the User Stacking action
|
||||
// can be used duiring the forward phase if specified by the method G4AdjointSimManager::UseUserStackingAction(Bool).
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
#ifndef G4AdjointStackingAction_h
|
||||
#define G4AdjointStackingAction_h 1
|
||||
// Stacking action used in the adjoint simulation. It is responsible to kill
|
||||
// a primary forward particle before it is traked in the forward phase,
|
||||
// if the last adjoint particle did not reach the adjoint surface.
|
||||
// Was needed for the new design where the G4AdjointSimManager is no more an
|
||||
// extension of G4RunManager. If the primary particles are not killed before
|
||||
// being tracked in the sensitive geometry, the User Stacking action can be
|
||||
// used during the forward phase if specified by the method
|
||||
// G4AdjointSimManager::UseUserStackingAction(G4bool).
|
||||
|
||||
// Author: L. Desorgher, SpaceIT GmbH - April 2008
|
||||
// Contract: ESA contract 21435/08/NL/AT
|
||||
// Customer: ESA/ESTEC
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4AdjointStackingAction_hh
|
||||
#define G4AdjointStackingAction_hh 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4UserStackingAction.hh"
|
||||
@@ -65,25 +53,30 @@ class G4AdjointTrackingAction;
|
||||
class G4AdjointStackingAction : public G4UserStackingAction
|
||||
{
|
||||
public:
|
||||
|
||||
G4AdjointStackingAction(G4AdjointTrackingAction* anAction);
|
||||
virtual ~G4AdjointStackingAction();
|
||||
|
||||
public:
|
||||
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track* aTrack);
|
||||
virtual void NewStage();
|
||||
virtual void PrepareNewEvent();
|
||||
inline void SetUserFwdStackingAction(G4UserStackingAction* anAction){theFwdStackingAction = anAction;}
|
||||
inline void SetUserAdjointStackingAction(G4UserStackingAction* anAction){theUserAdjointStackingAction = anAction;}
|
||||
inline void SetKillTracks(G4bool aBool){kill_tracks =aBool;}
|
||||
inline void SetAdjointMode(G4bool aBool){adjoint_mode=aBool;}
|
||||
inline void SetUserFwdStackingAction(G4UserStackingAction* anAction)
|
||||
{ theFwdStackingAction = anAction; }
|
||||
inline void SetUserAdjointStackingAction(G4UserStackingAction* anAction)
|
||||
{ theUserAdjointStackingAction = anAction; }
|
||||
inline void SetKillTracks(G4bool aBool)
|
||||
{ kill_tracks =aBool; }
|
||||
inline void SetAdjointMode(G4bool aBool)
|
||||
{ adjoint_mode=aBool; }
|
||||
|
||||
|
||||
|
||||
private:
|
||||
G4UserStackingAction* theFwdStackingAction;
|
||||
G4UserStackingAction* theUserAdjointStackingAction;
|
||||
G4bool reclassification_stage,first_reclassification_stage,kill_tracks,adjoint_mode;
|
||||
G4AdjointTrackingAction* theAdjointTrackingAction;
|
||||
|
||||
G4UserStackingAction* theFwdStackingAction = nullptr;
|
||||
G4UserStackingAction* theUserAdjointStackingAction = nullptr;
|
||||
G4bool reclassification_stage = false,
|
||||
first_reclassification_stage = false,
|
||||
kill_tracks = false, adjoint_mode = false;
|
||||
G4AdjointTrackingAction* theAdjointTrackingAction = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,19 +23,18 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4ClassificationOfNewTrack
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
//
|
||||
// An enumeration for the possible classifications of tracks newly pushed
|
||||
// to the stack. G4UserStackingAction can set the classification.
|
||||
|
||||
// Author: M.Asai, SLAC
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4ClassificationOfNewTrack_hh
|
||||
#define G4ClassificationOfNewTrack_hh 1
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This header file contain an enumeration for the possible classifications
|
||||
// for trackes newly pushed to the stack. G4UserStackingAction can set the
|
||||
// classification.
|
||||
|
||||
enum G4ClassificationOfNewTrack
|
||||
{
|
||||
fUrgent=0, // put into the urgent stack
|
||||
@@ -51,4 +50,3 @@ enum G4ClassificationOfNewTrack
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,40 +23,44 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4EvManMessenger
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// This is a concrete class of G4UImessenger which takes care of commands
|
||||
// addressed to G4EventManager. Commands handled by this messenger are
|
||||
// /event/
|
||||
// /event/abort
|
||||
// /event/verbose
|
||||
|
||||
#ifndef G4EvManMessenger_h
|
||||
#define G4EvManMessenger_h 1
|
||||
// Author: M.Asai, SLAC
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4EvManMessenger_hh
|
||||
#define G4EvManMessenger_hh 1
|
||||
|
||||
#include "G4UImessenger.hh"
|
||||
|
||||
class G4EventManager;
|
||||
class G4UIdirectory;
|
||||
class G4UIcmdWithoutParameter;
|
||||
class G4UIcmdWithAnInteger;
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This is a concrete class of G4UImessenger which takes care of commands
|
||||
// addressed to G4EventManager. Commands handled by this messenger are
|
||||
// /event/
|
||||
// /event/abort
|
||||
// /event/verbose
|
||||
//
|
||||
|
||||
class G4EvManMessenger: public G4UImessenger
|
||||
class G4EvManMessenger : public G4UImessenger
|
||||
{
|
||||
public:
|
||||
G4EvManMessenger(G4EventManager * fEvMan);
|
||||
|
||||
G4EvManMessenger(G4EventManager* fEvMan);
|
||||
~G4EvManMessenger();
|
||||
void SetNewValue(G4UIcommand * command,G4String newValues);
|
||||
G4String GetCurrentValue(G4UIcommand * command);
|
||||
void SetNewValue(G4UIcommand* command, G4String newValues);
|
||||
G4String GetCurrentValue(G4UIcommand* command);
|
||||
|
||||
private:
|
||||
G4EventManager * fEvManager;
|
||||
G4UIdirectory* eventDirectory;
|
||||
G4UIcmdWithoutParameter* abortCmd;
|
||||
G4UIcmdWithAnInteger* verboseCmd;
|
||||
G4UIcmdWithoutParameter* storeEvtCmd;
|
||||
|
||||
G4EventManager* fEvManager = nullptr;
|
||||
G4UIdirectory* eventDirectory = nullptr;
|
||||
G4UIcmdWithoutParameter* abortCmd = nullptr;
|
||||
G4UIcmdWithAnInteger* verboseCmd = nullptr;
|
||||
G4UIcmdWithoutParameter* storeEvtCmd = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+107
-96
@@ -23,20 +23,21 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4Event
|
||||
//
|
||||
//
|
||||
//
|
||||
// class description:
|
||||
// Class description:
|
||||
//
|
||||
// This is the class which represents an event. A G4Event is constructed and
|
||||
// deleted by G4RunManager (or its derived class). When a G4Event object is
|
||||
// passed to G4EventManager, G4Event must have one or more primary verteces
|
||||
// and primary particle(s) associated to the vertex(es) as an input of
|
||||
// and primary particle(s) associated to the verteces as an input of
|
||||
// simulating an event.
|
||||
// G4Event has trajectories, hits collections, and/or digi collections.
|
||||
|
||||
#ifndef G4Event_h
|
||||
#define G4Event_h 1
|
||||
// Author: M.Asai, SLAC
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4Event_hh
|
||||
#define G4Event_hh 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "evtdefs.hh"
|
||||
@@ -48,121 +49,88 @@
|
||||
#include "G4VUserEventInformation.hh"
|
||||
|
||||
class G4VHitsCollection;
|
||||
|
||||
class G4Event
|
||||
{
|
||||
public:
|
||||
G4Event();
|
||||
G4Event(G4int evID);
|
||||
~G4Event();
|
||||
|
||||
inline void *operator new(size_t);
|
||||
inline void operator delete(void* anEvent);
|
||||
G4Event();
|
||||
G4Event(G4int evID);
|
||||
~G4Event();
|
||||
|
||||
G4bool operator==(const G4Event &right) const;
|
||||
G4bool operator!=(const G4Event &right) const;
|
||||
G4Event(const G4Event &) = delete;
|
||||
G4Event& operator=(const G4Event &) = delete;
|
||||
|
||||
public: // with description
|
||||
void Print() const;
|
||||
inline void *operator new(std::size_t);
|
||||
inline void operator delete(void* anEvent);
|
||||
|
||||
G4bool operator==(const G4Event& right) const;
|
||||
G4bool operator!=(const G4Event& right) const;
|
||||
|
||||
void Print() const;
|
||||
// Print the event ID (starts with zero and increments by one) to G4cout.
|
||||
void Draw() const;
|
||||
void Draw() const;
|
||||
// Invoke Draw() methods of all stored trajectories, hits, and digits.
|
||||
// For hits and digits, Draw() methods of the concrete classes must be
|
||||
// implemented. Otherwise nothing will be drawn.
|
||||
|
||||
private:
|
||||
// Copy constructor and = operator must not be used.
|
||||
G4Event(const G4Event &) {;}
|
||||
G4Event& operator=(const G4Event &) { return *this; }
|
||||
|
||||
private:
|
||||
// event ID
|
||||
G4int eventID;
|
||||
|
||||
// PrimaryVertex
|
||||
G4PrimaryVertex* thePrimaryVertex;
|
||||
G4int numberOfPrimaryVertex;
|
||||
|
||||
// HitsCollection
|
||||
G4HCofThisEvent* HC;
|
||||
|
||||
// DigiCollection
|
||||
G4DCofThisEvent* DC;
|
||||
|
||||
// TrajectoryContainer
|
||||
G4TrajectoryContainer * trajectoryContainer;
|
||||
|
||||
// Boolean flag which shall be set to true if the event is aborted and
|
||||
// thus the containing information is not to be used.
|
||||
G4bool eventAborted;
|
||||
|
||||
// UserEventInformation (optional)
|
||||
G4VUserEventInformation* userInfo;
|
||||
|
||||
// Initial random number engine status before primary particle generation
|
||||
G4String* randomNumberStatus;
|
||||
G4bool validRandomNumberStatus;
|
||||
|
||||
// Initial random number engine status before event processing
|
||||
G4String* randomNumberStatusForProcessing;
|
||||
G4bool validRandomNumberStatusForProcessing;
|
||||
|
||||
// Flag to keep the event until the end of run
|
||||
G4bool keepTheEvent;
|
||||
mutable G4int grips;
|
||||
|
||||
public:
|
||||
inline void SetEventID(G4int i)
|
||||
inline void SetEventID(G4int i)
|
||||
{ eventID = i; }
|
||||
inline void SetHCofThisEvent(G4HCofThisEvent*value)
|
||||
inline void SetHCofThisEvent(G4HCofThisEvent* value)
|
||||
{ HC = value; }
|
||||
inline void SetDCofThisEvent(G4DCofThisEvent*value)
|
||||
inline void SetDCofThisEvent(G4DCofThisEvent* value)
|
||||
{ DC = value; }
|
||||
inline void SetTrajectoryContainer(G4TrajectoryContainer*value)
|
||||
inline void SetTrajectoryContainer(G4TrajectoryContainer* value)
|
||||
{ trajectoryContainer = value; }
|
||||
inline void SetEventAborted()
|
||||
inline void SetEventAborted()
|
||||
{ eventAborted = true; }
|
||||
inline void SetRandomNumberStatus(G4String& st)
|
||||
inline void SetRandomNumberStatus(G4String& st)
|
||||
{
|
||||
randomNumberStatus = new G4String(st);
|
||||
validRandomNumberStatus = true;
|
||||
}
|
||||
inline void SetRandomNumberStatusForProcessing(G4String& st)
|
||||
inline void SetRandomNumberStatusForProcessing(G4String& st)
|
||||
{
|
||||
randomNumberStatusForProcessing = new G4String(st);
|
||||
validRandomNumberStatusForProcessing = true;
|
||||
}
|
||||
inline void KeepTheEvent(G4bool vl=true)
|
||||
inline void KeepTheEvent(G4bool vl=true)
|
||||
{ keepTheEvent = vl; }
|
||||
inline G4bool ToBeKept() const
|
||||
inline G4bool ToBeKept() const
|
||||
{ return keepTheEvent; }
|
||||
inline void KeepForPostProcessing() const
|
||||
{ grips++; }
|
||||
inline void PostProcessingFinished() const
|
||||
{ grips--;
|
||||
if(grips<0)
|
||||
{ G4Exception("G4Event::Release()","EVENT91001",FatalException,
|
||||
"Number of grips became negative. This cannot be correct."); }
|
||||
inline void KeepForPostProcessing() const
|
||||
{ ++grips; }
|
||||
inline void PostProcessingFinished() const
|
||||
{
|
||||
--grips;
|
||||
if (grips<0)
|
||||
{
|
||||
G4Exception("G4Event::Release()", "EVENT91001", FatalException,
|
||||
"Number of grips is negative. This cannot be correct.");
|
||||
}
|
||||
}
|
||||
inline G4int GetNumberOfGrips() const
|
||||
inline G4int GetNumberOfGrips() const
|
||||
{ return grips; }
|
||||
|
||||
public: // with description
|
||||
inline G4int GetEventID() const
|
||||
inline G4int GetEventID() const
|
||||
{ return eventID; }
|
||||
// Returns the event ID
|
||||
inline void AddPrimaryVertex(G4PrimaryVertex* aPrimaryVertex)
|
||||
|
||||
inline void AddPrimaryVertex(G4PrimaryVertex* aPrimaryVertex)
|
||||
{
|
||||
// This method sets a new primary vertex. This method must be invoked
|
||||
// exclusively by G4VPrimaryGenerator concrete class.
|
||||
|
||||
if( thePrimaryVertex == nullptr )
|
||||
{ thePrimaryVertex = aPrimaryVertex; }
|
||||
else
|
||||
{ thePrimaryVertex->SetNext( aPrimaryVertex ); }
|
||||
numberOfPrimaryVertex++;
|
||||
++numberOfPrimaryVertex;
|
||||
}
|
||||
// This method sets a new primary vertex. This method must be invoked
|
||||
// exclusively by G4VPrimaryGenerator concrete class.
|
||||
inline G4int GetNumberOfPrimaryVertex() const
|
||||
|
||||
inline G4int GetNumberOfPrimaryVertex() const
|
||||
{ return numberOfPrimaryVertex; }
|
||||
// Returns number of primary vertexes the G4Event object has.
|
||||
// Returns number of primary verteces the G4Event object has.
|
||||
|
||||
inline G4PrimaryVertex* GetPrimaryVertex(G4int i=0) const
|
||||
{
|
||||
if( i == 0 )
|
||||
@@ -170,7 +138,7 @@ class G4Event
|
||||
else if( i > 0 && i < numberOfPrimaryVertex )
|
||||
{
|
||||
G4PrimaryVertex* primaryVertex = thePrimaryVertex;
|
||||
for( G4int j=0; j<i; j++ )
|
||||
for( G4int j=0; j<i; ++j )
|
||||
{
|
||||
if( !primaryVertex ) return nullptr;
|
||||
primaryVertex = primaryVertex->GetNext();
|
||||
@@ -180,24 +148,30 @@ class G4Event
|
||||
else
|
||||
{ return nullptr; }
|
||||
}
|
||||
// Returns i-th primary vertex of the event.
|
||||
inline G4HCofThisEvent* GetHCofThisEvent() const
|
||||
// Returns i-th primary vertex of the event.
|
||||
|
||||
inline G4HCofThisEvent* GetHCofThisEvent() const
|
||||
{ return HC; }
|
||||
inline G4DCofThisEvent* GetDCofThisEvent() const
|
||||
inline G4DCofThisEvent* GetDCofThisEvent() const
|
||||
{ return DC; }
|
||||
inline G4TrajectoryContainer* GetTrajectoryContainer() const
|
||||
inline G4TrajectoryContainer* GetTrajectoryContainer() const
|
||||
{ return trajectoryContainer; }
|
||||
// These three methods returns the pointers to the G4HCofThisEvent
|
||||
// These three methods return the pointers to the G4HCofThisEvent
|
||||
// (hits collections of this event), G4DCofThisEvent (digi collections
|
||||
// of this event), and G4TrajectoryContainer (trajectory coonainer),
|
||||
// respectively.
|
||||
inline G4bool IsAborted() const { return eventAborted; }
|
||||
|
||||
inline G4bool IsAborted() const { return eventAborted; }
|
||||
// Return a boolean which indicates the event has been aborted and thus
|
||||
// it should not be used for analysis.
|
||||
inline void SetUserInformation(G4VUserEventInformation* anInfo) { userInfo = anInfo; }
|
||||
inline G4VUserEventInformation* GetUserInformation() const { return userInfo; }
|
||||
|
||||
inline void SetUserInformation(G4VUserEventInformation* anInfo)
|
||||
{ userInfo = anInfo; }
|
||||
inline G4VUserEventInformation* GetUserInformation() const
|
||||
{ return userInfo; }
|
||||
// Set and Get method of G4VUserEventInformation
|
||||
inline const G4String& GetRandomNumberStatus() const
|
||||
|
||||
inline const G4String& GetRandomNumberStatus() const
|
||||
{
|
||||
if(!validRandomNumberStatus)
|
||||
{ G4Exception(
|
||||
@@ -205,7 +179,7 @@ class G4Event
|
||||
"Random number status is not available for this event."); }
|
||||
return *randomNumberStatus;
|
||||
}
|
||||
inline const G4String& GetRandomNumberStatusForProcessing() const
|
||||
inline const G4String& GetRandomNumberStatusForProcessing() const
|
||||
{
|
||||
if(!validRandomNumberStatusForProcessing)
|
||||
{ G4Exception(
|
||||
@@ -214,11 +188,48 @@ class G4Event
|
||||
"Random number status is not available for this event."); }
|
||||
return *randomNumberStatusForProcessing;
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// event ID
|
||||
G4int eventID = 0;
|
||||
|
||||
// PrimaryVertex
|
||||
G4PrimaryVertex* thePrimaryVertex = nullptr;
|
||||
G4int numberOfPrimaryVertex = 0;
|
||||
|
||||
// HitsCollection
|
||||
G4HCofThisEvent* HC = nullptr;
|
||||
|
||||
// DigiCollection
|
||||
G4DCofThisEvent* DC = nullptr;
|
||||
|
||||
// TrajectoryContainer
|
||||
G4TrajectoryContainer* trajectoryContainer = nullptr;
|
||||
|
||||
// Boolean flag which shall be set to true if the event is aborted and
|
||||
// thus the containing information is not to be used.
|
||||
G4bool eventAborted = false;
|
||||
|
||||
// UserEventInformation (optional)
|
||||
G4VUserEventInformation* userInfo = nullptr;
|
||||
|
||||
// Initial random number engine status before primary particle generation
|
||||
G4String* randomNumberStatus = nullptr;
|
||||
G4bool validRandomNumberStatus = false;
|
||||
|
||||
// Initial random number engine status before event processing
|
||||
G4String* randomNumberStatusForProcessing = nullptr;
|
||||
G4bool validRandomNumberStatusForProcessing = false;
|
||||
|
||||
// Flag to keep the event until the end of run
|
||||
G4bool keepTheEvent = false;
|
||||
mutable G4int grips = 0;
|
||||
};
|
||||
|
||||
extern G4EVENT_DLL G4Allocator<G4Event>*& anEventAllocator();
|
||||
|
||||
inline void* G4Event::operator new(size_t)
|
||||
inline void* G4Event::operator new(std::size_t)
|
||||
{
|
||||
if (!anEventAllocator()) anEventAllocator() = new G4Allocator<G4Event>;
|
||||
return (void*)anEventAllocator()->MallocSingle();
|
||||
|
||||
@@ -23,15 +23,18 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4EventManager
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
//
|
||||
// G4EventManager controls an event. This class must be a singleton
|
||||
// and should be constructed by G4RunManager.
|
||||
|
||||
// Author: M.Asai, SLAC
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4EventManager_hh
|
||||
#define G4EventManager_hh 1
|
||||
|
||||
#ifndef G4EventManager_h
|
||||
#define G4EventManager_h 1
|
||||
|
||||
#include "evmandefs.hh"
|
||||
#include "G4StackManager.hh"
|
||||
#include "G4TrajectoryContainer.hh"
|
||||
#include "G4PrimaryTransformer.hh"
|
||||
@@ -50,123 +53,84 @@ class G4StateManager;
|
||||
#include "globals.hh"
|
||||
class G4VUserEventInformation;
|
||||
|
||||
// class description:
|
||||
//
|
||||
// G4EventManager controls an event. This class must be a singleton
|
||||
// and should be constructed by G4RunManager.
|
||||
//
|
||||
|
||||
class G4EventManager
|
||||
{
|
||||
public: // with description
|
||||
static G4EventManager* GetEventManager();
|
||||
// This method returns the singleton pointer of G4EventManager.
|
||||
|
||||
private:
|
||||
static G4ThreadLocal G4EventManager* fpEventManager;
|
||||
|
||||
public:
|
||||
G4EventManager();
|
||||
~G4EventManager();
|
||||
|
||||
private:
|
||||
G4EventManager(const G4EventManager &right) = delete;
|
||||
G4EventManager& operator=(const G4EventManager& right) = delete;
|
||||
static G4EventManager* GetEventManager();
|
||||
// This method returns the singleton pointer of G4EventManager.
|
||||
|
||||
public: // with description
|
||||
void ProcessOneEvent(G4Event* anEvent);
|
||||
// This method is the main entry to this class for simulating an event.
|
||||
G4EventManager();
|
||||
~G4EventManager();
|
||||
|
||||
void ProcessOneEvent(G4TrackVector* trackVector,G4Event* anEvent=0);
|
||||
// This is an alternative entry for large HEP experiments which create G4Track
|
||||
// objects by themselves directly without using G4VPrimaryGenerator or user
|
||||
// primary generator action. Dummy G4Event object will be created if "anEvent" is null
|
||||
// for internal use, but this dummy object will be deleted at the end of this
|
||||
// method and will never be available for the use after the processing.
|
||||
// Note that in this case of null G4Event pointer no output of the simulated event
|
||||
// is returned by this method, but the user must implement some mechanism
|
||||
// of storing output by his/herself, e.g. in his/her UserEventAction and/or
|
||||
// sensitive detectors.
|
||||
// If valid G4Event object is given, this object will not be deleted with
|
||||
// this method and output objects such as hits collections and trajectories
|
||||
// will be associated to this event object. If this event object has valid
|
||||
// primary vertices/particles, they will be added to the given trackvector input.
|
||||
G4EventManager(const G4EventManager &right) = delete;
|
||||
G4EventManager& operator=(const G4EventManager& right) = delete;
|
||||
|
||||
private:
|
||||
void DoProcessing(G4Event* anEvent);
|
||||
void StackTracks(G4TrackVector *trackVector, G4bool IDhasAlreadySet=false);
|
||||
|
||||
G4Event* currentEvent;
|
||||
void ProcessOneEvent(G4Event* anEvent);
|
||||
// This method is the main entry to this class for simulating an event.
|
||||
|
||||
G4StackManager *trackContainer;
|
||||
G4TrackingManager *trackManager;
|
||||
G4TrajectoryContainer *trajectoryContainer;
|
||||
G4int trackIDCounter;
|
||||
G4int verboseLevel;
|
||||
G4SDManager* sdManager;
|
||||
G4PrimaryTransformer* transformer;
|
||||
G4bool tracking;
|
||||
G4bool abortRequested;
|
||||
void ProcessOneEvent(G4TrackVector* trackVector, G4Event* anEvent= nullptr);
|
||||
// This is an alternative entry for HEP experiments which create G4Track
|
||||
// objects by themselves directly without using G4VPrimaryGenerator or a
|
||||
// user-primary-generator action. Dummy G4Event object will be created if
|
||||
// "anEvent" is null for internal use, but this dummy object will be
|
||||
// deleted at the end of this method and will never be available for use
|
||||
// after the processing.
|
||||
// Note that in this case of null G4Event pointer, no output of the
|
||||
// simulated event is returned by this method; the user must implement
|
||||
// some mechanism of storing the output, e.g. in the UserEventAction
|
||||
// and/or in sensitive detectors.
|
||||
// If a valid G4Event object is given, this object will not be deleted
|
||||
// by this method, and output objects such as hits collections and
|
||||
// trajectories will be associated to the event object. If the event
|
||||
// object has valid primary vertices/particles, they will be added to
|
||||
// the given "trackvector" input.
|
||||
|
||||
G4EvManMessenger* theMessenger;
|
||||
|
||||
G4UserEventAction* userEventAction;
|
||||
G4UserStackingAction* userStackingAction;
|
||||
G4UserTrackingAction* userTrackingAction;
|
||||
G4UserSteppingAction* userSteppingAction;
|
||||
|
||||
G4int storetRandomNumberStatusToG4Event;
|
||||
G4String randomNumberStatusToG4Event;
|
||||
|
||||
G4StateManager* stateManager;
|
||||
|
||||
public: // with description
|
||||
inline const G4Event* GetConstCurrentEvent()
|
||||
inline const G4Event* GetConstCurrentEvent()
|
||||
{ return currentEvent; }
|
||||
inline G4Event* GetNonconstCurrentEvent()
|
||||
inline G4Event* GetNonconstCurrentEvent()
|
||||
{ return currentEvent; }
|
||||
// These methods returns the pointers of const G4Event*
|
||||
// These methods returns the pointers of const G4Event*
|
||||
// and G4Event*, respectively. Null will be returned when
|
||||
// an event is not processing.
|
||||
|
||||
public: // with description
|
||||
void AbortCurrentEvent();
|
||||
// This method aborts the processing of the current event. All stacked
|
||||
void AbortCurrentEvent();
|
||||
// This method aborts the processing of the current event. All stacked
|
||||
// tracks are deleted. The contents of G4Event object is not completed,
|
||||
// but trajectories, hits, and/or digits which are created before the
|
||||
// moment of abortion can be used.
|
||||
|
||||
public: // with description
|
||||
void SetUserAction(G4UserEventAction* userAction);
|
||||
void SetUserAction(G4UserStackingAction* userAction);
|
||||
void SetUserAction(G4UserTrackingAction* userAction);
|
||||
void SetUserAction(G4UserSteppingAction* userAction);
|
||||
inline G4UserEventAction* GetUserEventAction()
|
||||
void SetUserAction(G4UserEventAction* userAction);
|
||||
void SetUserAction(G4UserStackingAction* userAction);
|
||||
void SetUserAction(G4UserTrackingAction* userAction);
|
||||
void SetUserAction(G4UserSteppingAction* userAction);
|
||||
inline G4UserEventAction* GetUserEventAction()
|
||||
{ return userEventAction; }
|
||||
inline G4UserStackingAction* GetUserStackingAction()
|
||||
inline G4UserStackingAction* GetUserStackingAction()
|
||||
{ return userStackingAction; }
|
||||
inline G4UserTrackingAction* GetUserTrackingAction()
|
||||
inline G4UserTrackingAction* GetUserTrackingAction()
|
||||
{ return userTrackingAction; }
|
||||
inline G4UserSteppingAction* GetUserSteppingAction()
|
||||
inline G4UserSteppingAction* GetUserSteppingAction()
|
||||
{ return userSteppingAction; }
|
||||
// Set and get methods for user action classes. User action classes
|
||||
// which should belong to the other managers will be sent to the
|
||||
// corresponding managers.
|
||||
void SetNumberOfAdditionalWaitingStacks(G4int iAdd)
|
||||
|
||||
void SetNumberOfAdditionalWaitingStacks(G4int iAdd)
|
||||
{ trackContainer->SetNumberOfAdditionalWaitingStacks(iAdd); }
|
||||
|
||||
void KeepTheCurrentEvent();
|
||||
// If the current event exists, it is kept undeleted until the end of the current run
|
||||
void KeepTheCurrentEvent();
|
||||
// If the current event exists, it is kept undeleted until
|
||||
// the end of the current run
|
||||
|
||||
inline G4StackManager* GetStackManager() const
|
||||
inline G4StackManager* GetStackManager() const
|
||||
{ return trackContainer; }
|
||||
inline G4TrackingManager* GetTrackingManager() const
|
||||
inline G4TrackingManager* GetTrackingManager() const
|
||||
{ return trackManager; }
|
||||
|
||||
public: // with description
|
||||
inline G4int GetVerboseLevel()
|
||||
inline G4int GetVerboseLevel()
|
||||
{ return verboseLevel; }
|
||||
inline void SetVerboseLevel( G4int value )
|
||||
inline void SetVerboseLevel( G4int value )
|
||||
{
|
||||
verboseLevel = value;
|
||||
trackContainer->SetVerboseLevel( value );
|
||||
@@ -174,21 +138,51 @@ class G4EventManager
|
||||
}
|
||||
// Set and get method of the verbose level
|
||||
|
||||
void SetUserInformation(G4VUserEventInformation* anInfo);
|
||||
G4VUserEventInformation* GetUserInformation();
|
||||
void SetUserInformation(G4VUserEventInformation* anInfo);
|
||||
G4VUserEventInformation* GetUserInformation();
|
||||
// Set and get method of G4VUserEventInformation object associating with
|
||||
// the current event. Both methods are valid only for G4State_EventProc
|
||||
// application state.
|
||||
|
||||
inline G4PrimaryTransformer* GetPrimaryTransformer() const
|
||||
inline G4PrimaryTransformer* GetPrimaryTransformer() const
|
||||
{ return transformer; }
|
||||
inline void SetPrimaryTransformer(G4PrimaryTransformer* tf)
|
||||
inline void SetPrimaryTransformer(G4PrimaryTransformer* tf)
|
||||
{ transformer = tf; }
|
||||
inline void StoreRandomNumberStatusToG4Event(G4int vl)
|
||||
inline void StoreRandomNumberStatusToG4Event(G4int vl)
|
||||
{ storetRandomNumberStatusToG4Event = vl; }
|
||||
|
||||
private:
|
||||
|
||||
void DoProcessing(G4Event* anEvent);
|
||||
void StackTracks(G4TrackVector* trackVector, G4bool IDhasAlreadySet= false);
|
||||
|
||||
private:
|
||||
|
||||
static G4ThreadLocal G4EventManager* fpEventManager;
|
||||
|
||||
G4Event* currentEvent = nullptr;
|
||||
|
||||
G4StackManager* trackContainer = nullptr;
|
||||
G4TrackingManager* trackManager = nullptr;
|
||||
G4TrajectoryContainer* trajectoryContainer = nullptr;
|
||||
G4int trackIDCounter = 0;
|
||||
G4int verboseLevel = 0;
|
||||
G4SDManager* sdManager = nullptr;
|
||||
G4PrimaryTransformer* transformer = nullptr;
|
||||
G4bool tracking = false;
|
||||
G4bool abortRequested = false;
|
||||
|
||||
G4EvManMessenger* theMessenger = nullptr;
|
||||
|
||||
G4UserEventAction* userEventAction = nullptr;
|
||||
G4UserStackingAction* userStackingAction = nullptr;
|
||||
G4UserTrackingAction* userTrackingAction = nullptr;
|
||||
G4UserSteppingAction* userSteppingAction = nullptr;
|
||||
|
||||
G4int storetRandomNumberStatusToG4Event = 0;
|
||||
G4String randomNumberStatusToG4Event;
|
||||
|
||||
G4StateManager* stateManager = nullptr;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,45 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MODULE: G4GeneralParticleSource.hh
|
||||
//
|
||||
// Version: 2.0
|
||||
// Date: 5/02/04
|
||||
// Author: Fan Lei
|
||||
// Organisation: QinetiQ ltd.
|
||||
// Customer: ESA/ESTEC
|
||||
//
|
||||
// Documentation avaialable at http://reat.space.qinetiq.com/gps
|
||||
// These include:
|
||||
// User Requirement Document (URD)
|
||||
// Software Specification Documents (SSD)
|
||||
// Software User Manual (SUM): on-line version available
|
||||
// Technical Note (TN) on the physics and algorithms
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CHANGE HISTORY
|
||||
// --------------
|
||||
// 26/10/2004, F Lei
|
||||
// Added the Multiple_vertex capability.
|
||||
// Removed "inline" from all Set/Get methods.
|
||||
//
|
||||
// Version 2.0, 05/02/2004, Fan Lei, Created.
|
||||
// based on version 1.1 in Geant4 v6.0
|
||||
// - Mutilple particle source definition
|
||||
// - Re-structured commands
|
||||
// - Split the task into smaller classes
|
||||
//
|
||||
// - old commonds have been retained for backward compatibility, but will
|
||||
// be removed in the future.
|
||||
//
|
||||
// 25/03/2014, Andrew Green
|
||||
// Various changes to use the new G4GeneralParticleSourceData class, mostly
|
||||
// just transparent wrappers around the thread safe object.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// G4GeneralParticleSource
|
||||
//
|
||||
// Class Description:
|
||||
//
|
||||
@@ -69,93 +31,134 @@
|
||||
// It is designed to allow specification of mutiple particle sources, each with
|
||||
// independent definitions of particle type, position, direction (or angular)
|
||||
// and energy distributions.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MEMBER FUNCTIONS
|
||||
// ----------------
|
||||
//
|
||||
// G4GeneralParticleSource()
|
||||
// Constructor: Initializes variables and instantiates the
|
||||
// Messenger and generator classes
|
||||
//
|
||||
// ~G4GeneralParticleSourceMessenger()
|
||||
// Destructor: deletes Messenger and others
|
||||
//
|
||||
// G4int GetNumberofSource()
|
||||
// Return the number of particle gun defined
|
||||
//
|
||||
// void ListSource()
|
||||
// List the particle guns defined
|
||||
//
|
||||
// void SetCurrentSourceto(G4int)
|
||||
// set the current gun to the specified one so its definition can be changed
|
||||
//
|
||||
// void SetCurrentSourceIntensity(G4double)
|
||||
// change the current particle gun strength
|
||||
//
|
||||
// void SetMultipleVertex(G4bool )
|
||||
// Set if multiple vertex per event.
|
||||
|
||||
// G4SingleParticleSource* GetCurrentSource()
|
||||
// return the pointer to current particle gun
|
||||
//
|
||||
// G4int GetCurrentSourceIndex()
|
||||
// return the index of the current particle gun
|
||||
//
|
||||
// G4double GetCurrentSourceIntensity()
|
||||
// return the strength of the current gun
|
||||
//
|
||||
// void ClearAll()
|
||||
// remove all defined aprticle gun
|
||||
//
|
||||
// void AddaSource (G4double)
|
||||
// add a new particle gun with the specified strength
|
||||
//
|
||||
// void DeleteaSource(G4int);
|
||||
// delete the specified particle gun
|
||||
//
|
||||
// void SetParticleDefinition ();
|
||||
// G4ParticleDefinition * GetParticleDefinition ()
|
||||
// Get/Set the particle definition of the primary track
|
||||
//
|
||||
// void SetParticleCharge(G4double aCharge)
|
||||
// set the charge state of the primary track
|
||||
//
|
||||
// void SetParticlePolarization (G4ThreeVector aVal)
|
||||
// G4ThreeVector GetParticlePolarization ()
|
||||
// Set/Get the polarization state of the primary track
|
||||
//
|
||||
// void SetParticleTime(G4double aTime) { particle_time = aTime; };
|
||||
// G4double GetParticleTime() { return particle_time; };
|
||||
// Set/Get the Time.
|
||||
//
|
||||
// void SetNumberOfParticles(G4int i)
|
||||
// G4int GetNumberOfParticles()
|
||||
// set/get the number of particles to be generated in the primary track
|
||||
//
|
||||
// G4ThreeVector GetParticlePosition()
|
||||
// G4ThreeVector GetParticleMomentumDirection()
|
||||
// G4double GetParticleEnergy()
|
||||
// get the position, direction, and energy of the current particle
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
#ifndef G4GeneralParticleSource_H
|
||||
#define G4GeneralParticleSource_H 1
|
||||
// Author: Fan Lei, QinetiQ ltd
|
||||
// Customer: ESA/ESTEC
|
||||
// Version: 2.0
|
||||
// History:
|
||||
// - 05/02/2004, F.Lei - Version 2.0. Created.
|
||||
// - 26/10/2004, F.Lei - Added the Multiple_vertex capability.
|
||||
// - 25/03/2014, A.Green - Various changes to use the new class
|
||||
// G4GeneralParticleSourceData, mostly just transparent wrappers
|
||||
// around the thread safe object.
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4GeneralParticleSource_hh
|
||||
#define G4GeneralParticleSource_hh 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include <vector>
|
||||
|
||||
#include "G4Event.hh"
|
||||
#include "G4SingleParticleSource.hh"
|
||||
//
|
||||
#include "G4GeneralParticleSourceMessenger.hh"
|
||||
|
||||
#include "G4GeneralParticleSourceData.hh"
|
||||
|
||||
class G4SingleParticleSource;
|
||||
|
||||
class G4GeneralParticleSource : public G4VPrimaryGenerator
|
||||
{
|
||||
public:
|
||||
|
||||
G4GeneralParticleSource();
|
||||
// Initialize variables and instantiates the messenger and
|
||||
// generator classes
|
||||
|
||||
~G4GeneralParticleSource();
|
||||
// Delete messenger and others
|
||||
|
||||
void GeneratePrimaryVertex(G4Event*);
|
||||
|
||||
inline G4int GetNumberofSource() { return GPSData->GetSourceVectorSize(); }
|
||||
// Return the number of particle gun defined
|
||||
|
||||
void ListSource();
|
||||
// List the particle guns defined
|
||||
|
||||
void SetCurrentSourceto(G4int) ;
|
||||
// Set the current gun to the specified one so its definition
|
||||
// can be changed
|
||||
|
||||
void SetCurrentSourceIntensity(G4double);
|
||||
// Change the current particle gun strength
|
||||
|
||||
inline G4SingleParticleSource* GetCurrentSource() const
|
||||
{ return GPSData->GetCurrentSource(); }
|
||||
// Return the pointer to current particle gun
|
||||
inline G4int GetCurrentSourceIndex() const
|
||||
{ return GPSData->GetCurrentSourceIdx(); }
|
||||
// Return the index of the current particle gun
|
||||
inline G4double GetCurrentSourceIntensity() const
|
||||
{ return GPSData->GetIntensity(GetCurrentSourceIndex()); }
|
||||
// Return the strength of the current gun
|
||||
|
||||
void ClearAll();
|
||||
// Remove all defined particle gun
|
||||
void AddaSource (G4double);
|
||||
// Add a new particle gun with the specified strength
|
||||
void DeleteaSource(G4int);
|
||||
// Delete the specified particle gun
|
||||
|
||||
inline void SetVerbosity(G4int i) { GPSData->SetVerbosityAllSources(i); }
|
||||
// Set the verbosity level.
|
||||
|
||||
inline void SetMultipleVertex(G4bool av) { GPSData->SetMultipleVertex(av); }
|
||||
// Set if multiple vertex per event.
|
||||
|
||||
inline void SetFlatSampling(G4bool av)
|
||||
{ GPSData->SetFlatSampling(av); normalised = false;}
|
||||
// Set if flat_sampling is applied in multiple source case
|
||||
|
||||
inline void SetParticleDefinition (G4ParticleDefinition * aPDef)
|
||||
{ GPSData->GetCurrentSource()->SetParticleDefinition(aPDef); }
|
||||
inline G4ParticleDefinition* GetParticleDefinition () const
|
||||
{ return GPSData->GetCurrentSource()->GetParticleDefinition(); }
|
||||
// Set/Get the particle definition of the primary track
|
||||
|
||||
inline void SetParticleCharge(G4double aCharge)
|
||||
{ GPSData->GetCurrentSource()->SetParticleCharge(aCharge); }
|
||||
// Set the charge state of the primary track
|
||||
|
||||
inline void SetParticlePolarization (G4ThreeVector aVal)
|
||||
{ GPSData->GetCurrentSource()->SetParticlePolarization(aVal); }
|
||||
inline G4ThreeVector GetParticlePolarization () const
|
||||
{ return GPSData->GetCurrentSource()->GetParticlePolarization(); }
|
||||
// Set/Get polarization state of the primary track
|
||||
|
||||
inline void SetParticleTime(G4double aTime)
|
||||
{ GPSData->GetCurrentSource()->SetParticleTime(aTime); }
|
||||
inline G4double GetParticleTime() const
|
||||
{ return GPSData->GetCurrentSource()->GetParticleTime(); }
|
||||
// Set/Get the Time.
|
||||
|
||||
inline void SetNumberOfParticles(G4int i)
|
||||
{ GPSData->GetCurrentSource()->SetNumberOfParticles(i); }
|
||||
inline G4int GetNumberOfParticles() const
|
||||
{ return GPSData->GetCurrentSource()->GetNumberOfParticles(); }
|
||||
// Set/Get the number of particles to be generated in the primary track
|
||||
|
||||
inline G4ThreeVector GetParticlePosition() const
|
||||
{ return GPSData->GetCurrentSource()->GetParticlePosition(); }
|
||||
inline G4ThreeVector GetParticleMomentumDirection() const
|
||||
{ return GPSData->GetCurrentSource()->GetParticleMomentumDirection(); }
|
||||
inline G4double GetParticleEnergy() const
|
||||
{ return GPSData->GetCurrentSource()->GetParticleEnergy(); }
|
||||
// Get the position, direction, and energy of the current particle
|
||||
|
||||
private:
|
||||
|
||||
void IntensityNormalization();
|
||||
|
||||
private:
|
||||
|
||||
G4bool normalised = false;
|
||||
// Helper Boolean, used to reduce number of locks
|
||||
// at run time (see GeneratePrimaryVertex)
|
||||
|
||||
G4GeneralParticleSourceMessenger* theMessenger = nullptr;
|
||||
// Note this is a shared resource among MT workers
|
||||
G4GeneralParticleSourceData* GPSData = nullptr;
|
||||
// Note this is a shared resource among MT workers
|
||||
|
||||
/** Andrea Dotti Feb 2015
|
||||
* GPS messenger design requires some explanation for what distributions
|
||||
* parameters are concerned : Each thread has its own GPS
|
||||
@@ -176,88 +179,7 @@ class G4SingleParticleSource;
|
||||
* (for example in G4VUserActionInitialization::BuildForMaster() and set the
|
||||
* defaults parameter there).
|
||||
*/
|
||||
class G4GeneralParticleSource : public G4VPrimaryGenerator
|
||||
{
|
||||
//
|
||||
public:
|
||||
|
||||
G4GeneralParticleSource();
|
||||
~G4GeneralParticleSource();
|
||||
|
||||
void GeneratePrimaryVertex(G4Event*);
|
||||
|
||||
G4int GetNumberofSource() { return GPSData->GetSourceVectorSize(); };
|
||||
void ListSource();
|
||||
void SetCurrentSourceto(G4int) ;
|
||||
void SetCurrentSourceIntensity(G4double);
|
||||
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) {GPSData->SetVerbosityAllSources(i);} ;
|
||||
|
||||
// Set if multiple vertex per event.
|
||||
void SetMultipleVertex(G4bool av) { GPSData->SetMultipleVertex(av);} ;
|
||||
|
||||
// set if flat_sampling is applied in multiple source case
|
||||
|
||||
void SetFlatSampling(G4bool av) { GPSData->SetFlatSampling(av); normalised = false;} ;
|
||||
|
||||
// Set the particle species
|
||||
void SetParticleDefinition (G4ParticleDefinition * aParticleDefinition)
|
||||
{GPSData->GetCurrentSource()->SetParticleDefinition(aParticleDefinition); } ;
|
||||
|
||||
G4ParticleDefinition * GetParticleDefinition () const
|
||||
{ return GPSData->GetCurrentSource()->GetParticleDefinition();} ;
|
||||
|
||||
void SetParticleCharge(G4double aCharge)
|
||||
{ GPSData->GetCurrentSource()->SetParticleCharge(aCharge); } ;
|
||||
|
||||
// Set polarization
|
||||
void SetParticlePolarization (G4ThreeVector aVal)
|
||||
{GPSData->GetCurrentSource()->SetParticlePolarization(aVal);};
|
||||
G4ThreeVector GetParticlePolarization () const
|
||||
{return GPSData->GetCurrentSource()->GetParticlePolarization();};
|
||||
|
||||
// Set Time.
|
||||
void SetParticleTime(G4double aTime)
|
||||
{ GPSData->GetCurrentSource()->SetParticleTime(aTime); };
|
||||
G4double GetParticleTime() const
|
||||
{ return GPSData->GetCurrentSource()->GetParticleTime(); };
|
||||
|
||||
void SetNumberOfParticles(G4int i)
|
||||
{ GPSData->GetCurrentSource()->SetNumberOfParticles(i); };
|
||||
//
|
||||
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:
|
||||
//Helper boolean, used to reduce number of locks
|
||||
//at run time (see GeneratePrimaryVertex)
|
||||
G4bool normalised;
|
||||
|
||||
//Note this is a shared resource among MT workers
|
||||
G4GeneralParticleSourceMessenger* theMessenger;
|
||||
//Note this is a shared resource among MT workers
|
||||
G4GeneralParticleSourceData* GPSData;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,37 +23,30 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
// -------------------------------------------------------------------
|
||||
//
|
||||
// GEANT4 Class file
|
||||
//
|
||||
//
|
||||
// File name: G4GeneralParticleSourceData.hh
|
||||
//
|
||||
// Author: Andrew Green
|
||||
//
|
||||
// Creation date: 20 Mar 2014
|
||||
// G4GeneralParticleSourceData
|
||||
//
|
||||
// Class Description:
|
||||
//
|
||||
// This class uses the singleton pattern to create a single copy of the data
|
||||
// needed for the G4GPS class. As yet, only the largest parts have been split
|
||||
// off.
|
||||
//
|
||||
// Thread Safety:
|
||||
// Thread Safety considerations:
|
||||
// Singleton creation (G4GeneralParticleSourceData::Instance()) is thread safe.
|
||||
// Getters are thread-safe if no other thread is adding/deleting a source or normalizing
|
||||
// However please note that the setters are usually accessed via messenger. This should be
|
||||
// instantiated in master thread.
|
||||
// Getters are thread-safe if no other thread is adding/deleting a source or
|
||||
// normalizing. However, please note that the setters are usually accessed via
|
||||
// messenger. This should be instantiated in master thread.
|
||||
//
|
||||
// For convinience Lock and Unlock methods are provided that can be used to serialize calls.
|
||||
// For convenience Lock and Unlock methods are provided that can be used to
|
||||
// serialize calls.
|
||||
// For example:
|
||||
// gpsdata=G4GeneralParticleSourceData::Instance();
|
||||
// gpsdata->Lock();
|
||||
// gpsdata->AddASource(1.0);
|
||||
// gpsdata->Unlock();
|
||||
|
||||
|
||||
// Author: Andrew Green, 20.03.2014
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4GPS_DATA_HH
|
||||
#define G4GPS_DATA_HH 1
|
||||
|
||||
@@ -62,58 +55,71 @@
|
||||
|
||||
class G4GeneralParticleSourceData
|
||||
{
|
||||
public:
|
||||
static G4GeneralParticleSourceData* Instance();
|
||||
|
||||
void AddASource(G4double intensity);
|
||||
void DeleteASource(G4int idx);
|
||||
void ClearSources();
|
||||
|
||||
void IntensityNormalise();
|
||||
|
||||
G4bool Normalised() const {return normalised;}
|
||||
|
||||
G4SingleParticleSource* GetCurrentSource(G4int idx);
|
||||
G4SingleParticleSource* GetCurrentSource() const {return currentSource;}
|
||||
public:
|
||||
|
||||
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);}
|
||||
static G4GeneralParticleSourceData* Instance();
|
||||
|
||||
void SetCurrentSourceIntensity(G4double);
|
||||
void AddASource(G4double intensity);
|
||||
void DeleteASource(G4int idx);
|
||||
void ClearSources();
|
||||
|
||||
void IntensityNormalise();
|
||||
|
||||
inline G4bool Normalised() const
|
||||
{ return normalised; }
|
||||
|
||||
G4SingleParticleSource* GetCurrentSource(G4int idx);
|
||||
inline G4SingleParticleSource* GetCurrentSource() const
|
||||
{ return currentSource; }
|
||||
|
||||
void SetFlatSampling(G4bool fSamp){flat_sampling = fSamp;}
|
||||
G4bool GetFlatSampling() const { return flat_sampling; }
|
||||
inline G4int GetSourceVectorSize() const
|
||||
{ return G4int(sourceVector.size()); }
|
||||
inline G4int GetIntensityVectorSize() const
|
||||
{ return G4int(sourceIntensity.size()); }
|
||||
inline G4double GetIntensity(G4int idx) const
|
||||
{ return sourceIntensity.at(idx); }
|
||||
inline G4double GetSourceProbability(G4int idx) const
|
||||
{ return sourceProbability.at(idx); }
|
||||
|
||||
void SetCurrentSourceIntensity(G4double);
|
||||
|
||||
void SetMultipleVertex(G4bool flag) { multiple_vertex = flag; }
|
||||
G4bool GetMultipleVertex() const { return multiple_vertex; }
|
||||
inline void SetFlatSampling(G4bool fSamp)
|
||||
{ flat_sampling = fSamp; }
|
||||
inline G4bool GetFlatSampling() const
|
||||
{ return flat_sampling; }
|
||||
|
||||
G4int GetCurrentSourceIdx() const { return currentSourceIdx; }
|
||||
inline void SetMultipleVertex(G4bool flag)
|
||||
{ multiple_vertex = flag; }
|
||||
inline G4bool GetMultipleVertex() const
|
||||
{ return multiple_vertex; }
|
||||
|
||||
void SetVerbosityAllSources(G4int vl);
|
||||
//Lock/Unlock shared mutex
|
||||
void Lock();
|
||||
void Unlock();
|
||||
inline G4int GetCurrentSourceIdx() const
|
||||
{ return currentSourceIdx; }
|
||||
|
||||
void SetVerbosityAllSources(G4int vl);
|
||||
|
||||
void Lock();
|
||||
void Unlock();
|
||||
//Lock/Unlock shared mutex
|
||||
|
||||
private:
|
||||
G4GeneralParticleSourceData();
|
||||
~G4GeneralParticleSourceData();
|
||||
private:
|
||||
|
||||
G4GeneralParticleSourceData();
|
||||
~G4GeneralParticleSourceData();
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
std::vector<G4SingleParticleSource*> sourceVector;
|
||||
std::vector <G4double> sourceIntensity;
|
||||
std::vector <G4double> sourceProbability;
|
||||
|
||||
std::vector<G4SingleParticleSource*> sourceVector;
|
||||
std::vector <G4double> sourceIntensity;
|
||||
std::vector <G4double> sourceProbability;
|
||||
G4bool multiple_vertex = false;
|
||||
G4bool flat_sampling = false;
|
||||
G4bool normalised = false;
|
||||
|
||||
G4bool multiple_vertex;
|
||||
G4bool flat_sampling;
|
||||
G4bool normalised;
|
||||
|
||||
G4int currentSourceIdx;
|
||||
G4SingleParticleSource* currentSource;
|
||||
G4Mutex mutex;
|
||||
G4int currentSourceIdx = 0;
|
||||
G4SingleParticleSource* currentSource = nullptr;
|
||||
G4Mutex mutex;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,69 +23,34 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MODULE: G4GeneralParticleSourceMessenger.hh
|
||||
//
|
||||
// Version: 2.0
|
||||
// Date: 5/02/04
|
||||
// Author: Fan Lei
|
||||
// Organisation: QinetiQ ltd.
|
||||
// Customer: ESA/ESTEC
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CHANGE HISTORY
|
||||
// --------------
|
||||
//
|
||||
// Version 2.0, 05/02/2004, Fan Lei, Created.
|
||||
// After changes to version 1.1 as in Geant4 v6.0
|
||||
// - Mutilple particle source definition
|
||||
// - Re-structured commands
|
||||
// - old commonds have been retained for backward compatibility, will be
|
||||
// removed in the future.
|
||||
//
|
||||
// Version 3.0, Aug-Oct 2014, Andrea Dotti
|
||||
// Transformations for thread safety and use in MT application
|
||||
// Messenger is now a singleton w/ explicit Destroy() method for deletion
|
||||
// Note the following: the class should be instantiated only once
|
||||
// by a worker thread. It relies on a new feature of basic messenger class
|
||||
// that allows for UI commands to be created by worker threads but being
|
||||
// executed by master thread. For this reason the messenger itself should
|
||||
// be created once, form here the singleton pattern
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// G4GeneralParticleSourceMessenger
|
||||
//
|
||||
// Class Description:
|
||||
//
|
||||
// The function of the G4GeneralParticleSourceMessenger is to allow the user to
|
||||
// enter commands either in interactive command line mode or through macros to
|
||||
// control the G4GeneralParticleSource.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MEMBER FUNCTIONS
|
||||
// ----------------
|
||||
//
|
||||
// G4GeneralParticleSourceMessenger(G4GeneralParticleSource *fPtclGun)
|
||||
// Constructor: Sets up commands.
|
||||
//
|
||||
// ~G4GeneralParticleSourceMessenger()
|
||||
// Destructor: Deletes commands.
|
||||
//
|
||||
// void SetParticleGun(G4SingleParticleSource *fpg) { fParticleGun = fpg; } ;
|
||||
// To selecte the particle gun to be defined/modified.
|
||||
// void SetNewValue(G4UIcommand *command, G4String newValues)
|
||||
// Uses the appropriate methods in the G4GeneralParticleSource to carry out
|
||||
// the user commands.
|
||||
// G4String GetCurrentValue(G4UIcommand *command)
|
||||
// Allows the user to retrieve the current values of parameters.
|
||||
// Not implemented yet.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
#ifndef G4GeneralParticleSourceMessenger_h
|
||||
#define G4GeneralParticleSourceMessenger_h 1
|
||||
|
||||
// Author: Fan Lei, QinetiQ ltd.
|
||||
// Customer: ESA/ESTEC
|
||||
// History:
|
||||
// - Version 2.0, 05/02/2004, Fan Lei - Created.
|
||||
// Multiple particle source definition
|
||||
// - Version 2.1, 20/03/2014, Andrew Green - Modifications for MT
|
||||
// Added a check to force only one thread to parse the macro file.
|
||||
// This information is fed into the GPS which now has a split mechanism
|
||||
// for the large data (hence need to only read in 1 thread)
|
||||
// - Version 3.0, Aug-Oct 2014, Andrea Dotti
|
||||
// Transformations for thread safety and use in MT application
|
||||
// Messenger is now a singleton w/ explicit Destroy() method for deletion
|
||||
// Note the following: the class should be instantiated only once
|
||||
// by a worker thread. It relies on a new feature of basic messenger class
|
||||
// that allows for UI commands to be created by worker threads but being
|
||||
// executed by master thread. For this reason the messenger itself should
|
||||
// be created once, form here the singleton pattern
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4GeneralParticleSourceMessenger_hh
|
||||
#define G4GeneralParticleSourceMessenger_hh 1
|
||||
|
||||
#include "G4UImessenger.hh"
|
||||
#include "globals.hh"
|
||||
@@ -106,6 +71,153 @@ class G4UIcmdWithoutParameter;
|
||||
class G4SingleParticleSource;
|
||||
class G4GeneralParticleSource;
|
||||
|
||||
class G4GeneralParticleSourceMessenger: public G4UImessenger
|
||||
{
|
||||
public:
|
||||
|
||||
void SetParticleGun(G4SingleParticleSource *fpg) { fParticleGun = fpg; } ;
|
||||
// Select the particle gun to be defined/modified
|
||||
|
||||
void SetNewValue(G4UIcommand* command, G4String newValues);
|
||||
// Identifies the command which has been invoked by the user, extracts the
|
||||
// parameters associated with that command (held in newValues), and uses
|
||||
// these values with the appropriate member function of
|
||||
// G4GeneralParticleSource
|
||||
|
||||
G4String GetCurrentValue(G4UIcommand* command);
|
||||
// Allows the user to retrieve the current values of parameters.
|
||||
// NOT yet implemented!
|
||||
|
||||
static G4GeneralParticleSourceMessenger* GetInstance(G4GeneralParticleSource*);
|
||||
static void Destroy();
|
||||
|
||||
private:
|
||||
|
||||
G4GeneralParticleSourceMessenger(G4GeneralParticleSource*);
|
||||
// Constructor: sets up commands
|
||||
~G4GeneralParticleSourceMessenger();
|
||||
// Destructor: deletes commands
|
||||
|
||||
void IonCommand(G4String newValues);
|
||||
void IonLvlCommand(G4String newValues);
|
||||
|
||||
private:
|
||||
|
||||
G4GeneralParticleSource* fGPS = nullptr;
|
||||
G4SingleParticleSource* fParticleGun = nullptr;
|
||||
G4ParticleTable* particleTable = nullptr;
|
||||
G4String histtype;
|
||||
|
||||
G4UIdirectory* gpsDirectory;
|
||||
|
||||
// Multiple source control commands
|
||||
//
|
||||
G4UIdirectory *sourceDirectory;
|
||||
G4UIcmdWithADouble *addsourceCmd;
|
||||
G4UIcmdWithoutParameter *listsourceCmd;
|
||||
G4UIcmdWithoutParameter *clearsourceCmd;
|
||||
G4UIcmdWithoutParameter *getsourceCmd;
|
||||
G4UIcmdWithAnInteger *setsourceCmd;
|
||||
G4UIcmdWithADouble *setintensityCmd;
|
||||
G4UIcmdWithAnInteger *deletesourceCmd;
|
||||
G4UIcmdWithABool *multiplevertexCmd;
|
||||
G4UIcmdWithABool *flatsamplingCmd;
|
||||
|
||||
// Positional commands
|
||||
//
|
||||
G4UIdirectory *positionDirectory;
|
||||
G4UIcmdWithAString *typeCmd1;
|
||||
G4UIcmdWithAString *shapeCmd1;
|
||||
G4UIcmdWith3VectorAndUnit *centreCmd1;
|
||||
G4UIcmdWith3Vector *posrot1Cmd1;
|
||||
G4UIcmdWith3Vector *posrot2Cmd1;
|
||||
G4UIcmdWithADoubleAndUnit *halfxCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *halfyCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *halfzCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *radiusCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *radius0Cmd1;
|
||||
G4UIcmdWithADoubleAndUnit *possigmarCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *possigmaxCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *possigmayCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *paralpCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *partheCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *parphiCmd1;
|
||||
G4UIcmdWithAString *confineCmd1;
|
||||
|
||||
// Angular commands
|
||||
//
|
||||
G4UIdirectory* angularDirectory;
|
||||
G4UIcmdWithAString *angtypeCmd1;
|
||||
G4UIcmdWith3Vector *angrot1Cmd1;
|
||||
G4UIcmdWith3Vector *angrot2Cmd1;
|
||||
G4UIcmdWithADoubleAndUnit *minthetaCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *maxthetaCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *minphiCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *maxphiCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *angsigmarCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *angsigmaxCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *angsigmayCmd1;
|
||||
G4UIcmdWith3VectorAndUnit *angfocusCmd;
|
||||
G4UIcmdWithABool *useuserangaxisCmd1;
|
||||
G4UIcmdWithABool *surfnormCmd1;
|
||||
|
||||
// Energy commands
|
||||
//
|
||||
G4UIdirectory* energyDirectory;
|
||||
G4UIcmdWithAString *energytypeCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *eminCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *emaxCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *monoenergyCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *engsigmaCmd1;
|
||||
G4UIcmdWithADouble *alphaCmd1;
|
||||
G4UIcmdWithADouble *tempCmd1;
|
||||
G4UIcmdWithADouble *ezeroCmd1;
|
||||
G4UIcmdWithADouble *gradientCmd1;
|
||||
G4UIcmdWithADouble *interceptCmd1;
|
||||
G4UIcmdWithADouble *arbeintCmd1;
|
||||
G4UIcmdWithoutParameter *calculateCmd1;
|
||||
G4UIcmdWithABool *energyspecCmd1;
|
||||
G4UIcmdWithABool *diffspecCmd1;
|
||||
G4UIcmdWithABool *applyEnergyWeightCmd1;
|
||||
|
||||
// Histogram commands
|
||||
//
|
||||
G4UIdirectory *histDirectory;
|
||||
G4UIcmdWith3Vector *histpointCmd1;
|
||||
G4UIcmdWithAString *histfileCmd1;
|
||||
G4UIcmdWithAString *histnameCmd1;
|
||||
G4UIcmdWithAString *arbintCmd1;
|
||||
G4UIcmdWithAString *resethistCmd1;
|
||||
|
||||
G4UIcmdWithAnInteger* verbosityCmd;
|
||||
|
||||
// Commands from G4ParticleGun
|
||||
//
|
||||
G4UIcommand* ionCmd;
|
||||
G4UIcommand* ionLvlCmd;
|
||||
G4UIcmdWithAString* particleCmd;
|
||||
G4UIcmdWithADoubleAndUnit* timeCmd;
|
||||
G4UIcmdWith3Vector* polCmd;
|
||||
G4UIcmdWithAnInteger* numberCmd;
|
||||
G4UIcmdWith3VectorAndUnit* positionCmd;
|
||||
G4UIcmdWith3Vector* directionCmd;
|
||||
G4UIcmdWithADoubleAndUnit* energyCmd;
|
||||
G4UIcmdWithoutParameter* listCmd;
|
||||
|
||||
// For ion shooting
|
||||
//
|
||||
G4bool fShootIon = false;
|
||||
|
||||
G4int fAtomicNumber = 0;
|
||||
G4int fAtomicMass = 0;
|
||||
G4int fIonCharge = 0;
|
||||
G4double fIonExciteEnergy = 0.0;
|
||||
|
||||
G4int fAtomicNumberL = 0;
|
||||
G4int fAtomicMassL = 0;
|
||||
G4int fIonChargeL = 0;
|
||||
G4int fIonEnergyLevel = 0;
|
||||
|
||||
/** Andrea Dotti Feb 2015
|
||||
* GPS messenger design requires some explanation for what distributions
|
||||
* parameters are concerned : Each thread has its own GPS
|
||||
@@ -127,191 +239,6 @@ class G4GeneralParticleSource;
|
||||
* defaults parameter there).
|
||||
*/
|
||||
|
||||
class G4GeneralParticleSourceMessenger: public G4UImessenger
|
||||
{
|
||||
public:
|
||||
|
||||
void SetParticleGun(G4SingleParticleSource *fpg) { fParticleGun = fpg; } ;
|
||||
// Select the particle gun to be defined/modified
|
||||
|
||||
void SetNewValue(G4UIcommand *command, G4String newValues);
|
||||
// Identifies the command which has been invoked by the user, extracts the
|
||||
// parameters associated with that command (held in newValues), and uses
|
||||
// these values with the appropriate member function of G4GeneralParticleSource.
|
||||
|
||||
G4String GetCurrentValue(G4UIcommand *command);
|
||||
|
||||
static G4GeneralParticleSourceMessenger* GetInstance(G4GeneralParticleSource*);
|
||||
static void Destroy();
|
||||
private:
|
||||
G4GeneralParticleSourceMessenger(G4GeneralParticleSource*);
|
||||
~G4GeneralParticleSourceMessenger();
|
||||
|
||||
void IonCommand(G4String newValues);
|
||||
void IonLvlCommand(G4String newValues);
|
||||
|
||||
private:
|
||||
G4GeneralParticleSource* fGPS;
|
||||
G4SingleParticleSource* fParticleGun;
|
||||
G4ParticleTable* particleTable;
|
||||
G4String histtype;
|
||||
|
||||
private: //commands
|
||||
G4UIdirectory* gpsDirectory;
|
||||
|
||||
// multiple source control commands
|
||||
G4UIdirectory *sourceDirectory;
|
||||
G4UIcmdWithADouble *addsourceCmd;
|
||||
G4UIcmdWithoutParameter *listsourceCmd;
|
||||
G4UIcmdWithoutParameter *clearsourceCmd;
|
||||
G4UIcmdWithoutParameter *getsourceCmd;
|
||||
G4UIcmdWithAnInteger *setsourceCmd;
|
||||
G4UIcmdWithADouble *setintensityCmd;
|
||||
G4UIcmdWithAnInteger *deletesourceCmd;
|
||||
G4UIcmdWithABool *multiplevertexCmd;
|
||||
G4UIcmdWithABool *flatsamplingCmd;
|
||||
|
||||
// positional commands
|
||||
G4UIdirectory *positionDirectory;
|
||||
G4UIcmdWithAString *typeCmd1;
|
||||
G4UIcmdWithAString *shapeCmd1;
|
||||
G4UIcmdWith3VectorAndUnit *centreCmd1;
|
||||
G4UIcmdWith3Vector *posrot1Cmd1;
|
||||
G4UIcmdWith3Vector *posrot2Cmd1;
|
||||
G4UIcmdWithADoubleAndUnit *halfxCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *halfyCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *halfzCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *radiusCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *radius0Cmd1;
|
||||
G4UIcmdWithADoubleAndUnit *possigmarCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *possigmaxCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *possigmayCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *paralpCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *partheCmd1;
|
||||
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;
|
||||
|
||||
// angular commands
|
||||
G4UIdirectory* angularDirectory;
|
||||
G4UIcmdWithAString *angtypeCmd1;
|
||||
G4UIcmdWith3Vector *angrot1Cmd1;
|
||||
G4UIcmdWith3Vector *angrot2Cmd1;
|
||||
G4UIcmdWithADoubleAndUnit *minthetaCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *maxthetaCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *minphiCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *maxphiCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *angsigmarCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *angsigmaxCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *angsigmayCmd1;
|
||||
G4UIcmdWith3VectorAndUnit *angfocusCmd;
|
||||
G4UIcmdWithABool *useuserangaxisCmd1;
|
||||
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;
|
||||
|
||||
// energy commands
|
||||
G4UIdirectory* energyDirectory;
|
||||
G4UIcmdWithAString *energytypeCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *eminCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *emaxCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *monoenergyCmd1;
|
||||
G4UIcmdWithADoubleAndUnit *engsigmaCmd1;
|
||||
G4UIcmdWithADouble *alphaCmd1;
|
||||
G4UIcmdWithADouble *tempCmd1;
|
||||
G4UIcmdWithADouble *ezeroCmd1;
|
||||
G4UIcmdWithADouble *gradientCmd1;
|
||||
G4UIcmdWithADouble *interceptCmd1;
|
||||
G4UIcmdWithADouble *arbeintCmd1;
|
||||
G4UIcmdWithoutParameter *calculateCmd1;
|
||||
G4UIcmdWithABool *energyspecCmd1;
|
||||
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;
|
||||
|
||||
// histogram commands
|
||||
G4UIdirectory *histDirectory;
|
||||
// old ones, will be removed soon
|
||||
//G4UIcmdWith3Vector *histpointCmd;
|
||||
//G4UIcmdWithAString *histnameCmd;
|
||||
//G4UIcmdWithAString *arbintCmd;
|
||||
//G4UIcmdWithAString *resethistCmd;
|
||||
G4UIcmdWith3Vector *histpointCmd1;
|
||||
G4UIcmdWithAString *histfileCmd1;
|
||||
G4UIcmdWithAString *histnameCmd1;
|
||||
G4UIcmdWithAString *arbintCmd1;
|
||||
G4UIcmdWithAString *resethistCmd1;
|
||||
|
||||
G4UIcmdWithAnInteger* verbosityCmd;
|
||||
|
||||
// Commands from G4ParticleGun
|
||||
G4UIcommand* ionCmd;
|
||||
G4UIcommand* ionLvlCmd;
|
||||
G4UIcmdWithAString* particleCmd;
|
||||
G4UIcmdWithADoubleAndUnit* timeCmd;
|
||||
G4UIcmdWith3Vector* polCmd;
|
||||
G4UIcmdWithAnInteger* numberCmd;
|
||||
G4UIcmdWith3VectorAndUnit* positionCmd;
|
||||
G4UIcmdWith3Vector* directionCmd;
|
||||
G4UIcmdWithADoubleAndUnit* energyCmd;
|
||||
G4UIcmdWithoutParameter* listCmd;
|
||||
|
||||
private: // for ion shooting
|
||||
G4bool fShootIon;
|
||||
|
||||
G4int fAtomicNumber;
|
||||
G4int fAtomicMass;
|
||||
G4int fIonCharge;
|
||||
G4double fIonExciteEnergy;
|
||||
|
||||
G4int fAtomicNumberL;
|
||||
G4int fAtomicMassL;
|
||||
G4int fIonChargeL;
|
||||
G4int fIonEnergyLevel;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,14 +23,13 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4HEPEvtInterface
|
||||
//
|
||||
//
|
||||
//
|
||||
// class description:
|
||||
// Class description:
|
||||
//
|
||||
// This is a concrete class of G4VPrimaryGenerator.
|
||||
// This class object reads an ASCII file which contains particles generated
|
||||
// by a physics generator which supports /HEPEVT/ common block.
|
||||
// It reads an ASCII file which contains particles generated by a
|
||||
// physics generator which supports a /HEPEVT/ common block.
|
||||
//
|
||||
// The format of ASCII file must be equivalent to the following sample
|
||||
// Fortran code:
|
||||
@@ -61,8 +60,10 @@
|
||||
// corresponding set methods of G4VPrimaryGenerator base class, otherwise
|
||||
// zero will be set.
|
||||
|
||||
#ifndef G4HEPEvtInterface_h
|
||||
#define G4HEPEvtInterface_h 1
|
||||
// Author: Makoto Asai, 1997
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4HEPEvtInterface_hh
|
||||
#define G4HEPEvtInterface_hh 1
|
||||
|
||||
#include <fstream>
|
||||
#include <vector>
|
||||
@@ -74,20 +75,21 @@
|
||||
class G4PrimaryVertex;
|
||||
class G4Event;
|
||||
|
||||
class G4HEPEvtInterface:public G4VPrimaryGenerator
|
||||
class G4HEPEvtInterface : public G4VPrimaryGenerator
|
||||
{
|
||||
public: // with description
|
||||
G4HEPEvtInterface(const char* evfile, G4int vl=0);
|
||||
// G4HEPEvtInterface(G4String evfile);
|
||||
// Constructors, "evfile" is the file name (with directory path).
|
||||
|
||||
public:
|
||||
|
||||
G4HEPEvtInterface(const char* evfile, G4int vl=0);
|
||||
// Constructor, "evfile" is the file name (with directory path).
|
||||
|
||||
~G4HEPEvtInterface();
|
||||
// Destructor
|
||||
|
||||
void GeneratePrimaryVertex(G4Event* evt);
|
||||
|
||||
private:
|
||||
G4int vLevel;
|
||||
|
||||
G4int vLevel = 0;
|
||||
G4String fileName;
|
||||
std::ifstream inputFile;
|
||||
std::vector<G4HEPEvtParticle*> HPlist;
|
||||
|
||||
@@ -23,16 +23,17 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4HEPEvtParticle
|
||||
//
|
||||
//
|
||||
//
|
||||
// class desccription:
|
||||
// Class desccription:
|
||||
//
|
||||
// This class is exclusively used by G4HEPEvtInterface.
|
||||
// It represents one particle in /HEPEVT/ list.
|
||||
|
||||
#ifndef G4HEPEvtParticle_h
|
||||
#define G4HEPEvtParticle_h 1
|
||||
// Author: Makoto Asai, 1997
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4HEPEvtParticle_hh
|
||||
#define G4HEPEvtParticle_hh 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "evtdefs.hh"
|
||||
@@ -42,42 +43,38 @@
|
||||
class G4HEPEvtParticle
|
||||
{
|
||||
public:
|
||||
inline void *operator new(size_t);
|
||||
inline void operator delete(void *aStackedTrack);
|
||||
|
||||
G4HEPEvtParticle();
|
||||
G4HEPEvtParticle(G4PrimaryParticle* pp,
|
||||
G4int isthep, G4int jdahep1, G4int jdahep2);
|
||||
~G4HEPEvtParticle();
|
||||
G4HEPEvtParticle();
|
||||
G4HEPEvtParticle(G4PrimaryParticle* pp,
|
||||
G4int isthep, G4int jdahep1, G4int jdahep2);
|
||||
~G4HEPEvtParticle();
|
||||
|
||||
G4HEPEvtParticle & operator=(const G4HEPEvtParticle &right);
|
||||
G4bool operator==(const G4HEPEvtParticle &right) const;
|
||||
G4bool operator!=(const G4HEPEvtParticle &right) const;
|
||||
G4HEPEvtParticle & operator=(const G4HEPEvtParticle& right);
|
||||
G4bool operator==(const G4HEPEvtParticle &right) const;
|
||||
G4bool operator!=(const G4HEPEvtParticle &right) const;
|
||||
|
||||
inline void *operator new(std::size_t);
|
||||
inline void operator delete(void* aStackedTrack);
|
||||
|
||||
inline G4PrimaryParticle* GetTheParticle() { return theParticle; }
|
||||
inline void Done() { ISTHEP *= -1; }
|
||||
inline G4int GetISTHEP() { return ISTHEP; }
|
||||
inline G4int GetJDAHEP1() { return JDAHEP1; }
|
||||
inline G4int GetJDAHEP2() { return JDAHEP2; }
|
||||
|
||||
private:
|
||||
G4PrimaryParticle * theParticle;
|
||||
G4int ISTHEP; // Status code of the entry
|
||||
// Set to be 0 after generating links of
|
||||
// G4PrimaryParticle object
|
||||
G4int JDAHEP1;
|
||||
G4int JDAHEP2;
|
||||
|
||||
public:
|
||||
inline G4PrimaryParticle * GetTheParticle()
|
||||
{ return theParticle; }
|
||||
inline void Done()
|
||||
{ ISTHEP *= -1; }
|
||||
inline G4int GetISTHEP()
|
||||
{ return ISTHEP; }
|
||||
inline G4int GetJDAHEP1()
|
||||
{ return JDAHEP1; }
|
||||
inline G4int GetJDAHEP2()
|
||||
{ return JDAHEP2; }
|
||||
G4PrimaryParticle* theParticle = nullptr;
|
||||
G4int ISTHEP = 1; // Status code of the entry
|
||||
// Set to be 0 after generating links of
|
||||
// G4PrimaryParticle object
|
||||
G4int JDAHEP1 = 1;
|
||||
G4int JDAHEP2 = 1;
|
||||
};
|
||||
|
||||
extern G4EVENT_DLL G4Allocator<G4HEPEvtParticle>*& aHEPEvtParticleAllocator();
|
||||
|
||||
inline void * G4HEPEvtParticle::operator new(size_t)
|
||||
inline void * G4HEPEvtParticle::operator new(std::size_t)
|
||||
{
|
||||
if (!aHEPEvtParticleAllocator())
|
||||
aHEPEvtParticleAllocator() = new G4Allocator<G4HEPEvtParticle>;
|
||||
@@ -90,4 +87,3 @@ inline void G4HEPEvtParticle::operator delete(void * aHEPEvtParticle)
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,35 +23,28 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4MultiEventAction
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4MultiEventAction.hh
|
||||
//
|
||||
// Created on: Jan 17, 2016
|
||||
// Author: adotti
|
||||
//
|
||||
//
|
||||
// class description:
|
||||
// This class extends G4UserEventAction and allows multiple
|
||||
// user-defined tracking actions to be used in the same job.
|
||||
// The class is a vector of user-defined tracking actions.
|
||||
// This class owns and manages the dependent user-actions.
|
||||
// This class extends G4UserEventAction and allows multiple user-defined
|
||||
// tracking actions to be used in the same job.
|
||||
// The class is a vector of user-defined tracking actions.
|
||||
// This class owns and manages the dependent user-actions.
|
||||
// Usage:
|
||||
// There is no need to explicitly use this class as long as the
|
||||
// user actions are set via G4UserActionInitialization::SetUserAction
|
||||
// that can be called several times. Explicitly this is what is happening:
|
||||
// There is no need to explicitly use this class as long as the
|
||||
// user actions are set via G4UserActionInitialization::SetUserAction()
|
||||
// that can be called several times. Explicitly, this is what is happening:
|
||||
// In user-defined action initialization:
|
||||
// G4MultiEventAction* action = new G4MultiEventAction;
|
||||
// action->push_back( G4UserEventActionUPtr( new MyUserEventAction );
|
||||
// [... add as many as needed ...]
|
||||
// SetUserAction( action );
|
||||
// ---------------------------------------------------------------
|
||||
//
|
||||
// G4MultiEventAction* action = new G4MultiEventAction;
|
||||
// action->push_back( G4UserEventActionUPtr( new MyUserEventAction );
|
||||
// [... add as many as needed ...]
|
||||
// SetUserAction( action );
|
||||
|
||||
#ifndef G4MULTIEVENTACTION_HH_
|
||||
#define G4MULTIEVENTACTION_HH_
|
||||
// Author: Andrea Dotti, SLAC - 17.01.2016
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4MULTIEVENTACTION_HH
|
||||
#define G4MULTIEVENTACTION_HH
|
||||
|
||||
#include "G4UserEventAction.hh"
|
||||
#include <vector>
|
||||
@@ -60,14 +53,16 @@
|
||||
using G4UserEventActionUPtr=std::unique_ptr<G4UserEventAction>;
|
||||
using G4UserEventActionVector=std::vector<G4UserEventActionUPtr>;
|
||||
|
||||
class G4MultiEventAction : public G4UserEventAction , public G4UserEventActionVector
|
||||
class G4MultiEventAction : public G4UserEventAction
|
||||
, public G4UserEventActionVector
|
||||
{
|
||||
public:
|
||||
G4MultiEventAction() = default;
|
||||
virtual ~G4MultiEventAction() override = default;
|
||||
virtual void SetEventManager(G4EventManager* ) override;
|
||||
virtual void BeginOfEventAction(const G4Event* ) override;
|
||||
virtual void EndOfEventAction(const G4Event* ) override;
|
||||
public:
|
||||
|
||||
G4MultiEventAction() = default;
|
||||
virtual ~G4MultiEventAction() override = default;
|
||||
virtual void SetEventManager(G4EventManager* ) override;
|
||||
virtual void BeginOfEventAction(const G4Event* ) override;
|
||||
virtual void EndOfEventAction(const G4Event* ) override;
|
||||
};
|
||||
|
||||
#endif /* SOURCE_EVENT_INCLUDE_G4MULTIEVENTACTION_HH_ */
|
||||
#endif
|
||||
|
||||
@@ -23,12 +23,33 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4ParticleGum
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// This is a concrete class of G4VPrimaryGenerator. It shoots a particle of
|
||||
// given type into a given direction with either a given kinetic energy or
|
||||
// momentum.
|
||||
// The position and time of the primary particle must be set by the
|
||||
// corresponding set methods of the G4VPrimaryGenerator base class, otherwise
|
||||
// zero will be set.
|
||||
//
|
||||
// The FAQ to this class is for randomizing position/direction/kinetic energy
|
||||
// of the primary particle. But, G4ParticleGun does NOT have any way of
|
||||
// randomization. Instead, the user's concrete implementation of
|
||||
// G4VUserPrimaryGeneratorAction which transfer the G4Event object
|
||||
// to this particle gun can randomize these quantities and set to this
|
||||
// particle gun before invoking GeneratePrimaryVertex() method.
|
||||
// Note that, even if the particle gun shoots more than one particles at one
|
||||
// invokation of the GeneratePrimaryVertex() method, all particles have the
|
||||
// same physical quantities. If the user wants to shoot two particles with
|
||||
// different momentum, position, etc., should invoke GeneratePrimaryVertex()
|
||||
// method twice and set quantities on demand to the particle gun.
|
||||
|
||||
#ifndef G4ParticleGun_h
|
||||
#define G4ParticleGun_h 1
|
||||
|
||||
// Author: Makoto Asai, 1997
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4ParticleGun_hh
|
||||
#define G4ParticleGun_hh 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4VPrimaryGenerator.hh"
|
||||
@@ -40,103 +61,79 @@
|
||||
class G4Event;
|
||||
class G4ParticleGunMessenger;
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This is a concrete class of G4VPrimaryGenerator. It shoots a particle of given type
|
||||
// into a given direction with either a given kinetic energy or momentum.
|
||||
// The position and time of the primary particle must be set by the corresponding
|
||||
// set methods of G4VPrimaryGenerator base class, otherwise zero will be set.
|
||||
//
|
||||
// The FAQ to this class is for randomizing position/direction/kinetic energy of primary
|
||||
// particle. But, G4ParticleGun does NOT have any way of randomization. Instead, the user's
|
||||
// concrete implementation of G4VUserPrimaryGeneratorAction which transmits G4Event object
|
||||
// to this particle gun can randomize these quantities and set to this particle gun before
|
||||
// invoking GeneratePrimaryVertex() method.
|
||||
// Note that, even if the particle gun shoots more than one particles at one invokation of
|
||||
// GeneratePrimaryVertex() method, all particles have the same physical quantities. If the
|
||||
// user wants to shoot two particles with different momentum, position, etc., invoke
|
||||
// GeneratePrimaryVertex() method twice and set quantities on demand to the particle gun.
|
||||
//
|
||||
|
||||
class G4ParticleGun:public G4VPrimaryGenerator
|
||||
class G4ParticleGun : public G4VPrimaryGenerator
|
||||
{
|
||||
public: // with description
|
||||
G4ParticleGun();
|
||||
G4ParticleGun(G4int numberofparticles);
|
||||
G4ParticleGun(G4ParticleDefinition * particleDef,
|
||||
G4int numberofparticles = 1);
|
||||
// costructors. "numberofparticles" is number of particles to be shoot at one invokation
|
||||
// of GeneratePrimaryVertex() method. All paricles are shot with the same physical
|
||||
// quantities.
|
||||
|
||||
public:
|
||||
virtual ~G4ParticleGun();
|
||||
|
||||
private:
|
||||
G4ParticleGun(const G4ParticleGun&) = delete;
|
||||
const G4ParticleGun & operator=(const G4ParticleGun&) = delete;
|
||||
G4bool operator==(const G4ParticleGun&) const = delete;
|
||||
G4bool operator!=(const G4ParticleGun&) const = delete;
|
||||
G4ParticleGun();
|
||||
G4ParticleGun(G4int numberofparticles);
|
||||
G4ParticleGun(G4ParticleDefinition* particleDef,
|
||||
G4int numberofparticles = 1);
|
||||
// Costructors. "numberofparticles" is the number of particles to be
|
||||
// shot at one invokation of GeneratePrimaryVertex() method.
|
||||
// All particles are shot with the same physical quantities.
|
||||
|
||||
public: // with description
|
||||
virtual void GeneratePrimaryVertex(G4Event* evt);
|
||||
// Creates a primary vertex at the given point and put primary particles to it.
|
||||
// Followings are set methods for the particle properties.
|
||||
// SetParticleDefinition should be called first.
|
||||
// By using SetParticleMomentum(), both particle_momentum_direction and
|
||||
// particle_energy(Kinetic Energy) are set.
|
||||
//
|
||||
void SetParticleDefinition
|
||||
(G4ParticleDefinition * aParticleDefinition);
|
||||
void SetParticleEnergy(G4double aKineticEnergy);
|
||||
void SetParticleMomentum(G4double aMomentum);
|
||||
void SetParticleMomentum(G4ParticleMomentum aMomentum);
|
||||
void SetParticleMomentumDirection
|
||||
(G4ParticleMomentum aMomentumDirection)
|
||||
{ particle_momentum_direction = aMomentumDirection.unit(); }
|
||||
void SetParticleCharge(G4double aCharge)
|
||||
{ particle_charge = aCharge; }
|
||||
void SetParticlePolarization(G4ThreeVector aVal)
|
||||
{ particle_polarization = aVal; }
|
||||
void SetNumberOfParticles(G4int i)
|
||||
{ NumberOfParticlesToBeGenerated = i; }
|
||||
virtual ~G4ParticleGun();
|
||||
|
||||
public:
|
||||
G4ParticleDefinition* GetParticleDefinition() const
|
||||
{ return particle_definition; }
|
||||
G4ParticleMomentum GetParticleMomentumDirection() const
|
||||
{ return particle_momentum_direction; }
|
||||
G4double GetParticleEnergy() const
|
||||
{ return particle_energy; }
|
||||
G4double GetParticleMomentum() const
|
||||
{ return particle_momentum; }
|
||||
G4double GetParticleCharge() const
|
||||
{ return particle_charge; }
|
||||
G4ThreeVector GetParticlePolarization() const
|
||||
{ return particle_polarization; }
|
||||
G4int GetNumberOfParticles() const
|
||||
{ return NumberOfParticlesToBeGenerated; }
|
||||
G4ParticleGun(const G4ParticleGun&) = delete;
|
||||
const G4ParticleGun& operator=(const G4ParticleGun&) = delete;
|
||||
G4bool operator==(const G4ParticleGun&) const = delete;
|
||||
G4bool operator!=(const G4ParticleGun&) const = delete;
|
||||
|
||||
virtual void GeneratePrimaryVertex(G4Event* evt);
|
||||
// Creates a primary vertex at the given point
|
||||
// and put primary particles to it.
|
||||
|
||||
// Followings are the Set methods for the particle properties.
|
||||
// SetParticleDefinition() should be called first.
|
||||
// By using SetParticleMomentum(), both particle_momentum_direction and
|
||||
// particle_energy(Kinetic Energy) are set.
|
||||
//
|
||||
void SetParticleDefinition(G4ParticleDefinition* aParticleDefinition);
|
||||
void SetParticleEnergy(G4double aKineticEnergy);
|
||||
void SetParticleMomentum(G4double aMomentum);
|
||||
void SetParticleMomentum(G4ParticleMomentum aMomentum);
|
||||
inline void SetParticleMomentumDirection(G4ParticleMomentum aMomDirection)
|
||||
{ particle_momentum_direction = aMomDirection.unit(); }
|
||||
inline void SetParticleCharge(G4double aCharge)
|
||||
{ particle_charge = aCharge; }
|
||||
inline void SetParticlePolarization(G4ThreeVector aVal)
|
||||
{ particle_polarization = aVal; }
|
||||
inline void SetNumberOfParticles(G4int i)
|
||||
{ NumberOfParticlesToBeGenerated = i; }
|
||||
|
||||
inline G4ParticleDefinition* GetParticleDefinition() const
|
||||
{ return particle_definition; }
|
||||
inline G4ParticleMomentum GetParticleMomentumDirection() const
|
||||
{ return particle_momentum_direction; }
|
||||
inline G4double GetParticleEnergy() const
|
||||
{ return particle_energy; }
|
||||
inline G4double GetParticleMomentum() const
|
||||
{ return particle_momentum; }
|
||||
inline G4double GetParticleCharge() const
|
||||
{ return particle_charge; }
|
||||
inline G4ThreeVector GetParticlePolarization() const
|
||||
{ return particle_polarization; }
|
||||
inline G4int GetNumberOfParticles() const
|
||||
{ return NumberOfParticlesToBeGenerated; }
|
||||
|
||||
protected:
|
||||
|
||||
virtual void SetInitialValues();
|
||||
|
||||
G4int NumberOfParticlesToBeGenerated;
|
||||
G4ParticleDefinition* particle_definition;
|
||||
G4int NumberOfParticlesToBeGenerated = 0;
|
||||
G4ParticleDefinition* particle_definition = nullptr;
|
||||
G4ParticleMomentum particle_momentum_direction;
|
||||
G4double particle_energy;
|
||||
G4double particle_momentum;
|
||||
G4double particle_charge;
|
||||
G4double particle_energy = 0.0;
|
||||
G4double particle_momentum = 0.0;
|
||||
G4double particle_charge = 0.0;
|
||||
G4ThreeVector particle_polarization;
|
||||
|
||||
private:
|
||||
G4ParticleGunMessenger* theMessenger;
|
||||
|
||||
G4ParticleGunMessenger* theMessenger = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,12 +23,20 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4ParticleGunMessenger
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
//
|
||||
// This is a concrete class of G4UImessenger which handles commands for
|
||||
// G4ParticleGun.
|
||||
|
||||
#ifndef G4ParticleGunMessenger_h
|
||||
#define G4ParticleGunMessenger_h 1
|
||||
// Author: Makoto Asai, 1997
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4ParticleGunMessenger_hh
|
||||
#define G4ParticleGunMessenger_hh 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4UImessenger.hh"
|
||||
|
||||
class G4ParticleGun;
|
||||
class G4ParticleTable;
|
||||
@@ -41,58 +49,51 @@ class G4UIcmdWith3Vector;
|
||||
class G4UIcmdWith3VectorAndUnit;
|
||||
class G4UIcmdWithAnInteger;
|
||||
|
||||
#include "G4UImessenger.hh"
|
||||
#include "globals.hh"
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This is a concrete class of G4UImessenger which handles commands for
|
||||
// G4ParticleGun.
|
||||
//
|
||||
|
||||
class G4ParticleGunMessenger: public G4UImessenger
|
||||
class G4ParticleGunMessenger : public G4UImessenger
|
||||
{
|
||||
public:
|
||||
G4ParticleGunMessenger(G4ParticleGun * fPtclGun);
|
||||
|
||||
G4ParticleGunMessenger(G4ParticleGun* fPtclGun);
|
||||
~G4ParticleGunMessenger();
|
||||
|
||||
public:
|
||||
void SetNewValue(G4UIcommand * command,G4String newValues);
|
||||
G4String GetCurrentValue(G4UIcommand * command);
|
||||
void SetNewValue(G4UIcommand* command, G4String newValues);
|
||||
G4String GetCurrentValue(G4UIcommand* command);
|
||||
|
||||
private:
|
||||
void IonCommand(G4String newValues);
|
||||
void IonLevelCommand(G4String newValues);
|
||||
|
||||
void IonCommand(const G4String& newValues);
|
||||
void IonLevelCommand(const G4String& newValues);
|
||||
|
||||
private:
|
||||
G4ParticleGun * fParticleGun;
|
||||
G4ParticleTable * particleTable;
|
||||
|
||||
private: //commands
|
||||
G4UIdirectory * gunDirectory;
|
||||
G4UIcmdWithoutParameter * listCmd;
|
||||
G4UIcmdWithAString * particleCmd;
|
||||
G4UIcmdWith3Vector * directionCmd;
|
||||
G4UIcmdWithADoubleAndUnit * energyCmd;
|
||||
G4UIcmdWithADoubleAndUnit * momAmpCmd;
|
||||
G4UIcmdWith3VectorAndUnit * momCmd;
|
||||
G4UIcmdWith3VectorAndUnit * positionCmd;
|
||||
G4UIcmdWithADoubleAndUnit * timeCmd;
|
||||
G4UIcmdWith3Vector * polCmd;
|
||||
G4UIcmdWithAnInteger * numberCmd;
|
||||
|
||||
G4UIcommand * ionCmd;
|
||||
G4UIcommand* ionLvlCmd;
|
||||
G4ParticleGun* fParticleGun = nullptr;
|
||||
G4ParticleTable* particleTable = nullptr;
|
||||
|
||||
private: // for ion shooting
|
||||
G4bool fShootIon;
|
||||
G4int fAtomicNumber;
|
||||
G4int fAtomicMass;
|
||||
G4int fIonCharge;
|
||||
G4double fIonExciteEnergy;
|
||||
char fIonFloatingLevelBase;
|
||||
G4int fIonEnergyLevel;
|
||||
// Commands
|
||||
//
|
||||
G4UIdirectory* gunDirectory;
|
||||
G4UIcmdWithoutParameter* listCmd;
|
||||
G4UIcmdWithAString* particleCmd;
|
||||
G4UIcmdWith3Vector* directionCmd;
|
||||
G4UIcmdWithADoubleAndUnit* energyCmd;
|
||||
G4UIcmdWithADoubleAndUnit* momAmpCmd;
|
||||
G4UIcmdWith3VectorAndUnit* momCmd;
|
||||
G4UIcmdWith3VectorAndUnit* positionCmd;
|
||||
G4UIcmdWithADoubleAndUnit* timeCmd;
|
||||
G4UIcmdWith3Vector* polCmd;
|
||||
G4UIcmdWithAnInteger* numberCmd;
|
||||
G4UIcommand* ionCmd;
|
||||
G4UIcommand* ionLvlCmd;
|
||||
|
||||
// For ion shooting
|
||||
//
|
||||
G4bool fShootIon = false;
|
||||
G4int fAtomicNumber = 0;
|
||||
G4int fAtomicMass = 0;
|
||||
G4int fIonCharge = 0;
|
||||
G4double fIonExciteEnergy = 0.0;
|
||||
char fIonFloatingLevelBase = '\0';
|
||||
G4int fIonEnergyLevel = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,83 +23,84 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4PrimaryTransformer
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// This class is exclusively used by G4EventManager for the conversion
|
||||
// from G4PrimaryVertex/G4PrimaryParticle to G4DynamicParticle/G4Track.
|
||||
|
||||
#ifndef G4PromaryTransformer_h
|
||||
#define G4PromaryTransformer_h 1
|
||||
// Author: Makoto Asai, 1999
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4PrimaryTransformer_hh
|
||||
#define G4PrimaryTransformer_hh 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4TrackVector.hh"
|
||||
#include "G4ParticleTable.hh"
|
||||
#include "globals.hh"
|
||||
class G4Event;
|
||||
class G4PrimaryVertex;
|
||||
#include "G4PrimaryParticle.hh"
|
||||
#include "G4DynamicParticle.hh"
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This class is exclusively used by G4EventManager for the conversion
|
||||
// from G4PrimaryVertex/G4PrimaryParticle to G4DynamicParticle/G4Track.
|
||||
//
|
||||
class G4Event;
|
||||
class G4PrimaryVertex;
|
||||
|
||||
class G4PrimaryTransformer
|
||||
{
|
||||
public:
|
||||
|
||||
G4PrimaryTransformer();
|
||||
virtual ~G4PrimaryTransformer();
|
||||
|
||||
G4TrackVector* GimmePrimaries(G4Event* anEvent, G4int trackIDCounter=0);
|
||||
void CheckUnknown();
|
||||
|
||||
protected:
|
||||
G4TrackVector TV;
|
||||
G4ParticleTable* particleTable;
|
||||
G4int verboseLevel;
|
||||
G4int trackID;
|
||||
|
||||
G4ParticleDefinition* unknown;
|
||||
G4bool unknownParticleDefined;
|
||||
G4ParticleDefinition* opticalphoton;
|
||||
G4bool opticalphotonDefined;
|
||||
|
||||
G4int nWarn;
|
||||
|
||||
public:
|
||||
inline void SetVerboseLevel(G4int vl)
|
||||
{ verboseLevel = vl; };
|
||||
{ verboseLevel = vl; }
|
||||
|
||||
public: //with description
|
||||
void SetUnknnownParticleDefined(G4bool vl);
|
||||
// By invoking this Set method, the user can alter the treatment of unknown
|
||||
// particle. The ideal place to invoke this method is in the BeginOfRunAction.
|
||||
// By invoking this method, the user can alter the treatment of unknown
|
||||
// particles. The ideal place to invoke this method is in the
|
||||
// BeginOfRunAction().
|
||||
|
||||
inline G4bool GetUnknownParticleDefined() const
|
||||
{ return unknownParticleDefined; }
|
||||
{ return unknownParticleDefined; }
|
||||
|
||||
protected:
|
||||
|
||||
void GenerateTracks(G4PrimaryVertex* primaryVertex);
|
||||
void GenerateSingleTrack(G4PrimaryParticle* primaryParticle,
|
||||
G4double x0,G4double y0,G4double z0,G4double t0,G4double wv);
|
||||
G4double x0, G4double y0, G4double z0,
|
||||
G4double t0, G4double wv);
|
||||
void SetDecayProducts(G4PrimaryParticle* mother,
|
||||
G4DynamicParticle* motherDP);
|
||||
G4DynamicParticle* motherDP);
|
||||
G4bool CheckDynamicParticle(G4DynamicParticle*DP);
|
||||
|
||||
protected: //with description
|
||||
// Following two virtual methods are provided to customize the use of PrimaryTransformer
|
||||
// for particle types exotic to Geant4.
|
||||
// Following two virtual methods are provided to customize the use
|
||||
// of G4PrimaryTransformer for particle types exotic to Geant4.
|
||||
|
||||
virtual G4ParticleDefinition* GetDefinition(G4PrimaryParticle*pp);
|
||||
// Return appropriate G4ParticleDefinition w.r.t. the primary particle.
|
||||
// If NULL is returned, the particle will not be treated as a track, but its daughters
|
||||
// will be examined in case it has "pre-assigned decay products".
|
||||
virtual G4ParticleDefinition* GetDefinition(G4PrimaryParticle* pp);
|
||||
// Return appropriate G4ParticleDefinition w.r.t. the primary particle.
|
||||
// If nullptr is returned, the particle will not be treated as a track,
|
||||
// but its daughters will be examined in case it has "pre-assigned
|
||||
// decay products".
|
||||
|
||||
virtual G4bool IsGoodForTrack(G4ParticleDefinition*pd);
|
||||
// Return true if a primary particle should be converted into a track.
|
||||
// By default, all particles of non-shortlived and shortlived with valid decay
|
||||
// tables are converted.
|
||||
virtual G4bool IsGoodForTrack(G4ParticleDefinition* pd);
|
||||
// Return true if a primary particle should be converted into a track.
|
||||
// By default, all particles of non-shortlived and shortlived with
|
||||
// valid decay tables are converted.
|
||||
|
||||
protected:
|
||||
|
||||
G4TrackVector TV;
|
||||
G4ParticleTable* particleTable = nullptr;
|
||||
|
||||
G4ParticleDefinition* unknown = nullptr;
|
||||
G4ParticleDefinition* opticalphoton = nullptr;
|
||||
G4int verboseLevel = 0;
|
||||
G4int trackID = 0;
|
||||
G4int nWarn = 0;
|
||||
G4bool unknownParticleDefined = false;
|
||||
G4bool opticalphotonDefined = false;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
@@ -23,19 +23,18 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4RayShooter
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
|
||||
// class description:
|
||||
//
|
||||
// the object of this class shoots a ray (actually geantino) primary particle
|
||||
// The object of this class shoots a ray (actually geantino) primary particle
|
||||
// associated with a G4Event object. This slass must be used exclusively by
|
||||
// G4RayTracer.
|
||||
//
|
||||
|
||||
#ifndef G4RayShooter_h
|
||||
#define G4RayShooter_h 1
|
||||
|
||||
// Author: Makoto Asai, 2000
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4RayShooter_hh
|
||||
#define G4RayShooter_hh 1
|
||||
|
||||
#include "globals.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
@@ -47,33 +46,26 @@ class G4Event;
|
||||
|
||||
class G4RayShooter
|
||||
{
|
||||
public:
|
||||
G4RayShooter();
|
||||
public:
|
||||
virtual ~G4RayShooter();
|
||||
|
||||
public: // with description
|
||||
void Shoot(G4Event* evt,G4ThreeVector vtx,G4ThreeVector direc);
|
||||
// This method generates a primary vertex and a primary particle at the
|
||||
// given vertex point and with the given direction. This method is invoked
|
||||
// by G4RayTracer and G4MaterialScanner.
|
||||
G4RayShooter();
|
||||
virtual ~G4RayShooter();
|
||||
|
||||
private:
|
||||
void SetInitialValues();
|
||||
void Shoot(G4Event* evt, G4ThreeVector vtx, G4ThreeVector direc);
|
||||
// Generates a primary vertex and a primary particle at the given
|
||||
// vertex point and with the given direction. This method is invoked
|
||||
// by G4RayTracer and G4MaterialScanner.
|
||||
|
||||
G4ParticleDefinition* particle_definition;
|
||||
G4ParticleMomentum particle_momentum_direction;
|
||||
G4double particle_energy;
|
||||
G4ThreeVector particle_position;
|
||||
G4double particle_time;
|
||||
G4ThreeVector particle_polarization;
|
||||
private:
|
||||
|
||||
void SetInitialValues();
|
||||
|
||||
G4ParticleDefinition* particle_definition = nullptr;
|
||||
G4ParticleMomentum particle_momentum_direction;
|
||||
G4double particle_energy = 0.0;
|
||||
G4ThreeVector particle_position;
|
||||
G4double particle_time = 0.0;
|
||||
G4ThreeVector particle_polarization;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,133 +23,35 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// G4SPSAngDistribution
|
||||
//
|
||||
// MODULE: G4SPSAngDistribution.hh
|
||||
// Class description:
|
||||
//
|
||||
// Version: 1.0
|
||||
// Date: 5/02/04
|
||||
// Author: Fan Lei
|
||||
// Organisation: QinetiQ ltd.
|
||||
// Customer: ESA/ESTEC
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
//
|
||||
// CHANGE HISTORY
|
||||
// --------------
|
||||
// 06/06/2014 A Dotti
|
||||
// For thread safety: this is a shared object,
|
||||
// mutex has been added to control access to shared resources (data members).
|
||||
// in Getters and Setters, mutex is NOT used in GenerateOne because it is
|
||||
// assumed that properties are not changed during event loop.
|
||||
//
|
||||
// 26/10/2004 F Lei
|
||||
// To generate the direction of a primary vertex according to the
|
||||
// defined distribution. 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.
|
||||
|
||||
// Author: Fan Lei, QinetiQ ltd.
|
||||
// Customer: ESA/ESTEC
|
||||
// History:
|
||||
// - 05/02/2004, Fan Lei - Created.
|
||||
// Based on the G4GeneralParticleSource class.
|
||||
// - 26/10/2004, Fan Lei
|
||||
// Added a "focused" option to allow all primary particles pointing to
|
||||
// a user specified focusing point.
|
||||
//
|
||||
// Version 1.0, 05/02/2004, Fan Lei, Created.
|
||||
// Based on the G4GeneralParticleSource class in Geant4 v6.0
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Class Description:
|
||||
//
|
||||
// To generate the direction of a primary vertex according to the defined distribution
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MEMBER FUNCTIONS
|
||||
// ----------------
|
||||
//
|
||||
// G4SPSAngDistribution ()
|
||||
// Constructor: Initializes variables
|
||||
//
|
||||
// ~G4SPSAngDistribution ()
|
||||
// Destructor:
|
||||
//
|
||||
// void SetAngDistType(G4String)
|
||||
// Used to set the type of angular distribution wanted. Arguments
|
||||
// are iso, cos, beam and user for isotropic, cosine-law, beam and user-defined
|
||||
// respectively.
|
||||
//
|
||||
// void DefineAngRefAxes(G4String, G4ThreeVector)
|
||||
// DefineAngRefAxes is used in a similar way as SetPosRot to
|
||||
// define vectors, one x' and one in the plane x'y', to create
|
||||
// a rotated set of axes for the angular distribution.
|
||||
//
|
||||
// void SetMinTheta(G4double)
|
||||
// Sets the minimum value for the angle theta.
|
||||
//
|
||||
// void SetMinPhi(G4double)
|
||||
// Sets the minimum value for phi.
|
||||
//
|
||||
// void SetMaxTheta(G4double)
|
||||
// Sets the maximum value for theta.
|
||||
//
|
||||
// void SetMaxPhi(G4double)
|
||||
// Sets the maximum value for phi.
|
||||
//
|
||||
// void UserDefAngTheta(G4ThreeVector)
|
||||
// This method allows the user to define a histogram in Theta.
|
||||
//
|
||||
// void UserDefAngPhi(G4ThreeVector)
|
||||
// This method allows the user to define a histogram in phi.
|
||||
//
|
||||
// void GenerateIsotropicFlux()
|
||||
// This method generates momentum vectors for particles according
|
||||
// to an isotropic distribution.
|
||||
//
|
||||
// void GenerateCosineLawFlux()
|
||||
// This method generates momentum vectors for particles according
|
||||
// to a cosine-law distribution.
|
||||
//
|
||||
// void GenerateFocusedFlux()
|
||||
// This method generates momentum vectors for particles pointing to
|
||||
// an user specified focusing point.
|
||||
//
|
||||
// void GenerateUserDefFlux()
|
||||
// Controls generation of momentum vectors according to user-defined
|
||||
// distributions.
|
||||
//
|
||||
// G4double GenerateUserDefTheta()
|
||||
// Generates the theta angle according to a user-defined distribution.
|
||||
//
|
||||
// G4double GenerateUserDefPhi()
|
||||
// Generates phi according to a user-defined distribution.
|
||||
//
|
||||
// void SetBeamSigmaInAngR(G4double);
|
||||
// Sets the sigma for 1D beam
|
||||
//
|
||||
// void SetBeamSigmaInAngX(G4double);
|
||||
// Sets the first sigma for 2D beam
|
||||
//
|
||||
// void SetBeamSigmaInAngY(G4double);
|
||||
// Sets the second sigma for 2D beam
|
||||
//
|
||||
// void SetUserWRTSurface(G4bool)
|
||||
// Allows user to have user-defined spectra either with respect to the
|
||||
// co-ordinate system (default) or with respect to the surface normal.
|
||||
//
|
||||
// void SetPosDistribution(G4SPSPosDistribution* a) {posDist = a; };
|
||||
// Sets the required position generator, required for determining the cosine-law distribution
|
||||
//
|
||||
// void SetBiasRndm (G4SPSRandomGenerator* a)
|
||||
// Sets the biased random number generator
|
||||
//
|
||||
// G4ThreeVector GenerateOne();
|
||||
// Generate one random direction
|
||||
//
|
||||
// void ReSetHist(G4String);
|
||||
// Re-sets the histogram for user defined distribution
|
||||
//
|
||||
// void SetVerbosity(G4int)
|
||||
// Sets the verbosity level.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
#ifndef G4SPSAngDistribution_h
|
||||
#define G4SPSAngDistribution_h 1
|
||||
// - 06/06/2014, Andrea Dotti, SLAC
|
||||
// For thread safety: this is a shared object,
|
||||
// Added mutex to control access to shared resources (data members).
|
||||
// in Getters and Setters, mutex is NOT used in GenerateOne() because it is
|
||||
// assumed that properties are not changed during event loop.
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4SPSAngDistribution_hh
|
||||
#define G4SPSAngDistribution_hh 1
|
||||
|
||||
#include "G4PhysicsOrderedFreeVector.hh"
|
||||
#include "G4DataInterpolation.hh"
|
||||
@@ -161,97 +63,146 @@
|
||||
#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:
|
||||
G4SPSAngDistribution ();
|
||||
~G4SPSAngDistribution ();
|
||||
|
||||
// Angular Distribution Methods
|
||||
void SetAngDistType(G4String);
|
||||
void DefineAngRefAxes(G4String, G4ThreeVector);
|
||||
void SetMinTheta(G4double);
|
||||
void SetMinPhi(G4double);
|
||||
void SetMaxTheta(G4double);
|
||||
void SetMaxPhi(G4double);
|
||||
void SetBeamSigmaInAngR(G4double);
|
||||
void SetBeamSigmaInAngX(G4double);
|
||||
void SetBeamSigmaInAngY(G4double);
|
||||
void UserDefAngTheta(G4ThreeVector);
|
||||
void UserDefAngPhi(G4ThreeVector);
|
||||
void SetFocusPoint(G4ThreeVector);
|
||||
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection);
|
||||
void SetUseUserAngAxis(G4bool);
|
||||
void SetUserWRTSurface(G4bool);
|
||||
//
|
||||
void SetPosDistribution(G4SPSPosDistribution* a);
|
||||
void SetBiasRndm(G4SPSRandomGenerator* a);
|
||||
// method to re-set the histograms
|
||||
void ReSetHist(G4String);
|
||||
//
|
||||
// Set the verbosity level.
|
||||
void SetVerbosity(G4int a);
|
||||
// some get methods
|
||||
|
||||
public:
|
||||
|
||||
G4SPSAngDistribution ();
|
||||
// Constructor: Initializes variables
|
||||
~G4SPSAngDistribution ();
|
||||
// Destructor
|
||||
|
||||
// Angular Distribution Methods
|
||||
|
||||
void SetAngDistType(const G4String&);
|
||||
// Used to set the type of angular distribution wanted. Arguments
|
||||
// are iso, cos, beam and user for isotropic, cosine-law, beam and
|
||||
// user-defined respectively.
|
||||
|
||||
void DefineAngRefAxes(const G4String&, const G4ThreeVector&);
|
||||
// Used in a similar way as SetPosRot() to define vectors, one x'
|
||||
// and one in the plane x'y', to create a rotated set of axes for
|
||||
// the angular distribution.
|
||||
|
||||
void SetMinTheta(G4double);
|
||||
// Sets the minimum value for the angle theta.
|
||||
|
||||
void SetMinPhi(G4double);
|
||||
// Sets the minimum value for phi.
|
||||
|
||||
void SetMaxTheta(G4double);
|
||||
// Sets the maximum value for theta.
|
||||
|
||||
void SetMaxPhi(G4double);
|
||||
// Sets the maximum value for phi.
|
||||
|
||||
void SetBeamSigmaInAngR(G4double);
|
||||
// Sets the sigma for 1D beam.
|
||||
|
||||
void SetBeamSigmaInAngX(G4double);
|
||||
// Sets the first sigma for 2D beam.
|
||||
|
||||
void SetBeamSigmaInAngY(G4double);
|
||||
// Sets the second sigma for 2D beam.
|
||||
|
||||
void UserDefAngTheta(const G4ThreeVector&);
|
||||
// This method allows the user to define a histogram in Theta.
|
||||
|
||||
void UserDefAngPhi(const G4ThreeVector&);
|
||||
// This method allows the user to define a histogram in phi.
|
||||
|
||||
void SetFocusPoint(const G4ThreeVector&);
|
||||
void SetParticleMomentumDirection(const G4ParticleMomentum& aMomDirection);
|
||||
void SetUseUserAngAxis(G4bool);
|
||||
void SetUserWRTSurface(G4bool);
|
||||
// Allows user to have user-defined spectra either with respect to the
|
||||
// coordinate system (default) or with respect to the surface normal.
|
||||
|
||||
void SetPosDistribution(G4SPSPosDistribution* a);
|
||||
// Sets the required position generator, required for determining
|
||||
// the cosine-law distribution.
|
||||
|
||||
void SetBiasRndm(G4SPSRandomGenerator* a);
|
||||
// Sets the biased random number generator.
|
||||
|
||||
G4ParticleMomentum GenerateOne();
|
||||
// Generates one random direction.
|
||||
|
||||
void ReSetHist(const G4String&);
|
||||
// Re-sets the histogram for user defined distribution..
|
||||
|
||||
void SetVerbosity(G4int a);
|
||||
// Sets the verbosity level.
|
||||
|
||||
// Some accessors
|
||||
|
||||
G4String GetDistType();
|
||||
G4double GetMinTheta();
|
||||
G4double GetMaxTheta();
|
||||
G4double GetMinPhi();
|
||||
G4double GetMaxPhi();
|
||||
G4ThreeVector GetDirection();
|
||||
//
|
||||
G4ParticleMomentum GenerateOne();
|
||||
|
||||
private:
|
||||
|
||||
private:
|
||||
|
||||
// These methods generate the momentum vectors for the particles.
|
||||
void GenerateFocusedFlux(G4ParticleMomentum& outputMom);
|
||||
void GenerateIsotropicFlux(G4ParticleMomentum& outputMom);
|
||||
void GenerateCosineLawFlux(G4ParticleMomentum& outputMom);
|
||||
void GenerateBeamFlux(G4ParticleMomentum& outputMom);
|
||||
void GeneratePlanarFlux(G4ParticleMomentum& outputMom);
|
||||
void GenerateUserDefFlux(G4ParticleMomentum& outputMom);
|
||||
G4double GenerateUserDefTheta();
|
||||
G4double GenerateUserDefPhi();
|
||||
|
||||
private:
|
||||
void GenerateFocusedFlux(G4ParticleMomentum& outputMom);
|
||||
// This method generates momentum vectors for particles pointing to
|
||||
// an user specified focusing point.
|
||||
|
||||
// Angular distribution variables.
|
||||
G4String AngDistType; // String to hold Ang dist type iso, cos, user
|
||||
G4ThreeVector AngRef1, AngRef2, AngRef3; // Reference axes for ang dist
|
||||
G4double MinTheta, MaxTheta, MinPhi, MaxPhi; // min/max theta/phi
|
||||
G4double DR,DX,DY ; // Standard deviations for beam divergence
|
||||
G4double Theta, Phi; // Store these for use with DEBUG
|
||||
G4ThreeVector FocusPoint ; // the focusing point in mother coordinates
|
||||
G4bool IPDFThetaExist, IPDFPhiExist; // tell whether IPDF histos exist
|
||||
G4PhysicsOrderedFreeVector UDefThetaH; // Theta histo data
|
||||
G4PhysicsOrderedFreeVector IPDFThetaH; //Cumulative Theta histogram.
|
||||
G4PhysicsOrderedFreeVector UDefPhiH; // Phi histo bins
|
||||
G4PhysicsOrderedFreeVector IPDFPhiH; // Cumulative phi histogram.
|
||||
G4String UserDistType; //String to hold user distributions
|
||||
G4bool UserWRTSurface; // G4bool to tell whether user wants distribution wrt
|
||||
// surface normals or co-ordinate system
|
||||
G4bool UserAngRef; // Set to true when user defines a new coordinates
|
||||
//
|
||||
G4ParticleMomentum particle_momentum_direction;
|
||||
//
|
||||
G4SPSPosDistribution* posDist; // need it here for the cosine-law distri
|
||||
G4SPSRandomGenerator* angRndm; // biased random generator
|
||||
void GenerateIsotropicFlux(G4ParticleMomentum& outputMom);
|
||||
// This method generates momentum vectors for particles according
|
||||
// to an isotropic distribution.
|
||||
|
||||
// Verbosity
|
||||
G4int verbosityLevel;
|
||||
//
|
||||
G4PhysicsOrderedFreeVector ZeroPhysVector ; // for re-set only
|
||||
//
|
||||
G4Mutex mutex; //protect access to shared resources
|
||||
void GenerateCosineLawFlux(G4ParticleMomentum& outputMom);
|
||||
// This method generates momentum vectors for particles according
|
||||
// to a cosine-law distribution.
|
||||
|
||||
void GenerateBeamFlux(G4ParticleMomentum& outputMom);
|
||||
void GeneratePlanarFlux(G4ParticleMomentum& outputMom);
|
||||
|
||||
void GenerateUserDefFlux(G4ParticleMomentum& outputMom);
|
||||
// Controls generation of momentum vectors according to user-defined
|
||||
// distributions.
|
||||
|
||||
G4double GenerateUserDefTheta();
|
||||
// Generates the theta angle according to a user-defined distribution.
|
||||
|
||||
G4double GenerateUserDefPhi();
|
||||
// Generates phi according to a user-defined distribution.
|
||||
|
||||
private:
|
||||
|
||||
// Angular distribution variables.
|
||||
|
||||
G4String AngDistType; // String to hold Ang dist type iso, cos, user
|
||||
G4ThreeVector AngRef1, AngRef2, AngRef3; // Reference axes for ang dist
|
||||
G4double MinTheta, MaxTheta, MinPhi, MaxPhi; // min/max theta/phi
|
||||
G4double DR,DX,DY ; // Standard deviations for beam divergence
|
||||
G4double Theta, Phi; // Store these for use with DEBUG
|
||||
G4ThreeVector FocusPoint ; // the focusing point in mother coordinates
|
||||
G4bool IPDFThetaExist, IPDFPhiExist; // tell whether IPDF histos exist
|
||||
G4PhysicsOrderedFreeVector UDefThetaH; // Theta histo data
|
||||
G4PhysicsOrderedFreeVector IPDFThetaH; //Cumulative Theta histogram.
|
||||
G4PhysicsOrderedFreeVector UDefPhiH; // Phi histo bins
|
||||
G4PhysicsOrderedFreeVector IPDFPhiH; // Cumulative phi histogram.
|
||||
G4String UserDistType; //String to hold user distributions
|
||||
G4bool UserWRTSurface; // G4bool to tell whether user wants distribution wrt
|
||||
// surface normals or co-ordinate system
|
||||
G4bool UserAngRef; // Set to true when user defines a new coordinates
|
||||
|
||||
G4ParticleMomentum particle_momentum_direction;
|
||||
|
||||
G4SPSPosDistribution* posDist = nullptr; // need for the cosine-law distrib.
|
||||
G4SPSRandomGenerator* angRndm = nullptr; // biased random generator
|
||||
|
||||
G4int verbosityLevel; // Verbosity
|
||||
|
||||
G4PhysicsOrderedFreeVector ZeroPhysVector; // for re-set only
|
||||
|
||||
G4Mutex mutex; // Protect access to shared resources
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,133 +23,39 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MODULE: G4SPSEneDistribution.hh
|
||||
//
|
||||
// Version: 1.0
|
||||
// Date: 5/02/04
|
||||
// Author: Fan Lei
|
||||
// Organisation: QinetiQ ltd.
|
||||
// Customer: ESA/ESTEC
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CHANGE HISTORY
|
||||
// --------------
|
||||
//
|
||||
//
|
||||
// Version 1.0, 05/02/2004, Fan Lei, Created.
|
||||
// Based on the G4GeneralParticleSource class in Geant4 v6.0
|
||||
//
|
||||
//
|
||||
// 26/03/2014, Andrew Green.
|
||||
// Modification to used STL vectors instead of C-style arrays. This should save some space,
|
||||
// particularly when the blackbody function is not used. Also moved to dynamically allocated
|
||||
// memory in the LinearInterpolation, ExpInterpolation and LogInterpolation functions. Again,
|
||||
// this will save space if these functions are unused.
|
||||
//
|
||||
// 06/06/2014 A Dotti
|
||||
// For thread safety: this is a shared object,
|
||||
// mutex has been added to control access to shared resources (data members).
|
||||
// in Getters and Setters, mutex is NOT used in GenerateOne because it is
|
||||
// assumed that properties are not changed during event loop.
|
||||
//
|
||||
// 24/11/2017 Fan Lei
|
||||
// Added cutoff power-law distribution option. Implementation is similar to that of the BlackBody one.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// G4SPSEneDistribution
|
||||
//
|
||||
// Class Description:
|
||||
//
|
||||
// To generate the energy of a primary vertex according to the defined distribution
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MEMBER FUNCTIONS
|
||||
// ----------------
|
||||
//
|
||||
// G4SPSEneDistribution ()
|
||||
// Constructor: Initializes variables
|
||||
//
|
||||
// ~G4SPSEneDistribution ()
|
||||
// Destructor:
|
||||
//
|
||||
// void SetEnergyDisType(G4String)
|
||||
// Allows the user to choose the energy distribution type. The arguments
|
||||
// are Mono (mono-energetic), Lin (linear), Pow (power-law), Exp
|
||||
// (exponential), Gauss (gaussian), Brem (bremsstrahlung), BBody (black-body), Cdg
|
||||
// (cosmic diffuse gamma-ray), User (user-defined), Arb (arbitrary
|
||||
// point-wise), Epn (energy per nucleon).
|
||||
//
|
||||
// void SetEmin(G4double)
|
||||
// Sets the minimum energy.
|
||||
//
|
||||
// void SetEmax(G4double)
|
||||
// Sets the maximum energy.
|
||||
//
|
||||
// void SetMonoEnergy(G4double)
|
||||
// Sets energy for mono-energetic distribution.
|
||||
//
|
||||
// void SetAlpha(G4double)
|
||||
// Sets alpha for a power-law distribution.
|
||||
//
|
||||
// void SetTemp(G4double)
|
||||
// Sets Temperature for a Brem or BBody distributions.
|
||||
//
|
||||
// void SetEzero(G4double)
|
||||
// Sets Ezero for an exponential distribution.
|
||||
//
|
||||
// void SetGradient(G4double)
|
||||
// Sets gradient for a linear distribution.
|
||||
//
|
||||
// void SetInterCept(G4double)
|
||||
// Sets intercept for a linear distribution.
|
||||
//
|
||||
// void UserEnergyHisto(G4ThreeVector)
|
||||
// Allows user to defined a histogram for the energy distribution.
|
||||
//
|
||||
// void ArbEnergyHisto(G4ThreeVector)
|
||||
// Allows the user to define an Arbitrary set of points for the
|
||||
// energy distribution.
|
||||
//
|
||||
// void EpnEnergyHisto(G4ThreeVector)
|
||||
// Allows the user to define an Energy per nucleon histogram.
|
||||
//
|
||||
// void Calculate()
|
||||
// Controls the calculation of Integral PDF for the Cdg and BBody
|
||||
// distributions.
|
||||
//
|
||||
// void InputEnergySpectra(G4bool)
|
||||
// Allows the user to choose between momentum and energy histograms
|
||||
// for user-defined histograms and arbitrary point-wise spectr.
|
||||
// The default is true (energy).
|
||||
//
|
||||
// void InputDifferentialSpectra(G4bool)
|
||||
// Allows the user to choose between integral and differential
|
||||
// distributions when using the arbitrary point-wise option.
|
||||
//
|
||||
// void ArbInterpolate(G4String)
|
||||
// ArbInterpolate allows the user to specify the type of function to
|
||||
// interpolate the Arbitrary points spectrum with.
|
||||
//
|
||||
// void SetBiasRndm (G4SPSRandomGenerator* a)
|
||||
// Sets the biased random number generator
|
||||
//
|
||||
// G4double GenerateOne(G4ParticleDefinition*);
|
||||
// Generate one random energy for the specified particle
|
||||
//
|
||||
// void ReSetHist(G4String);
|
||||
// Re-sets the histogram for user defined distribution
|
||||
//
|
||||
// void SetVerbosity(G4int)
|
||||
// Sets the verbosity level.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// To generate the energy of a primary vertex according to the
|
||||
// defined distribution. 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 the setters during the event loop
|
||||
|
||||
#ifndef G4SPSEneDistribution_h
|
||||
#define G4SPSEneDistribution_h 1
|
||||
// Author: Fan Lei, QinetiQ ltd.
|
||||
// Customer: ESA/ESTEC
|
||||
// History:
|
||||
// - 05/02/2004, Fan Lei - Created.
|
||||
// Based on the G4GeneralParticleSource class.
|
||||
// - 26/03/2014, Andrew Green.
|
||||
// Modification to use STL vectors instead of C-style arrays.
|
||||
// Also moved to dynamically allocated memory in the LinearInterpolation(),
|
||||
// ExpInterpolation() and LogInterpolation() functions.
|
||||
// - 06/06/2014, Andrea Dotti.
|
||||
// For thread safety: this is a shared object.
|
||||
// Added mutex to control access to shared resources (data members).
|
||||
// in Getters and Setters, mutex is NOT used in GenerateOne() because it
|
||||
// is assumed that properties are not changed during event loop.
|
||||
// - 24/11/2017, Fan Lei
|
||||
// Added cutoff power-law distribution option. Implementation is similar
|
||||
// to that of the BlackBody one.
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4SPSEneDistribution_hh
|
||||
#define G4SPSEneDistribution_hh 1
|
||||
|
||||
#include "G4PhysicsOrderedFreeVector.hh"
|
||||
#include "G4ParticleMomentum.hh"
|
||||
@@ -161,187 +67,252 @@
|
||||
|
||||
#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:
|
||||
|
||||
class G4SPSEneDistribution {
|
||||
public:
|
||||
G4SPSEneDistribution();//
|
||||
~G4SPSEneDistribution();//
|
||||
G4SPSEneDistribution();
|
||||
// Constructor: initializes variables
|
||||
~G4SPSEneDistribution();
|
||||
// Destructor
|
||||
|
||||
void SetEnergyDisType(G4String);//
|
||||
G4String GetEnergyDisType();//
|
||||
void SetEmin(G4double);//
|
||||
G4double GetEmin();//
|
||||
G4double GetArbEmin();//
|
||||
void SetEmax(G4double);//
|
||||
G4double GetEmax();//
|
||||
G4double GetArbEmax();//
|
||||
void SetMonoEnergy(G4double);//
|
||||
void SetAlpha(G4double);//
|
||||
void SetBiasAlpha(G4double);//
|
||||
void SetTemp(G4double);//
|
||||
void SetBeamSigmaInE(G4double);////
|
||||
void SetEzero(G4double);//
|
||||
void SetGradient(G4double);//
|
||||
void SetInterCept(G4double);//
|
||||
void UserEnergyHisto(G4ThreeVector);//
|
||||
void ArbEnergyHisto(G4ThreeVector);//
|
||||
void ArbEnergyHistoFile(G4String);//
|
||||
void EpnEnergyHisto(G4ThreeVector);//
|
||||
void SetEnergyDisType(const G4String&);
|
||||
// Allows the user to choose the energy distribution type.
|
||||
// The arguments are: Mono (mono-energetic), Lin (linear),
|
||||
// Pow (power-law), Exp (exponential), Gauss (gaussian),
|
||||
// Brem (bremsstrahlung), BBody (black-body),
|
||||
// Cdg (cosmic diffuse gamma-ray), User (user-defined),
|
||||
// Arb (arbitrary point-wise), Epn (energy per nucleon)
|
||||
|
||||
void InputEnergySpectra(G4bool);//
|
||||
void InputDifferentialSpectra(G4bool);//
|
||||
void ArbInterpolate(G4String);//
|
||||
G4String GetIntType();//
|
||||
const G4String& GetEnergyDisType();
|
||||
|
||||
void SetEmin(G4double);
|
||||
// Sets the minimum energy
|
||||
|
||||
G4double GetEmin() const;
|
||||
G4double GetArbEmin();
|
||||
|
||||
void SetEmax(G4double);
|
||||
// Sets the maximum energy
|
||||
|
||||
G4double GetEmax() const;
|
||||
G4double GetArbEmax();
|
||||
|
||||
void SetMonoEnergy(G4double);
|
||||
// Sets energy for mono-energetic distribution
|
||||
|
||||
void SetAlpha(G4double);
|
||||
// Sets alpha for a power-law distribution
|
||||
|
||||
void SetBiasAlpha(G4double);
|
||||
|
||||
void SetTemp(G4double);
|
||||
// Sets Temperature for a Brem or BBody distributions
|
||||
|
||||
void SetBeamSigmaInE(G4double);
|
||||
|
||||
void SetEzero(G4double);
|
||||
// Sets Ezero for an exponential distribution
|
||||
|
||||
void SetGradient(G4double);
|
||||
// Sets gradient for a linear distribution
|
||||
|
||||
void SetInterCept(G4double);
|
||||
// Sets intercept for a linear distribution
|
||||
|
||||
void UserEnergyHisto(const G4ThreeVector&);
|
||||
// Allows user to defined a histogram for the energy distribution
|
||||
|
||||
void ArbEnergyHisto(const G4ThreeVector&);
|
||||
// Allows the user to define an Arbitrary set of points for the
|
||||
// energy distribution
|
||||
|
||||
void ArbEnergyHistoFile(const G4String&);
|
||||
|
||||
void EpnEnergyHisto(const G4ThreeVector&);
|
||||
// Allows the user to define an Energy per nucleon histogram
|
||||
|
||||
void InputEnergySpectra(G4bool);
|
||||
// Allows the user to choose between momentum and energy histograms
|
||||
// for user-defined histograms and arbitrary point-wise spectra.
|
||||
// The default is true (energy)
|
||||
|
||||
void InputDifferentialSpectra(G4bool);
|
||||
// Allows the user to choose between integral and differential
|
||||
// distributions when using the arbitrary point-wise option
|
||||
|
||||
void ArbInterpolate(const G4String&);
|
||||
// Allows the user to specify the type of function to
|
||||
// interpolate the Arbitrary points spectrum with
|
||||
|
||||
const G4String& GetIntType();
|
||||
|
||||
void Calculate();//
|
||||
void Calculate();
|
||||
// Controls the calculation of Integral PDF for the Cdg and BBody
|
||||
// distributions
|
||||
|
||||
void SetBiasRndm(G4SPSRandomGenerator* a);//
|
||||
// method to re-set the histograms
|
||||
void ReSetHist(G4String);//
|
||||
// Set the verbosity level.
|
||||
void SetVerbosity(G4int a);//
|
||||
void SetBiasRndm(G4SPSRandomGenerator* a);
|
||||
// Sets the biased random number generator
|
||||
|
||||
//x
|
||||
G4double GetWeight();
|
||||
void ReSetHist(const G4String&);
|
||||
// Resets the histogram for user defined distribution
|
||||
|
||||
G4double GetMonoEnergy(); //Mono-energteic energy
|
||||
G4double GetSE();// Standard deviation for Gaussion distrbution in energy
|
||||
G4double Getalpha(); // alpha (pow)
|
||||
G4double GetEzero(); // E0 (exp)
|
||||
G4double GetTemp(); // Temp (bbody,brem)
|
||||
G4double Getgrad(); // gradient and intercept for linear spectra
|
||||
G4double Getcept(); //
|
||||
void SetVerbosity(G4int a);
|
||||
// Sets the verbosity level
|
||||
|
||||
G4PhysicsOrderedFreeVector GetUserDefinedEnergyHisto(); //
|
||||
G4PhysicsOrderedFreeVector GetArbEnergyHisto(); //
|
||||
G4double GetWeight() const;
|
||||
|
||||
G4double GenerateOne(G4ParticleDefinition*);
|
||||
G4double GetProbability (G4double);
|
||||
G4double GetMonoEnergy();
|
||||
// Mono-energetic energy
|
||||
|
||||
G4double GetSE();
|
||||
// Standard deviation for Gaussian distribution in energy
|
||||
|
||||
private:
|
||||
void LinearInterpolation();//
|
||||
void LogInterpolation();//
|
||||
void ExpInterpolation();//
|
||||
void SplineInterpolation();//
|
||||
void CalculateCdgSpectrum();//
|
||||
void CalculateBbodySpectrum();//
|
||||
void CalculateCPowSpectrum();//
|
||||
G4double Getalpha() const;
|
||||
// Alpha (pow)
|
||||
|
||||
// The following methods generate energies according to the spectral
|
||||
// parameters defined above.
|
||||
void GenerateMonoEnergetic();//G4double& outputEne);//
|
||||
void GenerateBiasPowEnergies();//G4double& outputEne,G4double& outputWeight);//
|
||||
void GenerateGaussEnergies();//
|
||||
void GenerateBremEnergies();//
|
||||
void GenerateBbodyEnergies();//
|
||||
void GenerateCdgEnergies();//
|
||||
void GenUserHistEnergies();//
|
||||
void GenEpnHistEnergies();//
|
||||
void GenArbPointEnergies();//<<<<<<<<<<< DOES NOT WORK, REQUIRES UPDATE OF DATA MEMBERS.
|
||||
void GenerateExpEnergies(G4bool);//
|
||||
void GenerateLinearEnergies(G4bool);//
|
||||
void GeneratePowEnergies(G4bool);//
|
||||
void GenerateCPowEnergies();//
|
||||
G4double GetEzero() const;
|
||||
// E0 (exp)
|
||||
|
||||
// converts energy per nucleon to energy.
|
||||
void ConvertEPNToEnergy();
|
||||
G4double GetTemp();
|
||||
// Temp (bbody,brem)
|
||||
|
||||
G4double Getgrad() const;
|
||||
// Gradient and intercept for linear spectra
|
||||
|
||||
G4double Getcept() const;
|
||||
|
||||
G4PhysicsOrderedFreeVector GetUserDefinedEnergyHisto();
|
||||
|
||||
G4PhysicsOrderedFreeVector GetArbEnergyHisto();
|
||||
|
||||
G4double GenerateOne(G4ParticleDefinition*);
|
||||
// Generate one random energy for the specified particle
|
||||
|
||||
G4double GetProbability (G4double);
|
||||
|
||||
G4double GetArbEneWeight(G4double);
|
||||
|
||||
inline void ApplyEnergyWeight(G4bool val) { applyEvergyWeight = val; }
|
||||
inline G4bool IfApplyEnergyWeight() const { return applyEvergyWeight; }
|
||||
|
||||
private:
|
||||
|
||||
void LinearInterpolation();
|
||||
void LogInterpolation();
|
||||
void ExpInterpolation();
|
||||
void SplineInterpolation();
|
||||
void CalculateCdgSpectrum();
|
||||
void CalculateBbodySpectrum();
|
||||
void CalculateCPowSpectrum();
|
||||
|
||||
// The following methods generate energies according
|
||||
// to the spectral parameters defined above
|
||||
|
||||
void GenerateMonoEnergetic();
|
||||
void GenerateBiasPowEnergies();
|
||||
void GenerateGaussEnergies();
|
||||
void GenerateBremEnergies();
|
||||
void GenerateBbodyEnergies();
|
||||
void GenerateCdgEnergies();
|
||||
void GenUserHistEnergies();
|
||||
void GenEpnHistEnergies();
|
||||
void GenArbPointEnergies(); // NOTE: REQUIRES UPDATE OF DATA MEMBERS
|
||||
void GenerateExpEnergies(G4bool);
|
||||
void GenerateLinearEnergies(G4bool);
|
||||
void GeneratePowEnergies(G4bool);
|
||||
void GenerateCPowEnergies();
|
||||
|
||||
void ConvertEPNToEnergy();
|
||||
// Converts energy per nucleon to energy
|
||||
|
||||
void BBInitHists();//
|
||||
void CPInitHists();//
|
||||
void BBInitHists();
|
||||
void CPInitHists();
|
||||
|
||||
private:
|
||||
private: // Non invariant data members become G4Cache
|
||||
|
||||
G4String EnergyDisType; // energy dis type Variable - Mono,Lin,Exp,etc
|
||||
G4double weight; // particle weight //// NOT INVARIANT
|
||||
G4double MonoEnergy; //Mono-energteic energy
|
||||
G4double SE; // Standard deviation for Gaussion distrbution in energy
|
||||
//Non invariant data members become G4Cache
|
||||
G4double Emin, Emax; // emin and emax ////// NOT INVARIANT
|
||||
G4double alpha, Ezero;// alpha (pow), E0 (exp) ////// NOT INVARIANT
|
||||
G4String EnergyDisType; // energy dis type Variable - Mono,Lin,Exp,etc
|
||||
G4double weight; // particle weight //// NOT INVARIANT
|
||||
G4double MonoEnergy; //Mono-energteic energy
|
||||
G4double SE; // Standard deviation for Gaussian distribution in energy
|
||||
|
||||
G4double Emin, Emax; // emin and emax //// NOT INVARIANT
|
||||
G4double alpha, Ezero;// alpha (pow), E0 (exp) //// NOT INVARIANT
|
||||
G4double Temp; // Temp (bbody,brem)
|
||||
G4double biasalpha; // biased power index
|
||||
G4double grad, cept; // gradient and intercept for linear spectra ////// NOT INVARIANT
|
||||
G4double biasalpha; // biased power index
|
||||
G4double grad, cept; // gradient and intercept for linear spectra //// NOT INVARIANT
|
||||
G4double prob_norm; // normalisation factor use in calculate the probability
|
||||
G4bool Biased; // true - biased to power-law
|
||||
G4bool EnergySpec; // true - energy spectra, false - momentum spectra
|
||||
G4bool DiffSpec; // true - differential spec, false integral spec
|
||||
//G4bool ApplyRig; // false no rigidity cutoff, true then apply one
|
||||
//G4double ERig; // energy of rigidity cutoff
|
||||
G4PhysicsOrderedFreeVector UDefEnergyH; // energy hist data
|
||||
G4PhysicsOrderedFreeVector IPDFEnergyH;
|
||||
G4bool IPDFEnergyExist, IPDFArbExist, Epnflag;
|
||||
G4PhysicsOrderedFreeVector ArbEnergyH; // Arb x,y histogram
|
||||
G4PhysicsOrderedFreeVector IPDFArbEnergyH; // IPDF for Arb
|
||||
G4PhysicsOrderedFreeVector EpnEnergyH;
|
||||
G4double CDGhist[3]; // cumulative histo for cdg
|
||||
G4bool Biased = false; // biased to power-law
|
||||
G4bool EnergySpec = true; // energy spectra, false - momentum spectra
|
||||
G4bool DiffSpec = true; // differential spec, false integral spec
|
||||
|
||||
G4PhysicsOrderedFreeVector UDefEnergyH; // energy hist data
|
||||
G4PhysicsOrderedFreeVector IPDFEnergyH;
|
||||
G4bool IPDFEnergyExist = false, IPDFArbExist = false, Epnflag = false;
|
||||
G4PhysicsOrderedFreeVector ArbEnergyH; // Arb x,y histogram
|
||||
G4PhysicsOrderedFreeVector IPDFArbEnergyH; // IPDF for Arb
|
||||
G4PhysicsOrderedFreeVector EpnEnergyH;
|
||||
G4double CDGhist[3]; // cumulative histo for cdg
|
||||
|
||||
//AG: Begin edit to use STL vectors.
|
||||
// G4double BBHist[10001], Bbody_x[10001];
|
||||
std::vector<G4double>* BBHist;
|
||||
std::vector<G4double>* Bbody_x;
|
||||
G4bool BBhistInit;
|
||||
G4bool BBhistCalcd;
|
||||
// For cutoff power-law
|
||||
std::vector<G4double>* CPHist;
|
||||
std::vector<G4double>* CP_x;
|
||||
G4bool CPhistInit;
|
||||
G4bool CPhistCalcd;
|
||||
|
||||
|
||||
//AG: Edit here to use dynamic memory, will save space inless these functions are used.
|
||||
G4String IntType; // Interpolation type
|
||||
// G4double Arb_grad[1024], Arb_cept[1024]; // grad and cept for 1024 segments AG: Switched to DMA
|
||||
G4double* Arb_grad;
|
||||
G4double* Arb_cept;
|
||||
G4bool Arb_grad_cept_flag;
|
||||
// G4double Arb_alpha[1024], Arb_Const[1024]; // alpha and constants AG: Switched to DMA
|
||||
G4double* Arb_alpha;
|
||||
G4double* Arb_Const;
|
||||
G4bool Arb_alpha_Const_flag;
|
||||
// G4double Arb_ezero[1024]; // ezero AG: Switched to DMA
|
||||
G4double* Arb_ezero;
|
||||
G4bool Arb_ezero_flag;
|
||||
G4double ArbEmin, ArbEmax; // Emin and Emax for the whole arb distribution used primarily for debug.
|
||||
std::vector<G4double>* BBHist = nullptr;
|
||||
std::vector<G4double>* Bbody_x = nullptr;
|
||||
G4bool BBhistInit = false;
|
||||
G4bool BBhistCalcd = false;
|
||||
|
||||
G4double particle_energy;
|
||||
// For cutoff power-law
|
||||
//
|
||||
std::vector<G4double>* CPHist = nullptr;
|
||||
std::vector<G4double>* CP_x = nullptr;
|
||||
G4bool CPhistInit = false;
|
||||
G4bool CPhistCalcd = false;
|
||||
|
||||
G4SPSRandomGenerator* eneRndm;
|
||||
G4String IntType; // Interpolation type
|
||||
G4double* Arb_grad = nullptr;
|
||||
G4double* Arb_cept = nullptr;
|
||||
G4bool Arb_grad_cept_flag = false;
|
||||
G4double* Arb_alpha = nullptr;
|
||||
G4double* Arb_Const = nullptr;
|
||||
G4bool Arb_alpha_Const_flag = false;
|
||||
G4double* Arb_ezero = nullptr;
|
||||
G4bool Arb_ezero_flag = false;
|
||||
|
||||
// Verbosity
|
||||
G4int verbosityLevel;
|
||||
G4bool applyEvergyWeight = false;
|
||||
|
||||
G4PhysicsOrderedFreeVector ZeroPhysVector; // for re-set only
|
||||
G4double ArbEmin, ArbEmax;
|
||||
// Emin and Emax for the whole arb distribution used primarily for debug.
|
||||
|
||||
std::vector<G4DataInterpolation*> SplineInt;//[1024]; // holds Spline stuff required for sampling
|
||||
G4DataInterpolation *Splinetemp; // holds a temp Spline used for calculating area
|
||||
G4double particle_energy;
|
||||
|
||||
G4SPSRandomGenerator* eneRndm = nullptr;
|
||||
|
||||
G4int verbosityLevel;
|
||||
|
||||
G4PhysicsOrderedFreeVector ZeroPhysVector; // for re-set only
|
||||
|
||||
std::vector<G4DataInterpolation*> SplineInt;
|
||||
// Holds Spline stuff required for sampling
|
||||
G4DataInterpolation* Splinetemp = nullptr;
|
||||
// Holds a temp Spline used for calculating area
|
||||
|
||||
G4Mutex mutex; // protect access to shared resources
|
||||
//Thread local data (non-invariant during event loop).
|
||||
//These are copied from master one at the beginning of generation
|
||||
//of each event
|
||||
struct threadLocal_t {
|
||||
G4double Emin;
|
||||
G4double Emax;
|
||||
G4double alpha;
|
||||
G4double Ezero;
|
||||
G4double grad;
|
||||
G4double cept;
|
||||
G4ParticleDefinition* particle_definition;
|
||||
G4double weight;
|
||||
G4double particle_energy;
|
||||
|
||||
// Thread local data (non-invariant during event loop).
|
||||
// These are copied from master one at the beginning of
|
||||
// generation of each event
|
||||
//
|
||||
struct threadLocal_t
|
||||
{
|
||||
G4double Emin;
|
||||
G4double Emax;
|
||||
G4double alpha;
|
||||
G4double Ezero;
|
||||
G4double grad;
|
||||
G4double cept;
|
||||
G4ParticleDefinition* particle_definition;
|
||||
G4double weight;
|
||||
G4double particle_energy;
|
||||
};
|
||||
G4Cache<threadLocal_t> threadLocalData;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,273 +23,200 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MODULE: G4SPSPosDistribution.hh
|
||||
//
|
||||
// Version: 1.0
|
||||
// Date: 5/02/04
|
||||
// Author: Fan Lei
|
||||
// Organisation: QinetiQ ltd.
|
||||
// Customer: ESA/ESTEC
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CHANGE HISTORY
|
||||
// --------------
|
||||
//
|
||||
// 29/05/2019 M Asai
|
||||
// Added confinement getters.
|
||||
//
|
||||
// 30/04/2017 J Allison
|
||||
// Added GetRotx,y,z access functions.
|
||||
//
|
||||
// 06/06/2014 A Dotti
|
||||
// For thread safety: this is a shared object,
|
||||
// mutex has been added to control access to shared resources (data members).
|
||||
// in Getters and Setters, mutex is NOT used in GenerateOne because it is
|
||||
// assumed that properties are not changed during event loop.
|
||||
//
|
||||
// Version 1.0, 05/02/2004, Fan Lei, Created.
|
||||
// Based on the G4GeneralParticleSource class in Geant4 v6.0
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// G4SPSPosDistribution
|
||||
//
|
||||
// Class Description:
|
||||
//
|
||||
// To generate the position of a primary vertex according to the defined distribution
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MEMBER FUNCTIONS
|
||||
// ----------------
|
||||
//
|
||||
// G4SPSPosDistribution ()
|
||||
// Constructor: Initializes variables and instantiates the Navigator class
|
||||
//
|
||||
// ~G4SPSPosDistribution ()
|
||||
// Destructor:
|
||||
//
|
||||
// void SetPosDisType(G4String)
|
||||
// Allows user to choose Point, Plane, Surface or Volume source
|
||||
// position distributions.
|
||||
//
|
||||
// void SetPosDisShape(G4String)
|
||||
// Allows the user to choose the particular shape they wish for the
|
||||
// position distribution. Choices are Square, Circle, Ellipse, Rectangle,
|
||||
// Sphere, Ellipsoid, Cylinder, Parallelepiped.
|
||||
//
|
||||
// void SetCentreCoords(G4ThreeVector)
|
||||
// Sets the co-ordinates of the centre of the position distribution.
|
||||
//
|
||||
// void SetPosRot1(G4ThreeVector)
|
||||
// Used to specify the co-ordinate system for the position distribution
|
||||
// along with SetPosRot2. SetPosRot1 sets the vector x' and need not be
|
||||
// a unit vector.
|
||||
//
|
||||
// void SetPosRot2(G4ThreeVector)
|
||||
// Used in connection with SetPosRot1. This sets a vector in the plane
|
||||
// x'y'. By a series of cross products x', y', z' are generated. Again
|
||||
// need not be a unit vector.
|
||||
//
|
||||
// void SetHalfX(G4double)
|
||||
// Sets the half length in x.
|
||||
//
|
||||
// void SetHalfY(G4double)
|
||||
// Sets the half length in y.
|
||||
//
|
||||
// void SetHalfZ(G4double)
|
||||
// Sets the half length in z.
|
||||
//
|
||||
// void SetRadius(G4double)
|
||||
// Sets the radius where appropriate for source distribution shapes.
|
||||
//
|
||||
// void SetRadius0(G4double)
|
||||
// Sets the inner radius where appropriate for source distribution shapes.
|
||||
//
|
||||
// void SetBeamSigmaInR(G4double);
|
||||
// Sets the sigma for 1D beam
|
||||
//
|
||||
// void SetBeamSigmaInX(G4double);
|
||||
// Sets the first sigma for 2D beam
|
||||
//
|
||||
// void SetBeamSigmaInY(G4double);
|
||||
// Sets the second sigma for 2D beam
|
||||
//
|
||||
// void SetParAlpha(G4double)
|
||||
// Sets the angle Alpha in the Parallelepiped shapes.
|
||||
//
|
||||
// void SetParTheta(G4double)
|
||||
// Sets the angle Theta in the Parallelepiped shapes.
|
||||
//
|
||||
// void SetParPhi(G4double)
|
||||
// Sets the angle Phi in the Parallelepiped shapes.
|
||||
//
|
||||
// void ConfineSourceToVolume(G4String)
|
||||
// Used to confine the start positions to a particular volume.
|
||||
//
|
||||
// void SetBiasRndm (G4SPSRandomGenerator* a) { posRndm = a ; };
|
||||
// Sets the biased random number generator
|
||||
//
|
||||
// G4ThreeVector GenerateOne();
|
||||
// Generate one random position
|
||||
//
|
||||
// void SetVerbosity(G4int)
|
||||
// Sets the verbosity level.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
#ifndef G4SPSPosDistribution_h
|
||||
#define G4SPSPosDistribution_h 1
|
||||
// To generate the position of a primary vertex according to
|
||||
// the defined distribution. 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
|
||||
|
||||
// Author: Fan Lei, QinetiQ ltd.
|
||||
// Customer: ESA/ESTEC
|
||||
// History:
|
||||
// - 05/02/2004, Fan Lei, Created.
|
||||
// Based on the G4GeneralParticleSource class.
|
||||
// - 06/06/2014, Andrea Dotti
|
||||
// Added mutex to control access to shared resources (data members).
|
||||
// In Getters and Setters, mutex is NOT used in GenerateOne because
|
||||
// it is assumed that properties are not changed during event loop.
|
||||
// - 13/02/2017, Maxime Chauvin
|
||||
// Added surface and volume shape "EllipticCylinder"
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4SPSPosDistribution_hh
|
||||
#define G4SPSPosDistribution_hh 1
|
||||
|
||||
#include "G4Navigator.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 G4SPSPosDistribution
|
||||
{
|
||||
public:
|
||||
G4SPSPosDistribution ();
|
||||
~G4SPSPosDistribution ();
|
||||
public:
|
||||
|
||||
/**
|
||||
* 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
|
||||
void SetPosDisShape(G4String);
|
||||
// SetPosDisShape - Square, Circle, Annulus, Ellipse, Rectangle, Sphere,
|
||||
// Ellipsoid, Cylinder, Right (parallelepiped).
|
||||
void SetCentreCoords(G4ThreeVector);
|
||||
void SetPosRot1(G4ThreeVector);
|
||||
void SetPosRot2(G4ThreeVector);
|
||||
void SetHalfX(G4double);
|
||||
void SetHalfY(G4double);
|
||||
void SetHalfZ(G4double);
|
||||
void SetRadius(G4double);
|
||||
void SetRadius0(G4double);
|
||||
void SetBeamSigmaInR(G4double);
|
||||
void SetBeamSigmaInX(G4double);
|
||||
void SetBeamSigmaInY(G4double);
|
||||
void SetParAlpha(G4double);
|
||||
void SetParTheta(G4double);
|
||||
void SetParPhi(G4double);
|
||||
void ConfineSourceToVolume(G4String);
|
||||
//
|
||||
void SetBiasRndm (G4SPSRandomGenerator* a);
|
||||
// Set the verbosity level.
|
||||
void SetVerbosity(G4int a);
|
||||
//
|
||||
G4ThreeVector GenerateOne();
|
||||
G4SPSPosDistribution();
|
||||
// Constructor: initializes data and instantiates the Navigator class
|
||||
|
||||
G4String GetPosDisType() const;
|
||||
G4String GetPosDisShape() const;
|
||||
G4ThreeVector GetCentreCoords() const;
|
||||
G4double GetHalfX() const;
|
||||
G4double GetHalfY() const;
|
||||
G4double GetHalfZ() const;
|
||||
G4double GetRadius() const;
|
||||
G4double GetRadius0() const {return Radius0;}
|
||||
G4double GetParAlpha() const {return ParAlpha;}
|
||||
G4double GetParTheta() const {return ParTheta;}
|
||||
G4double GetParPhi() const {return ParPhi;}
|
||||
const G4ThreeVector& GetRotx() const {return Rotx;}
|
||||
const G4ThreeVector& GetRoty() const {return Roty;}
|
||||
const G4ThreeVector& GetRotz() const {return Rotz;}
|
||||
G4bool GetConfined() const { return Confine; }
|
||||
const G4String& GetConfineVolume() const { return VolName; }
|
||||
~G4SPSPosDistribution();
|
||||
// Destructor
|
||||
|
||||
G4ThreeVector GetSideRefVec1() const;
|
||||
G4ThreeVector GetSideRefVec2() const;
|
||||
G4ThreeVector GetSideRefVec3() const;
|
||||
G4String GetSourcePosType() const;
|
||||
G4ThreeVector GetParticlePos() const;
|
||||
// Methods to create source position dist
|
||||
|
||||
private:
|
||||
void SetPosDisType(const G4String&);
|
||||
// Allows user to choose Point, Plane, Surface or Volume source
|
||||
// position distributions
|
||||
|
||||
void GenerateRotationMatrices();
|
||||
// the following routines generate the source position
|
||||
void GeneratePointSource(G4ThreeVector& outoutPos);
|
||||
void GeneratePointsInBeam(G4ThreeVector& outoutPos);
|
||||
void GeneratePointsInPlane(G4ThreeVector& outoutPos);
|
||||
void GeneratePointsOnSurface(G4ThreeVector& outputPos);
|
||||
void GeneratePointsInVolume(G4ThreeVector& outputPos);
|
||||
void SetPosDisShape(const G4String&);
|
||||
// Allows the user to choose the particular shape they wish for the
|
||||
// position distribution. Choices are: Square, Circle, Ellipse,
|
||||
// Rectangle, Sphere, Ellipsoid, Cylinder, Parallelepiped
|
||||
|
||||
G4bool IsSourceConfined(G4ThreeVector& outputPos);
|
||||
void SetCentreCoords(const G4ThreeVector&);
|
||||
// Sets the coordinates of the centre of the position distribution
|
||||
|
||||
private:
|
||||
//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;
|
||||
// Verbosity
|
||||
G4int verbosityLevel;
|
||||
G4Cache<thread_data_t> ThreadData;
|
||||
// biased random generator
|
||||
G4Mutex a_mutex;
|
||||
G4SPSRandomGenerator* PosRndm;
|
||||
void SetPosRot1(const G4ThreeVector&);
|
||||
// Used to specify the coordinate system for the position distribution
|
||||
// along with SetPosRot2. Sets the vector x' and need not be a unit vector
|
||||
|
||||
void SetPosRot2(const G4ThreeVector&);
|
||||
// Used in connection with SetPosRot1. This sets a vector in the plane
|
||||
// x'y'. By a series of cross products x', y', z' are generated. Again
|
||||
// need not be a unit vector
|
||||
|
||||
void SetHalfX(G4double);
|
||||
// Sets the half length in x
|
||||
|
||||
void SetHalfY(G4double);
|
||||
// Sets the half length in y
|
||||
|
||||
void SetHalfZ(G4double);
|
||||
// Sets the half length in z
|
||||
|
||||
void SetRadius(G4double);
|
||||
// Sets the radius where appropriate for source distribution shapes
|
||||
|
||||
void SetRadius0(G4double);
|
||||
// Sets the inner radius where appropriate for source distribution shapes
|
||||
|
||||
void SetBeamSigmaInR(G4double);
|
||||
// Sets the sigma for 1D beam
|
||||
|
||||
void SetBeamSigmaInX(G4double);
|
||||
// Sets the first sigma for 2D beam
|
||||
|
||||
void SetBeamSigmaInY(G4double);
|
||||
// Sets the second sigma for 2D beam
|
||||
|
||||
void SetParAlpha(G4double);
|
||||
// Sets the angle Alpha in the Parallelepiped shapes
|
||||
|
||||
void SetParTheta(G4double);
|
||||
// Sets the angle Theta in the Parallelepiped shapes
|
||||
|
||||
void SetParPhi(G4double);
|
||||
// Sets the angle Phi in the Parallelepiped shapes
|
||||
|
||||
void ConfineSourceToVolume(const G4String&);
|
||||
// Used to confine the start positions to a particular volume
|
||||
|
||||
void SetBiasRndm (G4SPSRandomGenerator* a);
|
||||
// Sets the biased random number generator
|
||||
|
||||
void SetVerbosity(G4int a);
|
||||
// Sets the verbosity level
|
||||
|
||||
G4ThreeVector GenerateOne();
|
||||
// Generate one random position
|
||||
|
||||
const G4String& GetPosDisType() const;
|
||||
const G4String& GetPosDisShape() const;
|
||||
const G4ThreeVector& GetCentreCoords() const;
|
||||
G4double GetHalfX() const;
|
||||
G4double GetHalfY() const;
|
||||
G4double GetHalfZ() const;
|
||||
G4double GetRadius() const;
|
||||
inline G4double GetRadius0() const { return Radius0; }
|
||||
inline G4double GetParAlpha() const { return ParAlpha; }
|
||||
inline G4double GetParTheta() const { return ParTheta; }
|
||||
inline G4double GetParPhi() const { return ParPhi; }
|
||||
inline const G4ThreeVector& GetRotx() const { return Rotx; }
|
||||
inline const G4ThreeVector& GetRoty() const { return Roty; }
|
||||
inline const G4ThreeVector& GetRotz() const { return Rotz; }
|
||||
inline G4bool GetConfined() const { return Confine; }
|
||||
inline const G4String& GetConfineVolume() const { return VolName; }
|
||||
|
||||
const G4ThreeVector& GetSideRefVec1() const;
|
||||
const G4ThreeVector& GetSideRefVec2() const;
|
||||
const G4ThreeVector& GetSideRefVec3() const;
|
||||
const G4String& GetSourcePosType() const;
|
||||
const G4ThreeVector& GetParticlePos() const;
|
||||
|
||||
private:
|
||||
|
||||
void GenerateRotationMatrices();
|
||||
|
||||
// The following functions generate the source position
|
||||
//
|
||||
void GeneratePointSource(G4ThreeVector& outoutPos);
|
||||
void GeneratePointsInBeam(G4ThreeVector& outoutPos);
|
||||
void GeneratePointsInPlane(G4ThreeVector& outoutPos);
|
||||
void GeneratePointsOnSurface(G4ThreeVector& outputPos);
|
||||
void GeneratePointsInVolume(G4ThreeVector& outputPos);
|
||||
|
||||
G4bool IsSourceConfined(G4ThreeVector& outputPos);
|
||||
|
||||
private:
|
||||
|
||||
// NOTE:
|
||||
// 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();
|
||||
};
|
||||
|
||||
G4String SourcePosType;
|
||||
// Point, Plane, Surface, Volume
|
||||
G4String Shape;
|
||||
// Circle, Square, Rectangle, etc...
|
||||
G4ThreeVector CentreCoords;
|
||||
// Coordinates of centre of input shape
|
||||
G4ThreeVector Rotx, Roty, Rotz;
|
||||
// Unit vectors defining rotation matrix
|
||||
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 radial, x, y for beam type source
|
||||
G4double ParAlpha, ParTheta, ParPhi;
|
||||
// Angle for Right Parallellepipeds
|
||||
G4bool Confine = false;
|
||||
// If true confines source distribution to VolName
|
||||
G4String VolName;
|
||||
// Volume name
|
||||
G4int verbosityLevel;
|
||||
// Verbosity
|
||||
G4SPSRandomGenerator* PosRndm = nullptr;
|
||||
// Biased random generator
|
||||
|
||||
G4Cache<thread_data_t> ThreadData;
|
||||
G4Mutex a_mutex;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -23,120 +23,33 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MODULE: G4SPSRandomGenerator.hh
|
||||
//
|
||||
// Version: 1.0
|
||||
// Date: 5/02/04
|
||||
// Author: Fan Lei
|
||||
// Organisation: QinetiQ ltd.
|
||||
// Customer: ESA/ESTEC
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CHANGE HISTORY
|
||||
// --------------
|
||||
// 06/06/2014 A Dotti
|
||||
// Note on thread safety: added a mutex to protect access to shared
|
||||
// resources (data members).
|
||||
// Getters and Setters are mutex'd but not the GetRand* methods,
|
||||
// because it is assumed these are called only during the event loop
|
||||
// during which the status of this class is invariant.
|
||||
//
|
||||
// 26/10/2004 F Lei
|
||||
// Created separated the theta, phi generators for position distributions.
|
||||
//
|
||||
// Version 1.0, 05/02/2004, Fan Lei, Created.
|
||||
// Based on the G4GeneralParticleSource class in Geant4 v6.0
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// G4SPSRandomGenerator
|
||||
//
|
||||
// Class Description:
|
||||
//
|
||||
// Special random number generator used by G4GeneralParticleSource to allow
|
||||
// biasing applied at the lowest level for all distributions.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MEMBER FUNCTIONS
|
||||
// ----------------
|
||||
//
|
||||
// G4SPSRandomGenerator ()
|
||||
// Constructor: Initializes variables
|
||||
//
|
||||
// ~G4SPSRandomGenerator ()
|
||||
// Destructor:
|
||||
//
|
||||
// void SetXBias(G4ThreeVector)
|
||||
// Allows the user to re-distribute the random
|
||||
// numbers used to generate x co-ordinates.
|
||||
//
|
||||
// void SetYBias(G4ThreeVector)
|
||||
// Allows the user to re-distribute the random
|
||||
// numbers used to generate y co-ordinates.
|
||||
//
|
||||
// void SetZBias(G4ThreeVector)
|
||||
// Allows the user to re-distribute the random
|
||||
// numbers used to generate z co-ordinates.
|
||||
//
|
||||
// void SetThetaBias(G4ThreeVector)
|
||||
// Allows the user to re-distribute the random
|
||||
// numbers used to generate values of theta.
|
||||
//
|
||||
// void SetPhiBias(G4ThreeVector)
|
||||
// Allows the user to re-distribute the random
|
||||
// numbers used to generate values of phi.
|
||||
//
|
||||
// void SetPosThetaBias(G4ThreeVector)
|
||||
// Allows the user to re-distribute the random
|
||||
// numbers used to generate values of theta for position distribution.
|
||||
//
|
||||
// void SetPosPhiBias(G4ThreeVector)
|
||||
// Allows the user to re-distribute the random
|
||||
// numbers used to generate values of phi for position distribution.
|
||||
//
|
||||
// void SetEnergyBias(G4ThreeVector)
|
||||
// Allows the user to re-distribute the random
|
||||
// numbers used to generate the energies.
|
||||
//
|
||||
// G4double GenRandX()
|
||||
// Generates the random number for x, with or without biasing.
|
||||
//
|
||||
// G4double GenRandY()
|
||||
// Generates the random number for y, with or without biasing.
|
||||
//
|
||||
// G4double GenRandZ()
|
||||
// Generates the random number for z, with or without biasing.
|
||||
//
|
||||
// G4double GenRandTheta()
|
||||
// Generates the random number for theta, with or without biasing.
|
||||
//
|
||||
// G4double GenRandPhi()
|
||||
// Generates the random number for phi, with or without biasing.
|
||||
//
|
||||
// G4double GenRandEnergy()
|
||||
// Generates the random number for energy, with or without biasing.
|
||||
//
|
||||
// G4double GenRandPosTheta()
|
||||
// Generates the random number for theta, with or without biasing for position distribution.
|
||||
//
|
||||
// G4double GenRandPosPhi()
|
||||
// Generates the random number for phi, with or without biasing for position distribution.
|
||||
//
|
||||
// inline G4double GetBiasWeight()
|
||||
// Returns the weight change after biasing
|
||||
//
|
||||
// void ReSetHist(G4String);
|
||||
// Re-sets the histogram for user defined distribution
|
||||
//
|
||||
// void SetVerbosity(G4int)
|
||||
// Sets the verbosity level.
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
#ifndef G4SPSRandomGenerator_h
|
||||
#define G4SPSRandomGenerator_h 1
|
||||
// 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 the setters during the event loop
|
||||
|
||||
// Author: Fan Lei, QinetiQ ltd.
|
||||
// Customer: ESA/ESTEC
|
||||
// History:
|
||||
// - 05/02/2004, Fan Lei - Created.
|
||||
// Based on the G4GeneralParticleSource class
|
||||
// - 06/06/2014, Andrea Dotti
|
||||
// Added a mutex to protect access to shared resources (data members).
|
||||
// Getters and Setters are mutex'd but not the GetRand* methods,
|
||||
// because it is assumed these are called only during the event loop
|
||||
// during which the status of this class is invariant
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4SPSRandomGenerator_hh
|
||||
#define G4SPSRandomGenerator_hh 1
|
||||
|
||||
#include "G4PhysicsOrderedFreeVector.hh"
|
||||
#include "G4DataInterpolation.hh"
|
||||
@@ -144,108 +57,148 @@
|
||||
#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:
|
||||
|
||||
class G4SPSRandomGenerator {
|
||||
public:
|
||||
G4SPSRandomGenerator();
|
||||
~G4SPSRandomGenerator();
|
||||
G4SPSRandomGenerator();
|
||||
// Constructor: initializes variables
|
||||
|
||||
// static G4SPSRandomGenerator* getInstance ();
|
||||
~G4SPSRandomGenerator();
|
||||
// Destructor
|
||||
|
||||
// Biasing Methods
|
||||
void SetXBias(G4ThreeVector);
|
||||
void SetYBias(G4ThreeVector);
|
||||
void SetZBias(G4ThreeVector);
|
||||
void SetThetaBias(G4ThreeVector);
|
||||
void SetPhiBias(G4ThreeVector);
|
||||
void SetEnergyBias(G4ThreeVector);
|
||||
void SetPosThetaBias(G4ThreeVector);
|
||||
void SetPosPhiBias(G4ThreeVector);
|
||||
G4double GenRandX();
|
||||
G4double GenRandY();
|
||||
G4double GenRandZ();
|
||||
G4double GenRandTheta();
|
||||
G4double GenRandPhi();
|
||||
G4double GenRandEnergy();
|
||||
G4double GenRandPosTheta();
|
||||
G4double GenRandPosPhi();
|
||||
// Biasing Methods
|
||||
|
||||
void SetXBias(const G4ThreeVector&);
|
||||
// Allows the user to re-distribute the random
|
||||
// numbers used to generate x co-ordinates
|
||||
|
||||
void SetYBias(const G4ThreeVector&);
|
||||
// Allows the user to re-distribute the random
|
||||
// numbers used to generate y co-ordinates
|
||||
|
||||
void SetZBias(const G4ThreeVector&);
|
||||
// Allows the user to re-distribute the random
|
||||
// numbers used to generate z co-ordinates
|
||||
|
||||
void SetThetaBias(const G4ThreeVector&);
|
||||
// Allows the user to re-distribute the random
|
||||
// numbers used to generate values of theta
|
||||
|
||||
void SetPhiBias(const G4ThreeVector&);
|
||||
// Allows the user to re-distribute the random
|
||||
// numbers used to generate values of phi
|
||||
|
||||
void SetEnergyBias(const G4ThreeVector&);
|
||||
// Allows the user to re-distribute the random
|
||||
// numbers used to generate the energies
|
||||
|
||||
void SetPosThetaBias(const G4ThreeVector&);
|
||||
// Allows the user to re-distribute the random
|
||||
// numbers used to generate values of theta for position distribution
|
||||
|
||||
void SetPosPhiBias(const G4ThreeVector&);
|
||||
// Allows the user to re-distribute the random
|
||||
// numbers used to generate values of phi for position distribution
|
||||
|
||||
G4double GenRandX();
|
||||
// Generates the random number for x, with or without biasing
|
||||
|
||||
G4double GenRandY();
|
||||
// Generates the random number for y, with or without biasing
|
||||
|
||||
G4double GenRandZ();
|
||||
// Generates the random number for z, with or without biasing
|
||||
|
||||
G4double GenRandTheta();
|
||||
// Generates the random number for theta, with or without biasing
|
||||
|
||||
G4double GenRandPhi();
|
||||
// Generates the random number for phi, with or without biasing
|
||||
|
||||
G4double GenRandEnergy();
|
||||
// Generates the random number for energy, with or without biasing
|
||||
|
||||
G4double GenRandPosTheta();
|
||||
// Generates the random number for theta, with or without biasing
|
||||
// for position distribution
|
||||
|
||||
G4double GenRandPosPhi();
|
||||
// Generates the random number for phi, with or without biasing
|
||||
// for position distribution
|
||||
|
||||
void SetIntensityWeight(G4double weight);
|
||||
|
||||
G4double GetBiasWeight();
|
||||
G4double GetBiasWeight() const ;
|
||||
// Returns the weight change after biasing
|
||||
|
||||
// method to re-set the histograms
|
||||
void ReSetHist(G4String);
|
||||
// method to re-set the histograms
|
||||
void ReSetHist(const G4String&);
|
||||
// Resets the histogram for user defined distribution
|
||||
|
||||
// Set the verbosity level.
|
||||
void SetVerbosity(G4int a);
|
||||
void SetVerbosity(G4int a);
|
||||
// Sets the verbosity level
|
||||
|
||||
private:
|
||||
//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;
|
||||
private:
|
||||
|
||||
//G4double alpha; // for biasing energy
|
||||
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
|
||||
// Encapsulate in a struct to guarantee 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;
|
||||
|
||||
// Verbosity
|
||||
G4int verbosityLevel;
|
||||
struct bweights_t
|
||||
{
|
||||
G4double w[9];
|
||||
bweights_t();
|
||||
G4double& operator[] (const int i);
|
||||
};
|
||||
G4Cache<bweights_t> bweights;
|
||||
// record x,y,z,theta,phi,energy,posThet,posPhi,intensity weights
|
||||
|
||||
G4Mutex mutex; //protect shared resources
|
||||
G4int verbosityLevel;
|
||||
// Verbosity
|
||||
|
||||
G4Mutex mutex;
|
||||
// Protect shared resources
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,104 +23,43 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// G4SingleParticleSource
|
||||
//
|
||||
// MODULE: G4SingleParticleSource.hh
|
||||
//
|
||||
// Version: 1.0
|
||||
// Date: 5/02/04
|
||||
// Author: Fan Lei
|
||||
// Organisation: QinetiQ ltd.
|
||||
// Customer: ESA/ESTEC
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// CHANGE HISTORY
|
||||
// --------------
|
||||
//
|
||||
// Version 1.0, 05/02/2004, Fan Lei, Created.
|
||||
// Based on the G4GeneralParticleSource class in Geant4 v6.0
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Class Description:
|
||||
// Class description:
|
||||
//
|
||||
// The Single Particle Source is designed to extend the functionality of the
|
||||
// G4ParticleGun class. It is designed to allow specification of input
|
||||
// particles in terms of position, direction (or angular) and energy
|
||||
// distributions. It is used by the General Particle source class
|
||||
// distributions. It is used by the General Particle source class
|
||||
// and it is derived from G4VPrimaryGenerator.
|
||||
//
|
||||
// Note on thread safety:
|
||||
// G4SingleParticleSource instances can be shared among threads. GeneratePrimaryVertex
|
||||
// is protected via a mutex because underlying generators are not assumed to be thread-safe.
|
||||
// Note that internal status of this class is assumed to be changed by master thread (typically
|
||||
// via UI commands).
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// MEMBER FUNCTIONS
|
||||
// ----------------
|
||||
//
|
||||
// G4SingleParticleSource ()
|
||||
// Constructor: Initializes variables and instantiates the
|
||||
// Messenger and Navigator classes
|
||||
//
|
||||
// ~G4SingleParticleSource ()
|
||||
// Destructor: deletes Messenger and prints out run information.
|
||||
//
|
||||
// void GeneratePrimaryVertex(G4Event *evt)
|
||||
// Generate the particles initial parameters.
|
||||
//
|
||||
// G4SPSPosDistribution* GetPosDist()
|
||||
// Return a pointer to the position distribution generator
|
||||
//
|
||||
// G4SPSAngDistribution* GetAngDist()
|
||||
// Return a pointer to the angular distribution generator
|
||||
//
|
||||
// G4SPSEneDistribution* GetEneDist()
|
||||
// Return a pointer to the energy distribution generator
|
||||
//
|
||||
// G4SPSRandomGenerator* GetBiasRndm() {return biasRndm;};
|
||||
// Return a pointer to the biased random number generator
|
||||
//
|
||||
// void SetVerbosity(G4int);
|
||||
// Set the verbosity level.
|
||||
//
|
||||
// void SetParticleDefinition ();
|
||||
// G4ParticleDefinition * GetParticleDefinition ()
|
||||
// Get/Set the particle definition of the primary track
|
||||
//
|
||||
// void SetParticleCharge(G4double aCharge)
|
||||
// set the charge state of the primary track
|
||||
//
|
||||
// inline void SetParticlePolarization (G4ThreeVector aVal)
|
||||
// inline G4ThreeVector GetParticlePolarization ()
|
||||
// Set/Get the polarization state of the primary track
|
||||
//
|
||||
// inline void SetParticleTime(G4double aTime) { particle_time = aTime; };
|
||||
// inline G4double GetParticleTime() { return particle_time; };
|
||||
// Set/Get the Time.
|
||||
//
|
||||
// inline void SetNumberOfParticles(G4int i)
|
||||
// inline G4int GetNumberOfParticles()
|
||||
// set/get the number of particles to be generated in the primary track
|
||||
//
|
||||
// inline G4ThreeVector GetParticlePosition()
|
||||
// inline G4ThreeVector GetParticleMomentumDirection()
|
||||
// inline G4double GetParticleEnergy()
|
||||
// get the position, direction, and energy of the current particle
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
#ifndef G4SingleParticleSource_h
|
||||
#define G4SingleParticleSource_h 1
|
||||
// G4SingleParticleSource instances can be shared among threads.
|
||||
// GeneratePrimaryVertex is protected via a mutex because underlying
|
||||
// generators are not assumed to be thread-safe.
|
||||
// Note that internal status of this class is assumed to be changed by
|
||||
// master thread (typically via UI commands)
|
||||
// Only one thread should use the set-methods here.
|
||||
// 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
|
||||
|
||||
// Author: Fan Lei, QinetiQ ltd.
|
||||
// Customer: ESA/ESTEC
|
||||
// History:
|
||||
// - 05/02/2004, Fan Lei - Created.
|
||||
// Based on the G4GeneralParticleSource class
|
||||
// - 06/06/2014, Andrea Dotti
|
||||
// Added a mutex to protect access to shared resources (data members)
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4SingleParticleSource_hh
|
||||
#define G4SingleParticleSource_hh 1
|
||||
|
||||
#include "G4VPrimaryGenerator.hh"
|
||||
#include "G4ParticleMomentum.hh"
|
||||
#include "G4ParticleDefinition.hh"
|
||||
//
|
||||
|
||||
#include "G4SPSPosDistribution.hh"
|
||||
#include "G4SPSAngDistribution.hh"
|
||||
#include "G4SPSEneDistribution.hh"
|
||||
@@ -128,128 +67,98 @@
|
||||
#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:
|
||||
|
||||
class G4SingleParticleSource: public G4VPrimaryGenerator {
|
||||
public:
|
||||
G4SingleParticleSource();
|
||||
~G4SingleParticleSource();
|
||||
G4SingleParticleSource();
|
||||
// Constructor: initializes variables and instantiates the
|
||||
// messenger and navigator classes
|
||||
|
||||
void GeneratePrimaryVertex(G4Event *evt);
|
||||
//
|
||||
~G4SingleParticleSource();
|
||||
// Destructor: deletes messenger and prints out run information
|
||||
|
||||
G4SPSPosDistribution* GetPosDist() const {
|
||||
return posGenerator;
|
||||
}
|
||||
;
|
||||
G4SPSAngDistribution* GetAngDist() const {
|
||||
return angGenerator;
|
||||
}
|
||||
;
|
||||
G4SPSEneDistribution* GetEneDist() const {
|
||||
return eneGenerator;
|
||||
}
|
||||
;
|
||||
G4SPSRandomGenerator* GetBiasRndm() const {
|
||||
return biasRndm;
|
||||
}
|
||||
;
|
||||
void GeneratePrimaryVertex(G4Event *evt);
|
||||
// Generate the particles initial parameters
|
||||
|
||||
// Set the verbosity level.
|
||||
void SetVerbosity(G4int);
|
||||
inline G4SPSPosDistribution* GetPosDist() const { return posGenerator; }
|
||||
// Return a pointer to the position distribution generator
|
||||
|
||||
// Set the particle species
|
||||
void SetParticleDefinition(G4ParticleDefinition * aParticleDefinition);
|
||||
inline G4ParticleDefinition * GetParticleDefinition() const {
|
||||
return definition;
|
||||
}
|
||||
;
|
||||
inline G4SPSAngDistribution* GetAngDist() const { return angGenerator; }
|
||||
// Return a pointer to the angular distribution generator
|
||||
|
||||
inline void SetParticleCharge(G4double aCharge) {
|
||||
charge = aCharge;
|
||||
}
|
||||
;
|
||||
inline G4SPSEneDistribution* GetEneDist() const { return eneGenerator; }
|
||||
// Return a pointer to the energy distribution generator
|
||||
|
||||
// Set polarization
|
||||
inline void SetParticlePolarization(G4ThreeVector aVal) {
|
||||
polarization = aVal;
|
||||
}
|
||||
;
|
||||
inline G4ThreeVector GetParticlePolarization() const {
|
||||
return polarization;
|
||||
}
|
||||
;
|
||||
inline G4SPSRandomGenerator* GetBiasRndm() const { return biasRndm; }
|
||||
// Return a pointer to the biased random number generator
|
||||
|
||||
// Set Time.
|
||||
inline void SetParticleTime(G4double aTime) {
|
||||
time = aTime;
|
||||
}
|
||||
;
|
||||
inline G4double GetParticleTime() const {
|
||||
return time;
|
||||
}
|
||||
;
|
||||
void SetVerbosity(G4int);
|
||||
// Set the verbosity level
|
||||
|
||||
inline void SetNumberOfParticles(G4int i) {
|
||||
NumberOfParticlesToBeGenerated = i;
|
||||
}
|
||||
;
|
||||
//
|
||||
inline G4int GetNumberOfParticles() const {
|
||||
return NumberOfParticlesToBeGenerated;
|
||||
}
|
||||
;
|
||||
inline G4ThreeVector GetParticlePosition() const {
|
||||
return ParticleProperties.Get().position;
|
||||
}
|
||||
;
|
||||
inline G4ThreeVector GetParticleMomentumDirection() const {
|
||||
return ParticleProperties.Get().momentum_direction;
|
||||
}
|
||||
;
|
||||
inline G4double GetParticleEnergy() const {
|
||||
return ParticleProperties.Get().energy;
|
||||
}
|
||||
;
|
||||
void SetParticleDefinition(G4ParticleDefinition* aParticleDefinition);
|
||||
inline G4ParticleDefinition* GetParticleDefinition() const
|
||||
{ return definition; }
|
||||
// Get/Set the particle definition of the primary track
|
||||
|
||||
private:
|
||||
inline void SetParticleCharge(G4double aCharge) { charge = aCharge; }
|
||||
// Set the charge state of the primary track
|
||||
|
||||
G4SPSPosDistribution* posGenerator;
|
||||
G4SPSAngDistribution* angGenerator;
|
||||
G4SPSEneDistribution* eneGenerator;
|
||||
G4SPSRandomGenerator* biasRndm;
|
||||
//
|
||||
// Other particle properties
|
||||
//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;
|
||||
inline void SetParticlePolarization(const G4ThreeVector& aVal)
|
||||
{ polarization = aVal; }
|
||||
inline const G4ThreeVector& GetParticlePolarization() const
|
||||
{ return polarization; }
|
||||
// Set/Get the polarization state of the primary track
|
||||
|
||||
// Verbosity
|
||||
G4int verbosityLevel;
|
||||
inline void SetParticleTime(G4double aTime) { time = aTime; }
|
||||
inline G4double GetParticleTime() const { return time; }
|
||||
// Set/Get the Time
|
||||
|
||||
inline void SetNumberOfParticles(G4int i)
|
||||
{ NumberOfParticlesToBeGenerated = i; }
|
||||
inline G4int GetNumberOfParticles() const
|
||||
{ return NumberOfParticlesToBeGenerated; }
|
||||
// Set/get the number of particles to be generated in the primary track
|
||||
|
||||
inline G4ThreeVector GetParticlePosition() const
|
||||
{ return ParticleProperties.Get().position; }
|
||||
inline G4ThreeVector GetParticleMomentumDirection() const
|
||||
{ return ParticleProperties.Get().momentum_direction; }
|
||||
inline G4double GetParticleEnergy() const
|
||||
{ return ParticleProperties.Get().energy; }
|
||||
// Get the position, direction, and energy of the current particle
|
||||
|
||||
private:
|
||||
|
||||
G4SPSPosDistribution* posGenerator = nullptr;
|
||||
G4SPSAngDistribution* angGenerator = nullptr;
|
||||
G4SPSEneDistribution* eneGenerator = nullptr;
|
||||
G4SPSRandomGenerator* biasRndm = nullptr;
|
||||
|
||||
// Other particle properties
|
||||
// These need to be thread-local because a getter for them exits
|
||||
//
|
||||
struct part_prop_t
|
||||
{
|
||||
G4ParticleMomentum momentum_direction;
|
||||
G4double energy;
|
||||
G4ThreeVector position;
|
||||
part_prop_t();
|
||||
};
|
||||
|
||||
G4Cache<part_prop_t> ParticleProperties;
|
||||
G4int NumberOfParticlesToBeGenerated;
|
||||
G4ParticleDefinition* definition = nullptr;
|
||||
G4double charge;
|
||||
G4double time;
|
||||
G4ThreeVector polarization;
|
||||
|
||||
G4int verbosityLevel;
|
||||
// Verbosity
|
||||
|
||||
//This can be a shared resource, this mutex is used in GeneratePrimaryVertex
|
||||
G4Mutex mutex;
|
||||
// This can be a shared resource.
|
||||
// This mutex is uses in GeneratePrimaryVertex
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,12 +23,14 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// class description:
|
||||
// G4SmartTrackStack
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// This is a 'smart' stack class used by G4StackManager. This class object
|
||||
// stores G4StackedTrack class objects in various dedicated stacks
|
||||
|
||||
// Author: S.Kamperis - 04/Oct/12
|
||||
// Author: S.Kamperis - 4 October 2012
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4SmartTrackStack_hh
|
||||
#define G4SmartTrackStack_hh 1
|
||||
@@ -86,4 +88,3 @@ class G4SmartTrackStack
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,41 +23,38 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4StackChecker
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// A UserStackingAction for removing unreasonable tracks.
|
||||
|
||||
#ifndef G4StackChecker_h
|
||||
#define G4StackChecker_h 1
|
||||
// Author: Makoto Asai, 2003
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4StackChecker_hh
|
||||
#define G4StackChecker_hh 1
|
||||
|
||||
#include "G4UserStackingAction.hh"
|
||||
#include "G4ClassificationOfNewTrack.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This is the UserStackingAction for removing unreasonable tracks.
|
||||
//
|
||||
|
||||
class G4Track;
|
||||
|
||||
class G4StackChecker : public G4UserStackingAction
|
||||
class G4StackChecker : public G4UserStackingAction
|
||||
{
|
||||
public:
|
||||
G4StackChecker();
|
||||
virtual ~G4StackChecker();
|
||||
public:
|
||||
|
||||
public: // with description
|
||||
G4StackChecker();
|
||||
virtual ~G4StackChecker();
|
||||
|
||||
virtual G4ClassificationOfNewTrack
|
||||
ClassifyNewTrack(const G4Track* track);
|
||||
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track* track);
|
||||
|
||||
virtual void NewStage() {};
|
||||
virtual void PrepareNewEvent() {};
|
||||
virtual void NewStage();
|
||||
virtual void PrepareNewEvent();
|
||||
|
||||
private:
|
||||
|
||||
G4ThreeVector nullDirection;
|
||||
private:
|
||||
|
||||
G4ThreeVector nullDirection;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -23,14 +23,28 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4StackManager
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// Last Modification : 04/Oct/11 P. Mato - making use of G4TrackStack with value semantics
|
||||
///
|
||||
// This is the manager class of handling stacks of G4Track objects.
|
||||
// This class must be a singleton and be constructed by G4EventManager.
|
||||
// Almost all methods must be invoked exclusively by G4EventManager.
|
||||
// Especially, some Clear() methods MUST NOT be invoked by the user.
|
||||
// Event abortion is handled by G4EventManager.
|
||||
//
|
||||
// G4StackManager has three stacks, the urgent stack, the
|
||||
// waiting stack, and the postpone to next event stack. The meanings
|
||||
// of each stack is descrived in the Geant4 User's Manual.
|
||||
|
||||
|
||||
#ifndef G4StackManager_h
|
||||
#define G4StackManager_h 1
|
||||
// Author: Makoto Asai, 1996
|
||||
//
|
||||
// History:
|
||||
// - 01/Feb/1996, Makoto Asai - Created
|
||||
// - 04/Oct/2011, Pere Mato - Use of G4TrackStack with value semantics
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4StackManager_hh
|
||||
#define G4StackManager_hh 1
|
||||
|
||||
#include "G4UserStackingAction.hh"
|
||||
#include "G4StackedTrack.hh"
|
||||
@@ -40,43 +54,28 @@
|
||||
#include "G4Track.hh"
|
||||
#include "G4TrackStatus.hh"
|
||||
#include "globals.hh"
|
||||
#include "evmandefs.hh"
|
||||
|
||||
class G4StackingMessenger;
|
||||
class G4VTrajectory;
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This is the manager class of handling stacks of G4Track objects.
|
||||
// This class must be a singleton and be constructed by G4EventManager.
|
||||
// Almost all methods must be invoked exclusively by G4EventManager.
|
||||
// Especially, some Clear() methods MUST NOT be invoked by the user.
|
||||
// Event abortion is handled by G4EventManager.
|
||||
//
|
||||
// This G4StackingManager has three stacks, the urgent stack, the
|
||||
// waiting stack, and the postpone to next event stack. The meanings
|
||||
// of each stack is descrived in the Geant4 user's manual.
|
||||
//
|
||||
|
||||
class G4StackManager
|
||||
{
|
||||
public:
|
||||
G4StackManager();
|
||||
~G4StackManager();
|
||||
|
||||
private:
|
||||
const G4StackManager& operator=(const G4StackManager &right);
|
||||
G4bool operator==(const G4StackManager &right) const;
|
||||
G4bool operator!=(const G4StackManager &right) const;
|
||||
G4StackManager();
|
||||
~G4StackManager();
|
||||
|
||||
public:
|
||||
G4int PushOneTrack(G4Track *newTrack, G4VTrajectory *newTrajectory = 0);
|
||||
G4Track * PopNextTrack(G4VTrajectory**newTrajectory);
|
||||
G4int PrepareNewEvent();
|
||||
const G4StackManager& operator=(const G4StackManager&) = delete;
|
||||
G4bool operator==(const G4StackManager&) const = delete;
|
||||
G4bool operator!=(const G4StackManager&) const = delete;
|
||||
|
||||
public: // with description
|
||||
void ReClassify();
|
||||
// Send all tracks stored in the Urgent stack one by one to
|
||||
G4int PushOneTrack(G4Track* newTrack,
|
||||
G4VTrajectory* newTrajectory = nullptr);
|
||||
G4Track* PopNextTrack(G4VTrajectory** newTrajectory);
|
||||
G4int PrepareNewEvent();
|
||||
|
||||
void ReClassify();
|
||||
// Send all tracks stored in the Urgent stack one by one to
|
||||
// the user's concrete ClassifyNewTrack() method. This method
|
||||
// can be invoked from the user's G4UserStackingAction concrete
|
||||
// class, especially fron its NewStage() method. Be aware that
|
||||
@@ -84,56 +83,59 @@ class G4StackManager
|
||||
// stack are send to the urgent stack and then the user's NewStage()
|
||||
// method is invoked.
|
||||
|
||||
void SetNumberOfAdditionalWaitingStacks(G4int iAdd);
|
||||
// Set the number of additional (optional) waiting stacks.
|
||||
void SetNumberOfAdditionalWaitingStacks(G4int iAdd);
|
||||
// Set the number of additional (optional) waiting stacks.
|
||||
// This method must be invoked at PreInit, Init or Idle states.
|
||||
// Once the user set the number of additional waiting stacks,
|
||||
// he/she can use the corresponding ENUM in G4ClassificationOfNewTrack.
|
||||
// The user should invoke G4RunManager::SetNumberOfAdditionalWaitingStacks
|
||||
// method, which invokes this method.
|
||||
|
||||
void TransferStackedTracks(G4ClassificationOfNewTrack origin, G4ClassificationOfNewTrack destination);
|
||||
// Transfter all stacked tracks from the origin stack to the destination stack.
|
||||
// The destination stack needs not be empty.
|
||||
void TransferStackedTracks(G4ClassificationOfNewTrack origin,
|
||||
G4ClassificationOfNewTrack destination);
|
||||
// Transfer all stacked tracks from the origin stack to the
|
||||
// destination stack. The destination stack needs not be empty.
|
||||
// If the destination is fKill, tracks are deleted.
|
||||
// If the origin is fKill, nothing happen.
|
||||
|
||||
void TransferOneStackedTrack(G4ClassificationOfNewTrack origin, G4ClassificationOfNewTrack destination);
|
||||
// Transfter one stacked track from the origin stack to the destination stack.
|
||||
void TransferOneStackedTrack(G4ClassificationOfNewTrack origin,
|
||||
G4ClassificationOfNewTrack destination);
|
||||
// Transfter one stacked track from the origin stack to the destination
|
||||
// stack.
|
||||
// The transfered track is the one which came last to the origin stack.
|
||||
// The destination stack needs not be empty.
|
||||
// If the destination is fKill, the track is deleted.
|
||||
// If the origin is fKill, nothing happen.
|
||||
|
||||
private:
|
||||
G4UserStackingAction * userStackingAction;
|
||||
G4int verboseLevel;
|
||||
#ifdef G4_USESMARTSTACK
|
||||
G4SmartTrackStack * urgentStack;
|
||||
#else
|
||||
G4TrackStack * urgentStack;
|
||||
#endif
|
||||
G4TrackStack * waitingStack;
|
||||
G4TrackStack * postponeStack;
|
||||
G4StackingMessenger* theMessenger;
|
||||
std::vector<G4TrackStack*> additionalWaitingStacks;
|
||||
G4int numberOfAdditionalWaitingStacks;
|
||||
void clear();
|
||||
void ClearUrgentStack();
|
||||
void ClearWaitingStack(G4int i=0);
|
||||
void ClearPostponeStack();
|
||||
G4int GetNTotalTrack() const;
|
||||
G4int GetNUrgentTrack() const;
|
||||
G4int GetNWaitingTrack(G4int i=0) const;
|
||||
G4int GetNPostponedTrack() const;
|
||||
void SetVerboseLevel( G4int const value );
|
||||
void SetUserStackingAction(G4UserStackingAction* value);
|
||||
|
||||
public:
|
||||
void clear();
|
||||
void ClearUrgentStack();
|
||||
void ClearWaitingStack(int i=0);
|
||||
void ClearPostponeStack();
|
||||
G4int GetNTotalTrack() const;
|
||||
G4int GetNUrgentTrack() const;
|
||||
G4int GetNWaitingTrack(int i=0) const;
|
||||
G4int GetNPostponedTrack() const;
|
||||
void SetVerboseLevel( G4int const value );
|
||||
void SetUserStackingAction(G4UserStackingAction* value);
|
||||
|
||||
private:
|
||||
G4ClassificationOfNewTrack DefaultClassification(G4Track *aTrack);
|
||||
|
||||
G4ClassificationOfNewTrack DefaultClassification(G4Track* aTrack);
|
||||
|
||||
private:
|
||||
|
||||
G4UserStackingAction* userStackingAction = nullptr;
|
||||
G4int verboseLevel = 0;
|
||||
#ifdef G4_USESMARTSTACK
|
||||
G4SmartTrackStack* urgentStack = nullptr;
|
||||
#else
|
||||
G4TrackStack* urgentStack = nullptr;
|
||||
#endif
|
||||
G4TrackStack* waitingStack = nullptr;
|
||||
G4TrackStack* postponeStack = nullptr;
|
||||
G4StackingMessenger* theMessenger = nullptr;
|
||||
std::vector<G4TrackStack*> additionalWaitingStacks;
|
||||
G4int numberOfAdditionalWaitingStacks = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
// class description:
|
||||
//
|
||||
// This class is exclusively used by G4StackManager and G4TrackStack
|
||||
// classes for storing a G4Track object.
|
||||
//
|
||||
// Author: Makoto Asai (SLAC) - 02/Feb/96
|
||||
// classes for storing a G4Track object
|
||||
|
||||
// Author: Makoto Asai - 02/Feb/96
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4StackedTrack_hh
|
||||
#define G4StackedTrack_hh 1
|
||||
@@ -45,14 +45,13 @@ class G4StackedTrack
|
||||
: track(aTrack), trajectory(aTraj) {}
|
||||
~G4StackedTrack() {}
|
||||
|
||||
G4Track* GetTrack() const { return track; }
|
||||
G4VTrajectory* GetTrajectory() const { return trajectory; }
|
||||
inline G4Track* GetTrack() const { return track; }
|
||||
inline G4VTrajectory* GetTrajectory() const { return trajectory; }
|
||||
|
||||
private:
|
||||
|
||||
G4Track* track;
|
||||
G4VTrajectory* trajectory;
|
||||
G4Track* track = nullptr;
|
||||
G4VTrajectory* trajectory = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,35 +23,40 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4StackingMessenger
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
|
||||
#ifndef G4StackingMessenger_h
|
||||
#define G4StackingMessenger_h 1
|
||||
|
||||
#include "G4UImessenger.hh"
|
||||
class G4StackManager;
|
||||
class G4UIdirectory;
|
||||
class G4UIcmdWithoutParameter;
|
||||
class G4UIcmdWithAnInteger;
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This is a concrete class of G4UImessenger which handles the commands
|
||||
// This is a concrete class of G4UImessenger which handles the commands
|
||||
// for G4StackManager. It has the following commands:
|
||||
// /event/stack/
|
||||
// /event/stack/status
|
||||
// /event/stack/clear
|
||||
// /event/stack/verbose
|
||||
|
||||
class G4StackingMessenger: public G4UImessenger
|
||||
// Author: Makoto Asai, 1996
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4StackingMessenger_hh
|
||||
#define G4StackingMessenger_hh 1
|
||||
|
||||
#include "G4UImessenger.hh"
|
||||
|
||||
class G4StackManager;
|
||||
class G4UIdirectory;
|
||||
class G4UIcmdWithoutParameter;
|
||||
class G4UIcmdWithAnInteger;
|
||||
|
||||
class G4StackingMessenger : public G4UImessenger
|
||||
{
|
||||
public:
|
||||
|
||||
G4StackingMessenger(G4StackManager* fCont);
|
||||
~G4StackingMessenger();
|
||||
void SetNewValue(G4UIcommand * command,G4String newValues);
|
||||
~G4StackingMessenger();
|
||||
void SetNewValue(G4UIcommand* command, G4String newValues);
|
||||
|
||||
private:
|
||||
G4StackManager * fContainer;
|
||||
|
||||
G4StackManager* fContainer = nullptr;
|
||||
G4UIdirectory* stackDir;
|
||||
G4UIcmdWithoutParameter* statusCmd;
|
||||
G4UIcmdWithAnInteger* clearCmd;
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// class description:
|
||||
// Class description:
|
||||
//
|
||||
// This is a stack class used by G4StackManager. This class object
|
||||
// stores G4StackedTrack class objects in the form of bi-directional
|
||||
@@ -47,7 +47,7 @@ class G4TrackStack : public std::vector<G4StackedTrack>
|
||||
|
||||
G4TrackStack()
|
||||
: safetyValue1(0), safetyValue2(0), nstick(0) {}
|
||||
G4TrackStack(size_t n)
|
||||
G4TrackStack(std::size_t n)
|
||||
: safetyValue1(G4int(4*n/5)),
|
||||
safetyValue2(G4int(4*n/5-100)), nstick(100) { reserve(n); }
|
||||
~G4TrackStack();
|
||||
@@ -56,23 +56,23 @@ class G4TrackStack : public std::vector<G4StackedTrack>
|
||||
G4bool operator==(const G4TrackStack&) const = delete;
|
||||
G4bool operator!=(const G4TrackStack&) const = delete;
|
||||
|
||||
void PushToStack(const G4StackedTrack& aStackedTrack)
|
||||
inline void PushToStack(const G4StackedTrack& aStackedTrack)
|
||||
{ push_back(aStackedTrack); }
|
||||
G4StackedTrack PopFromStack()
|
||||
inline G4StackedTrack PopFromStack()
|
||||
{ G4StackedTrack st = back(); pop_back(); return st; }
|
||||
void TransferTo(G4TrackStack* aStack);
|
||||
void TransferTo(G4SmartTrackStack* aStack);
|
||||
|
||||
void clearAndDestroy();
|
||||
|
||||
size_t GetNTrack() const { return size(); }
|
||||
size_t GetMaxNTrack() const { return max_size(); }
|
||||
inline std::size_t GetNTrack() const { return size(); }
|
||||
inline std::size_t GetMaxNTrack() const { return max_size(); }
|
||||
inline G4int GetSafetyValue1() const { return safetyValue1; }
|
||||
inline G4int GetSafetyValue2() const { return safetyValue2; }
|
||||
inline G4int GetNStick() const { return nstick; }
|
||||
|
||||
G4double getTotalEnergy(void) const;
|
||||
void SetSafetyValue2(G4int x) { safetyValue2 = x < 0 ? 0 : x; }
|
||||
inline void SetSafetyValue2(G4int x) { safetyValue2 = x < 0 ? 0 : x; }
|
||||
|
||||
private:
|
||||
|
||||
|
||||
@@ -54,33 +54,33 @@ class G4TrajectoryContainer
|
||||
G4TrajectoryContainer(const G4TrajectoryContainer&) = delete;
|
||||
G4TrajectoryContainer& operator=(const G4TrajectoryContainer&) = delete;
|
||||
|
||||
inline void *operator new(size_t);
|
||||
inline void *operator new(std::size_t);
|
||||
inline void operator delete(void* anEvent);
|
||||
|
||||
G4bool operator==(const G4TrajectoryContainer& right) const;
|
||||
G4bool operator!=(const G4TrajectoryContainer& right) const;
|
||||
|
||||
inline size_t size() const { return vect->size(); }
|
||||
inline std::size_t size() const { return vect->size(); }
|
||||
inline void push_back(G4VTrajectory* p) { vect->push_back(p); }
|
||||
inline size_t entries() const { return size(); }
|
||||
inline std::size_t entries() const { return size(); }
|
||||
inline G4bool insert(G4VTrajectory* p) { push_back(p); return true; }
|
||||
inline void clearAndDestroy()
|
||||
{
|
||||
for(std::size_t i=0; i<size(); ++i) delete (*vect)[i];
|
||||
vect->clear();
|
||||
}
|
||||
inline G4VTrajectory* operator[](size_t n) { return (*vect)[n]; }
|
||||
inline G4VTrajectory* operator[](std::size_t n) { return (*vect)[n]; }
|
||||
inline TrajectoryVector* GetVector() const { return vect; }
|
||||
|
||||
private:
|
||||
|
||||
TrajectoryVector* vect;
|
||||
TrajectoryVector* vect = nullptr;
|
||||
};
|
||||
|
||||
extern G4EVENT_DLL
|
||||
G4Allocator<G4TrajectoryContainer>*& aTrajectoryContainerAllocator();
|
||||
|
||||
inline void* G4TrajectoryContainer::operator new(size_t)
|
||||
inline void* G4TrajectoryContainer::operator new(std::size_t)
|
||||
{
|
||||
if (!aTrajectoryContainerAllocator())
|
||||
aTrajectoryContainerAllocator() = new G4Allocator<G4TrajectoryContainer>;
|
||||
|
||||
@@ -23,44 +23,43 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UserEventAction
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
//
|
||||
//
|
||||
// This is the base class of one of the user's optional action classes.
|
||||
// The two methods BeginOfEventAction() and EndOfEventAction() are invoked
|
||||
// at the beginning and the end of one event processing. These methods are
|
||||
// invoked by G4EventManager.
|
||||
// Be aware that BeginOfEventAction() is invoked when a G4Event object is
|
||||
// sent to G4EventManager. Thus the primary vertexes/particles have already
|
||||
// been made by the primary generator. In case the user wants to do something
|
||||
// before generating primaries (i.e., store random number status), do it in
|
||||
// the G4VUserPrimaryGeneratorAction concrete class
|
||||
|
||||
#ifndef G4UserEventAction_h
|
||||
#define G4UserEventAction_h 1
|
||||
// Author: Makoto Asai (SLAC)
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4UserEventAction_hh
|
||||
#define G4UserEventAction_hh 1
|
||||
|
||||
class G4EventManager;
|
||||
class G4Event;
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This is the base class of one of the user's optional action classes.
|
||||
// The two methods BeginOfEventAction() and EndOfEventAction() are invoked
|
||||
// at the beginning and the end of one event processing. These methods are
|
||||
// invoked by G4EventManager.
|
||||
// Be aware that BeginOfEventAction() is invoked when a G4Event object is
|
||||
// sent to G4EventManager. Thus the primary vertexes/particles have already
|
||||
// been made by the primary generator. In case the user wants to do something
|
||||
// before generating primaries (i.e., store random number status), do it in
|
||||
// the G4VUserPrimaryGeneratorAction concrete class.
|
||||
//
|
||||
|
||||
class G4UserEventAction
|
||||
{
|
||||
public:
|
||||
G4UserEventAction();
|
||||
virtual ~G4UserEventAction();
|
||||
virtual void SetEventManager(G4EventManager* value)
|
||||
{ fpEventManager = value; }
|
||||
public: // with description
|
||||
virtual void BeginOfEventAction(const G4Event* anEvent);
|
||||
virtual void EndOfEventAction(const G4Event* anEvent);
|
||||
|
||||
G4UserEventAction();
|
||||
virtual ~G4UserEventAction();
|
||||
virtual void SetEventManager(G4EventManager* value);
|
||||
|
||||
virtual void BeginOfEventAction(const G4Event* anEvent);
|
||||
virtual void EndOfEventAction(const G4Event* anEvent);
|
||||
// Two virtual method the user can override.
|
||||
|
||||
protected:
|
||||
G4EventManager* fpEventManager;
|
||||
|
||||
G4EventManager* fpEventManager = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,103 +23,96 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4UserStackingAction
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// This is the base class of one of the user's optional action classes.
|
||||
// This class gives the hooks for G4StackManager which controls the stacks
|
||||
// of G4Track objects
|
||||
|
||||
#ifndef G4UserStackingAction_h
|
||||
#define G4UserStackingAction_h 1
|
||||
// Author: Makoto Asai (SLAC)
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4UserStackingAction_hh
|
||||
#define G4UserStackingAction_hh 1
|
||||
|
||||
#include "G4ClassificationOfNewTrack.hh"
|
||||
|
||||
class G4StackManager;
|
||||
class G4Track;
|
||||
#include "G4ClassificationOfNewTrack.hh"
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This is the base class of one of the user's optional action classes.
|
||||
// This class gives the hooks for G4StackManager which controls the stacks
|
||||
// of G4Track objects.
|
||||
//
|
||||
|
||||
class G4UserStackingAction
|
||||
{
|
||||
public:
|
||||
G4UserStackingAction();
|
||||
virtual ~G4UserStackingAction();
|
||||
|
||||
G4UserStackingAction();
|
||||
virtual ~G4UserStackingAction();
|
||||
|
||||
inline void SetStackManager(G4StackManager* value) { stackManager=value; }
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// vitual methods to be implemented by user
|
||||
// ---------------------------------------------------------------
|
||||
|
||||
virtual G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track* aTrack);
|
||||
//
|
||||
// Reply G4ClassificationOfNewTrack determined by the newly
|
||||
// coming G4Track.
|
||||
//
|
||||
// enum G4ClassificationOfNewTrack
|
||||
// {
|
||||
// fUrgent, // put into the urgent stack
|
||||
// fWaiting, // put into the waiting stack
|
||||
// fPostpone, // postpone to the next event
|
||||
// fKill // kill without stacking
|
||||
// }
|
||||
//
|
||||
// The parent_ID of the track indicates the origin of it:
|
||||
//
|
||||
// G4int parent_ID = aTrack->get_parentID();
|
||||
//
|
||||
// parent_ID = 0 : primary particle
|
||||
// > 0 : secondary particle
|
||||
// < 0 : postponed from the previous event
|
||||
|
||||
virtual void NewStage();
|
||||
//
|
||||
// This method is called by G4StackManager when the urgentStack
|
||||
// becomes empty and contents in the waitingStack are transferred
|
||||
// to the urgentStack.
|
||||
// Note that this method is not called at the begining of each
|
||||
// event, but "PrepareNewEvent()" is called.
|
||||
//
|
||||
// In case re-classification of the stacked tracks is needed,
|
||||
// use the following method to request to G4StackManager:
|
||||
//
|
||||
// stackManager->ReClassify();
|
||||
//
|
||||
// All of the stacked tracks in the waitingStack will be re-classified
|
||||
// by "ClassifyNewTrack()" method.
|
||||
// To abort current event, use the following method:
|
||||
//
|
||||
// stackManager->clear();
|
||||
//
|
||||
// Note that this way is valid and safe only for the case it is called
|
||||
// from this user class. The more global way of event abortion is:
|
||||
//
|
||||
// G4UImanager * UImanager = G4UImanager::GetUIpointer();
|
||||
// UImanager->ApplyCommand("/event/abort");
|
||||
|
||||
virtual void PrepareNewEvent();
|
||||
//
|
||||
// This method is called by G4StackManager at the beginning of
|
||||
// each event.
|
||||
// Be careful that the 'urgentStack' and the 'waitingStack' of
|
||||
// G4StackManager are empty at this moment, because this method
|
||||
// is called before accepting primary particles. Also, note that
|
||||
// the 'postponeStack' of G4StackManager may have some postponed
|
||||
// tracks.
|
||||
|
||||
protected:
|
||||
G4StackManager * stackManager;
|
||||
public:
|
||||
inline void SetStackManager(G4StackManager * value)
|
||||
{ stackManager = value; }
|
||||
|
||||
public: // with description
|
||||
//---------------------------------------------------------------
|
||||
// vitual methods to be implemented by user
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
virtual G4ClassificationOfNewTrack
|
||||
ClassifyNewTrack(const G4Track* aTrack);
|
||||
//
|
||||
// Reply G4ClassificationOfNewTrack determined by the
|
||||
// newly coming G4Track.
|
||||
//
|
||||
// enum G4ClassificationOfNewTrack
|
||||
// {
|
||||
// fUrgent, // put into the urgent stack
|
||||
// fWaiting, // put into the waiting stack
|
||||
// fPostpone, // postpone to the next event
|
||||
// fKill // kill without stacking
|
||||
// };
|
||||
//
|
||||
// The parent_ID of the track indicates the origin of it.
|
||||
//
|
||||
// G4int parent_ID = aTrack->get_parentID();
|
||||
//
|
||||
// parent_ID = 0 : primary particle
|
||||
// > 0 : secondary particle
|
||||
// < 0 : postponed from the previous event
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
virtual void NewStage();
|
||||
//
|
||||
// This method is called by G4StackManager when the urgentStack
|
||||
// becomes empty and contents in the waitingStack are transtered
|
||||
// to the urgentStack.
|
||||
// Note that this method is not called at the begining of each
|
||||
// event, but "PrepareNewEvent" is called.
|
||||
//
|
||||
// In case re-classification of the stacked tracks is needed,
|
||||
// use the following method to request to G4StackManager.
|
||||
//
|
||||
// stackManager->ReClassify();
|
||||
//
|
||||
// All of the stacked tracks in the waitingStack will be re-classified
|
||||
// by "ClassifyNewTrack" method.
|
||||
// To abort current event, use the following method.
|
||||
//
|
||||
// stackManager->clear();
|
||||
//
|
||||
// Note that this way is valid and safe only for the case it is called
|
||||
// from this user class. The more global way of event abortion is
|
||||
//
|
||||
// G4UImanager * UImanager = G4UImanager::GetUIpointer();
|
||||
// UImanager->ApplyCommand("/event/abort");
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
virtual void PrepareNewEvent();
|
||||
//
|
||||
// This method is called by G4StackManager at the begining of
|
||||
// each event.
|
||||
// Be careful that the urgentStack and the waitingStack of
|
||||
// G4StackManager are empty at this moment, because this method
|
||||
// is called before accepting primary particles. Also, note that
|
||||
// the postponeStack of G4StackManager may have some postponed
|
||||
// tracks.
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
|
||||
G4StackManager* stackManager = nullptr;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,54 +23,52 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// G4VPrimaryGenerator
|
||||
//
|
||||
// Class description:
|
||||
//
|
||||
// This is an abstract base class of all of primary generators.
|
||||
// This class has only one pure virtual method GeneratePrimaryVertex()
|
||||
// which takes a G4Event object and generates a primay vertex and
|
||||
// primary particles associate to the vertex
|
||||
|
||||
#ifndef G4VPrimaryGenerator_h
|
||||
#define G4VPrimaryGenerator_h 1
|
||||
// Author: Makoto Asai (SLAC)
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4VPrimaryGenerator_hh
|
||||
#define G4VPrimaryGenerator_hh 1
|
||||
|
||||
#include "G4ThreeVector.hh"
|
||||
|
||||
class G4Event;
|
||||
|
||||
// class description:
|
||||
//
|
||||
// This is an abstract base class of all of primary generators.
|
||||
// This class has only one pure virtual method GeneratePrimaryVertex()
|
||||
// which takes a G4Event object and generates a primay vertex and
|
||||
// primary particles associate to the vertex.
|
||||
//
|
||||
|
||||
class G4VPrimaryGenerator
|
||||
{
|
||||
public: // with description
|
||||
// static service method for checking a point is included in the (current) world
|
||||
static G4bool CheckVertexInsideWorld(const G4ThreeVector& pos);
|
||||
public:
|
||||
|
||||
public: // with description
|
||||
// Constructor and destrucot of this base class
|
||||
G4VPrimaryGenerator();
|
||||
virtual ~G4VPrimaryGenerator();
|
||||
G4VPrimaryGenerator();
|
||||
virtual ~G4VPrimaryGenerator();
|
||||
// Constructor and destructor
|
||||
|
||||
// Pure virtual method which a concrete class derived from this base class must
|
||||
// have a concrete implementation
|
||||
virtual void GeneratePrimaryVertex(G4Event* evt) = 0;
|
||||
static G4bool CheckVertexInsideWorld(const G4ThreeVector& pos);
|
||||
// Static service method for checking a point is included
|
||||
// in the (current) world
|
||||
|
||||
virtual void GeneratePrimaryVertex(G4Event* evt) = 0;
|
||||
// Pure virtual method which a concrete class derived from this
|
||||
// base class must implement
|
||||
|
||||
inline G4ThreeVector GetParticlePosition() { return particle_position; }
|
||||
inline G4double GetParticleTime() { return particle_time; }
|
||||
|
||||
inline void SetParticlePosition(G4ThreeVector aPosition)
|
||||
{ particle_position = aPosition; }
|
||||
inline void SetParticleTime(G4double aTime)
|
||||
{ particle_time = aTime; }
|
||||
|
||||
protected:
|
||||
G4ThreeVector particle_position;
|
||||
G4double particle_time;
|
||||
|
||||
public:
|
||||
G4ThreeVector GetParticlePosition()
|
||||
{ return particle_position; }
|
||||
G4double GetParticleTime()
|
||||
{ return particle_time; }
|
||||
void SetParticlePosition(G4ThreeVector aPosition)
|
||||
{ particle_position = aPosition; }
|
||||
void SetParticleTime(G4double aTime)
|
||||
{ particle_time = aTime; }
|
||||
|
||||
G4ThreeVector particle_position;
|
||||
G4double particle_time = 0.0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -23,45 +23,41 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
//---------------------------------------------------------------
|
||||
//
|
||||
// G4VUserEventInformation
|
||||
//
|
||||
// Class Description:
|
||||
// Class description:
|
||||
//
|
||||
// Abstract class which the user can derive his/her own concrete
|
||||
// class for toring user's information associating with a G4Event
|
||||
// class object.
|
||||
// Abstract class the user can derive from for tuning user's
|
||||
// information associating with a G4Event class object.
|
||||
//
|
||||
// It is user's responsibility to construct a concrete class object
|
||||
// and set the pointer to proper G4Event object.
|
||||
// It is user's responsibility to construct a concrete class object
|
||||
// and set the pointer to a proper G4Event object.
|
||||
//
|
||||
// To set a pointer of a concrete class object to G4Event in
|
||||
// G4UserEventingAction concrete implementation, given the G4Event
|
||||
// To set a pointer of a concrete class object to G4Event in
|
||||
// G4UserEventAction concrete implementation, given the G4Event
|
||||
// object is available only by "pointer to const", SetUserEventInformation()
|
||||
// method of G4EventManager is available.
|
||||
// Alternatively, the user may modify GenerateEvent() method of
|
||||
// Alternatively, the user may modify GenerateEvent() method of
|
||||
// his/her own RunManager.
|
||||
//
|
||||
// The concrete class object is deleted by Geant4 kernel when
|
||||
// The concrete class object is deleted by the Geant4 kernel when
|
||||
// associated G4Event object is deleted.
|
||||
|
||||
|
||||
#ifndef G4VUserEventInformation_H
|
||||
#define G4VUserEventInformation_H 1
|
||||
// Author: Makoto Asai (SLAC)
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef G4VUserEventInformation_hh
|
||||
#define G4VUserEventInformation_hh 1
|
||||
|
||||
class G4VUserEventInformation
|
||||
{
|
||||
public:
|
||||
|
||||
G4VUserEventInformation() {;}
|
||||
virtual ~G4VUserEventInformation() {;}
|
||||
|
||||
public:
|
||||
|
||||
virtual void Print() const = 0;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,29 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
#ifndef EventGenerator_DEBUG
|
||||
#define EventGenerator_DEBUG
|
||||
@@ -1,41 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
|
||||
///#define G4EVENTMANAGER_DEBUG 1
|
||||
///#define G4EVENTMANAGER_DEBUG_0 1
|
||||
#ifdef G4EVENTMANAGER_DEBUG
|
||||
#define G4EVENTMANAGER_DEBUG_0 1
|
||||
#endif
|
||||
|
||||
#include "trajectoryControl.hh"
|
||||
|
||||
//================ G4SmartStack ===================
|
||||
//
|
||||
//#define G4_USESMARTSTACK 1
|
||||
//
|
||||
|
||||
@@ -23,12 +23,10 @@
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
// Defines for Windows DLLs import/export
|
||||
//
|
||||
|
||||
// Author: G.Cosmo, CERN
|
||||
// --------------------------------------------------------------------
|
||||
#ifndef EVTDEFS_HH
|
||||
#define EVTDEFS_HH
|
||||
|
||||
@@ -47,4 +45,4 @@
|
||||
#define G4EVENT_DLL
|
||||
#endif
|
||||
|
||||
#endif /* G4EVTDEFS_HH */
|
||||
#endif /* EVTDEFS_HH */
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
//
|
||||
//
|
||||
////#define G4_STORE_TRAJECTORY 1
|
||||
|
||||
//#ifdef G4VISUALIZE
|
||||
//#ifndef G4_STORE_TRAJECTORY
|
||||
//#define G4_STORE_TRAJECTORY 1
|
||||
//#endif
|
||||
//#endif
|
||||
Reference in New Issue
Block a user