Session 3 : Enoncé

Code for download: session3_start.tar.gz

Exercise:

  • Change primary generator class with use of G4ParticleGun.
    See eg. example basic/B1. (see in Geant4 documentation)
  • Update run.mac and add runs with following primaries:
    proton, positron, pion-, muon+
    Run the macro from your interactive session (Qt).
  • Add a possibility to randomize particle direction with theta in [0,2*deg], phi [0.,360*deg].
    See example basic/B3.
  • Implement a command to select the randomize option using G4GenericMessenger.
    See B4aEventAction in basic/B4/B4a.
  • Activate storing of random generator status, run simulation with a retrieved status and check results:
    • A) Interactively
      1. Start application and run command:
        /random/setSavingFlag true
      2. Select a particle type and run 3 events:
        /gun/particle proton
        /run/beamOn 3
        Copy currentRun.rndm in Run0.rndm (by hand) and save a scene with 3 events.
      3. Run more events with varying the primary particle, eg. run your run.mac.
      4. 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.
    • B) Using the provided EDRunAction class after having implemented necessary commands for activating storing and retrieving random number generator status

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.

  • Add another primary generator class with use of G4GenericParticleSource.