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
26 #include "TComplex.h" //needed as include
27 #include "TCanvas.h" //needed as include
28 #include "TLegend.h" //needed as include
29 #include "TProfile.h" //needed as include
34 #include "AliFlowLYZConstants.h" //needed as include
35 #include "AliFlowCommonConstants.h" //needed as include
36 #include "AliFlowEventSimple.h"
37 #include "AliFlowTrackSimple.h"
38 #include "AliFlowCommonHist.h"
39 #include "AliFlowCommonHistResults.h"
40 #include "AliFlowLYZEventPlane.h"
41 #include "AliFlowAnalysisWithLYZEventPlane.h"
45 // AliFlowAnalysisWithLYZEventPlane:
47 // Class to do flow analysis with the event plane from the LYZ method
49 // author: N. van der Kolk (kolk@nikhef.nl)
52 ClassImp(AliFlowAnalysisWithLYZEventPlane)
54 //-----------------------------------------------------------------------
56 AliFlowAnalysisWithLYZEventPlane::AliFlowAnalysisWithLYZEventPlane():
59 fSecondReDtheta(NULL),
60 fSecondImDtheta(NULL),
63 fHistProVetaPOI(NULL),
68 fHistQsumforChi(NULL),
71 fHistDeltaPhihere(NULL),
77 fCommonHistsRes(NULL),
84 fQsum = new TVector2(); // flow vector sum
86 fHistList = new TList();
87 fSecondRunList = new TList();
92 //-----------------------------------------------------------------------
95 AliFlowAnalysisWithLYZEventPlane::~AliFlowAnalysisWithLYZEventPlane()
100 delete fSecondRunList;
104 //-----------------------------------------------------------------------
106 void AliFlowAnalysisWithLYZEventPlane::WriteHistograms(TString* outputFileName)
108 //store the final results in output .root file
110 TFile *output = new TFile(outputFileName->Data(),"RECREATE");
111 output->WriteObject(fHistList, "cobjLYZEP","SingleKey");
115 //-----------------------------------------------------------------------
117 void AliFlowAnalysisWithLYZEventPlane::WriteHistograms(TString outputFileName)
119 //store the final results in output .root file
121 TFile *output = new TFile(outputFileName.Data(),"RECREATE");
122 output->WriteObject(fHistList, "cobjLYZEP","SingleKey");
126 //-----------------------------------------------------------------------
127 void AliFlowAnalysisWithLYZEventPlane::Init() {
129 //Initialise all histograms
130 cout<<"---Analysis with Lee Yang Zeros Event Plane Method---"<<endl;
133 if (fSecondRunList) {
134 fSecondReDtheta = (TProfile*)fSecondRunList->FindObject("Second_FlowPro_ReDtheta_LYZ");
135 fHistList->Add(fSecondReDtheta);
137 fSecondImDtheta = (TProfile*)fSecondRunList->FindObject("Second_FlowPro_ImDtheta_LYZ");
138 fHistList->Add(fSecondImDtheta);
140 fFirstr0theta = (TProfile*)fSecondRunList->FindObject("First_FlowPro_r0theta_LYZ");
141 fHistList->Add(fFirstr0theta);
144 if (!fSecondReDtheta) {cout<<"fSecondReDtheta is NULL!"<<endl; }
145 if (!fSecondImDtheta) {cout<<"fSecondImDtheta is NULL!"<<endl; }
146 if (!fFirstr0theta) {cout<<"fFirstr0theta is NULL!"<<endl; }
150 fCommonHists = new AliFlowCommonHist("AliFlowCommonHistLYZEP");
151 fHistList->Add(fCommonHists);
153 fCommonHistsRes = new AliFlowCommonHistResults("AliFlowCommonHistResultsLYZEP");
154 fHistList->Add(fCommonHistsRes);
156 Int_t iNbinsPt = AliFlowCommonConstants::GetNbinsPt();
157 Int_t iNbinsEta = AliFlowCommonConstants::GetNbinsEta();
158 Double_t dPtMin = AliFlowCommonConstants::GetPtMin();
159 Double_t dPtMax = AliFlowCommonConstants::GetPtMax();
160 Double_t dEtaMin = AliFlowCommonConstants::GetEtaMin();
161 Double_t dEtaMax = AliFlowCommonConstants::GetEtaMax();
163 fHistProVetaRP = new TProfile("FlowPro_VetaRP_LYZEP","FlowPro_VetaRP_LYZEP",iNbinsEta,dEtaMin,dEtaMax);
164 fHistProVetaRP->SetXTitle("rapidity");
165 fHistProVetaRP->SetYTitle("v_{2}(#eta) for RP selection");
166 fHistList->Add(fHistProVetaRP);
168 fHistProVetaPOI = new TProfile("FlowPro_VetaPOI_LYZEP","FlowPro_VetaPOI_LYZEP",iNbinsEta,dEtaMin,dEtaMax);
169 fHistProVetaPOI->SetXTitle("rapidity");
170 fHistProVetaPOI->SetYTitle("v_{2}(#eta) for POI selection");
171 fHistList->Add(fHistProVetaPOI);
173 fHistProVPtRP = new TProfile("FlowPro_VPtRP_LYZEP","FlowPro_VPtRP_LYZEP",iNbinsPt,dPtMin,dPtMax);
174 fHistProVPtRP->SetXTitle("Pt");
175 fHistProVPtRP->SetYTitle("v_{2}(p_{T}) for RP selection");
176 fHistList->Add(fHistProVPtRP);
178 fHistProVPtPOI = new TProfile("FlowPro_VPtPOI_LYZEP","FlowPro_VPtPOI_LYZEP",iNbinsPt,dPtMin,dPtMax);
179 fHistProVPtPOI->SetXTitle("p_{T}");
180 fHistProVPtPOI->SetYTitle("v_{2}(p_{T}) for POI selection");
181 fHistList->Add(fHistProVPtPOI);
183 fHistProWr = new TProfile("FlowPro_Wr_LYZEP","FlowPro_Wr_LYZEP",100,0.,0.25);
184 fHistProWr->SetXTitle("Q");
185 fHistProWr->SetYTitle("Wr");
186 fHistList->Add(fHistProWr);
188 fHistQsumforChi = new TH1F("Flow_QsumforChi_LYZEP","Flow_QsumforChi_LYZEP",3,-1.,2.);
189 fHistQsumforChi->SetXTitle("Qsum.X , Qsum.Y, Q2sum");
190 fHistQsumforChi->SetYTitle("value");
191 fHistList->Add(fHistQsumforChi);
193 fHistDeltaPhi = new TH1F("Flow_DeltaPhi_LYZEP","Flow_DeltaPhi_LYZEP",100,0.,3.14);
194 fHistDeltaPhi->SetXTitle("DeltaPhi");
195 fHistDeltaPhi->SetYTitle("Counts");
196 fHistList->Add(fHistDeltaPhi);
198 fHistPhiLYZ = new TH1F("Flow_PhiLYZ_LYZEP","Flow_PhiLYZ_LYZEP",100,0.,3.14);
199 fHistPhiLYZ->SetXTitle("Phi from LYZ");
200 fHistPhiLYZ->SetYTitle("Counts");
201 fHistList->Add(fHistPhiLYZ);
203 fHistPhiEP = new TH1F("Flow_PhiEP_LYZEP","Flow_PhiEP_LYZEP",100,0.,3.14);
204 fHistPhiEP->SetXTitle("Phi from EP");
205 fHistPhiEP->SetYTitle("Counts");
206 fHistList->Add(fHistPhiEP);
208 fEventNumber = 0; //set number of events to zero
212 //-----------------------------------------------------------------------
214 void AliFlowAnalysisWithLYZEventPlane::Make(AliFlowEventSimple* anEvent, AliFlowLYZEventPlane* aLYZEP) {
216 //Get the event plane and weight for each event
219 //fill control histograms
220 fCommonHists->FillControlHistograms(anEvent);
222 //get the Q vector from the FlowEvent
223 AliFlowVector vQ = anEvent->GetQ();
224 if (vQ.X()== 0. && vQ.Y()== 0. ) { cout<<"Q vector is NULL!"<<endl; }
225 //Weight with the multiplicity
228 if (vQ.GetMult()!=0.) {
229 dQX = vQ.X()/vQ.GetMult();
230 dQY = vQ.Y()/vQ.GetMult();
231 } else {cerr<<"vQ.GetMult() is zero!"<<endl; }
233 //cout<<"vQ("<<dQX<<","<<dQY<<")"<<endl;
235 //for chi calculation:
237 fHistQsumforChi->SetBinContent(1,fQsum->X());
238 fHistQsumforChi->SetBinContent(2,fQsum->Y());
240 fHistQsumforChi->SetBinContent(3,fQ2sum);
241 //cout<<"fQ2sum = "<<fQ2sum<<endl;
243 //call AliFlowLYZEventPlane::CalculateRPandW() here!
244 aLYZEP->CalculateRPandW(vQ);
246 Double_t dWR = aLYZEP->GetWR();
247 Double_t dRP = aLYZEP->GetPsi();
249 //fHistProWr->Fill(vQ.Mod(),dWR); //this weight is always positive
250 fHistPhiLYZ->Fill(dRP);
252 //plot difference between event plane from EP-method and LYZ-method
253 Double_t dRPEP = vQ.Phi()/2; //gives distribution from (0 to pi)
254 //Double_t dRPEP = 0.5*TMath::ATan2(vQ.Y(),vQ.X()); //gives distribution from (-pi/2 to pi/2)
255 //cout<<"dRPEP = "<< dRPEP <<endl;
256 fHistPhiEP->Fill(dRPEP);
258 Double_t dDeltaPhi = dRPEP - dRP;
259 if (dDeltaPhi < 0.) { dDeltaPhi += TMath::Pi(); } //to shift distribution from (-pi/2 to pi/2) to (0 to pi)
260 //cout<<"dDeltaPhi = "<<dDeltaPhi<<endl;
261 fHistDeltaPhi->Fill(dDeltaPhi);
264 Double_t dLow = TMath::Pi()/4.;
265 Double_t dHigh = 3.*(TMath::Pi()/4.);
266 if ((dDeltaPhi > dLow) && (dDeltaPhi < dHigh)){
267 dRP -= (TMath::Pi()/2);
269 cerr<<"*** dRP modified ***"<<endl;
271 fHistProWr->Fill(vQ.Mod(),dWR); //corrected weight
273 //calculate flow for RP and POI selections
274 //loop over the tracks of the event
275 Int_t iNumberOfTracks = anEvent->NumberOfTracks();
276 for (Int_t i=0;i<iNumberOfTracks;i++)
278 AliFlowTrackSimple* pTrack = anEvent->GetTrack(i) ;
280 Double_t dPhi = pTrack->Phi();
281 //if (dPhi<0.) fPhi+=2*TMath::Pi();
282 Double_t dPt = pTrack->Pt();
283 Double_t dEta = pTrack->Eta();
285 Double_t dv2 = dWR * TMath::Cos(2*(dPhi-dRP));
286 if (pTrack->UseForIntegratedFlow()) {
287 //fill histograms for RP selection
288 fHistProVetaRP -> Fill(dEta,dv2);
289 fHistProVPtRP -> Fill(dPt,dv2);
291 if (pTrack->UseForDifferentialFlow()) {
292 //fill histograms for POI selection
293 fHistProVetaPOI -> Fill(dEta,dv2);
294 fHistProVPtPOI -> Fill(dPt,dv2);
300 // cout<<"@@@@@ "<<fEventNumber<<" events processed"<<endl;
304 //--------------------------------------------------------------------
305 void AliFlowAnalysisWithLYZEventPlane::Finish() {
307 //plot histograms etc.
308 cout<<"AliFlowAnalysisWithLYZEventPlane::Finish()"<<endl;
311 Double_t dJ01 = 2.405;
312 Int_t iNtheta = AliFlowLYZConstants::kTheta;
313 Int_t iNbinsPt = AliFlowCommonConstants::GetNbinsPt();
314 Int_t iNbinsEta = AliFlowCommonConstants::GetNbinsEta();
315 //set the event number
316 SetEventNumber((int)fCommonHists->GetHistMultOrig()->GetEntries());
317 //cout<<"number of events processed is "<<fEventNumber<<endl;
319 //set the sum of Q vectors
320 fQsum->Set(fHistQsumforChi->GetBinContent(1),fHistQsumforChi->GetBinContent(2));
321 SetQ2sum(fHistQsumforChi->GetBinContent(3));
323 //calculate dV the mean of dVtheta
324 Double_t dVtheta = 0;
326 for (Int_t theta=0;theta<iNtheta;theta++) {
327 Double_t dR0 = fFirstr0theta->GetBinContent(theta+1);
328 if (dR0!=0.) { dVtheta = dJ01/dR0 ;}
334 Double_t dSigma2 = 0;
336 if (fEventNumber!=0) {
337 *fQsum /= fEventNumber;
338 //cerr<<"fQsum->X() = "<<fQsum->X()<<endl;
339 //cerr<<"fQsum->Y() = "<<fQsum->Y()<<endl;
340 fQ2sum /= fEventNumber;
341 //cerr<<"fEventNumber = "<<fEventNumber<<endl;
342 //cerr<<"fQ2sum = "<<fQ2sum<<endl;
343 dSigma2 = fQ2sum - TMath::Power(fQsum->X(),2.) - TMath::Power(fQsum->Y(),2.) - TMath::Power(dV,2.); //BP eq. 62
344 //cerr<<"dSigma2"<<dSigma2<<endl;
345 if (dSigma2>0) dChi = dV/TMath::Sqrt(dSigma2);
347 fCommonHistsRes->FillChiRP(dChi);
349 // recalculate statistical errors on integrated flow
350 //combining 5 theta angles to 1 relative error BP eq. 89
351 Double_t dRelErr2comb = 0.;
352 Int_t iEvts = fEventNumber;
354 for (Int_t theta=0;theta<iNtheta;theta++){
355 Double_t dTheta = ((double)theta/iNtheta)*TMath::Pi();
356 Double_t dApluscomb = TMath::Exp((dJ01*dJ01)/(2*dChi*dChi)*
358 Double_t dAmincomb = TMath::Exp(-(dJ01*dJ01)/(2*dChi*dChi)*
360 dRelErr2comb += (1/(2*iEvts*(dJ01*dJ01)*TMath::BesselJ1(dJ01)*
361 TMath::BesselJ1(dJ01)))*
362 (dApluscomb*TMath::BesselJ0(2*dJ01*TMath::Sin(dTheta/2)) +
363 dAmincomb*TMath::BesselJ0(2*dJ01*TMath::Cos(dTheta/2)));
365 dRelErr2comb /= iNtheta;
367 Double_t dRelErrcomb = TMath::Sqrt(dRelErr2comb);
368 Double_t dVErr = dV*dRelErrcomb ;
369 fCommonHistsRes->FillIntegratedFlowRP(dV, dVErr);
371 cout<<"*************************************"<<endl;
372 cout<<"*************************************"<<endl;
373 cout<<" Integrated flow from "<<endl;
374 cout<<" Lee-Yang Zeroes Event Plane "<<endl;
376 cout<<"dChi = "<<dChi<<endl;
377 cout<<"dV(RP) = "<<dV<<" +- "<<dVErr<<endl;
382 //copy content of profile into TH1D, add error and fill the AliFlowCommonHistResults
384 //v as a function of eta for RP selection
385 for(Int_t b=0;b<iNbinsEta;b++) {
386 Double_t dv2pro = fHistProVetaRP->GetBinContent(b);
387 Double_t dNprime = fCommonHists->GetEntriesInEtaBinRP(b);
388 Double_t dErrdifcomb = 0.; //set error to zero
389 Double_t dErr2difcomb = 0.; //set error to zero
392 for (Int_t theta=0;theta<iNtheta;theta++) {
393 Double_t dTheta = ((double)theta/iNtheta)*TMath::Pi();
394 Double_t dApluscomb = TMath::Exp((dJ01*dJ01)/(2*dChi*dChi)*
396 Double_t dAmincomb = TMath::Exp(-(dJ01*dJ01)/(2*dChi*dChi)*
398 dErr2difcomb += (TMath::Cos(dTheta)/(4*dNprime*TMath::BesselJ1(dJ01)*
399 TMath::BesselJ1(dJ01)))*
400 ((dApluscomb*TMath::BesselJ0(2*dJ01*TMath::Sin(dTheta/2))) -
401 (dAmincomb*TMath::BesselJ0(2*dJ01*TMath::Cos(dTheta/2))));
405 if (dErr2difcomb!=0.) {
406 dErr2difcomb /= iNtheta;
407 dErrdifcomb = TMath::Sqrt(dErr2difcomb);
409 else {dErrdifcomb = 0.;}
411 fCommonHistsRes->FillDifferentialFlowEtaRP(b, dv2pro, dErrdifcomb);
415 //v as a function of eta for POI selection
416 for(Int_t b=0;b<iNbinsEta;b++) {
417 Double_t dv2pro = fHistProVetaPOI->GetBinContent(b);
418 Double_t dNprime = fCommonHists->GetEntriesInEtaBinPOI(b);
419 Double_t dErrdifcomb = 0.; //set error to zero
420 Double_t dErr2difcomb = 0.; //set error to zero
423 for (Int_t theta=0;theta<iNtheta;theta++) {
424 Double_t dTheta = ((double)theta/iNtheta)*TMath::Pi();
425 Double_t dApluscomb = TMath::Exp((dJ01*dJ01)/(2*dChi*dChi)*
427 Double_t dAmincomb = TMath::Exp(-(dJ01*dJ01)/(2*dChi*dChi)*
429 dErr2difcomb += (TMath::Cos(dTheta)/(4*dNprime*TMath::BesselJ1(dJ01)*
430 TMath::BesselJ1(dJ01)))*
431 ((dApluscomb*TMath::BesselJ0(2*dJ01*TMath::Sin(dTheta/2))) -
432 (dAmincomb*TMath::BesselJ0(2*dJ01*TMath::Cos(dTheta/2))));
436 if (dErr2difcomb!=0.) {
437 dErr2difcomb /= iNtheta;
438 dErrdifcomb = TMath::Sqrt(dErr2difcomb);
440 else {dErrdifcomb = 0.;}
442 fCommonHistsRes->FillDifferentialFlowEtaPOI(b, dv2pro, dErrdifcomb);
445 //v as a function of Pt for RP selection
446 for(Int_t b=0;b<iNbinsPt;b++) {
447 Double_t dv2pro = fHistProVPtRP->GetBinContent(b);
448 Double_t dNprime = fCommonHists->GetEntriesInPtBinRP(b);
449 Double_t dErrdifcomb = 0.; //set error to zero
450 Double_t dErr2difcomb = 0.; //set error to zero
453 for (Int_t theta=0;theta<iNtheta;theta++) {
454 Double_t dTheta = ((double)theta/iNtheta)*TMath::Pi();
455 Double_t dApluscomb = TMath::Exp((dJ01*dJ01)/(2*dChi*dChi)*
457 Double_t dAmincomb = TMath::Exp(-(dJ01*dJ01)/(2*dChi*dChi)*
459 dErr2difcomb += (TMath::Cos(dTheta)/(4*dNprime*TMath::BesselJ1(dJ01)*
460 TMath::BesselJ1(dJ01)))*
461 ((dApluscomb*TMath::BesselJ0(2*dJ01*TMath::Sin(dTheta/2))) -
462 (dAmincomb*TMath::BesselJ0(2*dJ01*TMath::Cos(dTheta/2))));
466 if (dErr2difcomb!=0.) {
467 dErr2difcomb /= iNtheta;
468 dErrdifcomb = TMath::Sqrt(dErr2difcomb);
469 //cerr<<"dErrdifcomb = "<<dErrdifcomb<<endl;
471 else {dErrdifcomb = 0.;}
474 fCommonHistsRes->FillDifferentialFlowPtRP(b, dv2pro, dErrdifcomb);
477 //v as a function of Pt for POI selection
478 TH1F* fHistPtDiff = fCommonHists->GetHistPtDiff(); //for calculating integrated flow
483 for(Int_t b=0;b<iNbinsPt;b++) {
484 Double_t dv2pro = fHistProVPtPOI->GetBinContent(b);
485 Double_t dNprime = fCommonHists->GetEntriesInPtBinPOI(b);
487 //cerr<<"dNprime = "<<dNprime<<endl;
488 //Int_t iNprime = TMath::Nint(fHistProVPtPOI->GetBinEntries(b));
489 //cerr<<"iNprime = "<<iNprime<<endl;
491 Double_t dErrdifcomb = 0.; //set error to zero
492 Double_t dErr2difcomb = 0.; //set error to zero
495 for (Int_t theta=0;theta<iNtheta;theta++) {
496 Double_t dTheta = ((double)theta/iNtheta)*TMath::Pi();
497 Double_t dApluscomb = TMath::Exp((dJ01*dJ01)/(2*dChi*dChi)*
499 Double_t dAmincomb = TMath::Exp(-(dJ01*dJ01)/(2*dChi*dChi)*
501 dErr2difcomb += (TMath::Cos(dTheta)/(4*dNprime*TMath::BesselJ1(dJ01)*
502 TMath::BesselJ1(dJ01)))*
503 ((dApluscomb*TMath::BesselJ0(2*dJ01*TMath::Sin(dTheta/2))) -
504 (dAmincomb*TMath::BesselJ0(2*dJ01*TMath::Cos(dTheta/2))));
508 if (dErr2difcomb!=0.) {
509 dErr2difcomb /= iNtheta;
510 dErrdifcomb = TMath::Sqrt(dErr2difcomb);
511 //cerr<<"dErrdifcomb = "<<dErrdifcomb<<endl;
513 else {dErrdifcomb = 0.;}
516 fCommonHistsRes->FillDifferentialFlowPtPOI(b, dv2pro, dErrdifcomb);
518 //calculate integrated flow for POI selection
520 Double_t dYieldPt = fHistPtDiff->GetBinContent(b);
521 dVPOI += dv2pro*dYieldPt;
523 dErrV += dYieldPt*dYieldPt*dErrdifcomb*dErrdifcomb;
524 } else { cout<<"fHistPtDiff is NULL"<<endl; }
528 dVPOI /= dSum; //the pt distribution should be normalised
529 dErrV /= (dSum*dSum);
530 dErrV = TMath::Sqrt(dErrV);
532 fCommonHistsRes->FillIntegratedFlowPOI(dVPOI,dErrV);
534 cout<<"dV(POI) = "<<dVPOI<<" +- "<<dErrV<<endl;
536 cout<<"*************************************"<<endl;
537 cout<<"*************************************"<<endl;
539 //cout<<".....finished"<<endl;