V2 calculation added
[u/mrichter/AliRoot.git] / ANALYSIS / AliFlowAnalysis.cxx
CommitLineData
b26900d0 1#include "AliFlowAnalysis.h"
2//________________________________
3///////////////////////////////////////////////////////////
4//
5// class AliFlowAnalysis
6//
7// Flow Analysis
8//
9//
10// S.Radomski@gsi.de
11// Piotr.Skowronski@cern.ch
12//
13///////////////////////////////////////////////////////////
14/*********************************************************/
15
16#include <TString.h>
17#include <TParticle.h>
18
19#include <AliStack.h>
20#include <AliESDtrack.h>
21#include <AliESD.h>
22
23ClassImp(AliFlowAnalysis)
24
25Int_t AliFlowAnalysis::Init()
26{
27 //Initilizes anaysis
28 Info("Init","");
29 return 0;
30}
31
32/*********************************************************/
33
34Int_t AliFlowAnalysis::ProcessEvent(AliESD* esd, AliStack* stack)
35{
36
37 Info("ProcessEvent","Stack address %#x",stack);
38 Double_t psi = GetEventPlane(esd);
39 Info("ProcessEvent","Event plane is %f",psi);
40 return 0;
41
42}
43/*********************************************************/
44
45Int_t AliFlowAnalysis::Finish()
46{
47 //Finish analysis and writes results
48 Info("Init","Finish");
49 return 0;
50}
51/*********************************************************/
52
53Double_t AliFlowAnalysis::GetEventPlane(AliESD* esd)
54{
55 //returns event plane
e6577ac7 56 if (esd == 0x0)
57 {
58 ::Error("GetFlow","Pointer to ESD is NULL");
59 return -1.0;
60 }
61
b26900d0 62 Double_t psi;
63 Int_t mult = esd->GetNumberOfTracks();
64
65 Double_t ssin = 0, scos = 0;
66
67 for (Int_t i=0; i<mult; i++)
68 {
69 AliESDtrack* esdtrack = esd->GetTrack(i);
70 if (esdtrack == 0x0)
71 {
72 ::Error("GetEventPlane","Can not get track %d", i);
73 continue;
74 }
75
76 Double_t mom[3];//momentum
77 esdtrack->GetPxPyPz(mom);
78 Double_t phi = TMath::Pi()+TMath::ATan2(-mom[1],-mom[0]);
79
80 ssin += TMath::Sin( 2.0 * phi );
81 scos += TMath::Cos( 2.0 * phi );
82 }
83
84 psi = atan2 (ssin, scos) / 2.0;
85 psi = psi * 180. / TMath::Pi();
86
87 return psi;
88
89}
e6577ac7 90
91void AliFlowAnalysis::GetFlow(AliESD* esd,Double_t& v2,Double_t& psi)
92{
93//returns flow parameters: v2 and event plane
94 if (esd == 0x0)
95 {
96 ::Error("GetFlow","Pointer to ESD is NULL");
97 return;
98 }
99
100 psi = GetEventPlane(esd);
101 Int_t mult = esd->GetNumberOfTracks();
102
103 Double_t ssin = 0, scos = 0;
104
105 for (Int_t i=0; i<mult; i++)
106 {
107 AliESDtrack* esdtrack = esd->GetTrack(i);
108 if (esdtrack == 0x0)
109 {
110 ::Error("GetEventPlane","Can not get track %d", i);
111 continue;
112 }
113
114 Double_t mom[3];//momentum
115 esdtrack->GetPxPyPz(mom);
116 Double_t phi = TMath::Pi()+TMath::ATan2(-mom[1],-mom[0]);
117
118 ssin += TMath::Sin( 2.0 * (phi - psi));
119 scos += TMath::Cos( 2.0 * (phi - psi));
120 }
121
122 v2 = TMath::Hypot(ssin,scos);
123}