Exercises and Solutions - Day 2
Exercises:
Exercises of the day
Exercises and solutions - Part I
The solutions are indicated in blue.
Part I - Introductory exercises
Exercise 2-1
Get familiar with the classes of the example application, which are subject of
the exercises.
The following diagram shows the class hierarchy of the detector (click here for a pdf file):
The class hierarchy of the primary generator is shown in the second diagram (click here for a pdf file):
Answer the following questions:
- What are the base classes of the following user classes?
- DetectorConstrution G4VUserDetectorConstruction.
- PrimaryGenerator G4VUserPrimaryGeneratorAction.
- Which of above classes is mandatory for a Geant4 application?
They are both mandatory, and they must be registered to the G4RunManager in the main()
program.
- Which virtual method do you have to overload in your DetectorConstruction? What does it return?
It is Construct(), and it returns the pointer to the physical world volume.
- Which virtual method do you have to overload in your PrimaryGenerator? What does it do?
It is GeneratePrimaries(G4Event*). It defines the primary event (particle, energy,
direction, etc.) and eventually generates the primary vertex.
- What are the ways to define a G4Material (molecule, mixture or compound)?
A material consisting of one element (e.g. copper), can be defined directly
as G4Material(G4String name,G4double Z,G4double A,G4double density).
Molecules and mixtures must
be built up by their constituent element (using number of atoms and mass fraction, respectively):
elements are added using methods AddElement(G4Element* element,G4int number_of_atoms) and
AddElement(G4Element* element,G4double mass_fraction), respectively.
For compounds, G4Materials
can be added using method AddMaterial(G4Material* material_to_add,G4double mass_fraction).
- What are the mandatory ingredients to define a G4Material? And the optional ones?
Mandatory: constituent elements (for mixtures: the mass fractions must sum up to 100%)
and density.
Optional: temperature, pressure, physics state.
- What are the G4VSolids to be used for boxes, cylinders and spheres?
G4Box, G4Tubs and G4Sphere
- How would you define a cylindrical sector of opening angle pi/4?
new G4Tubs(name="myTube", innerRadius=0.*cm, outerRadius=10.0*cm, height=10.0*cm,
startAngle=0,stopAngle=pi/4.);
- What is the difference between a solid and a logical volume?
A solid is a "geometrical
volume", in the sense that is is responsible for information only on the
shape and size of the volume.
A logical volume accounts also for other
properties: material, visualization attributes,
sensitivity attributes, magnetic field.
- What's the difference between a logical and a physical volume?
A physical volume is the "final" volume. In addition to its logical volume it
contains information on the placement and on the mother volume.
- What does it mean that a volume is the daughter of another one?
It means that the daughter volume is completely included in the mother volume. Daughter
is in the lower level of the hierarchy tree. Common points belong to the daughter.
- Is it possible for a volume to protrude from its mother?
No. This should be carefully avoided.
- Sensitive and visualization attributes are attached to the logical or to the physical volumes?
To logical volumes.
- What is the concrete generator (namely, inheriting from G4VPrimaryGenerator) used in the tutorial
example to shoot primary particles?
G4ParticleGun
- How can you get a pointer to the electron G4ParticleDefinition?
G4Electron::ElectronDefinition()