]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/AliFlowCommon/AliFlowAnalysisWithMCEventPlane.cxx
added 3D histograms
[u/mrichter/AliRoot.git] / PWG2 / FLOW / AliFlowCommon / AliFlowAnalysisWithMCEventPlane.cxx
CommitLineData
f1d945a1 1/*************************************************************************
2* Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
3* *
4* Author: The ALICE Off-line Project. *
5* Contributors are mentioned in the code where appropriate. *
6* *
7* Permission to use, copy, modify and distribute this software and its *
8* documentation strictly for non-commercial purposes is hereby granted *
9* without fee, provided that the above copyright notice appears in all *
10* copies and that both the copyright notice and this permission notice *
11* appear in the supporting documentation. The authors make no claims *
12* about the suitability of this software for any purpose. It is *
13* provided "as is" without express or implied warranty. *
14**************************************************************************/
15
16#define AliFlowAnalysisWithMCEventPlane_cxx
17
18#include "Riostream.h" //needed as include
19#include "TFile.h" //needed as include
20#include "TProfile.h" //needed as include
9cc9e6cc 21#include "TProfile2D.h"
f1d945a1 22#include "TComplex.h" //needed as include
28ca24ad 23#include "TList.h"
f1d945a1 24
25class TH1F;
26
27#include "AliFlowCommonConstants.h" //needed as include
28#include "AliFlowEventSimple.h"
29#include "AliFlowTrackSimple.h"
30#include "AliFlowCommonHist.h"
31#include "AliFlowCommonHistResults.h"
32#include "AliFlowAnalysisWithMCEventPlane.h"
33
34class AliFlowVector;
35
36// AliFlowAnalysisWithMCEventPlane:
37// Description: Maker to analyze Flow from the generated MC reaction plane.
38// This class is used to get the real value of the flow
39// to compare the other methods to when analysing simulated events
40// author: N. van der Kolk (kolk@nikhef.nl)
41
42ClassImp(AliFlowAnalysisWithMCEventPlane)
43
44 //-----------------------------------------------------------------------
45
46 AliFlowAnalysisWithMCEventPlane::AliFlowAnalysisWithMCEventPlane():
0092f3c2 47 fQsum(NULL),
f1d945a1 48 fQ2sum(0),
49 fEventNumber(0),
f1d945a1 50 fDebug(kFALSE),
28ca24ad 51 fHistList(NULL),
8232a5ec 52 fCommonHists(NULL),
53 fCommonHistsRes(NULL),
45cdbef2 54 fHistRP(NULL),
3963f25c 55 fHistProIntFlow(NULL),
9cc9e6cc 56 fHistProDiffFlowPtEtaRP(NULL),
45cdbef2 57 fHistProDiffFlowPtRP(NULL),
58 fHistProDiffFlowEtaRP(NULL),
9cc9e6cc 59 fHistProDiffFlowPtEtaPOI(NULL),
45cdbef2 60 fHistProDiffFlowPtPOI(NULL),
61 fHistProDiffFlowEtaPOI(NULL)
f1d945a1 62{
63
64 // Constructor.
28ca24ad 65 fHistList = new TList();
66
0092f3c2 67 fQsum = new TVector2; // flow vector sum
f1d945a1 68}
69
70
71 //-----------------------------------------------------------------------
72
73
74 AliFlowAnalysisWithMCEventPlane::~AliFlowAnalysisWithMCEventPlane()
75 {
76 //destructor
28ca24ad 77 delete fHistList;
0092f3c2 78 delete fQsum;
f1d945a1 79 }
80
7ebf0358 81//-----------------------------------------------------------------------
82
83void AliFlowAnalysisWithMCEventPlane::WriteHistograms(TString* outputFileName)
84{
85 //store the final results in output .root file
86 TFile *output = new TFile(outputFileName->Data(),"RECREATE");
7a2c2652 87 output->WriteObject(fHistList, "cobjMCEP","SingleKey");
7ebf0358 88 delete output;
89}
f1d945a1 90
91//-----------------------------------------------------------------------
b0fda271 92
93void AliFlowAnalysisWithMCEventPlane::WriteHistograms(TString outputFileName)
94{
95 //store the final results in output .root file
96 TFile *output = new TFile(outputFileName.Data(),"RECREATE");
97 output->WriteObject(fHistList, "cobjMCEP","SingleKey");
98 delete output;
99}
100
101//-----------------------------------------------------------------------
f1d945a1 102void AliFlowAnalysisWithMCEventPlane::Init() {
103
104 //Define all histograms
105 cout<<"---Analysis with the real MC Event Plane---"<<endl;
106
00731146 107 Int_t iNbinsPt = AliFlowCommonConstants::GetNbinsPt();
45cdbef2 108 Double_t dPtMin = AliFlowCommonConstants::GetPtMin();
109 Double_t dPtMax = AliFlowCommonConstants::GetPtMax();
110
111 Int_t iNbinsEta = AliFlowCommonConstants::GetNbinsEta();
112 Double_t dEtaMin = AliFlowCommonConstants::GetEtaMin();
113 Double_t dEtaMax = AliFlowCommonConstants::GetEtaMax();
f1d945a1 114
9d062fe3 115 fCommonHists = new AliFlowCommonHist("AliFlowCommonHistMCEP");
116 fHistList->Add(fCommonHists);
117 fCommonHistsRes = new AliFlowCommonHistResults("AliFlowCommonHistResultsMCEP");
118 fHistList->Add(fCommonHistsRes);
119
9d062fe3 120 fHistRP = new TH1F("Flow_RP_MCEP","Flow_RP_MCEP",100,0.,3.14);
f1d945a1 121 fHistRP->SetXTitle("Reaction Plane Angle");
122 fHistRP->SetYTitle("Counts");
28ca24ad 123 fHistList->Add(fHistRP);
45cdbef2 124
b7cb54d5 125 fHistProIntFlow = new TProfile("FlowPro_V_MCEP","FlowPro_V_MCEP",1,0.,1.);
3963f25c 126 fHistProIntFlow->SetLabelSize(0.06);
127 (fHistProIntFlow->GetXaxis())->SetBinLabel(1,"v_{n}{2}");
128 fHistProIntFlow->SetYTitle("");
129 fHistList->Add(fHistProIntFlow);
9cc9e6cc 130
131 fHistProDiffFlowPtEtaRP = new TProfile2D("FlowPro_VPtEtaRP_MCEP","FlowPro_VPtEtaRP_MCEP",iNbinsPt,dPtMin,dPtMax,iNbinsEta,dEtaMin,dEtaMax);
132 fHistProDiffFlowPtEtaRP->SetXTitle("P_{t}");
133 fHistProDiffFlowPtEtaRP->SetYTitle("#eta");
134 fHistList->Add(fHistProDiffFlowPtEtaRP);
45cdbef2 135
b7cb54d5 136 fHistProDiffFlowPtRP = new TProfile("FlowPro_VPtRP_MCEP","FlowPro_VPtRP_MCEP",iNbinsPt,dPtMin,dPtMax);
45cdbef2 137 fHistProDiffFlowPtRP->SetXTitle("P_{t}");
138 fHistProDiffFlowPtRP->SetYTitle("");
139 fHistList->Add(fHistProDiffFlowPtRP);
140
b7cb54d5 141 fHistProDiffFlowEtaRP = new TProfile("FlowPro_VetaRP_MCEP","FlowPro_VetaRP_MCEP",iNbinsEta,dEtaMin,dEtaMax);
45cdbef2 142 fHistProDiffFlowEtaRP->SetXTitle("#eta");
143 fHistProDiffFlowEtaRP->SetYTitle("");
144 fHistList->Add(fHistProDiffFlowEtaRP);
145
9cc9e6cc 146 fHistProDiffFlowPtEtaPOI = new TProfile2D("FlowPro_VPtEtaPOI_MCEP","FlowPro_VPtEtaPOI_MCEP",iNbinsPt,dPtMin,dPtMax,iNbinsEta,dEtaMin,dEtaMax);
147 fHistProDiffFlowPtEtaPOI->SetXTitle("P_{t}");
148 fHistProDiffFlowPtEtaPOI->SetYTitle("#eta");
149 fHistList->Add(fHistProDiffFlowPtEtaPOI);
150
b7cb54d5 151 fHistProDiffFlowPtPOI = new TProfile("FlowPro_VPtPOI_MCEP","FlowPro_VPtPOI_MCEP",iNbinsPt,dPtMin,dPtMax);
45cdbef2 152 fHistProDiffFlowPtPOI->SetXTitle("P_{t}");
153 fHistProDiffFlowPtPOI->SetYTitle("");
154 fHistList->Add(fHistProDiffFlowPtPOI);
155
b7cb54d5 156 fHistProDiffFlowEtaPOI = new TProfile("FlowPro_VetaPOI_MCEP","FlowPro_VetaPOI_MCEP",iNbinsEta,dEtaMin,dEtaMax);
45cdbef2 157 fHistProDiffFlowEtaPOI->SetXTitle("#eta");
158 fHistProDiffFlowEtaPOI->SetYTitle("");
159 fHistList->Add(fHistProDiffFlowEtaPOI);
f1d945a1 160
161 fEventNumber = 0; //set number of events to zero
162
163}
164
165//-----------------------------------------------------------------------
166
d7671632 167void AliFlowAnalysisWithMCEventPlane::Make(AliFlowEventSimple* anEvent) {
f1d945a1 168
169 //Calculate v2 from the MC reaction plane
8232a5ec 170 if (anEvent) {
d7671632 171
172 // get the MC reaction plane angle
173 Double_t aRP = anEvent->GetMCReactionPlaneAngle();
f1d945a1 174 //fill control histograms
8232a5ec 175 fCommonHists->FillControlHistograms(anEvent);
f1d945a1 176
177 //get the Q vector from the FlowEvent
00731146 178 AliFlowVector vQ = anEvent->GetQ();
179 //cout<<"vQ.Mod() = " << vQ.Mod() << endl;
f1d945a1 180 //for chi calculation:
00731146 181 *fQsum += vQ;
f1d945a1 182 //cout<<"fQsum.Mod() = "<<fQsum.Mod()<<endl;
00731146 183 fQ2sum += vQ.Mod2();
9d062fe3 184 //cout<<"fQ2sum = "<<fQ2sum<<endl;
f1d945a1 185
00731146 186 fHistRP->Fill(aRP);
45cdbef2 187
188 Double_t dPhi = 0.;
189 Double_t dv2 = 0.;
190 Double_t dPt = 0.;
191 Double_t dEta = 0.;
192 //Double_t dPi = TMath::Pi();
193
f1d945a1 194 //calculate flow
195 //loop over the tracks of the event
00731146 196 Int_t iNumberOfTracks = anEvent->NumberOfTracks();
197 for (Int_t i=0;i<iNumberOfTracks;i++)
f1d945a1 198 {
00731146 199 AliFlowTrackSimple* pTrack = anEvent->GetTrack(i) ;
200 if (pTrack){
b7cb54d5 201 if (pTrack->InRPSelection()){
45cdbef2 202 dPhi = pTrack->Phi();
b7cb54d5 203 dv2 = TMath::Cos(2*(dPhi-aRP));
204 dPt = pTrack->Pt();
45cdbef2 205 dEta = pTrack->Eta();
3963f25c 206 //no-name int. flow (to be improved):
207 fHistProIntFlow->Fill(0.,dv2);
9cc9e6cc 208 //differential flow (Pt, Eta, RP):
209 fHistProDiffFlowPtEtaRP->Fill(dPt,dEta,dv2,1.);
45cdbef2 210 //differential flow (Pt, RP):
211 fHistProDiffFlowPtRP->Fill(dPt,dv2,1.);
212 //differential flow (Eta, RP):
213 fHistProDiffFlowEtaRP->Fill(dEta,dv2,1.);
214 }
b7cb54d5 215 if (pTrack->InPOISelection()) {
45cdbef2 216 dPhi = pTrack->Phi();
00731146 217 //if (dPhi<0.) dPhi+=2*TMath::Pi();
f1d945a1 218 //calculate flow v2:
b7cb54d5 219 dv2 = TMath::Cos(2*(dPhi-aRP));
220 dPt = pTrack->Pt();
45cdbef2 221 dEta = pTrack->Eta();
9cc9e6cc 222 //differential flow (Pt, Eta, POI):
223 fHistProDiffFlowPtEtaPOI->Fill(dPt,dEta,dv2,1.);
45cdbef2 224 //differential flow (Pt, POI):
225 fHistProDiffFlowPtPOI->Fill(dPt,dv2,1.);
226 //differential flow (Eta, POI):
227 fHistProDiffFlowEtaPOI->Fill(dEta,dv2,1.);
228 }
f1d945a1 229 }//track selected
230 }//loop over tracks
231
232 fEventNumber++;
deebd72f 233 // cout<<"@@@@@ "<<fEventNumber<<" events processed"<<endl;
f1d945a1 234 }
235}
236
237 //--------------------------------------------------------------------
238void AliFlowAnalysisWithMCEventPlane::Finish() {
239
240 //*************make histograms etc.
241 if (fDebug) cout<<"AliFlowAnalysisWithMCEventPlane::Terminate()"<<endl;
9d062fe3 242
45cdbef2 243 Int_t iNbinsPt = AliFlowCommonConstants::GetNbinsPt();
244 Int_t iNbinsEta = AliFlowCommonConstants::GetNbinsEta();
245
3963f25c 246 // no-name int. flow (to be improved):
247 Double_t dV = fHistProIntFlow->GetBinContent(1);
248 Double_t dErrV = fHistProIntFlow->GetBinError(1); // to be improved (treatment of errors for non-Gaussian distribution needed!)
249 // fill no-name int. flow (to be improved):
250 fCommonHistsRes->FillIntegratedFlow(dV,dErrV);
251 cout<<"dV{MC} is "<<dV<<" +- "<<dErrV<<endl;
65af4339 252
3963f25c 253 //RP:
b7cb54d5 254 TH1F* fHistPtRP = fCommonHists->GetHistPtRP();
3963f25c 255 Double_t dYieldPtRP = 0.;
256 Double_t dVRP = 0.;
257 Double_t dErrVRP = 0.;
258 Double_t dSumRP = 0.;
259 //differential flow (RP, Pt):
45cdbef2 260 Double_t dvPtRP = 0.;
261 Double_t dErrvPtRP = 0.;
3963f25c 262 for(Int_t b=1;b<iNbinsPt;b++)
45cdbef2 263 {
3963f25c 264 dvPtRP = fHistProDiffFlowPtRP->GetBinContent(b);
265 dErrvPtRP = fHistProDiffFlowPtRP->GetBinError(b);//to be improved (treatment of errors for non-Gaussian distribution needed!)
266 fCommonHistsRes->FillDifferentialFlowPtRP(b, dvPtRP, dErrvPtRP);
267 if(fHistPtRP){
268 //integrated flow (RP)
269 dYieldPtRP = fHistPtRP->GetBinContent(b);
270 dVRP += dvPtRP*dYieldPtRP;
271 dSumRP += dYieldPtRP;
272 //error on integrated flow
273 dErrVRP += dYieldPtRP*dYieldPtRP*dErrvPtRP*dErrvPtRP;
274 }
45cdbef2 275 }
3963f25c 276 if (dSumRP != 0. ) {
277 dVRP /= dSumRP; //because pt distribution should be normalised
278 dErrVRP /= (dSumRP*dSumRP);
279 dErrVRP = TMath::Sqrt(dErrVRP);
280 }
281 // fill integrated flow (RP):
282 fCommonHistsRes->FillIntegratedFlowRP(dVRP,dErrVRP);
283 cout<<"dV{MC} (RP) is "<<dVRP<<" +- "<<dErrVRP<<endl;
65af4339 284
3963f25c 285 //differential flow (RP, Eta):
45cdbef2 286 Double_t dvEtaRP = 0.;
287 Double_t dErrvEtaRP = 0.;
3963f25c 288 for(Int_t b=1;b<iNbinsEta;b++)
45cdbef2 289 {
3963f25c 290 dvEtaRP = fHistProDiffFlowEtaRP->GetBinContent(b);
291 dErrvEtaRP = fHistProDiffFlowEtaRP->GetBinError(b);//to be improved (treatment of errors for non-Gaussian distribution needed!)
292 fCommonHistsRes->FillDifferentialFlowEtaRP(b, dvEtaRP, dErrvEtaRP);
45cdbef2 293 }
294
295 //POI:
b7cb54d5 296 TH1F* fHistPtPOI = fCommonHists->GetHistPtPOI();
3963f25c 297 Double_t dYieldPtPOI = 0.;
298 Double_t dVPOI = 0.;
299 Double_t dErrVPOI = 0.;
300 Double_t dSumPOI = 0.;
301 Double_t dv2proPtPOI = 0.;
302 Double_t dErrdifcombPtPOI = 0.;
303 Double_t dv2proEtaPOI = 0.;
304 Double_t dErrdifcombEtaPOI = 0.;
45cdbef2 305 //Pt:
b7cb54d5 306 if(fHistProDiffFlowPtPOI) {
3963f25c 307 for(Int_t b=1;b<iNbinsPt;b++){
3963f25c 308 dv2proPtPOI = fHistProDiffFlowPtPOI->GetBinContent(b);
309 dErrdifcombPtPOI = fHistProDiffFlowPtPOI->GetBinError(b);//to be improved (treatment of errors for non-Gaussian distribution needed!)
f1d945a1 310 //fill TH1D
3963f25c 311 fCommonHistsRes->FillDifferentialFlowPtPOI(b, dv2proPtPOI, dErrdifcombPtPOI);
312 if (fHistPtPOI){
65af4339 313 //integrated flow (POI)
3963f25c 314 dYieldPtPOI = fHistPtPOI->GetBinContent(b);
315 dVPOI += dv2proPtPOI*dYieldPtPOI;
316 dSumPOI += dYieldPtPOI;
f1d945a1 317 //error on integrated flow
3963f25c 318 dErrVPOI += dYieldPtPOI*dYieldPtPOI*dErrdifcombPtPOI*dErrdifcombPtPOI;
f1d945a1 319 }
65af4339 320 }//end of for(Int_t b=0;b<iNbinsPt;b++)
45cdbef2 321 } else { cout<<"fHistProFlow is NULL"<<endl; }
3963f25c 322 if (dSumPOI != 0. ) {
323 dVPOI /= dSumPOI; //because pt distribution should be normalised
324 dErrVPOI /= (dSumPOI*dSumPOI);
325 dErrVPOI = TMath::Sqrt(dErrVPOI);
65af4339 326 }
3963f25c 327 cout<<"dV{MC} (POI) is "<<dVPOI<<" +- "<<dErrVPOI<<endl;
328
329 fCommonHistsRes->FillIntegratedFlowPOI(dVPOI,dErrVPOI);
45cdbef2 330
45cdbef2 331 //Eta:
332 if(fHistProDiffFlowEtaPOI)
333 {
3963f25c 334 for(Int_t b=1;b<iNbinsEta;b++)
45cdbef2 335 {
3963f25c 336 dv2proEtaPOI = fHistProDiffFlowEtaPOI->GetBinContent(b);
337 dErrdifcombEtaPOI = fHistProDiffFlowEtaPOI->GetBinError(b);//to be improved (treatment of errors for non-Gaussian distribution needed!)
45cdbef2 338 //fill common hist results:
3963f25c 339 fCommonHistsRes->FillDifferentialFlowEtaPOI(b, dv2proEtaPOI, dErrdifcombEtaPOI);
45cdbef2 340 }
65af4339 341 }
3963f25c 342
343 cout<<endl;
b7cb54d5 344 //cout<<".....finished"<<endl;
9d062fe3 345}
f1d945a1 346
347
9d062fe3 348