Introduction
Today's exercises cover the following items:
- Sensitive Detector and Readout Geometry
- Hits and Hits Collection
- Retrieval of information from tracks, steps and particle classes
- Simple data analysis
The Geant4 application example, which is presented on the main page, serves again as the basis of the exercises. Do not use the example with your modifications from the last two days, but download again the original tar-ball (you may find the instructions on the main page).
The exercises include the modification and/or extension of the following classes:
Part I - Introductory exercises
Exercise 4-1
Get familiar with the classes of the example application, which are subject of the exercises (see the list above). Also try to understand the class hierarchies (abstract base class, concrete user implementation) of the relevant classes (see the below diagrams).
The following diagram shows the class hierarchy of the sensitive detector, hit, hits collection and readout geometry (click here for a pdf file):
The class hierarchy of user event action classes is shown in the second diagram (click here for a pdf file):
Answer following questions:
- What are the base classes of the following user classes?
- SensitiveDetector
- DetectorReadOutGeometry
- DetectorHit
- UserEventAction
- Try to remember: Which of above classes is mandatory for a Geant4 application?
- Does a sensitive detector require a readout geometry?
- What is the primary mandate of a sensitive detector?
- Which method of the sensitive detector (SD) is called for each particle step inside the logical volume the SD is attached to (provided the track is alive)?
- In which member function of the DetectorReadOutGeometry class is the readout geometry constructed? What is the return value of this function?
- The readout geometry uses replicas of thin slices. Along which coordinate axis are the slices placed?
- The hit class of our example is capable of storing two different quantities. What are they?
- When are hit objects created in our application example:
- At the beginning of an event,
- at the end of an event,
- at the beginning of a step or
- at the end of a step?
- At what level of tracking is the information of hits filled into analysis objects in our simulation application: Step, Event or Run?
- What are the names of the member functions, where DetectorHit objects are created and filled, and where the hit information filled into analysis objects?
- A G4Event object holds a pointer to a class which stores all hits collections at the end of an event. What is the name of this class?
- What is required to retrieve the pointer to a hits collection from this class: The hits collection name or the collection index?
Part II - Sensitive Detector and Hits
Exercise 4-2*
Extend the functionality of the hit class, in order that lateral coordinates (x and y) of hits can also be stored. Implement appropriate get and set functions. Moreover extend the copy constructor and the assignment operator accordingly.
- Note: This exercise only affects the hit class, but not the sensitive detector. The introduced functionalities will be used in the next exercise.
Exercise 4-3
This exercise provides a transition to part III (The topics covered in part II and III are closely linked, since the functionality of sensitive detectors allows to keep track of information which is basically retrieved from objects of classes like G4Track, G4Step or G4DynamicParticle):
In the ProcessHits method of your sensitive detector, retrieve the lateral coordinates of the particle step, and store them in the modified Hit class by using the new get functions.
- From which step-point do you need to retrieve the information?
- Note: You don't need the readout geometry for this example.
- Hint: The G4ThreeVector class provides the following methods to retrieve
the x, y and z coordinates: x(), y() and z().
Part III - Retrieval of information from tracks, steps and particle classes
Exercise 4-4
Introduce a conditional statement in the ProcessHits method of the sensitive detector, in order that hits are only created for primary particle tracks:
- How can primary particle tracks be distinguished from secondary particle tracks?
Exercise 4-5
Modify the conditional statement of the previous example, in order that hits are only created for secondary gammas:
- How can you check the particle type?
Exercise 4-6
You can find here the header file for a user tracking action class (the Geant4 exercise example does not yet included a user tracking action). The aim is to complete the class implementation and to integrate the class into the existing application:
- Class implementation:
Introduce a counting mechnism in the method PostUserTrackingAction, which keeps track of the total number of secondary electrons produced in the simulation:
- Create a new source file UserTrackingAction.cc, which contains the implementation of this function.
- The class definition already contains a data member "counter" of type G4int, which should be used to accumulate the number of secondary electrons.
- Don't forget to initialize the counter.
- Integration of user action class into the example:
- Where do you have to instantiate and register the user tracking action class?