]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG2/FORWARD/doc/doc.tex
removing the setting of AOD track references for TPC only tracks
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / doc / doc.tex
1 \documentclass[11pt]{article}
2 \usepackage[margin=2cm,twoside,a4paper]{geometry}
3 \usepackage{amstext}
4 \usepackage{amsmath}
5 \usepackage[ruled,vlined,linesnumbered]{algorithm2e}
6 \usepackage{graphicx}
7 \usepackage{color}
8 \usepackage{units}
9 \usepackage{listings}
10 \def\AlwaysText#1{\ifmmode\relax\text{#1}\else #1\fi}
11 \newcommand{\AbbrName}[1]{\AlwaysText{{\scshape #1}}}
12 \newcommand{\SPD}{\AbbrName{spd}}
13 \newcommand{\ESD}{\AbbrName{esd}}
14 \newcommand{\AOD}{\AbbrName{aod}}
15 \newcommand{\INEL}{\AbbrName{inel}}
16 \newcommand{\INELONE}{$\AbbrName{inel}>0$}
17 \newcommand{\NSD}{\AbbrName{nsd}}
18 \newcommand{\FMD}[1][]{\AbbrName{fmd\ifx|#1|\else#1\fi}}
19 \newcommand{\dndetadphi}[1][]{{\ensuremath% 
20     \ifx|#1|\else\left.\fi%
21     \frac{d^2N_{ch}}{d\eta\,d\varphi}%
22     \ifx|#1|\else\right|_{#1}\fi%
23 }}
24 \newcommand{\landau}[1]{{\ensuremath% 
25     \text{landau}\left(#1\right)}}
26 \newcommand{\dndeta}[1][]{{\ensuremath% 
27     \ifx|#1|\else\left.\fi%
28     \frac{1}{N}\frac{dN_{ch}}{d\eta}%
29     \ifx|#1|\else\right|_{#1}\fi%
30 }}
31 \newcommand{\MC}{\AlwaysText{MC}}
32 \newcommand{\Nsel}{{\ensuremath N_{v,\text{trigger,vertex}}}}
33 \newcommand{\GeV}[1]{\unit[#1]{\AlwaysText{GeV}}}
34 \newcommand{\cm}[1]{\unit[#1]{\AlwaysText{cm}}}
35
36 \setlength{\parskip}{1ex}
37 \setlength{\parindent}{0em}
38
39 \title{Analysing the FMD data for $\dndeta$}
40 \author{Christian Holm
41   Christensen\thanks{\texttt{$\langle$cholm@nbi.dk$\rangle$}}\quad\&\quad
42   Hans Hjersing Dalsgaard\thanks{\texttt{$\langle$canute@nbi.dk$\rangle$}}\\ 
43   Niels Bohr Institute\\
44   University of Copenhagen}
45 \date{\today}
46 \begin{document}
47 \maketitle 
48
49 \tableofcontents 
50 \section{Introduction}
51
52 This document describes the steps performed in the analysis of the
53 charged particle multiplicity in the forward pseudo--rapidity
54 regions. 
55
56 The analysis is performed as a two--step process.  
57 \begin{enumerate}
58 \item The Event--Summary--Data (\ESD{}) is processed event--by--event
59   and passed through a number of algorithms, and
60   $\dndetadphi$ for each event is output to an Analysis--Object--Data
61   (\AOD{}) tree.
62 \item The \AOD{} data is read in and the sub--sample of the data under
63   investigation is selected (e.g., \INEL{}, \INELONE{}, \NSD{}, or
64   some centrality class) and the $\dndetadphi$ histogram read in for
65   those events to build up $\dndeta$
66 \end{enumerate}
67 The details of each step above will be expanded upon in the
68 following. 
69
70 \section{Generating $\dndetadphi[i]$ event--by--event}
71
72 When reading in the \ESD{}s and generating the $\dndetadphi$
73 event--by--event the following steps are taken (in order) for each
74 event $i$
75 \begin{description}
76 \item[Event inspection] The global properties of the event is
77   determined, including the trigger type, vertex $z$ coordinate, and
78   whether this is a low--flux event or not. 
79 \item[Sharing filter] The \ESD{} object is read in and corrected for
80   sharing.  The result is a new \ESD{} object.
81 \item[Density calculator] The (possibly un--corrected) \ESD{} object
82   is then inspected and an inclusive, per--ring charged particle
83   density $\dndetadphi[incl,r,v,i]$  is made.  This
84   calculation depends in general upon the interaction
85   vertex\footnote{In the following simply labelled 'primary vertex' or
86     'vertex'.} position along the $z$ axis ($v_z$).  
87 \item[Corrections] The 5 $\dndetadphi[incl,r,v,i]$ are
88   corrected for secondary production, event selection efficiency, and
89   possibly the sharing efficiency.  These corrections are highly
90   dependent on the vertex $z$ coordinate.  The result is an per--ring,
91   charged primary particle density $\dndetadphi[r,v,i]$
92 \item[Histogram collector] Finally, the 5 $\dndetadphi[r,v,i]$ are
93   summed into a single $\dndetadphi[v,i]$ histogram, taking care of
94   the overlaps between the detector rings.  In principle, this
95   histogram is independent of the vertex, except that the
96   pseudo--rapidity range, and possible holes in that range, depends on
97   $v_z$ --- or rather the bin in which the $v_z$ falls. 
98 \end{description}
99
100 Each of these steps will be detailed in the following. 
101
102 \subsection{Event inspection}
103
104 The first thing to do, is to inspect the event for triggers.  A number
105 of trigger bits, like \INEL{}, \INELONE{}, \NSD{}, and so on is then
106 propagated to the \AOD{} output.  
107
108 Next, the number of \emph{tracklets} reconstructed in the Silicon
109 Pixel Detector (\SPD{}) compared to a threshold.  If the number of
110 track--lets falls belows this threshold, the event is consider a
111 low--flux event.   
112
113 Just after the sharing filter (described below) but before any more
114 processing, the vertex information is queried.  If there is no vertex
115 information, or if the vertex $z$ coordinate is outside the
116 pre--defined range, then no further processing takes place. 
117
118 \subsection{Sharing filter}
119
120 The \FMD{} \ESD{} object contains the scaled energy deposited $\Delta
121 E/\Delta E_{mip}$ for each of the 51,200 strips.  The \FMD{} is
122 organised in 3 \emph{sub--detectors} \FMD{1}, \FMD{2}, and \FMD{3}, each
123 consisting of 1 (\FMD{1}) or 2 (\FMD{2} and \FMD{3}) \emph{rings}.
124 The rings fall into two types: \emph{Inner} or \emph{outer} rings.
125 Each ring is in turn  azimuthal divided into \emph{sectors}, and each
126 sector is radially divided into \emph{strips}.  How many sectors,
127 strips, as well as the $\eta$ coverage is given in
128 \tablename~\ref{tab:fmd:overview}. 
129
130 \begin{table}[htbp]
131   \begin{center}
132     \caption{Physical dimensions of Si segments and strips.}
133     \label{tab:fmd:overview}
134     \vglue0.2cm
135     \begin{tabular}{|c|cc|cr@{\space--\space}l|r@{\space--\space}l|}
136       \hline
137       \textbf{Sub--detector/} &
138       \textbf{Azimuthal}&
139       \textbf{Radial} &
140       $z$ &
141       \multicolumn{2}{c|}{\textbf{$r$}} &
142       \multicolumn{2}{c|}{\textbf{$\eta$}} \\
143       \textbf{Ring}& 
144       \textbf{sectors} &
145       \textbf{strips} & 
146       \textbf{[cm]} &
147       \multicolumn{2}{c|}{\textbf{range [cm]}} &
148       \multicolumn{2}{c|}{\textbf{coverage}} \\
149       \hline
150       FMD1i & 20& 512& 320  &  4.2& 17.2& 3.68&  5.03\\
151       FMD2i & 20& 512&  83.4&  4.2& 17.2& 2.28&  3.68\\
152       FMD2o & 40& 256&  75.2& 15.4& 28.4& 1.70&  2.29\\
153       FMD3i & 20& 512& -75.2&  4.2& 17.2&-2.29& -1.70\\
154       FMD3o & 40& 256& -83.4& 15.4& 28.4&-3.40& -2.01\\
155       \hline
156     \end{tabular}
157   \end{center}
158 \end{table}
159
160 A particle originating from the vertex can, because of it's incident
161 angle on the \FMD{} sensors traverse more than one strip.  That means
162 that the energy loss of the particle is distributed over 1 or more
163 strips.  The signal in each strip should therefore possibly merged
164 with it's neighbor strip signals to properly reconstruct the energy
165 loss of a single particle.  
166
167 The effect is most pronounced in low--flux events, like proton--proton
168 collisions or peripheral Pb--Pb collisions, while in high--flux events
169 the hit density is so high that most likely each and every strip will
170 be hit and the effect cancel out on average. 
171
172 Since the particles travel more or less in straight lines toward the
173 \FMD{} sensors, the sharing effect predominantly in the $r$ or
174 \emph{strip} direction.  Only neighboring strips in a given sector is
175 therefor investigated for this effect.  
176
177 Algorithm~\ref{algo:sharing} is applied to the signals in a given
178 sector.
179
180 \begin{algorithm}[htpb]
181   \SetKwData{usedThis}{current strip used}
182   \SetKwData{usedPrev}{previous strip used}
183   \SetKwData{Output}{output}
184   \SetKwData{Input}{input}
185   \SetKwData{Nstr}{\# strips}
186   \SetKwData{Signal}{current}
187   \SetKwData{Eta}{$\eta$}
188   \SetKwData{prevE}{previous strip signal} 
189   \SetKwData{nextE}{next strip signal} 
190   \SetKwData{lowFlux}{low flux flag} 
191   \SetKwFunction{SignalInStrip}{SignalInStrip}
192   \SetKwFunction{MultiplicityOfStrip}{MultiplicityOfStrip}
193   \usedThis $\leftarrow$ false\;
194   \usedPrev $\leftarrow$ false\;
195   \For{$t\leftarrow1$ \KwTo \Nstr}{ 
196     \Output${}_t\leftarrow 0$\;
197     \Signal $\leftarrow$ \SignalInStrip($t$)\;
198
199     \uIf{\Signal is not valid}{ 
200       \Output${}_t \leftarrow$ invalid\;
201     }
202     \uElseIf{\Signal is 0}{ 
203       \Output${}_t \leftarrow$ 0\;
204     }
205     \Else{
206       \Eta$\leftarrow$ $\eta$ of \Input${}_t$\;
207       \prevE$\leftarrow$ 0\;
208       \nextE$\leftarrow$ 0\;
209       \lIf{$t \ne 1$}{ 
210         \prevE$\leftarrow$ \SignalInStrip($t-1$)\;
211       }
212       \lIf{$t \ne $\Nstr}{ 
213         \nextE$\leftarrow$ \SignalInStrip($t+1$)\;
214       }
215       \Output${}_t\leftarrow$
216       \MultiplicityOfStrip(\Signal,\Eta,\prevE,\nextE,\\
217       \hfill\lowFlux,$t$,\usedPrev,\usedThis)\;
218     }   
219   }
220   \caption{Sharing correction}
221   \label{algo:sharing}
222 \end{algorithm}
223
224 Here the function \FuncSty{SignalInStrip}($t$) returns the properly
225 path--length corrected signal in strip $t$.  The function
226 \FuncSty{MultiplicityInStrip} is where the real processing takes
227 place (see page \pageref{func:MultiplicityInStrip}). 
228
229 \begin{function}[htbp]
230   \caption{MultiplicityInStrip(\DataSty{current},$\eta$,\DataSty{previous},\DataSty{next},\DataSty{low
231       flux flag},\DataSty{previous signal used},\DataSty{this signal
232       used})} 
233   \label{func:MultiplicityInStrip}
234   \SetKwData{Current}{current} 
235   \SetKwData{Next}{next} 
236   \SetKwData{Previous}{previous} 
237   \SetKwData{lowFlux}{low flux flag}
238   \SetKwData{usedPrev}{previous signal used}
239   \SetKwData{usedThis}{this signal used}
240   \SetKwData{lowCut}{low cut}
241   \SetKwData{total}{Total}
242   \SetKwData{highCut}{high cut}
243   \SetKwData{Eta}{$\eta$}  
244   \SetKwFunction{GetHighCut}{GetHighCut}
245   \If{\Current is very large or \Current $<$ \lowCut} {
246     \usedThis $\leftarrow$ false\;
247     \usedPrev $\leftarrow$ false\;
248     \Return{0}
249   }
250   \If{\usedThis}{ 
251     \usedThis $\leftarrow$ false\;
252     \usedPrev $\leftarrow$ true\;
253     \Return{0}
254   }
255   \highCut $\leftarrow$ \GetHighCut($t$,\Eta)\;
256   \If{\Current $<$ \Next and \Next $>$ \highCut and \lowFlux set}{ 
257     \usedThis $\leftarrow$ false\;
258     \usedPrev $\leftarrow$ false\;
259     \Return{0}
260   }
261   \total $\leftarrow$ \Current\;
262   \lIf{\lowCut $<$ \Previous $<$ \highCut and not \usedPrev}{ 
263     \total $\leftarrow$ \total + \Previous\;
264   }
265   \If{\lowCut $<$ \Next $<$ \highCut}{ 
266     \total $\leftarrow$ \total + \Next\;  
267     \usedThis $\leftarrow$ true\;
268   }
269   \eIf{\total $>$ 0}{ 
270     \usedPrev $\leftarrow$ true\;
271     \Return{\total}
272   }{
273     \usedPrev $\leftarrow$ false\;
274     \usedThis $\leftarrow$ false\;
275     \Return{0}
276   }
277 \end{function}
278 Here, the function \FuncSty{GetHighCut} evaluates a Landau
279 distribution fitted to the energy spectrum in the $\eta$ bin
280 specified.  It returns 
281 $$
282 \Delta_{mp} - 2 w
283 $$
284 where $\Delta_{mp}$ is the most probable energy loss, and $w$ is the
285 width of the Landau distribution.  
286
287 The \KwSty{if} in line 5, says that if the previous strip was merged
288 with current one, and the signal of the current strip was added to
289 that, then we the current signal is set to 0, and we mark it as used
290 for the next iteration (\DataSty{previous signal
291   used}$\leftarrow$true). 
292
293 The \KwSty{if} in line 10 checks if the current signal is smaller than
294 the next signal, the next signal is larger than the upper cut defined
295 above, and if we have a low--flux event.  If that condition is met,
296 then the current signal is the smaller of two possible candidates for
297 merging, and it should be merged into the next signal.  Note, that
298 this \emph{only} applies in low--flux events.  
299
300 On line 15, we test if the previous signal lies between our low and
301 high cuts, and if it has not been marked as being used.  If so, we add
302 it to our current signal.  
303
304 The next \KwSty{if} on line 16 checks if the next signal is within our
305 cut bounds.  If so, we add that signal to the current signal and mark
306 it as used for the next iteration (\DataSty{this signal
307   used}$\leftarrow$true).  It will then be zero'ed on the next
308 iteration by the condition on line 6.
309
310 Finally, if our signal is still larger than 0, we return the signal
311 and mark this signal as used (\DataSty{previous signal
312   used}$\leftarrow$true) so that it will not be used in the next
313 iteration. Otherwise, we mark the current signal and the next signal
314 as unused and return a 0. 
315
316
317 \subsection{Density calculator}
318
319 The density calculator loops over all the strip signals and calculates
320 the inclusive (primary + secondary) charged particle density in
321 pre-defined $(\eta,\varphi)$ bins.  
322
323 \subsubsection{Inclusive number of charged particles} 
324
325 If the event is classified as a low--flux event, then the number of
326 charged particles in a given by a simple threshold: 
327 \begin{align}
328   N_{ch,t} &= \left\{
329     \begin{array}{cl}
330       0 & \Delta_t < \text{low cut}\\ 
331       1 & \Delta_t \ge \text{low cut}\\ 
332     \end{array}\right.\quad,
333 \end{align}
334 where $t$ is the strip identifier, $\Delta_t$ is the scaled energy
335 deposition in that strip, and 'low cut' is a predefined
336 cut\footnote{This low--flux mode is perhaps deprecated.}.  
337
338 For high flux events, the number charged particles in a strip is
339 calculated using multiple Landau distributions fitted to the energy
340 loss spectrum at a given $\eta$ value.
341 \begin{align}
342   \Delta_{i,mp} &= i (\Delta_{1,mp}+ \xi_1 \log(i))\nonumber\\
343   \xi_i         &= i\xi_1\nonumber\\
344   \sigma_i      &= \sqrt{i}\sigma_1\nonumber\\
345   N_{ch,t} &= \frac{\sum_i^{N_{max}}
346     i\,a_i\,F(\Delta_t;\Delta_{i,mp},\xi_i,\sigma_i)}{
347     \sum_i^{N_{max}}\,a_i\,F(\Delta_t;\Delta_{i,mp},\xi_i,\sigma_i)}\quad,
348 \end{align}
349 where $F(x;\Delta_{mp},\xi,\sigma)$ is the evaluation of the Landau
350 distribution $f_L$ with most probable value $\Delta_{mp}$ and width
351 $\xi$, folded with a Gaussian distribution with spread $\sigma$
352 \cite{nim:b1:16,phyrev:a28:615}.
353 $$
354 F(x;\Delta_{mp},\xi,\sigma) = \frac{1}{\sigma \sqrt{2 \pi}}
355 \int_{-\infty}^{+\infty} d\Delta' f_{L}(x;\Delta',\xi)
356 \exp{-\frac{(\Delta_{mp}-\Delta')^2}{2\sigma^2}}
357 $$
358 $\Delta_{1,mp}$, $\xi_1$, and $\sigma_1$ are the parameters for the
359 first MIP peak, $a_1=1$, and $a_i$ is the relative weight of the
360 $i^{\text{th}}$ MIP peak.   The parameters $\Delta_{1,mp}, \xi_1,
361 \sigma_1, a_2, \ldots a_{N_{max}}$ are obtained by fitting 
362 $$
363 \sum_{i=1}^{j} F(x;\Delta_{i,mp},\xi_{i},\sigma_i) 
364 $$
365 for increasing $j$ to the energy loss spectra in separate $\eta$
366 bins. 
367
368 \subsubsection{Acceptance and double-hit corrections}
369
370 Before the signal $N_{ch,t}$ can be added to the $(\eta,\varphi)$
371 bin in one of the 5 per--ring histograms, it needs to be corrected for
372 the $\varphi$ acceptance of the strip, as well as a correction for
373 double hits in low--flux events.   
374
375 The acceptance correction is only applicable where the strip length
376 does not cover the full sector.  This is the case for the outer strips
377 in both the inner and outer type rings.  The acceptance correction is
378 then simply 
379 \begin{align}
380   \label{eq:acc_corr}
381   a_t &= \frac{l_t}{\Delta\varphi}\quad
382 \end{align}
383 where $l_t$ is the strip length in radians at constant $r$, and
384 $\Delta\varphi$ is $2\pi$ divided by the number of sectors in the
385 ring (20 for inner type rings, and 40 for outer type rings). 
386
387 Even in low--flux events it is possible that more than one particle
388 hits a strip.  However, for low--flux events, it is not possible to
389 reconstruct the 3\textsuperscript{rd} nor even the
390 2\textsuperscript{nd} MIP peak in the energy loss spectrum.
391 Therefore, the strip signal needs to be corrected to the average
392 number of particle impinging on a strip at a given $\eta$\footnote{As
393   before, this low--flux mode is deprecated and this correction is not
394   applied}.  
395 \begin{align}
396   d_{t,r}(\eta) &= \left\{
397     \begin{array}{cl} \langle
398       n_{t,r}(\eta)\rangle & \text{low flux}\\
399       1 & \text{high flux}
400     \end{array}\right.\quad.
401 \end{align}
402 This correction is calculated separately for each ring in $\eta$ bins
403 from simulated events like
404 \begin{align}
405   \label{eq:double_hit_corr} 
406   \langle n_{t,r}(\eta)\rangle &= \frac{
407     \sum_i N_{\text{strips},r,i}(\eta)}{
408     \sum_i N_{ch,r,i}(\eta)}\quad,
409 \end{align}
410 where $N_{\text{strips},r,i}(\eta)$ is the number of strips in ring
411 $r$ in a given $\eta$ bin that have been hit in the $i^{\text{th}}$
412 event, and $N_{ch,r,i}(\eta)$ is the number of charged particles that
413 fell within the same $\eta$ bin in the $i^{\text{th}}$ event.
414
415 The final $(\eta,\varphi)$ content of the 5 output vertex dependent,
416 per--ring histograms of the inclusive charged particle density is then
417 given by
418 \begin{align}
419   \label{eq:density}
420   \dndetadphi[incl,r,v,i(\eta,\varphi)] &= \sum_t^{t\in(\eta,\varphi)}
421   N_{ch,t}\,a_t\,d_{t,r}(\eta)
422 \end{align}
423 where $t$ runs over the strips in the $(\eta,\varphi)$ bin. 
424
425 \subsection{Corrections}
426
427 The corrections code receives the five vertex dependent,
428 per--ring histograms of the inclusive charged particle density
429 $\dndetadphi[incl,r,v,i]$ from the density calculator and applies
430 three corrections 
431
432 \subsubsection{Secondary correction}
433 %%
434 %%                hHits_FMD<d><r>_vtx<v> 
435 %% hCorrection = -----------------------
436 %%                hPrimary_FMD_<r>_vtx<v>
437 %%
438 %% where 
439 %% - hPrimary_FMD_<r>_vtx<vtx> is 2D of eta,phi for all primary ch
440 %%   particles
441 %% - hHits_FMD<d><r>_vtx<v>  is 2D of eta,phi for all track-refs that
442 %%   hit the FMD - The 2D version of hMCHits_nocuts_FMD<d><r>_vtx<v>
443 %%   used below. 
444   This is a 2 dimensional histogram generated from simulations of the
445   ratio of primary particles to the total number of particles that
446   fall within an $(\eta,\varphi)$ bin for a given vertex bin
447
448   \begin{align}
449     \label{eq:secondary}
450     s_v(\eta,\varphi) &=
451     \frac{\sum_i^{\Nsel}N_{ch,\text{primary},i}(\eta,\varphi)}{
452       \sum_i^{\Nsel}N_{ch,\text{\FMD{}},i}(\eta,\varphi)}\quad,
453   \end{align}
454   where $\Nsel$ is the number of events with a valid trigger and a
455   vertex in bin $v$, and $N_{ch,\FMD{},i}$ is the total number of
456   charged particles that hit the \FMD{} in event $i$ in the specified
457   $(\eta,\varphi)$ bin and $N_{ch,\text{primary},i}$ is number of
458   primary charged particles in event $i$ within the specified
459   $(\eta,\varphi)$ bin.
460
461   $N_{ch,primary}(\eta,\varphi)$ is given by summing over the charged
462   particles labelled as primaries \emph{at the time of the collision}
463   as defined in the simulation code.  That is, it is the number of
464   primaries within the bin at the collision point --- not at the
465   \FMD{}.  
466
467 \subsubsection{Event selection efficiency}
468 %% AliFMDAnalysisTaskGenerateCorrection
469 %% 
470 %% Analysed_FMD<r>_vtx<v> 2D histogram (eta,phi)
471 %% EventsSelected[<v>]    bin content 
472 %% Inel_FMD<r>_vtx<v>     2D histogram (eta,phi) 
473 %% EventsAll[<v>]         bin content 
474 %%
475 %% correction is 
476 %%
477 %%      Analysed_FMD<d><r>_vtx<v> / EventsSelected[<v>]
478 %%    ---------------------------------------------------
479 %%      Inel_FMD<r>_vtx<v> / EventsAll[<v>] 
480 %% 
481 %% Inel_FMD<r>_vtx<v>        is d^2N_incl,ch/d\eta d\varphi for all
482 %%                           events  
483 %% Analysed_FMD<d><r>_vtx<v> is d^2N_{incl,ch}/d\eta d\varphi for
484 %%                           events with trigger _and_ vertex
485 %% EventsSelected            is dN/dv_z for events with trigger _and_
486 %%                           vertex
487 %% EventsAll                 is dN/dv_z for all events 
488   This correction is made from simulations.  It is a 2--dimensional
489   histogram of the ratio of average number of charged particles in
490   events that are triggered as interactions \emph{and} have vertex, to
491   the average number of charged particles in all events in
492   $(\eta,\varphi)$ bins
493   \begin{align}
494     \label{eq:event_sel_eff}
495     e_{v}(\eta,\varphi) &= 
496     \frac{\frac{1}{N_{v}} \sum_{i}^{N_{v}} N_{ch,\MC{},i}(\eta,\varphi)}{
497       \frac{1}{\Nsel{}}\sum_{i}^{\Nsel{}}
498       N_{ch,\MC{},i}(\eta,\varphi)}\nonumber\\
499     &= \frac{\Nsel{}}{N_{v}} \frac{\sum_{i}^{N_{v}} 
500       N_{ch,\MC{},i}(\eta,\varphi)}{\sum_{i}^{\Nsel{}}
501       N_{ch,\MC{},i}(\eta,\varphi)}\quad,
502   \end{align}
503   where $N_{v}$ is the total number of events in vertex bin $v$, and
504   $\Nsel{}$ is the number of events with a collision trigger and
505   vertex within the predefined range, for vertex bin $v$.
506   $N_{ch,\MC{},i}$ is the number of charged 'MC truth' particles
507   within the specified $(\eta,\varphi)$ range for event $i$.
508
509 \subsubsection{Sharing correction efficiency}
510 %% hits_NoCuts_FMD<d><r>_vtxbin<v>_proj 
511 %% hMCHits_nocuts_FMD<d><r>_vtxbin<v>
512 %% 
513 %% Correction is 
514 %% 
515 %%     hits_NoCuts_FMD<d><r>_vtxbin<v>_proj / hEvents[<v>]
516 %%    -----------------------------------------------------
517 %%     hMChits_nocuts_FMD<d><r>_vtxbin<v> / nMCEventsNoCuts[<v>] 
518 %%
519 %% Or 
520 %%
521 %%     sum_eta hits_FMD<d><r>_vtxbin<v> / EventSel1D / hEvents[<v>]
522 %%   ---------------------------------------------------------------
523 %%     hMCHits_nocuts_FMD<d><r>_vtxbin<v> / nMCEventsNoCuts[<v>] 
524 %%   
525 %% - hits_NoCuts_FMD<d><r>_vtxbin<v>_proj 
526 %%   A projection of hits_FMD<d><r>_vtxbin<v> onto the eta axis and
527 %%   possibly scaled to EventSel1D. 
528 %% - EventSel1D - the 1D event selection efficiency (per vertex) 
529 %%   This is the ratio of hEventAll divided hEventsSelected, with
530 %%   errors calculated as 
531 %% 
532 %%      da = sqrt(e_sel^2 + e_all^2)
533 %%      a  = c_all - c_sel 
534 %%      e  = sqrt(da^2 + a^2 / (c_ell*c_sel)^2)
535 %%         = sqrt(e_sel^2 + e_all^2 + (c_all-c_sel)^2 /
536 %%         (c_ell*c_sel)^2)
537 %%
538 %%   where hEventsAll[<v>] is the total number of events in the v bin,
539 %%   and hEventsSelected[<v>] is the notoal number of events with
540 %%   trigger and vertex in the v bin. Both for MC
541 %% - hits_FMD<d><r>_vtxbin<v>
542 %%   from AliFMDAnalysisTaskBackgroundCorrection - the uncorrected
543 %%   multiplicity in each ring - i.e.,
544 %%   \dndetadphi[incl,r,v,i(\eta,\varphi)] 
545 %% - hMCHits_nocuts_FMD<d><r>_vtxbin<v> - from
546 %%   AliFMDAnalysisTaskSharing - a 1D histogram in eta - sum of eta of
547 %%   track-refs that hit FMD with some requirements on the neighbors  
548 %% - hEvents[<v>] - bin content of dN/dv_{z} 
549 %% - nMCEventsNoCuts -  hPrimEvents[<v>] - bin content of dN/dv_{z}
550 %%   for MC events - from AliFMDAnalysisTaskSharing - number of not
551 %%   empty mc events per vertex bin 
552 %% 
553 This is a one dimension histogram in $\eta$, generated from running
554 the full analysis on simulated data\footnote{With improved energy loss
555   fits, this correction is redundant and not used} .
556   \begin{align}
557     \label{eq:sharing_corr}
558     m_v(\eta) &=
559     \frac{\frac1{\Nsel}\sum_i^{\Nsel{}}N_{ch,\text{\FMD{}},i}(\eta)}{
560       \frac{1}{e_{v}}\frac1{\Nsel{}}\left.\frac{dN_{ch}}{d\eta}
561       \right|_{incl,r,v(\eta)}^{\MC{}}}
562     \nonumber\\
563     &=
564     \frac{\frac1{\Nsel}\sum_i^{\Nsel{}}N_{ch,\text{\FMD{}},i}(\eta)}{
565       \frac1{N_v}\left.\frac{dN_{ch}}{d\eta}\right|_{incl,r,v(\eta)}^{\MC}}
566     \nonumber\\
567     &= 
568     \frac{N_v}{\Nsel{}}
569     \frac{\sum_i^{\Nsel{}}N_{ch,\text{\FMD{}},i}(\eta)}{
570       \left.\frac{dN_{ch}}{d\eta}\right|_{incl,r,v(\eta)}^{\MC}}\\
571     \intertext{since}
572     e_{v} &= \frac{N_{v}}{\Nsel{}}\quad,
573 %% \pm 
574 %%    \sqrt{\sqrt{\Nsel{}}^2 + \sqrt{N_v^2} +
575 %%      \frac{(N_v-\Nsel{})^2}{(\Nsel{}N_v)^2}}\nonumber \\
576 %%    &= \frac{N_{v}}{\Nsel{}} \pm 
577 %%    \sqrt{\Nsel{} + N_v + \frac1{\Nsel{}^2} + \frac1{N_v^2} -
578 %%      \frac1{\Nsel{}N_v}}\quad, 
579   \end{align}
580   and $N_v$ is the total number of simulated events with vertex in bin
581   $v$, $\Nsel{}$ is the number of simulated events with a collision
582   trigger and a reconstructed vertex, $N_{ch,\text{\FMD{}},i}(\eta)$ is
583   the total number of 'MC truth' charged particles that impinge on the
584   \FMD{} in the given eta  bin in event $i$, and 
585   \begin{align}
586     \left.\frac{dN_{ch}}{d\eta}\right|_{incl,r,v(\eta)}^{\MC{}} &= 
587     \int_0^{2\pi}d\varphi\dndetadphi[incl,r,v(\eta,\varphi)]
588     \nonumber\\
589     &=  \int_0^{2\pi}d\varphi\sum_i^{\Nsel{}}\dndetadphi[incl,i,r,v(\eta,\varphi)]\quad,
590   \end{align}
591   where the integrand is \eqref{eq:density} for simulated data i.e.,
592   this is the inclusive total charge particle density in a given $v$
593   bin for ring $r$ in event $i$. 
594
595 Putting equations \eqref{eq:secondary}, \eqref{eq:event_sel_eff}, and
596 \eqref{eq:sharing_corr} together we get the total correction
597 $c_v(\eta,\varphi)$ to be 
598 \begin{align}
599   \label{eq:total_corr}
600   c_v(\eta,\varphi) =\ &
601   s_v(\eta,\varphi)\,e_v(\eta,\varphi)\,m_v(\eta)\nonumber\\ 
602   =\ & \frac{\sum_i^{\Nsel}N_{ch,\text{primary},i}(\eta,\varphi)}{
603       \sum_i^{\Nsel}N_{ch,\text{\FMD{}},i}(\eta,\varphi)}
604     \nonumber\\
605     & \times\ \frac{\Nsel{}}{N_{v}} \frac{\sum_{i}^{N_{v}} 
606       N_{ch,\MC{},i}(\eta,\varphi)}{\sum_{i}^{\Nsel{}}
607       N_{ch,\MC{},i}(\eta,\varphi)}\nonumber\\
608     & \times\ \frac{N_v}{\Nsel{}}
609     \frac{\sum_i^{\Nsel{}}N_{ch,\text{\FMD{}},i}(\eta)}{
610       \left.\frac{dN_{ch}}{d\eta}\right|_{incl,r,v(\eta)}^{\MC}}\nonumber\\
611   =\ & \frac{\sum_i^{\Nsel}N_{ch,\text{primary},i}(\eta,\varphi)}{
612       \sum_i^{\Nsel}N_{ch,\text{\FMD{}},i}(\eta,\varphi)}
613     \frac{\sum_{i}^{N_{v}} N_{ch,\MC{},i}(\eta,\varphi)}{
614       \sum_{i}^{\Nsel{}} N_{ch,\MC{},i}(\eta,\varphi)}
615     \frac{\sum_i^{\Nsel{}}N_{ch,\text{\FMD{}},i}(\eta)}{
616       \left.\frac{dN_{ch}}{d\eta}\right|_{incl,r,v(\eta)}^{\MC}}\quad,
617 \end{align}
618 which\footnote{Note that $\sum_{i}^{\Nsel{}} N_{ch,\FMD{},i}(\eta) =
619   \int_0^{2\pi}d\varphi\,\sum_{i}^{\Nsel{}}
620   N_{ch,\FMD{},i}(\eta,\varphi)$} is independent of the overall
621 number of events $N_v$ and $\Nsel{}$.
622
623 The 5 output vertex dependent, per--ring histograms of the primary
624 charged particle density is then given by
625 \begin{align}
626   \dndetadphi[r,v,i(\eta,\varphi)] &=
627   c_v(\eta,\varphi)\dndetadphi[incl,r,v,i(\eta,\varphi)]
628 \end{align}
629
630 \subsection{Histogram collector}
631
632 The histogram collector collects the information from the 5 vertex
633 dependent, per--ring histograms of the primary charged particle
634 density $\dndetadphi[r,v,i]$ into a single vertex dependent histogram
635 of the charged particle density $\dndetadphi[v,i]$.  
636
637 To do this, it first calculates, for each vertex bin, the $\eta$ bin
638 range to use for each ring.  It investigates the secondary correction
639 maps $s_v(\eta,\varphi)$ to find the edges of the map.  The edges are
640 given by the $\eta$ range where $s_v(\eta,\varphi)$ is larger than
641 some threshold\footnote{Typically $t_s\approx 0.1$.}  $t_s$. The code
642 applies safety margin of a $N_{cut}$ bins\footnote{Typically
643   $N_{cut}=1$.}, to ensure that the data selected does not have too
644 large corrections associated with it.
645
646 It then loops over the bins in the defined $\eta$ range and sums the
647 contributions from each of the 5 histograms.  In the $\eta$ ranges
648 where two rings overlap, the collector calculates the average and adds
649 the errors in quadrature.
650
651 The output vertex dependent histogram of the primary
652 charged particle density is then given by
653 \begin{align}
654   \label{eq:superhist}
655   \dndetadphi[v,i(\eta,\varphi)] &=
656   \frac{1}{N_{r\in(\eta,\varphi)}}\sum_{r}^{r\in(\eta,\varphi)}  
657   \dndetadphi[r,v,i(\eta,\varphi)]\\
658   \delta\left[\dndetadphi[v,i(\eta,\varphi)]\right] &=
659   \frac{1}{N_{r\in(\eta,\varphi)}}\sqrt{\sum_{r}^{r\in(\eta,\varphi)}   
660     \delta\left[\dndetadphi[r,v,i(\eta,\varphi)]\right]^2}
661   \quad,
662 \end{align}
663 where $N_{r\in(\eta,\varphi)}$ is the number of overlapping histograms
664 in the given $(\eta,\varphi)$ bin. 
665
666 The histogram collector stores the found $\eta$ ranges in the
667 underflow bin of the histogram produced.  The content of the overflow
668 bins are 
669 \begin{align}
670   \label{eq:overflow}
671   I_{v,i}(\eta) &= 
672   \frac{1}{N_{r\in(\eta)}}
673   \sum_{r}^{r\in(\eta)} \left\{\begin{array}{cl} 
674       0 & \eta \text{\ bin not selected}\\ 
675       1 & \eta \text{\ bin selected}
676       \end{array}\right.\quad,
677 \end{align}
678 where $N_{r\in(\eta)}$ is the number of overlapping histograms in the
679 given $\eta$ bin.  The subscript $v$ indicates that the content
680 depends on the current vertex bin of event $i$.
681
682 \section{Building the final $\dndeta$}
683
684 To build the final $\dndeta$ distribution it is enough to sum
685 \eqref{eq:superhist} and \eqref{eq:overflow} over all interesting
686 events and then scale it to the number of events that had a collision
687 trigger
688 \begin{align}
689   \dndetadphi[(\eta,\varphi)] &= \sum_i^{N_{\text{selected}}}
690   \dndetadphi[i,v(\eta,\varphi)]\\ 
691   I(\eta) &= \sum_i^{N_{\text{selected}}}I_{i,v}(\eta)\\
692   \intertext{With $N_{\text{trigger}}$ equal to the number of events with a
693     collision trigger, we get}
694   \dndeta[(\eta)] &=
695   \frac{\Nsel{}}{N_{\text{trigger}}}\frac{1}{\Delta\eta}
696   \frac{1}{I(\eta)}\sum_{\varphi}\dndetadphi[(\eta,\varphi)]\quad,
697 \end{align}
698 where $\Delta\eta$ is the $\eta$ bin width.  Note that in general
699 $\Nsel{}\ne N_{\text{selected}}$. 
700
701 \section{Using the per--event $\dndetadphi[i,v]$ histogram for other
702   analysis} 
703
704 \subsection{Multiplicity distribution} 
705
706 To build the multiplicity distribution for a given $\eta$ range
707 $[\eta_1,\eta_2]$, one needs to find the total multiplicity in that
708 $\eta$ range for each event. To do so, one should sum the
709 $\dndetadphi[i,v]$ histogram over all $\varphi$ and in the selected
710 $\eta$ range.
711 \begin{align}
712   n'_{i[\eta_1,\eta_2]}, &= \int_{\eta_1}^{\eta_2}d\eta\int_0^{2\pi}d\varphi
713   \dndetadphi[i,v]\quad.\nonumber
714 \end{align}
715 However, $n'_i$ is not corrected for the coverage in $\eta$ for the
716 particular vertex range $v$.  One therefor needs to correct for the
717 number of missing bins in the range $[\eta_1,\eta_2]$.  Suppose
718 $[\eta_1,\eta_2]$ covers $N_{[\eta_1,\eta_2]}$ $\eta$ bins, then the acceptance
719 correction is given by 
720 \begin{align}
721   A_{i,[\eta_1,\eta_2]} = \frac{N_{[\eta_1,\eta_2]}}{\int_{\eta_1}^{\eta_2}d\eta\,
722     I_{i,v}(\eta)}\quad.\nonumber
723 \end{align}
724 The per--event multiplicity is then given by 
725 \begin{align}
726   n_{i,[\eta_1,\eta_2]} &= A_{i,[\eta_1,\eta_2]}\,n'_{i,[\eta_1,\eta_2]}\nonumber\\
727   &= \frac{N_{[\eta_1,\eta_2]}}{\int_{\eta_1}^{\eta_2}\eta
728     I_{i,v}(\eta)} \int_{\eta_1}^{\eta_2}d\eta\int_0^{2\pi}d\varphi
729   \dndetadphi[i,v]
730   \label{eq:event_n}
731 \end{align}
732
733 \subsection{Forward--Backward correlations} 
734
735 To do forward--backward correlations, one need to calculate
736 $n_{i,[\eta_1,\eta_2]}$ as shown in \eqref{eq:event_n} in two bins
737 $n_{i,[\eta_1,\eta_2]}$ and $n_{i,[-\eta_2,-\eta_1]}$ \textit{e.g.},
738 $n_{i,f}=n_{i,[-3,-1]}$ and $n_{i,b}=n_{i,[1,3]}$. 
739
740 \section{Some results}
741
742 \figurename{}s \ref{fig:1} to \ref{fig:3} shows some results.
743
744 \begin{figure}[tbp]
745   \centering
746   \includegraphics[keepaspectratio,width=\textwidth]{%
747     dndeta_0900GeV_m10-p10cm_rb05_inel}
748   \caption{$\dndeta$ for pp for \INEL{} events at $\sqrt{s}=\GeV{900}$,
749     $\cm{-10}\le v_z\le\cm{10}$, rebinned by a factor 5.  Comparisons
750     to other measurements shown where applicable}
751   \label{fig:1}
752 \end{figure} 
753 \begin{figure}[tbp]
754   \centering
755   \includegraphics[keepaspectratio,width=\textwidth]{%
756     dndeta_0900GeV_m10-p10cm_rb05_inelgt0}
757   \caption{$\dndeta$ for pp for \INELONE{} events at
758     $\sqrt{s}=\GeV{900}$, $\cm{-10}\le v_z\le\cm{10}$, rebinned by a
759     factor 5.  Comparisons to other measurements shown where
760     applicable}
761   \label{fig:2}
762 \end{figure} 
763 \begin{figure}[tbp]
764   \centering
765   \includegraphics[keepaspectratio,width=\textwidth]{%
766     dndeta_0900GeV_m10-p10cm_rb05_nsd}
767   \caption{$\dndeta$ for pp for \NSD{} events at $\sqrt{s}=\GeV{900}$,
768     $\cm{-10}\le v_z\le\cm{10}$, rebinned by a factor 5.  Comparisons
769     to other measurements shown where applicable}
770   \label{fig:3}
771 \end{figure} 
772
773 \clearpage
774 \appendix 
775 \section{Second pass example code}
776 \lstset{basicstyle=\small\ttfamily,% 
777   keywordstyle=\color[rgb]{0.627,0.125,0.941}\bfseries,% 
778   identifierstyle=\color[rgb]{0.133,0.545,0.133}\itshape,%
779   commentstyle=\color[rgb]{0.698,0.133,0.133},%
780   stringstyle=\color[rgb]{0.737,0.561,0.561},
781   emph={TH2D,TFile,TTree,AliAODForwardMult},emphstyle=\color{blue},%
782   emph={[2]dndeta,sum,norm},emphstyle={[2]\bfseries\underbar},%
783   language=c++,%
784 }
785 \begin{lstlisting}[caption={Example 2\textsuperscript{nd} pass code to
786     do $\dndeta$},label={lst:example},frame=single,captionpos=b]
787 void Analyse()
788
789   gSystem->Load("libANALYSIS.so");      // Load analysis libraries
790   gSystem->Load("libANALYSISalice.so"); // General ALICE stuff
791   gSystem->Load("libPWG2forward2.so");  // New code 
792
793   TH2D*              sum        = 0;                  // Summed hist
794   TFile*             file       = TFile::Open("AliAODs.root","READ");
795   TTree*             tree       = static_cast<TTree*>(file->Get("aodTree"));
796   AliAODForwardMult* mult       = 0;                  // AOD object
797   int                nTriggered = 0;                  // # of triggered ev.
798   int                nWithVertex= 0;                  // # of ev. w/vertex
799   int                nAvailable = tree->GetEntries(); // How many entries
800   float              vzLow      = -10;                // Lower ip cut
801   float              vzHigh     = +10;                // Upper ip cut
802   int                mask       = AliAODForwardMult::kInel;// Trigger mask
803   tree->SetBranchAddress("Forward", &forward);        // Set the address
804
805   for (int i = 0; i < nAvailable; i++) { 
806     // Read the i'th event 
807     tree->GetEntry(i);
808
809     // Create sum histogram on first event - to match binning to input
810     if (!sum) 
811       sum = static_cast<TH2D*>(mult->GetHistogram()->Clone("d2ndetadphi"));
812     
813     // Other trigger/event requirements could be defined 
814     if (!mult->IsTriggerBits(mask)) continue; 
815     nTriggered++;
816
817     // Check if we have vertex 
818     if (!mult->HasIpZ()) continue;
819     nWithVertex++;
820
821     // Select vertex range (in centimeters) 
822     if (!mult->InRange(vzLow, vzHigh) continue; 
823
824     // Add contribution from this event
825     sum->Add(&(mult->GetHistogram()));
826   }
827
828   // Get acceptance normalisation from underflow bins 
829   TH1D* norm   = sum->Projection("norm", 0, 1, "");
830   // Project onto eta axis - _ignoring_underflow_bins_!
831   TH1D* dndeta = sum->Projection("dndeta", 1, -1, "e");
832   // Normalize to the acceptance, and scale by the vertex efficiency 
833   dndeta->Divide(norm);
834   dndeta->Scale(double(nWithVertex)/nTriggered, "width");
835   // And draw the result
836   dndeta->Draw();
837 }
838 \end{lstlisting}
839
840 \begin{thebibliography}{99}
841 \bibitem{nim:b1:16} Nucl.Instrum.Meth.B1:16
842 \bibitem{phyrev:a28:615} Phys.Rev.A28:615
843 \end{thebibliography}
844 \end{document}