2020 Session 1 : Exercise

Code for download: session1_start.tar.gz


  • Geant4 is already installed on the machines in the directory /usr/local. Please, do not forget to run the Geant4 script to define the environment needed to build & run Geant4 application; for example is you isntalled Geant4 in /usr/local/bin:
    . /usr/local/bin/geant4.sh
  • Build & run the example:
    • Download the start source code session1_start.tar.gz. (On MacOS, the file will be saved as session1_start.tar.gz in $HOME/Downloads directory.)
    • Untar the file:
      tar xvf session1_start.tar.gz
    • Rename the session1_start directory as exampleED:
      mv session1_start exampleED
    • Create the example build directory, run cmake and make to build the application: 
      mkdir exampleED_build
      cd exampleED_build
      cmake ../exampleED
    • Run the created executable:

  • Get familiar with the provided code
    • You can skip EDDetectorConstruction.cc and EDPrimaryGeneratorAction.cc which will be explored later
  • Get familiar with Geant4 Qt User Interface
    • Use the provided button (an arrow in a green circle) to run 1 event, observe the picture and the output in the Output window.
    • Run 1 event from the command line. You have to type this command in the Session window:
      /run/beamOn 1
    • Run 1 event via a selection of the command from the Help menu.
    • Set tracking verbose level to 1 and observe the output:
      /tracking/verbose 1
  • Add printing of the event number at the begin of event and another printing about the end of event in the EDEventAction class:
    G4cout << ">>> Start event: " << event->GetEventID() << G4endl;
    G4cout << ">>> End event: " << event->GetEventID() << G4endl;

    • Hint: Each line of the code above should be inserted in the relevant function of the EDEventAction class in the EDEventAction.cc file.

Solution: session1_solution.tar.gz