Geant4 11.3.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4VPrimaryGenerator Class Referenceabstract

#include <G4VPrimaryGenerator.hh>

+ Inheritance diagram for G4VPrimaryGenerator:

Public Member Functions

 G4VPrimaryGenerator ()=default
 
virtual ~G4VPrimaryGenerator ()=default
 
virtual void GeneratePrimaryVertex (G4Event *evt)=0
 
G4ThreeVector GetParticlePosition ()
 
G4double GetParticleTime ()
 
void SetParticlePosition (G4ThreeVector aPosition)
 
void SetParticleTime (G4double aTime)
 
void CheckInside (G4bool val=true)
 
G4bool IfCheckInside ()
 

Static Public Member Functions

static G4bool CheckVertexInsideWorld (const G4ThreeVector &pos)
 

Protected Attributes

G4ThreeVector particle_position
 
G4double particle_time = 0.0
 
G4bool ifCheckInside = true
 

Detailed Description

Definition at line 44 of file G4VPrimaryGenerator.hh.

Constructor & Destructor Documentation

◆ G4VPrimaryGenerator()

G4VPrimaryGenerator::G4VPrimaryGenerator ( )
default

◆ ~G4VPrimaryGenerator()

virtual G4VPrimaryGenerator::~G4VPrimaryGenerator ( )
virtualdefault

Member Function Documentation

◆ CheckInside()

void G4VPrimaryGenerator::CheckInside ( G4bool val = true)
inline

Definition at line 73 of file G4VPrimaryGenerator.hh.

74 { ifCheckInside = val; }

◆ CheckVertexInsideWorld()

G4bool G4VPrimaryGenerator::CheckVertexInsideWorld ( const G4ThreeVector & pos)
static

Definition at line 38 of file G4VPrimaryGenerator.cc.

39{
40 // Check can only happen if run has been initialised
41 //
42 if (G4StateManager::GetStateManager()->GetCurrentState() != G4State_Idle)
43 {
44 return true;
45 }
46
48 -> GetNavigatorForTracking();
49 G4VPhysicalVolume* world= navigator-> GetWorldVolume();
50 G4VSolid* solid = world-> GetLogicalVolume()-> GetSolid();
51 EInside qinside = solid-> Inside(pos);
52
53 return qinside == kInside;
54}
@ G4State_Idle
static G4StateManager * GetStateManager()
static G4TransportationManager * GetTransportationManager()
EInside
Definition geomdefs.hh:67
@ kInside
Definition geomdefs.hh:70

Referenced by SetParticlePosition().

◆ GeneratePrimaryVertex()

virtual void G4VPrimaryGenerator::GeneratePrimaryVertex ( G4Event * evt)
pure virtual

◆ GetParticlePosition()

G4ThreeVector G4VPrimaryGenerator::GetParticlePosition ( )
inline

Definition at line 60 of file G4VPrimaryGenerator.hh.

60{ return particle_position; }
G4ThreeVector particle_position

◆ GetParticleTime()

G4double G4VPrimaryGenerator::GetParticleTime ( )
inline

Definition at line 61 of file G4VPrimaryGenerator.hh.

61{ return particle_time; }

◆ IfCheckInside()

G4bool G4VPrimaryGenerator::IfCheckInside ( )
inline

Definition at line 75 of file G4VPrimaryGenerator.hh.

76 { return ifCheckInside; }

◆ SetParticlePosition()

void G4VPrimaryGenerator::SetParticlePosition ( G4ThreeVector aPosition)

Definition at line 56 of file G4VPrimaryGenerator.cc.

57{
58 if (ifCheckInside && !CheckVertexInsideWorld(aPosition))
59 {
61 ed << "Invalid vertex position (" << aPosition << "). "
62 << "Position MUST be located -inside- the world volume." << G4endl
63 << "Gun position has NOT been changed!";
64 G4Exception("G4VPrimaryGenerator::SetParticlePosition",
65 "Event0401", JustWarning, ed);
66 return;
67 }
68 particle_position = aPosition;
69}
@ JustWarning
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
std::ostringstream G4ExceptionDescription
#define G4endl
Definition G4ios.hh:67
static G4bool CheckVertexInsideWorld(const G4ThreeVector &pos)

◆ SetParticleTime()

void G4VPrimaryGenerator::SetParticleTime ( G4double aTime)
inline

Definition at line 70 of file G4VPrimaryGenerator.hh.

71 { particle_time = aTime; }

Member Data Documentation

◆ ifCheckInside

G4bool G4VPrimaryGenerator::ifCheckInside = true
protected

Definition at line 82 of file G4VPrimaryGenerator.hh.

Referenced by CheckInside(), IfCheckInside(), and SetParticlePosition().

◆ particle_position

◆ particle_time


The documentation for this class was generated from the following files: