Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
B4PrimaryGeneratorAction Class Reference

#include <B4PrimaryGeneratorAction.hh>

Inheritance diagram for B4PrimaryGeneratorAction:
Collaboration diagram for B4PrimaryGeneratorAction:

Public Member Functions

 B4PrimaryGeneratorAction ()
 
virtual ~B4PrimaryGeneratorAction ()
 
virtual void GeneratePrimaries (G4Event *event)
 
void SetRandomFlag (G4bool value)
 
 B4PrimaryGeneratorAction ()
 
virtual ~B4PrimaryGeneratorAction ()
 
virtual void GeneratePrimaries (G4Event *event)
 
void SetRandomFlag (G4bool value)
 
 B4PrimaryGeneratorAction ()
 
virtual ~B4PrimaryGeneratorAction ()
 
virtual void GeneratePrimaries (G4Event *event)
 
void SetRandomFlag (G4bool value)
 
 B4PrimaryGeneratorAction ()
 
virtual ~B4PrimaryGeneratorAction ()
 
virtual void GeneratePrimaries (G4Event *event)
 
void SetRandomFlag (G4bool value)
 
- Public Member Functions inherited from G4VUserPrimaryGeneratorAction
 G4VUserPrimaryGeneratorAction ()
 
virtual ~G4VUserPrimaryGeneratorAction ()
 

Detailed Description

The primary generator action class with particle gum.

It defines a single particle which hits the calorimeter perpendicular to the input face. The type of the particle can be changed via the G4 build-in commands of G4ParticleGun class (see the macros provided with this example).

Definition at line 47 of file B4PrimaryGeneratorAction.hh.

Constructor & Destructor Documentation

B4PrimaryGeneratorAction::B4PrimaryGeneratorAction ( )

Definition at line 46 of file B4PrimaryGeneratorAction.cc.

48  fParticleGun(nullptr)
49 {
50  G4int nofParticles = 1;
51  fParticleGun = new G4ParticleGun(nofParticles);
52 
53  // default particle kinematic
54  //
55  auto particleDefinition
57  fParticleGun->SetParticleDefinition(particleDefinition);
58  fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
59  fParticleGun->SetParticleEnergy(50.*MeV);
60 }
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
CLHEP::Hep3Vector G4ThreeVector
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
int G4int
Definition: G4Types.hh:78
void SetParticleEnergy(G4double aKineticEnergy)
static G4ParticleTable * GetParticleTable()
static constexpr double MeV
Definition: G4SIunits.hh:214
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)

Here is the call graph for this function:

B4PrimaryGeneratorAction::~B4PrimaryGeneratorAction ( )
virtual

Definition at line 64 of file B4PrimaryGeneratorAction.cc.

65 {
66  delete fParticleGun;
67 }
B4PrimaryGeneratorAction::B4PrimaryGeneratorAction ( )
virtual B4PrimaryGeneratorAction::~B4PrimaryGeneratorAction ( )
virtual
B4PrimaryGeneratorAction::B4PrimaryGeneratorAction ( )
virtual B4PrimaryGeneratorAction::~B4PrimaryGeneratorAction ( )
virtual
B4PrimaryGeneratorAction::B4PrimaryGeneratorAction ( )
virtual B4PrimaryGeneratorAction::~B4PrimaryGeneratorAction ( )
virtual

Member Function Documentation

void B4PrimaryGeneratorAction::GeneratePrimaries ( G4Event event)
virtual

Implements G4VUserPrimaryGeneratorAction.

Definition at line 71 of file B4PrimaryGeneratorAction.cc.

72 {
73  // This function is called at the begining of event
74 
75  // In order to avoid dependence of PrimaryGeneratorAction
76  // on DetectorConstruction class we get world volume
77  // from G4LogicalVolumeStore
78  //
79  G4double worldZHalfLength = 0.;
80  auto worldLV = G4LogicalVolumeStore::GetInstance()->GetVolume("World");
81 
82  // Check that the world volume has box shape
83  G4Box* worldBox = nullptr;
84  if ( worldLV ) {
85  worldBox = dynamic_cast<G4Box*>(worldLV->GetSolid());
86  }
87 
88  if ( worldBox ) {
89  worldZHalfLength = worldBox->GetZHalfLength();
90  }
91  else {
93  msg << "World volume of box shape not found." << G4endl;
94  msg << "Perhaps you have changed geometry." << G4endl;
95  msg << "The gun will be place in the center.";
96  G4Exception("B4PrimaryGeneratorAction::GeneratePrimaries()",
97  "MyCode0002", JustWarning, msg);
98  }
99 
100  // Set gun position
101  fParticleGun
102  ->SetParticlePosition(G4ThreeVector(0., 0., -worldZHalfLength));
103 
104  fParticleGun->GeneratePrimaryVertex(anEvent);
105 }
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
CLHEP::Hep3Vector G4ThreeVector
Definition: G4Box.hh:64
virtual void GeneratePrimaryVertex(G4Event *evt)
G4double GetZHalfLength() const
G4LogicalVolume * GetVolume(const G4String &name, G4bool verbose=true) const
void SetParticlePosition(G4ThreeVector aPosition)
static G4LogicalVolumeStore * GetInstance()
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76

Here is the call graph for this function:

virtual void B4PrimaryGeneratorAction::GeneratePrimaries ( G4Event event)
virtual
virtual void B4PrimaryGeneratorAction::GeneratePrimaries ( G4Event event)
virtual
virtual void B4PrimaryGeneratorAction::GeneratePrimaries ( G4Event event)
virtual
void B4PrimaryGeneratorAction::SetRandomFlag ( G4bool  value)
void B4PrimaryGeneratorAction::SetRandomFlag ( G4bool  value)
void B4PrimaryGeneratorAction::SetRandomFlag ( G4bool  value)
void B4PrimaryGeneratorAction::SetRandomFlag ( G4bool  value)

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