1 /**************************************************************************
2 * Copyright(c) 1998-1999, 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 /////////////////////////////////////////////////////////////////////////////////////////
17 //Description: Maker to analyze Flow using the LeeYangZeros method
18 // Equation numbers are from Big Paper (BP): Nucl. Phys. A 727, 373 (2003)
19 // Practical Guide (PG): J. Phys. G: Nucl. Part. Phys. 30, S1213 (2004)
20 // Adapted from StFlowLeeYangZerosMaker.cxx
21 // by Markus Oldenberg and Art Poskanzer, LBNL
22 // with advice from Jean-Yves Ollitrault and Nicolas Borghini
24 //Author: Naomi van der Kolk (kolk@nikhef.nl)
25 /////////////////////////////////////////////////////////////////////////////////////////
27 #include "Riostream.h" //needed as include
28 #include "TObject.h" //needed as include
29 #include "AliFlowCommonConstants.h" //needed as include
30 #include "AliFlowLYZConstants.h" //needed as include
31 #include "AliFlowAnalysisWithLeeYangZeros.h"
32 #include "AliFlowLYZHist1.h" //needed as include
33 #include "AliFlowLYZHist2.h" //needed as include
34 #include "AliFlowCommonHist.h" //needed as include
35 #include "AliFlowCommonHistResults.h" //needed as include
36 #include "AliFlowEventSimple.h" //needed as include
37 #include "AliFlowTrackSimple.h" //needed as include
41 #include "TMath.h" //needed as include
42 #include "TFile.h" //needed as include
51 ClassImp(AliFlowAnalysisWithLeeYangZeros)
53 //-----------------------------------------------------------------------
55 AliFlowAnalysisWithLeeYangZeros::AliFlowAnalysisWithLeeYangZeros():
67 fHistProVetaPOI(NULL),
70 fHistProR0theta(NULL),
71 fHistProReDenom(NULL),
72 fHistProImDenom(NULL),
73 fHistProReDtheta(NULL),
74 fHistProImDtheta(NULL),
75 fHistQsumforChi(NULL),
81 if (fDebug) cout<<"****AliFlowAnalysisWithLeeYangZeros::AliFlowAnalysisWithLeeYangZeros default constructor****"<<endl;
83 fHistList = new TList();
84 fFirstRunList = new TList();
86 for(Int_t i = 0;i<5;i++)
93 fQsum = new TVector2();
97 //-----------------------------------------------------------------------
100 AliFlowAnalysisWithLeeYangZeros::~AliFlowAnalysisWithLeeYangZeros()
103 if (fDebug) cout<<"****~AliFlowAnalysisWithLeeYangZeros****"<<endl;
106 delete fFirstRunList;
110 //-----------------------------------------------------------------------
112 void AliFlowAnalysisWithLeeYangZeros::WriteHistograms(TString* outputFileName)
114 //store the final results in output .root file
116 TFile *output = new TFile(outputFileName->Data(),"RECREATE");
118 output->WriteObject(fHistList, "cobjLYZ1","SingleKey");
121 output->WriteObject(fHistList, "cobjLYZ2","SingleKey");
126 //-----------------------------------------------------------------------
128 void AliFlowAnalysisWithLeeYangZeros::WriteHistograms(TString outputFileName)
130 //store the final results in output .root file
132 TFile *output = new TFile(outputFileName.Data(),"RECREATE");
134 output->WriteObject(fHistList, "cobjLYZ1","SingleKey");
137 output->WriteObject(fHistList, "cobjLYZ2","SingleKey");
142 //-----------------------------------------------------------------------
144 Bool_t AliFlowAnalysisWithLeeYangZeros::Init()
147 if (fDebug) cout<<"****AliFlowAnalysisWithLeeYangZeros::Init()****"<<endl;
150 Int_t iNtheta = AliFlowLYZConstants::kTheta;
151 Int_t iNbinsPt = AliFlowCommonConstants::GetNbinsPt();
152 Int_t iNbinsEta = AliFlowCommonConstants::GetNbinsEta();
154 Double_t dPtMin = AliFlowCommonConstants::GetPtMin();
155 Double_t dPtMax = AliFlowCommonConstants::GetPtMax();
156 Double_t dEtaMin = AliFlowCommonConstants::GetEtaMin();
157 Double_t dEtaMax = AliFlowCommonConstants::GetEtaMax();
159 //for control histograms
160 if (fFirstRun){ fCommonHists = new AliFlowCommonHist("AliFlowCommonHistLYZ1");
161 fHistList->Add(fCommonHists);
162 fCommonHistsRes = new AliFlowCommonHistResults("AliFlowCommonHistResultsLYZ1");
163 fHistList->Add(fCommonHistsRes);
165 else { fCommonHists = new AliFlowCommonHist("AliFlowCommonHistLYZ2");
166 fHistList->Add(fCommonHists);
167 fCommonHistsRes = new AliFlowCommonHistResults("AliFlowCommonHistResultsLYZ2");
168 fHistList->Add(fCommonHistsRes);
171 fHistQsumforChi = new TH1F("Flow_QsumforChi_LYZ","Flow_QsumforChi_LYZ",3,-1.,2.);
172 fHistQsumforChi->SetXTitle("Qsum.X , Qsum.Y, Q2sum");
173 fHistQsumforChi->SetYTitle("value");
174 fHistList->Add(fHistQsumforChi);
176 //for first loop over events
178 fHistProR0theta = new TProfile("First_FlowPro_r0theta_LYZ","First_FlowPro_r0theta_LYZ",iNtheta,-0.5,iNtheta-0.5);
179 fHistProR0theta->SetXTitle("#theta");
180 fHistProR0theta->SetYTitle("r_{0}^{#theta}");
181 fHistList->Add(fHistProR0theta);
183 fHistProVtheta = new TProfile("First_FlowPro_Vtheta_LYZ","First_FlowPro_Vtheta_LYZ",iNtheta,-0.5,iNtheta-0.5);
184 fHistProVtheta->SetXTitle("#theta");
185 fHistProVtheta->SetYTitle("V_{n}^{#theta}");
186 fHistList->Add(fHistProVtheta);
188 //class AliFlowLYZHist1 defines the histograms: fHistProGtheta, fHistProReGtheta, fHistProImGtheta, fHistProR0theta
189 for (Int_t theta=0;theta<iNtheta;theta++) {
190 TString name = "AliFlowLYZHist1_";
192 fHist1[theta]=new AliFlowLYZHist1(theta, name);
193 fHistList->Add(fHist1[theta]);
197 //for second loop over events
199 fHistProReDenom = new TProfile("Second_FlowPro_ReDenom_LYZ","Second_FlowPro_ReDenom_LYZ" , iNtheta, -0.5, iNtheta-0.5);
200 fHistProReDenom->SetXTitle("#theta");
201 fHistProReDenom->SetYTitle("Re(Q^{#theta}e^{ir_{0}^{#theta}Q^{#theta}})");
202 fHistList->Add(fHistProReDenom);
204 fHistProImDenom = new TProfile("Second_FlowPro_ImDenom_LYZ","Second_FlowPro_ImDenom_LYZ" , iNtheta, -0.5, iNtheta-0.5);
205 fHistProImDenom->SetXTitle("#theta");
206 fHistProImDenom->SetYTitle("Im(Q^{#theta}e^{ir_{0}^{#theta}Q^{#theta}})");
207 fHistList->Add(fHistProImDenom);
209 fHistProVetaRP = new TProfile("Second_FlowPro_VetaRP_LYZ","Second_FlowPro_VetaRP_LYZ",iNbinsEta,dEtaMin,dEtaMax);
210 fHistProVetaRP->SetXTitle("rapidity");
211 fHistProVetaRP->SetYTitle("v_{2}(#eta) for RP selection");
212 fHistList->Add(fHistProVetaRP);
214 fHistProVetaPOI = new TProfile("Second_FlowPro_VetaPOI_LYZ","Second_FlowPro_VetaPOI_LYZ",iNbinsEta,dEtaMin,dEtaMax);
215 fHistProVetaPOI->SetXTitle("rapidity");
216 fHistProVetaPOI->SetYTitle("v_{2}(#eta) for POI selection");
217 fHistList->Add(fHistProVetaPOI);
219 fHistProVPtRP = new TProfile("Second_FlowPro_VPtRP_LYZ","Second_FlowPro_VPtRP_LYZ",iNbinsPt,dPtMin,dPtMax);
220 fHistProVPtRP->SetXTitle("Pt");
221 fHistProVPtRP->SetYTitle("v_{2}(p_{T}) for RP selection");
222 fHistList->Add(fHistProVPtRP);
224 fHistProVPtPOI = new TProfile("Second_FlowPro_VPtPOI_LYZ","Second_FlowPro_VPtPOI_LYZ",iNbinsPt,dPtMin,dPtMax);
225 fHistProVPtPOI->SetXTitle("p_{T}");
226 fHistProVPtPOI->SetYTitle("v_{2}(p_{T}) for POI selection");
227 fHistList->Add(fHistProVPtPOI);
229 fHistProReDtheta = new TProfile("Second_FlowPro_ReDtheta_LYZ","Second_FlowPro_ReDtheta_LYZ",iNtheta, -0.5, iNtheta-0.5);
230 fHistProReDtheta->SetXTitle("#theta");
231 fHistProReDtheta->SetYTitle("Re(D^{#theta})");
232 fHistList->Add(fHistProReDtheta);
234 fHistProImDtheta = new TProfile("Second_FlowPro_ImDtheta_LYZ","Second_FlowPro_ImDtheta_LYZ",iNtheta, -0.5, iNtheta-0.5);
235 fHistProImDtheta->SetXTitle("#theta");
236 fHistProImDtheta->SetYTitle("Im(D^{#theta})");
237 fHistList->Add(fHistProImDtheta);
239 //class AliFlowLYZHist2 defines the histograms:
240 for (Int_t theta=0;theta<iNtheta;theta++) {
241 TString nameRP = "AliFlowLYZHist2RP_";
243 fHist2RP[theta]=new AliFlowLYZHist2(theta, "RP", nameRP);
244 fHistList->Add(fHist2RP[theta]);
246 TString namePOI = "AliFlowLYZHist2POI_";
248 fHist2POI[theta]=new AliFlowLYZHist2(theta, "POI", namePOI);
249 fHistList->Add(fHist2POI[theta]);
252 //read histogram fHistProR0theta from the first run list
254 fHistProR0theta = (TProfile*)fFirstRunList->FindObject("First_FlowPro_r0theta_LYZ");
255 if (!fHistProR0theta) {cout<<"fHistProR0theta has a NULL pointer!"<<endl;}
256 fHistList->Add(fHistProR0theta);
257 } else { cout<<"list is NULL pointer!"<<endl; }
262 if (fDebug) cout<<"****Histograms initialised****"<<endl;
264 fEventNumber = 0; //set event counter to zero
269 //-----------------------------------------------------------------------
271 Bool_t AliFlowAnalysisWithLeeYangZeros::Make(AliFlowEventSimple* anEvent)
274 if (fDebug) cout<<"****AliFlowAnalysisWithLeeYangZeros::Make()****"<<endl;
276 //get tracks from event
279 fCommonHists->FillControlHistograms(anEvent);
280 FillFromFlowEvent(anEvent);
283 fCommonHists->FillControlHistograms(anEvent);
284 SecondFillFromFlowEvent(anEvent);
289 cout<<"##### FlowLeeYangZero: Stack pointer null"<<endl;
292 // cout<<"^^^^read event "<<fEventNumber<<endl;
300 //-----------------------------------------------------------------------
301 Bool_t AliFlowAnalysisWithLeeYangZeros::Finish()
304 if (fDebug) cout<<"****AliFlowAnalysisWithLeeYangZeros::Finish()****"<<endl;
306 //define variables for both runs
307 Double_t dJ01 = 2.405;
308 Int_t iNtheta = AliFlowLYZConstants::kTheta;
309 //set the event number
310 SetEventNumber((int)fCommonHists->GetHistMultOrig()->GetEntries());
311 //cout<<"number of events processed is "<<fEventNumber<<endl;
313 //set the sum of Q vectors
314 fQsum->Set(fHistQsumforChi->GetBinContent(1),fHistQsumforChi->GetBinContent(2));
315 SetQ2sum(fHistQsumforChi->GetBinContent(3));
319 Double_t dVtheta = 0;
322 for (Int_t theta=0;theta<iNtheta;theta++)
324 //get the first minimum r0
325 fHist1[theta]->FillGtheta();
326 dR0 = fHist1[theta]->GetR0();
328 //calculate integrated flow
329 if (dR0!=0.) { dVtheta = dJ01/dR0; }
330 else { cout<<"r0 is not found! Leaving LYZ analysis."<<endl; return kFALSE; }
332 //for estimating systematic error resulting from d0
333 Double_t dBinsize = (AliFlowLYZConstants::fgMax)/(AliFlowLYZConstants::kNbins);
334 Double_t dVplus = -1.;
335 Double_t dVmin = -1.;
336 if (dR0+dBinsize!=0.) {dVplus = dJ01/(dR0+dBinsize);}
337 if (dR0-dBinsize!=0.) {dVmin = dJ01/(dR0-dBinsize);}
338 //convert V to v (normally v = V/M, but here V=v because the Q-vector is scaled by 1/M)
340 Double_t dvplus = dVplus;
341 Double_t dvmin = dVmin;
342 if (fDebug) cout<<"dv = "<<dv<<" and dvplus = "<<dvplus<< " and dvmin = "<<dvmin<<endl;
344 //fill the histograms
345 fHistProR0theta->Fill(theta,dR0);
346 fHistProVtheta->Fill(theta,dVtheta);
347 //get average value of fVtheta = fV
349 } //end of loop over theta
351 //get average value of fVtheta = fV
355 Double_t dSigma2 = 0;
357 if (fEventNumber!=0) {
358 *fQsum /= fEventNumber;
359 fQ2sum /= fEventNumber;
360 dSigma2 = fQ2sum - TMath::Power(fQsum->X(),2.) - TMath::Power(fQsum->Y(),2.) - TMath::Power(dV,2.); //BP eq. 62
361 if (dSigma2>0) dChi = dV/TMath::Sqrt(dSigma2);
363 fCommonHistsRes->FillChiRP(dChi);
365 cout<<"*************************************"<<endl;
366 cout<<"*************************************"<<endl;
367 cout<<" Integrated flow from "<<endl;
368 cout<<" Lee-Yang Zeroes "<<endl;
370 cout<<"Chi = "<<dChi<<endl;
374 // recalculate statistical errors on integrated flow
375 //combining 5 theta angles to 1 relative error BP eq. 89
376 Double_t dRelErr2comb = 0.;
377 Int_t iEvts = fEventNumber;
379 for (Int_t theta=0;theta<iNtheta;theta++){
380 Double_t dTheta = ((double)theta/iNtheta)*TMath::Pi();
381 Double_t dApluscomb = TMath::Exp((dJ01*dJ01)/(2*dChi*dChi)*
383 Double_t dAmincomb = TMath::Exp(-(dJ01*dJ01)/(2*dChi*dChi)*
385 dRelErr2comb += (1/(2*iEvts*(dJ01*dJ01)*TMath::BesselJ1(dJ01)*
386 TMath::BesselJ1(dJ01)))*
387 (dApluscomb*TMath::BesselJ0(2*dJ01*TMath::Sin(dTheta/2)) +
388 dAmincomb*TMath::BesselJ0(2*dJ01*TMath::Cos(dTheta/2)));
390 dRelErr2comb /= iNtheta;
392 Double_t dRelErrcomb = TMath::Sqrt(dRelErr2comb);
394 //copy content of profile into TH1D and add error
395 Double_t dv2pro = dV; //in the case that fv is equal to fV
396 Double_t dv2Err = dv2pro*dRelErrcomb ;
397 cout<<"dV = "<<dv2pro<<" +- "<<dv2Err<<endl;
399 cout<<"*************************************"<<endl;
400 cout<<"*************************************"<<endl;
401 fCommonHistsRes->FillIntegratedFlow(dv2pro, dv2Err);
404 if (fDebug) cout<<"****histograms filled****"<<endl;
407 fEventNumber =0; //set to zero for second round over events
413 //calculate differential flow
415 TComplex cDenom, cNumerRP, cNumerPOI, cDtheta;
417 TComplex i = TComplex::I();
418 Double_t dBesselRatio[3] = {1., 1.202, 2.69};
419 Int_t iNbinsPt = AliFlowCommonConstants::GetNbinsPt();
420 Int_t iNbinsEta = AliFlowCommonConstants::GetNbinsEta();
422 Double_t dEtaRP, dPtRP, dReRatioRP, dVetaRP, dVPtRP, dEtaPOI, dPtPOI, dReRatioPOI, dVetaPOI, dVPtPOI;
425 Double_t dVtheta = 0.;
427 Double_t dReDenom = 0.;
428 Double_t dImDenom = 0.;
429 for (Int_t theta=0;theta<iNtheta;theta++) { //loop over theta
430 if (!fHistProR0theta) {
431 cout << "Hist pointer R0theta in file does not exist" <<endl;
433 dR0 = fHistProR0theta->GetBinContent(theta+1); //histogram starts at bin 1
434 if (fDebug) cerr<<"dR0 = "<<dR0<<endl;
435 if (dR0!=0) dVtheta = dJ01/dR0;
437 // BP Eq. 9 -> Vn^theta = j01/r0^theta
438 if (!fHistProReDenom && !fHistProImDenom) {
439 cout << "Hist pointer fDenom in file does not exist" <<endl;
441 dReDenom = fHistProReDenom->GetBinContent(theta+1);
442 dImDenom = fHistProImDenom->GetBinContent(theta+1);
443 cDenom(dReDenom,dImDenom);
445 //for new method and use by others (only with the sum generating function):
447 cDtheta = dR0*cDenom/dJ01;
448 fHistProReDtheta->Fill(theta,cDtheta.Re());
449 fHistProImDtheta->Fill(theta,cDtheta.Im());
452 cDenom *= TComplex::Power(i, m-1);
453 //cerr<<"TComplex::Power(i, m-1) = "<<TComplex::Power(i, m-1).Rho()<<endl; //checked ok
455 //v as a function of eta for RP selection
456 for (Int_t be=1;be<=iNbinsEta;be++) {
457 dEtaRP = fHist2RP[theta]->GetBinCenter(be);
458 cNumerRP = fHist2RP[theta]->GetNumerEta(be);
459 if (cNumerRP.Rho()==0) {
460 if (fDebug) cerr<<"WARNING: modulus of cNumerRP is zero in Finish()"<<endl;
463 else if (cDenom.Rho()==0) {
464 if (fDebug) cerr<<"WARNING: modulus of cDenom is zero"<<endl;
468 dReRatioRP = (cNumerRP/cDenom).Re();
470 dVetaRP = dBesselRatio[m-1]*dReRatioRP*dVtheta; //BP eq. 12
471 fHistProVetaRP->Fill(dEtaRP,dVetaRP);
472 } //loop over bins be
475 //v as a function of eta for POI selection
476 for (Int_t be=1;be<=iNbinsEta;be++) {
477 dEtaPOI = fHist2POI[theta]->GetBinCenter(be);
478 cNumerPOI = fHist2POI[theta]->GetNumerEta(be);
479 if (cNumerPOI.Rho()==0) {
480 if (fDebug) cerr<<"WARNING: modulus of cNumerPOI is zero in Finish()"<<endl;
483 else if (cDenom.Rho()==0) {
484 if (fDebug) cerr<<"WARNING: modulus of cDenom is zero"<<endl;
488 dReRatioPOI = (cNumerPOI/cDenom).Re();
490 dVetaPOI = dBesselRatio[m-1]*dReRatioPOI*dVtheta; //BP eq. 12
491 fHistProVetaPOI->Fill(dEtaPOI,dVetaPOI);
492 } //loop over bins be
495 //v as a function of Pt for RP selection
496 for (Int_t bp=1;bp<=iNbinsPt;bp++) {
497 dPtRP = fHist2RP[theta]->GetBinCenterPt(bp);
498 cNumerRP = fHist2RP[theta]->GetNumerPt(bp);
499 if (cNumerRP.Rho()==0) {
500 if (fDebug) cerr<<"WARNING: modulus of cNumerRP is zero"<<endl;
503 else if (cDenom.Rho()==0) {
504 if (fDebug) cerr<<"WARNING: modulus of cDenom is zero"<<endl;
508 dReRatioRP = (cNumerRP/cDenom).Re();
510 dVPtRP = dBesselRatio[m-1]*dReRatioRP*dVtheta; //BP eq. 12
511 fHistProVPtRP->Fill(dPtRP,dVPtRP);
512 } //loop over bins bp
516 //v as a function of Pt for POI selection
517 for (Int_t bp=1;bp<=iNbinsPt;bp++) {
518 dPtPOI = fHist2POI[theta]->GetBinCenterPt(bp);
519 cNumerPOI = fHist2POI[theta]->GetNumerPt(bp);
520 if (cNumerPOI.Rho()==0) {
521 if (fDebug) cerr<<"WARNING: modulus of cNumerPOI is zero"<<endl;
524 else if (cDenom.Rho()==0) {
525 if (fDebug) cerr<<"WARNING: modulus of cDenom is zero"<<endl;
529 dReRatioPOI = (cNumerPOI/cDenom).Re();
531 dVPtPOI = dBesselRatio[m-1]*dReRatioPOI*dVtheta; //BP eq. 12
532 fHistProVPtPOI->Fill(dPtPOI,dVPtPOI);
533 } //loop over bins bp
538 }//end of loop over theta
540 //calculate the average of fVtheta = fV
542 if (dV==0.) { cout<<"dV = 0! Leaving LYZ analysis."<<endl; return kFALSE; }
544 //sigma2 and chi (for statistical error calculations)
545 Double_t dSigma2 = 0;
547 if (fEventNumber!=0) {
548 *fQsum /= fEventNumber;
549 //cerr<<"fQsum.X() = "<<fQsum.X()<<endl;
550 //cerr<<"fQsum.Y() = "<<fQsum.Y()<<endl;
551 fQ2sum /= fEventNumber;
552 //cout<<"fQ2sum = "<<fQ2sum<<endl;
553 dSigma2 = fQ2sum - TMath::Power(fQsum->X(),2.) - TMath::Power(fQsum->Y(),2.) - TMath::Power(dV,2.); //BP eq. 62
554 if (dSigma2>0) dChi = dV/TMath::Sqrt(dSigma2);
556 fCommonHistsRes->FillChiRP(dChi);
558 // recalculate statistical errors on integrated flow
559 //combining 5 theta angles to 1 relative error BP eq. 89
560 Double_t dRelErr2comb = 0.;
561 Int_t iEvts = fEventNumber;
563 for (Int_t theta=0;theta<iNtheta;theta++){
564 Double_t dTheta = ((double)theta/iNtheta)*TMath::Pi();
565 Double_t dApluscomb = TMath::Exp((dJ01*dJ01)/(2*dChi*dChi)*
567 Double_t dAmincomb = TMath::Exp(-(dJ01*dJ01)/(2*dChi*dChi)*
569 dRelErr2comb += (1/(2*iEvts*(dJ01*dJ01)*TMath::BesselJ1(dJ01)*
570 TMath::BesselJ1(dJ01)))*
571 (dApluscomb*TMath::BesselJ0(2*dJ01*TMath::Sin(dTheta/2)) +
572 dAmincomb*TMath::BesselJ0(2*dJ01*TMath::Cos(dTheta/2)));
574 dRelErr2comb /= iNtheta;
576 Double_t dRelErrcomb = TMath::Sqrt(dRelErr2comb);
577 Double_t dVErr = dV*dRelErrcomb ;
578 fCommonHistsRes->FillIntegratedFlow(dV,dVErr);
580 cout<<"*************************************"<<endl;
581 cout<<"*************************************"<<endl;
582 cout<<" Integrated flow from "<<endl;
583 cout<<" Lee-Yang Zeroes "<<endl;
585 cout<<"Chi = "<<dChi<<endl;
586 cout<<"dV = "<<dV<<" +- "<<dVErr<<endl;
590 //copy content of profile into TH1D and add error and fill the AliFlowCommonHistResults
592 //v as a function of eta for RP selection
593 for(Int_t b=0;b<iNbinsEta;b++) {
594 Double_t dv2pro = fHistProVetaRP->GetBinContent(b);
595 Double_t dNprime = fCommonHists->GetEntriesInEtaBinRP(b);
596 Double_t dErrdifcomb = 0.; //set error to zero
597 Double_t dErr2difcomb = 0.; //set error to zero
600 for (Int_t theta=0;theta<iNtheta;theta++) {
601 Double_t dTheta = ((double)theta/iNtheta)*TMath::Pi();
602 Double_t dApluscomb = TMath::Exp((dJ01*dJ01)/(2*dChi*dChi)*
604 Double_t dAmincomb = TMath::Exp(-(dJ01*dJ01)/(2*dChi*dChi)*
606 dErr2difcomb += (TMath::Cos(dTheta)/(4*dNprime*TMath::BesselJ1(dJ01)*
607 TMath::BesselJ1(dJ01)))*
608 ((dApluscomb*TMath::BesselJ0(2*dJ01*TMath::Sin(dTheta/2))) -
609 (dAmincomb*TMath::BesselJ0(2*dJ01*TMath::Cos(dTheta/2))));
613 if (dErr2difcomb!=0.) {
614 dErr2difcomb /= iNtheta;
615 dErrdifcomb = TMath::Sqrt(dErr2difcomb);
617 else {dErrdifcomb = 0.;}
619 fCommonHistsRes->FillDifferentialFlowEtaRP(b, dv2pro, dErrdifcomb);
623 //v as a function of eta for POI selection
624 for(Int_t b=0;b<iNbinsEta;b++) {
625 Double_t dv2pro = fHistProVetaPOI->GetBinContent(b);
626 Double_t dNprime = fCommonHists->GetEntriesInEtaBinPOI(b);
627 Double_t dErrdifcomb = 0.; //set error to zero
628 Double_t dErr2difcomb = 0.; //set error to zero
631 for (Int_t theta=0;theta<iNtheta;theta++) {
632 Double_t dTheta = ((double)theta/iNtheta)*TMath::Pi();
633 Double_t dApluscomb = TMath::Exp((dJ01*dJ01)/(2*dChi*dChi)*
635 Double_t dAmincomb = TMath::Exp(-(dJ01*dJ01)/(2*dChi*dChi)*
637 dErr2difcomb += (TMath::Cos(dTheta)/(4*dNprime*TMath::BesselJ1(dJ01)*
638 TMath::BesselJ1(dJ01)))*
639 ((dApluscomb*TMath::BesselJ0(2*dJ01*TMath::Sin(dTheta/2))) -
640 (dAmincomb*TMath::BesselJ0(2*dJ01*TMath::Cos(dTheta/2))));
644 if (dErr2difcomb!=0.) {
645 dErr2difcomb /= iNtheta;
646 dErrdifcomb = TMath::Sqrt(dErr2difcomb);
648 else {dErrdifcomb = 0.;}
650 fCommonHistsRes->FillDifferentialFlowEtaPOI(b, dv2pro, dErrdifcomb);
655 //v as a function of Pt for RP selection
656 TH1F* fHistPtRP = fCommonHists->GetHistPtRP(); //for calculating integrated flow
660 for(Int_t b=0;b<iNbinsPt;b++) {
661 Double_t dv2pro = fHistProVPtRP->GetBinContent(b);
662 Double_t dNprime = fCommonHists->GetEntriesInPtBinRP(b);
663 Double_t dErrdifcomb = 0.; //set error to zero
664 Double_t dErr2difcomb = 0.; //set error to zero
667 for (Int_t theta=0;theta<iNtheta;theta++) {
668 Double_t dTheta = ((double)theta/iNtheta)*TMath::Pi();
669 Double_t dApluscomb = TMath::Exp((dJ01*dJ01)/(2*dChi*dChi)*
671 Double_t dAmincomb = TMath::Exp(-(dJ01*dJ01)/(2*dChi*dChi)*
673 dErr2difcomb += (TMath::Cos(dTheta)/(4*dNprime*TMath::BesselJ1(dJ01)*
674 TMath::BesselJ1(dJ01)))*
675 ((dApluscomb*TMath::BesselJ0(2*dJ01*TMath::Sin(dTheta/2))) -
676 (dAmincomb*TMath::BesselJ0(2*dJ01*TMath::Cos(dTheta/2))));
680 if (dErr2difcomb!=0.) {
681 dErr2difcomb /= iNtheta;
682 dErrdifcomb = TMath::Sqrt(dErr2difcomb);
683 //cerr<<"dErrdifcomb = "<<dErrdifcomb<<endl;
685 else {dErrdifcomb = 0.;}
688 fCommonHistsRes->FillDifferentialFlowPtRP(b, dv2pro, dErrdifcomb);
689 //calculate integrated flow for RP selection
691 Double_t dYieldPt = fHistPtRP->GetBinContent(b);
692 dVRP += dv2pro*dYieldPt;
694 dErrV += dYieldPt*dYieldPt*dErrdifcomb*dErrdifcomb;
695 } else { cout<<"fHistPtRP is NULL"<<endl; }
699 dVRP /= dSum; //the pt distribution should be normalised
700 dErrV /= (dSum*dSum);
701 dErrV = TMath::Sqrt(dErrV);
703 cout<<"dV(RP) = "<<dVRP<<" +- "<<dErrV<<endl;
705 fCommonHistsRes->FillIntegratedFlowRP(dVRP,dErrV);
708 //v as a function of Pt for POI selection
709 TH1F* fHistPtPOI = fCommonHists->GetHistPtPOI(); //for calculating integrated flow
714 for(Int_t b=0;b<iNbinsPt;b++) {
715 Double_t dv2pro = fHistProVPtPOI->GetBinContent(b);
716 Double_t dNprime = fCommonHists->GetEntriesInPtBinPOI(b);
717 Double_t dErrdifcomb = 0.; //set error to zero
718 Double_t dErr2difcomb = 0.; //set error to zero
721 for (Int_t theta=0;theta<iNtheta;theta++) {
722 Double_t dTheta = ((double)theta/iNtheta)*TMath::Pi();
723 Double_t dApluscomb = TMath::Exp((dJ01*dJ01)/(2*dChi*dChi)*
725 Double_t dAmincomb = TMath::Exp(-(dJ01*dJ01)/(2*dChi*dChi)*
727 dErr2difcomb += (TMath::Cos(dTheta)/(4*dNprime*TMath::BesselJ1(dJ01)*
728 TMath::BesselJ1(dJ01)))*
729 ((dApluscomb*TMath::BesselJ0(2*dJ01*TMath::Sin(dTheta/2))) -
730 (dAmincomb*TMath::BesselJ0(2*dJ01*TMath::Cos(dTheta/2))));
734 if (dErr2difcomb!=0.) {
735 dErr2difcomb /= iNtheta;
736 dErrdifcomb = TMath::Sqrt(dErr2difcomb);
737 //cerr<<"dErrdifcomb = "<<dErrdifcomb<<endl;
739 else {dErrdifcomb = 0.;}
742 fCommonHistsRes->FillDifferentialFlowPtPOI(b, dv2pro, dErrdifcomb);
743 //calculate integrated flow for POI selection
745 Double_t dYieldPt = fHistPtPOI->GetBinContent(b);
746 dVPOI += dv2pro*dYieldPt;
748 dErrV += dYieldPt*dYieldPt*dErrdifcomb*dErrdifcomb;
749 } else { cout<<"fHistPtPOI is NULL"<<endl; }
753 dVPOI /= dSum; //the pt distribution should be normalised
754 dErrV /= (dSum*dSum);
755 dErrV = TMath::Sqrt(dErrV);
757 cout<<"dV(POI) = "<<dVPOI<<" +- "<<dErrV<<endl;
759 cout<<"*************************************"<<endl;
760 cout<<"*************************************"<<endl;
761 fCommonHistsRes->FillIntegratedFlowPOI(dVPOI,dErrV);
765 //cout<<"----LYZ analysis finished....----"<<endl<<endl;
771 //-----------------------------------------------------------------------
773 Bool_t AliFlowAnalysisWithLeeYangZeros::FillFromFlowEvent(AliFlowEventSimple* anEvent)
775 // Get event quantities from AliFlowEvent for all particles
777 if (fDebug) cout<<"****AliFlowAnalysisWithLeeYangZeros::FillFromFlowEvent()****"<<endl;
780 cout<<"##### FlowLeeYangZero: FlowEvent pointer null"<<endl;
785 TComplex cExpo, cGtheta, cGthetaNew, cZ;
786 Int_t iNtheta = AliFlowLYZConstants::kTheta;
787 Int_t iNbins = AliFlowLYZConstants::kNbins;
791 Double_t dOrder = 2.;
794 AliFlowVector vQ = anEvent->GetQ();
795 //weight by the multiplicity
798 if (vQ.GetMult() != 0) {
799 dQX = vQ.X()/vQ.GetMult();
800 dQY = vQ.Y()/vQ.GetMult();
804 //for chi calculation:
806 fHistQsumforChi->SetBinContent(1,fQsum->X());
807 fHistQsumforChi->SetBinContent(2,fQsum->Y());
809 fHistQsumforChi->SetBinContent(3,fQ2sum);
810 //cerr<<"fQ2sum = "<<fQ2sum<<endl;
812 for (Int_t theta=0;theta<iNtheta;theta++)
814 Double_t dTheta = ((double)theta/iNtheta)*TMath::Pi()/dOrder;
816 //calculate dQtheta = cos(dOrder*(fPhi-dTheta);the projection of the Q vector on the reference direction dTheta
817 Double_t dQtheta = GetQtheta(vQ, dTheta);
819 for (Int_t bin=1;bin<=iNbins;bin++)
821 Double_t dR = fHist1[theta]->GetBinCenter(bin); //bincentre of bins in histogram //FIXED???
822 //if (theta == 0) cerr<<"cerr::dR = "<<dR<<endl;
825 //calculate the sum generating function
826 cExpo(0.,dR*dQtheta); //Re=0 ; Im=dR*dQtheta
827 cGtheta = TComplex::Exp(cExpo);
831 //calculate the product generating function
832 cGtheta = GetGrtheta(anEvent, dR, dTheta);
833 if (cGtheta.Rho2() > 100.) break;
836 fHist1[theta]->Fill(dR,cGtheta); //fill real and imaginary part of cGtheta
847 //-----------------------------------------------------------------------
848 Bool_t AliFlowAnalysisWithLeeYangZeros::SecondFillFromFlowEvent(AliFlowEventSimple* anEvent)
850 //for differential flow
852 if (fDebug) cout<<"****AliFlowAnalysisWithLeeYangZeros::SecondFillFromFlowEvent()****"<<endl;
855 cout<<"##### FlowLeeYangZero: FlowEvent pointer null"<<endl;
860 TComplex cExpo, cDenom, cNumerRP, cNumerPOI, cCosTermComplex;
861 Double_t dPhi, dEta, dPt;
863 Double_t dCosTermRP = 0.;
864 Double_t dCosTermPOI = 0.;
866 Double_t dOrder = 2.;
867 Int_t iNtheta = AliFlowLYZConstants::kTheta;
871 AliFlowVector vQ = anEvent->GetQ();
872 //weight by the multiplicity
875 if (vQ.GetMult() != 0) {
876 dQX = vQ.X()/vQ.GetMult();
877 dQY = vQ.Y()/vQ.GetMult();
881 //for chi calculation:
883 fHistQsumforChi->SetBinContent(1,fQsum->X());
884 fHistQsumforChi->SetBinContent(2,fQsum->Y());
886 fHistQsumforChi->SetBinContent(3,fQ2sum);
888 for (Int_t theta=0;theta<iNtheta;theta++)
890 Double_t dTheta = ((double)theta/iNtheta)*TMath::Pi()/dOrder;
892 //calculate dQtheta = cos(dOrder*(dPhi-dTheta);the projection of the Q vector on the reference direction dTheta
893 Double_t dQtheta = GetQtheta(vQ, dTheta);
894 //cerr<<"dQtheta for fdenom = "<<dQtheta<<endl;
896 //denominator for differential v
897 if (fHistProR0theta) {
898 dR0 = fHistProR0theta->GetBinContent(theta+1);
901 cout <<"pointer fHistProR0theta does not exist" << endl;
903 //cerr<<"dR0 = "<<dR0 <<endl;
905 if (fUseSum) //sum generating function
907 cExpo(0.,dR0*dQtheta);
908 cDenom = dQtheta*(TComplex::Exp(cExpo)); //BP eq 12
909 //loop over tracks in event
910 Int_t iNumberOfTracks = anEvent->NumberOfTracks();
911 for (Int_t i=0;i<iNumberOfTracks;i++) {
912 AliFlowTrackSimple* pTrack = anEvent->GetTrack(i);
914 dEta = pTrack->Eta();
916 dPhi = pTrack->Phi();
917 if (pTrack->InRPSelection()) { // RP selection
918 dCosTermRP = cos(m*dOrder*(dPhi-dTheta));
919 cNumerRP = dCosTermRP*(TComplex::Exp(cExpo));
920 if (cNumerRP.Rho()==0) {cerr<<"WARNING: modulus of cNumerRP is zero in SecondFillFromFlowEvent"<<endl;}
921 if (fDebug) cerr<<"modulus of cNumerRP is "<<cNumerRP.Rho()<<endl;
922 if (fHist2RP[theta]) {
923 fHist2RP[theta]->Fill(dEta,dPt,cNumerRP); }
925 if (pTrack->InPOISelection()) { //POI selection
926 dCosTermPOI = cos(m*dOrder*(dPhi-dTheta));
927 cNumerPOI = dCosTermPOI*(TComplex::Exp(cExpo));
928 if (cNumerPOI.Rho()==0) {cerr<<"WARNING: modulus of cNumerPOI is zero in SecondFillFromFlowEvent"<<endl;}
929 if (fDebug) cerr<<"modulus of cNumerPOI is "<<cNumerPOI.Rho()<<endl;
930 if (fHist2POI[theta]) {
931 fHist2POI[theta]->Fill(dEta,dPt,cNumerPOI); }
934 // cout << "fHist2 pointer mising" <<endl;
937 else {cerr << "no particle!!!"<<endl;}
941 else //product generating function
943 cDenom = GetDiffFlow(anEvent, dR0, theta);
946 if (fHistProReDenom && fHistProImDenom) {
947 fHistProReDenom->Fill(theta,cDenom.Re()); //fill the real part of fDenom
948 fHistProImDenom->Fill(theta,cDenom.Im()); //fill the imaginary part of fDenom
951 cout << "Pointers to cDenom mising" << endl;
954 }//end of loop over theta
960 //-----------------------------------------------------------------------
961 Double_t AliFlowAnalysisWithLeeYangZeros::GetQtheta(AliFlowVector aQ, Double_t aTheta)
963 //calculate Qtheta. Qtheta is the sum over all particles of cos(dOrder*(dPhi-dTheta)) BP eq. 3
964 if (fDebug) cout<<"****AliFlowAnalysisWithLeeYangZeros::GetQtheta()****"<<endl;
966 Double_t dQtheta = 0.;
967 Double_t dOrder = 2.;
969 dQtheta = aQ.X()*cos(dOrder*aTheta)+aQ.Y()*sin(dOrder*aTheta);
976 //-----------------------------------------------------------------------
977 TComplex AliFlowAnalysisWithLeeYangZeros::GetGrtheta(AliFlowEventSimple* const anEvent, Double_t aR, Double_t aTheta)
979 // Product Generating Function for LeeYangZeros method
980 // PG Eq. 3 (J. Phys. G Nucl. Part. Phys 30 S1213 (2004))
982 if (fDebug) cout<<"****AliFlowAnalysisWithLeeYangZeros::GetGrtheta()****"<<endl;
985 TComplex cG = TComplex::One();
986 Double_t dOrder = 2.;
987 Double_t dWgt = 1./anEvent->GetEventNSelTracksRP(); //weight with the multiplicity
989 Int_t iNumberOfTracks = anEvent->NumberOfTracks();
991 for (Int_t i=0;i<iNumberOfTracks;i++) //loop over tracks in event
993 AliFlowTrackSimple* pTrack = anEvent->GetTrack(i) ;
995 if (pTrack->InRPSelection()) {
996 Double_t dPhi = pTrack->Phi();
997 Double_t dGIm = aR * dWgt*cos(dOrder*(dPhi - aTheta));
998 TComplex cGi(1., dGIm);
999 cG *= cGi; //product over all tracks
1002 else {cerr << "no particle pointer !!!"<<endl;}
1010 //-----------------------------------------------------------------------
1011 TComplex AliFlowAnalysisWithLeeYangZeros::GetDiffFlow(AliFlowEventSimple* const anEvent, Double_t aR0, Int_t theta)
1013 // Sum for the denominator for diff. flow for the Product Generating Function for LeeYangZeros method
1014 // PG Eq. 9 (J. Phys. G Nucl. Part. Phys 30 S1213 (2004))
1015 // Also for v1 mixed harmonics: DF Eq. 5
1016 // It is the deriverative of Grtheta at r0 divided by Grtheta at r0
1018 if (fDebug) cout<<"****AliFlowAnalysisWithLeeYangZeros::GetGrtheta()****"<<endl;
1020 TComplex cG = TComplex::One();
1021 TComplex cdGr0(0.,0.);
1022 Double_t dOrder = 2.;
1025 Int_t iNumberOfTracks = anEvent->NumberOfTracks();
1027 Int_t iNtheta = AliFlowLYZConstants::kTheta;
1028 Double_t dTheta = ((double)theta/iNtheta)*TMath::Pi()/dOrder;
1030 //for the denominator (use all RP selected particles)
1031 for (Int_t i=0;i<iNumberOfTracks;i++) //loop over tracks in event
1033 AliFlowTrackSimple* pTrack = anEvent->GetTrack(i) ;
1035 if (pTrack->InRPSelection()) {
1036 Double_t dPhi = pTrack->Phi();
1037 Double_t dCosTerm = dWgt*cos(dOrder*(dPhi - dTheta));
1039 Double_t dGIm = aR0 * dCosTerm;
1040 TComplex cGi(1., dGIm);
1041 TComplex cCosTermComplex(1., aR0*dCosTerm);
1042 cG *= cGi; //product over all tracks
1044 cdGr0 +=(dCosTerm / cCosTermComplex); //sum over all tracks
1047 else {cerr << "no particle!!!"<<endl;}
1051 for (Int_t i=0;i<iNumberOfTracks;i++)
1053 AliFlowTrackSimple* pTrack = anEvent->GetTrack(i) ;
1055 Double_t dEta = pTrack->Eta();
1056 Double_t dPt = pTrack->Pt();
1057 Double_t dPhi = pTrack->Phi();
1058 Double_t dCosTerm = cos(dOrder*(dPhi-dTheta));
1059 TComplex cCosTermComplex(1.,aR0*dCosTerm);
1061 if (pTrack->InRPSelection()) {
1062 TComplex cNumerRP = cG*dCosTerm/cCosTermComplex; //PG Eq. 9
1063 fHist2RP[theta]->Fill(dEta,dPt,cNumerRP);
1066 if (pTrack->InPOISelection()) {
1067 TComplex cNumerPOI = cG*dCosTerm/cCosTermComplex; //PG Eq. 9
1068 fHist2POI[theta]->Fill(dEta,dPt,cNumerPOI);
1071 else {cerr << "no particle pointer!!!"<<endl;}
1074 TComplex cDenom = cG*cdGr0;
1079 //-----------------------------------------------------------------------