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

#include <B2PrimaryGeneratorAction.hh>

Inheritance diagram for B2PrimaryGeneratorAction:
Collaboration diagram for B2PrimaryGeneratorAction:

Public Member Functions

 B2PrimaryGeneratorAction ()
 
virtual ~B2PrimaryGeneratorAction ()
 
virtual void GeneratePrimaries (G4Event *)
 
G4ParticleGunGetParticleGun ()
 
void SetRandomFlag (G4bool)
 
 B2PrimaryGeneratorAction ()
 
virtual ~B2PrimaryGeneratorAction ()
 
virtual void GeneratePrimaries (G4Event *)
 
G4ParticleGunGetParticleGun ()
 
void SetRandomFlag (G4bool)
 
 B2PrimaryGeneratorAction ()
 
virtual ~B2PrimaryGeneratorAction ()
 
virtual void GeneratePrimaries (G4Event *)
 
G4ParticleGunGetParticleGun ()
 
void SetRandomFlag (G4bool)
 
- 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 Tracker 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 B2PrimaryGeneratorAction.hh.

Constructor & Destructor Documentation

B2PrimaryGeneratorAction::B2PrimaryGeneratorAction ( )

Definition at line 46 of file B2PrimaryGeneratorAction.cc.

48 {
49  G4int nofParticles = 1;
50  fParticleGun = new G4ParticleGun(nofParticles);
51 
52  // default particle kinematic
53 
54  G4ParticleDefinition* particleDefinition
56 
57  fParticleGun->SetParticleDefinition(particleDefinition);
58  fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.,0.,1.));
59  fParticleGun->SetParticleEnergy(3.0*GeV);
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 GeV
Definition: G4SIunits.hh:217
void SetParticleDefinition(G4ParticleDefinition *aParticleDefinition)

Here is the call graph for this function:

B2PrimaryGeneratorAction::~B2PrimaryGeneratorAction ( )
virtual

Definition at line 64 of file B2PrimaryGeneratorAction.cc.

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

Member Function Documentation

void B2PrimaryGeneratorAction::GeneratePrimaries ( G4Event anEvent)
virtual

Implements G4VUserPrimaryGeneratorAction.

Definition at line 71 of file B2PrimaryGeneratorAction.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  G4LogicalVolume* worldLV
82  G4Box* worldBox = NULL;
83  if ( worldLV ) worldBox = dynamic_cast<G4Box*>(worldLV->GetSolid());
84  if ( worldBox ) worldZHalfLength = worldBox->GetZHalfLength();
85  else {
86  G4cerr << "World volume of box not found." << G4endl;
87  G4cerr << "Perhaps you have changed geometry." << G4endl;
88  G4cerr << "The gun will be place in the center." << G4endl;
89  }
90 
91  fParticleGun->SetParticlePosition(G4ThreeVector(0., 0., -worldZHalfLength));
92 
93  fParticleGun->GeneratePrimaryVertex(anEvent);
94 }
CLHEP::Hep3Vector G4ThreeVector
Definition: G4Box.hh:64
G4VSolid * GetSolid() const
virtual void GeneratePrimaryVertex(G4Event *evt)
G4double GetZHalfLength() const
G4LogicalVolume * GetVolume(const G4String &name, G4bool verbose=true) const
void SetParticlePosition(G4ThreeVector aPosition)
static G4LogicalVolumeStore * GetInstance()
#define G4endl
Definition: G4ios.hh:61
double G4double
Definition: G4Types.hh:76
G4GLOB_DLL std::ostream G4cerr

Here is the call graph for this function:

virtual void B2PrimaryGeneratorAction::GeneratePrimaries ( G4Event )
virtual
virtual void B2PrimaryGeneratorAction::GeneratePrimaries ( G4Event )
virtual
G4ParticleGun* B2PrimaryGeneratorAction::GetParticleGun ( void  )
inline

Definition at line 55 of file B2PrimaryGeneratorAction.hh.

55 {return fParticleGun;}
G4ParticleGun* B2PrimaryGeneratorAction::GetParticleGun ( void  )
inline

Definition at line 55 of file B2PrimaryGeneratorAction.hh.

55 {return fParticleGun;}
G4ParticleGun* B2PrimaryGeneratorAction::GetParticleGun ( void  )
inline

Definition at line 55 of file B2PrimaryGeneratorAction.hh.

55 {return fParticleGun;}
void B2PrimaryGeneratorAction::SetRandomFlag ( G4bool  )
void B2PrimaryGeneratorAction::SetRandomFlag ( G4bool  )
void B2PrimaryGeneratorAction::SetRandomFlag ( G4bool  )

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