]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/AliFlowAnalysis.cxx
from Y. Schutz
[u/mrichter/AliRoot.git] / ANALYSIS / AliFlowAnalysis.cxx
1 #include "AliFlowAnalysis.h"
2
3 //*********************************************************
4 // class AliFlowAnalysis
5 // Flow Analysis
6 // S.Radomski@gsi.de
7 // Piotr.Skowronski@cern.ch
8 //*********************************************************
9
10 #include <AliAOD.h>
11 #include <AliVAODParticle.h>
12 #include <AliAODParticleCut.h>
13
14 #include <AliESDtrack.h>
15 #include <AliESD.h>
16
17 ClassImp(AliFlowAnalysis)
18
19 AliFlowAnalysis::AliFlowAnalysis():
20  fPartCut(0x0)
21 {
22  //ctor
23 }
24 /*********************************************************/
25
26 AliFlowAnalysis::~AliFlowAnalysis()
27 {
28  //dtor
29   delete fPartCut;
30 }
31 /*********************************************************/
32
33 Int_t AliFlowAnalysis::Init()
34 {
35   //Initilizes anaysis
36   Info("Init","");
37   return 0; 
38 }
39 /*********************************************************/
40
41 Int_t AliFlowAnalysis::ProcessEvent(AliAOD* aodrec, AliAOD* aodsim)
42 {
43   // Process AOD events containing the reconstructed and simulated information
44   Info("ProcessEvent","Sim AOD address %#x",aodsim);
45   Double_t psi = 0, v2 = 0;
46   if (aodrec)
47    {
48      GetFlow(aodrec,v2,psi);
49      Info("ProcessEvent","Reconstructed Event: Event plane is %f, V2 is %f",psi,v2);
50    }  
51
52   if (aodsim)
53    {
54      GetFlow(aodsim,v2,psi);
55      Info("ProcessEvent","Simulated Event: Event plane is %f, V2 is %f",psi,v2);
56    }  
57   
58   return 0;
59   
60 }
61 /*********************************************************/
62
63 Int_t AliFlowAnalysis::Finish()
64 {
65   //Finish analysis and writes results
66   Info("Init","Finish");
67   return 0;
68 }
69 /*********************************************************/
70
71 Double_t AliFlowAnalysis::GetEventPlane(AliAOD* aod)
72 {
73   //returns event plane in degrees
74   if (aod == 0x0)
75    {
76      Error("AliFlowAnalysis::GetFlow","Pointer to AOD is NULL");
77      return -1.0;
78    }
79
80   Double_t psi;
81   Int_t mult = aod->GetNumberOfParticles();
82   
83   Double_t ssin = 0, scos = 0;
84
85   for (Int_t i=0; i<mult; i++) 
86    {
87      AliVAODParticle* aodtrack = aod->GetParticle(i);
88      if (aodtrack == 0x0)
89       {
90         Error("AliFlowAnalysis::GetEventPlane","Can not get track %d", i);
91         continue;
92       }
93      
94      if (fPartCut)
95       if (fPartCut->Rejected(aodtrack))
96         continue;
97
98      Double_t phi = TMath::Pi()+TMath::ATan2(-aodtrack->Py(),-aodtrack->Px()); 
99      
100      ssin += TMath::Sin( 2.0 * phi );
101      scos += TMath::Cos( 2.0 * phi );
102    }
103
104   psi = atan2 (ssin, scos) / 2.0;
105   psi = psi * 180. / TMath::Pi(); 
106   
107   return psi;
108
109 }
110 /*********************************************************/
111
112 void AliFlowAnalysis::GetFlow(AliAOD* aod,Double_t& v2,Double_t& psi)
113 {
114 //returns flow parameters: v2 and event plane
115   if (aod == 0x0)
116    {
117      Error("AliFlowAnalysis::GetFlow","Pointer to AOD is NULL");
118      return;
119    }
120    
121   psi = GetEventPlane(aod);
122   Int_t mult = aod->GetNumberOfParticles();
123   
124   Double_t ssin = 0, scos = 0;
125
126   for (Int_t i=0; i<mult; i++) 
127    {
128      AliVAODParticle* aodtrack = aod->GetParticle(i);
129      if (aodtrack == 0x0)
130       {
131         Error("AliFlowAnalysis::GetEventPlane","Can not get track %d", i);
132         continue;
133       }
134      if (fPartCut)
135       if (fPartCut->Rejected(aodtrack))
136         continue;
137       
138      Double_t phi = TMath::Pi()+TMath::ATan2(-aodtrack->Py(),-aodtrack->Px()); 
139      ssin += TMath::Sin( 2.0 * (phi - psi));
140      scos += TMath::Cos( 2.0 * (phi - psi));
141    }
142    
143   v2 = TMath::Hypot(ssin,scos);
144 }
145
146
147 /*********************************************************/
148
149 Double_t AliFlowAnalysis::GetEventPlane(AliESD* esd)
150 {
151   //returns event plane
152   if (esd == 0x0)
153    {
154      ::Error("AliFlowAnalysis::GetFlow","Pointer to ESD is NULL");
155      return -1.0;
156    }
157
158   Double_t psi;
159   Int_t mult = esd->GetNumberOfTracks();
160   
161   Double_t ssin = 0, scos = 0;
162
163   for (Int_t i=0; i<mult; i++) 
164    {
165      AliESDtrack* esdtrack = esd->GetTrack(i);
166      if (esdtrack == 0x0)
167       {
168         ::Error("AliFlowAnalysis::GetEventPlane","Can not get track %d", i);
169         continue;
170       }
171       
172      Double_t mom[3];//momentum
173      esdtrack->GetPxPyPz(mom); 
174      Double_t phi = TMath::Pi()+TMath::ATan2(-mom[1],-mom[0]); 
175      
176      ssin += TMath::Sin( 2.0 * phi );
177      scos += TMath::Cos( 2.0 * phi );
178    }
179
180   psi = atan2 (ssin, scos) / 2.0;
181   psi = psi * 180. / TMath::Pi(); 
182   
183   return psi;
184
185 }
186 /*********************************************************/
187
188 void AliFlowAnalysis::GetFlow(AliESD* esd,Double_t& v2,Double_t& psi)
189 {
190 //returns flow parameters: v2 and event plane
191   if (esd == 0x0)
192    {
193      ::Error("AliFlowAnalysis::GetFlow","Pointer to ESD is NULL");
194      return;
195    }
196    
197   psi = GetEventPlane(esd);
198   Int_t mult = esd->GetNumberOfTracks();
199   
200   Double_t ssin = 0, scos = 0;
201
202   for (Int_t i=0; i<mult; i++) 
203    {
204      AliESDtrack* esdtrack = esd->GetTrack(i);
205      if (esdtrack == 0x0)
206       {
207         ::Error("AliFlowAnalysis::GetEventPlane","Can not get track %d", i);
208         continue;
209       }
210       
211      Double_t mom[3];//momentum
212      esdtrack->GetPxPyPz(mom); 
213      Double_t phi = TMath::Pi()+TMath::ATan2(-mom[1],-mom[0]); 
214      
215      ssin += TMath::Sin( 2.0 * (phi - psi));
216      scos += TMath::Cos( 2.0 * (phi - psi));
217    }
218    
219   v2 = TMath::Hypot(ssin,scos);
220 }
221 /*********************************************************/