FairRoot
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Tutorial1:

How to implement a simple detector using the old ASCII interface to describe the geometry (see Detector Geometry and Media for more details about this geometry interface) See also Adding new detector for a detailed description of the detector class implementation, MC point class and the CMakeLists.txt

To run this tutorial:

After building FairRoot successfully go to the build directory and call the configuration script (config.sh or config.csh according to our shell) cd to the Tutorial1/macros directory run the following command: root run_tutorial1.C (you can also load the macro into root and then run it) This will start a simulation session with Geant3 and create 10 events generated by a box generator, the input in the box generator can be chosen by the user, by default in this macro we use "pions" (see macro lines 20-22) for details. To choose Geant4 you just have to change TGeant3 to TGeant4 in line 8 of the macro, or of you are loading the macro to root before exciting it you just give TGeant4 as second argument to the run_tutorial1 call, i.e:

```bash root>.L run_tutorial1.C root>run_tutorial(10, "TGeant4") ```

Fast simulation of a detector

Fast simulation should be implamented within the user class derived from FairFastSimDetector. In this tutorial there are two examples of such user class: FairFastSimExample and FairFastSimExample2. They differ only in the position of the region for the fast simulation. Methods, which need to be overwritten by deriving from FairFastSimDetector:

  • Initialize() - initialization
  • Register() - register output in FairRootManager
  • ConstructGeometry - define the region for the fast simulation. It should be a single active volume. Use fFastSimMedium data member as the medium.
  • EndOfEvent() - called after each event
  • Reset() - clear the array with output
  • TClonesArray* GetCollection(Int_t iColl) - return the pointer to output array with MC points.
  • FastSimProcessParticle() - implementation of fast simulation algorithm for a single particle. Called when a track is entering the region defined in ConstructGeometry(). After simulation of the detector response, the particle should be transported outside the region or killed. For that use: ``` FairStack* stack = static_cast<FairStack*>(TVirtualMC::GetMC()->GetStack()); stack->FastSimMoveParticleTo(Double_t xx, Double_t yy, Double_t zz, Double_t tt, Double_t px, Double_t py, Double_t pz, Double_t en); // or stack->FastSimStopParticle(); ```

Macro to run the example with fast simulation: run_tutorial1_fastsim.C

Seed for the random number generator

``` TRandom3 random(seed); gRandom = run->Init(); ```