Code for download: session3_start.tar.gz
Exercise:
- Change primary generator class with use of
G4ParticleGun
.
See eg. example basic/B1 README page and its B1PrimaryGenerator class - Update
run.mac
and add runs with following primaries:
proton, positron, pion-, muon+
Run the macro from your interactive session (Qt). - Add randomizing the particle direction with
theta in [0,2*deg], phi [0.,360*deg]
.
See example basic/B3 README page and its B3PrimaryGenerator class - Inspect the implementation of a command using
G4GenericMessenger
in theEDEventAction
class, execute the command to inactivate verbose mode and run a new event - Make randomizing of the particle direction optional, and then implement a command to select the randomize option using
G4GenericMessenger
in an analogous way as the command in EDEventAction - Activate interactively storing of random generator status, run simulation with a retrieved status and check results:
- Start application and run command:
/random/setSavingFlag true
- Select a particle type and run 3 events:
/gun/particle proton
/run/beamOn 3
CopycurrentRun.rndm
inRun0.rndm
(by hand) and save a scene with 3 events. - Run more events with varying the primary particle, eg. run your
run.mac
. - Restore random status from the
Run0.rndm
file:/random/resetEngineFrom Run0.rndm
repeat commands in step 2) and compare the scene with the saved one.
- Start application and run command:
Solution: session3_solution.tar.gz
Exercise ++:
The exercises marked as ++ are optional; they are recommended for participants who have already some experience with Geant4 and get some time left for practicing more than the basic exercise proposed above.
- Implement necessary commands for activating storing and retrieving random number generator status in the provided
EDRunAction
class. Then to test your implementation, activate storing of random generator status, run simulation with a retrieved status and check results. - Add another primary generator class with use of
G4GenericParticleSource
.