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

#include <Par02PrimaryGeneratorAction.hh>

Inheritance diagram for Par02PrimaryGeneratorAction:
Collaboration diagram for Par02PrimaryGeneratorAction:

Public Member Functions

 Par02PrimaryGeneratorAction ()
 
 ~Par02PrimaryGeneratorAction ()
 
virtual void GeneratePrimaries (G4Event *anEvent)
 
G4ParticleGunGetParticleGun ()
 
- Public Member Functions inherited from G4VUserPrimaryGeneratorAction
 G4VUserPrimaryGeneratorAction ()
 
virtual ~G4VUserPrimaryGeneratorAction ()
 

Detailed Description

Construction of a primary generation action.

For simplicity, we use here the particle gun, but in the original application for FCC (developed by Anna Zaborowska), the Monte Carlo event generator Pythia8 is used as generator and it is interfaced to Geant4 via HepMC.

Definition at line 46 of file Par02PrimaryGeneratorAction.hh.

Constructor & Destructor Documentation

Par02PrimaryGeneratorAction::Par02PrimaryGeneratorAction ( )

Definition at line 42 of file Par02PrimaryGeneratorAction.cc.

42  {
43  G4int n_particle = 1;
44  fParticleGun = new G4ParticleGun( n_particle );
45 
47  G4String particleName;
48  G4ParticleDefinition* particle =
49  particleTable->FindParticle( particleName = "geantino" );
50  fParticleGun->SetParticleDefinition( particle );
51 
52  fParticleGun->SetParticleMomentumDirection( G4ThreeVector( 0.0, 1.0, 0.0 ) );
53  fParticleGun->SetParticleEnergy( 100.0*GeV );
54  fParticleGun->SetParticlePosition( G4ThreeVector( 0.0, 0.0, 0.0 ) );
55 }
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
CLHEP::Hep3Vector G4ThreeVector
void SetParticleMomentumDirection(G4ParticleMomentum aMomentumDirection)
int G4int
Definition: G4Types.hh:78
void SetParticlePosition(G4ThreeVector aPosition)
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:

Par02PrimaryGeneratorAction::~Par02PrimaryGeneratorAction ( )

Definition at line 59 of file Par02PrimaryGeneratorAction.cc.

59  {
60  delete fParticleGun;
61 }

Member Function Documentation

void Par02PrimaryGeneratorAction::GeneratePrimaries ( G4Event anEvent)
virtual

Implements G4VUserPrimaryGeneratorAction.

Definition at line 65 of file Par02PrimaryGeneratorAction.cc.

65  {
66  fParticleGun->GeneratePrimaryVertex( anEvent );
67 
68  // Loop over the vertices, and then over primary particles,
69  // and for each primary particle create an info object, in
70  // which to store "Monte Carlo true" information.
71  // This approach could appear unnecessarily heavy in the present case
72  // of a trivial particle gun generator, but it is useful in the more
73  // realistic case of a Monte Carlo event generator like Pythia8.
74  G4int count_particles = 0;
75  for ( G4int ivtx = 0; ivtx < anEvent->GetNumberOfPrimaryVertex(); ivtx++ ) {
76  for ( G4int ipp = 0; ipp < anEvent->GetPrimaryVertex( ivtx )->GetNumberOfParticle();
77  ipp++ ) {
78  G4PrimaryParticle* primary_particle =
79  anEvent->GetPrimaryVertex( ivtx )->GetPrimary( ipp );
80  if ( primary_particle ) {
82  count_particles, primary_particle->GetPDGcode(),
83  primary_particle->GetMomentum() ) );
84  count_particles++;
85  }
86  }
87  }
88 }
G4int GetNumberOfParticle() const
G4ThreeVector GetMomentum() const
void SetUserInformation(G4VUserPrimaryParticleInformation *anInfo)
G4int GetNumberOfPrimaryVertex() const
Definition: G4Event.hh:164
int G4int
Definition: G4Types.hh:78
virtual void GeneratePrimaryVertex(G4Event *evt)
G4PrimaryParticle * GetPrimary(G4int i=0) const
G4PrimaryVertex * GetPrimaryVertex(G4int i=0) const
Definition: G4Event.hh:167
G4int GetPDGcode() const

Here is the call graph for this function:

G4ParticleGun * Par02PrimaryGeneratorAction::GetParticleGun ( void  )

Definition at line 92 of file Par02PrimaryGeneratorAction.cc.

92  {
93  return fParticleGun;
94 }

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