musrsim/geant4/TaoLEMuSR/doc/vocabulary.dox
2008-03-20 09:23:20 +00:00

62 lines
4.6 KiB
Plaintext

/*! @page Voc Vocabulary and Notions
<BR>
<B> Previous:</B> @ref sAbout
<B> Up:</B> @ref Intro
<B> Next:</B> @ref lemutree
<BR>
<HR>
@section sVoc Preliminary Vocabulary
Before going any further, we should familiarize ourselves with some basic vocabulary. In this report we will encounter some words taken from C++ language, and others related to Geant4 architecture. Let us have a brief description of them.
\subsection cppwords C++ words
* - Class: a class is the definition of a collection of variables or functions called the <I>members</I> of the class. For example the class <I>Particle</I> has for members: mass, lifetime, charge ...In other words, the class defines a type of variable with parameters that can be specified.
* - Instance, object: in order to use a class in a program one may create an instance, or object, of it. For example <I>Particle particle1</I> will create a variable of the type Particle. It is then possible to set all the parameters of the object particle1 and to use it independently in the program.
* - Inheritance: it is possible to build subclasses. For example, <I>Lepton</I> would be a subclass of <I>Particle</I> class. Instead of building a completely new class, one just has to give <I>Lepton</I> class all the caracteristics of a <I>Particle</I> and add the properties which make a particle a lepton. We say that <I>Lepton</I> class <I>inherits</I> from <I>Particle</I> class.
* - Virtual method: in the same register as inheritance concept has been created so-called <i>vitual</i> methods. Those are functions declared in the mother class but which is not or only partially implemented. They can be overriden in a subclass. The advantage of those virtual method is that each subclass will have it own implementation of the same base function. Then the name of the function can be used in a general way without having to worry about which subclass we are dealing with.
A good example is the construction of the detector geometry. The class LEMuSRDetectorConstruction is a subclass G4VUserDetectorConstruction. In order to build the detector, the user has to give geant4 an object of type G4VUserDetectorConstruction. This is done in the main file LEMusR.cc. When initializing the simulation geant4 calls the method G4UserDetectorConstruction::Construct(). This method is virtual but implemented in the LEMuSRDetectorConstruction class and therefore the user's detector geometry will be built.
\subsection g4words Geant4 words
* - Run: this is the word for a the simulation process.
* - Event: during a run, one can shoot as many particles as needed. An event is the simulation of all the primary particles. Before the run the user specifies the number of primary particles shoot per Event as well as the number of events.
* - Track: this is the information collection of one particle tracking
* - Step: step by step, a track is build. At each step the simulation engine is called to decide the process that the particle will suffer, this in accordance to cross-sections or priority orders defined by the user.
@section sVocb Usefull notions of C++ language
\subsection Header files and source codes files
Geant4 is a C++ toolkit and one need to write both a header and a source files for each object class.
The header file contains the declaration of all methods and variables that are specific to the class that is being defined. One also have to specify all the other classes from which his class inherits. Finally, one should indicate if the methods and variables are public (can be seen and get their values modified by other methods) or private (excusive appartenance to the class). Header files are located in the $LEMU/include directory.
The source file contains the code of each method. These files are located in the $LEMU/source directory.
\anchor virtual_classes
\subsection The inheritance philosophy
A base class (a class from which other classes derive) can present so-called <I><B>virtual</B></I> methods. That means that these methods can be re-written when defining a daughter class: in C++ language, we say that virtual methods can be <i>overloaded</i>. Virtual methods are the key of Geant4 framework modularity: many of Geant4 classes can be personalized by the user. They are called \b virtual \b classes.
One only has to build a daughter class of those classes and overload the virtual methods, making sure to keep their name exact because they are called at other places of the framework. It is also possible to add new methods and variables at will.
For example, the method in charge of building the geometry must be called <I>Construct()</I>, and the messengers methods in charge of modifying parameters must have the name <I>SetNewValue()</I>.
*/