]> git.uio.no Git - u/mrichter/AliRoot.git/blob - TRD/doc/trd_software_writeup.tex
update documentation with the tracking part
[u/mrichter/AliRoot.git] / TRD / doc / trd_software_writeup.tex
1 % ---------------------------------------------------------------------
2 %
3 % TRD Software Writeup
4 %
5 % ---------------------------------------------------------------------
6 %
7 \documentclass{alicetdr}
8 %\documentclass[draft]{alicetdr}
9 %
10 % For figures
11 \usepackage{graphicx}
12 %
13 % Helvetica
14 \usepackage{helvet}
15 \renewcommand{\rmdefault}{phv}
16 \renewcommand{\sfdefault}{phv}
17 %
18 \let\Otemize =\itemize
19 \let\Onumerate =\enumerate
20 \let\Oescription =\description
21 % Zero the vertical spacing parameters
22 \def\Nospacing{\itemsep=0pt\topsep=0pt\partopsep=0pt\parskip=0pt\parsep=0pt}
23 \def\Topspac{\vspace{-0.5\baselineskip}}
24 \def\Botspac{\vspace{-0.2\baselineskip}}
25 % Redefine the environments in terms of the original values
26 \newenvironment{Itemize}{\Topspac\Otemize\Nospacing}{\endlist\Botspac}
27 \newenvironment{Enumerate}{\Topspac\Onumerate\Nospacing}{\endlist\Botspac}
28 \newenvironment{Description}{\Topspac\Oescription\Nospacing}{\endlist\Botspac}
29 %
30 \include{alicedefs}
31 %
32 \begin{document}
33 %
34 \pagenumbering{roman}
35 %
36 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
37 %
38 % Title page
39 %
40 \font\HUGEA=phvr at 36mm  % declare very big font
41 \font\HUGEB=phvr at 14mm  % declare very big font
42 %
43 \begin{titlepage}
44 %
45 \vspace{10.0cm}
46 %
47 \begin{center}
48 {\HUGEA T\hspace{5.mm}R\hspace{5.mm}D} \\
49 %
50 \vspace{3.5cm}
51 {\HUGEB Offline Software Writeup} \\
52 %
53 \vspace{2.0cm}
54 {\Large Version 1.0, \today}\\
55 %
56 \vfill
57 %
58 \vspace{5.5cm}
59 %
60 \end{center}
61 %
62 \end{titlepage}
63 %
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
65 %
66 % Empty page to adjust page numbering
67 %
68 \onecolumn
69 \thispagestyle{empty}
70 \mbox{  }
71 %
72 \setcounter{page}{0}
73 \onecolumn
74 %
75 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
76 %
77 \pagenumbering{arabic}
78 %
79 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
80 %
81 % List of content
82 %
83 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
84 %
85 \thispagestyle{empty}
86 \tableofcontents
87 %
88 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
89 %
90 % Text
91 %
92 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
93 %
94 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
95 \setcounter{chapter}{0}
96 \setcounter{section}{0}    
97 \Chapter{Introduction}
98 \thispagestyle{empty}
99 %
100 This document is supposed to provide a description of the offline
101 software components that are specific to the TRD.  It is an attempt
102 to collect useful informations on the design and usage of the TRD
103 software, in order to facilitate newcomers the introduction to the
104 code.  The most important classes and procedures are described and
105 several examples and use cases are given.
106 However, this writeup is not meant to be a basic AliRoot introduction.  
107 For this purpose the reader is referred to the general AliRoot users 
108 guide \cite{ALIROOT}. 
109 %
110 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
111 \newpage
112 \setcounter{chapter}{1}
113 \setcounter{section}{0}    
114 \Chapter{Simulation}
115 \thispagestyle{empty}
116 %
117 \section{Geometry}
118 \label{GEO:intro}
119 %
120 {\it Author: C.~Blume (blume@ikf.uni-frankfurt.de)}
121 \smallskip
122 \\
123 %
124 The TRD geometry, as implemented in {\tt AliTRDgeometry}, consists of 
125 several components: The readout chambers (ROC), the services, and the 
126 supermodule frame.  All these parts are placed inside the TRD mother 
127 volumes, which in turn are part of the space frame geometry 
128 ({\tt AliFRAMEv2}).  Therefore, the space frame geometry has to be 
129 present to build the TRD geometry.  For each of the 18 supermodules 
130 one single mothervolume is provided (BTRDxx).  This allows to configure 
131 the TRD geometry in {\tt Config.C} such that it only contains a subset 
132 of supermodules in the total ALICE geometry via 
133 {\tt AliTRDgeometry::SetSMstatus()}.  An incomplete detector setup, as
134 it exists for first data taking, can thus be modelled.  The class
135 {\tt AliTRDgeometry} also serves as the central place to collect all
136 geometry relevant numbers and the definitions of various numbering
137 schemes of detector components (e.g. sector numbers).  However, all 
138 geometric parameters that refer to the pad planes are compiled in
139 {\tt AliTRDpadPlane}.
140 %
141 \subsection{Readout Chambers}
142 \label{GEO:rocs}
143 %
144 \begin{figure}[htb]
145 \begin{center}
146 \includegraphics[width=0.85\textwidth]{plots/geo_roc.eps}
147 \end{center}
148 \caption{
149 A TRD read out chamber as implemented in the AliRoot geometry.  The
150 various material layers are visible.  Also, the MCMs on top of the
151 chamber, as well as the cooling pipes are shown.
152 }
153 \label{FIG_GEO:roc_geom}
154 \end{figure}
155 %
156 All ROCs are modelled in the same way, only their dimensions vary.  
157 They consist of an aluminum frame, which contains the material for 
158 the radiator and the gas of the drift region, a Wacosit frame (whose 
159 material is represented by carbon), that surrounds the amplification 
160 region, and the support structure, consisting of its aluminum frame, 
161 material for the read out pads, back panel, and readout boards).  The 
162 material inside the active parts of the chambers (radiator, gas, wire 
163 planes, pad planes, glue, read out boards, etc.) is introduced by 
164 uniform layers of the corresponding material, whose thicknesses were 
165 chosen such to result in the correct radiation length.  On top of the
166 individual ROCs the multi chip modules (MCM) as well as the cooling 
167 pipes and cables are placed.  One obvious simplification, already visible
168 in Fig.~\ref{FIG_GEO:roc_geom}, is that in the AliRoot geometry the pipes
169 run straight across the chambers instead of following the meandering path 
170 as in reality.
171 %
172 \subsection{Supermodules}
173 \label{GEO:smframes}
174 %
175 \begin{figure}[htb]
176 \begin{center}
177 \begin{minipage}[b]{0.49\textwidth}
178 \begin{center}
179 \includegraphics[width=0.65\textwidth,angle=270]{plots/geo_smframe.eps}
180 \end{center}
181 \end{minipage}
182 \begin{minipage}[b]{0.49\textwidth}
183 \begin{center}
184 \includegraphics[width=0.70\textwidth,angle=270]{plots/geo_sm.eps}
185 \end{center}
186 \end{minipage}
187 \end{center}
188 \caption{
189 A TRD supermodule, as implemented in the AliRoot geometry.  The left
190 panel shows only the support structures of the aluminum frame, together
191 with some service elements.  The right panel shows a complete 
192 supermodule including some surrounding parts of the space frame.
193 }
194 \label{FIG_GEO:sm_geom}
195 \end{figure}
196 %
197 The supermodule frames consist of the aluminum sheets on the sides, top,
198 and bottom of a supermodule together with the traversing support structures.
199 The left panel of Fig.~\ref{FIG_GEO:sm_geom} shows the structures that are
200 implemented in the TRD geometry.  Also, parts of the services like the LV
201 power bus bars and cooling arteries can be seen.  Additional electronics 
202 equipment (e.g. ``Sch\"utten-Box``) is represented by aluminum boxes that 
203 contain corresponding copper layers to mimic the present material.  The 
204 services also include e.g. gas distribution boxes, cooling pipes, power and
205 readout cables, and power connection panels.  Part of the services extend
206 into the baby and the back frame.  Therefore, additional mother volumes
207 have been introduced in order to accommodate this material.  All supermodules 
208 have inserts of carbon fiber sheets in the bottom part of the aluminum 
209 casing, for the ones in front of the PHOS detector (sectors 11--15) also 
210 the top part includes carbon fiber inserts.  The supermodules in the sectors 
211 13--15 do not contain any ROCs in the middle stack in order to provide the 
212 holes for the PHOS detector.  Instead, gas tubes of stainless steel have
213 been built in.
214 %
215 Generally, the TRD volumina start with the letter  ``{\bf U}''.  The geometry
216 is defined by the function {\tt AliTRDgeometry::CreateGeometry()}, which
217 generates the TRD mother volumes ({\bf UTI1}, {\bf UTI2}, {\bf UTI3}) and the 
218 volumes that constitute a single ROC.  This function in turn also calls 
219 {\tt AliTRDgeometry::CreateFrame()} to create the TRD support frame, 
220 {\tt AliTRDgeometry::CreateServices()} to create the services, and 
221 {\tt AliTRDgeometry::GroupChambers()} which assembles the alignable
222 volumes for a single ROC ({\bf UTxx}, where {\bf xx} is the detector
223 number {\bf DET-SEC}, defined inside a single super module, see below). The
224 materials, together with their tracking parameters, that are assigned to
225 the volumina, are defined in {\tt AliTRD::CreateMaterials()}.
226 In the following table the most important TRD volumina are described
227 ({\bf xx} = {\bf DET-SEC} number):
228 %
229 \begin{center}
230 \begin{tabular}{l|l}
231 Name       & Description                                                                \\ \hline
232 {\bf UTR1} & TRD mothervolume for default supermodules                                  \\
233 {\bf UTR2} & TRD mothervolume for supermodules in front of PHOS                         \\
234 {\bf UTR3} & As {\bf UTR2}, but w/o middle stack                                        \\ \hline
235 {\bf UTxx} & Top volume of a single ROC                                                 \\ 
236            & Defines the alignable volume for a single ROC                              \\ \hline
237 {\bf UAxx} & Lower part of the ROCs, including drift volume and radiator                \\
238 {\bf UDxx} & Amplification region                                                       \\
239 {\bf UFxx} & Back panel, including pad planes and PCB boards of readout electronics     \\
240 {\bf UUxx} & Contains services on chambers (cooling, cables, DCS boards) and MCM chips  \\
241 \end{tabular}
242 \end{center}
243 %
244 \subsection{Material Budget and Weight}
245 %
246 \begin{figure}[htb]
247 \begin{center}
248 \includegraphics[width=0.75\textwidth]{plots/geo_material_budget.eps}
249 \end{center}
250 \caption{
251 The radiation length map in units of $X/X_{0}$ in part of the active 
252 detector area of super module 0 as a function of the pseudorapidity 
253 $\eta$ and the azimuth angle $\phi$, calculated from the geometry in 
254 AliRoot.  Visible are the positions of the MCMs and the cooling pipes 
255 as hot spots.
256 }
257 \label{FIG_GEO:mat_budget}
258 \end{figure}
259 %
260 The volumina defining a ROC contain several layers that represent the 
261 different materials present inside a chamber and which therefore define 
262 the material budget inside the sensitive areas:
263 \begin{center}
264 \begin{tabular}{l|l|l|l|c|c|c}
265 Name         & Mother & Material    & Description                  & Thickness & Density      & $X/X_{0}$ \\ 
266              &        &             &                              & [cm]      & [g/cm$^{3}$] & [\%]      \\ \hline
267 {\bf URMYxx} & UAxx   & Mylar       & Mylar layer on radiator (x2) & 0.0015    & 1.39         & 0.005     \\
268 {\bf URCBxx} & UAxx   & Carbon      & Carbon fiber mats (x2)       & 0.0055    & 1.75         & 0.023     \\
269 {\bf URGLxx} & UAxx   & Araldite    & Glue on the fiber mats (x2)  & 0.0065    & 1.12         & 0.018     \\
270 {\bf URRHxx} & UAxx   & Rohacell    & Sandwich structure (x2)      & 0.8       & 0.075        & 0.149     \\
271 {\bf URFBxx} & UAxx   & PP          & Fiber mats inside radiator   & 3.186     & 0.068        & 0.490     \\ \hline
272 {\bf UJxx}   & UAxx   & Xe/CO$_{2}$ & The drift region             & 3.0       & 0.00495      & 0.167     \\ 
273 {\bf UKxx}   & UDxx   & Xe/CO$_{2}$ & The amplification region     & 0.7       & 0.00495      & 0.039     \\ 
274 {\bf UWxx}   & UKxx   & Copper      & Wire planes (x2)             & 0.00011   & 8.96         & 0.008     \\ \hline
275 {\bf UPPDxx} & UFxx   & Copper      & Copper of pad plane          & 0.0025    & 8.96         & 0.174     \\
276 {\bf UPPPxx} & UFxx   & G10         & PCB of pad plane             & 0.0356    & 2.0          & 0.239     \\
277 {\bf UPGLxx} & UFxx   & Araldite    & Glue on pad plane            & 0.0923    & 1.12         & 0.249     \\
278              &        & Araldite    & + additional glue (leaks)    & 0.0505    & 1.12         & 0.107     \\
279 {\bf UPCBxx} & UFxx   & Carbon      & Carbon fiber mats (x2)       & 0.019     & 1.75         & 0.078     \\
280 {\bf UPHCxx} & UFxx   & Aramide     & Honeycomb structure          & 2.0299    & 0.032        & 0.169     \\
281 {\bf UPPCxx} & UFxx   & G10         & PCB of readout boards        & 0.0486    & 2.0          & 0.326     \\
282 {\bf UPRDxx} & UFxx   & Copper      & Copper of readout boards     & 0.0057    & 8.96         & 0.404     \\
283 {\bf UPELxx} & UFxx   & Copper      & Electronics and cables       & 0.0029    & 8.96         & 0.202     \\
284 \end{tabular}
285 \end{center}
286 This material budget has been adjusted to match the estimate given 
287 in~\cite{CLEMENS}, with the exception of the glue layer in the back panel
288 ({\bf UPGLxx}), which has been made thicker to include all the additional
289 glue that has been applied to fix the gas leaks.  Figure~\ref{FIG_GEO:mat_budget}
290 shows the resulting radiation length map in the active detector area for
291 super module 0, which has only carbon fiber inserts at the bottom and is
292 thus one of the super modules with the largest material budget.  It is
293 clearly visible that the MCMs and the cooling pipes introduce hot spots
294 in $X/X_{0}$.  However, after averaging over the shown area, the mean
295 value is found to be $\langle X/X_{0}\rangle =$~24.7~\%.  For a supermodule
296 with carbon fiber inserts at the top and the bottom one finds
297 $\langle X/X_{0}\rangle =$~23.8~\% and in the regions of the PHOS holes (i.e.
298 in the middle stack of supermodules 13--15) it is only 
299 $\langle X/X_{0}\rangle =$~1.9~\%.
300
301 The total weight of a single TRD super module in the AliRoot geometry, 
302 including all services, is currently 1595kg, which is ca. 5\% short of its
303 real weight.  A single ROC of the type L0C1 with electronics and cooling 
304 pipes weighs 21.82kg.
305 %
306 \subsection{Naming Conventions and Numbering Schemes}
307 %
308 \begin{figure}[htb]
309 \begin{minipage}[b]{0.49\textwidth}
310 \begin{center}
311 \includegraphics[width=\textwidth]{plots/sector_numbering.eps}
312 \end{center}
313 \end{minipage}
314 \begin{minipage}[b]{0.49\textwidth}
315 \begin{center}
316 \includegraphics[width=\textwidth]{plots/layer_numbering.eps}
317 \vspace{1.4cm}
318 \end{center}
319 \end{minipage}
320 \begin{center}
321 \includegraphics[width=0.60\textwidth]{plots/stack_numbering.eps}
322 \end{center}
323 \caption{
324 Illustration of the TRD numbering scheme for super modules, defined in
325 the global ALICE coordinate system: a) {\bf SECTOR} number, b) 
326 {\bf LAYER} number, c) {\bf STACK} number.
327 }
328 \label{FIG_GEO:sm_numbering}
329 \end{figure}
330 %
331 The numbering schemes and the orientations of coordinate systems generally 
332 follow the official ALICE-TRD definition \cite{DAVID}.  Therefore, the
333 whole geometry is defined in the global ALICE coordinate system.
334 %
335 Inside the code we use the following nomenclature (see 
336 Fig.~\ref{FIG_GEO:sm_numbering}), which should be used consistently
337 throughout the TRD code:
338 %
339 \begin{center}
340 \begin{tabular}{l|l|l}
341 Name          & Definition                                   & Range  \\ \hline
342 {\bf SECTOR}  & TRD sector in azimuth (i.e. one supermodule) & 0--17  \\
343 {\bf LAYER}   & Layer inside a supermodule                   & 0--5   \\
344 {\bf STACK}   & Division of a supermodule along z-direction  & 0--4   \\
345 {\bf DET}     & Single ROC in whole TRD                      & 0--539 \\ 
346 {\bf DET-SEC} & Single ROC in one super module               & 0--29 
347 \end{tabular}
348 \end{center}
349 %
350 Due to the holes in front of the PHOS detector, naturally not all {\bf DET} 
351 numbers correspond to existing ROCs.  A single ROC can thus be uniquely 
352 addressed by either using the three numbers 
353 ({\bf LAYER}, {\bf STACK}, {\bf SECTOR}) or the single {\bf DET} number.
354 The correspondence between the two possibilities is defined as:
355 \begin{center}
356 \mbox{{\bf DET} = {\bf LAYER} + {\bf STACK}$\times$5 + {\bf SECTOR}$\times$5$\times$4}
357 \end{center}
358 Additionally, there is a number that is unique inside a given super module (i.e. 
359 sector) and therefore has a range of 0~--~29:
360 \begin{center}
361 \mbox{{\bf DET-SEC} = {\bf LAYER} + {\bf STACK}$\times$5}
362 \end{center}
363 The class {\tt AliTRDgeometry} provides a set of functions that could/should
364 be used to convert the one into the other:\\
365 \hspace*{1.5cm}{\tt AliTRDgeometry::GetDetector(layer,stack,sector)} \\
366 \hspace*{1.5cm}{\tt AliTRDgeometry::GetDetectorSec(layer,stack)}     \\
367 \hspace*{1.5cm}{\tt AliTRDgeometry::GetLayer(det)}                   \\
368 \hspace*{1.5cm}{\tt AliTRDgeometry::GetStack(det)}                   \\
369 \hspace*{1.5cm}{\tt AliTRDgeometry::GetSector(det)}                  \\
370 %
371 \subsection{Pad Planes}
372 %
373 All geometric parameters relevant to the pad planes are handled via the
374 class {\tt AliTRDpadPlane}.  This comprises the dimensions of the pad planes
375 and the pad themselves, the number of padrows, padcolumns, and their tilting angle.  
376 The initialization of the needed {\tt AliTRDpadPlane} objects is done in 
377 {\tt AliTRDgeometry::CreatePadPlaneArray()}.  The number of padrows can be 12 
378 (C0-type) or 16 (C1-type), the number of padcolumns is 144 in any case.  Again,
379 the numbering convention follows the definition given in \cite{DAVID}.  Thus,
380 the padrow numbers in a given pad plane increase from 0 to 11(15) with decreasing
381 $z$-position, while the padcolumn numbers increase from 0 to 144 with increasing 
382 $\phi$ angle (i.e. counter clockwise).  The tilting angle of the pads is 2~degrees,
383 with alternating signs at different layers, beginning with +2~degrees for layer~0.
384 The class {\tt AliTRDpadPlane} provides a variety of functions that allow to assign 
385 a pad number (row/column) to signals generated at a given hit position and which
386 are used during the digitization process.
387 %
388 \section{Hit Generation}
389 %
390 {\it Author: C.~Blume (blume@ikf.uni-frankfurt.de)}
391 \smallskip
392 \\
393 %
394 In the case of the TRD a single hit corresponds to a cluster of electrons 
395 resulting from the ionization of the detector gas.  This ionization can be due
396 to the normal energy loss process of a charged particle or due to the 
397 absorption of a transition radiation (TR) photon.  A single TRD hit, as
398 defined in {\tt AliTRDhit} therefore contains the following data members:
399 %
400 \begin{center}
401 \begin{tabular}{ll}
402 {\tt fTrack}    & Index of MC particle in kine tree                                        \\
403 {\tt fX}        & X-position of the hit in global coordinates                              \\
404 {\tt fY}        & Y-position of the hit in global coordinates                              \\
405 {\tt fZ}        & Z-position of the hit in global coordinates                              \\
406 {\tt fDetector} & Number of the ROC ({\bf DET} number)                                     \\
407 {\tt fQ}        & Number of electrons created in the ionization step. Negative for TR hits \\
408 {\tt fTime}     & Absolute time of the hit in $\mu$s. Needed for pile-up events            \\
409 \end{tabular}
410 \end{center}
411 %
412 On top of this, it is also stored in the {\tt TObject} bit field status word  
413 whether a hit is inside the drift or the amplification region 
414 (see {\tt AliTRDhit::FromDrift()} and {\tt AliTRDhit::FromAmplification()}).
415 The creation of hits is steered by {\tt AliTRDv1::StepManager()}.
416 %
417 \subsection{Energy loss}
418 %
419 A charged particle, traversing the gas volume of the TRD chambers, will release
420 charge proportional to its specific energy loss.  In the TRD code this process
421 is implemented in \\{\tt AliTRDv1::StepManager()}.  This implementation used a 
422 fixed step size.  The standard value here is 0.1~cm, but other values can be
423 set via {\tt AliTRDv1::SetStepSize()}.  The energy deposited in a given step is
424 then calculated by the chosen MC program (typically Geant3.21), which after
425 division by the ionization energy gives the number of electrons of the new hit.
426 The version 2) will also work for an Ar/CO$_{2}$ mixture, which can be selected
427 by \\{\tt AliTRDSimParam::SetArgon()}. 
428 %
429 \subsection{Photons from transition radiation}
430 %
431 Additionally to the hits from energy loss, also hits from the absorption of
432 TR photons are generated.  This is done in {\tt AliTRDv1::CreateTRhit()}, which
433 in turn is called by the chosen step manager for electrons and positrons
434 entering the entering the drift volume.  The process consists of two steps:
435 first the number and energies of the TR photons have to be determined and then
436 their absorption position inside the gas volume has to be calculated.  The
437 corresponding procedures, used by {\tt AliTRDv1::CreateTRhit()}, are 
438 implemented in {\tt AliTRDsimTR()}.  This class contains a parametrization
439 of TR photons generated by a regular foil stack radiator \cite{TRPHOT}.  This
440 parametrization has been tuned such that the resulting spectrum matches the
441 one of the fiber radiator that used in reality.  Since the TR production
442 depends also on the momentum of the electron, the parameters have been 
443 adjusted in several momentum bins.  After a TR photon has been generated and put
444 on the particle stack, it is assumed that it follows a straight trajectory 
445 whose direction is determined by the momentum vector of the generating electron.  
446 Since the emission angle for TR photons is very small ($\sim 1/\gamma$) this 
447 is a valid approximation.  The absorption length, which thus determines the 
448 TR hit position, is randomly chosen according to the absorption cross sections
449 in the gas mixture.  These energy dependent cross sections are also included
450 in {\tt AliTRDsimTR}.
451 %
452 \subsection{Track references}
453 %
454 The TRD simulation produces track references ({\tt AliTrackReference}) each time 
455 a charged particle is entering the drift region and exiting the amplification 
456 region.  These track references thus provide information on the position where 
457 the MC particle was entering and existing the sensitive region of a ROC, as well
458 as on its momentum components at this positions.  Also, the index to the MC particle
459 in the kinematic tree is stored so that the full MC history can be retrieved.
460 %
461 \section{Digitization}
462 %
463 {\it Author: C.~Blume (blume@ikf.uni-frankfurt.de)}
464 \smallskip
465 \\
466 %
467 The second step in the simulation chain is the translation of the hit information,
468 i.e. position and amount of deposited charge, into the final detector response
469 that can be stored in digits objects ({\tt AliTRDdigits}):
470 %
471 \begin{center}
472 \begin{tabular}{ll}
473 {\tt fAmp}         & Signal amplitude                      \\
474 {\tt fId}          & Number of the ROC ({\bf DET} number)  \\
475 {\tt fIndexInList} & Track index                           \\
476 {\tt fRow}         & Pad row number                        \\
477 {\tt fColumn}      & Pad column number                     \\
478 {\tt fTime}        & Time bin number                       \\
479 \end{tabular}
480 \end{center}
481 %
482 However, in practice {\tt AliTRDdigits} is not used to store the digits 
483 information.  Instead the data containers described in \ref{DIGITS:containers}
484 are used for this purpose.  The digitization process includes as an 
485 intermediate step between hit and digits the so-called summable digits, or 
486 sdigits:
487 \begin{center}
488 \mbox{{\bf HITS} $\Longrightarrow$ {\bf SDIGITS} $\Longrightarrow$ {\bf DIGITS}}
489 \end{center}
490 They sdigits contain the detector signals before discretization and the addition
491 of noise and are used to merge several events into a single one.
492 %
493 \subsection{Digitizer}
494 %
495 The class {\tt AliTRDdigitizer} contains all the necessary procedures to convert
496 hits into sdigits and subsequently sdigits into digits.  The standard sequence to
497 produce sdigits, as would be initiated by {\tt AliSimulation}, is shown here:
498 %
499 \begin{center}
500 \unitlength1.0cm
501 \begin{picture}(10,9)
502 \put(2.5,8.0){\framebox(5.0,0.8){{\tt MakeDigits()}}}
503 \put(2.5,6.4){\framebox(5.0,0.8){{\tt SortHits()}}}
504 \put(2.5,4.8){\framebox(5.0,0.8){{\tt ConvertHits(det)}}}
505 \put(2.5,3.2){\framebox(5.0,0.8){{\tt ConvertSignals(det)}}}
506 \put(2.5,1.6){\framebox(5.0,0.8){{\tt Signal2SDigits(det)}}}
507 \put(2.5,0.0){\framebox(5.0,0.8){{\tt TRD.SDigits.root}}}
508 \put(5.0,8.0){\vector(0,-1){0.8}}
509 \put(5.0,6.4){\vector(0,-1){0.8}}
510 \put(5.0,4.8){\vector(0,-1){0.8}}
511 \put(5.0,3.2){\vector(0,-1){0.8}}
512 \put(5.0,1.6){\vector(0,-1){0.8}}
513 \put(5.0,1.2){\line(-1,0){4.0}}
514 \put(1.0,1.2){\line(0,1){4.8}}
515 \put(1.0,6.0){\vector(1,0){4.0}}
516 \put(0.2,6.1){{\tt det=0-539}}
517 \end{picture}
518 \end{center}
519 %
520 The first function {\tt SortHits()} sorts the simulated hits according to
521 their {\bf DET} number, so that the digitization procedures can be called
522 for a single ROCs in the following loop.  The function {\tt ConvertHits()}
523 does the conversion of the hit information into a detector signal.  In this
524 procedure each electron of a given hit is in principle followed along its
525 path from the position of the primary ionization towards the anode wire.
526 The position of this electron can be modified by diffusion in the gas
527 ({\tt AliTRDdigitizer::Diffusion()}), ExB effect ({\tt AliTRDdigitizer::ExB()}),
528 and absorption ({\tt AliTRDdigitizer::Absorbtion()}, off per default).
529 The drift time of the electrons is also modified according to their distance
530 to the corresponding anode wire position ({\tt AliTRDdigitizer::TimeStruct()}),
531 since the electric field lines are not uniform inside the amplification region.
532 This results in a non-isochronity of the drift time, which has been
533 simulated with the GARFIELD program and the tabulated results of this
534 simulation are used in the digitizing process to adjust the drift times
535 accordingly. Once the position and the drift time of the electron at the
536 anode wire plane are know, the signal induced on the pads can be calculated.
537 This involves three effects: the pad response, which distributes the charge
538 on several pads ({\tt AliTRDdigitizer::PadResponse()}), the time response due 
539 to the slow ion drift and the PASA response function, which distributes the
540 charge onto the following time bins, ({\tt AliTRDdigitizer::TimeResponse()}), 
541 and the cross talk between neighboring pads ({\tt AliTRDdigitizer::CrossTalk()}).  
542 At the end of this procedure, the charge seen by each pad in each time bin 
543 is available.  Also, the indices of maximally three MC particles in the kine
544 tree contributing to a given pad signal are stored, so that in a later 
545 analysis it can be tested which particle generated what signal.
546 As a next step the signals could either directly be converted into {\bf DIGITS},
547 or, which is the default procedure, they are stored as {\bf SDIGITIS}.
548 The corresponding functions ({\tt AliTRDdigitizer::Signal2SDigits()} and
549 {\tt AliTRDdigitizer::Signal2ADC()}) are called from 
550 {\tt AliTRDdigitizer::ConvertSignals()}, depending on the configuration.
551 The function {\tt AliTRDdigitizer::Signal2SDigits()} stores the signals as 
552 {\bf SDIGITS} in data structures of the type {\tt AliTRDarraySignal} (see 
553 section \ref{DIGITS:containers}).  
554
555 If desired, the {\bf SDIGITS} can now be added to the {\bf SDIGITS} from other
556 simulated events, e.g. in order to embed a specific signal into a background
557 event ({\tt AliTRDdigitizer::MergeSDigits()}). After this optional step, the 
558 {\bf SDIGITS} are finally being converted into {\bf DIGITS}. This process is
559 steered by the function ({\tt AliTRDdigitizer::ConvertSDigits()}). 
560 %
561 \begin{center}
562 \unitlength1.0cm
563 \begin{picture}(10,9)
564 \put(2.5,8.0){\framebox(5.0,0.8){{\tt Exec()}}}
565 \put(2.5,6.4){\framebox(5.0,0.8){{\tt SDigits2Digits()}}}
566 \put(2.5,4.8){\framebox(5.0,0.8){{\tt MergeSDigits()}}}
567 \put(2.5,3.2){\framebox(5.0,0.8){{\tt ConvertSDigits()}}}
568 \put(2.5,1.6){\framebox(5.0,0.8){{\tt Signal2ADC(det)}}}
569 \put(2.5,0.0){\framebox(5.0,0.8){{\tt TRD.Digits.root}}}
570 \put(5.0,8.0){\vector(0,-1){0.8}}
571 \put(5.0,6.4){\vector(0,-1){0.8}}
572 \put(5.0,4.8){\vector(0,-1){0.8}}
573 \put(5.0,3.2){\vector(0,-1){0.8}}
574 \put(5.0,1.6){\vector(0,-1){0.8}}
575 \put(5.0,1.2){\line(-1,0){4.0}}
576 \put(1.0,1.2){\line(0,1){1.6}}
577 \put(1.0,2.8){\vector(1,0){4.0}}
578 \put(0.2,2.9){{\tt det=0-539}}
579 \end{picture}
580 \end{center}
581 %
582 The essential step in the final {\bf SDIGITS} $\Longrightarrow$ {\bf DIGITS} 
583 conversion is performed by the function {\tt AliTRDdigitizer::Signal2ADC()}. 
584 Here pad signals, that are stored as floats, are finally translated into 
585 integer ADC values. This conversion involves a number of parameters: the pad 
586 coupling and time coupling factors, the gain of the PASA and of the 
587 amplification at the anode wire, and the input range and baseline of the ADCs. 
588 The coupling factors take into account that only a fraction of the incoming 
589 signal is sampled in the digitization process. At this point also the relative 
590 gain factors derived from the calibration procedures for a given dataset will 
591 be used to distort the simulated data correspondingly. The noise is generated 
592 according to a Gaussian distribution of a given width and added to the output. 
593 Finally, the converted signals are discretize into the ADC values of the 
594 defined resolution. At this stage also the zero suppression mechanism is applied 
595 to the simulated ADC values ({\tt AliTRDdigitizer::ZS()}), in order to reduce 
596 the output volume (see section \ref{DIGITS:zs}). These {\bf DIGITS} can then 
597 serve as input to the raw data simulation (see section \ref{RAWSIM}).
598 %
599 \subsection{Simulation parameter}
600 %
601 The parameters that are needed to configure the digitization, are either
602 read from the OCDB (e.g. calibration gain factors) or are taken from the
603 parameter class {\tt AliTRDSimParam}. This class contains the default values
604 of these parameters, but it can be configured in order to test different 
605 scenarios. The following table lists the available parameters:
606 %
607 \begin{center}
608 \begin{tabular}{lll}
609 Parameter              & Description                                   & Default value \\ \hline
610 {\tt fGasGain}         & Gas gain at the anode wire                    & 4000          \\
611 {\tt fNoise}           & Noise of the chamber readout                  & 1250          \\
612 {\tt fChipGain}        & Gain of the PASA                              & 12.4          \\
613 {\tt fADCoutRange}     & ADC output range (number of ADC channels)     & 1023 (10bit)  \\
614 {\tt fADCinRange}      & ADC input range (input charge)                & 2000 (2V)     \\
615 {\tt fADCbaseline}     & ADC intrinsic baseline in ADC channels        & 0             \\
616 {\tt fElAttachProb}    & Probability for electron attachment per meter & 0             \\
617 {\tt fPadCoupling}     & Pad coupling factor                           & 0.46          \\
618 {\tt fTimeCoupling}    & Time coupling factor                          & 0.4           \\ \hline
619 {\tt fDiffusionOn}     & Switch for diffusion                          & kTRUE         \\
620 {\tt fElAttachOn}      & Switch for electron attachment                & kFALSE        \\
621 {\tt fTRFOn}           & Switch for time response                      & kTRUE         \\
622 {\tt fCTOn}            & Switch for cross talk                         & kTRUE         \\
623 {\tt fTimeStructOn}    & Switch for time structure                     & kTRUE         \\
624 {\tt fPRFOn}           & Switch for pad response                       & kTRUE         \\
625 {\tt fGasMixture}      & Switch for gas mixture (0: Xe/CO2, 1: Ar/CO2) & 0             \\
626 \end{tabular}
627 \end{center}
628 %
629 \subsection{Digits manager}
630 \label{DIGITS:manager}
631 %
632 {\it Author: H.~Leon~Vargas (hleon@ikf.uni-frankfurt.de)}
633 \smallskip
634 \\
635 %
636 The class {\tt AliTRDdigitsManager} handles arrays of data container 
637 objects in the form of ROOT's {\tt TObjArray}.  Its main functionality 
638 is that it provides setters and getters for the information of each chamber.
639 %
640 \begin{figure}[htb]
641 \begin{center}
642 \includegraphics[width=0.85\textwidth]{plots/digitsmanager_containers.eps}
643 \end{center}
644 \caption{
645 Data containers used in the class {\tt AliTRDdigitsManager}.
646 }
647 \label{FIG_DIG:manager}
648 \end{figure}
649 %
650 \subsection{Data containers}
651 \label{DIGITS:containers}
652 %
653 During simulation different kinds of information are created and stored 
654 in various data containers depending on their characteristics. 
655 These containers were designed with the idea of keeping the code as 
656 simple as possible and to ease its maintenance. 
657 The simulated signals or sdigits for a given row, column and time bin 
658 of each detector, as generated by \\ {\tt AliTRDdigitizer::ConvertHits()}, 
659 are stored in an object of the class {\tt AliTRDarraySignal}.   This 
660 class stores the data in an array of floating point values.  In this 
661 case, the compression method takes as an argument a threshold.  All the 
662 values equal or below that threshold will be set to zero during
663 compression. The threshold can take any value greater or equal to zero.
664 The sdigits data is used during event merging.
665
666 In the simulation the information about the particles that generated the
667 hits (index in kine tree) is stored for each detector in an object
668 of the class {\tt AliTRDarrayDictionary}. In this case the information 
669 is stored in an array of integer values, which is initialized to -1.
670  
671 In the digitizer, the signals stored in the sdigits are converted 
672 afterwards into ADC values and kept in objects of the class 
673 {\tt AliTRDarrayADC}.  This class saves the ADC values in an array of 
674 short values. The ADC range uses only the first 9 bits, bits 10 to 12 
675 are used to set the pad status.  An uncompressed object of the class 
676 {\tt AliTRDarrayADC} should only contain values that are equal or 
677 greater than -1, because the compression algorithm of this class uses 
678 all the other negative values in the range of the short data type. The 
679 value -1 in the data array is used in the simulation to indicate where 
680 an ADC value was ``zero suppressed''. This is done in this way so we 
681 are be able to discriminate between real zeroes and suppressed zeroes. 
682 For the details of the use of pad status refer to the method 
683 {\tt AliTRDarrayADC::SetPadStatus()} in the implementation file of this class.
684 %
685 \subsection{Zero suppression}
686 \label{DIGITS:zs}
687 %
688 {\it Author: H.~Leon~Vargas (hleon@ikf.uni-frankfurt.de)}
689 \smallskip
690 \\
691 %
692 The zero suppression algorithm was applied at the end of digitization
693 in order to decrease the size of the digits file. The code is implemented 
694 in the class {\tt AliTRDmcmSim}.  This algorithm is based on testing 
695 three conditions on the ADC values of three neighboring pads as seen 
696 in Fig.~\ref{FIG_DIG:zs} (for more information see the Data Indication 
697 subsection in the TRAP User Manual). The conditions are the following:\\
698
699 1) Peak center detection:\\
700
701 ADC-1(t) $\leq$ ADC(t) $\geq$ ADC+1(t)\\
702
703 2) Cluster:\\
704
705 ADC-1(t)+ADC(t)+ADC+1(t) $>$ Threshold\\
706
707 3) Absolute Large Peak:\\
708
709 ADC(t) $>$ Threshold\\
710
711 If a given combination of these conditions is not fulfilled, the value ADC(t) 
712 is suppressed. The algorithm runs over all ADC values.
713 %
714 \begin{figure}[htb]
715 \begin{center}
716 \includegraphics[width=0.60\textwidth]{plots/zsuppression.eps}
717 \end{center}
718 \caption{
719 Zero suppression code.
720 }
721 \label{FIG_DIG:zs}
722 \end{figure}
723 %
724 \section{Raw Data Simulation}
725 \label{RAWSIM}
726 %
727 \section{Trigger Simulation}
728 \label{TRGSIM}
729 {\it Author: J.~Klein (jklein@physi.uni-heidelberg.de)}
730 \vspace{.3cm}
731
732 The trigger generation chain of the TRD can be simulated within
733 AliRoot as well. It contains several stages as in the real
734 hardware (s. Fig.~\ref{fig:trgsim}). 
735
736 For each event the hits in the active volume are converted to
737 digitized signals in the AliTRDdigitizer. The digital processing as
738 done in the TRAP is simulated in its method \\
739 {\tt RunDigitalProcessing()} calling the MCM simulation (in {\tt
740   AliTRDmcmSim}) which implements the filters, zero-suppression and
741 tracklet calculation. Here the same integer arithmetics is used as in
742 the real TRAP. The trigger-relevant preprocessed data, i.e. the
743 tracklets, are stored using a dedicated loader. From there they are
744 accessed by the GTU simulation which runs the stackwise tracking. The
745 individual stages are discussed in more detail in the following
746 sections.
747 \begin{figure}
748 \begin{center}
749 \includegraphics[angle=0,width=0.9\textwidth]{plots/trgsim_ov}
750 \end{center}
751 \caption[Trigger simulation overview]{Overview of the trigger
752   simulation}
753 \label{fig:trgsim}
754 \end{figure}
755
756 \subsection{MCM simulation}
757 The MCM simulation is contained in {\tt AliTRDmcmSim}. This class
758 mimics the digital part of an MCM. It can be used for the simulation
759 after digitization has been performed.
760
761 Internally, an object of {\tt AliTRDmcmSim} can hold the data of
762 21~ADC channels both raw and filtered. After the instantiation {\tt
763   Init()} has to be called to define the position of the MCM. Then,
764 the data can be fed using either of the following methods:
765 \begin{description}
766 \item[{\tt SetData(Int\_t iadc, Int\_t *adc)}] ~\\ Set the data for the
767   given ADC channel {\it iadc} from an array {\it adc} containing the
768   data for all timebins.
769 \item[{\tt SetData(Int\_t iadc, Int\_t it, Int\_t adc)}] ~\\ Set the data for the
770   given ADC channel {\it iadc} and timebin {\it it} to the value {\it adc}.
771 \item[{\tt SetData(AliTRDarrayADC *adcArray)}] ~\\ Set the data for the
772   whole MCM from the digits array pointed to by {\it adcArray}.
773 \item[{\tt LoadMCM(AliRunLoader *rl, Int\_t det, Int\_t rob, Int\_t mcm)}]
774   ~\\ This method automatically initializes the MCM for the specified
775   location and loads the relevant data via the runloader pointed by
776   {\it rl}. 
777 \end{description}
778
779 After loading of the data the processing stages can be run
780 individually:
781 \begin{description}
782 \item[{\tt Filter()}] ~\\ The pedestal, gain and tail cancellation filters
783   are run on the currently loaded raw data. The filter settings
784   (including bypasses) are used as configured in the TRAP
785   (s.~\ref{sec:trapcfg}). The unfiltered raw data is kept such that it
786   is possible to rerun Filter(), e.g. with different settings. 
787 \item[{\tt Tracklet()}] ~\\ The tracklet calculation operates on the
788   filtered data (which is identical to the unfiltered data if Filter()
789   was not called). First, the hits are calculated and the fit
790   registers filled. Subsequently, the straight line fits for the four
791   most promising tracklets are calculated. 
792 \item[{\tt ZSMapping()}] ~\\ This methods performs the zero-suppression
793   which can be based on different criteria (to be configured in the
794   TRAP). 
795 \end{description}
796
797 The results of the MCM simulation can be accessed in different ways:
798 \begin{description}
799 \item[{\tt WriteData(AliTRDarrayADC *digits)}] ~\\ Hereby, the data are
800   written to the pointed digits array. It is part of the TRAP
801   configuration whether raw or filtered data is written (EBSF). 
802 \item[{\tt ProduceRawStream(UInt\_t *buf, Int\_t bufsize, UInt\_t
803     iEv)}] ~\\ Produce the raw data stream for this MCM as it will
804   appear in the raw data of the half-chamber. 
805 \item[{\tt ProduceTrackletStream(UInt\_t *buf, Int\_t bufsize)}] ~\\
806   Produce the raw stream of tracklets as they appear in raw data. 
807 \item[{\tt StoreTracklets()}] ~\\ The tracklets are stored via the
808   runloader. This has to be called explicitly, otherwise the tracklets
809   will not be written. 
810 \end{description}
811
812 \subsection{TRAP configuration} 
813 \label{sec:trapcfg}
814 The TRAP configuration is kept in {\tt AliTRDtrapConfig} which is
815 implemented as singleton. After obtaining a pointer to the class by a
816 call to {\tt AliTRDtrapConfig::Instance()} values can be changed and read by:
817 \begin{description}
818 \item[{\tt SetTrapReg(TrapReg\_t reg, Int\_t value, Int\_t det, Int\_t rob,
819   Int\_t mcm)}] ~\\ This sets the given TRAP register given as the
820   abbreviation from the TRAP manual with preceding 'k' (enum) to the
821   given value. If you specify {\it det}, {\it rob} or {\it mcm} the
822   values are changed for individual MCMs. Not specified the setting is
823   applied globally. 
824 \item[{\tt GetTrapReg(TrapReg\_t reg, Int\_t det, Int\_t rob, Int\_t mcm)}]
825   ~\\ This method gets the current value of the given TRAP
826   registers. If the values are set individually for different MCMs you
827   have to pass {\it det}, {\it rob} and {\it mcm}. Otherwise, these
828   parameters can be omitted. 
829 \item[{\tt PrintTrapReg(TrapReg\_t reg, Int\_t det, Int\_t rob, Int\_t mcm)}]
830   ~\\ It is similar to the preceding method but prints the information
831   to stdout. 
832 \end{description}
833
834 The calculated tracklets can be stored by a call to {\tt AliTRDmcmSim::StoreTracklets()}.
835
836 \subsection{Tracklet classes}
837 In order to unify the different sources of tracklets, e.g. real data
838 or simulation, all implementations of tracklets derive from the
839 abstract base class {\tt AliTRDtrackletBase}. The following
840 implementations are currently in use:
841 \begin{description}
842 \item[{\tt AliTRDtrackletWord}] ~\\ This class is meant to represent the
843   information as really available from the FEE, i.e. only a 32-bit
844   word and the information on the detector it was produced on.
845 \item[{\tt AliTRDtrackletMCM}] ~\\ Tracklets of this type are produced in
846   the MCM simulation and contain additional MC information.
847 \item[{\tt AliTRDtrackletGTU}] This class is used during the GTU tracking
848   and contains a pointer to a tracklet and information assigned to it
849   during the global tracking.  
850 \end{description}
851
852 \subsection{GTU simulation}
853
854 The simulation of the TRD global tracking on tracklets is steered by
855 AliTRDgtuSim. This class provides all the interface. The following
856 classes are involved:
857 \begin{description}
858 \item[{\tt AliTRDgtuParam}] ~\\ This class contains or generates the relevant
859   parameters used for the GTU tracking. 
860 \item[{\tt AliTRDgtuTMU}] ~\\ This class holds the actual tracking algorithm
861   as it runs in one Track Matching Unit (TMU) which corresponds to one
862   stack. 
863 \end{description}
864
865 The GTU simulation can be run by calling {\tt
866   AliTRDgtuSim::RunGTU(AliLoader *loader, AliESDEvent *esd)} where
867 {\it loader} points to the TRD loader and {\it esd} to an ESD
868 event. The latter can be omitted in which case the output is not
869 written to the ESD. The tracklets are automatically retrieved via the
870 loader and the found tracks of type {\tt AliTRDtrackGTU} are
871 internally stored in a tree for which a getter exists to access. If a
872 pointer to an {\tt AliESDEvent} is given, the tracks are also written
873 to the ESD (as {\tt AliESDTrdTrack}). For this the method {\tt
874   AliTRDtrackGTU::CreateTrdTrack()} is used which creates the {\tt
875   AliESDTrdTrack} (with reduced information compared to {\tt
876   AliTRDtrackGTU}).
877
878 \subsection{CTP interface}
879
880 The interface to the central trigger is defined in {\tt
881   AliTRDTrigger}. This class is called automatically during simulation
882 and produces the trigger inputs for TRD (in {\tt
883   CreateInputs()}). They are only considered if they are part of the
884 used trigger configuration (e.g. GRP/CTP/p-p.cfg).
885
886 The actual trigger generation has to be contained in {\tt
887   Trigger()}. Currently, the GTU simulation is run from here using the
888 previously calculated tracklets. The generated tracks are stored and
889 the trigger inputs are propagated to CTP. Which trigger classes make
890 use of the TRD inputs has to be defined in the trigger configuration. 
891 %
892 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
893 \newpage
894 \setcounter{chapter}{2}
895 \setcounter{section}{0}    
896 \Chapter{Reconstruction}\label{REC:}
897 {\it Author: A.~Bercuci (A.Bercuci@gsi.de)}
898 \thispagestyle{empty}
899 %
900 \section{Raw Data Reading}
901 %
902 \section{Cluster Finding}\label{REC:CL:}
903 %
904 \subsection[Cluster position reconstruction]{Cluster position reconstruction\footnote{The procedures described in this section are implemented in the functions 
905 {\tt AliTRDcluster::GetXloc()}, {\tt AliTRDcluster::GetYloc()},
906 {\tt AliTRDcluster::GetSX()} and {\tt AliTRDcluster::GetSY()}.}}\label{REC:CL:rphi}
907 {\it Author: A.~Bercuci (A.Bercuci@gsi.de)}
908
909 {\bf Calculation of cluster position in the radial direction} in local chamber coordinates (with respect to the anode wire 
910 position) is using the following parameters:\\
911   $t_0$ - calibration aware trigger delay $[\mu s]$\\
912   $v_d$ - drift velocity in the detector region of the cluster $[cm/\mu s]$\\
913   z  - distance to the anode wire [cm]. By default average over the drift cell width\\
914   q \& $x_q$ - array of charges and cluster positions from previous clusters in the tracklet [a.u.]
915
916 The estimation of the radial position is based on calculating the drift time and the drift velocity at the point of 
917 estimation. The drift time can be estimated according to the expression:
918 \begin{equation}
919 t_{drift} = t_{bin} - t_{0} - t_{cause}(x) - t_{TC}(q_{i-1}, q_{i-2}, ...)
920 \end{equation}
921 where $t_0$ is the delay of the trigger signal. $t_{cause}$ is the causality delay between ionization electrons hitting 
922 the anode and the registration of mean signal by the electronics - due to the rising time of the TRF 
923 A second order correction here comes from the fact that the time spreading of charge at anode is the convolution of
924 TRF with the diffusion and thus cross-talk between clusters before and after local clusters changes with drift length. 
925 $t_{TC}$ is the residual charge from previous (in time) clusters due to residual tails after tail cancellation. 
926 This tends to push cluster forward and depends on the magnitude of their charge.
927
928 The drift velocity varies with the drift length (and distance to anode wire) as described by cell structure simulation. 
929 Thus one, in principle, can calculate iteratively the drift length from the expression:
930 \begin{equation}
931 x = t_{drift}(x)*v_{drift}(x)
932 \end{equation}
933 In practice we use a numerical approach (see AliTRDcluster::GetXcorr() and Figure \ref{FIG_CLUSTER:Xcorr} left) to correct for anisochronity obtained from MC 
934 comparison (see AliTRDclusterResolution::ProcessSigma() for the implementation). Also the calibration of the 0 approximation (no x dependence)
935 for $t_{cause}$ is obtained from MC comparisons and impossible to disentangle in real life from trigger delay.
936 \begin{figure}[htb]
937 \begin{center}
938 \includegraphics[width=0.48\textwidth]{plots/clusterXcorr.eps}
939 \includegraphics[width=0.48\textwidth]{plots/clusterYcorr.eps}
940 \end{center}
941 \caption{
942 Correction of the radial and $r-\phi$ position of the TRD cluster.}
943 \label{FIG_CLUSTER:Xcorr}
944 \end{figure}
945
946 For {\bf the calculation of the $r-\phi$ offset} of the cluster from the middle of the center pad three methods are implemented:
947   - Center of Gravity (COG) see AliTRDcluster::GetDYcog()
948   - Look-up Table (LUT) see AliTRDcluster::GetDYlut()
949   - Gauss shape (GAUS) see AliTRDcluster::GetDYgauss()
950 In addition for the case of LUT method position corrections are also applied (see AliTRDcluster::GetYcorr() and Figure \ref{FIG_CLUSTER:Xcorr} right).
951
952 One may calculate the $r-\phi$ offset, based on the gaussian approximation of the PRF, from the signals $q_{i-1}$, $q_i$ and $q_{i+1}$ in the 3 adiacent pads by:
953 \begin{equation}
954 y = \frac{1}{w_{1}+w_{2}} [{w_{1}({y_{0}-\frac{W}{2}+\frac{s^{2}}{W}ln\frac{q_{i}}{q_{i-1}}})+w_{2}({y_{0}+ \frac{W}{2}+\frac{s^{2}}{W}ln\frac{q_{i+1}}{q_{i}}}})]
955 \end{equation}
956 where W is the pad width, $y_0$ is the position of the middle of the center pad and $s^2$ is given by
957 \begin{equation}
958 s^{2} = s^{2}_{0} + s^{2}_{diff} (x,B) + \frac{tg^{2}(\phi-\alpha_{L})*l^{2}}{12}
959 \end{equation}
960 with $s_0$ being the PRF for 0 drift and track incidence phi equal to the lorentz angle $\alpha_L$ and the diffusion term being described by:
961 \begin{equation}
962 s_{diff} (x,B) = \frac{D_{L}\sqrt{x}}{1+({\omega\tau}^{2}})
963 \end{equation}
964 with x being the drift length. The weights $w_1$ and $w_2$ are taken to be $q_{i-1}^2$ and $q_{i+1}^2$ respectively.
965
966 {\bf Determination of shifts by comparing with MC}\\
967
968 The resolution of the cluster corrected for pad tilt with respect to MC in the $r-\phi$ (measuring) plane can be 
969 expressed by:
970 \begin{eqnarray}
971 \Delta y&=&w - y_{MC}(x_{cl})\\
972 w &=& y_{cl}^{'} + h*(z_{MC}(x_{cl})-z_{cl})\\
973 y_{MC}(x_{cl}) &=& y_{0} - dy/dx*x_{cl}\\
974 z_{MC}(x_{cl}) &=& z_{0} - dz/dx*x_{cl}\\
975 y_{cl}^{'} &=& y_{cl}-x_{cl}*tg(\alpha_{L})
976 \end{eqnarray}
977 where $x_{cl}$ is the drift length attached to a cluster, $y_{cl}$ is the $r-\phi$ coordinate of the cluster measured by
978 charge sharing on adjacent pads and $y_0$ and $z_0$ are MC reference points (as example the track references at 
979 entrance/exit of a chamber). If we suppose that both $r-\phi$ (y) and radial (x) coordinate of the clusters are 
980 affected by errors we can write
981 \begin{eqnarray}
982 x_{cl} &=& x_{cl}^{*} + \delta x\\ 
983 y_{cl} &=& y_{cl}^{*} + \delta y 
984 \end{eqnarray} 
985 where the starred components are the corrected values. Thus by definition the following quantity
986 \begin{equation}
987 \Delta y^{*}= w^{*} - y_{MC}(x_{cl}^{*})
988 \end{equation}
989 has 0 average over all dependency. Using this decomposition we can write:
990 \begin{equation}\label{EQ_CLUSTER:shift}
991 <\Delta y>=<\Delta y^{*}> + <\delta x * (dy/dx-h*dz/dx) + \delta y - \delta x * tg(\alpha_{L})>
992 \end{equation}
993 which can be transformed to the following linear dependence:
994 \begin{equation}
995 <\Delta y>= <\delta x> * (dy/dx-h*dz/dx) + <\delta y - \delta x * tg(\alpha_{L})>
996 \end{equation}
997 if expressed as function of dy/dx-h*dz/dx. Furtheremore this expression can be plotted for various clusters
998 i.e. we can explicitely introduce the diffusion ($x_{cl}$) and drift cell - anisochronity ($z_{cl}$) dependences. From 
999 plotting this dependence and linear fitting it with:
1000 \begin{equation}
1001 <\Delta y>= a(x_{cl}, z_{cl}) * (dy/dx-h*dz/dx) + b(x_{cl}, z_{cl})
1002 \end{equation}
1003 the systematic shifts will be given by:
1004 \begin{eqnarray}
1005 \delta x (x_{cl}, z_{cl}) &=& a(x_{cl}, z_{cl})\\
1006 \delta y (x_{cl}, z_{cl}) &=& b(x_{cl}, z_{cl}) + a(x_{cl}, z_{cl}) * tg(\alpha_{L})
1007 \end{eqnarray}
1008 In Figure \ref{FIG_CLUSTER:shift} left there is an example of such dependency. 
1009 \begin{figure}[htb]
1010 \begin{center}
1011 \includegraphics[width=0.48\textwidth]{plots/clusterShiftMethod.eps}
1012 \includegraphics[width=0.48\textwidth]{plots/clusterSigmaMethod.eps}
1013 \end{center}
1014 \caption{
1015 Linear relation to estimate radial and $r-\phi$ cluster shifts and error.}
1016 \label{FIG_CLUSTER:shift}
1017 \end{figure}
1018
1019 The occurance of the radial shift is due to the following conditions \\
1020 - the approximation of a constant drift velocity over the drift length (larger drift velocities close to 
1021   cathode wire plane)\\
1022 - the superposition of charge tails in the amplification region (first clusters appear to be located at the 
1023   anode wire)\\
1024 - the superposition of charge tails in the drift region (shift towards anode wire)\\
1025 - diffusion effects which convolute with the TRF thus enlarging it\\
1026 - approximate knowledge of the TRF (approximate measuring in test beam conditions) \\
1027 The numerical results for ideal simulations for the radial are displayed in Figure \ref{FIG_CLUSTER:Xcorr}.
1028
1029 The representation of $dy=f(y_cen, x_drift| layer, \phi=tg(\alpha_L))$ can be also used to estimate the systematic shift in the $r-\phi$ 
1030 coordinate resulting from imperfection in the cluster shape parameterization. From Eq. \ref{EQ_CLUSTER:shift} with $\phi=tg(\alpha_L)$ one gets: 
1031 \begin{eqnarray}
1032 <\Delta y>&=& <\delta x> * (tg(\alpha_{L})-h*dz/dx) + <\delta y - \delta x * tg(\alpha_{L})>\\
1033 <\Delta y>(y_{cen})&=& -h*<\delta x>(x_{drift}, q_{cl}) * dz/dx + \delta y(y_{cen}, ...)
1034 \end{eqnarray}
1035 where all dependences are made explicit. This last expression can be used in two ways:
1036   - by average on the dz/dx we can determine directly dy (the method implemented here - see Figure \ref{FIG_CLUSTER:Xcorr} right) 
1037   - by plotting as a function of dzdx one can determine both dx and dy components in an independent method.
1038 The occurance of the $r-\phi$ shift is due to the following conditions:\\ 
1039   - approximate model for cluster shape (LUT)\\
1040   - rounding-up problems
1041
1042
1043 \subsection[Cluster error parameterization]{Cluster error parametrization\footnote{The procedures described in this section are implemented in the functions 
1044 {\tt AliTRDcluster::SetSigmaY2()}, {\tt AliTRDclusterResolution::ProcessCharge()}, {\tt AliTRDclusterResolution::ProcessCenterPad()}, {\tt AliTRDclusterResolution::ProcessSigma()} and {\tt AliTRDclusterResolution::ProcessMean()}.}}\label{REC:CL:error}
1045 {\it Author: A.~Bercuci (A.Bercuci@gsi.de)}
1046
1047 The error of TRD cluster is represented by the variance in the $r-\phi$ and radial direction. For the z direction the error is simply given by:
1048 \begin{equation}
1049 \sigma^2_z=L^2_{pad}/12
1050 \end{equation}
1051
1052 The parameters on which the {\bf $r-\phi$ error parameterization} depends are:\\ 
1053   - $s^2$  - variance due to PRF width for the case of Gauss model. Replaced by parameterization in case of LUT.\\
1054   - dt  - transversal diffusion coefficient\\ 
1055   - exb - tg of lorentz angle\\
1056   - x   - drift length - with respect to the anode wire\\
1057   - z   - offset from the anode wire\\
1058   - tgp - local tangent of the track momentum azimuthal angle\\
1059
1060 The ingredients from which the error is computed are:\\
1061   - PRF (charge sharing on adjacent pads)  - see AliTRDcluster::GetSYprf()
1062   - diffusion (dependence with drift length and [2nd order] distance to anode wire) - see AliTRDcluster::GetSYdrift()\\
1063   - charge of the cluster (complex dependence on gain and tail cancellation) - see AliTRDcluster::GetSYcharge()\\
1064   - lorentz angle (dependence on the drift length and [2nd order] distance to anode wire) - see AliTRDcluster::GetSX()\\
1065   - track angle (superposition of charges on the anode wire) - see AliTRDseedV1::Fit()\\
1066   - projection of radial(x) error on $r-\phi$ due to fixed value assumed in tracking for x - see AliTRDseedV1::Fit()\\
1067
1068 The last 2 contributions to cluster error can be estimated only during tracking when the track angle 
1069 is known (tgp). For this reason the errors (and optional position) of TRD clusters are recalculated during 
1070 tracking and thus clusters attached to tracks might differ from bare clusters.
1071
1072 Taking into account all contributions one can write the the TRD cluster error parameterization as:
1073 \begin{equation}\label{EQ_CLUSTER:error}
1074 \sigma_{y}^{2} = (\sigma_{diff}*Gauss(0, s_{ly}) + \delta_{\sigma}(q))^{2} + tg^{2}(\alpha_{L})*\sigma_{x}^{2} + tg^{2}(\phi-\alpha_{L})*\sigma_{x}^{2}+[tg(\phi-\alpha_{L})*tg(\alpha_{L})*x]^{2}/12
1075 \end{equation}
1076 From this formula one can deduce that the simplest calibration method for PRF and diffusion contributions is 
1077 by measuring resolution at B=0T and phi=0. To disentangle further the two remaining contributions one has 
1078 to represent $s^2$ as a function of drift length. 
1079
1080 In the gaussian model the diffusion contribution can be expressed as:
1081 \begin{equation}
1082 \sigma^{2}_{y} = \sigma^{2}_{PRF} + \frac{x\delta_{t}^{2}}{(1+tg(\alpha_{L}))^{2}}
1083 \end{equation}
1084 thus resulting the PRF contribution. For the case of the LUT model both contributions have to be determined from 
1085 the fit (see AliTRDclusterResolution::ProcessCenterPad() for details).\\
1086
1087 {\bf Parameterization with respect to the distance to the middle of the center pad}\\
1088
1089 If $\phi = \alpha_L$ in Eq. \ref{EQ_CLUSTER:error}  one gets the following expression:
1090 \begin{equation}\label{EQ_CLUSTER:errorPhiAlpha}
1091 \sigma_{y}^{2} = \sigma_{y}^{2}|_{B=0} + tg^{2}(\alpha_{L})*\sigma_{x}^{2}
1092 \end{equation}
1093 where we have explicitely marked the remaining term in case of absence of magnetic field. Thus one can use the 
1094 previous equation to estimate $s_y$ for B=0 and than by comparing in magnetic field conditions one can get the $s_x$.
1095 This is a simplified method to determine the error parameterization for $s_x$ and $s_y$ as compared to the one 
1096 implemented in ProcessSigma(). For more details on cluster error parameterization please see also 
1097 AliTRDcluster::SetSigmaY2().\\
1098
1099 {\bf Parameterization with respect to drift length and distance to the anode wire}\\
1100
1101 As the $r-\phi$ coordinate is the only one which is measured by the TRD detector we have to rely on it to
1102 estimate both the radial (x) and $r-\phi$ (y) errors. This method is based on the following assumptions. 
1103 The measured error in the y direction is the sum of the intrinsic contribution of the $r-\phi$ measurement
1104 with the contribution of the radial measurement - because x is not a parameter of Alice track model (Kalman).
1105 \begin{equation}
1106 \sigma^{2}|_{y} = \sigma^{2}_{y*} + \sigma^{2}_{x*}   
1107 \end{equation}
1108 In the general case 
1109 \begin{eqnarray}
1110 \sigma^{2}_{y*}& =& \sigma^{2}_{y} + tg^{2}(\alpha_{L})\sigma^{2}_{x_{drift}}\\   
1111 \sigma^{2}_{x*} &=& tg^{2}(\phi - \alpha_{L})*(\sigma^{2}_{x_{drift}} + \sigma^{2}_{x_{0}} + tg^{2}(\alpha_{L})*x^{2}/12)
1112 \end{eqnarray}
1113 where we have explicitely show the lorentz angle correction on y and the projection of radial component on the y
1114 direction through the track angle in the bending plane ($\phi$). Also we have shown that the radial component in the
1115 last equation has two terms, the drift and the misalignment ($x_0$). For ideal geometry or known misalignment one 
1116 can solve the equation
1117 \begin{equation}
1118 \sigma^{2}|_{y} = tg^{2}(\phi - \alpha_{L})*(\sigma^{2}_{x} + tg^{2}(\alpha_{L})*x^{2}/12)+ [\sigma^{2}_{y} + tg^{2}(\alpha_{L})\sigma^{2}_{x}]
1119 \end{equation}
1120 by fitting a straight line:
1121 \begin{equation}
1122 \sigma^{2}|_{y} = a(x_{cl}, z_{cl}) * tg^{2}(\phi - \alpha_{L}) + b(x_{cl}, z_{cl})
1123 \end{equation}
1124 the error parameterization will be given by:
1125 \begin{eqnarray}
1126 \sigma_{x} (x_{cl}, z_{cl}) &=& \sqrt{a(x_{cl}, z_{cl}) - tg^{2}(\alpha_{L})*x^{2}/12}\\
1127 \sigma_{y} (x_{cl}, z_{cl}) &=& \sqrt{b(x_{cl}, z_{cl}) - \sigma^{2}_{x} (x_{cl}, z_{cl}) * tg^{2}(\alpha_{L})}
1128 \end{eqnarray}
1129 In Figure \ref{FIG_CLUSTER:shift} left, there is an example of such dependency. 
1130
1131 The error parameterization obtained by this method are implemented in the functions AliTRDcluster::GetSX() and
1132 AliTRDcluster::GetSYdrift(). 
1133
1134 An independent method to determine $s_y$ as a function of drift length (see AliTRDclusterResolution::ProcessCenterPad()) is to plot cluster resolution as a function of drift length at $\phi = \alpha_L$ as seen in Eq. \ref{EQ_CLUSTER:errorPhiAlpha}. Thus one can use directly the 
1135 previous equation to estimate $s_y$ for $B=0$ and than by comparing in magnetic field conditions one can get the $s_x$.
1136
1137 One has to keep in mind that while the first method returns the mean $s_y$ over the distance
1138 to the middle of center pad ($y_{center}$) distribution the second method returns the *STANDARD* value at $y_{center}=0$ (maximum). To recover the 
1139 standard value one has to solve the obvious equation:
1140 \begin{equation}
1141 \sigma_{y}^{STANDARD} = \frac{<\sigma_{y}>}{\int{s exp(s^{2}/\sigma) ds}}
1142 \end{equation}
1143 with "$<s_y>$" being the value calculated in first method and "sigma" the width of the $s_y$ distribution calculated in the second.\\
1144
1145 {\bf Parameterization with respect to cluster charge}\\
1146
1147 In Eq. \ref{EQ_CLUSTER:errorPhiAlpha} one can explicitely write:
1148 \begin{equation}
1149 \sigma_{y}|_{B=0} = \sigma_{diff}*Gauss(0, s_{ly}) + \delta_{\sigma}(q)
1150 \end{equation}
1151 which further can be simplified to:
1152 \begin{eqnarray}
1153 <\sigma_{y}|_{B=0}>(q) &=& <\sigma_{y}> + \delta_{\sigma}(q)\\
1154 <\sigma_{y}> &=& \int{f(q)\sigma_{y}dq}
1155 \end{eqnarray}
1156 The results for $s_y$ and $f(q)$ are displayed in Figure \ref{FIG_CLUSTER:errorCharge}:
1157 \begin{figure}[htb]
1158 \begin{center}
1159 \includegraphics[width=0.48\textwidth]{plots/clusterQerror.eps}
1160 \includegraphics[width=0.48\textwidth]{plots/clusterSX.eps}
1161 \includegraphics[width=0.48\textwidth]{plots/clusterSY.eps}
1162 \end{center}
1163 \caption{
1164 Cluster error parameterization for different components.}
1165 \label{FIG_CLUSTER:errorCharge}
1166 \end{figure}
1167 The function has to extended to accommodate gain calibration scaling and errors.
1168
1169 %
1170 \setcounter{footnote}{0}
1171 \section{The TRD tracklet}\label{REC:Tracklet:}
1172 {\it Author: A.~Bercuci (A.Bercuci@gsi.de)}\\
1173
1174 \noindent
1175 The tracking in TRD can be done in two major ways:
1176 \begin{itemize}
1177 \item Track prolongation from TPC.
1178 \item Stand alone track finding.
1179 \end{itemize}
1180 The first mode is the main tracking mode for all barrel tracks while the second 
1181 is used to peak-up track segments fully contained in the TRD fiducial volume 
1182 like conversions. Another feature of the TRD tracking besides the relative high 
1183 thickness (conversions) is the spatial correlation of the signals in the radial 
1184 direction due to residual tails in the cluster signals. This feature asked for 
1185 an intermediate step between clusters and tracks, the tracklets. The TRD 
1186 tracklets are linear fits of the clusters from one chamber. They are implemented 
1187 in the class {\tt AliTRDseedV1} and they represent the core of the TRD offline 
1188 reconstruction. In the following the tracklets will be described independently 
1189 of the framework in which they are living (tracking) in the sections 
1190 \ref{REC:Tracking:TrackletAttach}, \ref{REC:Tracking:TrackletFit} and 
1191 \ref{REC:Tracking:TrackletErrors} and than their usage will be outlined in the 
1192 barrel (section \ref{REC:Tracking:Propagate}) and stand alone tracking (section 
1193 \ref{REC:Tracking:Clusters2TracksStack}).
1194
1195 \subsection[Tracklet building]{Tracklet building - Attaching clusters to tracklet\footnote{The 
1196 procedures described in this section are implemented in the function 
1197 {\tt AliTRDseedV1::AttachClusters()}.}}\label{REC:Tracking:TrackletAttach}
1198
1199 Projective algorithm to attach clusters to seeding tracks. The following steps are performed :\\
1200 1. Collapse x coordinate for the full detector along track direction dydx.\\
1201 2. truncated mean on y (r-phi) direction\\
1202 3. purge clusters\\
1203 4. truncated mean on z direction\\
1204 5. purge clusters\\
1205 Optionally one can use the z, dz/dx information from the seeding track to correct for tilting.
1206         
1207 We start up by defining the track direction in the xy plane and roads. The roads are calculated based
1208 on tracking information (variance in the $r-\phi$ direction) and estimated variance of the standard 
1209 clusters (see AliTRDcluster::SetSigmaY2()) corrected for tilt (see GetCovAt()). From this the road is.
1210 \begin{eqnarray}
1211 r_{y} &=& 3*\sqrt{12*(\sigma^{2}_{Trk}(y) + \frac{\sigma^{2}_{cl}(y) + tg^{2}(\alpha_{L})\sigma^{2}_{cl}(z)}{1+tg^{2}(\alpha_{L})})}\\
1212 r_{z} &= &1.5*L_{pad}
1213 \end{eqnarray}
1214
1215 \subsection[Tracklet fitting]{Tracklet fitting\footnote{The procedures described in this 
1216 section are implemented in the function {\tt AliTRDseedV1::Fit()}.}}\label{REC:Tracking:TrackletFit}
1217
1218 {\bf Fit in the xy plane}\\
1219
1220 The fit is performed to estimate the y position of the tracklet and the track 
1221 angle in the bending plane. The clusters are represented in the chamber coordinate 
1222 system (with respect to the anode wire - see {\tt AliTRDtrackerV1::FollowBackProlongation()} 
1223 on how this is set). The $x$ and $y$ position of the cluster and also their variances 
1224 are known from clusterizer level (see {\tt AliTRDcluster::GetXloc()}, 
1225 {\tt AliTRDcluster::GetYloc()}, {\tt AliTRDcluster::GetSX()} and \\
1226 {\tt AliTRDcluster::GetSY()}). If a Gaussian approximation is used to calculate 
1227 $y$ coordinate of the cluster the position is recalculated taking into account the 
1228 track angle.
1229
1230 Since errors are calculated only in the $y$ directions, radial errors ($x$ direction) 
1231 are mapped to $y$ by projection i.e.
1232 \begin{equation}
1233 \sigma_{x|y} = tg(\phi) \sigma_{x}
1234 \end{equation}
1235 and also by the Lorentz angle correction.\\
1236
1237 {\bf Fit in the xz plane}\\
1238
1239 The "fit" is performed to estimate the radial position ($x$ direction) where pad 
1240 row cross happens. If no pad row crossing the $z$ position is taken from geometry 
1241 and radial position is taken from the xy fit (see below).
1242
1243 There are two methods to estimate the radial position of the pad row cross:\\
1244 1. leading cluster radial position : Here the lower part of the tracklet is 
1245 considered and the last cluster registered (at radial $x_{0}$) on this segment 
1246 is chosen to mark the pad row crossing. The error of the $z$ estimate is given by :
1247 \begin{equation}
1248 \sigma_{z} = tg(\theta) \Delta x_{x_{0}}/\sqrt{12}
1249 \end{equation}
1250 The systematic errors for this estimation are generated by the following sources:
1251   - no charge sharing between pad rows is considered (sharp cross)
1252   - missing cluster at row cross (noise peak-up, under-threshold signal etc.).
1253 \\
1254 2. charge fit over the crossing point : Here the full energy deposit along 
1255 the tracklet is considered to estimate the position of the crossing by a fit 
1256 in the qx plane. The errors in the q directions are parameterized as 
1257 $\sigma_q = q^2$. The systematic errors for this estimation are generated by the 
1258 following sources:
1259   - no general model for the qx dependence
1260   - physical fluctuations of the charge deposit 
1261   - gain calibration dependence.\\
1262
1263 {\bf Estimation of the radial position of the tracklet}\\
1264
1265 For pad row cross the radial position is taken from the xz fit (see above). 
1266 Otherwise it is taken as the interpolation point of the tracklet i.e. the 
1267 point where the error in $y$ of the fit is minimum. The error in the $y$ 
1268 direction of the tracklet is (see {\tt AliTRDseedV1::GetCovAt()}):
1269 \begin{equation}
1270 \sigma_{y} = \sigma^{2}_{y_{0}} + 2x\:cov(y_{0}, dy/dx) + \sigma^{2}_{dy/dx}
1271 \end{equation}
1272 and thus the radial position is:
1273 \begin{equation}
1274 x = - cov(y_{0}, dy/dx)/\sigma^{2}_{dy/dx}
1275 \end{equation}
1276
1277 {\bf Estimation of tracklet position error}\\ 
1278
1279 The error in $y$ direction is the error of the linear fit at the radial 
1280 position of the tracklet while in the $z$ direction is given by the cluster 
1281 error or pad row cross error. In case of no pad row cross this is given by:
1282 \begin{eqnarray}
1283 \sigma_{y} &=& \sigma^{2}_{y_{0}} - 2cov^{2}(y_{0}, dy/dx)/\sigma^{2}_{dy/dx} + \sigma^{2}_{dy/dx}\\
1284 \sigma_{z} &=& L_{pad}/\sqrt{12}
1285 \end{eqnarray}
1286 For pad row cross the full error is calculated at the radial position of the 
1287 crossing (see above) and the error in $z$ by the width of the crossing region - 
1288 being a matter of parameterization. 
1289 \begin{equation}
1290 \sigma_{z} = tg(\theta) \Delta x_{x_{0}}/\sqrt{12}
1291 \end{equation}
1292 In case of no tilt correction (default in the barrel tracking) the tilt is 
1293 taken into account by the rotation of the covariance matrix. See 
1294 {\tt AliTRDseedV1::GetCovAt()} or \ref{REC:Tracking:TrackletErrors} for details.
1295
1296 \subsection[Tracklet errors]{Tracklet errors\footnote{The procedures described in this 
1297 section are implemented in the function {\tt AliTRDseedV1::GetCovAt()}.}}\label{REC:Tracking:TrackletErrors}
1298
1299 In general, for the linear transformation
1300 \begin{equation}
1301 Y = T_{x} X^{T}
1302 \end{equation}
1303 the error propagation has the general form
1304 \begin{equation}
1305 C_{Y} = T_{x} C_{X} T_{x}^{T} 
1306 \end{equation}
1307 We apply this formula 2 times. First to calculate the covariance of the tracklet 
1308 at point $x$ we consider: 
1309 \begin{eqnarray}
1310 T_{x} &=& (1\; x)\\ 
1311 X&=&(y0\; dy/dx)\\
1312 C_{X}&=&
1313   \left( \begin{array}{cc}
1314     Var(y0) & Cov(y0, dy/dx)\\
1315     Cov(y0, dy/dx) & Var(dy/dx) 
1316   \end{array} \right)
1317 \end{eqnarray}
1318 and secondly to take into account the tilt angle
1319 \begin{eqnarray}
1320 T_{\alpha}& = &
1321   \left( \begin{array}{cc}
1322     cos(\alpha)&sin(\alpha)\\
1323     -sin(\alpha)& cos(\alpha)
1324   \end{array} \right)\\
1325 X&=&(y\; z)\\ 
1326 C_{X}&=&
1327   \left( \begin{array}{cc}
1328     Var(y) &0\\
1329     0 &Var(z) 
1330   \end{array} \right)
1331 \end{eqnarray}
1332 using simple trigonometric one can write for this last case
1333 \begin{equation}
1334 C_{Y}=\frac{1}{1+tg^{2}\alpha} 
1335   \left( \begin{array}{cc}
1336     \sigma_{y}^{2}+tg^{2}(\alpha)\sigma_{z}^{2} &  tg(\alpha)(\sigma_{z}^{2}-\sigma_{y}^{2})\\
1337     tg(\alpha)(\sigma_{z}^{2}-\sigma_{y}^{2}) & \sigma_{z}^{2}+tg^{2}(\alpha)\sigma_{y}^{2}
1338   \end{array} \right)
1339 \end{equation}
1340 which can be approximated for small alphas (2 deg) with
1341 \begin{equation}
1342 C_{Y}=
1343   \left( \begin{array}{cc}
1344     \sigma_{y}^{2} & (\sigma_{z}^{2}-\sigma_{y}^{2})tg(\alpha)\\
1345     ((\sigma_{z}^{2}-\sigma_{y}^{2})tg(\alpha) & \sigma_{z}^{2} 
1346   \end{array} \right)
1347 \end{equation}
1348 before applying the tilt rotation we also apply systematic uncertainties 
1349 to the tracklet position which can be tuned from outside via the 
1350 {\tt AliTRDrecoParam::SetSysCovMatrix()}. They might account for extra 
1351 misalignment/miscalibration uncertainties. 
1352
1353 \subsection[Tracklet dE/dx]{Energy loss calculations\footnote{The procedures described in this 
1354 section are implemented in the function {\tt AliTRDseedV1::CookdEdx()} and {\tt AliTRDseedV1::GetdQdl()}.}}\label{REC:Tracking:TrackletdEdx}
1355
1356 Using the linear approximation of the track inside one TRD chamber (TRD tracklet) 
1357 the charge per unit length can be written as:
1358 \begin{equation}
1359 \frac{dq}{dl}(x) = \frac{q_{c}}{dx(x) * \sqrt{1 + (\frac{dy}{dx})^{2}_{fit} + (\frac{dz}{dx})^{2}_{ref}}}
1360 \end{equation}
1361 where $q_c$ is the total charge collected in the current time bin and dx is the length 
1362 of the time bin (see Figure \ref{FIG_TRACKLET:dEdx} right). The representation of charge deposit used for PID differs thus in principle from the measured dQ/dt distribution (see Figure \ref{FIG_TRACKLET:dEdx} left) 
1363 \begin{figure}[htb]
1364 \begin{center}
1365 \includegraphics[width=0.88\textwidth, height=0.45\textwidth]{plots/trackletDQDT.eps}
1366 \end{center}
1367 \caption{
1368 Energy loss measurement on the tracklet as a function of drift time [left] and respectively drift length [right] for different particle species.}
1369 \label{FIG_TRACKLET:dEdx}
1370 \end{figure} 
1371 The following correction are applied :
1372   - charge : pad row cross corrections
1373              [diffusion and TRF asymmetry] TODO
1374   - dx     : anisochronity.
1375 Due to anisochronity of the TRD detector drift velocity varies as function of drift length and distance to the anode wire. Thus 
1376 \begin{eqnarray}
1377 dx(x) &=& dx(\inf) + \delta_x(x,z)\\ 
1378       &=& dt*v_d^{\inf} + \delta_x(x,z) 
1379 \end{eqnarray}
1380 the dependence of $\delta_x$ can be found in Figure \ref{FIG_CLUSTER:Xcorr}.
1381
1382 \subsection[Tracklet PID]{Particle identification\footnote{The procedures described in this 
1383 section are implemented in the function {\tt AliTRDtrackV1::CookPID()} and {\tt AliTRDseedV1::CookPID()}.}}\label{REC:Tracking:TrackletPID}
1384
1385 Retrieve PID probabilities for $e^\pm$, $\mu^\pm$, $K^\pm$, $\pi^\pm$ and $p^\pm$ from the DB according to tracklet information:
1386 \begin{itemize}
1387 \item[-] estimated momentum at tracklet reference point 
1388 \item[-] dE/dx measurements
1389 \item[-] tracklet length
1390 \item[-] TRD layer
1391 \end{itemize}
1392 According to the steering settings specified in the reconstruction one of the following methods are used.\\
1393 - Neural Network [default] - option "nn"\\
1394 - 2D Likelihood - option "!nn"\\
1395 \begin{figure}[htb]
1396 \begin{center}
1397 \includegraphics[width=0.88\textwidth, height=0.45\textwidth]{plots/trackPID.eps}
1398 \end{center}
1399 \caption{
1400 Pion efficiency capability of TRD for tracks with 6 tracklets as a function of momentum [left] and the corresponding threshold value for selecting $90\%$ of electrons [right] for the two methods used defined in TRD.}
1401 \label{FIG_TRACK:PID}
1402 \end{figure}
1403
1404 At track level the PID information is calculated by delegating the omonim function of the tracklets. 
1405 The number of tracklets used is also computed. The tracklet information are considered independent. 
1406 For the moment no global track measurement of PID is performed as for example to estimate 
1407 bremsstrahlung probability based on global $\chi^2$ of the track. The status bit AliESDtrack::kTRDpid is set during the call of AliTRDtrackV1::UpdateESDtrack().The PID performance of the TRD for tracks with 6 tacklets is displayed in Figure \ref{FIG_TRACK:PID}. \\
1408
1409
1410 \setcounter{footnote}{0}
1411 \section{Tracking}\label{REC:Tracking:}
1412 {\it Author: A.~Bercuci (A.Bercuci@gsi.de)}\\
1413
1414 The tracking procedures in TRD are responsible to attach clusters to tracks 
1415 and to estimate/update the track parameters accordingly. The main class involved 
1416 in this procedure is {\tt AliTRDtrackerV1} and the helper classes {\tt AliTRDcluster}, 
1417 {\tt AliTRDseedV1} and {\tt AliTRDtrackV1}.  Additionally, information from 
1418 {\tt AliTRDrecoParam} is mandatory to select the proper setup of the reconstruction.
1419 \\
1420
1421 \subsection[Track propagation barrel]{Track propagation in barrel tracking\footnote{The 
1422 procedures described in this section are implemented in the function 
1423 {\tt AliTRDtrackerV1::PropagateBack()}.}}\label{REC:Tracking:Propagate}
1424
1425 Propagate the ESD tracks from TPC to TOF detectors and building of the TRD track. For building
1426 a TRD track an ESD track is used as seed. The informations obtained on the TRD track (measured points,
1427 covariance, PID, etc.) are than used to update the corresponding ESD track.
1428 Each track seed is first propagated to the geometrical limit of the TRD detector. 
1429 Its prolongation is searched in the TRD and if corresponding clusters are found tracklets are 
1430 constructed out of them (see AliTRDseedV1::AttachClusters()) and the track is updated. 
1431 Otherwise the ESD track is left unchanged.
1432
1433 The following steps are performed:
1434 \begin{itemize}
1435 \item[1.] Selection of tracks based on the variance in the y-z plane.
1436 \item[2.] Propagation to the geometrical limit of the TRD volume. If track propagation fails the AliESDtrack::kTRDStop is set.
1437 \item[3.] Prolongation inside the fiducial volume (see AliTRDtrackerV1::FollowBackProlongation()) and marking
1438 the following status bits:
1439   \begin{itemize}
1440   \item[a.] AliESDtrack::kTRDin - if the tracks enters the TRD fiducial volume
1441   \item[b.] AliESDtrack::kTRDStop - if the tracks fails propagation  
1442   \item[c.] AliESDtrack::kTRDbackup - if the tracks fulfills chi2 conditions and qualify for refitting
1443   \end{itemize}
1444 \item[4.] Writting to friends, PID, MC label, quality etc. Setting status bit AliESDtrack::kTRDout.
1445 \item[5.] Propagation to TOF. If track propagation fails the AliESDtrack::kTRDStop is set.
1446 \end{itemize}
1447
1448 {\bf TRD Tracklet initialization and Kalman fit}\footnote{The procedures 
1449 described in this section are implemented in the function 
1450 {\tt AliTRDtrackerV1::FollowBackProlongation()}.}\\
1451
1452 Starting from the arbitrary radial position of the track this is
1453 extrapolated through the 6 TRD layers. The following steps
1454 are being performed for each layer:
1455 \begin{itemize}
1456 \item[1.] Propagate track to the entrance of the next chamber:\\
1457   - get chamber limits in the radial direction\\
1458   - check crossing sectors \\
1459   - check track inclination\\
1460   - check track prolongation against boundary conditions (see exclusion boundaries on AliTRDgeometry::IsOnBoundary())
1461 \item[2.] Build tracklet (see AliTRDseed::AttachClusters() for details) for this layer if needed. If only 
1462    Kalman filter is needed and tracklets are already linked to the track this step is skipped.
1463 \item[3.] Fit tracklet using the information from the Kalman filter.
1464 \item[4.] Propagate and update track at reference radial position of the tracklet.
1465 \item[5.] Register tracklet with the tracker and track; update pulls monitoring.
1466 \end{itemize}
1467
1468 During the propagation a bit map is filled detailing the status of the track in each TRD chamber.\\
1469 - AliTRDtrackV1::kProlongation : track prolongation failed\\
1470 - AliTRDtrackV1::kPropagation : track prolongation failed\\
1471 - AliTRDtrackV1::kAdjustSector : failed during sector crossing\\
1472 - AliTRDtrackV1::kSnp : too large bending\\
1473 - AliTRDtrackV1::kTrackletInit : fail to initialize tracklet\\
1474 - AliTRDtrackV1::kUpdate : fail to attach clusters or fit the tracklet\\
1475 - AliTRDtrackV1::kUnknown : anything which is not covered before\\
1476 By default the status of the track before first TRD update is saved. 
1477
1478 \subsection[Stand alone track finding]{Stand alone track finding\footnote{The procedures 
1479 described in this section are implemented in the function 
1480 {\tt AliTRDtrackerV1::Clusters2TracksStack()}.}}\label{REC:Tracking:Clusters2TracksStack}
1481
1482 Seeding tracklets and build candidate TRD tracks. The procedure is used during barrel tracking to account for tracks which are 
1483 either missed by TPC prolongation or are conversions inside the TRD volume. 
1484 For stand alone tracking the procedure is used to estimate all tracks measured by TRD. 
1485
1486 {\bf TRD track finding}\footnote{The procedures described in this section 
1487 are implemented in the function {\tt AliTRDtrackerV1::MakeSeeds()}.}
1488
1489 The following steps are performed:
1490 \begin{itemize}
1491 \item[1.] Build seeding layers by collapsing all time bins from each of the four seeding chambers along the 
1492 radial coordinate. See AliTRDtrackingChamber::GetSeedingLayer() for details. The chambers selection for seeding
1493 is described in AliTRDtrackerV1::Clusters2TracksStack().
1494 \item[2.] Using the seeding clusters from the seeding layer (step 1) build combinatorics using the following algorithm:\\
1495 - for each seeding cluster in the lower seeding layer find\\
1496 - all seeding clusters in the upper seeding layer inside a road defined by a given phi angle. The angle 
1497   is calculated on the minimum pt of tracks from vertex accesible to the stand alone tracker.\\
1498 - for each pair of two extreme seeding clusters select middle upper cluster using roads defined externally by the 
1499   reco params\\
1500 - select last seeding cluster as the nearest to the linear approximation of the track described by the first three
1501   seeding clusters.
1502   The implementation of road calculation and cluster selection can be found in the functions AliTRDchamberTimeBin::BuildCond()
1503   and AliTRDchamberTimeBin::GetClusters().   
1504 \item[3.] Helix fit of the seeding clusters set. (see AliTRDtrackerFitter::FitRieman(AliTRDcluster**)). No tilt correction is 
1505    performed at this level 
1506 \item[4.] Initialize seeding tracklets in the seeding chambers.
1507 \item[5.] {\bf Filter 0} Chi2 cut on the Y and Z directions. The threshold is set externally by the reco params.
1508 \item[6.] Attach (true) clusters to seeding tracklets (see AliTRDseedV1::AttachClusters()) and fit tracklet (see 
1509    AliTRDseedV1::Fit()). The number of used clusters used by current seeds should not exceed ... (25).
1510 \item[7.] {\bf Filter 1} Check if all 4 seeding tracklets are correctly constructed.
1511 \item[8.] Helix fit of the clusters from the seeding tracklets with tilt correction. Refit tracklets using the new 
1512    approximation of the track. The model of the Riemann tilt fit is based on solving simultaneously the equations:
1513 \begin{eqnarray}
1514 R^{2} &=& (x-x_{0})^{2} + (y^{*}-y_{0})^{2}\\
1515 y^{*} &=& y - tg(h)(z - z_{t})\\
1516 z_{t} &=& z_{0}+dzdx*(x-x_{r})
1517 \end{eqnarray}
1518 with $(x, y, z)$ the coordinate of the cluster, $(x_0, y_0, z_0)$ the coordinate of the center of the Riemann circle,
1519 R its radius, $x_r$ a constant reference radial position in the middle of the TRD stack  and dzdx the slope of the 
1520 track in the x-z plane. Using the following transformations
1521 \begin{eqnarray}
1522 t &=& 1 / (x^{2} + y^{2})\\
1523 u &=& 2 * x * t\\
1524 v &=& 2 * tg(h) * t\\
1525 w &=& 2 * tg(h) * (x - x_{r}) * t
1526 \end{eqnarray}
1527 One gets the following linear equation
1528 \begin{equation}
1529 a + b * u + c * t + d * v  + e * w = 2 * (y + tg(h) * z) * t
1530 \end{equation}
1531 where the coefficients have the following meaning 
1532 \begin{eqnarray}
1533 a &=& -1/y_{0}\\
1534 b &=& x_{0}/y_{0}\\
1535 c &=& (R^{2} -x_{0}^{2} - y_{0}^{2})/y_{0}\\
1536 d &=& z_{0}\\
1537 e &=& dz/dx
1538 \end{eqnarray}
1539 The error calculation for the free term is thus
1540 \begin{equation}
1541 \sigma = 2 * \sqrt{\sigma^{2}_{y}(tilt\ corr ...) + tg^{2}(h) * \sigma^{2}_{z}} * t
1542 \end{equation}
1543
1544 From this simple model one can compute $\chi^2$ estimates and a rough approximation of $1/p_t$ from the 
1545 curvature according to the formula:
1546 \begin{equation}
1547 C = 1/R = a/(1 + b^{2} + c*a)
1548 \end{equation}
1549
1550 \item[9.] {\bf Filter 2} Calculate likelihood of the track. (See AliTRDtrackerV1::CookLikelihood()). The following quantities are checked against the Riemann fit:\\
1551      - position resolution in y\\
1552      - angular resolution in the bending plane\\
1553      - likelihood of the number of clusters attached to the tracklet
1554 \item[10.] Extrapolation of the helix fit to the other 2 chambers *non seeding* chambers:\\
1555      - Initialization of extrapolation tracklets with the fit parameters\\
1556      - Attach clusters to extrapolated tracklets\\
1557      - Helix fit of tracklets
1558 \item[11.] Improve seeding tracklets quality by reassigning clusters based on the last parameters of the track
1559      See AliTRDtrackerV1::ImproveSeedQuality() for details.
1560 \item[12.] Helix fit of all 6 seeding tracklets and chi2 calculation
1561 \item[13.] Hyperplane fit and track quality calculation. See AliTRDtrackerFitter::FitHyperplane() for details.
1562 \item[14.] Cooking labels for tracklets. Should be done only for MC
1563 \item[15.] Register seeds.
1564 \end{itemize}
1565
1566 %
1567 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1568 \newpage
1569 \setcounter{chapter}{3}
1570 \setcounter{section}{0}    
1571 \Chapter{Calibration}
1572 %
1573 {\it Author: R.~Bailhache (rbailhache@ikf.uni-frankfurt.de)}
1574 \smallskip
1575 \\
1576 %
1577 \section{Database Entries}
1578 A local database with default parameters can be found in the AliRoot 
1579 installation directory. The official database is in Alien under the 
1580 directory 
1581 {\tt /alice/data/$\langle$year$\rangle$/$\langle$LHCPeriod$\rangle$/OCDB}. 
1582 The calibration objects are stored in root files named according to their 
1583 run validity range, their version and subversion number. For the TRD they 
1584 are in the subdirectory {\tt \$AliRoot/OCDB/TRD/Calib} and correspond to 
1585 a perfect TRD detector. The parameters are listed in Tab.\ref{entriesdatabase}.\\  
1586 \begin{table} [h]
1587   \begin{center}
1588     \begin{tabular}{|c|c|c|c|c|c|}
1589       \hline Parameter                  & Description                                        & Number of         & Data type  & Unit & Default value \\ 
1590                                         &                                                    & channels          &            &  &  \\ \hline
1591       ChamberGainFactor                 & Mean gas gain                                      & 540               & Float      & $-$  & 1.0          \\ 
1592       $ $                               & per chamber                                        &                   &            &  &          \\ \hline
1593       LocalGainFactor                   & Gas gain                                           & 1181952           & UShort     & $-$  & 1.0   \\ 
1594                                         & per pad                                            & 1181952           & UShort     & $-$  & 1.0   \\ \hline
1595       ChamberVdrift                     & Mean drift velocity                                & 540               & Float      & cm$/$$\mu$s & 1.5 \\ 
1596                                         & per chamber                                        & 540               & Float      & cm$/$$\mu$s & 1.5 \\ \hline
1597       LocalVdrift                       & Drift velocity                                     & 1181952           & UShort     & $-$ & 1.0  \\ 
1598                                         &  per pad                                           & 1181952           & UShort     & $-$ & 1.0  \\ \hline
1599       ChamberT0                         & Minimum timeoffset                                 & 540               & Float      & timebin  & 0.0   \\ 
1600                                         & in the chamber                                        & 540               & Float      & timebin  & 0.0   \\ \hline
1601       LocalT0                           & Timeoffset                                         & 1181952           & UShort     & timebin & 0.0  \\ 
1602                                         & per pad                                            &                   &            &  &   \\ \hline
1603       PRFWidth                          & Width of the PRF                                   & 1181952           & UShort     & pad width &  0.515 ( layer 0) \\
1604       $ $                               & per pad                                            & $ $               & $ $        & $ $       &  0.502 ( layer 1) \\
1605       $ $                               & $ $                                                & $ $               & $ $        & $ $       &  0.491 ( layer 2) \\
1606       $ $                               & $ $                                                & $ $               & $ $        & $ $       &  0.481 ( layer 3) \\
1607       $ $                               & $ $                                                & $ $               & $ $        & $ $       &  0.471 ( layer 4) \\
1608       $ $                               & $ $                                                & $ $               & $ $        & $ $       &  0.463 ( layer 5) \\ \hline
1609       DetNoise                          & Scale factor                                       & 540               & Float      & $-$ & 0.1  \\ \hline
1610       PadNoise                          & Noise                                              & 1181952           & UShort     & ADC  & 12  \\ 
1611                                         & per pad                                            &                   &            & counts &   \\ \hline
1612       PadStatus                         & Status                                             & 1181952           & char       & $-$  & $-$   \\ 
1613                                         & per pad                                            &                   &            &  &   \\ \hline
1614     \end{tabular}
1615   \end{center}
1616 \caption{\label{entriesdatabase}Entries in the database}
1617 \end{table}
1618 %
1619 They are related to the calibration of:
1620 \begin{itemize}
1621 \item the gas gain: {\tt ChamberGainFactor} and {\tt LocalGainFactor}
1622 \item the electron drift velocity: {\tt ChamberVdrift} and {\tt LocalVdrift}
1623 \item the timeoffset: {\tt ChamberT0} and {\tt LocalT0}
1624 \item the width of the Pad Response Function: {\tt PRFWidth}
1625 \item the noise per channel: {\tt DetNoise}, {\tt PadNoise} and {\tt PadStatus}.
1626 \end{itemize} 
1627 To save disk space the values per pad are stored in UShort (2 Bytes) 
1628 format in AliTRDCalROC objects, one per chamber, that are members of 
1629 a general {\tt AliTRDCalPad} object. The final constants have a 
1630 numerical precision of 10$^{-4}$. They are computed by 
1631 multiplication (gain, drift velocity and noise) or addition (timeoffset) 
1632 of the detector and pad coefficients. From the pad noise level a status 
1633 is determined for each pad ( masked, bridgedleft, bridgedright, read by 
1634 the second MCM, not connected). One example macro ({\tt AliTRDCreate.C}) 
1635 to produce a local database is given in the {\tt \$AliRoot/TRD/Macros} 
1636 directory.\\
1637 During the simulation of the detector response and the reconstruction 
1638 of the events the parameters are used to compute the amplitude of the 
1639 signal and its position inside the detector. The database has to be 
1640 first choosen with the help of the {\tt AliCDBManager}. The parameters 
1641 are then called by an {\tt AliTRDcalibDB} instance. The macro 
1642 {\tt \$AliRoot/TRD/Macros/ReadCDD.C} shows how to read a local database 
1643 and plot the gas gain or drift velocity as function of the detector 
1644 number or pad number.
1645 %
1646 \section{DAQ Calibration}
1647 Calibration procedures are performed online during data-taking on 
1648 different systems. The principal role of the Data AcQuisition System is 
1649 to build the events and archive the data to permanent storage tapes. In 
1650 addition it also provides an efficient access to the data. Nevertheless 
1651 the complete reconstruction of the events with tracks is not available. 
1652 Two algorithms are executed on DAQ for the TRD: a pedestal algorithm and 
1653 an algorithm for the drift velocity and timeoffset. They are implemented 
1654 as rpm packages, that can be easily built inside AliRoot compiled with 
1655 the DATE software \cite{DATE}. The outputs of the algorithms are stored 
1656 in root files and put on the DAQ File Exchange Server (FXS). At the end 
1657 of the run they are picked up by the so called SHUTTLE and further 
1658 processed in the Preprocessor to fill finally the OCDB. 
1659 \begin{figure}[h]
1660   \centering\mbox{\epsfig{file=plots/baselinenoisedet0run34510ex.eps,width=0.45\textwidth}}
1661   \caption{\label{baselinenoisedet0run34510ex}2D histogram of the 
1662 detector 0 (SM 0, S0, L0) with the ADC value distributions around 
1663 the baseline (10 ADC counts) for each pad (PEDESTAL run 34510).}
1664 \end{figure}
1665 \subsection{Pedestal algorithm}
1666 During a pedestal run empty events without zero suppression are taken 
1667 with the TRD alone and a random trigger. They are used to determine 
1668 the noise in ADC counts of each pad. The algorithm can be found in the 
1669 {\tt TRDPEDESTALda.cxx} file of the AliRoot TRD directory. It is 
1670 executed on the Local Data Concentrators (LDCs), which are part of the 
1671 dataflow and gives access to sub-events. The TRD has three LDCs 
1672 corresponding to the following blocks of supermodules (SMs):
1673 \begin{itemize}
1674 \item 0-1-2-9-10-11
1675 \item 3-4-5-12-13-14
1676 \item 6-7-8-15-16-17
1677 \end{itemize}   
1678 Three algorithms are therefore executed in parallel during a PEDESTAL 
1679 run for a full installed TRD. After about 100 events, the data-taking 
1680 stops automatically and a 2D histogram is filled for each chamber with 
1681 the ADC amplitude distributions around the baseline for each pad. Such 
1682 a histogram is shown in Fig.\ref{baselinenoisedet0run34510ex} for 
1683 chamber 0 (SM 0 Stack 0 Layer 0).
1684 \begin{figure}[h]
1685   \centering\mbox{\epsfig{file=plots/run38125sm0nounfold.eps,width=0.88\textwidth,height=0.55\textwidth}}
1686   \caption{\label{run38125sm0nounfold}Noise in the six planes of 
1687 SM 0 (PEDESTAL run 38125). The five stacks in each layer are in 
1688 the {\it{z}} direction.}
1689 \end{figure}
1690 The chambers should be so configured that the data is without zero 
1691 suppression otherwise an error message appears on the DAQ online 
1692 Logbook. The container class is called {\tt AliTRDCalibPadStatus} 
1693 and allows to further fit the distributions with a Gaussian to 
1694 determine the baseline and noise of each pad. The function is called 
1695 {\tt AliTRDCalibPadStatus::AnalyseHisto()}. In 
1696 Fig.\ref{run38125sm0nounfold} the noise in SM 0 is plotted for the 
1697 PEDESTAL run 38125. It shows stripe patterns of higher noise in the 
1698 $z$-direction (beam direction) correlated to the static pad capacitance 
1699 of the pad plane. The noise distributions has to be first corrected 
1700 for the expected noise variations induced by the pad capacitance 
1701 before a status can be given to each pad. This is not done on the DAQ 
1702 but just before storing the parameters inside the Offline Condition 
1703 Database (OCDB) in the Preprocessor.
1704
1705 \subsection{Drift velocity and timeoffset algorithm}
1706 The drift velocity and timeoffset are calibrated with physics events, 
1707 $pp$ or $PbPb$ collisions. The algorithm is called 
1708 {\tt TRDVDRIFTda.cxx} and can be found in the AliRoot TRD directory. 
1709 It is executed on a dedicated monitoring server, which is not part 
1710 of the dataflow and gives access to full events of the TRD. The 
1711 physics events are used to fill continuously during data-taking an 
1712 average pulse height for each detector. They are stored in a 
1713 {\tt TProfile2D}, which is a member of a { \tt AliTRDCalibraFillHisto} 
1714 object. The {\tt TProfile2D} is written at the end of the run in a 
1715 root file put on the DAQ FXS.\\
1716 \begin{figure}[h]
1717   \centering\mbox{\epsfig{file=plots/referenceph2d.eps,width=0.6\textwidth,,height=0.5\textwidth}}
1718   \caption{\label{referenceph2d}2D histogram containing the average 
1719 pulse height distributions of each calibration group (here detector), 
1720 produced with decalibrated simulated $pp$ events.}
1721 \end{figure}
1722
1723 Fig.\ref{referenceph2d} shows an output {\tt TProfile2D} obtained 
1724 from simulated decalibrated $pp$ collisions at 14\,TeV. The first 
1725 peak in time corresponds to the amplification region, where the 
1726 contributions of ionization electrons, which come from both sides 
1727 of the anode wire plane, are overlapping. The flat plateau results 
1728 from the electrons in the drift region. The tail is caused by the 
1729 Time Response Function. From this average signal as function of time 
1730 the drift velocity and timeoffset can be extracted by fit procedures. 
1731 This last step is performed in the Preprocessor.\\
1732 Since no tracking is available on DAQ, a simple tracklet finder is 
1733 used. It was optimized for a low charged particle multiplicity 
1734 environment. The algorithm looks for a maximum of the signal 
1735 amplitudes in the chamber after integration over all timebins. The 
1736 average pulse height is then filled for a spot of two pad rows 
1737 ($z$ direction) and four pad columns ($r\phi$ direction) around the 
1738 maximum. Further details can be found in the function 
1739 {\tt AliTRDCalibraFillHisto::ProcessEventDAQ}.
1740 %
1741 \section{HLT Calibration}
1742 The High Level Trigger has the big advantage to provide an online 
1743 reconstruction of the events. The idea is then to run the calibration 
1744 procedures in a transparent way, independent whether online or 
1745 offline. The same function 
1746 \\{\tt AliTRDCalibraFillHisto::UpdateHistogramsV1(AliTRDtrackV1 *t)} 
1747 is used to fill the $dE/dx$ distributions (gain), the average pulse 
1748 height (drift velocity and timeoffset) and the Pad Response Function 
1749 for each detector in respectively one {\tt TH2I} and two 
1750 {\tt TProfile2Ds}. The calibration is nevertheless done per chamber, 
1751 whereas by integrating statistics it will be possible to get the gain, 
1752 drift velocity and timeoffset distributions inside the chambers offline. 
1753 Therefore the class {\tt AliTRDCalibraFillHisto} contains a flag 
1754 ({\tt fIsHLT}) to avoid extra calculations not needed at the detector 
1755 level.\\
1756 \begin{figure}[hbt]
1757   \centering\mbox{\epsfig{file=plots/referencech2d.eps,width=0.55\textwidth,,height=0.45\textwidth}}
1758   \caption{\label{referencech2d}A 2D histogram containing the 
1759 $dE$$/$$dx$ distributions of each detector. These were produced 
1760 with decalibrated simulated $pp$ events.}
1761 \end{figure}
1762
1763 Fig.\ref{referencech2d} shows one example of a {\tt TH2I} histogram, 
1764 where the $dE/dx$ distributions of each detector is stored for $pp$ 
1765 collisions at 14\,TeV. No minimal $p_{T}$ cut was applied on the 
1766 TRD tracks. Assuming that the charged particles are uniformy 
1767 distributed over the TRD chambers, the position of the Most Probable 
1768 Value of the $dE/dx$ distribution is used to calibrate the gain.\\ 
1769 At the beginning of each run, a local copy of the OCDB is updated 
1770 on the HLT cluster: the HCDB (HLT Condition Database). The last set 
1771 of calibration objects are used to reconstruct the events. The gain 
1772 correction preformed during the tracking has to be taken into account 
1773 when filling the $dE/dx$ distributions. That is why the calibration 
1774 algorithm has to know which database was used during the 
1775 reconstruction. The TRD HLT code can be found in the {\tt HLT/TRD} 
1776 subdirectory of the AliRoot installation. The calibration is 
1777 implemented as an {\tt AliHLTTRDCalibrationComponent}, whose members 
1778 are an {\tt AliCDBManager} together with the path for the current 
1779 database used, and an {\tt AliTRDCalibraFillHisto} object. The main 
1780 functions are:
1781 \begin{itemize}
1782 \item {\tt AliHLTCalibrationComponent::InitCalibration}, where the 
1783 {\tt TH2I} and {\tt TProfile2Ds} are created.
1784 \item {\tt AliHLTCalibrationComponent::ProcessCalibration}, where 
1785 the function\\ 
1786 {\tt AliTRDCalibraFillHisto::UpdateHistogramsV1(AliTRDtrackV1 *t)} 
1787 is called to fill the histograms.
1788 \item {\tt AliHLTCalibrationComponent::FormOutput}, which returns 
1789 a {\tt TObjArray} with the histograms.
1790 \end{itemize}     
1791 The histograms are shipped at the end of each run to the HLT File 
1792 Exchange Server to be picked up by the SHUTTLE and further processed 
1793 by the Preprocessor, exactly as the data from the calibration on DAQ.
1794 %
1795 \section{Preprocessor}
1796 %
1797 The online systems, like the Detector Control System (DCS), the DAQ 
1798 and the HLT, are protected from outside by a firewall. A special 
1799 framework, called the SHUTTLE, has been developped to retrieve offline 
1800 data in the online systems or store relevant information from the 
1801 online systems in the OCDB. The SHUTTLE has access to the DCS, DAQ 
1802 and HLT FXS. At the end of each run the reference data, outputs of 
1803 the calibration algorithms on DAQ and HLT, are retrieved and further 
1804 processed to determine the calibration constants (gain, drift velocity, 
1805 timeoffset and width of the Pad Response Function). The reference 
1806 data are finally stored in the Grid reference Data Base, whereas the 
1807 results of the fit procedures are stored in the OCDB.\\
1808 The code is contained in the {\tt AliTRDPreprocessor} class. The 
1809 Process function is executed for the run types: PEDESTAL, STANDALONE, 
1810 DAQ and PHYSICS.
1811 \begin{itemize}
1812 \item The PEDESTAL run are dedicated to the calibration of the noise 
1813 on DAQ. Only the output of the DAQ pedestal algorithm is retrieved at 
1814 the SHUTTLE. From the noise and baseline of each pad, a pad status is 
1815 determined. Disconnected pads are recognizable by a small noise. 
1816 Bridged pads have the same noise and baseline. The noise and 
1817 padstatus of the previous pedestal run in the OCDB are taken for half 
1818 chambers, which were not On. Finally the database entries 
1819 {\tt DetNoise}, {\tt PadNoise} and {\tt PadStatus} are populated in 
1820 the OCDB. More informations can be found in the function 
1821 \\{\tt AliTRDPreprocessor::ExtractPedestals}.
1822 \item The STANDALONE runs are used to check the data integrity or the 
1823 correlated noise. The data are taken with the TRD alone and a random 
1824 trigger. Only the DCS data are retrieved.
1825 \item The DAQ run are test runs for the DAQ people. Only the DCS data 
1826 are retrieved.
1827 \item The PHYSICS run are global runs including more than one detector 
1828 and different trigger clusters. They are used for the calibration of 
1829 the gain, driftvelocity and timeoffset, and width of the PRF. Therefore 
1830 the output of the calibration algorihms running on HLT are retrieved. 
1831 If the procedure is not successful the output of the 
1832 driftvelocity$/$timeoffset algorithm on DAQ is also retrieved. The 
1833 reference data, the histograms, are fitted using an 
1834 {\tt ALiTRDCalibraFit} instance:
1835 \begin{itemize}
1836 \item {\tt AliTRDCalibraFit::AnalyseCH(const TH2I *ch)} determines 
1837 the MPVs of the $dE/dx$ distributions and compares them to a reference 
1838 value.
1839 \item {\tt AliTRDCalibraFit::AnalysePH(const TProfile2D *ph)} fits 
1840 the average pulse height and determines the position of the amplification 
1841 region peak and the end of the drift region for each chamber. Knowing 
1842 the length of the drift region one can deduce the drift velocity. The 
1843 amplification peak gives also information on the timeoffset.   
1844 \item {\tt AliTRDCalibraFit::AnalysePRFMarianFit(const TProfile2D *prf)} 
1845 determines the spread of the clusters as function of azimuthal angle of 
1846 the track. The minimum gives the width of the PRF.
1847 \end{itemize}
1848 The results of each fit procedure are stored in a {\tt TObjArray} of 
1849 \\{\tt AliTRDCalibraFit::AliTRDFitInfo} objects, one per chamber, which 
1850 is a member of the {\tt AliTRDCalibraFit} instance. The functions 
1851 {\tt AliTRDCalibratFit::CreateDetObject*} and {\tt ::CreatePadObject*} 
1852 allow to create from the {\tt TObjArray} the final calibration objects, 
1853 that have to be put in the OCDB.
1854 \end{itemize}
1855 Tab.\ref{taskruntype} summarizes the tasks executed by the prepocessor 
1856 for each run type.
1857 \begin{table}[h]
1858 \begin{center}
1859 \begin{tabular} {|c|c|c|c|c|}
1860 \hline run type & DCS data points  & DCS FXS & DAQ FXS & HLT FXS  \\
1861  & temperatures  & electronic  & calibration DA  & calibration DA   \\
1862  & voltages, etc $\cdots$  &  configuration & noise/($v_{dE}$$/$$t_{0}$)  
1863 & $g$/($v_{dE}$$/$$t_{0}$)/$\sigma_{PRF}$   \\
1864 \hline DAQ   & yes & yes & no & no \\\hline
1865 \hline PEDESTAL   & no & no & yes (noise) & no \\\hline
1866 \hline STANDALONE & yes & yes & no & no \\\hline
1867 \hline PHYSICS & yes & yes & yes ($v_{dE}$$/$$t_{0}$) & yes \\\hline
1868 \end{tabular} 
1869 \caption{\label{taskruntype} Tasks performed by the TRD preprocessor 
1870 for every run type.} 
1871 \end{center}
1872 \end{table}
1873 The DCS data points are measurements of the currents, voltages, 
1874 temperatures and other variables of the chambers as function of time. 
1875 They are saved in the DCS Archive DB during the run and made available 
1876 at the SHUTTLE by AMANDA.
1877 %
1878 \section{Offline Calibration}
1879 The offline calibration of the gain, driftvelocity$/$timeoffset and 
1880 width of the PRF is meant to improve the first calibration online. 
1881 It follows the following steps:
1882 \begin{itemize}
1883 \item Fill reference data (the $dE/dx$ distributions, the average 
1884 pulse heights $\cdots$) during the reconstruction of the events offline.
1885 \item Store the reference data in root files in AliEn.
1886 \item Merge the reference data of different runs and$/$or calibration groups.
1887 \item Fit the reference data to extract the calibration constants and 
1888 create the calibration objects.
1889 \item Store the calibration objects according to their run validity in 
1890 the OCDB.
1891 \end{itemize}
1892 The calibration procedure is not performed per detector anymore but per 
1893 pad, at least for the first step, the filling of the reference data. 
1894 Depending on the available statics the reference data of different pads 
1895 (calibration groups) can be merged together to determine a mean 
1896 calibration coefficient over these pads.
1897 \subsection{AliTRDCalibraVector container}
1898 The high granularity of the calibration, with a total number of 1181952 
1899 pads, implies that the size of the reference data has to be reduced to 
1900 the strict minimum needed.
1901 \begin{table}[h]
1902 \begin{center}
1903 \begin{tabular} {|c|c|c|}
1904 \hline reference data & Number of  & size  \\
1905  for & calibration groups  & in MB   \\\hline
1906  gain & 1181952 & 225 \\\hline
1907  driftvelocity$/$timeoffset & 1181952 & 271 \\\hline
1908  PRF  & 131328  & 200 \\\hline
1909  All together & & 696 \\\hline
1910 \end{tabular} 
1911 \caption{\label{sizeofAliTRDCalibraVector} Size of the 
1912 {\tt AliTRDCalibraVector} object for a given granularity.} 
1913 \end{center}
1914 \end{table}
1915
1916 The {\tt TH2I} and {\tt TProfile2D} objects are not a good option 
1917 anymore. Therefore a container class, {\tt AliTRDCalibraVector}, was 
1918 developped. The {\tt TH2I} corresponds to an array of UShort (2 Bytes) 
1919 for the number of entries in each bin, the {\tt TProfile2D} to an array 
1920 of UShort for the number of entries in each bin and two arrays of Float 
1921 for the sum of the weights and the sum of the squared weights in each 
1922 bin. The mean value and its error are computed per hand in the functions 
1923 {\tt AliTRDCalibraVector::UpdateVector*}, where the object is filled 
1924 with new data. The size of the {\tt AliTRDCalibraVector} object is 
1925 summarized in Tab.\ref{sizeofAliTRDCalibraVector}.\\
1926 %
1927 \subsection{Additional method to calibrate the drift velocity}
1928 In addition an other method is available for the calibration of the 
1929 drift velocity. It is based on the comparison of the slope of the TRD 
1930 tracklet in the azimuthal plane $xy$ with the $\phi$ angle of the 
1931 global track. It can be shown that the slope $dy/dt$ of a TRD tracklet 
1932 depends linearly on its global track parameters, 
1933 $\tan(\phi)+(dz/dx)\tan(\beta_{tilt})$ \cite{THESISR}. The slope 
1934 parameter is the drift velocity in the electric field direction, 
1935 whereas the constant gives the tangent of the Lorentz angle. If the 
1936 TRD tracklet crosses two different pads in the $z$ direction (the 
1937 beam direction), the relation is not true anymore. Therefore such 
1938 tracklets are rejected in the calibration procedure. The reference 
1939 data are a {\tt TObjArray} of one {\tt TH2F} histogram for each 
1940 detector.\\
1941 \begin{figure}[hbt]
1942   \centering\mbox{\epsfig{file=plots/crossrow.eps,width=0.5\textwidth,height=0.45\textwidth}}
1943   \caption{\label{crossrow}The correlation between $dy/dt$ and 
1944 $\tan(\phi)+(dz/dx)\tan(\beta_{tilt})$ for the reconstructed track 
1945 in one chamber. The tracks crossing at least two pad rows are in 
1946 red crosses and those crossing one pad row in blue points.}
1947 \end{figure}
1948
1949 Fig.\ref{crossrow} shows one example of such a histogram. They are 
1950 filled in the function 
1951 \\{\tt AliTRDCalibraFillHisto: :UpdateHistogramsV1(AliTRDtrackV1 *t)}, 
1952 like the reference data for other calibration constants, if the 
1953 flag {\tt fLinearFitterDebugOn} is true.\\
1954 The histograms are stored in the container class, 
1955 \\{\tt AliTRDCalibraVdriftLinearFit}, for which a {\tt Merge} and 
1956 {\tt Add} function have been implemented. In a second step, the 
1957 {\tt AliTRDCalibraVdriftLinearFit} objects can be merged together 
1958 for different runs. In a third step, the {\tt TH2F} histograms are 
1959 fitted in the function \\{\tt AliTRDCalibraVdriftLinearFit::FillPEArray}. 
1960 The result parameters are members of the 
1961 {\tt AliTRDCalibraVdriftLinearFit} object, as well as their error 
1962 coming from the fit procedures. Finally the 
1963 {\tt AliTRDCalibraVdriftLinearFit} object is passed to an 
1964 {\tt AliTRDCalibraFit} instance through the function 
1965 {\tt AliTRDCalibraFit::AnalyseLinearFitters}, in which the Lorentz 
1966 angle is computed from the fit parameters and stored together with 
1967 the drift velocity in a {\tt TObjArray}, member of the 
1968 {\tt AliTRDCalibraFit} instance. As for the other calibration 
1969 constants the functions {\tt AliTRDCalibratFit::CreateDetObject*} 
1970 and {\tt ::CreatePadObject*} allows to create the final calibration 
1971 objects, that have to be put in the OCDB. Since the Lorentz angle 
1972 is not a OCDB entries, it is only used for debugging.
1973 %       
1974 \subsection{The calibration AliAnalysisTask}
1975 The reference data of the calibration are filled in an AliAnalysisTask 
1976 during the reconstruction or after the reconstruction. Since it needs 
1977 some informations only stored in the AliESDfriends, they have to be 
1978 written if one wants to run the calibration. This will be the case 
1979 only for TRD track above a given $p_{T}$ since the size of the events 
1980 is otherwise to big.
1981 %
1982 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1983 \newpage
1984 \setcounter{chapter}{4}
1985 \setcounter{section}{0}    
1986 \Chapter{Alignment}
1987 \thispagestyle{empty}
1988 %
1989 \section{???}
1990 %
1991 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
1992 \newpage
1993 \setcounter{chapter}{5}
1994 \setcounter{section}{0}    
1995 \Chapter{Quality Assurance (QA)}
1996 \thispagestyle{empty}
1997 %
1998 \section{???}
1999 %
2000 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2001 \newpage
2002 \setcounter{chapter}{6}
2003 \setcounter{section}{0}    
2004 \Chapter{High Level Trigger (HLT)}
2005 \thispagestyle{empty}
2006 %
2007 \section{???}
2008 %
2009 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2010 \newpage
2011 \setcounter{chapter}{7}
2012 \setcounter{section}{0}    
2013 \Chapter{References}
2014 \thispagestyle{empty}
2015 %
2016 \begin{thebibliography}{99}
2017 %
2018 \bibitem{ALIROOT}  {\it The ALICE Offline Bible}\\
2019                    http://aliceinfo.cern.ch/export/sites/AlicePortal/Offline/galleries/Download/OfflineDownload/ \\
2020                    OfflineBible.pdf.
2021 %
2022 \bibitem{CLEMENS}  C.~Adler,
2023                    {\it Radiation length of the ALICE TRD}
2024 %
2025 \bibitem{DAVID}    D.~Emschermann,
2026                    {\it Numbering Convention for the ALICE TRD Detector.},
2027                    http://www.physi.uni-heidelberg.de/\~demscher/alice/numbering/more/TRD\_numbering\_v04.pdf.
2028 %
2029 \bibitem{TRPHOT}   M.~Castellano et al.,
2030                    Comp. Phys. Comm. {\bf 55}, 431 (1988),
2031                    Comp. Phys. Comm. {\bf 61}, 395 (1990),
2032 %
2033 \bibitem{DATE}     K.~Schossmaier et al.,
2034                    {\it The Alice Data Acquisition and Test Environment DATE V5}, 
2035                    CHEP06.
2036 %
2037 \bibitem{THESISR}  R.~Bailhache, 
2038                    {\it Calibration of the ALICE Transition Radiation Detector 
2039                    and a study of $Z^{0}$ and heavy quark production in $pp$ 
2040                    collisions at the LHC},
2041                    PhD thesis, University of Darmstadt (Germany), 2009.
2042 %
2043 \end{thebibliography}
2044 %
2045 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2046 %
2047 \end{document}
2048 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%