|
|
|
|
|
Introduction to Geant4
Lectures by Andrea dell'Acqua (CERN)
From the Ann Arbor Workshop on Geant4 26 February to 2 March, 2001.
|
|
Exercise N04
Exercise number 4 comes from Lecture 10, Kinematics, beginning on slide number 12.
Steps ExN04
The aim of the exercise is to implement a PrimaryGeneratorAction, 4-p generator (flat generation of particles in eta-phi).Definitions
- Use G4ParticleGun as a first attempt (the test beam generator is trivial in this case).
- Now try and implement your own PrimaryGenerator.
- Use G4UniformRand(), from Randomize.hh, if you need a random number generator (flat distribution in ]0,1[ ).
Helpful Links
- The G4VUserPrimaryGeneratorAction is one of the mandatory classes the user has to derive a concrete class from.
- G4VUserPrimaryGeneratorAction has a pure virtual method named GeneratePrimaries(), invoked at the beginning of each event. This method receives (as an argument) a pointer to the current G4Event which must be filled with particles that will then be traced through the detector.
GeneratePrimaries(G4Event* anEvent);
- The Primary Event (kinematics) is made of G4Primary Particles.
- Primary Particles are associated to their production vertex (of type G4PrimaryVertex).
- The GeneratePrimaries(), in G4VPrimaryGeneratorAction, is invoked at the beginning of each event to fill up a G4Event with particles to be tracked through the simulated detector.
- An abstract generator class, G4VPrimaryGenerator, is provided by Geant4 for users to inherit from so they may implement their preferred way of generating an event. It provides the possibility of having different ways of generating the kinematics of an event available in the same simulation program.
- G4ParticleGun is a primary particle generator provided by Geant4. It generates primary particles with a given momentum and position.
Checklist
- To see examples of primary particles and how they are associated to the primary vertex by the means of AddPrimaryVertex, view slide number 3.
- To see how to implement the purely abstract method of G4VPrimaryGenerator, begin with slide number 4.
- For an example of PrimaryGeneratorAction, start on slide number 5.
- To see an example of PrimaryGenerator, look on slide number 9.
- To see the methods provided for G4ParticleGun, view slide number 11.
- Is the primary generator selected in the constructor of the concrete class derived from G4VUserPrimaryGeneratorAction?
- Is the particle generator destroyed in the destructor? It needs to be.
- In the method, GeneratePrimaries(), one must invoke the GeneratePrimaryVertex() method of the G4VPrimaryGenerator concrete class that was instantiated. Did you remember to do this?
- Did you invoke several of G4ParticleGun's methods in order to have randomization of energy, momentum and position? See slide number 11 for the methods provided for G4ParticleGun.
Back to the Geant4 Lectures
![]()
For information: wlap@umich.edu http://www.umich.edu/~wlap Last modified: syscmd(date)