step manager section added - Bjorn
[u/mrichter/AliRoot.git] / EMCAL / doc / simulation.tex
02582a78 1\section{Simulation code}
017e0494 3The class AliSimulation manages this part. An example is here : ``\$ALICE\_ROOT/EMCAL/
02582a78 4macros/TestEMCALSimulation.C''. The simulation
5consists of different steps: geometry and event definition, particle
6generation, transport of the particle in the material (GEANT) and
7finally digitization. Note that the final output from the digitization
017e0494 8process is different from the processing of real experimental Raw Data. The process
9of converting the digitized data to Raw Data is discussed in Sec.~\ref{sec:digi}.
10Sec.~\ref{sec:simu_steps} gives the recipe to do all the steps of the simulation.
02582a78 11
e5d639f4 13%\subsection{Event generation and particle transport: Hits}
02582a78 14
e5d639f4 16%Once the generator is executed, the generated particles are transported
17%in the detector material with the Monte Carlo code, GEANT3 by default. Other options are
18%GEANT4 or FLUKA\footnote{There may be some license problems with FLUKA right now which could explain why it cannot be used at the moment}. All the generated particles are kept in a file called \textbf{Kinematics.root}. After the particle transport is executed, the objects \textbf{Hits}
19%are created. They contain the energy deposited in the sensitive material
20%of the detector by the generated particle, their position, impact
21%time (after collision) and the identity of the original particle.
22%Hits are stored in a file called \textbf{DETECTOR.Hits.root}, in the
23%calorimeter case: \textbf{EMCAL.Hits.root.}
02582a78 27
017e0494 29\subsection{Digitization: SDigits and Digits - Evi \label{sec:digi}}
02582a78 30
31We want to generate events which look like the real data collected
32by the experiment. In the end, we want to have an amplitude in ADC
33counts and a time (when particle traverse a cell) per each cell (tower)
34of the calorimeter. In the code for calorimeters, it is done in the
017e0494 35following steps:
37\item \textbf{SDigit} objects are created, they consist
02582a78 38of the sum of deposited energy by all Hits in a cell (a particle can
39create Hits in different cells but only one in a single cell), so
017e0494 40there is only one SDigit per fired cell.
41\item \textbf{Digit} objects are created, they are like the SDigits but the energy in the cell
02582a78 42is transformed into the ADC amplitude units, the electronic noise
43is added and Digits whose energy does not pass an energy threshold
44(3 ADC counts) are eliminated. SDigits and Digits are stored in the files
45\textbf{EMCAL.SDigits.root} and \textbf{EMCAL.Digits.root}, respectively.
017e0494 46\end{enumerate}
02582a78 47
43ac0b81 48\subsection{Raw data - David \label{sec:simu_raw}}
50The experiment does not record Digits directly, but instead a series of so-called
51time samples with 10-bit ADC counts per channel. Each time bin is 100 ns
52wide, corresponding to a 10 MHz readout.
53These samples are referred to as
54\textbf{Raw Data}. The samples follow a certain signal shape, more complicated than
55a Gaussian distribution, which is fitted offline.
56The simulated signal (Gamma-2) shape is described in the AliEMCALRawResponse class,
57in the RawResponseFunction method.
58With real data, which is zero-suppressed, i.e. has the pedestal subtracted online, the
02582a78 59Digits amplitude is just the maximum of the distribution obtained
017e0494 60with the fit to the sample. The Digit time (defined by the time the
43ac0b81 61particle hits the active volume of the detector) is the time value at
62the maximum signal fit. There are methods to go from Digits to
63Raw and vice versa in the AliEMCALRawUtils class: Raw2Digits and Digits2Raw,
017e0494 64respectively. For the reconstruction step Digits are needed. The
43ac0b81 65generation of Raw Data is optional during simulations and the generated
66data can be reconstructed directly from Digits, but Raw data is the initial
02582a78 67step when reconstructing real data.
017e0494 70\subsection{How to make a simulation\label{sec:simu_steps}}
02582a78 71
72TestEMCALSimulation.C is a very simple macro where we specify all the simulation parameters
017e0494 73and proccess the simulation. Below is a similar but a bit more elaborated macro:
02582a78 74
02582a78 75
02582a78 76
017e0494 77\begin{DDbox}{\linewidth}
79void TestEMCALSimulation() {
02582a78 80
017e0494 81TString detector=``EMCAL TPC''; // Define in this variable the detectors that you want to be included in the simulation for the digitization. They can be less detectors than the detectors defined in the Config.C file, imagine that you want all the detectors in front of EMCal present to consider the conversion of particles but you are not really interested in the output from these detectors.
82// Option detector=``ALL'' makes all detectors.
02582a78 83
017e0494 84AliSimulation sim ; //Create simulation object
02582a78 85
017e0494 86// Generation and simulation
02582a78 87
017e0494 88sim.SetRunGeneration(kTRUE) ; //Default value is kTRUE, make generation
89// For some reason we may want to redo the Digitization, without redoing the generation, in this case it must set to kFALSE
02582a78 90
017e0494 91// Making SDigits
92sim.SetMakeSDigits(detector) ; //We want to make SDigits
93// set no detectors if SDigits are already made
02582a78 94
017e0494 95// Making Digits
96sim.SetMakeDigits(detector) ; //We want to make Digits
97// set no detectors if SDigits are already made
02582a78 98
017e0494 99//Merging
100//sim.MergeWith(``bgrd/galice.root'') ; //If we want to merge a signal and a background, the merging is done at the SDigit level. The background must be located in the repertory defined in the method.
02582a78 101
017e0494 102//Write Raw Data, make Raw data from digits
103//sim.SetWriteRawData(detector) ;
104//sim.SetConfigFile(``somewhere/ConfigXXX.C'');//Default is Config.C
02582a78 105
017e0494 106//Make the simulation
107sim.Run(3) ; // Run the simulation and make 3 events
02582a78 108
02582a78 109
02582a78 110
017e0494 111\end{lstlisting}