The simulation of particles traversing the detector components is performed by a class derived from
The Monte Carlos used in ALICE are GEANT 3.21, GEANT 4 and FLUKA. More information can be found on the VMC Web page: http://root.cern.ch/root/vmc
Virtual Monte Carlo
TVirtualMC . The Virtual Monte Carlo also provides an interface to construct the geometry of detectors. The task of the geometry description is done by the geometrical modeler TGeo . The concrete implementation of the virtual Monte Carlo application TVirtualMCApplication is AliMC.
Our strategy was to develop a virtual interface to the detector simulation code. We call the interface to the transport code virtual Monte Carlo. It is implemented via C++ virtual classes and is schematically shown in the figure:
Thanks to the virtual Monte Carlo we have converted all FORTRAN user code developed for GEANT 3 into C++, including the geometry definition and the user scoring routines, StepManager . These have been integrated in the detector classes of the AliRoot framework. The output of the simulation is saved directly with ROOT I/O, simplifying the development of the digitization and reconstruction code in C++.
Modules and Detectors
Each module of the ALICE detector is described by a class derived from AliModule . Classes for active modules (= detectors) are not derived directly from AliModule but from its subclass AliDetector . These base classes define the interface to the simulation framework via a set of virtual methods.
Configuration File (Config.C)
The configuration file is a C++ macro that is processed before the simulation starts. It creates and configures the Monte Carlo object, the generator object, the magnetic field map and the detector modules. A detailed description is given here.
Detector Geometry
The virtual Monte Carlo application creates and initializes the geometry of the detector modules by calling the virtual functions CreateMaterials , CreateGeometry , Init and BuildGeometry .
Hits and Track References
The Monte Carlo simulates the transport of a particle step by step. After each step the virtual method. For each detector methods like StepManager of the module in which the particle currently is located is called. In this step manager method, the hits in the detector are created by calling AddHit . Optionally also track references (location and momentum of simulated particles at selected places) can be created by calling AddTackReference . AddHit has to be implemented by each detector whereas AddTackReference is already implemented in AliModule. The container and the branch for the hits – and for the (summable) digits – are managed by the detector class via a set of so-called loaders. The relevant data members and methods are fHits, fDigits, ResetHits , ResetSDigits , ResetDigits , MakeBranch and SetTreeAddress . PreTrack , PostTrack , FinishPrimary , FinishEvent and FinishRun are called during the simulation when the conditions indicated by the method names are fulfilled.
Summable Digits
Summable digits are created by calling the virtual method Hits2SDigits of a detector. This method loops over all events, creates the summable digits from hits and stores them in the sdigits file(s).
Digitization and Merging
Dedicated classes derived from AliDigitizer are used for the conversion of summable digits into digits. Since AliDigitizer is a TTask, this conversion is done for the current event by the Exec method. Inside this method the summable digits of all input streams have to be added, combined with noise, converted to digital values taking into account possible thresholds, and stored in the digits container.
An object of type AliRunDigitizer manages the input streams (more than one in case of merging) as well as the output stream. The methods GetNinputs, GetInputFolderName and GetOutputFolderName return the relevant information. The run digitizer is accessible inside the digitizer via the protected data member fManager. If the flag fRegionOfInterest is set, only detector parts where summable digits from the signal event are present should be digitized. When Monte Carlo labels are assigned to digits, the stream-dependent offset given by the method GetMask is added to the label of the summable digit.
The detector specific digitizer object is created in the virtual method CreateDigitizer of the concrete detector class. The run digitizer object is used to construct the detector digitizer. The Init method of each digitizer is called before the loop over the events is started.
A direct conversion from hits directly to digits can be implemented in the method Hits2Digits of a detector. The loop over the events takes place inside the method. Of course merging is not supported in this case.
An example of a simulation script that can be used for simulation of proton-proton collisions is provided below:
void sim(Int_t nev=100) {
AliSimulation simulator;
// Measure the total time spent in the simulation
TStopwatch timer;
timer.Start();
// List of detectors, where both summable digits and digits are provided
simulator.SetMakeSDigits("TRD TOF PHOS EMCAL HMPID MUON ZDC PMD FMD T0 VZERO");
// Direct conversion of hits to digits for faster processing (ITS TPC)
simulator.SetMakeDigitsFromHits("ITS TPC");
simulator.Run(nev);
timer.Stop();
timer.Print();
}
The following example shows how one can do event merging:
void sim(Int_t nev=6) {
AliSimulation simulator;
// The underlying events are stored in a separate directory.
// Three signal events will be merged in turn with each
// underlying event
simulator.MergeWith("../backgr/galice.root",3);
simulator.Run(nev);
}