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 **************************************************************************/
20 //#define AliFlowAnalysisWithLYZEventPlane_cxx
22 #include "Riostream.h" //needed as include
23 #include "TComplex.h" //needed as include
24 #include "TProfile.h" //needed as include
31 #include "AliFlowLYZConstants.h" //needed as include
32 #include "AliFlowCommonConstants.h" //needed as include
33 #include "AliFlowEventSimple.h"
34 #include "AliFlowTrackSimple.h"
35 #include "AliFlowCommonHist.h"
36 #include "AliFlowCommonHistResults.h"
37 #include "AliFlowLYZEventPlane.h"
38 #include "AliFlowAnalysisWithLYZEventPlane.h"
42 // AliFlowAnalysisWithLYZEventPlane:
44 // Class to do flow analysis with the event plane from the LYZ method
46 // author: N. van der Kolk (kolk@nikhef.nl)
49 ClassImp(AliFlowAnalysisWithLYZEventPlane)
51 //-----------------------------------------------------------------------
53 AliFlowAnalysisWithLYZEventPlane::AliFlowAnalysisWithLYZEventPlane():
56 fSecondReDtheta(NULL),
57 fSecondImDtheta(NULL),
60 fHistProVetaPOI(NULL),
65 fHistQsumforChi(NULL),
68 fHistDeltaPhihere(NULL),
74 fCommonHistsRes(NULL),
81 fQsum = new TVector2(); // flow vector sum
83 fHistList = new TList();
84 fSecondRunList = new TList();
89 //-----------------------------------------------------------------------
92 AliFlowAnalysisWithLYZEventPlane::~AliFlowAnalysisWithLYZEventPlane()
97 delete fSecondRunList;
101 //-----------------------------------------------------------------------
103 void AliFlowAnalysisWithLYZEventPlane::WriteHistograms(TString* outputFileName)
105 //store the final results in output .root file
107 TFile *output = new TFile(outputFileName->Data(),"RECREATE");
108 output->WriteObject(fHistList, "cobjLYZEP","SingleKey");
112 //-----------------------------------------------------------------------
114 void AliFlowAnalysisWithLYZEventPlane::WriteHistograms(TString outputFileName)
116 //store the final results in output .root file
118 TFile *output = new TFile(outputFileName.Data(),"RECREATE");
119 output->WriteObject(fHistList, "cobjLYZEP","SingleKey");
123 //-----------------------------------------------------------------------
124 void AliFlowAnalysisWithLYZEventPlane::Init() {
126 //Initialise all histograms
127 cout<<"---Analysis with Lee Yang Zeros Event Plane Method---"<<endl;
130 if (fSecondRunList) {
131 fSecondReDtheta = (TProfile*)fSecondRunList->FindObject("Second_FlowPro_ReDtheta_LYZ");
132 fHistList->Add(fSecondReDtheta);
134 fSecondImDtheta = (TProfile*)fSecondRunList->FindObject("Second_FlowPro_ImDtheta_LYZ");
135 fHistList->Add(fSecondImDtheta);
137 fFirstr0theta = (TProfile*)fSecondRunList->FindObject("First_FlowPro_r0theta_LYZ");
138 fHistList->Add(fFirstr0theta);
141 if (!fSecondReDtheta) {cout<<"fSecondReDtheta is NULL!"<<endl; }
142 if (!fSecondImDtheta) {cout<<"fSecondImDtheta is NULL!"<<endl; }
143 if (!fFirstr0theta) {cout<<"fFirstr0theta is NULL!"<<endl; }
147 fCommonHists = new AliFlowCommonHist("AliFlowCommonHistLYZEP");
148 fHistList->Add(fCommonHists);
150 fCommonHistsRes = new AliFlowCommonHistResults("AliFlowCommonHistResultsLYZEP");
151 fHistList->Add(fCommonHistsRes);
153 Int_t iNbinsPt = AliFlowCommonConstants::GetNbinsPt();
154 Int_t iNbinsEta = AliFlowCommonConstants::GetNbinsEta();
155 Double_t dPtMin = AliFlowCommonConstants::GetPtMin();
156 Double_t dPtMax = AliFlowCommonConstants::GetPtMax();
157 Double_t dEtaMin = AliFlowCommonConstants::GetEtaMin();
158 Double_t dEtaMax = AliFlowCommonConstants::GetEtaMax();
160 fHistProVetaRP = new TProfile("FlowPro_VetaRP_LYZEP","FlowPro_VetaRP_LYZEP",iNbinsEta,dEtaMin,dEtaMax);
161 fHistProVetaRP->SetXTitle("rapidity");
162 fHistProVetaRP->SetYTitle("v_{2}(#eta) for RP selection");
163 fHistList->Add(fHistProVetaRP);
165 fHistProVetaPOI = new TProfile("FlowPro_VetaPOI_LYZEP","FlowPro_VetaPOI_LYZEP",iNbinsEta,dEtaMin,dEtaMax);
166 fHistProVetaPOI->SetXTitle("rapidity");
167 fHistProVetaPOI->SetYTitle("v_{2}(#eta) for POI selection");
168 fHistList->Add(fHistProVetaPOI);
170 fHistProVPtRP = new TProfile("FlowPro_VPtRP_LYZEP","FlowPro_VPtRP_LYZEP",iNbinsPt,dPtMin,dPtMax);
171 fHistProVPtRP->SetXTitle("Pt");
172 fHistProVPtRP->SetYTitle("v_{2}(p_{T}) for RP selection");
173 fHistList->Add(fHistProVPtRP);
175 fHistProVPtPOI = new TProfile("FlowPro_VPtPOI_LYZEP","FlowPro_VPtPOI_LYZEP",iNbinsPt,dPtMin,dPtMax);
176 fHistProVPtPOI->SetXTitle("p_{T}");
177 fHistProVPtPOI->SetYTitle("v_{2}(p_{T}) for POI selection");
178 fHistList->Add(fHistProVPtPOI);
180 fHistProWr = new TProfile("FlowPro_Wr_LYZEP","FlowPro_Wr_LYZEP",100,0.,0.25);
181 fHistProWr->SetXTitle("Q");
182 fHistProWr->SetYTitle("Wr");
183 fHistList->Add(fHistProWr);
185 fHistQsumforChi = new TH1F("Flow_QsumforChi_LYZEP","Flow_QsumforChi_LYZEP",3,-1.,2.);
186 fHistQsumforChi->SetXTitle("Qsum.X , Qsum.Y, Q2sum");
187 fHistQsumforChi->SetYTitle("value");
188 fHistList->Add(fHistQsumforChi);
190 fHistDeltaPhi = new TH1F("Flow_DeltaPhi_LYZEP","Flow_DeltaPhi_LYZEP",100,0.,3.14);
191 fHistDeltaPhi->SetXTitle("DeltaPhi");
192 fHistDeltaPhi->SetYTitle("Counts");
193 fHistList->Add(fHistDeltaPhi);
195 fHistPhiLYZ = new TH1F("Flow_PhiLYZ_LYZEP","Flow_PhiLYZ_LYZEP",100,0.,3.14);
196 fHistPhiLYZ->SetXTitle("Phi from LYZ");
197 fHistPhiLYZ->SetYTitle("Counts");
198 fHistList->Add(fHistPhiLYZ);
200 fHistPhiEP = new TH1F("Flow_PhiEP_LYZEP","Flow_PhiEP_LYZEP",100,0.,3.14);
201 fHistPhiEP->SetXTitle("Phi from EP");
202 fHistPhiEP->SetYTitle("Counts");
203 fHistList->Add(fHistPhiEP);
205 fEventNumber = 0; //set number of events to zero
209 //-----------------------------------------------------------------------
211 void AliFlowAnalysisWithLYZEventPlane::Make(AliFlowEventSimple* anEvent, AliFlowLYZEventPlane* aLYZEP) {
213 //Get the event plane and weight for each event
216 //fill control histograms
217 fCommonHists->FillControlHistograms(anEvent);
219 //get the Q vector from the FlowEvent
220 AliFlowVector vQ = anEvent->GetQ();
221 if (vQ.X()== 0. && vQ.Y()== 0. ) { cout<<"Q vector is NULL!"<<endl; }
222 //Weight with the multiplicity
225 if (vQ.GetMult()!=0.) {
226 dQX = vQ.X()/vQ.GetMult();
227 dQY = vQ.Y()/vQ.GetMult();
228 } else {cerr<<"vQ.GetMult() is zero!"<<endl; }
230 //cout<<"vQ("<<dQX<<","<<dQY<<")"<<endl;
232 //for chi calculation:
234 fHistQsumforChi->SetBinContent(1,fQsum->X());
235 fHistQsumforChi->SetBinContent(2,fQsum->Y());
237 fHistQsumforChi->SetBinContent(3,fQ2sum);
238 //cout<<"fQ2sum = "<<fQ2sum<<endl;
240 //call AliFlowLYZEventPlane::CalculateRPandW() here!
241 aLYZEP->CalculateRPandW(vQ);
243 Double_t dWR = aLYZEP->GetWR();
244 Double_t dRP = aLYZEP->GetPsi();
246 //fHistProWr->Fill(vQ.Mod(),dWR); //this weight is always positive
247 fHistPhiLYZ->Fill(dRP);
249 //plot difference between event plane from EP-method and LYZ-method
250 Double_t dRPEP = vQ.Phi()/2; //gives distribution from (0 to pi)
251 //Double_t dRPEP = 0.5*TMath::ATan2(vQ.Y(),vQ.X()); //gives distribution from (-pi/2 to pi/2)
252 //cout<<"dRPEP = "<< dRPEP <<endl;
253 fHistPhiEP->Fill(dRPEP);
255 Double_t dDeltaPhi = dRPEP - dRP;
256 if (dDeltaPhi < 0.) { dDeltaPhi += TMath::Pi(); } //to shift distribution from (-pi/2 to pi/2) to (0 to pi)
257 //cout<<"dDeltaPhi = "<<dDeltaPhi<<endl;
258 fHistDeltaPhi->Fill(dDeltaPhi);
261 Double_t dLow = TMath::Pi()/4.;
262 Double_t dHigh = 3.*(TMath::Pi()/4.);
263 if ((dDeltaPhi > dLow) && (dDeltaPhi < dHigh)){
264 dRP -= (TMath::Pi()/2);
266 cerr<<"*** dRP modified ***"<<endl;
268 fHistProWr->Fill(vQ.Mod(),dWR); //corrected weight
270 //calculate flow for RP and POI selections
271 //loop over the tracks of the event
272 Int_t iNumberOfTracks = anEvent->NumberOfTracks();
273 for (Int_t i=0;i<iNumberOfTracks;i++)
275 AliFlowTrackSimple* pTrack = anEvent->GetTrack(i) ;
277 Double_t dPhi = pTrack->Phi();
278 //if (dPhi<0.) fPhi+=2*TMath::Pi();
279 Double_t dPt = pTrack->Pt();
280 Double_t dEta = pTrack->Eta();
282 Double_t dv2 = dWR * TMath::Cos(2*(dPhi-dRP));
283 if (pTrack->UseForIntegratedFlow()) {
284 //fill histograms for RP selection
285 fHistProVetaRP -> Fill(dEta,dv2);
286 fHistProVPtRP -> Fill(dPt,dv2);
288 if (pTrack->UseForDifferentialFlow()) {
289 //fill histograms for POI selection
290 fHistProVetaPOI -> Fill(dEta,dv2);
291 fHistProVPtPOI -> Fill(dPt,dv2);
297 // cout<<"@@@@@ "<<fEventNumber<<" events processed"<<endl;
301 //--------------------------------------------------------------------
302 void AliFlowAnalysisWithLYZEventPlane::Finish() {
304 //plot histograms etc.
305 cout<<"AliFlowAnalysisWithLYZEventPlane::Finish()"<<endl;
308 Double_t dJ01 = 2.405;
309 Int_t iNtheta = AliFlowLYZConstants::kTheta;
310 Int_t iNbinsPt = AliFlowCommonConstants::GetNbinsPt();
311 Int_t iNbinsEta = AliFlowCommonConstants::GetNbinsEta();
312 //set the event number
313 SetEventNumber((int)fCommonHists->GetHistMultOrig()->GetEntries());
314 //cout<<"number of events processed is "<<fEventNumber<<endl;
316 //set the sum of Q vectors
317 fQsum->Set(fHistQsumforChi->GetBinContent(1),fHistQsumforChi->GetBinContent(2));
318 SetQ2sum(fHistQsumforChi->GetBinContent(3));
320 //calculate dV the mean of dVtheta
321 Double_t dVtheta = 0;
323 for (Int_t theta=0;theta<iNtheta;theta++) {
324 Double_t dR0 = fFirstr0theta->GetBinContent(theta+1);
325 if (dR0!=0.) { dVtheta = dJ01/dR0 ;}
331 Double_t dSigma2 = 0;
333 if (fEventNumber!=0) {
334 *fQsum /= fEventNumber;
335 //cerr<<"fQsum->X() = "<<fQsum->X()<<endl;
336 //cerr<<"fQsum->Y() = "<<fQsum->Y()<<endl;
337 fQ2sum /= fEventNumber;
338 //cerr<<"fEventNumber = "<<fEventNumber<<endl;
339 //cerr<<"fQ2sum = "<<fQ2sum<<endl;
340 dSigma2 = fQ2sum - TMath::Power(fQsum->X(),2.) - TMath::Power(fQsum->Y(),2.) - TMath::Power(dV,2.); //BP eq. 62
341 //cerr<<"dSigma2"<<dSigma2<<endl;
342 if (dSigma2>0) dChi = dV/TMath::Sqrt(dSigma2);
344 fCommonHistsRes->FillChiRP(dChi);
346 // recalculate statistical errors on integrated flow
347 //combining 5 theta angles to 1 relative error BP eq. 89
348 Double_t dRelErr2comb = 0.;
349 Int_t iEvts = fEventNumber;
351 for (Int_t theta=0;theta<iNtheta;theta++){
352 Double_t dTheta = ((double)theta/iNtheta)*TMath::Pi();
353 Double_t dApluscomb = TMath::Exp((dJ01*dJ01)/(2*dChi*dChi)*
355 Double_t dAmincomb = TMath::Exp(-(dJ01*dJ01)/(2*dChi*dChi)*
357 dRelErr2comb += (1/(2*iEvts*(dJ01*dJ01)*TMath::BesselJ1(dJ01)*
358 TMath::BesselJ1(dJ01)))*
359 (dApluscomb*TMath::BesselJ0(2*dJ01*TMath::Sin(dTheta/2)) +
360 dAmincomb*TMath::BesselJ0(2*dJ01*TMath::Cos(dTheta/2)));
362 dRelErr2comb /= iNtheta;
364 Double_t dRelErrcomb = TMath::Sqrt(dRelErr2comb);
365 Double_t dVErr = dV*dRelErrcomb ;
366 fCommonHistsRes->FillIntegratedFlow(dV, dVErr);
368 cout<<"*************************************"<<endl;
369 cout<<"*************************************"<<endl;
370 cout<<" Integrated flow from "<<endl;
371 cout<<" Lee-Yang Zeroes Event Plane "<<endl;
373 cout<<"dChi = "<<dChi<<endl;
374 cout<<"dV = "<<dV<<" +- "<<dVErr<<endl;
379 //copy content of profile into TH1D, add error and fill the AliFlowCommonHistResults
381 //v as a function of eta for RP selection
382 for(Int_t b=0;b<iNbinsEta;b++) {
383 Double_t dv2pro = fHistProVetaRP->GetBinContent(b);
384 Double_t dNprime = fCommonHists->GetEntriesInEtaBinRP(b);
385 Double_t dErrdifcomb = 0.; //set error to zero
386 Double_t dErr2difcomb = 0.; //set error to zero
389 for (Int_t theta=0;theta<iNtheta;theta++) {
390 Double_t dTheta = ((double)theta/iNtheta)*TMath::Pi();
391 Double_t dApluscomb = TMath::Exp((dJ01*dJ01)/(2*dChi*dChi)*
393 Double_t dAmincomb = TMath::Exp(-(dJ01*dJ01)/(2*dChi*dChi)*
395 dErr2difcomb += (TMath::Cos(dTheta)/(4*dNprime*TMath::BesselJ1(dJ01)*
396 TMath::BesselJ1(dJ01)))*
397 ((dApluscomb*TMath::BesselJ0(2*dJ01*TMath::Sin(dTheta/2))) -
398 (dAmincomb*TMath::BesselJ0(2*dJ01*TMath::Cos(dTheta/2))));
402 if (dErr2difcomb!=0.) {
403 dErr2difcomb /= iNtheta;
404 dErrdifcomb = TMath::Sqrt(dErr2difcomb);
406 else {dErrdifcomb = 0.;}
408 fCommonHistsRes->FillDifferentialFlowEtaRP(b, dv2pro, dErrdifcomb);
412 //v as a function of eta for POI selection
413 for(Int_t b=0;b<iNbinsEta;b++) {
414 Double_t dv2pro = fHistProVetaPOI->GetBinContent(b);
415 Double_t dNprime = fCommonHists->GetEntriesInEtaBinPOI(b);
416 Double_t dErrdifcomb = 0.; //set error to zero
417 Double_t dErr2difcomb = 0.; //set error to zero
420 for (Int_t theta=0;theta<iNtheta;theta++) {
421 Double_t dTheta = ((double)theta/iNtheta)*TMath::Pi();
422 Double_t dApluscomb = TMath::Exp((dJ01*dJ01)/(2*dChi*dChi)*
424 Double_t dAmincomb = TMath::Exp(-(dJ01*dJ01)/(2*dChi*dChi)*
426 dErr2difcomb += (TMath::Cos(dTheta)/(4*dNprime*TMath::BesselJ1(dJ01)*
427 TMath::BesselJ1(dJ01)))*
428 ((dApluscomb*TMath::BesselJ0(2*dJ01*TMath::Sin(dTheta/2))) -
429 (dAmincomb*TMath::BesselJ0(2*dJ01*TMath::Cos(dTheta/2))));
433 if (dErr2difcomb!=0.) {
434 dErr2difcomb /= iNtheta;
435 dErrdifcomb = TMath::Sqrt(dErr2difcomb);
437 else {dErrdifcomb = 0.;}
439 fCommonHistsRes->FillDifferentialFlowEtaPOI(b, dv2pro, dErrdifcomb);
442 //v as a function of Pt for RP selection
443 TH1F* fHistPtInt = fCommonHists->GetHistPtInt(); //for calculating integrated flow
448 for(Int_t b=0;b<iNbinsPt;b++) {
449 Double_t dv2pro = fHistProVPtRP->GetBinContent(b);
450 Double_t dNprime = fCommonHists->GetEntriesInPtBinRP(b);
451 Double_t dErrdifcomb = 0.; //set error to zero
452 Double_t dErr2difcomb = 0.; //set error to zero
455 for (Int_t theta=0;theta<iNtheta;theta++) {
456 Double_t dTheta = ((double)theta/iNtheta)*TMath::Pi();
457 Double_t dApluscomb = TMath::Exp((dJ01*dJ01)/(2*dChi*dChi)*
459 Double_t dAmincomb = TMath::Exp(-(dJ01*dJ01)/(2*dChi*dChi)*
461 dErr2difcomb += (TMath::Cos(dTheta)/(4*dNprime*TMath::BesselJ1(dJ01)*
462 TMath::BesselJ1(dJ01)))*
463 ((dApluscomb*TMath::BesselJ0(2*dJ01*TMath::Sin(dTheta/2))) -
464 (dAmincomb*TMath::BesselJ0(2*dJ01*TMath::Cos(dTheta/2))));
468 if (dErr2difcomb!=0.) {
469 dErr2difcomb /= iNtheta;
470 dErrdifcomb = TMath::Sqrt(dErr2difcomb);
471 //cerr<<"dErrdifcomb = "<<dErrdifcomb<<endl;
473 else {dErrdifcomb = 0.;}
476 fCommonHistsRes->FillDifferentialFlowPtRP(b, dv2pro, dErrdifcomb);
477 //calculate integrated flow for RP selection
479 Double_t dYieldPt = fHistPtInt->GetBinContent(b);
480 dVRP += dv2pro*dYieldPt;
482 dErrV += dYieldPt*dYieldPt*dErrdifcomb*dErrdifcomb;
483 } else { cout<<"fHistPtDiff is NULL"<<endl; }
488 dVRP /= dSum; //the pt distribution should be normalised
489 dErrV /= (dSum*dSum);
490 dErrV = TMath::Sqrt(dErrV);
492 fCommonHistsRes->FillIntegratedFlowRP(dVRP,dErrV);
494 cout<<"dV(RP) = "<<dVRP<<" +- "<<dErrV<<endl;
498 //v as a function of Pt for POI selection
499 TH1F* fHistPtDiff = fCommonHists->GetHistPtDiff(); //for calculating integrated flow
504 for(Int_t b=0;b<iNbinsPt;b++) {
505 Double_t dv2pro = fHistProVPtPOI->GetBinContent(b);
506 Double_t dNprime = fCommonHists->GetEntriesInPtBinPOI(b);
508 //cerr<<"dNprime = "<<dNprime<<endl;
509 //Int_t iNprime = TMath::Nint(fHistProVPtPOI->GetBinEntries(b));
510 //cerr<<"iNprime = "<<iNprime<<endl;
512 Double_t dErrdifcomb = 0.; //set error to zero
513 Double_t dErr2difcomb = 0.; //set error to zero
516 for (Int_t theta=0;theta<iNtheta;theta++) {
517 Double_t dTheta = ((double)theta/iNtheta)*TMath::Pi();
518 Double_t dApluscomb = TMath::Exp((dJ01*dJ01)/(2*dChi*dChi)*
520 Double_t dAmincomb = TMath::Exp(-(dJ01*dJ01)/(2*dChi*dChi)*
522 dErr2difcomb += (TMath::Cos(dTheta)/(4*dNprime*TMath::BesselJ1(dJ01)*
523 TMath::BesselJ1(dJ01)))*
524 ((dApluscomb*TMath::BesselJ0(2*dJ01*TMath::Sin(dTheta/2))) -
525 (dAmincomb*TMath::BesselJ0(2*dJ01*TMath::Cos(dTheta/2))));
529 if (dErr2difcomb!=0.) {
530 dErr2difcomb /= iNtheta;
531 dErrdifcomb = TMath::Sqrt(dErr2difcomb);
532 //cerr<<"dErrdifcomb = "<<dErrdifcomb<<endl;
534 else {dErrdifcomb = 0.;}
537 fCommonHistsRes->FillDifferentialFlowPtPOI(b, dv2pro, dErrdifcomb);
539 //calculate integrated flow for POI selection
541 Double_t dYieldPt = fHistPtDiff->GetBinContent(b);
542 dVPOI += dv2pro*dYieldPt;
544 dErrV += dYieldPt*dYieldPt*dErrdifcomb*dErrdifcomb;
545 } else { cout<<"fHistPtDiff is NULL"<<endl; }
549 dVPOI /= dSum; //the pt distribution should be normalised
550 dErrV /= (dSum*dSum);
551 dErrV = TMath::Sqrt(dErrV);
553 fCommonHistsRes->FillIntegratedFlowPOI(dVPOI,dErrV);
555 cout<<"dV(POI) = "<<dVPOI<<" +- "<<dErrV<<endl;
557 cout<<"*************************************"<<endl;
558 cout<<"*************************************"<<endl;
560 //cout<<".....finished"<<endl;