1 /*************************************************************************
2 * Copyright(c) 1998-2008, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 #define AliFlowAnalysisWithMCEventPlane_cxx
18 #include "Riostream.h" //needed as include
19 #include "TFile.h" //needed as include
20 #include "TProfile.h" //needed as include
21 #include "TProfile2D.h"
22 #include "TComplex.h" //needed as include
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"
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)
42 ClassImp(AliFlowAnalysisWithMCEventPlane)
44 //-----------------------------------------------------------------------
46 AliFlowAnalysisWithMCEventPlane::AliFlowAnalysisWithMCEventPlane():
53 fCommonHistsRes(NULL),
55 fHistProIntFlow(NULL),
56 fHistProDiffFlowPtEtaRP(NULL),
57 fHistProDiffFlowPtRP(NULL),
58 fHistProDiffFlowEtaRP(NULL),
59 fHistProDiffFlowPtEtaPOI(NULL),
60 fHistProDiffFlowPtPOI(NULL),
61 fHistProDiffFlowEtaPOI(NULL)
65 fHistList = new TList();
67 fQsum = new TVector2; // flow vector sum
71 //-----------------------------------------------------------------------
74 AliFlowAnalysisWithMCEventPlane::~AliFlowAnalysisWithMCEventPlane()
81 //-----------------------------------------------------------------------
83 void AliFlowAnalysisWithMCEventPlane::WriteHistograms(TString* outputFileName)
85 //store the final results in output .root file
86 TFile *output = new TFile(outputFileName->Data(),"RECREATE");
87 //output->WriteObject(fHistList, "cobjMCEP","SingleKey");
88 fHistList->SetName("cobjMCEP");
89 fHistList->Write(fHistList->GetName(), TObject::kSingleKey);
93 //-----------------------------------------------------------------------
95 void AliFlowAnalysisWithMCEventPlane::WriteHistograms(TString outputFileName)
97 //store the final results in output .root file
98 TFile *output = new TFile(outputFileName.Data(),"RECREATE");
99 //output->WriteObject(fHistList, "cobjMCEP","SingleKey");
100 fHistList->SetName("cobjMCEP");
101 fHistList->Write(fHistList->GetName(), TObject::kSingleKey);
105 //-----------------------------------------------------------------------
106 void AliFlowAnalysisWithMCEventPlane::Init() {
108 //Define all histograms
109 cout<<"---Analysis with the real MC Event Plane---"<<endl;
111 Int_t iNbinsPt = AliFlowCommonConstants::GetNbinsPt();
112 Double_t dPtMin = AliFlowCommonConstants::GetPtMin();
113 Double_t dPtMax = AliFlowCommonConstants::GetPtMax();
115 Int_t iNbinsEta = AliFlowCommonConstants::GetNbinsEta();
116 Double_t dEtaMin = AliFlowCommonConstants::GetEtaMin();
117 Double_t dEtaMax = AliFlowCommonConstants::GetEtaMax();
119 fCommonHists = new AliFlowCommonHist("AliFlowCommonHistMCEP");
120 fHistList->Add(fCommonHists);
121 fCommonHistsRes = new AliFlowCommonHistResults("AliFlowCommonHistResultsMCEP");
122 fHistList->Add(fCommonHistsRes);
124 fHistRP = new TH1F("Flow_RP_MCEP","Flow_RP_MCEP",100,0.,3.14);
125 fHistRP->SetXTitle("Reaction Plane Angle");
126 fHistRP->SetYTitle("Counts");
127 fHistList->Add(fHistRP);
129 fHistProIntFlow = new TProfile("FlowPro_V_MCEP","FlowPro_V_MCEP",1,0.,1.);
130 fHistProIntFlow->SetLabelSize(0.06);
131 (fHistProIntFlow->GetXaxis())->SetBinLabel(1,"v_{n}{2}");
132 fHistProIntFlow->SetYTitle("");
133 fHistList->Add(fHistProIntFlow);
135 fHistProDiffFlowPtEtaRP = new TProfile2D("FlowPro_VPtEtaRP_MCEP","FlowPro_VPtEtaRP_MCEP",iNbinsPt,dPtMin,dPtMax,iNbinsEta,dEtaMin,dEtaMax);
136 fHistProDiffFlowPtEtaRP->SetXTitle("P_{t}");
137 fHistProDiffFlowPtEtaRP->SetYTitle("#eta");
138 fHistList->Add(fHistProDiffFlowPtEtaRP);
140 fHistProDiffFlowPtRP = new TProfile("FlowPro_VPtRP_MCEP","FlowPro_VPtRP_MCEP",iNbinsPt,dPtMin,dPtMax);
141 fHistProDiffFlowPtRP->SetXTitle("P_{t}");
142 fHistProDiffFlowPtRP->SetYTitle("");
143 fHistList->Add(fHistProDiffFlowPtRP);
145 fHistProDiffFlowEtaRP = new TProfile("FlowPro_VetaRP_MCEP","FlowPro_VetaRP_MCEP",iNbinsEta,dEtaMin,dEtaMax);
146 fHistProDiffFlowEtaRP->SetXTitle("#eta");
147 fHistProDiffFlowEtaRP->SetYTitle("");
148 fHistList->Add(fHistProDiffFlowEtaRP);
150 fHistProDiffFlowPtEtaPOI = new TProfile2D("FlowPro_VPtEtaPOI_MCEP","FlowPro_VPtEtaPOI_MCEP",iNbinsPt,dPtMin,dPtMax,iNbinsEta,dEtaMin,dEtaMax);
151 fHistProDiffFlowPtEtaPOI->SetXTitle("P_{t}");
152 fHistProDiffFlowPtEtaPOI->SetYTitle("#eta");
153 fHistList->Add(fHistProDiffFlowPtEtaPOI);
155 fHistProDiffFlowPtPOI = new TProfile("FlowPro_VPtPOI_MCEP","FlowPro_VPtPOI_MCEP",iNbinsPt,dPtMin,dPtMax);
156 fHistProDiffFlowPtPOI->SetXTitle("P_{t}");
157 fHistProDiffFlowPtPOI->SetYTitle("");
158 fHistList->Add(fHistProDiffFlowPtPOI);
160 fHistProDiffFlowEtaPOI = new TProfile("FlowPro_VetaPOI_MCEP","FlowPro_VetaPOI_MCEP",iNbinsEta,dEtaMin,dEtaMax);
161 fHistProDiffFlowEtaPOI->SetXTitle("#eta");
162 fHistProDiffFlowEtaPOI->SetYTitle("");
163 fHistList->Add(fHistProDiffFlowEtaPOI);
165 fEventNumber = 0; //set number of events to zero
169 //-----------------------------------------------------------------------
171 void AliFlowAnalysisWithMCEventPlane::Make(AliFlowEventSimple* anEvent) {
173 //Calculate v2 from the MC reaction plane
176 // get the MC reaction plane angle
177 Double_t aRP = anEvent->GetMCReactionPlaneAngle();
178 //fill control histograms
179 fCommonHists->FillControlHistograms(anEvent);
181 //get the Q vector from the FlowEvent
182 AliFlowVector vQ = anEvent->GetQ();
183 //cout<<"vQ.Mod() = " << vQ.Mod() << endl;
184 //for chi calculation:
186 //cout<<"fQsum.Mod() = "<<fQsum.Mod()<<endl;
188 //cout<<"fQ2sum = "<<fQ2sum<<endl;
196 //Double_t dPi = TMath::Pi();
199 //loop over the tracks of the event
200 Int_t iNumberOfTracks = anEvent->NumberOfTracks();
201 for (Int_t i=0;i<iNumberOfTracks;i++)
203 AliFlowTrackSimple* pTrack = anEvent->GetTrack(i) ;
205 if (pTrack->InRPSelection()){
206 dPhi = pTrack->Phi();
207 dv2 = TMath::Cos(2*(dPhi-aRP));
209 dEta = pTrack->Eta();
210 //no-name int. flow (to be improved):
211 fHistProIntFlow->Fill(0.,dv2);
212 //differential flow (Pt, Eta, RP):
213 fHistProDiffFlowPtEtaRP->Fill(dPt,dEta,dv2,1.);
214 //differential flow (Pt, RP):
215 fHistProDiffFlowPtRP->Fill(dPt,dv2,1.);
216 //differential flow (Eta, RP):
217 fHistProDiffFlowEtaRP->Fill(dEta,dv2,1.);
219 if (pTrack->InPOISelection()) {
220 dPhi = pTrack->Phi();
221 //if (dPhi<0.) dPhi+=2*TMath::Pi();
223 dv2 = TMath::Cos(2*(dPhi-aRP));
225 dEta = pTrack->Eta();
226 //differential flow (Pt, Eta, POI):
227 fHistProDiffFlowPtEtaPOI->Fill(dPt,dEta,dv2,1.);
228 //differential flow (Pt, POI):
229 fHistProDiffFlowPtPOI->Fill(dPt,dv2,1.);
230 //differential flow (Eta, POI):
231 fHistProDiffFlowEtaPOI->Fill(dEta,dv2,1.);
237 // cout<<"@@@@@ "<<fEventNumber<<" events processed"<<endl;
240 //--------------------------------------------------------------------
242 void AliFlowAnalysisWithMCEventPlane::GetOutputHistograms(TList *outputListHistos) {
243 // get the pointers to all output histograms before calling Finish()
244 if (outputListHistos) {
245 //Get the common histograms from the output list
246 AliFlowCommonHist *pCommonHists = dynamic_cast<AliFlowCommonHist*>
247 (outputListHistos->FindObject("AliFlowCommonHistMCEP"));
248 AliFlowCommonHistResults *pCommonHistResults =
249 dynamic_cast<AliFlowCommonHistResults*>
250 (outputListHistos->FindObject("AliFlowCommonHistResultsMCEP"));
252 TProfile *pHistProIntFlow = dynamic_cast<TProfile*>
253 (outputListHistos->FindObject("FlowPro_V_MCEP"));
255 TProfile2D *pHistProDiffFlowPtEtaRP = dynamic_cast<TProfile2D*>
256 (outputListHistos->FindObject("FlowPro_VPtEtaRP_MCEP"));
258 TProfile *pHistProDiffFlowPtRP = dynamic_cast<TProfile*>
259 (outputListHistos->FindObject("FlowPro_VPtRP_MCEP"));
261 TProfile *pHistProDiffFlowEtaRP = dynamic_cast<TProfile*>
262 (outputListHistos->FindObject("FlowPro_VetaRP_MCEP"));
264 TProfile2D *pHistProDiffFlowPtEtaPOI = dynamic_cast<TProfile2D*>
265 (outputListHistos->FindObject("FlowPro_VPtEtaPOI_MCEP"));
267 TProfile *pHistProDiffFlowPtPOI = dynamic_cast<TProfile*>
268 (outputListHistos->FindObject("FlowPro_VPtPOI_MCEP"));
270 TProfile *pHistProDiffFlowEtaPOI = dynamic_cast<TProfile*>
271 (outputListHistos->FindObject("FlowPro_VetaPOI_MCEP"));
273 if (pCommonHists && pCommonHistResults && pHistProIntFlow &&
274 pHistProDiffFlowPtRP && pHistProDiffFlowEtaRP &&
275 pHistProDiffFlowPtPOI && pHistProDiffFlowEtaPOI) {
276 this->SetCommonHists(pCommonHists);
277 this->SetCommonHistsRes(pCommonHistResults);
278 this->SetHistProIntFlow(pHistProIntFlow);
279 this->SetHistProDiffFlowPtEtaRP(pHistProDiffFlowPtEtaRP);
280 this->SetHistProDiffFlowPtRP(pHistProDiffFlowPtRP);
281 this->SetHistProDiffFlowEtaRP(pHistProDiffFlowEtaRP);
282 this->SetHistProDiffFlowPtEtaPOI(pHistProDiffFlowPtEtaPOI);
283 this->SetHistProDiffFlowPtPOI(pHistProDiffFlowPtPOI);
284 this->SetHistProDiffFlowEtaPOI(pHistProDiffFlowEtaPOI);
286 cout<<"WARNING: Histograms needed to run Finish() are not accessible!"<<endl; }
288 //fListHistos->Print();
289 } else { cout << "histogram list pointer is empty" << endl;}
293 //--------------------------------------------------------------------
294 void AliFlowAnalysisWithMCEventPlane::Finish() {
296 //*************make histograms etc.
297 if (fDebug) cout<<"AliFlowAnalysisWithMCEventPlane::Terminate()"<<endl;
299 Int_t iNbinsPt = AliFlowCommonConstants::GetNbinsPt();
300 Int_t iNbinsEta = AliFlowCommonConstants::GetNbinsEta();
302 // no-name int. flow (to be improved):
303 Double_t dV = fHistProIntFlow->GetBinContent(1);
304 Double_t dErrV = fHistProIntFlow->GetBinError(1); // to be improved (treatment of errors for non-Gaussian distribution needed!)
305 // fill no-name int. flow (to be improved):
306 fCommonHistsRes->FillIntegratedFlow(dV,dErrV);
307 cout<<"dV{MC} is "<<dV<<" +- "<<dErrV<<endl;
310 TH1F* fHistPtRP = fCommonHists->GetHistPtRP();
311 Double_t dYieldPtRP = 0.;
313 Double_t dErrVRP = 0.;
314 Double_t dSumRP = 0.;
315 //differential flow (RP, Pt):
316 Double_t dvPtRP = 0.;
317 Double_t dErrvPtRP = 0.;
318 for(Int_t b=1;b<iNbinsPt;b++)
320 dvPtRP = fHistProDiffFlowPtRP->GetBinContent(b);
321 dErrvPtRP = fHistProDiffFlowPtRP->GetBinError(b);//to be improved (treatment of errors for non-Gaussian distribution needed!)
322 fCommonHistsRes->FillDifferentialFlowPtRP(b, dvPtRP, dErrvPtRP);
324 //integrated flow (RP)
325 dYieldPtRP = fHistPtRP->GetBinContent(b);
326 dVRP += dvPtRP*dYieldPtRP;
327 dSumRP += dYieldPtRP;
328 //error on integrated flow
329 dErrVRP += dYieldPtRP*dYieldPtRP*dErrvPtRP*dErrvPtRP;
333 dVRP /= dSumRP; //because pt distribution should be normalised
334 dErrVRP /= (dSumRP*dSumRP);
335 dErrVRP = TMath::Sqrt(dErrVRP);
337 // fill integrated flow (RP):
338 fCommonHistsRes->FillIntegratedFlowRP(dVRP,dErrVRP);
339 cout<<"dV{MC} (RP) is "<<dVRP<<" +- "<<dErrVRP<<endl;
341 //differential flow (RP, Eta):
342 Double_t dvEtaRP = 0.;
343 Double_t dErrvEtaRP = 0.;
344 for(Int_t b=1;b<iNbinsEta;b++)
346 dvEtaRP = fHistProDiffFlowEtaRP->GetBinContent(b);
347 dErrvEtaRP = fHistProDiffFlowEtaRP->GetBinError(b);//to be improved (treatment of errors for non-Gaussian distribution needed!)
348 fCommonHistsRes->FillDifferentialFlowEtaRP(b, dvEtaRP, dErrvEtaRP);
352 TH1F* fHistPtPOI = fCommonHists->GetHistPtPOI();
353 Double_t dYieldPtPOI = 0.;
355 Double_t dErrVPOI = 0.;
356 Double_t dSumPOI = 0.;
357 Double_t dv2proPtPOI = 0.;
358 Double_t dErrdifcombPtPOI = 0.;
359 Double_t dv2proEtaPOI = 0.;
360 Double_t dErrdifcombEtaPOI = 0.;
362 if(fHistProDiffFlowPtPOI) {
363 for(Int_t b=1;b<iNbinsPt;b++){
364 dv2proPtPOI = fHistProDiffFlowPtPOI->GetBinContent(b);
365 dErrdifcombPtPOI = fHistProDiffFlowPtPOI->GetBinError(b);//to be improved (treatment of errors for non-Gaussian distribution needed!)
367 fCommonHistsRes->FillDifferentialFlowPtPOI(b, dv2proPtPOI, dErrdifcombPtPOI);
369 //integrated flow (POI)
370 dYieldPtPOI = fHistPtPOI->GetBinContent(b);
371 dVPOI += dv2proPtPOI*dYieldPtPOI;
372 dSumPOI += dYieldPtPOI;
373 //error on integrated flow
374 dErrVPOI += dYieldPtPOI*dYieldPtPOI*dErrdifcombPtPOI*dErrdifcombPtPOI;
376 }//end of for(Int_t b=0;b<iNbinsPt;b++)
377 } else { cout<<"fHistProFlow is NULL"<<endl; }
378 if (dSumPOI != 0. ) {
379 dVPOI /= dSumPOI; //because pt distribution should be normalised
380 dErrVPOI /= (dSumPOI*dSumPOI);
381 dErrVPOI = TMath::Sqrt(dErrVPOI);
383 cout<<"dV{MC} (POI) is "<<dVPOI<<" +- "<<dErrVPOI<<endl;
385 fCommonHistsRes->FillIntegratedFlowPOI(dVPOI,dErrVPOI);
388 if(fHistProDiffFlowEtaPOI)
390 for(Int_t b=1;b<iNbinsEta;b++)
392 dv2proEtaPOI = fHistProDiffFlowEtaPOI->GetBinContent(b);
393 dErrdifcombEtaPOI = fHistProDiffFlowEtaPOI->GetBinError(b);//to be improved (treatment of errors for non-Gaussian distribution needed!)
394 //fill common hist results:
395 fCommonHistsRes->FillDifferentialFlowEtaPOI(b, dv2proEtaPOI, dErrdifcombEtaPOI);
400 //cout<<".....finished"<<endl;