]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGCF/FLOW/Documentation/FlowPackageManual.tex
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / PWGCF / FLOW / Documentation / FlowPackageManual.tex
1 \documentclass[a4paper]{book}
2 \usepackage[nottoc,numbib]{tocbibind}
3 \usepackage[english]{babel}
4 \usepackage[pdftex]{graphics} %enable pdfgraphics support necessary for pdflatex
5 \usepackage{graphicx}
6 \usepackage{tikz}
7 \usepackage[small,bf]{caption}
8 \usepackage{footmisc}
9 \usepackage{sidecap}
10 \usepackage{fancyvrb}
11 \usepackage{color}
12 \usepackage{rotating}
13 \makeatletter
14 \setlength{\@fptop}{0pt}
15 \setlength{\@fpsep}{5pt}
16 \makeatother
17 \renewcommand{\dotfill}{\leaders\hbox to 5pt{\hss.\hss}\hfill}
18 \usepackage[hmargin=1.2cm,vmargin=1.5cm]{geometry} %set custom margins
19 \usepackage{fancyhdr} %enable hyperlinking, highlight page numbers
20 \usepackage{amsmath}
21 \usepackage{amssymb}
22 \numberwithin{equation}{subsection}
23 \usepackage{amsfonts}
24 \usepackage{mathrsfs}
25 \usepackage{tabularx}
26 \usepackage{lastpage}
27 \usepackage{subfigure}
28 \usepackage{multicol}
29 \usepackage{lipsum}
30 \usepackage{xspace}
31 \usepackage{latexsym} 
32 \usepackage{verbatim}
33 \usepackage{listings}
34 \usepackage{color}
35 \usepackage[usenames,dvipsnames]{xcolor}
36 \definecolor{listinggray}{gray}{0.9}
37 \definecolor{lbcolor}{rgb}{0.9,0.9,0.9}
38 \usepackage{listings}
39 \usepackage{color}
40
41 \definecolor{mygreen}{rgb}{0,0.6,0}
42 \definecolor{mygray}{rgb}{0.5,0.5,0.5}
43 \definecolor{mymauve}{rgb}{0.58,0,0.82}
44
45 \lstset{ %
46    backgroundcolor=\color{white},   % choose the background color; you must add \usepackage{color} or \usepackage{xcolor}
47    basicstyle=\footnotesize,        % the size of the fonts that are used for the code
48    breakatwhitespace=false,         % sets if automatic breaks should only happen at whitespace
49    breaklines=true,                 % sets automatic line breaking
50 %   captionpos=b,                    % sets the caption-position to bottom
51    commentstyle=\color{mygreen},    % comment style
52    deletekeywords={...},            % if you want to delete keywords from the given language
53    escapeinside={\%*}{*)},          % if you want to add LaTeX within your code
54    extendedchars=true,              % lets you use non-ASCII characters; for 8-bits encodings only, does not work with UTF-8
55    frame=single,                    % adds a frame around the code
56    keepspaces=true,                 % keeps spaces in text, useful for keeping indentation of code (possibly needs columns=flexible)
57    keywordstyle=\color{blue},       % keyword style
58    language=C,                 % the language of the code
59    morekeywords={*,...},            % if you want to add more keywords to the set
60    numbers=left,                    % where to put the line-numbers; possible values are (none, left, right)
61    numbersep=5pt,                   % how far the line-numbers are from the code
62    numberstyle=\tiny\color{mygray}, % the style that is used for the line-numbers
63    rulecolor=\color{black},         % if not set, the frame-color may be changed on line-breaks within not-black text (e.g. comments (green here))
64    showspaces=false,                % show spaces everywhere adding particular underscores; it overrides 'showstringspaces'
65    showstringspaces=false,          % underline spaces within strings only
66    showtabs=false,                  % show tabs within strings adding particular underscores
67    stepnumber=1,                    % the step between two line-numbers. If it's 1, each line will be numbered
68    stringstyle=\color{mymauve},     % string literal style
69    tabsize=2,                       % sets default tabsize to 2 spaces
70 %   title=\lstname                   % show the filename of files included with \lstinputlisting; also try caption instead of title
71 % in the end language and linenumbres will be called for each block, otherwise html conversion doesn't pick up on the proper markup ...
72 }
73 % tweak the the style a little bit
74 \lstdefinestyle{customc}{
75 %   belowcaptionskip=1\baselineskip,
76    breaklines=true,
77    frame=single,
78    xleftmargin=\parindent,
79    language=C,
80 %   showstringspaces=false,
81    basicstyle=\footnotesize\ttfamily,
82    keywordstyle=\bfseries\color{green!40!black},
83    commentstyle=\itshape\color{mygray},
84    identifierstyle=\color{blue},
85    stringstyle=\color{orange},
86    framexleftmargin=5mm,
87 }
88
89 \lstset{escapechar=@,style=customc}
90 \usepackage[sort&compress,numbers]{natbib}
91
92 \pagestyle{fancy} %enable custom headeres
93 \fancyhead{}
94 \fancyfoot{} %clear predefined headers, then create your own:
95 \lhead{\footnotesize AliROOT Flow Package manual and documentation}
96 \rhead{\footnotesize The FLOW team}
97 \rfoot{\footnotesize Page \thepage\ of \pageref{LastPage}}
98 \lfoot{\footnotesize \rightmark}
99 \usepackage[bookmarks=true,
100             bookmarksopen=true, 
101             bookmarksnumbered=true, pdftex,
102             hyperindex=true,linktocpage]{hyperref}
103 \hypersetup{
104     bookmarks=true,         % show bookmarks bar?
105     unicode=false,          % non-Latin characters in Acrobat’s bookmarks
106     pdftoolbar=true,        % show Acrobat’s toolbar?
107     pdfmenubar=true,        % show Acrobat’s menu?
108     pdffitwindow=false,     % window fit to page when opened
109     pdfstartview={FitH},    % fits the width of the page to the window
110     pdftitle={AliROOT Flow Package manual and documentation},    % title
111     pdfauthor={Redmer Alexander Bertens},     % author
112     pdfsubject={AliROOT Flow Package manual and documentation},   % subject of the document
113     pdfcreator={Redmer Alexander Bertens},   % creator of the document
114     pdfproducer={Redmer Alexander Bertens}, % producer of the document
115     pdfkeywords={ALICE} {AliROOT} {ROOT} {manual} {flow} {package} {software}, % list of keywords
116     pdfnewwindow=true,      % links in new window
117     colorlinks=true,       % false: boxed links; true: colored links
118     linkcolor=blue,          % color of internal links
119     citecolor=green,        % color of links to bibliography
120     filecolor=blue,      % color of file links
121     urlcolor=blue           % color of external links
122 }
123 \usepackage{lineno}
124 \usepackage{makeidx}
125 \makeindex
126
127 \sloppy
128 \fancypagestyle{plain}
129  {
130  \fancyhead{}
131  \fancyfoot{}
132  } % clear header and footer of plain page because of ToC
133
134  % tikxstyle for integration of tikz graphics
135  % for if in the future i'll find time for making a flowchart ...
136 \tikzstyle{every node}=[font=\tiny]
137 \tikzstyle{decision} = [rectangle, draw, fill=yellow!20, 
138     rounded corners, minimum height=1.5em, minimum width=2.5em, inner sep=3pt]
139 \tikzstyle{decision2} = [rectangle, draw, fill=red!20, 
140     rounded corners, minimum height=1.5em, minimum width=2.5em, inner sep=3pt]
141 \tikzstyle{decision3} = [rectangle, draw, fill=green!20, 
142     rounded corners, minimum height=1.5em, minimum width=2.5em, inner sep=3pt]
143 \tikzstyle{block} = [rectangle, draw, fill=blue!20, 
144     rounded corners, minimum height=1.5em, minimum width=2.5em, inner sep=3pt]
145 \tikzstyle{line} = [draw, -latex']
146 \tikzstyle{cloud} = [draw, ellipse,fill=red!20, 
147     minimum height=2em]
148 \tikzstyle{sdecision} = [rectangle, draw, fill=yellow!20, 
149     rounded corners, minimum height=1.5em, minimum width=2.5em, inner sep=3pt]
150 \tikzstyle{sblock} = [rectangle, draw, fill=blue!20, 
151     rounded corners, minimum height=1.5em, minimum width=2.5em, inner sep=3pt]
152 \tikzstyle{scloud} = [draw, ellipse,fill=red!20, 
153     minimum height=2em]
154 \tikzstyle{ycloud} = [draw, ellipse,fill=yellow!20, 
155     minimum height=2em]
156
157 \renewcommand{\thefootnote}{\fnsymbol{footnote}}
158 \frontmatter
159
160 \linenumbers
161 \begin{document}
162
163 \noindent
164 \begin{center}
165         \vspace*{1.5cm}
166         {\LARGE \bf The FLOW Analysis Package}\\
167                 
168         \vspace{1.5cm}
169         \begin{figure}[hbt]
170                 \includegraphics[width=1.\textwidth]{figs/daVinci.png}
171         \end{figure}
172                 
173         \vspace{1.5cm}
174         \noindent
175         {\large \bf a short manual}\\
176         \today\\
177 \vfill
178 \noindent
179 Redmer Alexander Bertens \\ (\texttt{rbertens @ cern.ch}) \\
180 with excerpts from other manuals, authors of those are mentioned in text
181 \end{center}
182
183 \clearpage
184 \thispagestyle{empty}
185 \pagenumbering{roman}
186 \tableofcontents
187 \renewcommand{\thefootnote}{\alph{footnote}}
188 \mainmatter
189 \chapter{Introduction}
190 The \texttt{ALICE flow package}\index{flow package}\index{ALICE flow package|see{flow package}}\footnote{The \texttt{ALICE} flow package is part of \texttt{AliROOT}\index{AliROOT}, the ALICE extension of the \texttt{ROOT} framework, which can be obtained from \href{http://git.cern.ch/pub/AliRoot}{http://git.cern.ch/pub/AliRoot}. The flow package itself is located in the folder \texttt{\$ALICE\_ROOT/PWG/FLOW/}, where \texttt{\$ALICE\_ROOT} refers to the source directory of \texttt{AliROOT}.} contains most known flow analysis methods. The package itself consists of two parts
191 \begin{enumerate}
192     \item The `tasks' library, which can be considered to be the \texttt{ALICE} interface to the package and takes care of e.g. track cuts, event cuts, etc;
193     \item The `base' library, which is the core of the package and contains the actual implementtaion of flow analysis methods such as the scalar product method, Q-cumulant method, etc. This part of the package has no dependencies other than \texttt{ROOT} and can be used on any type of input data.
194 \end{enumerate}
195 \section{This manual}
196 This manual is designed to get you started with using the flow package. It is written in the following way:
197 \begin{itemize}
198     \item Chapter \ref{sec:onthefly} is designed to get you started on a short Monte Carlo example. In this example you will use the flow package to generate toy Monte Carlo events and analyze them;
199     \item Chapter \ref{sec:program} describes the flow package itself in detail. This includes a brief discussion on the structure of the package, sections on track and event cuts, an explanation of some relevant code sections and ending with an example analysis of $v_2(p_t)$ of charged pions with the Q-cumulant method. Most of this chapter pertains to the `tasks (the \texttt{AliROOT})' part of the flow package (i.e. event cuts, track cuts, PID, etc);
200     \item Chapter \ref{sec:methods} gives an overview of the available flow analysis methods. For the theory behind the methods references to papers are given. Settings relevant to the specific implementation are given as well. 
201     \item Lastly, chapter \ref{sec:exotic} explains how the flow package can be put to use in more `exotic' environments, such as an invariant mass method estimate of flow of rapidly decaying particles. 
202     \end{itemize}
203 \section{Disclaimer}
204 What this manual is \emph{not} designed for is letting the analyzer use the flow package as a `black box'. It is supposed to be a starting point, to give an overview of the design of the software and point you to relevant classes, but in the end, the analyzer is responsible for understanding what is happening and using the software in a proper way. Configurations of the package which may work on a technical level (i.e. produce output) do not necessarily mean that the output is what you expect it to be! Always make sure that you understand what you are doing, and when in doubt, browse through the source code or consult an expert. The package is not a static entity, users are encouraged to make additions, be it track cuts, bug fixes, additional analysis methods, etc, etc. If you have suggestions, questions, commit requests, send an email to the flow-pag mailing list or to \texttt{rbertens @ cern}. 
205 \chapter{A Quick Start}\label{sec:onthefly}
206 We'll begin with a hands-on exercise in which you'll get acquainted with some aspects of the flow package in a few minutes. We'll do this by generating a few simple toy Monte Carlo events and performing a flow analysis on these simulated events without writing them (the events) to disk, a so called `flow analysis on-the-fly'\footnote{In this example the \texttt{AliFlowEventSimple} class will be used to generate toy events (which is described in detail in section \ref{sec:program}). Another on-the-fly routine is available in the \texttt{AliFlowEventSimpleMakerOnTheFly}, the original on-the-fly manual for that class is reprinted in the appendix (see \ref{sec:ante}) of this document.}. 
207 \section{On the fly - getting started on a Toy MC}
208 The steps which will be followed in this example will be the same as the steps we take when performing an analysis on data\footnote{In data, some of these steps are actually taken care of by an analysis task, but this will be described in more detail in the next chapter.}: 
209 \begin{enumerate}
210 \item Prepare your \texttt{(Ali)ROOT} session by loaded the necessary libraries
211 \item Create the analysis method objects
212 \item Initialize the methods (which creates their histograms)
213 \item Define track cuts
214 \item Create flow events, which is a container class holding all necessary information (e.g. tracks) for the flow analysis of an event (collision) and actually do the analysis
215 \item Finish the analysis, which will calculate the final $v_n$ values
216 \item Write the results to an output file
217 \end{enumerate}
218 In this Monte Carlo exercise, the flow event class will not receive data from a detector, but instead generate toy events itself. 
219
220 We will now go through these step one-by-one. All the code that is used can also be foud in the macro \texttt{runFlowOnTheFlyExample.C}\index{On the fly}\index{runFlowOnTheFlyExample.C}\footnote{In aliroot, this macro can be found at \\ \texttt{\$ALICE\_ROOT/PWGCF/FLOW/Documentation/examples/manual/runFlowOnTheFlyExample}}.
221 \begin{enumerate}
222         \item To use the flow code the flow library needs to be loaded. In\index{libraries, AliROOT} \texttt{AliROOT}:
223         \begin{lstlisting}[language=C, numbers=left]
224 gSystem->Load("libPWGflowBase");\end{lstlisting}
225         In \texttt{root} additional libraries need to be loaded\index{libraries, ROOT}: 
226         \begin{lstlisting}[language=C, numbers=left]
227 gSystem->Load("libGeom");
228 gSystem->Load("libVMC");
229 gSystem->Load("libXMLIO");
230 gSystem->Load("libPhysics");
231 gSystem->Load("libPWGflowBase");\end{lstlisting}
232         \item We need to instantiate the flow analysis methods which we want to use. In this example we will
233             instantiate two methods: one which calculates the flow versus the Monte Carlo event plane (this our reference value: as the event plane orientation is known by this method, the $v_2$ value we retrieve should be equal to the input $v_2$ by definition) and as a second method the so called Q-cumulant analysis.
234 \begin{lstlisting}[language=C, numbers=left]
235 AliFlowAnalysisWithMCEventPlane *mcep = new AliFlowAnalysisWithMCEventPlane();
236 AliFlowAnalysisWithQCumulants *qc = new AliFlowAnalysisWithQCumulants();\end{lstlisting}
237         \item Each of the methods needs to be initialized\index{initialize methods} (e.g. to define the histograms): 
238 \begin{lstlisting}[language=C, numbers=left]
239 mcep->Init(); 
240 qc->Init();\end{lstlisting}
241         \item To define the particles we are going to use as Reference Particles\index{reference particles} \index{RP|see{reference particles}} (RP's, particles 
242         used for the {\bf Q} vector) and the Particles Of Interest\index{particles of interest} \index{POI|see{particles of interest}} (POI's, the particles of which we calculate the differential flow) we have to define two track cut objects\index{track cut object, simple}:
243         \begin{lstlisting}[language=C, numbers=left]
244 AliFlowTrackSimpleCuts *cutsRP = new AliFlowTrackSimpleCuts();
245 AliFlowTrackSimpleCuts *cutsPOI = new AliFlowTrackSimpleCuts();
246 cutsPOI->SetPtMin(0.2);
247 cutsPOI->SetPtMax(2.0); \end{lstlisting}
248 Particles will be selected as either POI or RP depending on whether or not they pass these cuts.
249         \item Now we are ready to start the analysis. For a quick start we create a toy Monte Carlo event, tag the reference particles and particles of interest (which means that, if a particle passes the POI or RP cuts, it is flagged as `POI' or `RP')  and pass it to the two flow methods. 
250         
251         Since we want to analyze more than one event, this step is performed in loop. First define the number of events that need to be created, their multiplicity, and a value $v_2$ value, which can either be supplied as a fixed number (no $p_t$ dependence) of a function (to generate $p_t$ differential flow\footnote{The on the fly event generator is not limited to the generation of the second harmonic $v_2$, but to get started, this is a nice example.}
252         
253         \begin{lstlisting}[language=C, numbers=left]
254 Int_t nEvents = 1000;   // generate 1000 events
255 Int_t mult = 2000;              // use track multiplicity of 2000
256 Double_t v2 = .05;              // 5 pct integrated flow
257 // or sample differential flow
258 TF1* diffv2 = new TF1("diffv2", "((x<1.)*(0.1/1.)*x+(x>=1.)*0.1)", 0., 20.); \end{lstlisting}
259         
260 Now we have all the ingredients to our first flow analysis      
261         
262         \begin{lstlisting}[language=C, numbers=left]
263 for(Int_t i=0; i<nEvents; i++) { 
264     // make an event with mult particles 
265     AliFlowEventSimple* flowevent = AliFlowEventSimple(mult,AliFlowEventSimple::kGenerate);
266     // modify the tracks adding the flow value v2
267     flowevent->AddV2(diffv2);
268     // select the particles for the reference flow
269     flowevent->TagRP(cutsRP);
270     // select the particles for differential flow
271     flowevent->TagPOI(cutsPOI);
272     // do flow analysis with various methods:
273     mcep->Make(flowevent);
274     qc->Make(flowevent);
275     // delete the event from memory
276     delete flowevent;
277 } \end{lstlisting}
278         \item To fill the histograms which contain the final results we have to call Finish for each method:
279         \begin{lstlisting}[language=C, numbers=left]
280 mcep->Finish(); 
281 qc->Finish(); \end{lstlisting}
282         \item This concludes the analysis and now we can write the results into a file. Two options for writing the input to a file are available: 
283      \begin{itemize}
284      \item Create a new output file and write the output to this file
285      \begin{lstlisting}[language=C, numbers=left]
286 TFile *outputFile = new TFile("outputMCEPanalysis.root","RECREATE");
287 mcep->WriteHistograms();
288 TFile *outputFile = new TFile("outputQCanalysis.root","RECREATE");
289 qc->WriteHistograms();\end{lstlisting}
290
291 Please note that this will create a new output file, and overwrite any existing filse called \texttt{AnalysisResults.root}.
292
293 \item  To write the output of multiple analyses into subdirectories of one file, one can do the following:
294 \begin{lstlisting}[language=C, numbers=left]
295 TFile *outputFile = new TFile("AnalysisResults.root","RECREATE");
296 TDirectoryFile* dirQC = new TDiretoryFile("outputQCanalysis", "outputQCanalysis");
297 qc->WriteHistograms(dirQC);
298 TDirectoryFile* dirMCEP = new TDiretoryFile("outputMCEPanalysis", "outputMCEPanalysis");
299 mcep->WriteHistograms(dirMCEP);
300 \end{lstlisting}
301 \end{itemize}
302
303 Note that \texttt{AnalysisResults.root} \index{AnalysisResults.root} is the default name given to analyses in \texttt{AliROOT}. Many macros in \texttt{AliROOT} will expect a file \texttt{AnalyisResults.root} as input, so for most users it will be convenient to follow this convention.
304
305 When done with running the analysis, do not forget to write the file to disk by calling
306 \begin{lstlisting}[language=C, numbers=left]
307 TFile::Close(); // write the buffered file to disk \end{lstlisting}
308 \end{enumerate}
309
310 \section{What is in the output file ?}
311 \index{output file} Now we have written the results into a file, but what is in there? 
312
313 Although the output of different flow analysis techniques might differ slightly as a result of their different approaches at estimating $v_2$, the output files containers are always constructed in a similar way. 
314
315 \subsection{AliFlowCommonHists - Output objects}\label{sec:commonhists}
316 Objects of two types are stored in the output of the flow analysis\footnote{Make sure that \texttt{libPWGflowBase.so} is loaded in your \texttt{(Ali)ROOT} session, otherwise these objects will be unknown.}
317 \begin{enumerate}
318 \item \texttt{AliFlowCommonHist}\index{AliFlowCommonHist}, which is a class that contains common histograms for the flow analysis (e.g. QA histograms and histograms that contain the analysis flags which were used). Depending on the type of flow analysis that was used, this object contains histograms from the following list:
319 \begin{lstlisting}[language=C, numbers=left]
320   Bool_t    fBookOnlyBasic;       // book and fill only control histos needed for all methods
321   TH1F*     fHistMultRP;          // multiplicity for RP selection
322   TH1F*     fHistMultPOI;         // multiplicity for POI selection
323   TH2F*     fHistMultPOIvsRP;     // multiplicity for POI versus RP
324   TH1F*     fHistPtRP;            // pt distribution for RP selection
325   TH1F*     fHistPtPOI;           // pt distribution for POI selection
326   TH1F*     fHistPtSub0;          // pt distribution for subevent 0
327   TH1F*     fHistPtSub1;          // pt distribution for subevent 1
328   TH1F*     fHistPhiRP;           // phi distribution for RP selection
329   TH1F*     fHistPhiPOI;          // phi distribution for POI selection
330   TH1F*     fHistPhiSub0;         // phi distribution for subevent 0
331   TH1F*     fHistPhiSub1;         // phi distribution for subevent 1
332   TH1F*     fHistEtaRP;           // eta distribution for RP selection
333   TH1F*     fHistEtaPOI;          // eta distribution for POI selection
334   TH1F*     fHistEtaSub0;         // eta distribution for subevent 0
335   TH1F*     fHistEtaSub1;         // eta distribution for subevent 1
336   TH2F*     fHistPhiEtaRP;        // eta vs phi for RP selection
337   TH2F*     fHistPhiEtaPOI;       // eta vs phi for POI selection
338   TProfile* fHistProMeanPtperBin; // mean pt for each pt bin (for POI selection)
339   TH2F*     fHistWeightvsPhi;     // particle weight vs particle phi
340   TH1F*     fHistQ;               // Qvector distribution
341   TH1F*     fHistAngleQ;          // distribution of angle of Q vector
342   TH1F*     fHistAngleQSub0;      // distribution of angle of subevent 0 Q vector
343   TH1F*     fHistAngleQSub1;      // distribution of angle of subevent 1 Q vector
344   TProfile* fHarmonic;            // harmonic 
345   TProfile* fRefMultVsNoOfRPs;    // <reference multiplicity> versus # of RPs
346   TH1F*     fHistRefMult;         // reference multiplicity distribution
347   TH2F*     fHistMassPOI;         // mass distribution for POI selection \end{lstlisting}
348   This information is from the header file of the AliFlowCommonHist object\footnote{The headers of both output objects can be found in \texttt{\$ALICE\_ROOT/PWG/FLOW/Base/}.}
349   \item \texttt{AliFlowCommonHistResults}\index{AliFlowCommonHistResults} is an object designed to hold the common results of the flow analysis\footnote{The word common here is used to indicate histograms that hold observables which are evaluated in all flow analysis methods. Specific analysis methods may however store additional histograms which are not covered in this list!}. The possible common histograms stored in this object are
350   \begin{lstlisting}[language=C, numbers=left]
351   TH1D* fHistIntFlow; // reference flow
352   TH1D* fHistChi;     // resolution
353   // RP = Reference Particles:  
354   TH1D* fHistIntFlowRP;     // integrated flow of RPs
355   TH1D* fHistDiffFlowPtRP;  // differential flow (Pt) of RPs
356   TH1D* fHistDiffFlowEtaRP; // differential flow (Eta) of RPs
357   // POI = Particles Of Interest:
358   TH1D* fHistIntFlowPOI;     // integrated flow of POIs
359   TH1D* fHistDiffFlowPtPOI;  // differential flow (Pt) of POIs
360   TH1D* fHistDiffFlowEtaPOI; // differential flow (Eta) of POIs \end{lstlisting}
361   
362   \end{enumerate}
363   The titles of the histograms in the output object differ from the names of the pointers given in the two lists printed above, but the lists give an overview of what is available; the easiest way however of getting acquainted with where to find histograms in the output is browsing them in \texttt{ROOT's TBrowser}\index{TBrowser} (see figure \ref{fig:browserExample}).
364   \begin{lstlisting}[language=C, numbers=left]
365   new TBrowser(); \end{lstlisting}
366 \begin{SCfigure}
367  \includegraphics[width=0.70\textwidth]{figs/browserExample.png}
368  \caption[TBrowser with output file]{Example of output file opened in a TBrowser, results of differential $v_2$ analysis with second order Q-cumulant analysis are shown.}
369  \label{fig:browserExample}
370 \end{SCfigure}
371
372 The \texttt{AliFlowCommonHist} and \texttt{AliFlowCommonHistResults} classes are derived from the generic \texttt{TNamed}\index{TNamed} \texttt{ROOT} object and can be written to a \texttt{ROOT} file. The flow analysis tasks will, as output, write the complete \texttt{AliFlowCommonHist} and \texttt{AliFlowCommonHistResults} objects to file at the end of an analysis. To read the content of these objects, the \texttt{libPWGflowBase} library must be loaded in your \texttt{ROOT} session. 
373
374 \subsubsection{Comparing flow results}
375 A convenient way of comparing the results of the different flow analysis strategies that have been used is invoking the macro \texttt{compareFlowResults.C}\footnote{\texttt{\$ALICE\_ROOT/PWGCF/FLOW/macros/compareFlowResults.C}}\index{compareFlowResults}.  This macro will read the analysis output file \texttt{AnalysisResults.root}, extract the requested results from it and plot them. For a full overview of what can be done with the macro, the reader is referred to the macro itself and its ample documentation. To run the macro on the dataset that we have just generated, simply do
376 \begin{lstlisting}[language=C, numbers=left]
377 .L compareFlowResults.C
378 compareFlowResults(TSring(""))  // the empty suffix indicates on the fly events \end{lstlisting}
379
380 \begin{SCfigure}
381  \includegraphics[width=0.70\textwidth]{figs/compareFlowResults.png}
382  \caption[Comparing on the fly flow results]{Example of inspecting the output file of the on the fly analysis with the \texttt{compareFlowResults.C macro}.}
383  \label{fig:browserExample}
384 \end{SCfigure}
385
386
387 \chapter{The Program}\label{sec:program}
388 The basic idea behind the flow package is that from whatever input you have, a \emph{flow event}\index{flow event} is constructed, which is then passed to one or more flow analysis methods\index{flow analysis method} (e.g. the scalar product method\index{scalar product} or Q-cumulant\index{Q-cumulant} method). The flow event is a collection of \emph{flow tracks}\index{flow track}, which are simple objects carrying only the kinematic information that is necessary to do flow analysis. By setting up the flow package in this way, the flow analysis methods can analyze input from various sources, be it ALICE data, Monte Carlo events, STAR data, etc, etc, as long as the flow event is properly filled\index{STAR input} \index{Monte Carlo input}. This might all sound a bit abstract at this point; this chapter however will explain all details and relevant classes in detail. For those who are impatient and prefer seeing the flow package in action, section \ref{sec:example} gives a step-by-step example of doing a $\pi^{\pm}$ $v_2$ analysis in the \texttt{AliROOT} analysis framework. 
389
390 \section{Overview}
391 \begin{figure}
392 \begin{center}
393 \includegraphics[width=.75\textwidth]{figs/flowChart.png}
394 \caption{Schematic presentation of the organization of the flow package. Input, which can come from any kind of source, is converted to a generic \texttt{AliFlowEventSimple} object, which in turn is passed to the analysis methods.}
395 \label{fig:flowchart}
396 \end{center}
397 \end{figure}
398 Figure \ref{fig:flowchart} gives a simple schematic representation\index{flowchart} of the flow package. Input events (in the case of the figure this is either ESDs or AODs) pass a set of event cuts (the common cuts) and are then converted to a flow event (stored as an \texttt{AliFlowEventSimple}\index{AliFlowEventSimple} object). This flow event holds a collection of flow tracks (\texttt{AliFlowTrackSimple}\index{AliFlowTrackSimple} objects) which are passed to flow analysis methods. The only steps of this flow chart which depend on \texttt{AliROOT} libraries are the ones handling \texttt{ALICE} data types (the ESDs or AODs). The rest of the analysis chain (the \texttt{AliFlowEventSimle} and the analysis methods) have no specific \texttt{AliROOT} dependence and are just simple \texttt{c++} objects. Therefore, the flow package is split into two libraries
399 \begin{description}
400     \item [libPWGflowBase] \index{libPWGflowBase}The base library, which has no specific \texttt{AliROOT} dependencies. This library holds objects such as the \texttt{AliFlowEventSimple} and \texttt{AliFlowTrackSimple}, and analysis methods classes. The analysis methods classes follow the naming scheme: \texttt{AliFlowAnalysisWith$\ast$} where $\ast$ denotes a specific analysis method. All classes which end up in the \text{libPWGflowBase.so} shared object can be found in \texttt{\$ALICE\_ROOT/PWG/FLOW/Base};
401     \item [libPWGflowTasks] \index{libPWGflowTasks} The tasks library, which has specific \texttt{AliROOT} dependencies. Contrary to what the name suggests, this library does not just hold tasks, but actually comprises all classes of the flow package which need to include \texttt{AliROOT} specific classes. This ranges from classes to read the AOD or ESD input data (important examples are the \texttt{AliFlowEvent}\index{AliFlowEvent} and \texttt{AliFlowTrackCuts}\index{AliFlowTrackCuts}, which will be discussed later on in this chapter) and the \texttt{AliAnalysisTask$\ast$} classes, which are analysis tasks, derived from \texttt{AliAnalysisTaskSE} which can be used in the \texttt{AliROOT} analysis framework and are actually just interface classes to the underlying flow analysis methods of libPWGflowBase. The classes which are bundled into the \text{libPWGflowTasks.so} shared object can be found in \texttt{\$ALICE\_ROOT/PWG/FLOW/Tasks};
402 \end{description}
403 Some tools, such as the flow event or track cuts, have a `base' component which name ends with the suffix `simple', and an `tasks' (\texttt{AliROOT}) component which does not have this suffix. The `tasks' class in these cases inherits from the `base' class. 
404
405 \section{Flow Event}\index{flow event}
406 Every flow analysis in the flow package starts with the flow event. As mentioned earlier, the flow event is a simple container class which holds a collection of flow tracks, which are in turn fed to the flow analysis methods. 
407 \subsection{Input data}\index{input data}
408 Before passing the flow event to the flow analysis methods, it needs to be filled with a set of flow tracks. In general, a distinction is made between \emph{reference particles} (or \emph{RP's}), which are particles that are used to build the \textbf{Q} vector(s), and \emph{particles of interest} (or \emph{POI's}), which are the particles of which you'll calculate the differential flow. The flow event and the flow analysis methods are designed to keep track of which flow tracks are POI's, RP's (or even both at the same time), which is important to avoid auto-correlation effects which can distort the $v_n$ measurement. The user of the flow package however is responsible for properly setting up the analysis! 
409
410 The flow event can be filled with input from many sources. In the second chapter of this manual, a simple method has been shown where the flow event (the \texttt{AliFlowEventSimple} object) fills itself by generating a set of Monte Carlo tracks by sampling kinematic variables from supplied p.d.f.'s. Using this method is a very effective tool for testing and developing new flow analysis methods (if you generate events with a certain $v_2(p_t)$ and then retrieve the same $v_2(p_t)$ from your flow analysis method, you can use that as a tool to proof the validation of your analysis method) but if you want to do a data analysis, a somewhat more advanced - but not difficult - approach is necessary. 
411
412 Filling a flow event from data can be performed either `by-hand' (which is covered in section \ref{sec:exotic} on more exotic analyses), but the most commonly used method of filling a flow event in the \texttt{AliROOT} analysis framework is using the dedicated task \texttt{AliAnalysisTaskFlowEvent}\index{AliAnalysisTaskFlowEvent}. 
413
414 The idea behind this is the following:
415 \begin{enumerate}
416 \item Setup the \texttt{AliAnalysisTaskFlowEvent} task to receive input events (e.g. \texttt{AODs}, \texttt{ESDs}, \texttt{MC}, $\ldots$;
417 \item Define two sets of track selection criteria (colloquially referred to as \emph{track cuts}), one for POI's and one for RP's;
418 \item Pass these two sets of track cuts to the \texttt{AliAnalysisTaskFlowEvent};
419 \item The \texttt{AliAnalysisTaskFlowEvent} will convert the tracks  of each input event to a set of \texttt{AliFlowSimpleTracks}. Depending on whether or not a track passes the track selection for POI's or RP's, the \texttt{AliFlowSimpleTrack} is labeled as a POI or RP (or both. In the case where a track does not meet any of the track selection criteria, it is omitted from the \texttt{AliFlowSimpleTrack} collection and not added to the flow event);
420 \item All the \texttt{AliFlowSimpleTracks} are added to the flow event which is passed to the flow analysis methods. 
421 \end{enumerate}
422
423 \subsection{Event selection}\index{event selection}
424 When using the \texttt{AliAnalysisTaskFlowEvent} task to create your flow event, the \texttt{AliAnalysisTaskFlowEvent} task is responsible for ensuring that only good quality tracks enter into your analysis by making sensible track selections. The first step however at safeguarding track quality is making sure that the events that are accepted by \texttt{AliAnalysisTaskFlowEvent} pass sane event selection criteria. 
425
426 \subsubsection{Trigger selection}\index{event selection!trigger selection}
427 A certain combination a of detector signals (a \emph{trigger}) is required for an event to be written to storage. Different types of analyses might require different types of events, and hence, different types of triggers. 
428
429 You can set a trigger by calling
430 \begin{lstlisting}[language=C, numbers=left]
431 AliAnalysisTaskFlowEvent::SelectCollisionCandidates(UInt_t offlineTriggerMask);\end{lstlisting}
432 where \texttt{offlineTriggerMask} is the trigger mask corresponding to the desired trigger. A list of all available triggers, with a short descrption, can be found in the header file of the \texttt{AliVEvent} class\footnote{\texttt{\$ALICE\_ROOT/...}}. This function, however, is not implement in the \texttt{AliAnalysisTaskFlowEvent} itself, but rather in the base class of which most of the analysis task classes within \texttt{AliROOT} are derived: the \texttt{AliAnalysisTaskSE} class (which is designed to handle a single event, hence the suffix `SE'). For each event that is written from a file, but function \texttt{AliAnalysisTaskSE::Exec()} is called, which - among other things - checks if an event passes the requested trigger selection, and if so, calls the \texttt{UserExec()} function of your analysis task. In the case of the \texttt{AliAnalysisTaskFlowEvent} this is the \texttt{AliAnalysisTaskFlowEvent::UserExec()}, which creates \texttt{AliFlowSimpleTracks} and fills the flow event. 
433
434 A general remark about trigger selection in flow analyses is that the non-uniform acceptance correction methods that are implemented in the flow package assume a flat \textbf{Q} vector distribution. Specific triggers (e.g. EMCal triggers) result in a \textbf{Q} vector bias which should \emph{not} be corrected as they invalidate that assumption. A safe approach is therefore using a minimum bias trigger for your analysis (such as \texttt{AliVEvent::kMB}), other triggers selections will not a-priori lead to problems, but use them with caution!
435
436 \subsubsection{Event cuts}\index{event selection!event cuts}
437 In addition to trigger selection, generally one wants to perform additional event (quality) selection. The flow package contains an event cuts class which can be used to perform event selection, the \texttt{AliFlowEventCuts} object\footnote{\texttt{\$ALICE\_ROOT/PWG/FLOW/Tasks/AliFlowEventCuts.cxx}}. \index{AliFlowEventCuts}
438
439 To use the event cuts object in combination with the \texttt{AliAnalysisTaskFlowEvent} task, simply create the event cuts object, configure it and pass it to the \texttt{AliAnalysisTaskFlowEvent}:
440 \begin{lstlisting}[language=C, numbers=left]
441   AliFlowEventCuts* cutsEvent = new AliFlowEventCuts("EventCuts");
442   // configure some event cuts, e.g. centrality
443   cutsEvent->SetCentralityPercentileRange(20., 30.);
444   // pass it to the flow event task via the setter
445   AliAnalysisTaskFlowEvent::SetCutsEvent(cutsEvent);\end{lstlisting}
446
447   The available cut parameters in the flow event cuts object are\index{event selection!parameters}
448 \begin{lstlisting}[language=C, numbers=left]
449   Bool_t fCutNumberOfTracks;//cut on # of tracks
450   Int_t fNumberOfTracksMax;  //limits
451   Int_t fNumberOfTracksMin;  //limits
452   Bool_t fCutRefMult; //cut on refmult
453   refMultMethod fRefMultMethod; //how do we calculate refmult?
454   Bool_t fUseAliESDtrackCutsRefMult; //use AliESDtrackCuts for refmult calculation
455   AliESDtrackCuts::MultEstTrackType fRefMultMethodAliESDtrackCuts;
456   Int_t fRefMultMax; //max refmult
457   Int_t fRefMultMin; //min refmult
458   AliFlowTrackCuts* fRefMultCuts; //cuts
459   AliFlowTrackCuts* fMeanPtCuts; //mean pt cuts
460   AliFlowTrackCuts* fStandardTPCcuts; //Standard TPC cuts
461   AliFlowTrackCuts* fStandardGlobalCuts; //StandardGlobalCuts
462   Bool_t fCutPrimaryVertexX; //cut on x of prim vtx
463   Double_t fPrimaryVertexXmax; //max x prim vtx
464   Double_t fPrimaryVertexXmin; //min x prim vtx
465   Bool_t fCutPrimaryVertexY; //cut on y of prim vtx
466   Double_t fPrimaryVertexYmax; //max y prim vtx
467   Double_t fPrimaryVertexYmin; //min y prim vtx
468   Bool_t fCutPrimaryVertexZ; //cut on z of prim vtx
469   Double_t fPrimaryVertexZmax; //max z prim vtx
470   Double_t fPrimaryVertexZmin; //min z prim vtx
471   Bool_t fCutNContributors; //cut on number of contributors
472   Int_t fNContributorsMax; //maximal number of contrib
473   Int_t fNContributorsMin; //minimal number of contrib
474   Bool_t fCutMeanPt; //cut on mean pt
475   Double_t fMeanPtMax; //max mean pt
476   Double_t fMeanPtMin; //min mean pt
477   Bool_t fCutSPDvertexerAnomaly; //cut on the spd vertexer anomaly
478   Bool_t fCutSPDTRKVtxZ; //require compatibility between SPDvertexz TRKvertexz
479   Bool_t fCutTPCmultiplicityOutliers; //cut TPC multiplicity outliers
480   Bool_t fCutTPCmultiplicityOutliersAOD; // cut TPC outliers in 10h or 11h aod
481   Bool_t fUseCentralityUnchecked; //use the unchecked method
482   refMultMethod fCentralityPercentileMethod; //where to get the percentile from
483   Bool_t fCutZDCtiming;   //cut on ZDC timing
484   AliTriggerAnalysis fTrigAna; //trigger analysis object
485   Bool_t fCutImpactParameter; //cut on impact parameter (MC header)
486   Double_t fImpactParameterMin; // min impact parameter
487   Double_t fImpactParameterMax; // max impact parameter
488   TH2F *fhistTPCvsGlobalMult; //!correlation between TPCMult and GlobalMult
489   Bool_t fData2011; //2011 data is used\end{lstlisting}
490   all of which are accessible via dedicated setters\index{event selection!setters},
491 \begin{lstlisting}[language=C, numbers=left]
492   void SetNumberOfTracksMax(Int_t value) {fNumberOfTracksMax=value;fCutNumberOfTracks=kTRUE;}
493   void SetNumberOfTracksMin(Int_t value) {fNumberOfTracksMin=value;fCutNumberOfTracks=kTRUE;}
494   void SetNumberOfTracksRange(Int_t min, Int_t max) {fNumberOfTracksMin=min;fNumberOfTracksMax=max;fCutNumberOfTracks=kTRUE;}
495   void SetRefMultMax(Int_t value) {fRefMultMax=value;fCutRefMult=kTRUE;}
496   void SetRefMultMin(Int_t value) {fRefMultMin=value;fCutRefMult=kTRUE;}
497   void SetRefMultRange(Int_t min, Int_t max) {fRefMultMin=min;fRefMultMax=max;fCutRefMult=kTRUE;}
498   void SetImpactParameterMax(Double_t value) {fImpactParameterMax=value;fCutImpactParameter=kTRUE;}
499   void SetImpactParameterMin(Double_t value) {fImpactParameterMin=value;fCutImpactParameter=kTRUE;}
500   void SetImpactParameterRange(Double_t min, Double_t max) {fImpactParameterMin=min;fImpactParameterMax=max;fCutImpactParameter=kTRUE;}
501   void SetPrimaryVertexXrange(Double_t min, Double_t max)
502   void SetPrimaryVertexYrange(Double_t min, Double_t max)
503   void SetPrimaryVertexZrange(Double_t min, Double_t max)
504   void SetNContributorsRange(Int_t min, Int_t max=INT_MAX) 
505   void SetMeanPtRange(Double_t min, Double_t max) {fCutMeanPt=kTRUE; fMeanPtMax=max; fMeanPtMin=min;}
506   void SetCutSPDvertexerAnomaly(Bool_t b=kTRUE) {fCutSPDvertexerAnomaly=b;}
507   void SetCutZDCtiming(Bool_t c=kTRUE) {fCutZDCtiming=c;}
508   void SetCutSPDTRKVtxZ(Bool_t b=kTRUE) {fCutSPDTRKVtxZ=b;}
509   void SetCutTPCmultiplicityOutliers(Bool_t b=kTRUE) {fCutTPCmultiplicityOutliers=b;}  
510   void SetCutTPCmultiplicityOutliersAOD(Bool_t b=kTRUE) {fCutTPCmultiplicityOutliersAOD=b;}
511   void SetRefMultMethod(refMultMethod m) {fRefMultMethod=m;}
512   void SetRefMultMethod(AliESDtrackCuts::MultEstTrackType m) { fRefMultMethodAliESDtrackCuts=m; 
513   void SetRefMultCuts( AliFlowTrackCuts* cuts ) {fRefMultCuts=static_cast<AliFlowTrackCuts*>(cuts->Clone());}
514   void SetMeanPtCuts( AliFlowTrackCuts* cuts ) {fMeanPtCuts=static_cast<AliFlowTrackCuts*>(cuts->Clone());}
515   void SetQA(Bool_t b=kTRUE) {if (b) DefineHistograms();}
516   void SetCentralityPercentileMethod( refMultMethod m) {fCentralityPercentileMethod=m;}
517   void SetUseCentralityUnchecked(Bool_t b=kTRUE) {fUseCentralityUnchecked=b;}
518   void SetUsedDataset(Bool_t b=kTRUE) {fData2011=b;}    // confusing name, better use different interface
519   void SetLHC10h(Bool_t b=kTRUE) {fData2011=(!b);}      // TODO let cut object determine runnumber and period
520   void SetLHC11h(Bool_t b=kTRUE) {fData2011=b;}         // use this only as 'manual override'\end{lstlisting}
521
522 \subsubsection{Caveats and remarks}  
523 Some caveats\index{event selection!caveats} and remarks about using the event cuts object
524 \begin{description}
525 \item[Default behavior] By default, the event cuts object accepts all events. All desired cuts have to be set by the user. This is also reflected in the design of the setters: most of the setters will, when called, set a \texttt{Bool\_t} to true which enables a cut on a certain parameter;
526 \item[Applicability of cuts to different datatypes] \index{event selection!data types}Not all the cuts can be applied to all input data types. In e.g. the process of filtering \texttt{AODs} from \texttt{ESDs}, `technical' event cuts are made and not all events are stored in the \texttt{AOD} format. Because of this, information that can be rqeuired from \texttt{ESDs} might not be available (as it is not necessary) in \texttt{AODs}. To see whether or not a cut you set is actually applied to the datatype you're using, take a look at
527 \begin{lstlisting}[language=C, numbers=left]
528 Bool_t AliFlowEventCuts::PassesCuts(AliVEvent *event, ALIMCEvent *mcevent)\end{lstlisting}
529 This function determines whether or not an event is accepted: it starts by converting the virtual event type that is passed as argument to either an \texttt{ESD} or \texttt{AOD} event, and goes through selection criteria accordingly. 
530 \item[Event cuts outside of the \texttt{AliAnalysisTaskFlowEvent} class]
531 When you perform a flow analysis without using the \texttt{AliAnalysisTaskFlowEvent} class (which is done e.g. in the analyses explained in section \ref{sec:exotic}), you can still use the event cuts class by creating an instance of the object, passing it to your analsyis class and `manually' checking the return value of the function 
532 \begin{lstlisting}[language=C, numbers=left]
533 Bool_t AliFlowEventCuts::PassesCuts(AliVEvent *event, ALIMCEvent *mcevent)\end{lstlisting}
534 \item[Data taking period] Most event cuts will be tuned specifically to the LHC10h or LHC11h data taking periods. The event cuts class might need to be updated to accomodate specific cuts for different periods - do not hesitate write patches for this!
535 \end{description}
536 for e.g. each event that is passed to your \texttt{::UserExec()} function.
537
538 \section{Track cuts and the track cuts object}\index{track selection}
539 As explained in the previous subsection, flow events are filled with tracks which fulfill certain track selection criteria. These criteria are checked using the \texttt{AliFlowTrackCuts} class. The \texttt{AliFlowTrackCuts} class can handle different types of input from diffferent data-types (e.g. \texttt{ESD} or \texttt{AOD}) and information from different sub-detector systems. All input is in the end converted to \texttt{AliFlowSimpleTracks} which are added to the flow event. To understand how the \texttt{AliFlowTrackCuts}\index{AliFlowTrackCuts} object works and how it should be configured, it is good to make a few distinctions and remarks. 
540
541 The term `track' is generally used for reconstructed particle trajectories which are constructed from information coming from the tracking detectors in central barrel of the \texttt{ALICE} detector (more specifically from information from the \texttt{ITS} and \texttt{TPC} detectors). Tracks are the most commonly used data source, and the translation from `track' to \texttt{AliFlowTrackSimple} is trivial, as it merely comprises copying  kinematic information ($p_t$, $\varphi$, $\eta$) from the barrel track to the \texttt{AliFlowTrackSimple} object. 
542
543 When using information that is not coming from tracking detectors, e.g. information from the \texttt{VZERO}\index{VZERO} system, this procedure of simply copying variables is not suitable as the \texttt{VZERO} system does not measure $p_t$, $\varphi$, $\eta$ of particles, but is an array of scintillators with limited spatial resolution. Nevertheless, the \texttt{AliFlowTrackCuts} class converts the \texttt{VZERO} signal to \texttt{AliFlowTrackSimples} which are, to the flow event, indistinguishable from barrel tracks. As the procedure of accepting these tracks is very different from the procedure of accepting barrel tracks, they will be treated separately in the following subsections. 
544
545 \subsection{ESD tracks as data source}\index{track selection!ESD tracks}
546 The safest and most convenient way of using \texttt{ESD} tracks as a data source is by using one of the pre-defined track cuts sets that are available in the \texttt{AliFlowTrackCuts} class. These sets of track cuts mimic the cuts that are defined in the \texttt{AliESDtrackCuts} class\footnote{\texttt{\$ALICE\_ROOT/ANALYSIS/AliESDtrackCuts.cxx}}. The following default track cuts sets are available:
547 \begin{lstlisting}[language=C, numbers=left]
548   static AliFlowTrackCuts* GetStandardTPCStandaloneTrackCuts();
549   static AliFlowTrackCuts* GetStandardTPCStandaloneTrackCuts2010();
550   static AliFlowTrackCuts* GetStandardGlobalTrackCuts2010();
551   static AliFlowTrackCuts* GetStandardITSTPCTrackCuts2009(Bool_t selPrimaries=kTRUE);
552   static AliFlowTrackCuts* GetStandardMuonTrackCuts(Bool_t isMC=kFALSE, Int_t passN=2);
553   \end{lstlisting}
554 All these are static methods which create a new track cuts object and configure it properly, so to use these track cuts it suffices to type e.g.
555 \begin{lstlisting}[language=C, numbers=left]
556 AliFlowTrackCuts* myCuts = AliFlowTrackCuts::GetStandardGlobalTrackCuts2010();\end{lstlisting}
557 To get a better understanding of what the \texttt{AliFlowTrackCuts} class actually does, let's take a look at what how the cut object is configured in this case:
558 \begin{lstlisting}[language=C, numbers=left]
559 AliFlowTrackCuts* AliFlowTrackCuts::GetStandardGlobalTrackCuts2010()
560 {
561   //get standard cuts
562   AliFlowTrackCuts* cuts = new AliFlowTrackCuts("standard Global tracks");
563   cuts->SetParamType(kGlobal);
564   cuts->SetPtRange(0.2,5.);
565   cuts->SetEtaRange(-0.8,0.8);
566   cuts->SetMinNClustersTPC(70);
567   cuts->SetMinChi2PerClusterTPC(0.1);
568   cuts->SetMaxChi2PerClusterTPC(4.0);
569   cuts->SetMinNClustersITS(2);
570   cuts->SetRequireITSRefit(kTRUE);
571   cuts->SetRequireTPCRefit(kTRUE);
572   cuts->SetMaxDCAToVertexXY(0.3);
573   cuts->SetMaxDCAToVertexZ(0.3);
574   cuts->SetAcceptKinkDaughters(kFALSE);
575   cuts->SetMinimalTPCdedx(10.);
576   return cuts;
577 }\end{lstlisting}
578 The configuration falls into three categories:
579 \begin{enumerate}
580 \item A number of track quality cuts is set;
581 \item Some kinematic cuts are set;
582 \item The parameter type\index{track selection!parameter type} is set by calling \texttt{AliFlowTrackCuts::SetParamType()} (in this case to \texttt{AliFlowTrackCuts::kGlobal}). This last step is of particular importance as it takes care disentangling the POI and RP selection and removing a $v_n$ bias due to auto-correlations. When the flow event is filled (the relevant piece of code is printed under section \ref{sec:fill}), a check is done to see if the POI's and RP's are of the same type. If not, a track cannot be a POI and RP at the same time (as they are from different sources). However, if POI's and RP's originate from the same source, an \texttt{AliFlowTrackSimple} can be both a POI and RP at the same time if it satisfies both the POI and RP track selection criteria. By specifying the parameter type by calling \texttt{AliFlowTrackCuts::SetParamType()} the flow event is configured to properly deal with overlapping or exclusive POI and RP selections. A wrongly configured parameter type can lead to double counting of tracks and nonsensical analysis results! The following list of track parameter types is available as an \texttt{enum} in \texttt{AliFlowTrackCuts.h}
583 \begin{lstlisting}[language=C, numbers=left]
584   enum trackParameterType { kMC, 
585                             kGlobal, 
586                             kTPCstandalone, 
587                             kSPDtracklet,
588                             kPMD,
589                             kV0,    //neutral reconstructed v0 particle
590                             kVZERO, //forward VZERO detector
591                             kMUON,
592                             kKink,
593                             kAODFilterBit,
594                             kUserA,     // reserved for custom cuts
595                             kUserB      // reserved for custom cuts
596                           };\end{lstlisting}
597 Note that \texttt{kV0} is reserved to denote a decay vertex of a neutral particle, and \texttt{kVZERO} is used to indicate the VZERO detector system. kUserA and kUserB are additional flags which can selected for `custom' track selection sets.
598 \end{enumerate}
599
600 \subsection{AOD tracks as data source}\index{track selection!AOD tracks}
601 \texttt{AOD} tracks are derived from \texttt{ESD} tracks via process called `fitlering'. If an \texttt{ESD} track meets a pre-defined set of track cuts, it is converted to an \texttt{AOD} track which is stored in an \texttt{AOD} event. The \texttt{AOD} track carries a specific flag (called \texttt{filterbit}) which corresponds to the specific set of cuts that was applied to create accept the track. A full list of track selection criteria corresponding to distinct filterbits can be found \href{}{here}. Note that different \texttt{AOD} productions might have different filterbit definitions!
602
603 In \texttt{AOD} analysis it generally suffices to select tracks of a certain filterbit, instead of checking quality criteria `by-hand' as is done in \texttt{ESD} analyses (some variables which one would cut on in \texttt{ESD} tracks might not even be available in the \texttt{AOD} tracks as the \texttt{AOD} is designed to be a light-weight `end-user' data format). To get an instance of the \texttt{AliFlowTrackCuts} object which only selects tracks based on a specific filterbit\index{track selection!AOD filterbit}\index{filterbit}, one can call
604 \begin{lstlisting}[language=C, numbers=left]
605  static AliFlowTrackCuts* GetAODTrackCutsForFilterBit(UInt_t bit = 1);\end{lstlisting}
606  which is defined as
607  \begin{lstlisting}[language=C, numbers=left]
608  AliFlowTrackCuts* AliFlowTrackCuts::GetAODTrackCutsForFilterBit(UInt_t bit)
609 {
610   // object which in its default form only cuts on filterbit (for AOD analysis)
611   AliFlowTrackCuts* cuts = new AliFlowTrackCuts(Form("AOD fitlerbit %i", (int)bit));
612   cuts->SetMinimalTPCdedx(-999999999);
613   cuts->SetAODfilterBit(bit);
614   cuts->SetParamType(AliFlowTrackCuts::kAODFilterBit);
615   return cuts;
616 }  \end{lstlisting}
617 The \texttt{SetMinimalTPCdedx(-999999999);} is kept here for backward-compatibility. 
618
619 Note that also in the case of \text{AOD} analyses the parameter type is set to (if necessary) decouple POI and RP selections. 
620
621 \subsection{Additional options}
622 As stated, input data needn't necessarily come in the form of barrel tracks - we can use other detector systems as well. When dealing with barrel tracks, quality criteria might not be the only thing you want to select your tracks on: perhaps you want to do analysis on identified particles. The following sub-sections explain how the \texttt{AliFlowTrackCuts} object can be used to achieve this. 
623
624 \subsubsection{Identified particles}\index{track selection!particle identification}\index{particle identification}
625 The \texttt{AliFlowTrackCuts} object can do particle selection for a number of particles that are defined in the AliPID\footnote{\texttt{\$ALICE\_ROOT/STEER/STEERBas/AliPID.h}}. To enable 
626 particle identification as a selection criterion, call the function
627 \begin{lstlisting}[language=C, numbers=left]
628 void AliFlowTrackCuts::SetPID(
629     AliPID::EParticleType pid, 
630     PIDsource s=kTOFpid, 
631     Double_t prob=0.9)
632 {fParticleID=pid; fPIDsource=s; fParticleProbability=prob; fCutPID=kTRUE; InitPIDcuts();
633 }\end{lstlisting}
634 The first argument specifies the particle species that will be selected via the \texttt{EParticleType} enum. The total list of particles as defined in the  \texttt{AliPID} class reads
635 \begin{lstlisting}[language=C, numbers=left]
636   enum EParticleType {
637     kElectron = 0, 
638     kMuon = 1, 
639     kPion = 2, 
640     kKaon = 3, 
641     kProton = 4, 
642
643     kDeuteron = 5,
644     kTriton = 6,
645     kHe3 = 7,
646     kAlpha = 8,
647     
648     kPhoton = 9,
649     kPi0 = 10, 
650     kNeutron = 11, 
651     kKaon0 = 12, 
652     kEleCon = 13,
653     
654     kUnknown = 14
655   };\end{lstlisting}
656   Note that not all these particles may be available for selection via \texttt{AliFlowTrackCuts}!
657   
658   The second argument tells the \texttt{AliFlowTrackCuts} class which particle identification method\index{particle identification!methods} should be used. The available methods are
659   \begin{lstlisting}[language=C, numbers=left]
660     enum PIDsource {
661                    kTPCpid,      // default TPC pid (via GetTPCpid)
662                    kTOFpid,      // default TOF pid (via GetTOFpid)
663                    kTOFbayesian, // TOF bayesian pid (F.Noferini)
664                    kTOFbeta,     // asymmetric cuts of TOF beta signal
665                    kTPCdedx,      // asymmetric cuts of TPC dedx signal
666                    kTOFbetaSimple, //simple TOF only cut
667                    kTPCbayesian, //bayesian cutTPC
668                    kTPCNuclei,   // added by Natasha for Nuclei
669                    kTPCTOFNsigma // simple cut on combined tpc tof nsigma
670                    };\end{lstlisting}
671                    
672 The third argument (with a default value of 0.9) gives the analyzer control over the purity of the particle sample by setting a lower bound on the probability that a particle is of a certain species (where 0 would mean no selection and 1 -theoretically - means a 100\% pure sample). To see how - and if - this parameter is used in a certain identification routine, take a look at the source code.
673                    
674 The best way of understanding how particles are identified is by just browsing the relevant pieces of the code in the \texttt{AliFlowTrackCuts.cxx} file (look at the list of \texttt{Passes$\ast$Cuts()}, but to give a very short overview:
675 \begin{description}
676 \item[kTPCpid] Return particle identity as stored in the \texttt{AliESDtrack}, TPC information only;
677 \item[kTOFpid] Return particle identify as stored in the \texttt{AliESDtrack}, TOF information only;
678 \item[kTOFbayesian] Combined TPC and TOF Bayesian PID method;
679 \item[kTOFbeta] PID based on asymmetric TOF $\beta$ cut;
680 \item[kTPCdedx] PID cut using TPC $\frac{dE}{dx}$ measurements stored in the \texttt{AliESDtrack},
681 \item[kTOFbetaSimple] PID cut based on TOF time stored in the \texttt{AliESDtrack};
682 \item[kTPCbayesian] Bayesian cut based on TPC or TOF signal;
683 \item[kTPCNuclei] PID selection for heavy nuclei;
684 \item[kTPCTOFNsigma]  Cut based in a simple combined cut on the $n$-$\sigma$ signal from TPC and TOF, requires PID response object. The PID response object is created by the PID response task, and thus requires that the PID response task runs in an analysis train \emph{before} the \texttt{AliFlowTrackCuts} class does its selection. To enable the PID response task, add the following lines to your run macro:
685 \begin{lstlisting}[language=C, numbers=left]
686 gROOT->LoadMacro("ANALYSIS/macros/AddTaskPIDResponse.C");
687 AddTaskPIDResponse();\end{lstlisting}
688 The default value for $n$-$\sigma$ is 3, but it can be set to a different 
689 value using
690 \begin{lstlisting}[language=C, numbers=left]
691 void AliFlowTrackCuts::SetNumberOfSigmas(Float_t val);\end{lstlisting}
692 \end{description}
693
694 \subsubsection{Caveats and notes}
695 \index{particle identification!caveats}
696 \begin{description}
697 \item[Applicability of cuts to different data types] Just as not all event and track cuts that are available for all data types. For the track quality cuts this has been explained in the previous subsections, but one has to reqlize that in addition, not all particle identification methods are available for all types of data. At the time of writing, the \texttt{ESD} particle identification is more elaborate than the \texttt{AOD} counterpart. To see which PID methods exist for the different data types, check the \texttt{AliFlowTrackCuts::Passes$\ast$pidCut()} functions,  printed below for your convenience.
698
699 \begin{lstlisting}[language=C, numbers=left]
700 Bool_t AliFlowTrackCuts::PassesAODpidCut(const AliAODTrack* track )
701 {
702      if(!track->GetAODEvent()->GetTOFHeader()){
703           AliAODPid *pidObj = track->GetDetPid();
704           if (!pidObj) fESDpid.GetTOFResponse().SetTimeResolution(84.);
705           else{
706             Double_t sigmaTOFPidInAOD[10];
707             pidObj->GetTOFpidResolution(sigmaTOFPidInAOD);
708             if(sigmaTOFPidInAOD[0] > 84.){
709               fESDpid.GetTOFResponse().SetTimeResolution(sigmaTOFPidInAOD[0]); // use the electron TOF PID sigma as time resolution (including the T0 used)
710           }
711         }
712      }
713
714  //check if passes the selected pid cut for ESDs
715   Bool_t pass = kTRUE;
716   switch (fPIDsource)
717   {
718    case kTOFbeta:
719       if (!PassesTOFbetaCut(track)) pass=kFALSE;
720       break;
721   case kTOFbayesian:
722       if (!PassesTOFbayesianCut(track)) pass=kFALSE;
723       break;
724   case kTPCbayesian:
725       if (!PassesTPCbayesianCut(track)) pass=kFALSE;
726       break;
727   case kTPCTOFNsigma:
728       if (!PassesTPCTOFNsigmaCut(track)) pass = kFALSE;
729       break;
730   default:
731     return kTRUE;
732     break;
733  }
734   return pass;
735
736 }
737 //-----------------------------------------------------------------------
738 Bool_t AliFlowTrackCuts::PassesESDpidCut(const AliESDtrack* track )
739 {
740   //check if passes the selected pid cut for ESDs
741   Bool_t pass = kTRUE; 
742   switch (fPIDsource)    
743   {
744     case kTPCpid:
745       if (!PassesTPCpidCut(track)) pass=kFALSE;
746       break;
747     case kTPCdedx:
748       if (!PassesTPCdedxCut(track)) pass=kFALSE;
749       break;
750     case kTOFpid:
751       if (!PassesTOFpidCut(track)) pass=kFALSE;
752       break;
753     case kTOFbeta:
754       if (!PassesTOFbetaCut(track)) pass=kFALSE;
755       break;
756     case kTOFbetaSimple:
757       if (!PassesTOFbetaSimpleCut(track)) pass=kFALSE;
758       break;
759     case kTPCbayesian:
760       if (!PassesTPCbayesianCut(track)) pass=kFALSE;
761       break;
762     case kTOFbayesian:
763       if (!PassesTOFbayesianCut(track)) pass=kFALSE;
764       break;
765     case kTPCNuclei:
766       if (!PassesNucleiSelection(track)) pass=kFALSE;
767       break;
768     case kTPCTOFNsigma:
769       if (!PassesTPCTOFNsigmaCut(track)) pass = kFALSE;
770       break;
771     default:
772       printf("AliFlowTrackCuts::PassesCuts() this should never be called!\n");
773       pass=kFALSE;
774       break;
775   }
776   return pass;
777 }\end{lstlisting}
778 In general, particle identification is not a trivial procedure, and one needs to find a balance between purity and efficiency. Which particle identification to choose depends heavily on the desired outcome of the analysis. In case of e.g. a high-precision measurement of $\pi$ $v_2$, a method which has a very high purity but low efficiency can be chosen: $\pi$'s are an abundant particle species and high precision requires high purity. On the other hand, if one does selection for kaons to reconstruct $\varphi$-mesons, loose cuts with high efficiency can be chosen, as the $\varphi$-meson is a rare probe and invariant mass requirements on the kaon pairs will take care of mis-identifications. 
779
780 To get access to QA information on track selection \emph{before} and \emph{after} PID cuts, the QA mode of the \texttt{AliFlowTrackCuts} can be selected.
781
782 \item[Track cuts outside of the \texttt{AliAnalysisTaskFlowEvent} class] Just as the flow event cuts can be used outside of the \texttt{AliAnalysisTaskFlowEvent} class, one can use the \texttt{AliFlowTrackCuts} class in a similar way, by calling, for each track,
783 \begin{lstlisting}[language=C, numbers=left]
784 Bool_t AliFlowTrackCuts::IsSelected(TObject* obj, Int_t id)\end{lstlisting}
785 or directly one of the \texttt{PassesCuts($\ast$)} functions which \texttt{IsSelected()} calls. 
786 \end{description}
787
788 \subsubsection{VZERO}\index{track selection!VZERO}\index{VZERO}
789 Now that the barrel tracks have been explained, let's continue to the treatment of VZERO information. The VZERO detector consists of two scintillator arrays at opposite sides of the interaction point (VZEROA and VZEROC) each containing 32 readout channels. To convert the VZERO information to \texttt{AliFlowTrackCuts}, two steps are taken:
790 \begin{enumerate}
791 \item A `track' is built from a VZERO tile by taking the geometric mean of the tile as the track direction (from which $\eta$ and $\varphi$ can be constructed);
792 \item The VZERO analogue signal strength within a VZERO tile (which is proportional to charge deposition) is taken as a weight when evaluating the total \textbf{Q} vector.
793 \end{enumerate}
794 As there is no straightforward way to convert VZERO multiplicity to $p_t$, the VZERO signal can in principle not be used as POI in the flow analysis, neither can a $p_t$ range be selected when using the VZERO as RP selection. In addition to this, the `raw' VZERO signal itself cannot be used directly for flow analysis  but needs to be calibrated tile-by-tile. To understand how this calibration is performed in the flow package, we need to go into a little bit of detail on how to build a \textbf{Q} vector. 
795
796 In general, a \textbf{Q} vector is defined as
797 \begin{equation}\label{qvzero}
798 \mbox{\textbf{Q}} = \sum_{\mbox{tracks}} w_i \exp \left( i n \varphi \right)
799 \end{equation}
800 where $w_i$ is a track weight, $n$ is the harmonic, and $\varphi$ is the azimuthal angle of a track.  As explained, in the case of VZERO tiles, $\varphi$ is derived from the position of the VZERO tile and $w_i$ is the VZERO signal which is proportional to multiplicity. However, not all VZERO tiles are equally sensitive, and the sensitivity (can have) a runnumber dependence, which results in a non-flat VZERO \textbf{Q} vector distribution. As this effect might be different run-by-run, it cannot be corrected by applying a non-uniform acceptance correction at the end of your analysis, as an analysis generally comprises running over multiple runnumers and the non-uniform acceptance correction corrects only for non-uniformity which is equal for all runs. Hence, the VZERO non-uniformity needs to be corrected\index{VZERO!calibration} at the time of the construction of the \textbf{Q} vectors.
801
802 The functions in the flow package which are responsible for building the \textbf{Q} vectors (or sub-event \textbf{Q} vectors, the use of which will be described in subsection \ref{sec:scalar_product}) are
803 \begin{lstlisting}[language=C, numbers=left]
804 // Q-vector  calculation
805 AliFlowVector AliFlowEventSimple::GetQ( 
806     Int_t n,                            // harmonic
807     TList *weightsList,                 // weight list
808     Bool_t usePhiWeights,       // use phi weights?
809     Bool_t usePtWeights,        // use pt weights?
810     Bool_t useEtaWeights        // use eta weights?
811     )
812
813 // Q-vectors of sub-events
814 void AliFlowEventSimple::Get2Qsub( 
815         AliFlowVector* Qarray,  // array with q-vectors
816     Int_t n, 
817     TList *weightsList, 
818     Bool_t usePhiWeights, 
819     Bool_t usePtWeights, 
820     Bool_t useEtaWeights 
821     )
822
823 // overloaded implementation of Q-vectors of sub-events for VZERO information
824 void AliFlowEvent::Get2Qsub(
825         AliFlowVector* Qarray, 
826         Int_t n, 
827         TList *weightsList, 
828         Bool_t usePhiWeights, 
829         Bool_t usePtWeights, 
830         Bool_t useEtaWeights
831         )\end{lstlisting}
832 These functions are called by the flow analysis tasks and generally not by the user directly, but it is good to know where they can be found. The first two functions merely loop over all tracks in a flow event and fill the \textbf{Q} vector. The last function is designed for building a \textbf{Q} vector from VZERO information, applying a calibration step to the VZERO signal. To make life complicated, the calibration of the VZERO \textbf{Q} vector in LHC10h is not the same as the calibration of the VZERO \textbf{Q} vector LHC11h data. Let's start by taking a look at the LHC10h case. 
833 \begin{description}
834     \item [LHC10h]\index{VZERO!calibration!LHC10h}
835 The calibration of LHC10h data is a two-step procedure. 
836 \begin{itemize}
837 \item The first step is evaluating the \textbf{Q} vector using equation \ref{qvzero}. However, the VZERO signal of each tile is \emph{re-weighted} before it is used as a weigth in equation \ref{qvzero}. The re-weighting comprises 
838 \begin{enumerate}
839 \item Taking a \texttt{TProfile} with average multiplicity per cell (these profiles are stored in a \texttt{OADB} file for each run-number)
840 \item Fitting a constant line per disc (or ring) $y = a$ (see next slide for example)
841 \item Evaluating the track weight for each VZERO cell is now calculated in a second iteration as
842 \begin{equation}
843 \mbox{track weight} = \frac{\mbox{cell multiplicity} * a}{\mbox{average multiplicity in a cell}} 
844 \end{equation}
845 \end{enumerate}
846 \item After the \textbf{Q} vectors have been built, they are recentered. Re-centering is basically a small adjustment of the components of the \textbf{Q} vector, changing its angle event-by-event so that on average a flat \textbf{Q} vector distribution is obtained. The steps that are taken for re-centering are the following:
847 \begin{enumerate}
848 \item Retrieve the average mean and spread of the \textbf{Q} vector distribution from a database file;
849 \item The corrected \textbf{Q} vectors can now be obtained by doing
850 \begin{equation}
851 Q_n \longrightarrow \frac{Q_n - \langle Q_n \rangle }{\sigma_{Q_n}} 
852 \end{equation}
853 where brackets denote the one-run average, and $\sigma_{Q_n}$ the standard deviation of $Q_n$ in the sample
854 \end{enumerate}
855 \end{itemize}
856 Note that the calibration is only available for $n=2$ and $n=3$. For higher harmonics, the flow package will use the equalized VZERO multiplicity
857 \begin{lstlisting}[language=C, numbers=left]
858 AliVEvent::GetVZEROEqMultiplicity(Int_t i);\end{lstlisting}
859 to build the \textbf{Q} vectors, whether this is satisfactory for an analysis, or if non-uniform acceptance effects can be reverted by performing a correction on a run-by-run basis is up to the analyzer. The \textbf{Q} vector distributions of total \textbf{Q} vectors and subevent vectors can always be checked via the \texttt{AliFlowCommonHists} classes (see section \ref{sec:commonhists}) via
860 \begin{lstlisting}[language=C, numbers=left]
861   TH1F*     GetHistQ()               {return fHistQ; } ;  
862   TH1F*     GetHistAngleQ()          {return fHistAngleQ; }
863   TH1F*     GetHistAngleQSub0()      {return fHistAngleQSub0; }
864   TH1F*     GetHistAngleQSub1()      {return fHistAngleQSub1; }\end{lstlisting}
865 \item [LHC11h]\index{VZERO!calibration!LHC11h} The calibration of the LHC11h VZERO information is not performed by the flow package, but by an external class, name the VZEROEPselection task, which will store the corrected \textbf{Q} vectors in the AliVEvent header, from which they are retrieved by the \textbf{AliFlowTrackCuts} class. To use this method, make sure that you run this VZEROEPselection task \emph{before} your flow analysis tasks in an analysis train. To enable this task, add the following lines to your analysis macro
866 \begin{lstlisting}[language=C, numbers=left]
867 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskVZEROEPSelection.C");
868 AddTaskVZEROEPSelection();\end{lstlisting}
869 \end{description}
870 Note that for LHC11h data, calibration is performed only for the second harmonic ($n=2$). For higher harmonics, the flow package uses equalized VZERO multiplicity to build \textbf{Q} vectors (as indicated for the LHC10h data). 
871
872 After describing how and why calibration is performed, it is now time to indicate how to set up this calibration routine. Just as selecting barrel tracks, this can be done by creating an \texttt{AliFlowTrackCuts} object via a \texttt{static} access method,
873 \begin{lstlisting}[language=C, numbers=left]
874 AliFlowTrackCuts* cutsVZERO = GetStandardVZEROOnlyTrackCuts();\end{lstlisting}
875 At run-time, the flow package will detector whether LHC10h or LHC11h data is used by reading the analyzed events' runnumber. This can be convenient when having these cuts defined in a script which is designed to run on multiple types of input data. However, one can also call the LHC10h or LHC11h specific cuts directly via dedicated functions, which are reprinted here as the comments are important
876
877 \begin{lstlisting}[language=C, numbers=left]
878 AliFlowTrackCuts* AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts2010()
879 {
880   //get standard VZERO cuts
881   //DISCLAIMER: LHC10h VZERO calibration consists (by default) of two steps
882   //1) re-weigting of signal
883   //2) re-centering of q-vectors
884   //step 2 is available only for n==2 and n==3, for the higher harmonics the user
885   //is repsonsible for making sure the q-sub distributions are (sufficiently) flat
886   //or a sensible NUA procedure is applied !
887   AliFlowTrackCuts* cuts = new AliFlowTrackCuts("standard vzero flow cuts");
888   cuts->SetParamType(AliFlowTrackCuts::kVZERO);
889   cuts->SetEtaRange( -10, +10 );
890   cuts->SetEtaGap(-1., 1.);
891   cuts->SetPhiMin( 0 );
892   cuts->SetPhiMax( TMath::TwoPi() );
893   // options for the reweighting
894   cuts->SetVZEROgainEqualizationPerRing(kFALSE);
895   cuts->SetApplyRecentering(kTRUE);
896   // to exclude a ring , do e.g. 
897   // cuts->SetUseVZERORing(7, kFALSE);
898   // excluding a ring will break the re-centering as re-centering relies on a 
899   // database file which tuned to receiving info from all rings
900   return cuts;
901 }
902 //-----------------------------------------------------------------------
903 AliFlowTrackCuts* AliFlowTrackCuts::GetStandardVZEROOnlyTrackCuts2011()
904 {
905   //get standard VZERO cuts for 2011 data
906   //in this case, the vzero segments will be weighted by
907   //VZEROEqMultiplicity, 
908   //if recentering is enableded, the sub-q vectors
909   //will be taken from the event header, so make sure to run 
910   //the VZERO event plane selection task before this task !
911   //DISCLAIMER: recentering is only available for n==2
912   //for the higher harmonics the user
913   //is repsonsible for making sure the q-sub distributions are (sufficiently) flat
914   //or a sensible NUA procedure is applied !
915   //recentering replaces the already evaluated q-vectors, so 
916   //when chosen, additional settings (e.g. excluding rings) 
917   //have no effect. recentering is true by default
918   //
919   //NOTE user is responsible for running the vzero event plane
920   //selection task in advance, e.g. add to your launcher macro
921   //
922   //  gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskVZEROEPSelection.C");
923   //  AddTaskVZEROEPSelection();
924   //
925   AliFlowTrackCuts* cuts = new AliFlowTrackCuts("standard vzero flow cuts 2011");
926   cuts->SetParamType(kVZERO);
927   cuts->SetEtaRange( -10, +10 );
928   cuts->SetEtaGap(-1., 1.);
929   cuts->SetPhiMin( 0 );
930   cuts->SetPhiMax( TMath::TwoPi() );
931   cuts->SetApplyRecentering(kTRUE);
932   cuts->SetVZEROgainEqualizationPerRing(kFALSE);
933  return cuts;
934 }\end{lstlisting}
935
936 \subsubsection{Caveats and remarks}\index{VZERO!caveats}
937 Using the VZERO as reference detector in a flow analysis certainly has its benefits (such as suppressing the non-flow contribution to the $v_n$ signal) but a few remarks have to be made
938 \begin{description}
939 \item[Applicability to flow analysis methods] As the calibration affects the information that is returned by the function
940 \begin{lstlisting}[language=C, numbers=left]
941 void AliFlowEvent::Get2Qsub()\end{lstlisting}
942 only flow analysis methods which call this function (and thus use sub-events) can use the calibrated VZERO signal. Most notably, this is the scalar product method. In combination with this, one should keep in mind that the two VZERO detectors have different $\eta$ coverage. For the recent \texttt{ALICE} paper on the flow of identified particles, the scalar product method with VZERO subevents was used, where the two VZERO detectors comprised the two sub-events. For more information on this, take a look at the description of the scalar product method in subsection \ref{sec:scalar_product}. 
943 \item[VZERO as RP source] The VZERO signal should only be used as source for reference flow. Although technically there is no objection to using the VZERO signal as POI's (you will probably get output) there is no guarantee that this makes sense from a `physics' viewpoint;
944 \item[Tuning of the calibration] The calibration in the LHC11h data is taken from an external class and therefore, as far as the flow package is considered, as-is (although the calibration can be disabeled). The LHC10h calibration however is done within the package, and can be tuned quite a bit. 
945
946 Tuning the calibration is done by functions of the \texttt{AliFlowTrackCuts} class. Some of these functions apply to both LHC10h and LHC11h data but can have slightly different effects:
947 \begin{lstlisting}[language=C, numbers=left]
948   // to either enable or disable the recentering 
949   // (for 11h this will mean that no calibration is performed,
950   // for 10h it will result in only doing a re-weighting)
951   void SetApplyRecentering(Bool_t r)
952   // to enable a per-ring instead of per-disc gain equalization (=re-weighting)
953   // (for 11h this has no effect)
954   void SetVZEROgainEqualizationPerRing(Bool_t s)   
955   // exclude vzero rings: 0 through 7 can be excluded by calling this setter multiple times
956   // 0 corresponds to segment ID 0 through 7, etc
957   // disabled vzero rings get weight 0
958   // with this function you can omit information from entire vzero rings
959   // might be useful for runs where there is a bad signal in one of the tiles
960   // (sometimes referred to as 'clipping')
961   void SetUseVZERORing(Int_t i, Bool_t u)\end{lstlisting}
962 Be warned however: the databases which are read during the calibration however are tuned to the combination of re-weighting of all rings with re-centering. Changing this combination might lead to biases in the \textbf{Q} vector distribution, so: playing with the calibration settings might be interesting for e.g. evaluating systematic uncertainties, but keep an eye on the control histograms!
963 \end{description}
964
965 \subsubsection{Track weights}\index{track weights}\label{sec:weights}
966 When it is a-priori know that a track sample needs to be weighted in $\varphi$, $\eta$ or $p_t$ (e.g. to correct for a non-uniform acceptance bias in azimuth by using weight which are inversely proportional to the azimuthal track distribution) histograms with weight distributions can be supplied to the flow package. The weights are supplied to flow analysis tasks, which then apply these weights by passing them to the \texttt{Q} vector calculation functions which are printed in the previous subsection. 
967
968 The weights have to be supplied as \texttt{TH1F} objects (or objects which can be dynamically cast to a \texttt{TH1F} encapsulated in \texttt{TList}. The histograms have to have specific names: \texttt{"phi\_weights"} for $\varphi$ weights, \texttt{"pt\_weights"} for $p_t$ weights and \texttt{"eta\_weights"} for $\eta$ weights. The binning of the histograms is not important, as long as bins are of equal width. The weights are disabled by default and have to be passed to specific flow analysis tasks (as not all tasks support weights) via
969 \begin{lstlisting}[language=C, numbers=left]
970 // set weight list
971 AliFlowAnalysisWith*::SetWeightsList(TList* const) 
972 // toggle phi weights on / off
973 AliFlowAnalysisWith*::SetUsePhiWeights(Bool_t const)
974 // toggle eta weighs on / off
975 AliFlowAnalysisWith*::SetUseEtaWeights(Bool_t const)
976 // toggle pt weights on / off
977 AliFlowAnalysisWith*::SetUsePtWeights(Bool_t const)\end{lstlisting}
978 and are applied to total \texttt{Q} vectors and sub-event \texttt{Q} vectors. 
979
980 The tasks which support weights are
981 \begin{itemize}
982 \item AliFlowAnalysisWithNestedLoops
983 \item AliFlowAnalysisWithScalarProduct
984 \item AliFlowAnalysisWithQCumulants
985 \item AliFlowAnalysisTemplate
986 \item AliFlowAnalysisWithFittingQDistribution
987 \item AliFlowAnalysisWithCumulants
988 \item AliFlowAnalysisWithMixedHarmonics
989 \end{itemize}
990 For details on how the weighting is implemented (and defined) the user is referred to the specific \texttt{Q} vector evaluation functions given in the previous subsection.
991
992 \subsubsection{AliFlowCommonConstants - The Common Constants class}\index{AliFlowCommonConstants}
993 All flow analysis use a common output container to store their histograms. To set the configuration for the histograms in these containers - e.g. the $p_t$ ranges of histograms, the number of bins, etc, etc - all flow analysis methods initialize their output containers using variables from a static (global) instance of the \texttt{AliFlowCommonConstants}\index{AliFlowCommonConstants} class. This object, which can be obtained via the a static function
994 \begin{lstlisting}[language=C, numbers=left]
995 static AliFlowCommonConstants* GetMaster(); \end{lstlisting} 
996 can be tuned to the  user's liking by requesting a pointer to it via the static access method, and using the available setter functions, e.g. the following
997 \begin{lstlisting}[language=C, numbers=left]
998 AliFlowCommonConstants* cc = AliFlowCommonConstants::GetMaster();
999 cc->SetNbinsPt(100);
1000 cc->SetPtMin(0);
1001 cc->SetPtMax(10); \end{lstlisting}
1002 will result in an analysis which is performed in 100 $p_t$ bins of 0.1 GeV/$c$ width. The full set of histogram sizes and limits that can be set is
1003
1004 \begin{lstlisting}[language=C, numbers=left]
1005  //histogram sizes
1006   Int_t  fNbinsMult; // histogram size
1007   Int_t  fNbinsPt;   // histogram size
1008   Int_t  fNbinsPhi;  // histogram size
1009   Int_t  fNbinsEta;  // histogram size
1010   Int_t  fNbinsQ;    // histogram size
1011   Int_t  fNbinsMass; // histogram size
1012  
1013   // Histograms limits
1014   Double_t  fMultMin;  // histogram limit 
1015   Double_t  fMultMax;  // histogram limit
1016   Double_t  fPtMin;    // histogram limit
1017   Double_t  fPtMax;    // histogram limit
1018   Double_t  fPhiMin;     // histogram limit
1019   Double_t  fPhiMax;   // histogram limit
1020   Double_t  fEtaMin;     // histogram limit
1021   Double_t  fEtaMax;     // histogram limit
1022   Double_t  fQMin;         // histogram limit
1023   Double_t  fQMax;     // histogram limit
1024   Double_t  fMassMin;  // histogram limit 
1025   Double_t  fMassMax;  // histogram limit
1026   Double_t  fHistWeightvsPhiMin; // histogram limit
1027   Double_t  fHistWeightvsPhiMax; // histogram limit\end{lstlisting}
1028   
1029   via the setters
1030   
1031   \begin{lstlisting}[language=C, numbers=left]
1032     void SetNbinsMult( Int_t i ) { fNbinsMult = i; }
1033   void SetNbinsPt( Int_t i )   { fNbinsPt = i; }
1034   void SetNbinsPhi( Int_t i )  { fNbinsPhi = i; }
1035   void SetNbinsEta( Int_t i )  { fNbinsEta = i; }
1036   void SetNbinsQ( Int_t i )    { fNbinsQ = i; }
1037   void SetNbinsMass( Int_t i ) { fNbinsMass = i; }
1038   void SetMultMin( Double_t i ) { fMultMin = i; }
1039   void SetMultMax( Double_t i ) { fMultMax = i; }
1040   void SetPtMin( Double_t i )   { fPtMin = i; }
1041   void SetPtMax( Double_t i )   { fPtMax = i; }
1042   void SetPhiMin( Double_t i )  { fPhiMin = i; }
1043   void SetPhiMax( Double_t i )  { fPhiMax = i; }
1044   void SetEtaMin( Double_t i )  { fEtaMin = i; }
1045   void SetEtaMax( Double_t i )  { fEtaMax = i; }
1046   void SetQMin( Double_t i )    { fQMin = i; }
1047   void SetQMax( Double_t i )    { fQMax = i; }
1048   void SetMassMin( Double_t i )    { fMassMin = i; }
1049   void SetMassMax( Double_t i )    { fMassMax = i; }
1050   void SetHistWeightvsPhiMax( Double_t d ) {fHistWeightvsPhiMax=d;}
1051   void SetHistWeightvsPhiMin( Double_t d ) {fHistWeightvsPhiMin=d;}\end{lstlisting} 
1052
1053 Note that the common constants object is \texttt{static}, meaning that, within a process (e.g. an analysis train) just \emph{one} instance of the object is created. The histogram limits and sizes that are set via the common constants object therefore affect \emph{all} histograms within an analysis chain.
1054
1055 \subsubsection{AliFlowCommonHist and AliFlowCommonHistResults - details}\index{AliFlowCommonHist!details}\index{AliFlowCommonHistResults!details}
1056 Both the \texttt{AliFlowCommonHist} and \texttt{AliFlowCommonHistResults} classes do not only contain (pointers to) histograms and profiles, but also have a collection of `getters'\footnote{A `getter' in this manual will be used to describe a function of the form \texttt{Get$\ast$()} which returns a (pointer to) a member of a class and is used to interface with the class.} which you can use to retrieve histograms of profiles using the \texttt{ROOT} command line in stead of the \texttt{TBrowser}, which may come in handy when one needs to read the output of the flow analysis tasks in a macro. 
1057
1058 Using the output file that was generated in the example given in the previous sections of this chapter, reading the objects of the common histogram classes is done in the following way. First, start an \texttt{(Ali)ROOT} session, and load the prerequisite libraries,
1059 \begin{lstlisting}[language=C, numbers=left]
1060 gSystem->Load("libPWGflowBase");\end{lstlisting}
1061 Then, open the analysis file and grab the common histogram objects
1062 \begin{lstlisting}[language=C, numbers=left]
1063 // open the file
1064 TFile f("AnalysisResults.root");
1065 // get the qc analysis output directory
1066 TDirectoryFile* dir = (TDirectoryFile*)f.Get("outputQCanalysis");
1067 // and retrieve the output list of the analysis
1068 TList* outputList = (TList*)dir->Get("cobjQC")\end{lstlisting}
1069 The \texttt{TList} that you have just obtained holds not only the common histogram objects, but can also hold additional information that has been added to the analysis output by a specific flow analysis task. To read the entire content of the \texttt{TList}, you can type
1070 \begin{lstlisting}[language=C, numbers=left]
1071 outputList->ls();\end{lstlisting}
1072 However, in this example we want to retrieve the common histogram objects. To do so, type
1073 \begin{lstlisting}[language=C, numbers=left]
1074 // get common histogram object from the TList
1075 AliFlowCommonHist* commonHist = (AliFlowCommonHist*)outputList->FindObject("AliFlowCommonHistQC");
1076 // get the results for the 2 particle cumulant from the TList
1077 AliFlowCommonHistResults* commonHistResults2 = (AliFlowCommonHistResults*)outputList->FindObject("AliFlowCommonHistResults2ndOrderQC");\end{lstlisting}
1078 Once you have retrieved the pointers to the \texttt{AliFlowCommonHist} or \texttt{AliFlowCommonHistResults} objects, you can use the getters to retrieve a histogram. To e.g. draw the $\eta$ distribution of POI's, type
1079 \begin{lstlisting}[language=C, numbers=left]
1080  commonHist->GetHistEtaPOI()->Draw();\end{lstlisting}
1081  
1082  The following getters are available in \texttt{AliFlowCommonHist}
1083  \begin{lstlisting}[language=C, numbers=left]
1084   Double_t GetEntriesInPtBinRP(Int_t iBin);   //gets entries from fHistPtRP
1085   Double_t GetEntriesInPtBinPOI(Int_t iBin);  //gets entries from fHistPtPOI
1086   Double_t GetEntriesInEtaBinRP(Int_t iBin);  //gets entries from fHistEtaRP
1087   Double_t GetEntriesInEtaBinPOI(Int_t iBin); //gets entries from fHistEtaPOI
1088   Double_t GetMeanPt(Int_t iBin);             //gets the mean pt for this bin from fHistProMeanPtperBin   
1089   TH1F*     GetHistMultRP()          {return fHistMultRP; } ;  
1090   TH1F*     GetHistMultPOI()         {return fHistMultPOI; } ; 
1091   TH2F*     GetHistMultPOIvsRP()     {return fHistMultPOIvsRP; } ;
1092   TH1F*     GetHistPtRP()            {return fHistPtRP; } ;  
1093   TH1F*     GetHistPtPOI()           {return fHistPtPOI; } ;
1094   TH1F*     GetHistPtSub0()          {return fHistPtSub0; } ;
1095   TH1F*     GetHistPtSub1()          {return fHistPtSub1; } ;
1096   TH1F*     GetHistPhiRP()           {return fHistPhiRP; } ;  
1097   TH1F*     GetHistPhiPOI()          {return fHistPhiPOI; } ;  
1098   TH1F*     GetHistPhiSub0()         {return fHistPhiSub0; } ; 
1099   TH1F*     GetHistPhiSub1()         {return fHistPhiSub1; } ; 
1100   TH1F*     GetHistEtaRP()           {return fHistEtaRP; } ;  
1101   TH1F*     GetHistEtaPOI()          {return fHistEtaPOI;  } ;  
1102   TH1F*     GetHistEtaSub0()         {return fHistEtaSub0;  } ; 
1103   TH1F*     GetHistEtaSub1()         {return fHistEtaSub1;  } ; 
1104   TH2F*     GetHistPhiEtaRP()        {return fHistPhiEtaRP;  } ; 
1105   TH2F*     GetHistPhiEtaPOI()       {return fHistPhiEtaPOI;  } ; 
1106   TProfile* GetHistProMeanPtperBin() {return fHistProMeanPtperBin; } ;
1107   TH2F*     GetHistWeightvsPhi()     {return fHistWeightvsPhi; } ;
1108   TH1F*     GetHistQ()               {return fHistQ; } ;  
1109   TH1F*     GetHistAngleQ()          {return fHistAngleQ; }
1110   TH1F*     GetHistAngleQSub0()      {return fHistAngleQSub0; }
1111   TH1F*     GetHistAngleQSub1()      {return fHistAngleQSub1; }
1112   TProfile* GetHarmonic()            {return fHarmonic; } ; 
1113   TProfile* GetRefMultVsNoOfRPs()    {return fRefMultVsNoOfRPs; } ;
1114   TH1F*     GetHistRefMult()         {return fHistRefMult; } ; 
1115   TH2F*     GetHistMassPOI()         {return fHistMassPOI; }
1116   TList*    GetHistList()            {return fHistList;} ;  \end{lstlisting}
1117   and in \texttt{AliFlowCommonHistResults}
1118   \begin{lstlisting}[language=C, numbers=left]
1119   TH1D* GetHistChi(){return fHistChi;};
1120   TH1D* GetHistIntFlow(){return fHistIntFlow;};    
1121   TH1D* GetHistIntFlowRP(){return fHistIntFlowRP;}; 
1122   TH1D* GetHistDiffFlowPtRP(){return fHistDiffFlowPtRP;}; 
1123   TH1D* GetHistDiffFlowEtaRP(){return fHistDiffFlowEtaRP;}; 
1124   TH1D* GetHistIntFlowPOI(){return fHistIntFlowPOI;};
1125   TH1D* GetHistDiffFlowPtPOI(){return fHistDiffFlowPtPOI;}; 
1126   TH1D* GetHistDiffFlowEtaPOI(){return fHistDiffFlowEtaPOI;}; 
1127   TList* GetHistList(){return fHistList;};  \end{lstlisting}
1128  
1129   \subsubsection{Afterburner}\index{afterburner}
1130 To e.g. test your analysis setup, an `afterburner' can be called which adds  user-defined flow to (isotropic) events. Two afterburner techniques are implemented.
1131 \begin{description}
1132 \item[Differential $v_2$] The first technique injects differential $v_2$ into events, using the following steps: As a starting point, an isotropic distribution of tracks is used
1133 \begin{equation}
1134     \frac{dN}{d\varphi_0} = \frac{1}{2 \pi}.
1135 \end{equation}
1136 Adding a periodic azimuthal modulation, this is translated to
1137 \begin{equation}
1138     \frac{dN}{d\varphi} = \frac{1}{2\pi}\left( 1 + v_2 \cos \left[ 2 \left( \varphi - \Psi \right) \right] \right)
1139 \end{equation}
1140 which can be re-written as
1141 \begin{equation}
1142     \frac{dN}{d\varphi} = \frac{dN}{d\varphi_0}\frac{d\varphi_0}{d\varphi} = \frac{1}{2\pi}\frac{d\varphi_0}{d\varphi}
1143 \end{equation}
1144 so that for each track the following equation can be solved by Newton-Raphson iteration
1145 \begin{equation}
1146     \varphi = \varphi_0 - v_2 \sin \left[ 2 \left( \varphi - \Psi \right) \right].
1147 \end{equation}
1148 \item[Integrated $v_n$] The second option is adding integrated $v_n$ by sampling the azimuthal distribution of an event from a Fourier series
1149 \begin{equation}
1150 \frac{dN}{d\varphi} \propto 1 + \frac{1}{2} \sum_n v_n \left( n \Delta \varphi \right).
1151 \end{equation}
1152 \end{description}
1153 In the `quick start' of this manual you have already see how you can generate flow events with a certain $v_n$ value by generating flow events by hand. The afterburner routine can also be called from the \texttt{AliAnalysisTaskFlowEvent} via the functions
1154 \begin{lstlisting}[language=C, numbers=left]
1155  // setters for adding by hand flow values (afterburner)
1156  
1157  // toggle the afterburner on / off
1158   void SetAfterburnerOn(Bool_t b=kTRUE) {fAfterburnerOn=b;}
1159  // set differential v2 via a TF1  
1160   void SetPtDifferentialV2( TF1 *gPtV2) {fDifferentialV2 = gPtV2;}
1161   // set integrated flow (used when the gPtV2 = NULL)
1162   void SetFlow( Double_t v1, Double_t v2, Double_t v3=0.0, Double_t v4=0.0, Double_t v5=0.0)
1163                {fV1=v1;fV2=v2;fV3=v3;fV4=v4;fV5=v5;}\end{lstlisting}
1164 To introduce non-flow effects to using the afterburner, tracks can be cloned. To clone, for each event, a given number $n$ of tracks, enable the afterburner and call
1165 \begin{lstlisting}[language=C, numbers=left]
1166   void SetNonFlowNumberOfTrackClones(Int_t n) {fNonFlowNumberOfTrackClones=n;}\end{lstlisting}
1167 Effectively this will result in $n$ tracks appearing twice in the track sample, mimicking the effects of e.g. resonance decays of track splitting on $v_n$.
1168
1169 \subsection{Relevant pieces of code}
1170 The best way of getting familiar with the flwo package is perhaps browsing the source code, but it can be difficult to find a good starting point for this. Two relevant pieces of code have been selected here which are at the heart of the flow package: 
1171 \begin{enumerate}\index{AliAnalysisTaskFlowEvent::UserExec()}
1172 \item The AliAnalysisTaskFlowEvent::UserExec() function, which is called for each event that enters an analysis train;
1173 \item AliFlowEvent::Fill(), which selects POI's and RP's following the track selection criteria and fills the flow event which is passed to the analysis methods. The functions are shortened and simplified and provided with additional lines of comments.
1174 \end{enumerate}
1175 \subsubsection{AliAnalysisTaskFlowEvent::UserExec()}
1176 This function is called for each event. 
1177 \begin{lstlisting}[language=C, numbers=left]
1178 void AliAnalysisTaskFlowEvent::UserExec(Option_t *)
1179 {
1180   // Main loop
1181   // Called for each event
1182   //delete fFlowEvent;
1183   AliMCEvent*  mcEvent = MCEvent();                              // from TaskSE
1184   AliESDEvent* myESD = dynamic_cast<AliESDEvent*>(InputEvent()); // from TaskSE
1185   AliAODEvent* myAOD = dynamic_cast<AliAODEvent*>(InputEvent()); // from TaskSE
1186
1187   // the rp and poi cuts will be used to fill the flow event
1188   // so they have to be defined here
1189   if (!(fCutsRP&&fCutsPOI&&fCutsEvent))
1190   {
1191     AliError("cuts not set");
1192     return;
1193   }
1194
1195   //DEFAULT - automatically takes care of everything
1196   // the flow package will determine the datatype that you are using
1197   if (fAnalysisType == "AUTOMATIC")
1198   {
1199     //check event cuts
1200     if (InputEvent() && !fCutsEvent->IsSelected(InputEvent(),MCEvent())) 
1201       return;
1202
1203     //first attach all possible information to the cuts
1204     // the track cuts will make the track selection, so they
1205     // have to be supplied with the current event
1206     // the mc event is NULL unless it is retrieved by AliAnalysisTaskSE   
1207     fCutsRP->SetEvent( InputEvent(), MCEvent() );  //attach event
1208     fCutsPOI->SetEvent( InputEvent(), MCEvent() );
1209
1210     //then make the event
1211     // this function will fill the flow event with selected poi's and rp's
1212     // the implementation is printed below
1213     fFlowEvent->Fill( fCutsRP, fCutsPOI );
1214
1215     // pass some event info to the flow event
1216     fFlowEvent->SetReferenceMultiplicity(fCutsEvent->GetReferenceMultiplicity(InputEvent(),mcEvent));
1217     fFlowEvent->SetCentrality(fCutsEvent->GetCentrality(InputEvent(),mcEvent));
1218     if (mcEvent && mcEvent->GenEventHeader()) fFlowEvent->SetMCReactionPlaneAngle(mcEvent);
1219   }
1220
1221   // a lot of code is omitted here //
1222
1223   //////////////////////////////////////////////////////////////////////////////
1224   ///////////////////////////AFTERBURNER
1225   if (fAfterburnerOn)
1226   {
1227     //if reaction plane not set from elsewhere randomize it before adding flow
1228     if (!fFlowEvent->IsSetMCReactionPlaneAngle())
1229       fFlowEvent->SetMCReactionPlaneAngle(gRandom->Uniform(0.0,TMath::TwoPi()));
1230
1231     if(fDifferentialV2)
1232       fFlowEvent->AddV2(fDifferentialV2);
1233     else 
1234       fFlowEvent->AddFlow(fV1,fV2,fV3,fV4,fV5);     //add flow
1235     fFlowEvent->CloneTracks(fNonFlowNumberOfTrackClones); //add nonflow by cloning tracks
1236   }
1237   //////////////////////////////////////////////////////////////////////////////
1238
1239   //tag subEvents
1240   // some flow analysis methods (such as the scalar product) 
1241   // use sub-events. by calling this function, all tracks in the 
1242   // flow event are tagged as belonging to either sub-event a or b
1243   fFlowEvent->TagSubeventsInEta(fMinA,fMaxA,fMinB,fMaxB);\end{lstlisting}
1244
1245   \subsubsection{AliFlowEvent::Fill()}\label{sec:fill}\index{AliFlowEvent::Fill()}
1246   This function fills the flow event with \texttt{AliFlowSimpleTracks}. One important thing to notice here, is that both POI's and RP's are stored in a common array of flow tracks, internally only referred to as POI's. What distinguishes the POI's and RP's is their \emph{type}: RP's are stored as type 0 POI's, and POI's are stored as non-zero type POI's (where nonzero means 1, 2, 3 ...).
1247 \begin{lstlisting}[language=C, numbers=left]
1248 //-----------------------------------------------------------------------
1249 void AliFlowEvent::Fill( AliFlowTrackCuts* rpCuts,
1250                          AliFlowTrackCuts* poiCuts )
1251 {
1252   //Fills the event from a vevent: AliESDEvent,AliAODEvent,AliMCEvent
1253   //the input data needs to be attached to the cuts
1254   //we have two cases, if we're cutting the same collection of tracks
1255   //(same param type) then we can have tracks that are both rp and poi
1256   //in the other case we want to have two exclusive sets of rps and pois
1257   //e.g. one tracklets, the other PMD or global - USER IS RESPOSIBLE
1258   //FOR MAKING SURE THEY DONT OVERLAP OR ELSE THE SAME PARTICLE WILL BE
1259   //TAKEN TWICE
1260
1261   // remove the previous event
1262   ClearFast();
1263   if (!rpCuts || !poiCuts) return;
1264   // check the source of rp's
1265   AliFlowTrackCuts::trackParameterType sourceRP = rpCuts->GetParamType();
1266   // and ditto for the poi's
1267   AliFlowTrackCuts::trackParameterType sourcePOI = poiCuts->GetParamType();
1268   
1269   AliFlowTrack* pTrack=NULL;
1270  
1271   // if the source for rp's or poi's is the VZERO detector, get the calibration 
1272   // and set the calibration parameters
1273   if (sourceRP == AliFlowTrackCuts::kVZERO) {
1274       SetVZEROCalibrationForTrackCuts(rpCuts);
1275       if(!rpCuts->GetApplyRecentering()) {
1276           // if the user does not want to recenter, switch the flag
1277           fApplyRecentering = -1;
1278       }
1279       // note: this flag is used in the overloaded implementation of Get2Qsub()
1280       // and tells the function to use as Qsub vectors the recentered Q-vectors
1281       // from the VZERO oadb file or from the event header
1282   }
1283   if (sourcePOI == AliFlowTrackCuts::kVZERO) {
1284       // probably no-one will choose vzero tracks as poi's ...
1285       SetVZEROCalibrationForTrackCuts(poiCuts); 
1286   }
1287   
1288
1289   if (sourceRP==sourcePOI)
1290   {
1291     //loop over tracks
1292     Int_t numberOfInputObjects = rpCuts->GetNumberOfInputObjects();
1293     for (Int_t i=0; i<numberOfInputObjects; i++)
1294     {
1295       //get input object (particle)
1296       TObject* particle = rpCuts->GetInputObject(i);
1297
1298       Bool_t rp = rpCuts->IsSelected(particle,i);
1299       Bool_t poi = poiCuts->IsSelected(particle,i);
1300
1301       if (!(rp||poi)) continue;
1302
1303       //make new AliFlowTrack
1304       if (rp)
1305       {
1306         pTrack = rpCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
1307         if (!pTrack) continue;
1308         pTrack->Tag(0); IncrementNumberOfPOIs(0);
1309         if (poi) {pTrack->Tag(1); IncrementNumberOfPOIs(1);}
1310         if (pTrack->GetNDaughters()>0) fMothersCollection->Add(pTrack);
1311       }
1312       else if (poi)
1313       {
1314         pTrack = poiCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
1315         if (!pTrack) continue;
1316         pTrack->Tag(1); IncrementNumberOfPOIs(1);
1317         if (pTrack->GetNDaughters()>0) fMothersCollection->Add(pTrack);
1318       }
1319       fNumberOfTracks++;
1320     }//end of while (i < numberOfTracks)
1321   }
1322   else if (sourceRP!=sourcePOI)
1323   {
1324     //here we have two different sources of particles, so we fill
1325     //them independently
1326     //POI
1327     for (Int_t i=0; i<poiCuts->GetNumberOfInputObjects(); i++)
1328     {
1329       TObject* particle = poiCuts->GetInputObject(i);
1330       Bool_t poi = poiCuts->IsSelected(particle,i);
1331       if (!poi) continue;
1332       pTrack = poiCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
1333       if (!pTrack) continue;
1334       pTrack->Tag(1);
1335       IncrementNumberOfPOIs(1);
1336       fNumberOfTracks++;
1337       if (pTrack->GetNDaughters()>0) fMothersCollection->Add(pTrack);
1338     }
1339     //RP
1340     Int_t numberOfInputObjects = rpCuts->GetNumberOfInputObjects();
1341     for (Int_t i=0; i<numberOfInputObjects; i++)
1342       {
1343       TObject* particle = rpCuts->GetInputObject(i);
1344       Bool_t rp = rpCuts->IsSelected(particle,i);
1345       if (!rp) continue;
1346       pTrack = rpCuts->FillFlowTrack(fTrackCollection,fNumberOfTracks);
1347       if (!pTrack) continue;
1348       pTrack->Tag(0);
1349       IncrementNumberOfPOIs(0);
1350       fNumberOfTracks++;
1351       if (pTrack->GetNDaughters()>0) fMothersCollection->Add(pTrack);
1352     }
1353   }
1354 }\end{lstlisting}
1355
1356 \section{The flow package in the ALICE analysis framework}
1357 Many of the classes which are described in the previous section deal with \texttt{ALICE} data (e.g. event and track selection). Generally, this data is analyzed in \texttt{ALICE} analysis framework. This framework is setup in the following way
1358 \begin{enumerate}
1359 \item An analysis manager \texttt{analysis manager} is created; 
1360 \item The manager is connected to a source of input data (this can be data that is stored on your local machine, but more often data comes in the form of \texttt{.xml}\index{xml} files which point to data on \texttt{GRID} storage elements);
1361 \item A number of analysis tasks is initialized, configured, and added to the analysis manager (so that you construct an `analysis train')\index{analysis train};
1362 \item The analysis is performed, which in effect means that the manager reads an event, passes it to the analysis tasks (who analyze it sequentially), and repeats this until all events are read. In this way, an event can be analyzed by many tasks whilst reading it from file just once;
1363 \item The analysis outputs are gathered by the manager and written to an output file.
1364 \end{enumerate}
1365 In this case of the flow package, the most common way of using this framework is 
1366 \begin{itemize}
1367 \item Creating flow events using the dedicated flow event task \texttt{AliAnalysisTaskFlowEvent};
1368 \item Analyzing these events using the \texttt{AliROOT} interface to the generic flow analysis tasks. 
1369 \end{itemize}
1370
1371 \subsection{AliAnalysisTaskSE}
1372 All analysis tasks that are called by the analysis manager have to be derived from a common class, the \texttt{AliAnalysisTaskSE}\footnote{This section is very brief an incomplete, but keep in mind that this is a flow package manual, and not an \texttt{AliROOT} tutorial.} (where the suffix `SE' stands for `single event'). \texttt{AliAnalysisTaskSE} has a few virtual functions which can be called in user tasks by the analysis manager at specific times. Most notably these are
1373 \begin{description}
1374 \item[UserCreateOutputObjects] \index{UserCreateOutputObjects}This function is called \emph{before} the analysis starts;
1375 \item[UserExec] \index{UserExec}This function is called for each event;
1376 \item[Terminate] \index{Terminate}Called at the end of the analysis (after the last event has been processed).
1377 \end{description}
1378 So, why is this important for the flow package? As said, the analysis manager can only handle tasks that derive from \texttt{AliAnalysisTaskSE}. Therefore, all flow analysis in the flow package consist of \emph{two} classes:
1379 \begin{description}
1380 \item[AliAnalysisTask$\ast$] These can be found in the `tasks' directory of the flow package and are derived of \texttt{AliAnalysisTaskSE}. These classes interface with \texttt{AliROOT};
1381 \item[AliFlowAnalysisWith$\ast$] These can be found in the `base' folder of the flow package and perform the actual flow analysis.
1382 \end{description}
1383 In chapter \ref{sec:onthefly} of this manual, you have seen that, using just the \texttt{AliFlowAnalysisWith$\ast$} class, a flow analysis basically follows the path
1384 \begin{enumerate}
1385 \item \texttt{Init()}: called once to initialize the task and histograms;
1386 \item \texttt{Make()}: called for each event, does the analysis;
1387 \item \texttt{Finish()}: wrap up the analysis.
1388 \end{enumerate}
1389 When doing the analysis in the analysis framework, you will not use the \texttt{AliFlowAnalysisWith$\ast$} class, but instead use the \texttt{AliAnalysisTask$\ast$} which calls the \texttt{AliFlowAnalysisWith$\ast$} class for you via the calls from \texttt{AliAnalysisTaskSE}. To be more specific:
1390 \begin{enumerate}
1391 \item \texttt{Init()} is called in \texttt{UserCreateOutputObjects()};
1392 \item \texttt{Make()} is called in \texttt{UserExec()};
1393 \item \texttt{Finish()} is called in \texttt{Terminate()}.
1394 \end{enumerate}
1395 All of this may still seem a bit abstract at this point, but in principle you now know all you need to know about the structure of the flow package. It is recommended however that you take a look at the example in \ref{sec:example}, to get a step-by-step explanation of how these things work in the real world.
1396
1397 \subsubsection{Analysys on grid: redoFinish.C}
1398 As explained in \ref{sec:onthefly} and in the previoius subsection, a flow analysis is finished by a call to \texttt{Finish()}. Although the exact implementation of \texttt{Finish()} is different for each flow analysis method, the general principle method in most methods is that calculations on event-averaged values are performed to end up with a final value for an observable. 
1399
1400 \index{redoFinish.C} When an analysis is run in parallel on many nodes (e.g. when running on \texttt{GRID}\index{GRID}) the output of the flow analysis tasks in \texttt{AnalysisResults.root} is typically wrong, as merging files via \texttt{ROOT's} \texttt{TFileMerger}\index{TFileMerger} will trivially sum up results in all histograms. 
1401
1402 The \texttt{redoFinish.C}\footnote{\texttt{\$ALICE\_ROOT/PWGCF/FLOW/macros/refoFinish.C}} macro re-evaluates all output that cannot trivially be merged and re-calls the \texttt{Finish()} method. To use \texttt{redoFinish.C}, make sure your analysis output file is called \texttt{mergedAnalysisResults.root} and simply run the macro
1403 \begin{lstlisting}[language=C, numbers=left]
1404 .L redoFinish.C
1405 redoFinish(); \end{lstlisting}
1406 \texttt{redoFinish.C} will produce a new \texttt{AnalysisResults.root} file with the corrected results by calling the \texttt{::Finish()}\index{Finish()} function on all known output structures in the \texttt{mergedAnalysisResults.root}\index{mergedAnalysisResults} file. Additionally \texttt{redoFinish.C} can be used to repeat the call to \texttt{::Finish()} with different settings, which might alter the outcome of the flow analysis (e.g. use a different strategy to correct for non-uniform acceptance). 
1407
1408 The macro itself is well documented and lists several options that are available at the time of running:
1409 \begin{lstlisting}[language = C, numbers=left]
1410 // Macro redoFinish.C is typically used after the merging macros (mergeOutput.C or
1411 // mergeOutputOnGrid.C) have been used to produce the merged, large statistics
1412 // file of flow analysis. Results stored in merged file are WRONG because after
1413 // merging the results from small statistics files are trivially summed up in all
1414 // histograms. This is taken into account and corrected for with macro redoFinish.C.
1415 // Another typical use of the macro redoFinish.C is to repeat the call to Finish()
1416 // in all classes, but with different values of some settings which might modify
1417 // the final results (Example: redo the Finish() and apply correction for detector
1418 // effects in QC code because by default this correction is switched off).
1419
1420 // Name of the merged, large statistics file obtained with the merging macros:
1421 TString mergedFileName = "mergedAnalysisResults.root";
1422 // Final output file name holding correct final results for large statistics sample:
1423 TString outputFileName = "AnalysisResults.root";
1424
1425 Bool_t bApplyCorrectionForNUA = kFALSE; // apply correction for non-uniform acceptance
1426 Bool_t bApplyCorrectionForNUAVsM = kFALSE; // apply correction for non-uniform acceptance in each multiplicity bin independently
1427 Bool_t bPropagateErrorAlsoFromNIT = kFALSE; // propagate error also from non-isotropic terms
1428 Bool_t bMinimumBiasReferenceFlow = kTRUE; // store in CRH for reference flow the result obtained wihout rebinning in multiplicity (kTRUE)
1429 Bool_t checkForCommonHistResults = kTRUE; // check explicitely if the TList AliFlowCommonHistResults is available in the output\end{lstlisting}
1430
1431 Flow analysis output is recognized by keywords in output list names (e.g. a Q-cumulant output needs to have the letters `QC' somewhere in the name to be recognized). 
1432
1433 When your analysis output is in the form of a merged file, \emph{always} run \texttt{redoFinish.C} to get your results!
1434
1435 \subsection{Example: $\pi^{\pm}$ $v_n$}\label{sec:example}\index{example}
1436 As an example of how to do a flow analysis using the flow package within the \texttt{AliROOT} analysis framework\index{analysis framework}, this section will guide you through the process of measuring $\pi^{\pm}$ $v_2$, $v_3$ and $v_4$ step-by-step, using the Q-vector cumulant flow analysis method. 
1437
1438 Generally, doing an analysis in the \texttt{AliROOT} is a `two-file process', where one runs a run.C\index{run.C}\index{steering macro} script in \texttt{AliROOT} (coloquially referred to as `steering macro'), which sets up the analysis framework and takes care of the interface to the analysis \texttt{GRID}, and calls an \texttt{AddTask$\ast$.C}\index{AddTask macro} macro which in turn creates and configures instances of the relevant analysis tasks. In this example, the distinction will not be so clear, but mentioned in the text. In practice of course, you would copy these steps into macros and launch the macros from the \texttt{AliROOT} command line when doing analysis. We will not run this test on \texttt{GRID}, but assume that you have some \texttt{AliAOD.root} files available on your local system. Note that this example is a guideline, there are many ways leading to Rome, and many ways of setting up an analysis. Some of the variables that are set in the code examples below are actually also set by default. This may seem a little bit redundant, but it is done to make the reader aware of the fact that they exist. 
1439
1440 A script which contains all the steps described below and should work `out-of-the-box' can be found at \texttt{\$ALICE\_ROOT/PWGCF/FLOW/Documentation/examples/manual/runFlowOnDataExample.C}.
1441 \begin{description}
1442 \item [Preparing the session] First, we need to prepare the framework and root session (these steps would go into your run.C macro). Launch \texttt{AliROOT} and load the necessary libraries
1443 \begin{lstlisting}[language=C, numbers=left]
1444   // load libraries
1445   gSystem->Load("libCore.so");        
1446   gSystem->Load("libGeom.so");
1447   gSystem->Load("libVMC.so");
1448   gSystem->Load("libPhysics.so");
1449   gSystem->Load("libTree.so");
1450   gSystem->Load("libSTEERBase.so");
1451   gSystem->Load("libESD.so");
1452   gSystem->Load("libAOD.so");
1453   gSystem->Load("libANALYSIS.so");
1454   gSystem->Load("libANALYSISalice.so");
1455   gSystem->Load("libEventMixing.so");
1456   gSystem->Load("libCORRFW.so");
1457   gSystem->Load("libPWGTools.so");
1458   gSystem->Load("libPWGCFebye.so");
1459   gSystem->Load("libPWGflowBase.so");
1460   gSystem->Load("libPWGflowTasks.so"); \end{lstlisting}
1461   \item [Creating the manager and connecting input data]
1462       Create an analysis manager\index{analysis manager}\index{AliAnalysisManager} and create a \texttt{TChain}\index{TChain} which we will point to the data you have stored locally on your machine
1463 \begin{lstlisting}[language=C, numbers=left]
1464   // create the analysis manager
1465   AliAnalysisManager* mgr = new AliAnalysisManager("MyManager");
1466   // create a tchain which will point to an aod tree
1467   TChain* chain = new TChain("aodTree");
1468   // add a few files to the chain
1469   chain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/data/2010/LHC10h/000139510/ESDs/pass2/AOD086/0003/AliAOD.root");
1470   chain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/data/2010/LHC10h/000139510/ESDs/pass2/AOD086/0003/AliAOD.root");
1471   chain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/data/2010/LHC10h/000139510/ESDs/pass2/AOD086/0004/AliAOD.root");
1472   chain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/data/2010/LHC10h/000139510/ESDs/pass2/AOD086/0005/AliAOD.root");
1473   chain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/data/2010/LHC10h/000139510/ESDs/pass2/AOD086/0006/AliAOD.root");
1474   chain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/data/2010/LHC10h/000139510/ESDs/pass2/AOD086/0007/AliAOD.root");
1475   chain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/data/2010/LHC10h/000139510/ESDs/pass2/AOD086/0008/AliAOD.root");
1476   chain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/data/2010/LHC10h/000139510/ESDs/pass2/AOD086/0009/AliAOD.root");
1477   chain->Add("/home/rbertens/Documents/CERN/ALICE_DATA/data/2010/LHC10h/000139510/ESDs/pass2/AOD086/0010/AliAOD.root");
1478   // create an input handler
1479   AliVEventHandler* inputH = new AliAODInputHandler();
1480   // and connect it to the manager
1481   mgr->SetInputEventHandler(inputH);\end{lstlisting}
1482   Great, at this point we have created an analysis manager, which will read events from a chain of AliAOD.root files. \index{AliVEventHandler}\index{AliVEventHandler!AliAODInputHandler}
1483   
1484 The next step will be adding specific analyses to the analysis manager. This is usually done by calling an \texttt{AddTask$\ast$.C} macro, which creates instances of analysis tasks, connects input (events from the analysis manager) to these tasks, and then connects output from the task back to the analysis manager (which will take care of writing the analysis to a common output file). These next steps show what would be in your \texttt{AddTask$\ast$.C} macro.
1485   
1486 The heart of our flow analysis will be the flow event. To fill a flow event from the input AOD events, we will use the \texttt{AliAnalysisTaskFlowEvent}\index{example!AliAnalysisTaskFlowEvent} class. The AOD input events have to be supplied by the analysis manager, so first things first, retrieve the manager to which you will connect your flow analysis tasks\footnote{In the example macro this is a not necessary as you already have a pointer to the manager in your macro. However, if you split the macro into a steering macro and AddTask macro, the AddTask macro needs to retrieve a pointer to the manager which is craeted in the steering macro.}:
1487
1488 \begin{lstlisting}[language=C, numbers=left]
1489   // the manager is static, so get the existing manager via the static method
1490   AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1491   if (!mgr) {
1492       printf("No analysis manager to connect to!\n");
1493       return NULL;
1494   }
1495         
1496   // just to see if all went well, check if the input event handler has been connected
1497   if (!mgr->GetInputEventHandler()) {
1498       printf("This task requires an input event handler!\n");
1499       return NULL;
1500     }\end{lstlisting}
1501     \item [Setting up the flow event task]
1502 The manager and input data are present, so we can create the flow event task and do some basic configuration
1503 \begin{lstlisting}[language=C, numbers=left]
1504   // create instance of the class. because possible qa plots are added in a second ouptut slot,
1505   // the flow analysis task must know if you want to save qa plots at the time of class construction
1506   Bool_t doQA = kTRUE;
1507   // craete instance of the class
1508   AliAnalysisTaskFlowEvent* taskFE = new AliAnalysisTaskFlowEvent("FlowEventTask", "", doQA);
1509   // add the task to the manager
1510   mgr->AddTask(taskFE);
1511   // enable QA plots (will give you more insight into what you're doing)
1512   taskFE->SetQAOn(kTRUE);
1513   // set the trigger selection
1514   taskFE->SelectCollisionCandidates(AliVEvent::kMB);\end{lstlisting}
1515 Note that in the last step you have set the trigger configuration\index{example!trigger selection}. Always make sure that you run on a trigger that makes sense for your analysis. A general remark is that the non-uniform acceptance correction methods that are implemented in the flow package, assume a flat \textbf{Q} vector distribution. Specific triggers (e.g. EMCal triggers) result in a \textbf{Q} vector bias which should \emph{not} be corrected as they invalidate that assumption\footnote{The actual event selection based on triggers is done in the \texttt{AliAnalysisTaskSE} class (to be specific, the trigger is checked in \texttt{AliAnalysisTaskSE::Exec()}) from which the \texttt{AliAnalysisTaskFlowEvent} is derived. The full set of available triggers can be found in the virtual event header \texttt{AliVEvent.h}. }.
1516
1517 In addition to the trigger selection, one might want to do some more event selection\index{example!event selection}. The flow package has a common event selection class, which we will add to your flow event
1518
1519 \begin{lstlisting}[language=C, numbers=left]
1520   // define the event cuts object
1521   AliFlowEventCuts* cutsEvent = new AliFlowEventCuts("EventCuts");
1522   // configure some event cuts, starting with centrality
1523   cutsEvent->SetCentralityPercentileRange(20., 30.);
1524   // method used for centrality determination
1525   cutsEvent->SetCentralityPercentileMethod(AliFlowEventCuts::kV0);
1526   // vertex-z cut
1527   cutsEvent->SetPrimaryVertexZrange(-10.,10.);
1528   // enable the qa plots
1529   cutsEvent->SetQA(doQA);
1530   // explicit multiplicity outlier cut
1531   cutsEvent->SetCutTPCmultiplicityOutliersAOD(kTRUE);
1532   cutsEvent->SetLHC10h(kTRUE);
1533   
1534   
1535   // and, last but not least, pass these cuts to your flow event task
1536   taskFE->SetCutsEvent(cutsEvent);\end{lstlisting}
1537
1538 \item [Track selection]\index{example!track selection}
1539 Now that the flow event task has been created and some basic configuration has been done, it's time to specify the POI and RP selection. This is done by defining sets of track selection criteria for both POI's and RP's: tracks in an event that pass the track selection criteria are used as POI or RP. The track selection is defined in \texttt{AliFlowTrackCuts} objects which are passed to the \texttt{AliAnalysisTaskFlowEvent} task which does the actual selection based on the passed criteria. So, let's create some track selection objects!
1540
1541 Starting with the RP's, for which we'll just use a uniform selection of charged tracks,
1542 \begin{lstlisting}[language=C, numbers=left]
1543   //create the track cuts object using a static function of AliFlowTrackCuts
1544   AliFlowTrackCuts* cutsRP = AliFlowTrackCuts::GetAODTrackCutsForFilterBit(1, "RP cuts");
1545   // specify the pt range
1546   cutsRP->SetPtRange(0.2, 5.);
1547   // specify eta range
1548   cutsRP->SetEtaRange(-0.8, 0.8);
1549   // specify track type
1550   cutsRP->SetParamType(AliFlowTrackCuts::kAODFilterBit);
1551   // enable saving qa histograms
1552   cutsRP->SetQA(kTRUE);\end{lstlisting}
1553   
1554 The particles in this example of which we want to measure the differential $v_2$ (the POI's) are the charged pions. To measure the $v_2$ of charged pions, one must of course identify tracks are pions: for this we will use the \texttt{AliFlowTrackCuts} class. First, we do the basic setup, creating the cut object and setting some kinematic variables:
1555   
1556 \begin{lstlisting}[language=C, numbers=left]
1557   //create the track cuts object using a static function of AliFlowTrackCuts
1558   AliFlowTrackCuts* cutsPOI = AliFlowTrackCuts::GetAODTrackCutsForFilterBit(1, "pion selection");
1559   // specify the pt range
1560   cutsPOI->SetPtRange(0.2, 5.);
1561   // specify eta range
1562   cutsPOI->SetEtaRange(-0.8, 0.8);
1563   // specify the track type
1564   cutsRP->SetParamType(AliFlowTrackCuts::kAODFilterBit);
1565   // enable saving qa histograms
1566   cutsPOI->SetQA(kTRUE);\end{lstlisting}
1567
1568 Once this is done, the particle identification routine is defined. In this example, the particle identification will be done using a Bayesian approach, combining the signals from the TPC and TOF detectors. 
1569 \begin{lstlisting}[language=C, numbers=left]
1570   // which particle do we want to identify ?
1571   AliPID::EParticleType particleType=AliPID::kPion;
1572   // specify the pid method that we want to use  
1573   AliFlowTrackCuts::PIDsource sourcePID=AliFlowTrackCuts::kTOFbayesian;
1574   // define the probability (between 0 and 1) 
1575   Double_t probability = .9;
1576   // pass these variables to the track cut object
1577   cutsPOI->SetPID(particleType, sourcePID, probability);
1578   // the bayesian pid routine uses priors tuned to an average centrality
1579   cutsPOI->SetPriors(35.);\end{lstlisting}
1580   
1581 Now that the track cuts for both POI's and RP's are defined, we can connect them to the flow event task,
1582 \begin{lstlisting}[language=C, numbers=left]
1583   // connect the RP's to the flow event task
1584   taskFE->SetCutsRP(cutsRP);
1585   // connect the POI's to the flow event task
1586   taskFE->SEtCutsPOI(cutsPOI);\end{lstlisting}
1587   
1588   \item [Connecting input and output]\index{InputContainer}\index{OutputContainer}\index{ExchangeContainer}\index{example!connecting containers}\index{connecting containers}
1589   At this point, the event and track cuts have been set and connected to the flow event task. The next step will be connecting the flow event task to the analysis manager (so that it can receive input events) and subsequently connecting the flow event task to flow analysis tasks, so that the flow events can be analyzed by our favorite flow analysis methods. 
1590   
1591 \begin{lstlisting}[language=C, numbers=left]
1592   // get the default name of the output file ("AnalysisResults.root")
1593   TString file = GetCommonFileName();
1594   // get the common input container from the analysis manager
1595   AliAnalysisDataContainer *cinput = mgr->GetCommonInputContainer();
1596    // create a data container for the output of the flow event task  
1597    // the output of the task is the AliFlowEventSimle class which will
1598    // be passed to the flow analysis tasks. note that we use a kExchangeContainer here,
1599    // which exchanges data between classes of the analysis chain, but is not
1600    // written to the output file
1601   AliAnalysisDataContainer *coutputFE = mgr->CreateContainer(
1602       "FlowEventContainer",
1603       AliFlowEventSimple::Class(),
1604       AliAnalysisManager::kExchangeContainer);
1605   // connect the input data to the flow event task
1606   mgr->ConnectInput(taskFE,0,cinput);
1607   // and connect the output to the flow event task
1608   mgr->ConnectOutput(taskFE,1,coutputFE);
1609   // create an additional container for the QA output of the flow event task
1610   // the QA histograms will be stored in a sub-folder of the output file called 'QA'
1611   TString taskFEQAname = file;
1612   taskFEQAname += ":QA";
1613   AliAnalysisDataContainer* coutputFEQA = mgr->CreateContainer(
1614       "FlowEventContainerQA",
1615        TList::Class(),
1616        AliAnalysisManager::kOutputContainer,
1617        taskFEQAname.Data()       
1618        );
1619   // and connect the qa output container to the flow event. 
1620   // this container will be written to the output file
1621   mgr->ConnectOutput(taskFE,2,coutputFEQA);\end{lstlisting}
1622   \item [Flow analysis tasks]
1623 Now that the flow event task is connected to input data, the flow analysis tasks can be set up:
1624 \begin{lstlisting}[language=C, numbers=left]
1625   // declare necessary pointers
1626   AliAnalysisDataContainer *coutputQC[3];
1627   AliAnalysisTaskQCumulants *taskQC[3];
1628
1629   // the tasks will be creaated and added to the manager in a loop
1630   for(Int_t i = 0; i < 3; i++) {
1631       // create the flow analysis tasks
1632       taskQC[i] = new AliAnalysisTaskQCumulants(Form("TaskQCumulants_n=%i", i+2));
1633       // set thei triggers 
1634       taskQC[i]->SelectCollisionCandidates(AliVEvent::kMB);
1635       // and set the correct harmonic n
1636       taskQC[i]->SetHarmonic(i+2);
1637
1638       // connect the task to the analysis manager
1639       mgr->AddTask(taskQC[i]);
1640
1641       // create and connect the output containers
1642       TString outputQC = file;
1643       // create a sub-folder in the output file for each flow analysis task's output
1644       outputQC += Form(":QC_output_for_n=%i", i+2);
1645       /// create the output containers
1646       coutputQC[i] = mgr->CreateContainer(
1647           outputQC.Data(),
1648           TList::Class(),
1649           AliAnalysisManager::kOutputContainer,
1650           outputQC);
1651       // connect the output of the flow event task to the flow analysis task
1652       mgr->ConnectInput(taskQC[i], 0, coutputFE);
1653       // and connect the output of the flow analysis task to the output container
1654       // which will be written to the output file
1655       mgr->ConnectOutput(taskQC[i], 1, coutputQC[i]);
1656   }\end{lstlisting}
1657       \item[Launching the analysis]
1658           With this, the \texttt{AddTask$\ast$.C} is concluded. The only thing that is left to do, is (from the \texttt{run.C} macro) see if all tasks and containers are properly connected and initialized and launch the analysis locally\index{example!launch analysis}:
1659 \begin{lstlisting}[language=C, numbers=left]
1660   // check if we can initialize the manager
1661   if(!mgr->InitAnalysis()) return;   
1662   // print the status of the manager to screen 
1663   mgr->PrintStatus();
1664   // print to screen how the analysis is progressing
1665   mgr->SetUseProgressBar(1, 25);
1666   // start the analysis locally, reading the events from the tchain
1667   mgr->StartAnalysis("local", chain);\end{lstlisting}
1668 \end{description}
1669
1670 \chapter{Methods}\index{flow analysis methods}\index{methods}
1671 \label{sec:methods}
1672 The flow package aims at providing the user with most of the known flow analysis methods. Detailed theoretical overview of the methods can be found in the following papers, which are included in the folder \texttt{\$ALICE\_ROOT/PWGCF/FLOW/Documentation/otherdocs/}
1673 \begin{itemize}
1674         \item Scalar Product Method \\ \hspace*{1cm} \texttt{EventPlaneMethod/FlowMethodsPV.pdf}
1675         \item Generating Function Cumulants \\ \hspace*{1cm} \texttt{GFCumulants/Borghini\_GFCumulants\_PracticalGuide.pdf}
1676         \item Q-vector Cumulant method \\ \hspace*{1cm} \texttt{QCumulants/QCpaperdraft.pdf} 
1677         \item Lee-Yang Zero Method \\ \hspace*{1cm} \texttt{LeeYangZeroes/Borghini\_LYZ\_PracticalGuide.pdf}
1678         \item Lee-Yang Zero Method \\ \hspace*{1cm} \texttt{LeeYangZeroesEP/LYZ\_RP.pdf}
1679 \end{itemize}
1680 The structure of this  chapter is as follows: of each of the available methods a short description is given in the \texttt{theory} subsection (for more detailed information, see the papers listed above) followed by details which are specific to the implementation in the subsection \texttt{implementation}. Caveats, possible issues, etc, are listed in the \texttt{caveats} subsections. 
1681 %-----------------------------------------------------------------------
1682
1683  \section{AliFlowAnalysisWithMCEventPlane}\index{AliFlowAnalysisWithMCEventPlane}\index{methods!AliFlowAnalysisWithLYZEventPlane}
1684 \label{sec:MC}
1685 \subsection{Theory}
1686 From the \texttt{.cxx} of the task: 
1687 \begin{lstlisting}[language=C, numbers=left]
1688 // Description: Maker to analyze Flow from the generated MC reaction plane.
1689 //              This class is used to get the real value of the flow 
1690 //              to compare the other methods to when analysing simulated events.\end{lstlisting}
1691 This method can be used to check what $v_n$ was generated in an on-the-fly flow study or using the \texttt{AliAnalysisTaskFlowEvent} with afterburner. 
1692 \subsection{Implementation}
1693 There is no specific information on the implementation here, for details the reader is referred to the source code.
1694
1695 \section{AliFlowAnalysisWithQCumulants}\label{sec:QC}\index{AliFlowAnalysisWithQCumulants}\index{methods!AliFlowAnalysisWithQCumulants}
1696 \subsection{Implementation}
1697 A how-to of the QC method in the flow-package is written by the author of the analysis software and is available on the FLOW-PAG twiki page (\href{https://twiki.cern.ch/twiki/bin/view/ALICE/FlowPackageHowto}{https://twiki.cern.ch/twiki/bin/view/ALICE/FlowPackageHowto}). This section is copied from the twiki page (and may therefore overlap with other parts of this manual).
1698
1699  To get the first feeling how the FLOW package and QC output are organized, perhaps you can just trivially execute one 'on-the-fly' example 
1700
1701  Essentially, you have to do two things: 
1702         \begin{lstlisting}[language=C, numbers=left]
1703 cp $ALICE_ROOT/PWGCF/FLOW/macros/runFlowAnalysisOnTheFly.C
1704 aliroot runFlowAnalysisOnTheFly.C \end{lstlisting}
1705
1706  In the analysis on-the-fly particles are sampled from hardwired Fourier-like p.d.f, so input vn harmonics are completely under control. Please have a look at the steering macro runFlowAnalysisOnTheFly.C and corresponding class AliFlowEventSimpleMakerOnTheFly.cxx in the FLOW package, which are easily written (no fancy C++ features in my code!), and well documented. 
1707
1708  If you have landed successfully, you will get an output AnalysisResults.root, where the results from each method are structured in directories. 
1709
1710  To make a size of the file lighter (which matters a lot during merging!), you may want not to use all the methods. You can make your selection of the methods via:
1711         \begin{lstlisting}[language=C, numbers=left]
1712 Bool_t MCEP = kTRUE; // Monte Carlo Event Plane
1713 Bool_t SP = kTRUE; // Scalar Product (a.k.a 'flow analysis with eta gaps')
1714 Bool_t GFC = kTRUE; // Generating Function Cumulants
1715 Bool_t QC = kTRUE; // Q-cumulants
1716 Bool_t FQD = kTRUE; // Fitted q-distribution
1717 Bool_t LYZ1SUM = kTRUE; // Lee-Yang Zero (sum generating function), first pass over the data
1718 Bool_t LYZ1PROD = kTRUE; // Lee-Yang Zero (product generating function), first pass over the data
1719 Bool_t LYZ2SUM = kFALSE; // Lee-Yang Zero (sum generating function), second pass over the data
1720 Bool_t LYZ2PROD = kFALSE; // Lee-Yang Zero (product generating function), second pass over the data
1721 Bool_t LYZEP = kFALSE; // Lee-Yang Zero Event Plane
1722 Bool_t MH = kFALSE; // Mixed Harmonics (used for strong parity violation studies) 
1723 Bool_t NL = kFALSE; // Nested Loops (neeed for debugging, only for developers)  \end{lstlisting}
1724  Next important remark, if you want to browse through AnalysisResults.root, make sure that in AliROOT prompt you have loaded the FLOW library:
1725         \begin{lstlisting}[language=C, numbers=left]
1726 root [0] gSystem->Load("libPWGflowBase");       \end{lstlisting}
1727  In the AnalysisResults.root, the QC output is stored in "outputQCanalysis". Just browse there, browse in "cobjQC", and you will see the directory structure.
1728  "Integrated Flow" $\Rightarrow$ contains all results needed for reference flow. Browse in, and explore the directory (in fact, TList) "Results". The names of the histos should be self-explanatory;
1729  "Differential Flow" $\Rightarrow$ browse further into "Results", and you will find a bunch of things that you can explore. For instance, in the directory "Differential Q-cumulants (POI,p$_{T}$)" you will find histos holding differential QC\{2\} vs pt, QC\{4\} vs p$_{T}$, etc. On the other hand, the flow estimates themselves, namely differential vn\{2\} vs pt, vn\{4\} vs pt you can fetch from TList "Differential Flow (POI,p$_{T}$)"
1730  I hope that the names for all other things you might need are self-explanatory. 
1731  You configure QC method in the steering macro via setters:
1732         \begin{lstlisting}[language=C, numbers=left]
1733 qc->SetHarmonic(2);
1734 qc->SetCalculateDiffFlow(kTRUE);
1735 qc->SetCalculate2DDiffFlow(kFALSE); // vs (pt,eta)
1736 qc->SetApplyCorrectionForNUA(kFALSE);
1737 qc->SetFillMultipleControlHistograms(kFALSE); 
1738 qc->SetMultiplicityWeight("combinations"); // default (other supported options are "unit" and "multiplicity")
1739 qc->SetCalculateCumulantsVsM(kFALSE);
1740 qc->SetCalculateAllCorrelationsVsM(kFALSE); // calculate all correlations in mixed harmonics "vs M"
1741 qc->SetnBinsMult(10000);
1742 qc->SetMinMult(0);
1743 qc->SetMaxMult(10000); 
1744 qc->SetBookOnlyBasicCCH(kFALSE); // book only basic common control histograms
1745 qc->SetCalculateDiffFlowVsEta(kTRUE); // if you set kFALSE only differential flow vs pt is calculated
1746 qc->SetCalculateMixedHarmonics(kFALSE); // calculate all multi-partice mixed-harmonics correlators      \end{lstlisting}
1747  You can make QC output lighter by setting 
1748         \begin{lstlisting}[language=C, numbers=left]
1749 qc->SetBookOnlyBasicCCH(kTRUE); \end{lstlisting} 
1750 (to book only basic control histograms, and disabling lot of 2D beasts), and 
1751         \begin{lstlisting}[language=C, numbers=left]
1752 qc->SetCalculateDiffFlowVsEta(kFALSE);  \end{lstlisting}
1753 (if not interested in differential flow vs eta $\Rightarrow$ this will make the final output smaller) 
1754  In the "cobjQC" you might also consider "AliFlowCommonHistQC" to be useful thing, which contains a lot of trivial but still important control histograms (eg multiplicity distribution of RPs, POIs, etc). 
1755  I think this is the best and fastest way for you to get familiar with the FLOW package => once you send the QC code over the real data, you get the output organized in the very same way. I will send you shortly an example set of macros which get be used for the analysis on Grid over the real data. 
1756  Differential QC\{2\} and QC\{4\} implementation is generic. You can tag as RP and POI whatever you want, and it will give you results automatically decoupled from any autocorrelation effects. For this reason, it is important that if you have certain particles which is classified both as RP and POI, to be explicitly tagged also as RPs and POI once you are building the "flow event". 
1757  The basic feature in the FLOW package is that from whichever input you start, we have to build the same intermediate step called "flow event", with which than we feed all methods (SP, QC, etc) in the very same way. 
1758  To see what "flow event" does, and what does it need as an input, you may want to consult task AliAnalysisTaskFlowEvent.cxx and classes needed there-in. 
1759
1760 \section{AliFlowAnalysisWithScalarProduct}\index{AliFlowAnalysisWithScalarProduct}\index{methods!AliFlowAnalysisWithScalarProduct}
1761 \label{sec:SP}\label{sec:scalar_product}
1762 \subsection{Theory}
1763 \begin{lstlisting}[language=C, numbers=left]
1764 /////////////////////////////////////////////////////////////////////////////
1765 // Description: Maker to analyze Flow from the Event Plane method.
1766 //              Adaptation based on Scalar Product
1767 // authors: Naomi van del Kolk
1768 //          Ante Bilandzic
1769 // mods:    Carlos Perez 
1770 /////////////////////////////////////////////////////////////////////////////
1771 \end{lstlisting}
1772 \subsubsection{The scalar product method}
1773 The scalar product method estimates $v_n$ directly from \textbf{Q} vectors:
1774 \begin{equation}\label{sp_func}
1775 v_n = \frac{\langle u \cdotp Q \rangle }{\sqrt{\langle Q_A \cdotp Q_B \rangle}}
1776 \end{equation}
1777 The denominator of equation \ref{sp_func} consists of two sub-event \textbf{Q} vectors, \textbf{Q}$_{A}$ and \textbf{Q}$_{B}$. Sub-events are built from RP's. These sub-event vectors are in the flow package defined as coming from different $\eta$ ranges. 
1778
1779 To setup the different $\eta$ ranges, one can use the \texttt{AliAnalysisTaskFlowEvent} directly by calling
1780 \begin{lstlisting}[language=C, numbers=left]
1781 AliAnalysisTaskFlowEvent:: void SetSubeventEtaRange(Double_t minA, Double_t maxA, Double_t minB, Double_t maxB)
1782     {this->fMinA = minA; this->fMaxA = maxA; this->fMinB = minB; this->fMaxB = maxB; }\end{lstlisting}
1783 Sub-events can be re-tagged using the filter task, which will be described in section \ref{sec:exotic}. 
1784 Internally, the tagging is performed by the function
1785 \begin{lstlisting}[language=C, numbers=left]
1786 AliFlowEventSimple::TagSubEventsInEta(Double_t etaMinA, Double_t etaMaxA, Double_t etaMinB, Double_t etaMaxB);\end{lstlisting}
1787 which should be called when you fill your flow events `by-hand' and want to tag sub-events. 
1788
1789
1790 The numerator of equation \ref{sp_func} is the correlator of the POI \textbf{Q} vector ($u$) and a sub-event \textbf{Q} vector which is generally referred to as the reference detector. In the flow package, this sub-event \textbf{Q} vector is called `total q-vector'. The user of the task needs to specify what part of the RP selection (that is, which sub-events) are used as total \textbf{Q} vector. Passing this information to the scalar product task is done in the following way
1791 \begin{lstlisting}[language=C, numbers=left]
1792 AliAnalysisTaskScalarProduct:: void SetTotalQvector(const char *tqv) {*this->fTotalQvector = tqv;}; \end{lstlisting}
1793 where the following options are available
1794 \begin{lstlisting}[language=C, numbers=left]
1795   TString   *fTotalQvector;      // total Q-vector is: "QaQb" (means Qa+Qb), "Qa"  or "Qb" \end{lstlisting}
1796 In general, one has to be a bit careful with setting up sub-events. Make sure that the combination of reference detector and sub-events is mathematically sound! An example of how to deal with complex setups is given in the VZERO scalar product subsection (\ref{sec:vzerp_sp}).
1797
1798 \subsubsection{VZERO scalar product}\label{sec:vzerp_sp}
1799                 
1800 The VZEROA and VZEROC detectors have different $\eta$ coverage w.r.t the TPC, so to evaluate $v_2$ from VZERO-SP, do
1801 \begin{equation}
1802 v_n = \sqrt{\frac{\langle u_i \cdotp Q_A \rangle }{\sqrt{\langle Q_A \cdotp Q_B \rangle}} \cdotp \frac{\langle u_j \cdotp Q_B \rangle }{\sqrt{\langle Q_A \cdotp Q_B \rangle}}}
1803 \end{equation}
1804 \begin{itemize}
1805 \item $Q_A$ and $Q_B$ are the VZEROC and VZEROA RP's
1806 \end{itemize}
1807 What is up for debate is the following: how do we defined the POI's?
1808 \begin{itemize}
1809 \item Take $u$ = full TPC = $u_j$ = $u_i$, or do $u_j$ = $\eta < 0$, $u_i$ = $\eta > 0$ ?
1810 \end{itemize}
1811 In the elliptic flow analysis of identified particles, majority vote has yielded the following:
1812 \begin{itemize}
1813 \item $u$ = full TPC = $u_j$ = $u_i$
1814 \end{itemize}
1815 so that in the end the published points were obtained using
1816 \begin{equation}
1817 v_n = \sqrt{\frac{\langle u \cdotp Q_A \rangle }{\sqrt{\langle Q_A \cdotp Q_B \rangle}} \cdotp \frac{\langle u \cdotp Q_B \rangle }{\sqrt{\langle Q_A \cdotp Q_B \rangle}}}
1818 \end{equation}
1819 Note that this requires running \emph{two} scalar product tasks in the flow package (one for each reference detector) the output $v_2$ of which was in turn multiplied point-by-point in $p_t$. 
1820
1821 \subsubsection{Extension to Event Plane method}
1822 By normalizing the \textbf{Q} vectors, the scalar product method is essentially reduced to the `classic' event plane method. Normalization of the \textbf{Q} vectors can be set using
1823 \begin{lstlisting}[language=C, numbers=left]
1824 AliAnalysisTaskScalarProduct::SetBehaveAsEP()\end{lstlisting}
1825
1826 \section{AliFlowAnalysisWithCumulants}\index{AliFlowAnalysisWithCumulants}\index{methods!AliFlowAnalysisWithCumulants}
1827 \subsection{Theory}
1828 \begin{lstlisting}[language=C, numbers=left]
1829 /************************************************* 
1830  * Flow analysis with cumulants. In this class   *
1831  * cumulants are calculated by making use of the *
1832  * formalism of generating functions proposed by *
1833  * Ollitrault et al.                             *
1834  *                                               * 
1835  *      Author: Ante Bilandzic                   * 
1836  *************************************************/ \end{lstlisting}
1837
1838 \subsection{Implementation}
1839 There is no specific information on the implementation here, for details the reader is referred to the source code.
1840 \section{AliFlowAnalysisWithMixedHarmonics}\index{AliFlowAnalysisWithMixedHarmonics}\index{methods!AliFlowAnalysisWithMixedHarmonics}
1841 \subsection{Theory}
1842 There is no specific information on the theory here, for details the reader is referred to the source code.
1843 \subsection{Implementation}
1844 There is no specific information on the implementation here, for details the reader is referred to the source code.
1845
1846 \section{AliFlowAnalysisWithFittingQDistribution}\index{AliFlowAnalysisWithFittingQDistribution}\index{methods!AliFlowAnalysisWithFittingQDistribution}
1847 \subsection{Theory}
1848 \begin{lstlisting}[language=C, numbers=left]
1849 /******************************** 
1850  * estimating reference flow by *
1851  *   fitting q-distribution     * 
1852  *                              *
1853  * author: Ante Bilandzic       * 
1854  *                              *  
1855  *  based on the macro written  *
1856  *     by Sergei Voloshin       *
1857  *******************************/  \end{lstlisting}
1858 \subsection{Implementation}
1859 There is no specific information on the implementation here, for details the reader is referred to the source code.
1860
1861
1862 \section{AliFlowAnalysisWithMultiparticleCorrelations}\index{AliFlowAnalysisWithMultiparticleCorrelations}\index{methods!AliFlowAnalysisWithMultiparticleCorrelations}
1863 \subsection{Theory}
1864 \begin{lstlisting}[language=C, numbers=left]
1865 /********************************************************** 
1866  * In this class azimuthal correlators in mixed harmonics *
1867  * are implemented in terms of Q-vectors. This approach   *
1868  * doesn't require evaluation of nested loops. This class *
1869  * can be used to:                                        *
1870  *                                                        *  
1871  *  a) Extract subdominant harmonics (like v1 and v4);    *
1872  *  b) Study flow of two-particle resonances;             *
1873  *  c) Study strong parity violation.                     * 
1874  *                                                        * 
1875  * Author: Ante Bilandzic                                 *
1876  *********************************************************/ \end{lstlisting}
1877 \subsection{Implementation}
1878 There is no specific information on the implementation here, for details the reader is referred to the source code.
1879
1880 \section{AliFlowAnalysisWithLeeYangZeros}\index{AliFlowAnalysisWithLeeYangZeros}\index{methods!AliFlowAnalysisWithLeeYangZeros}
1881 \subsection{Theory}
1882 \begin{lstlisting}[language=C, numbers=left]
1883 ////////////////////////////////////////////////////////////////////
1884 // Description: Maker to analyze Flow by the LeeYangZeros method
1885 //              One needs to do two runs over the data; 
1886 //              First to calculate the integrated flow 
1887 //              and in the second to calculate the differential flow
1888 // Author: Naomi van der Kolk 
1889 //////////////////////////////////////////////////////////////////// \end{lstlisting}
1890 \subsection{Implementation}
1891 There is no specific information on the implementation here, for details the reader is referred to the source code.
1892
1893 \section{AliFlowAnalysisWithLYZEventPlane}\index{AliFlowAnalysisWithLYZEventPlane}\index{methods!AliFlowAnalysisWithLYZEventPlane}
1894 \subsection{Theory}
1895 \begin{lstlisting}[language=C, numbers=left]
1896 // AliFlowAnalysisWithLYZEventPlane:
1897 // Class to do flow analysis with the event plane
1898 // from the LYZ method
1899 \end{lstlisting}
1900 \subsection{Implementation}
1901 There is no specific information on the implementation here, for details the reader is referred to the source code.
1902
1903 \section{Developing your own task}
1904 Of course this list of flow analysis methods could be extended. Adding a new flow analysis method means developing two classes: a `base' class where the method is implemented and a `tasks' class to interface with the analysis manager. As a starting point, `templates' have been developed, which are just empty base and task classes in the flow package. You can find these at
1905 \begin{description}
1906 \item[base] \texttt{\$ALICE\_ROOT/PWG/FLOW/Base/AliFlowAnalysisTemplate.cxx (h)}
1907 \item[tasks] \texttt{\$ALICE\_ROOT/PWG/FLOW/Tasks/AliAnalysisTaskTemplate.cxx (h)}
1908 \end{description}
1909         
1910                 
1911 \chapter{More exotic uses}\label{sec:exotic}
1912 This chapter deals with more `exotic' uses of the flow package. 
1913 \section{Flow analysis in the LEGO framework: re-tagging your POI and RP selections}\index{LEGO framework}\index{AliAnalysisTaskFilterFE}
1914 To save resources, it is beneficial to construct analysis trains in which just one flow event is created which is passed to multiple analysis tasks. This can be inconvenient when the different analysis tasks require different POI and RP selections\footnote{A noteble example of this is doing an invariant mass analysis, which will briefly be touched in the next section.}. To overcome this, a filter task, \texttt{AliAnalysisTaskFilterFE}, has been developed, which can run between the \texttt{AliAnalysisTaskFlowEvent} and a specific flow analysis task, and can re-tag POI's and RP's. The re-tagging is performed by looping over all tracks in an event and checking whether or not these tracks pass a selection of simple cuts. The filter task can only re-tag existing tracks in the flow event, it cannot add new tracks to the flow event. To illustrate the functionality of the filtertask, we'll take the example of section \ref{sec:example} but perform the analysis using different $\vert \eta \vert$ windows for RP's.
1915
1916 The first step towards filtering is setting up the filtering criteria. These are defined using the \texttt{AliFlowTrackSimpleCuts}\index{AliFlowTrackSimpleCuts} object:
1917 \begin{lstlisting}[language=C, numbers=left]
1918 // create the simple cuts object
1919 AliFlowTrackSimpleCuts* filterRP = new AliFlowTrackSimpleCuts("filterRP"); 
1920 // specify a rapidity interval
1921 filterRP->SetEtaMin(-0.4);
1922 filterRP->SetEtaMax(0.4);\end{lstlisting}
1923
1924 All available filtering options in \texttt{AliFlowTrackSimpleCuts} are: 
1925 \begin{lstlisting}[language=C, numbers=left]
1926   //setters
1927   void SetPtMax(Double_t max)   {this->fPtMax = max; fCutPt=kTRUE; }
1928   void SetPtMin(Double_t min)   {this->fPtMin = min; fCutPt=kTRUE;  }
1929   void SetEtaMax(Double_t max)  {this->fEtaMax = max; fCutEta=kTRUE; }
1930   void SetEtaMin(Double_t min)  {this->fEtaMin = min; fCutEta=kTRUE; }
1931   void SetEtaGap(Double_t min, Double_t max)
1932         {fEtaGapMin = min, fEtaGapMax = max, fCutEtaGap = kTRUE; }
1933   void SetPhiMax(Double_t max)  {this->fPhiMax = max; fCutPhi=kTRUE; }
1934   void SetPhiMin(Double_t min)  {this->fPhiMin = min; fCutPhi=kTRUE; }
1935   void SetPID(Int_t pid)        {this->fPID = pid; fCutPID=kTRUE; }
1936   void SetCharge(Int_t c)       {this->fCharge = c; fCutCharge=kTRUE; }
1937   void SetMassMax(Double_t max) {this->fMassMax = max; fCutMass=kTRUE; }
1938   void SetMassMin(Double_t min) {this->fMassMin = min; fCutMass=kTRUE; }\end{lstlisting}
1939 All cuts are disabled by default. 
1940
1941 The second step is constructing the filter class object itself:
1942 \begin{lstlisting}[language=C, numbers=left]
1943 // create the filter task object. note that the desired cuts have to be passed 
1944 // in the constructor, the 0x0 that is passed means that POI's will not be filtered
1945 AliAnalysisTaskFilterFE* filterTask = AliAnalysisTaskFilterFE("filter task", filterRP, 0x0);\end{lstlisting}
1946 Sub-events can also be re-defined using the filter task. To do so, call
1947 \begin{lstlisting}[language=C, numbers=left]
1948 AliAnalysisTaskFilterFE::SetSubeventEtaRange(Double_t minA, Double_t maxA, Double_t minB, Double_t maxB)
1949     {this->fMinA = minA; this->fMaxA = maxA; this->fMinB = minB; this->fMaxB = maxB; }\end{lstlisting}
1950 If yo use the filter task for a flow analysis method which uses sub-events, make sure that you set the correct $\eta$ ranges! Otherwise, the default values will be used, which may (or may not) be correct for your analysis. 
1951
1952 The \texttt{UserExec()} of the fitler task is as follows:
1953 \begin{lstlisting}[language=C, numbers=left]
1954 void AliAnalysisTaskFilterFE::UserExec(Option_t *)
1955 {
1956   // Main loop
1957   fFlowEvent = dynamic_cast<AliFlowEventSimple*>(GetInputData(0)); // from TaskSE
1958   if (!fFlowEvent) return;
1959   if(fCutsRFP) fFlowEvent->TagRP(fCutsRFP);
1960   if(fCutsPOI) fFlowEvent->TagPOI(fCutsPOI);
1961   fFlowEvent->TagSubeventsInEta(fMinA,fMaxA,fMinB,fMaxB);
1962   PostData(1,fFlowEvent);
1963 }\end{lstlisting}
1964
1965 Now that the filter task has been configured, it needs to be added to the analysis chain. As stated, the task needs to be put \emph{in between} the flow event task and the flow analysis method. 
1966 \begin{lstlisting}[numbers=left, language=C]
1967 // get the analysis manager
1968 AliAnalysisManager *mgr = AliAnalysisManager::GetAnalysisManager();
1969 // add the fitler task to the manager (should be done before the
1970 // analysis task is added!)
1971 mgr->AddTask(filterTask);
1972 // create a temporary container which the filter task will pass to the 
1973 // analysis task
1974 AliAnalysisDataContainer *coutputFilter = mgr->CreateContainer(
1975    "FilterContainer",
1976    AliFlowEventSimple::Class(),
1977    AliAnalysisManager::kExchangeContainer);
1978 // connect the output of the flow analysis task as input to the filter task
1979 mgr->ConnectInput(filterTask, 0, coutputFE);
1980 // and connect the filter container as output
1981 mgr->ConnectOutput(filterTask, 1, coutputFilter);
1982 // pass the filter task output to the analysis method   
1983 // (this is assuming you already have setup the analysis task as
1984 // explained in the example in section 3.4.3
1985 mgr->ConnectInput(taskQC[i], 0, coutputFilter);\end{lstlisting}
1986 \subsection{Caveats}
1987 Note that the filter task will change the tags of the flow tracks in the flow event. \emph{Every} analysis task that runs after the filter task in an analysis train will therefore be affected by the re-taggging that is performed by the filter task. Often it can be useful to run multiple filter tasks with different configurations in an analysis train. 
1988
1989 \section{Flow analysis of resonances}
1990 One notable case in which the filter task is useful, is the flow analysis of rapidly decaying particles via the invariant mass method. If a particle decays to daughter particles, e.g.
1991 \begin{equation}
1992 \Lambda \longrightarrow \pi + \mbox{p}
1993 \end{equation}
1994 one can do an invariant mass flow analysis, which basically comprises
1995 \begin{enumerate}
1996 \item Take all the $\pi + \mbox{p}$ pairs in an event and plot their invariant mass
1997 \item Extract the signal yield \alert{$N^S$} and total yield \alert{$N^T$} from this distribution
1998 \item Measure $v_2$ of all $\pi + \mbox{p}$ pairs
1999 \end{enumerate}
2000 Under the assumption that signal and background flow are additive, their contributions can be disentangled by solving
2001 \begin{equation}
2002 v_2^{T}(m_{inv})  = v_2^{S} \frac{N^{S} }{N^{S} + N^{B}}(m_{inv})  + v_2^{B}(m_{inv}) \frac{ N^{B}}{N^{S} + N^{B}}(m_{inv})
2003 \end{equation}
2004 for $v_2^{S}$. To do so, $v_2^{T}(m_{inv})$ must be measured. This can be done by measuring the $v_2$ of all possible $\pi + \mbox{p}$ pairs in different invariant mass intervals. When a flow event is filled by-hand with $\pi + \mbox{p}$ pairs, the filter task can then be in turn be used to split the flow event into invariant mass intervals and perform flow analysis on those separately, thereby extracting all necessary information. Examples of such analyses are e.g. the $\varhi$-meson flow analysis (\texttt{\$ALICE\_ROOT/PWG/FLOW/Tasks/AliAnalylsisTaskPhiFlow}) or the $\Lambda$ and $\K^0$ flow task (\texttt{\$ALICE\_ROOT/PWG/FLOW/Tasks/AliAnalysisTaskFlowStrange}).
2005
2006 \section{Non-uniform acceptance correction}\index{NUA} \index{non uniform acceptance} 
2007 In practice a detector can have inefficiencies which result in a non-uniform acceptance which might bias the measured $v_n$ signal. One way of compensating for this is using track weights (as explained in section \ref{sec:weights}. Another way of correcting for these effects is by adjusting the \texttt{Q} vectors based on the assumption that the underlying \texttt{Q} vector distribution itself is flat. 
2008
2009 By default all necessary information to perform such a correction is stored when running a flow analysis task. The actual correction itself is performed when 
2010 \texttt{Finish()} is called, depending whether or not the flag to perform the correction is set to \texttt{kTRUE}.
2011
2012 The effects of the acceptance correction can always be checked by running the \texttt{redoFinish.C} macro, by toggling the flag
2013 \begin{lstlisting}[language=C, numbers=left]
2014 Bool_t bApplyCorrectionForNUA = kFALSE; // apply correction for non-uniform acceptance\end{lstlisting}
2015 to either false or true.
2016 \subsection{Caveats}
2017 The non-uniform acceptance correction is based on the assumption that the physical \texttt{Q} vector distribution in your event sample is flat. This works for minimum bias events, but might not work for e.g. triggered events or for event samples where the detector efficiency varies event-by-event. Details pertaining to the implementation can be found in the \texttt{Finish()} methods of the various flow analysis tasks.
2018
2019 \chapter{Summary}
2020 After reading the documentation, you should have a general feeling of how the flow package is organized and be able to do a standard flow analysis. This however is just where the fun begins! Connect your classes, write a new method, add new routines $\cdots$ and publish your paper!
2021
2022                 
2023         \begin{thebibliography}{99}
2024         \bibliographystyle{apsrev}
2025                                 
2026                                   
2027                 \bibitem{Ollitrault:1992bk}
2028                 J.~Y.~Ollitrault,
2029                 %``Anisotropy as a signature of transverse collective flow,''
2030                 Phys.\ Rev.\ D {\bf 46} (1992) 229.
2031                 %%CITATION = PHRVA,D46,229;%%
2032                                 
2033                 \bibitem{Danielewicz:1999vh}
2034                 P.~Danielewicz,
2035                 %``Flow and equation of state in heavy-ion collisions,''
2036                 Nucl.\ Phys.\ A {\bf 661} (1999) 82.
2037                 %  [arXiv:nucl-th/9907098].
2038                 %%CITATION = NUCL-TH 9907098;%%
2039                                 
2040                 \bibitem{Rischke:1996nq}
2041                 D.~H.~Rischke,
2042                 %``Hydrodynamics and collective behavior in relativistic nuclear
2043                 %collisions,''
2044                 Nucl.\ Phys.\ A {\bf 610} (1996) 88C.
2045                 %  [arXiv:nucl-th/9608024].
2046                 %%CITATION = NUCL-TH 9608024;%%
2047                                 
2048                 \bibitem{Ollitrault:1997vz}
2049                 J.~Y.~Ollitrault,
2050                 %``Flow systematics from SIS to SPS energies,''
2051                 Nucl.\ Phys.\ A {\bf 638} (1998) 195.
2052                 %  [arXiv:nucl-ex/9802005].
2053                 %%CITATION = NUCL-EX 9802005;%%
2054                                 
2055                 \bibitem{Voloshin:1994mz}
2056                 S.~Voloshin and Y.~Zhang,
2057                 %``Flow study in relativistic nuclear collisions by Fourier expansion of
2058                 %Azimuthal particle distributions,''
2059                 Z.\ Phys.\ C {\bf 70} (1996) 665.
2060                 %  [arXiv:hep-ph/9407282].
2061                 %%CITATION = HEP-PH 9407282;%%
2062                                 
2063                 %\cite{Ackermann:2000tr}
2064                 \bibitem{Ackermann:2000tr}  
2065                 K.~H.~Ackermann {\it et al.}  [STAR Collaboration],
2066                 %``Elliptic flow in Au + Au collisions at s(N N)**(1/2) = 130-GeV,''
2067                 Phys.\ Rev.\ Lett.\  {\bf 86} (2001) 402
2068                 %[arXiv:nucl-ex/0009011].  
2069                 %%CITATION = NUCL-EX 0009011;%%
2070                                   
2071                 %\cite{Adler:2001nb}
2072                 \bibitem{Adler:2001nb}  
2073                 C.~Adler {\it et al.}  [STAR Collaboration],
2074                 % ``Identified particle elliptic flow in Au + Au collisions at  
2075                 %s(NN)**(1/2) =  130-GeV,''
2076                 Phys.\ Rev.\ Lett.\  {\bf 87} (2001) 182301  
2077                 %[arXiv:nucl-ex/0107003].  
2078                 %%CITATION = NUCL-EX 0107003;%%
2079                                 
2080                 %%% theory RHIC discoveries %%%
2081                 %\cite{Gyulassy:2004zy}
2082                 \bibitem{RHIC_Discoveries}
2083                 T.D.~Lee {\it et al.}, 
2084                 New Discoveries at RHIC: Case for the Strongly Interacting 
2085                 Quark-Gluon Plasma. 
2086                 Contributions from the RBRC Workshop held May 14-15, 2004.
2087                 Nucl.\ Phys.\ A {\bf 750} (2005) 1-171
2088                 %%% end theory white-papers
2089                                 
2090                                     
2091         \end{thebibliography}
2092
2093 \appendix               
2094         \chapter{About this document}
2095         \section{Specifics and webpage}
2096         Typeset using \LaTeX, converted to HTML using \texttt{pandoc} via \texttt{pandoc -r latex -w html -S -s -m -N --toc --highlight-style tango --indented-code-classes numberLines --self-contained -o outfile.html FLOW.tex}
2097         
2098         \chapter{Flow analysis `on-the-fly'}\label{sec:ante}
2099                 The original `on-the-fly' manual by Ante Biland\zic is reprinted here in this appendix
2100
2101         \section{Introduction}
2102 Flow analysis `on the fly' is a feature in the \textit{ALICE flow package}\footnote{\texttt{http://alisoft.cern.ch/viewvc/trunk/PWG2/FLOW/?root=AliRoot .}} which can serve both as a demo for the potential users of the package and as an important debugging tool for the core flow code developers. Underlying idea is very simple: To simulate events of interest for flow analysis (in what follows we shall refer to such events as \textit{flow events}) in the computers memory and than pass them `on the fly' to the implemented methods for flow analysis. Benefits of this approach include: 
2103 %
2104 \begin{enumerate}
2105 \item No need to store data on disk (storing only the output files with the final results and not the simulated events themselves);
2106 \item Enormous gain in statistics; 
2107 \item Speed (no need to open the files from disk to read the events);
2108 \item Random generators initialized with the same and random seed (if the same seed is used simulations are reproducible)\,. 
2109 \end{enumerate}
2110 %
2111 In Section~\ref{kickStart} we indicate how the user can immediately in a few simple steps start flow analysis `on the fly' with the default settings both within AliRoot and Root. In Section~\ref{makingYourOwnFlowEvents} we explain how the user can modify the default settings and create `on the fly' different flow events by following the guidance of his own taste. 
2112  
2113 \section{Kickstart}
2114 \label{kickStart}
2115 We divide the potential users of ALICE flow package into two groups, namely the users which are using AliRoot (default) and the users which are using only Root.   
2116
2117 \subsection{AliRoot users}
2118 To run flow analysis `on the fly' with the default settings within AliRoot and to see the final results obtained from various implemented methods for flow analysis, the user should execute the following steps:
2119 %
2120 \begin{list}{}{}
2121 \item \textbf{Step 1:} Turn off the lights ...
2122 \item \textbf{Step 2:} ... take a deep breath ...
2123 \item \textbf{Step 3:} ... start to copy macros 
2124 \texttt{runFlowAnalysisOnTheFly.C} and \\ \texttt{compareFlowResults.C} from
2125 \texttt{AliRoot/PWG2/FLOW/macros} to your favorite directory slowly. 
2126 \item \textbf{Step 4:} Once you have copied those macros in your favorite directory simply go to that directory and type
2127 %
2128 \begin{center}
2129 \texttt{aliroot runFlowAnalysisOnTheFly.C}
2130 \end{center}
2131 %
2132 \item \textbf{Step 5:} If you have a healthy AliRoot version the flow analysis `on the fly' will start. Once it is finished in your directory you should have the following files: 
2133 %
2134 \begin{center}
2135 \begin{tabular}[t]{l}
2136 \texttt{runFlowAnalysisOnTheFly.C} \\ 
2137 \texttt{compareFlowResults.C} \\ 
2138 \texttt{outputLYZ1PRODanalysis.root} \\ 
2139 \texttt{outputQCanalysis.root} \\
2140 \texttt{outputFQDanalysis.root} \\ 
2141 \texttt{outputLYZ1SUManalysis.root} \\ 
2142 \texttt{outputSPanalysis.root} \\
2143 \texttt{outputGFCanalysis.root} \\
2144 \texttt{outputMCEPanalysis.root}
2145 \end{tabular}
2146 \end{center}
2147 %
2148 Each implemented method for flow analysis produced its own output file holding various output histograms. The final flow results are stored in the common histogram structure implemented in the class \texttt{AliFlowCommonHistResults}. 
2149 \item \textbf{Step 6:} To access and compare those final flow results automatically there is a dedicated macro available, so execute  
2150 %
2151 \begin{center}
2152 \begin{tabular}[t]{l}
2153 \texttt{> aliroot} \\
2154 \texttt{root [0] .x compareFlowResults.C("")}
2155 \end{tabular}
2156 \end{center}
2157 %
2158 \item \textbf{Step 7:} If you want to rerun and get larger statistics modify
2159 %
2160 \begin{center}
2161 \begin{tabular}[t]{l}
2162 \texttt{Int\_t nEvts=440} 
2163 \end{tabular}
2164 \end{center}
2165 %
2166 in the macro \texttt{runFlowAnalysisOnTheFly.C}\,.
2167 \item \textbf{Step 8:} Have fun!
2168 \end{list}
2169 In the next section we outline the steps for the Root users.
2170
2171 \subsection{Root users}
2172 To be written at Nikhef...
2173 \section{Making your own flow events}
2174 \label{makingYourOwnFlowEvents}
2175 This section is common both for AliRoot and Roor users. In this section we outline the procedure the user should follow in order to simulate `on the fly' the events with his own settings by making use of the available setters. Those setters are implemented in the class \texttt{AliFlowEventSimpleMakerOnTheFly} and user shall use them in the macro \texttt{runFlowAnalysisOnTheFly.C}.
2176
2177 \subsection{$p_T$ spectra}
2178 Transverse momentum of particles is sampled from the predefined Boltzmann distribution 
2179 %
2180 \begin{equation}
2181 \frac{dN}{dp_T} = Mp_T\exp\left(-\frac{\sqrt{m^2+p_T^2}}{T}\right)\,,
2182 \label{Boltzmann}
2183 \end{equation}
2184 %
2185 where $M$ is the multiplicity of the event, $T$ is ``temperature'' and $m$ is the mass of the particle. By increasing the parameter $T$ one is increasing the number of high $p_T$ particles and this parameter is the same for all events. On the other hand, multiplicity $M$ will in general vary from event to event. In the macro \texttt{runFlowAnalysisOnTheFly.C} one can modify distribution (\ref{Boltzmann}) by using setter for ``temperature'' $T$ and various setters for multiplicity $M$. 
2186
2187 \vspace{0.5cm}
2188 \noindent\textbf{Example:} \textit{If one wants to increase/decrease the number of high $p_T$ particles, one should modify the line}
2189 %
2190 \begin{center}
2191 \texttt{Double\_t dTemperatureOfRP = 0.44;}
2192 \end{center}
2193 %
2194 \textit{Examples of $p_T$ spectra for two different values of $T$ are shown in Figures~\ref{temperature020} and \ref{temperature050}}.
2195 \vspace{0.5cm}
2196
2197 \begin{figure}
2198 \begin{minipage}[t]{0.5\linewidth} % A minipage that covers half the page
2199 \centering
2200 \includegraphics[width=7.5cm]{figures/temperature020.pdf}
2201 \caption{$T=0.2$ GeV/$c$\,.}
2202 \label{temperature020}
2203 \end{minipage}
2204 \hspace{0.5cm} % To get a little bit of space between the figures
2205 \begin{minipage}[t]{0.5\linewidth}
2206 \centering
2207 \includegraphics[width=7.5cm]{figures/temperature050.pdf}
2208 \caption{$T=0.5$ GeV/$c$\,.}
2209 \label{temperature050}
2210 \end{minipage}
2211 \end{figure} 
2212
2213 \noindent What is shown in Figures~\ref{temperature020} and \ref{temperature050} is only one example of the so called \textit{common control histograms}. They are the histograms organized in the same structure and implemented in the class \texttt{AliFlowCommonHist}. In output file of each method one can access those histograms with \texttt{TBrowser}.
2214
2215 When it comes to multiplicity $M$, one has a choice to sample it event-by-event from two different distributions before plugging its value into Eq. (\ref{Boltzmann}) which than will be used to sample transverse momenta of $M$ particles in that event. 
2216
2217 \vspace{0.5cm}
2218 \noindent\textbf{Example:} \textit{If one wants to sample multiplicity event-by-event from Gaussian distribution with mean 500 and spread 10, one should have the following relevant settings}
2219 %
2220 \begin{center}
2221 \begin{tabular}[t]{l}
2222 \texttt{Bool\_t bMultDistrOfRPsIsGauss = kTRUE;} \\
2223 \texttt{Int\_t iMultiplicityOfRP = 500;} \\
2224 \texttt{Double\_t dMultiplicitySpreadOfRP = 10;}
2225 \end{tabular}
2226 \end{center}
2227 %
2228 \textit{Example plot for multiplicity distribution with these settings is shown in Figure~\ref{multiplicityGauss}}.
2229 \vspace{0.5cm}
2230
2231 \noindent Another way to sample multiplicity event-by-event is by using uniform distribution.
2232
2233 \vspace{0.5cm}
2234 \noindent\textbf{Example:} \textit{If one wants to sample multiplicity event-by-event from uniform distribution in the interval [400,600], one must have the following relevant settings}
2235 %
2236 \begin{center}
2237 \begin{tabular}[t]{l}
2238 \texttt{Bool\_t bMultDistrOfRPsIsGauss = kFALSE;} \\
2239 \texttt{Int\_t iMinMultOfRP = 400;} \\
2240 \texttt{Int\_t iMaxMultOfRP = 600;}
2241 \end{tabular}
2242 \end{center}
2243 %
2244 \textit{Example plot for multiplicity distribution with these settings is shown in Figure~\ref{multiplicityUniform}}.
2245 \vspace{0.5cm}
2246
2247 \begin{figure}
2248 \begin{minipage}[t]{0.5\linewidth} % A minipage that covers half the page
2249 \centering
2250 \includegraphics[width=7.5cm]{figures/multiplicityGauss.pdf}
2251 \caption{Gaussian multiplicity distribution.}
2252 \label{multiplicityGauss}
2253 \end{minipage}
2254 \hspace{0.5cm} % To get a little bit of space between the figures
2255 \begin{minipage}[t]{0.5\linewidth}
2256 \centering
2257 \includegraphics[width=7.5cm]{figures/multiplicityUniform.pdf}
2258 \caption{Uniform multiplicity distribution.}
2259 \label{multiplicityUniform}
2260 \end{minipage}
2261 \end{figure} 
2262
2263 \noindent One can also fix multiplicity to be the same for each event.
2264
2265 \vspace{0.5cm}
2266 \noindent\textbf{Example:} \textit{If one wants to have the same fixed multiplicity of 500 for each event one can use the following settings:}
2267 %
2268 \begin{center}
2269 \begin{tabular}[t]{l}
2270 \texttt{Bool\_t bMultDistrOfRPsIsGauss = kTRUE;} \\
2271 \texttt{Int\_t iMultiplicityOfRP = 500;} \\
2272 \texttt{Double\_t dMultiplicitySpreadOfRP = 0;}
2273 \end{tabular}
2274 \end{center}
2275 %
2276 \vspace{0.5cm}
2277
2278 \noindent These are all manipulations available at the moment with $p_T$ spectra given in Eq. (\ref{Boltzmann}). 
2279
2280 \subsection{Azimuthal distribution}
2281 If the anisotropic flow exists, it will manifest itself in the anisotropic azimuthal distribution of outgoing particles measured with respect to the reaction plane:
2282 %
2283 \begin{equation}
2284 E\frac{d^3 N}{d^3 \vec{p}} = \frac{1}{2\pi} \frac{d^2 N}{p_T dp_T d\eta} \left( 1+\sum_{n=1}^{\infty}2v_n(p_T, \eta) \cos\left( n\left( \phi-\Psi_{\rm RP}\right) \right) \right)\,.
2285 \label{azimuthalDistributionGeneral}
2286 \end{equation}
2287 %
2288 Flow harmonics $v_n$ quantify anisotropic flow and are in general function of transverse momentum $p_T$ and pseudorapidity $\eta$. Orientation of reaction plane $\Psi_{\rm RP}$ fluctuates randomly event-by-event and cannot be measured directly. In the implementation `on the fly' reaction plane is sampled uniformly event-by-event from the interval $[0^{\rm o},360^{\rm o}]$. When it comes to flow harmonics, there are two modes which we outline next.
2289
2290 \subsubsection{Constant flow harmonics}
2291 In this mode all flow harmonics are treated as a constant, event-wise quantities, meaning that for a particular event azimuthal angles of all particles will be sampled from the same azimuthal distribution in which flow harmonics appear just as fixed parameters. The implemented most general azimuthal distribution for this mode reads 
2292 %
2293 \begin{equation}
2294 \frac{dN}{d\phi} = 1+2v_1\cos(\phi-\Psi_{\rm RP})+2v_2\cos(2(\phi-\Psi_{\rm RP}))+2v_4\cos(4(\phi-\Psi_{\rm RP}))\,.
2295 \label{azimuthalDistributionOnlyPhi}
2296 \end{equation}
2297 %
2298 In the macro \texttt{runFlowAnalysisOnTheFly.C} one can use the dedicated setters and have handle on the flow harmonics $v_1$, $v_2$ and $v_4$. The most important harmonic is $v_2$, the so called \textit{elliptic flow}, so we start with it first. 
2299
2300 \vspace{0.5cm}
2301 \noindent\textbf{Example:} \textit{If one wants to sample particle azimuthal angles from azimuthal distribution parameterized only with constant elliptic flow of 5\%, namely}
2302 %
2303 \begin{equation}
2304 \frac{dN}{d\phi} = 1+2\cdot 0.05\cdot\cos(2(\phi-\Psi_{\rm RP}))\,,
2305 \end{equation}
2306 %
2307 \textit{then one should use the following settings}
2308 %
2309 \begin{center}
2310 \begin{tabular}[t]{l}
2311 \texttt{Bool\_t bConstantHarmonics = kTRUE;} \\
2312 \texttt{Bool\_t bV2DistrOfRPsIsGauss = kTRUE;} \\
2313 \texttt{Double\_t dV2RP = 0.05;} \\
2314 \texttt{Double\_t dV2SpreadRP = 0.0;} \\
2315 \texttt{Double\_t dV1RP = 0.0;} \\
2316 \texttt{Double\_t dV1SpreadRP = 0.0;} \\
2317 \texttt{Double\_t dV4RP = 0.0;} \\
2318 \texttt{Double\_t dV4SpreadRP = 0.0;}
2319 \end{tabular}
2320 \end{center}
2321 %
2322 \vspace{0.5cm}
2323
2324 \noindent In this mode the flow coefficients are constant for all particles within particular event, but still the flow coefficients can fluctuate event-by-event. 
2325
2326 \vspace{0.5cm}
2327 \noindent\textbf{Example:} \textit{If one wants to sample particle azimuthal angles from azimuthal distribution parameterized only with elliptic flow which fluctuates event-by-event according to Gaussian distribution with mean 5\% and spread 1\%, than one should use the following settings}
2328 %
2329 \begin{center}
2330 \begin{tabular}[t]{l}
2331 \texttt{Bool\_t bConstantHarmonics = kTRUE;} \\
2332 \texttt{Bool\_t bV2DistrOfRPsIsGauss = kTRUE;} \\
2333 \texttt{Double\_t dV2RP = 0.05;} \\
2334 \texttt{Double\_t dV2SpreadRP = 0.01;} \\
2335 \texttt{Double\_t dV1RP = 0.0;} \\
2336 \texttt{Double\_t dV1SpreadRP = 0.0;} \\
2337 \texttt{Double\_t dV4RP = 0.0;} \\
2338 \texttt{Double\_t dV4SpreadRP = 0.0;}
2339 \end{tabular}
2340 \end{center}
2341 %
2342 \vspace{0.5cm}
2343
2344 \noindent On can also study uniform flow fluctuations.
2345
2346 \vspace{0.5cm}
2347 \noindent\textbf{Example:} \textit{If one wants to sample particle azimuthal angles from azimuthal distribution parameterized only with elliptic flow which fluctuates event-by-event according to uniform distribution in interval [4\%,6\%], than one should use the following settings}
2348 %
2349 \begin{center}
2350 \begin{tabular}[t]{l}
2351 \texttt{Bool\_t bConstantHarmonics = kTRUE;} \\
2352 \texttt{Bool\_t bV2DistrOfRPsIsGauss = kFALSE;} \\
2353 \texttt{Double\_t dMinV2RP = 0.04;} \\
2354 \texttt{Double\_t dMinV2RP = 0.06;} \\
2355 \texttt{Double\_t dV1RP = 0.0;} \\
2356 \texttt{Double\_t dV1SpreadRP = 0.0;} \\
2357 \texttt{Double\_t dV4RP = 0.0;} \\
2358 \texttt{Double\_t dV4SpreadRP = 0.0;}
2359 \end{tabular}
2360 \end{center}
2361 %
2362 \vspace{0.5cm}
2363
2364 \noindent It is of course possible to simulate simultanously nonvanishing $v_1$, $v_2$ and $v_4$. 
2365
2366
2367 \vspace{0.5cm}
2368 \noindent\textbf{Example:} \textit{If one wants to sample particle azimuthal angles from azimuthal distribution parameterized by harmonics $v_1=2\%$, $v_2=5\%$ and $v_4=1\%$, namely}
2369 %
2370 \begin{eqnarray}
2371 \frac{dN}{d\phi} &=& 1+2\cdot 0.02\cdot\cos(\phi-\Psi_{\rm RP})+2\cdot 0.05\cdot\cos(2(\phi-\Psi_{\rm RP}))\nonumber\\
2372 &+&2\cdot 0.01\cdot\cos(4(\phi-\Psi_{\rm RP}))
2373 \end{eqnarray}
2374 %
2375 \textit{then one should use the following settings}
2376 %
2377 \begin{center}
2378 \begin{tabular}[t]{l}
2379 \texttt{Bool\_t bConstantHarmonics = kTRUE;} \\
2380 \texttt{Bool\_t bV2DistrOfRPsIsGauss = kTRUE;} \\
2381 \texttt{Double\_t dV2RP = 0.05;} \\
2382 \texttt{Double\_t dV2SpreadRP = 0.0;} \\
2383 \texttt{Double\_t dV1RP = 0.02;} \\
2384 \texttt{Double\_t dV1SpreadRP = 0.0;} \\
2385 \texttt{Double\_t dV4RP = 0.01;} \\
2386 \texttt{Double\_t dV4SpreadRP = 0.0;}
2387 \end{tabular}
2388 \end{center}
2389 %
2390 \vspace{0.5cm}
2391
2392 \noindent In the next section we outline the procedure for simulating flow events with $p_T$ dependent flow harmonics.
2393
2394 \subsubsection{$p_T$ dependent flow harmonics}
2395 In this mode the functional dependence of flow harmonics on transverse momentum is treated as an event-wise quantity, while within the particular event the flow harmonics will change from particle to particle depending on its transverse momentum. The implemented azimuthal distribution for this case reads 
2396 %
2397 \begin{equation}
2398 \frac{dN}{d\phi} = 1+2v_2(p_T)\cos(2(\phi-\Psi_{\rm RP}))\,,
2399 \label{azimuthalDistributionOnlyPtDependent}
2400 \end{equation}
2401 %
2402 and the functional dependence $v_2(p_T)$ is implemented as follows:
2403 %
2404 \begin{equation}
2405 v_2(p_T) = \left\{
2406 \begin{array}{ll}
2407 v_{\rm max}(p_T/p_{\rm cutoff}) & p_T < p_{\rm cutoff}\,, \\
2408 v_{\rm max} & p_T \geq p_{\rm cutoff}\,. \\
2409 \end{array}
2410 \right.
2411 \label{v(pt)parametrization}
2412 \end{equation}
2413 %
2414 In the macro \texttt{runFlowAnalysisOnTheFly.C} one can have the handle on the parameters $v_{\rm max}$ and $p_{\rm cutoff}$.
2415
2416 \vspace{0.5cm}
2417 \noindent\textbf{Example:} \textit{If one wants to set $v_{\rm max} = 0.2$ and $p_{\rm cutoff} = 2$ GeV/$c$, than one should use the following settings:}
2418 %
2419 \begin{center}
2420 \begin{tabular}[t]{l}
2421 \texttt{Bool\_t bConstantHarmonics = kFALSE;} \\
2422 \texttt{Double\_t dV2RPMax = 0.20;} \\
2423 \texttt{Double\_t dPtCutOff = 2.0;}
2424 \end{tabular}
2425 \end{center}
2426 %
2427 \textit{Example plot is given in Figure~\ref{vVsPt}}.
2428 \vspace{0.5cm}
2429
2430 %
2431 \begin{figure}
2432 \begin{center}
2433   \includegraphics[width=7.5cm,angle=0]{figures/vVsPt.pdf}
2434   \caption{$p_T$ dependent elliptic flow.}
2435 \label{vVsPt}
2436 \end{center}
2437 \end{figure}
2438 %
2439
2440 (Remark: Add further explanation here.)
2441
2442 \subsection{Nonflow}
2443 One can simply simulate strong 2-particle nonflow correlations by taking each particle twice.  
2444
2445 \vspace{0.5cm}
2446 \noindent\textbf{Example:} \textit{If one wants to simulate strong 2-particle nonflow correlations one should simply set}
2447 %
2448 \begin{center}
2449 \texttt{Int\_t iLoops = 2;}
2450 \end{center}
2451 %
2452 \vspace{0.5cm}
2453
2454 \subsection{Detector inefficiencies}
2455 In reality we never deal with a detector with uniform azimuthal coverage, hence a need for a thorough studies of the systematic bias originating from the non-uniform acceptance.
2456
2457 \vspace{0.5cm}
2458 \noindent\textbf{Example:} \textit{One wants to simulate a detector whose acceptance is uniform except for the sector which spans the azimuthal interval $[60^{\rm o},120^{\rm o}]$. In this sector there are some issues, so only half of the particles are reconstructed. To simulate this acceptance one should use the following settings:}
2459 %
2460 \begin{center}
2461 \begin{tabular}[t]{l}
2462 \texttt{Bool\_t uniformAcceptance = kFALSE;} \\
2463 \texttt{Double\_t phimin1 = 60;} \\
2464 \texttt{Double\_t phimax1 = 120;} \\
2465 \texttt{Double\_t p1 = 1/2.;} \\
2466 \texttt{Double\_t phimin2 = 0.0;} \\
2467 \texttt{Double\_t phimax2 = 0.0;} \\
2468 \texttt{Double\_t p2 = 0.0;} 
2469 \end{tabular}
2470 \end{center}
2471 %
2472 \textit{The resulting azimuthal profile is shown in Figure~(\ref{azimuthalAcceptanceOneSector})}.
2473 \vspace{0.5cm}
2474
2475 \noindent One can also simulate two problematic sectors.
2476
2477 \vspace{0.5cm}
2478 \noindent\textbf{Example:} \textit{One wants to simulate a detector whose acceptance is uniform except for the two sectors which span azimuth $[60^{\rm o}, 120^{\rm o}]$ and $[270^{\rm o}, 330^{\rm o}]$, respectively. In the first sector only 1/2 of the particles are reconstructed and only 1/3 of the particles are reconstructed in the second. To simulate this acceptance one should use the following settings:}
2479 %
2480 \begin{center}
2481 \begin{tabular}[t]{l}
2482 \texttt{Bool\_t uniformAcceptance = kFALSE;} \\
2483 \texttt{Double\_t phimin1 = 60;} \\
2484 \texttt{Double\_t phimax1 = 120;} \\
2485 \texttt{Double\_t p1 = 1/2.;} \\
2486 \texttt{Double\_t phimin2 = 270.0;} \\
2487 \texttt{Double\_t phimax2 = 330.0;} \\
2488 \texttt{Double\_t p2 = 1/3.;} 
2489 \end{tabular}
2490 \end{center}
2491 %
2492 \textit{The resulting azimuthal profile is shown in Figure~(\ref{azimuthalAcceptanceTwoSectors})}.
2493 \vspace{0.5cm}
2494
2495 \begin{figure}
2496 \begin{minipage}[t]{0.5\linewidth} % A minipage that covers half the page
2497 \centering
2498 \includegraphics[width=7.5cm]{figures/azimuthalAcceptanceOneSector.pdf}
2499 \caption{Non-uniform acceptance.}
2500 \label{azimuthalAcceptanceOneSector}
2501 \end{minipage}
2502 \hspace{0.5cm} % To get a little bit of space between the figures
2503 \begin{minipage}[t]{0.5\linewidth}
2504 \centering
2505 \includegraphics[width=7.5cm]{figures/azimuthalAcceptanceTwoSectors.pdf}
2506 \caption{Non-uniform acceptance.}
2507 \label{azimuthalAcceptanceTwoSectors}
2508 \end{minipage}
2509 \end{figure} 
2510 \printindex
2511 \end{document}