]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/macros/runFlowAnalysisOnTheFly.C
Added class AliFlowEvent, inherits from AliFlowEventSimple.
[u/mrichter/AliRoot.git] / PWG2 / FLOW / macros / runFlowAnalysisOnTheFly.C
CommitLineData
93ff27bd 1#include "TStopwatch.h"
2#include "TObjArray"
3#include "Riostream.h"
4#include "TFile.h"
5
6//--------------------------------------------------------------------------------------
7// RUN SETTINGS
8// flow analysis method can be: (set to kTRUE or kFALSE)
06868ea2 9Bool_t MCEP = kTRUE;
c741f5d0 10Bool_t SP = kTRUE;
06868ea2 11Bool_t GFC = kTRUE;
12Bool_t QC = kTRUE;
13Bool_t FQD = kTRUE;
14Bool_t LYZ1SUM = kTRUE;
15Bool_t LYZ1PROD = kTRUE;
c741f5d0 16Bool_t LYZ2SUM = kFALSE;
17Bool_t LYZ2PROD = kFALSE;
5b40431d 18Bool_t LYZEP = kFALSE;
d66d46f7 19Bool_t MH = kTRUE; // mixed harmonics
83bc3e95 20Bool_t NL = kFALSE; // nested loops
d66d46f7 21Bool_t MCEP_AH = kFALSE; // MCEP in another harmonic
93ff27bd 22//--------------------------------------------------------------------------------------
23
7fb984f6 24// Weights
25// use weights for Q-vector:
26Bool_t usePhiWeights = kFALSE; // phi weights (correction for non-uniform azimuthal acceptance)
27Bool_t usePtWeights = kFALSE; // pt weights
28Bool_t useEtaWeights = kFALSE; // eta weights
29
7a01f4a7 30// Define the range for eta subevents
31Double_t minA = -0.9;
32Double_t maxA = -0.01;
33Double_t minB = 0.01;
34Double_t maxB = 0.9;
35
e1911c19 36// Define simple cuts for RP selection:
37Double_t ptMinRP = 0.0; // in GeV
38Double_t ptMaxRP = 10.0; // in GeV
d66d46f7 39Double_t etaMinRP = -1.;
40Double_t etaMaxRP = 1.;
e1911c19 41Double_t phiMinRP = 0.0; // in degrees
42Double_t phiMaxRP = 360.0; // in degrees
43Int_t pidRP = -1; // to be improved (supported eventually)
44
45// Define simple cuts for POI selection:
46Double_t ptMinPOI = 0.0; // in GeV
47Double_t ptMaxPOI = 10.0; // in GeV
d66d46f7 48Double_t etaMinPOI = -1.;
49Double_t etaMaxPOI = 1.;
e1911c19 50Double_t phiMinPOI = 0.0; // in degrees
51Double_t phiMaxPOI = 360.0; // in degrees
52Int_t pidPOI = -1; // to be improved (supported eventually)
53
7fb984f6 54// Parameters for the simulation of events 'on the fly':
7a01f4a7 55//===SEED========================================================
56// use always the same seed for random generators.
57// usage of same seed (kTRUE) is relevant in two cases:
58// 1.) If you want to use LYZ method to calcualte differential flow;
59// 2.) If you want to use phi weights for GFC, QC and FQD
2a54d329 60Bool_t bSameSeed = kFALSE;
4d603348 61
7a01f4a7 62//===NONFLOW=============================================
63// number of times to use each track (to simulate nonflow)
64Int_t iLoops = 1;
524798bf 65Double_t phiRange = 0.0; // If the original track with azimuthal angle phi is splitted,
66 // the azimuthal angle of splitted track is sampled uniformly
67 // from (phi-phiRange, phi+phiRange). If phiRange = 0.0, the
68 // azimuthal angle of splitted track is the same as azimuthal
69 // angle of original track. (Remark: phiRange's unit is degree.)
2a54d329 70Double_t ptRange = 0.0; // If the original track with momentum pt is splitted,
71 // the momentum of splitted track is sampled uniformly
72 // from (pt-ptRange, pt+ptRange). If ptRange = 0.0, the
73 // momentum of splitted track is the same as momentum
524798bf 74 // of original track. (Remark: ptRange's unit is GeV.)
2a54d329 75Double_t etaRange = 0.0; // If the original track with pseudorapidity eta is splitted,
524798bf 76 // the pseudorapidity of splitted track is sampled uniformly
77 // from (eta-etaRange, eta+etaRange). If etaRange = 0.0, the
78 // pseudorapidity of splitted track will be the same as the
79 // pseudorapidity of original track.
e1911c19 80// in addition one can simulate nonflow only in a certain detector's sector
81// ranging from nonflowSectorMin to nonflowSectorMax. Outside this sector the
82// tracks will not be splitted. Use the following two settings only if iLoops>1:
83Double_t nonflowSectorMin = 0.0; // detector's sector in which tracks will be splitted starts at this angle (in degrees)
84Double_t nonflowSectorMax = 360.0; // detector's sector in which tracks will be splitted ends at this angle (in degrees)
93ff27bd 85
7a01f4a7 86//===FLOW HARMONICS===============================================================
bdb5c432 87// harmonics V1, V2, V4... are constants or functions of pt and eta:
88Bool_t bPtDependentHarmonicV1 = kFALSE;
89Bool_t bEtaDependentHarmonicV1 = kFALSE;
90Bool_t bPtDependentHarmonicV2 = kFALSE;
91Bool_t bEtaDependentHarmonicV2 = kFALSE;
92Bool_t bPtDependentHarmonicV4 = kFALSE;
93Bool_t bEtaDependentHarmonicV4 = kFALSE;
94// 1.) if you use constant harmonics (bPtDependentHarmonic* = kFALSE, bEtaDependentHarmonic* = kFALSE)
95// you can additionally select if V2 will be sampled e-b-e from Gaussian or from uniform distribution
96// (constant harmonics V1 and V4 will be always sampled from Gaussian):
524798bf 97Bool_t bConstantV2IsSampledFromGauss = kTRUE;
98 // 1a.) if kTRUE = elliptic flow of RPs is sampled e-b-e from Gaussian distribution with
99 // mean = dV2RP and spread = dV2SpreadRP (analogously for V1 and V4).
100 // 1b.) if kFALSE = elliptic flow of RPs is sampled e-b-e uniformly from
101 // interval [dMinV2RP,dMaxV2RP] (not supported for V1 and V4).
102 // 1c.) for a fixed elliptic flow e-b-e use Gaussian with zero spread or use uniform with dMinV2RP=dMaxV2RP
103 // V2:
104 Double_t dV2RP = 0.05; // elliptic flow of RPs (if sampled from Gaussian)
105 Double_t dV2SpreadRP = 0.0; // elliptic flow spread of RPs (if sampled from Gaussian)
d66d46f7 106 Double_t dMinV2RP = 0.04; // minimal elliptic flow of RPs (if sampled uniformly)
107 Double_t dMaxV2RP = 0.06; // maximal elliptic flow of RPs (if sampled uniformly)
524798bf 108 // V1:
109 Double_t dV1RP = 0.0; // directed flow of RPs
110 Double_t dV1SpreadRP = 0.0; // directed flow spread of RPs
111 // V4:
112 Double_t dV4RP = 0.0; // harmonic V4 of RPs (to be improved: name needed)
113 Double_t dV4SpreadRP = 0.0; // harmonic V4's spread of RPs (to be improved: name needed)
bdb5c432 114// 2.) if you use (pt,eta) dependent harmonic V1 (bPtDependentHarmonicV1 = kTRUE or bEtaDependentHarmonicV1 = kTRUE):
115// 2a.) V1(pt) is linear up to pt = dV1PtCutOff and for pt > dV1PtCutOff it is constant, V1(pt) = dV1vsPtEtaMax:
116// 2b.) V1(eta) is determined from formula V1(eta) = -eta
117 Double_t dV1vsPtEtaMax = 0.10; // maximum value of V1(pt,eta) (for pt >= dV1PtCutOff and at eta = 0)
118 Double_t dV1PtCutOff = 2.0; // up to this pt value V1(pt) is growing linearly versus pt
119// 3.) if you use (pt,eta) dependent harmonic V2 (bPtDependentHarmonicV2 = kTRUE or bEtaDependentHarmonicV2 = kTRUE):
120// 2a.) V2(pt) is linear up to pt = dV2PtCutOff and for pt > dV2PtCutOff it is constant, V2(pt) = dV2vsPtEtaMax:
524798bf 121// 2b.) V2(eta) is Gaussian centered at midrapidity (eta=0) with V2(0) = dV2vsPtEtaMax and spread = dV2vsEtaSpread:
bdb5c432 122 Double_t dV2vsPtEtaMax = 0.20; // maximum value of V2(pt,eta) (for pt >= dV2PtCutOff and at eta = 0)
123 Double_t dV2PtCutOff = 2.0; // up to this pt value V2(pt) is growing linearly versus pt
524798bf 124 Double_t dV2vsEtaSpread = 0.75; // V2(eta) is Gaussian centered at midrapidity (eta=0) with spread = dV2vsEtaSpread
bdb5c432 125// 4.) if you use (pt,eta) dependent harmonic V4 (bPtDependentHarmonicV4 = kTRUE or bEtaDependentHarmonicV4 = kTRUE):
126// V4(pt,eta) is determined as V4(pt,eta) = pow(V2(pt,eta),2.)
7a01f4a7 127
128//===MULTIPLICITY===============================================================
129// 1.) if kTRUE = multiplicitiy of RPs is sampled e-b-e from Gaussian distribution with
130// mean = iMultiplicityOfRP and spread = dMultiplicitySpreadOfRP
131// 2.) if kFALSE = multiplicitiy of RPs is sampled e-b-e uniformly from
132// interval [iMinMultOfRP,iMaxMultOfRP]
133// 3.) for a fixed multiplicity use Gaussian with zero spread or use uniform with iMinMult=iMaxMult
134Bool_t bMultDistrOfRPsIsGauss = kTRUE;
135
136Int_t iMultiplicityOfRP = 500; // mean multiplicity of RPs (if sampled from Gaussian)
137Double_t dMultiplicitySpreadOfRP = 0; // multiplicity spread of RPs (if sampled from Gaussian)
d66d46f7 138Int_t iMinMultOfRP = 400; // minimal multiplicity of RPs (if sampled uniformly)
139Int_t iMaxMultOfRP = 600; // maximal multiplicity of RPs (if sampled uniformly)
7a01f4a7 140
141//===DETECTOR ACCEPTANCE===============================================================
142
143// 1.) if kTRUE = detectors has uniform azimuthal acceptance
144// 2.) if kFALSE = you will simulate detector with non-uniform acceptance in one or two sectors.
145// For each of two sectors you specify phi_min, phi_max and probability p. Then all particles
146// going in direction phi_min < phi < phi_max will be taken with probability p. If p = 0, that
147// sector is blocked. Set bellow phimin1, phimax1, p1 for the first sector and phimin2, phimax2, p2
148// for the second sector. If you set phimin2 = phimax2 = p2 = 0, only first non-uniform sector is
149// simulated.
150Bool_t uniformAcceptance = kTRUE;
151
e23cbd39 152// settings for non-uniform acceptance:
153// Remark: set the angles in degrees from interval [0,360] and probability from interval [0,1]
154
155// 1st non-uniform sector:
156Double_t phimin1 = 60; // first non-uniform sector starts at this azimuth
157Double_t phimax1 = 120; // first non-uniform sector ends at this azimuth
e1911c19 158Double_t p1 = 0.5; // e.g. if p1 = 0 all particles emitted in phimin1 < phi < phimax1 are blocked
e23cbd39 159 // e.g. if p1 = 0.5 half of the particles emitted in phimin1 < phi < phimax1 are blocked
160
161// 2nd non-uniform sector (Remark: if you do NOT want to simulate this sector, set phimin2 = phimax2 = p2 = 0):
d66d46f7 162Double_t phimin2 = 0.0; // second non-uniform sector starts at this azimuth (make sure phimin2 > phimax1 !!!!)
163Double_t phimax2 = 0.0; // second non-uniform sector ends at this azimuth
524798bf 164Double_t p2 = 0.0;
7a01f4a7 165
524798bf 166
167//===MODIFYING Pt SPECTRA===============================================================
168Double_t dTemperatureOfRP = 0.44; // 'temperature' of RPs in GeV/c (increase this parameter to get more high pt RPs)
e23cbd39 169
4d603348 170enum anaModes {mLocal,mLocalSource,mLocalPAR};
93ff27bd 171// mLocal: Analyze data on your computer using aliroot
172// mLocalPAR: Analyze data on your computer using root + PAR files
173// mLocalSource: Analyze data on your computer using root + source files
174
524798bf 175int runFlowAnalysisOnTheFly(Int_t nEvts=1000, Int_t mode=mLocal)
93ff27bd 176{
bdb5c432 177 CheckUserSettings();
93ff27bd 178 TStopwatch timer;
179 timer.Start();
180
93ff27bd 181 cout<<endl;
182 cout<<endl;
183 cout<<" ---- ARE YOU READY TO FLY ? ---- "<<endl;
184 cout<<endl;
185
186 cout<<endl;
187 cout<<" ---- BEGIN FLOW ANALYSIS 'ON THE FLY' ---- "<<endl;
188 cout<<endl;
189 cout<<endl;
190
93ff27bd 191 LoadLibraries(mode);
192
4d603348 193 // Initialize the seed for random generator
194 UInt_t sseed = 0;
195
196 if(bSameSeed)
197 {
198 sseed = 44; // the default constant value for seed for random generators
199 }
5b8dccde 200
4d603348 201 if(!bSameSeed)
202 {
203 TTimeStamp dt;
204 sseed = dt.GetNanoSec()/1000;
205 }
206
e23cbd39 207 cout<<endl;
208 cout<<"Seed for the random generators is "<<sseed<<endl;
209 cout<<endl;
210
7fb984f6 211 //---------------------------------------------------------------------------------------
212 // If the weights are used:
213 TFile *fileWithWeights = NULL;
214 TList *listWithWeights = NULL;
215
216 if(usePhiWeights||usePtWeights||useEtaWeights) {
217 fileWithWeights = TFile::Open("weights.root","READ");
218 if(fileWithWeights) {
219 listWithWeights = (TList*)fileWithWeights->Get("weights");
220 }
221 else
222 {cout << " WARNING: the file <weights.root> with weights from the previous run was not found."<<endl;
223 break;
224 }
225 }
226
93ff27bd 227 //---------------------------------------------------------------------------------------
228 // Initialize the flowevent maker
5b8dccde 229 AliFlowEventSimpleMakerOnTheFly* eventMakerOnTheFly = new AliFlowEventSimpleMakerOnTheFly(sseed);
4d603348 230 eventMakerOnTheFly->Init();
7a01f4a7 231 //set the range for eta subevents
232 eventMakerOnTheFly->SetSubeventEtaRange(minA,maxA,minB,maxB);
93ff27bd 233
93ff27bd 234 //---------------------------------------------------------------------------------------
ce4a88f5 235 // Initialize all the flow methods for default analysis:
236 AliFlowAnalysisWithQCumulants *qc = NULL;
237 AliFlowAnalysisWithCumulants *gfc = NULL;
238 AliFlowAnalysisWithFittingQDistribution *fqd = NULL;
239 AliFlowAnalysisWithLeeYangZeros *lyz1sum = NULL;
240 AliFlowAnalysisWithLeeYangZeros *lyz1prod = NULL;
241 AliFlowAnalysisWithLeeYangZeros *lyz2sum = NULL;
242 AliFlowAnalysisWithLeeYangZeros *lyz2prod = NULL;
243 AliFlowAnalysisWithLYZEventPlane *lyzep = NULL;
244 AliFlowAnalysisWithScalarProduct *sp = NULL;
d66d46f7 245 AliFlowAnalysisWithMixedHarmonics *mh = NULL;
83bc3e95 246 AliFlowAnalysisWithNestedLoops *nl = NULL;
ce4a88f5 247 AliFlowAnalysisWithMCEventPlane *mcep = NULL;
d66d46f7 248 AliFlowAnalysisWithMCEventPlane *mcep_AH = NULL;
93ff27bd 249
250 // MCEP = monte carlo event plane
251 if (MCEP) {
252 AliFlowAnalysisWithMCEventPlane *mcep = new AliFlowAnalysisWithMCEventPlane();
bdb5c432 253 //mcep->SetHarmonic(2); // default is v2
93ff27bd 254 mcep->Init();
255 }
256
d66d46f7 257 // MCEP = monte carlo event plane in another harmonic:
258 if(MCEP_AH)
259 {
260 AliFlowAnalysisWithMCEventPlane *mcep_ah = new AliFlowAnalysisWithMCEventPlane();
261 mcep_ah->SetHarmonic(1);
262 mcep_ah->Init();
263 }
264
265 // Mixed harmonics:
266 if(MH)
267 {
268 AliFlowAnalysisWithMixedHarmonics *mh = new AliFlowAnalysisWithMixedHarmonics();
269 mh->SetCorrelatorInteger(1); // integer n in expression cos[n(2phi1-phi2-phi3)] = v2n*vn^2
83bc3e95 270 mh->SetMinMultiplicity(100);
271 mh->SetNoOfMultipicityBins(5);
272 mh->SetMultipicityBinWidth(200);
d66d46f7 273 mh->Init();
274 }
275
83bc3e95 276 // NL = nested loops:
277 if(NL) {
278 AliFlowAnalysisWithNestedLoops *nl = new AliFlowAnalysisWithNestedLoops();
279 nl->Init();
280 }
281
ce4a88f5 282 // QC = Q-cumulants
93ff27bd 283 if(QC) {
284 AliFlowAnalysisWithQCumulants* qc = new AliFlowAnalysisWithQCumulants();
7fb984f6 285 if(listWithWeights) qc->SetWeightsList(listWithWeights);
286 if(usePhiWeights) qc->SetUsePhiWeights(usePhiWeights);
287 if(usePtWeights) qc->SetUsePtWeights(usePtWeights);
288 if(useEtaWeights) qc->SetUseEtaWeights(useEtaWeights);
afa4af05 289 // qc->SetHarmonic(2); // default is v2
290 // qc->SetApplyCorrectionForNUA(kTRUE); // default
a5b7efd0 291 // qc->SetCalculate2DFlow(kFALSE); // default
292 // qc->SetMultiplicityWeight("combinations"); // default
293 // qc->SetMultiplicityWeight("unit");
294 // qc->SetMultiplicityWeight("multiplicity");
ce4a88f5 295 qc->Init();
93ff27bd 296 }
297
298 // GFC = Generating Function Cumulants
299 if(GFC) {
300 AliFlowAnalysisWithCumulants* gfc = new AliFlowAnalysisWithCumulants();
7fb984f6 301 if(listWithWeights) gfc->SetWeightsList(listWithWeights);
302 if(usePhiWeights) gfc->SetUsePhiWeights(usePhiWeights);
303 if(usePtWeights) gfc->SetUsePtWeights(usePtWeights);
304 if(useEtaWeights) gfc->SetUseEtaWeights(useEtaWeights);
ce4a88f5 305 gfc->Init();
93ff27bd 306 }
307
308 // FQD = Fitting q-distribution
309 if(FQD) {
ce4a88f5 310 AliFlowAnalysisWithFittingQDistribution* fqd = new AliFlowAnalysisWithFittingQDistribution();
7fb984f6 311 if(listWithWeights) fqd->SetWeightsList(listWithWeights);
312 if(usePhiWeights) fqd->SetUsePhiWeights(usePhiWeights);
ce4a88f5 313 fqd->Init();
93ff27bd 314 }
315
316 // SP = Scalar Product
317 if(SP) {
318 AliFlowAnalysisWithScalarProduct* sp = new AliFlowAnalysisWithScalarProduct();
7a01f4a7 319 if(listWithWeights) sp->SetWeightsList(listWithWeights);
320 sp->SetUsePhiWeights(usePhiWeights);
93ff27bd 321 sp->Init();
322 }
323
324 // LYZ1 = Lee-Yang Zeroes first run
c741f5d0 325 if(LYZ1SUM) {
326 AliFlowAnalysisWithLeeYangZeros* lyz1sum = new AliFlowAnalysisWithLeeYangZeros();
327 lyz1sum->SetFirstRun(kTRUE);
328 lyz1sum->SetUseSum(kTRUE);
329 lyz1sum->Init();
330 }
331 if(LYZ1PROD) {
332 AliFlowAnalysisWithLeeYangZeros* lyz1prod = new AliFlowAnalysisWithLeeYangZeros();
333 lyz1prod->SetFirstRun(kTRUE);
334 lyz1prod->SetUseSum(kFALSE);
335 lyz1prod->Init();
93ff27bd 336 }
93ff27bd 337 // LYZ2 = Lee-Yang Zeroes second run
c741f5d0 338 if(LYZ2SUM) {
339 AliFlowAnalysisWithLeeYangZeros* lyz2sum = new AliFlowAnalysisWithLeeYangZeros();
93ff27bd 340 // read the input file from the first run
c741f5d0 341 TString inputFileNameLYZ2SUM = "outputLYZ1SUManalysis.root" ;
342 TFile* inputFileLYZ2SUM = new TFile(inputFileNameLYZ2SUM.Data(),"READ");
343 if(!inputFileLYZ2SUM || inputFileLYZ2SUM->IsZombie()) {
5b40431d 344 cerr << " ERROR: To run LYZ2SUM you need the output file from LYZ1SUM. This file is not there! Please run LYZ1SUM first." << endl ;
93ff27bd 345 break;
346 }
347 else {
c741f5d0 348 TList* inputListLYZ2SUM = (TList*)inputFileLYZ2SUM->Get("cobjLYZ1SUM");
349 if (!inputListLYZ2SUM) {cout<<"Input list LYZ2SUM is NULL pointer!"<<endl; break;}
93ff27bd 350 else {
c741f5d0 351 cout<<"LYZ2SUM input file/list read..."<<endl;
352 lyz2sum->SetFirstRunList(inputListLYZ2SUM);
353 lyz2sum->SetFirstRun(kFALSE);
354 lyz2sum->SetUseSum(kTRUE);
355 lyz2sum->Init();
93ff27bd 356 }
357 }
358 }
c741f5d0 359 if(LYZ2PROD) {
360 AliFlowAnalysisWithLeeYangZeros* lyz2prod = new AliFlowAnalysisWithLeeYangZeros();
361 // read the input file from the first run
362 TString inputFileNameLYZ2PROD = "outputLYZ1PRODanalysis.root" ;
363 TFile* inputFileLYZ2PROD = new TFile(inputFileNameLYZ2PROD.Data(),"READ");
364 if(!inputFileLYZ2PROD || inputFileLYZ2PROD->IsZombie()) {
5b40431d 365 cerr << " ERROR: To run LYZ2PROD you need the output file from LYZ1PROD. This file is not there! Please run LYZ1PROD first." << endl ;
c741f5d0 366 break;
367 }
368 else {
369 TList* inputListLYZ2PROD = (TList*)inputFileLYZ2PROD->Get("cobjLYZ1PROD");
370 if (!inputListLYZ2PROD) {cout<<"Input list LYZ2PROD is NULL pointer!"<<endl; break;}
371 else {
372 cout<<"LYZ2PROD input file/list read..."<<endl;
373 lyz2prod->SetFirstRunList(inputListLYZ2PROD);
374 lyz2prod->SetFirstRun(kFALSE);
375 lyz2prod->SetUseSum(kFALSE);
376 lyz2prod->Init();
377 }
378 }
379 }
380
93ff27bd 381 // LYZEP = Lee-Yang Zeroes event plane
382 if(LYZEP) {
383 AliFlowLYZEventPlane* ep = new AliFlowLYZEventPlane() ;
384 AliFlowAnalysisWithLYZEventPlane* lyzep = new AliFlowAnalysisWithLYZEventPlane();
385 // read the input file from the second lyz run
c741f5d0 386 TString inputFileNameLYZEP = "outputLYZ2SUManalysis.root" ;
93ff27bd 387 TFile* inputFileLYZEP = new TFile(inputFileNameLYZEP.Data(),"READ");
388 if(!inputFileLYZEP || inputFileLYZEP->IsZombie()) {
5b40431d 389 cerr << " ERROR: To run LYZEP you need the output file from LYZ2SUM. This file is not there! Please run LYZ2SUM first." << endl ;
93ff27bd 390 break;
391 }
392 else {
c741f5d0 393 TList* inputListLYZEP = (TList*)inputFileLYZEP->Get("cobjLYZ2SUM");
394 if (!inputListLYZEP) {cout<<"Input list LYZEP is NULL pointer!"<<endl; break;}
93ff27bd 395 else {
396 cout<<"LYZEP input file/list read..."<<endl;
397 ep ->SetSecondRunList(inputListLYZEP);
398 lyzep->SetSecondRunList(inputListLYZEP);
399 ep ->Init();
400 lyzep->Init();
401 }
402 }
403 }
404 //---------------------------------------------------------------------------------------
ce4a88f5 405
524798bf 406 // set the global event parameters:
aaa62cf0 407 eventMakerOnTheFly->SetNoOfLoops(iLoops);
524798bf 408 eventMakerOnTheFly->SetPhiRange(phiRange*TMath::Pi()/180.);
2a54d329 409 eventMakerOnTheFly->SetPtRange(ptRange);
410 eventMakerOnTheFly->SetEtaRange(etaRange);
e1911c19 411 eventMakerOnTheFly->SetNonflowSectorMin(nonflowSectorMin*TMath::Pi()/180.);
412 eventMakerOnTheFly->SetNonflowSectorMax(nonflowSectorMax*TMath::Pi()/180.);
678f8252 413 if(bMultDistrOfRPsIsGauss)
414 {
415 eventMakerOnTheFly->SetMultDistrOfRPsIsGauss(bMultDistrOfRPsIsGauss);
416 eventMakerOnTheFly->SetMultiplicityOfRP(iMultiplicityOfRP);
417 eventMakerOnTheFly->SetMultiplicitySpreadOfRP(dMultiplicitySpreadOfRP);
418 } else
419 {
420 eventMakerOnTheFly->SetMultDistrOfRPsIsGauss(bMultDistrOfRPsIsGauss);
421 eventMakerOnTheFly->SetMinMultOfRP(iMinMultOfRP);
422 eventMakerOnTheFly->SetMaxMultOfRP(iMaxMultOfRP);
423 }
424
cf90787f 425 eventMakerOnTheFly->SetTemperatureOfRP(dTemperatureOfRP);
bdb5c432 426 eventMakerOnTheFly->SetPtDependentHarmonicV1(bPtDependentHarmonicV1);
427 eventMakerOnTheFly->SetEtaDependentHarmonicV1(bEtaDependentHarmonicV1);
428 eventMakerOnTheFly->SetPtDependentHarmonicV2(bPtDependentHarmonicV2);
429 eventMakerOnTheFly->SetEtaDependentHarmonicV2(bEtaDependentHarmonicV2);
430 eventMakerOnTheFly->SetPtDependentHarmonicV4(bPtDependentHarmonicV4);
431 eventMakerOnTheFly->SetEtaDependentHarmonicV4(bEtaDependentHarmonicV4);
432 // V1:
433 if(!(bPtDependentHarmonicV1 || bEtaDependentHarmonicV1))
524798bf 434 {
435 eventMakerOnTheFly->SetV1RP(dV1RP);
436 eventMakerOnTheFly->SetV1SpreadRP(dV1SpreadRP);
bdb5c432 437 } else // (pt,eta) dependent V1
438 {
439 eventMakerOnTheFly->SetV1vsPtEtaMax(dV1vsPtEtaMax);
440 if(bPtDependentHarmonicV1)
441 {
442 eventMakerOnTheFly->SetV1PtCutOff(dV1PtCutOff);
443 }
444 }
445 // V2:
446 if(!(bPtDependentHarmonicV2 || bEtaDependentHarmonicV2)) // constant V2
4d603348 447 {
524798bf 448 eventMakerOnTheFly->SetConstantV2IsSampledFromGauss(bConstantV2IsSampledFromGauss);
449 if(bConstantV2IsSampledFromGauss) // Gauss
55381065 450 {
55381065 451 eventMakerOnTheFly->SetV2RP(dV2RP);
452 eventMakerOnTheFly->SetV2SpreadRP(dV2SpreadRP);
524798bf 453 } else // uniform
55381065 454 {
55381065 455 eventMakerOnTheFly->SetMinV2RP(dMinV2RP);
456 eventMakerOnTheFly->SetMaxV2RP(dMaxV2RP);
457 }
524798bf 458 } else // (pt,eta) dependent V2
459 {
460 eventMakerOnTheFly->SetV2vsPtEtaMax(dV2vsPtEtaMax);
bdb5c432 461 if(bPtDependentHarmonicV2)
524798bf 462 {
bdb5c432 463 eventMakerOnTheFly->SetV2PtCutOff(dV2PtCutOff);
524798bf 464 }
bdb5c432 465 if(bEtaDependentHarmonicV2)
524798bf 466 {
467 eventMakerOnTheFly->SetV2vsEtaSpread(dV2vsEtaSpread);
468 }
bdb5c432 469 }
470 // V4:
471 if(!(bPtDependentHarmonicV4 || bEtaDependentHarmonicV4))
472 {
473 eventMakerOnTheFly->SetV4RP(dV4RP);
474 eventMakerOnTheFly->SetV4SpreadRP(dV4SpreadRP);
475 }
e23cbd39 476
477 // non-uniform acceptance:
478 if(!uniformAcceptance)
479 {
480 eventMakerOnTheFly->SetFirstSectorPhiMin(phimin1);
481 eventMakerOnTheFly->SetFirstSectorPhiMax(phimax1);
482 eventMakerOnTheFly->SetFirstSectorProbability(p1);
483 eventMakerOnTheFly->SetSecondSectorPhiMin(phimin2);
484 eventMakerOnTheFly->SetSecondSectorPhiMax(phimax2);
485 eventMakerOnTheFly->SetSecondSectorProbability(p2);
486 }
e1911c19 487
488 // simple cuts for RPs and POIs:
489 AliFlowTrackSimpleCuts *cutsRP = new AliFlowTrackSimpleCuts();
490 cutsRP->SetPtMax(ptMaxRP);
491 cutsRP->SetPtMin(ptMinRP);
492 cutsRP->SetEtaMax(etaMaxRP);
493 cutsRP->SetEtaMin(etaMinRP);
494 cutsRP->SetPhiMax(phiMaxRP*TMath::Pi()/180.);
495 cutsRP->SetPhiMin(phiMinRP*TMath::Pi()/180.);
496 cutsRP->SetPID(pidRP);
497
498 AliFlowTrackSimpleCuts *cutsPOI = new AliFlowTrackSimpleCuts();
499 cutsPOI->SetPtMax(ptMaxPOI);
500 cutsPOI->SetPtMin(ptMinPOI);
501 cutsPOI->SetEtaMax(etaMaxPOI);
502 cutsPOI->SetEtaMin(etaMinPOI);
503 cutsPOI->SetPhiMax(phiMaxPOI*TMath::Pi()/180.);
504 cutsPOI->SetPhiMin(phiMinPOI*TMath::Pi()/180.);
505 cutsPOI->SetPID(pidPOI);
506
93ff27bd 507 //---------------------------------------------------------------------------------------
508 // create and analyze events 'on the fly':
509
93ff27bd 510 for(Int_t i=0;i<nEvts;i++) {
511 // creating the event with above settings:
e1911c19 512 AliFlowEventSimple *event = eventMakerOnTheFly->CreateEventOnTheFly(cutsRP,cutsPOI);
93ff27bd 513
514 // analyzing the created event 'on the fly':
93ff27bd 515 // do flow analysis for various methods:
c741f5d0 516 if(MCEP) mcep->Make(event);
517 if(QC) qc->Make(event);
518 if(GFC) gfc->Make(event);
519 if(FQD) fqd->Make(event);
520 if(LYZ1SUM) lyz1sum->Make(event);
521 if(LYZ1PROD)lyz1prod->Make(event);
522 if(LYZ2SUM) lyz2sum->Make(event);
523 if(LYZ2PROD)lyz2prod->Make(event);
524 if(LYZEP) lyzep->Make(event,ep);
525 if(SP) sp->Make(event);
d66d46f7 526 if(MH) mh->Make(event);
83bc3e95 527 if(NL) nl->Make(event);
d66d46f7 528 if(MCEP_AH) mcep_ah->Make(event);
ce4a88f5 529
93ff27bd 530 delete event;
531 } // end of for(Int_t i=0;i<nEvts;i++)
532 //---------------------------------------------------------------------------------------
533
93ff27bd 534 //---------------------------------------------------------------------------------------
ad87ae62 535 // create a new file which will hold the final results of all methods:
536 TString outputFileName = "AnalysisResults.root";
537 TFile *outputFile = new TFile(outputFileName.Data(),"RECREATE");
538 // create a new file for each method wich will hold list with final results:
83bc3e95 539 const Int_t nMethods = 13;
540 TString method[nMethods] = {"MCEP","SP","GFC","QC","FQD","LYZ1SUM","LYZ1PROD","LYZ2SUM","LYZ2PROD","LYZEP","MH","NL","MCEP_AH"};
ad87ae62 541 TDirectoryFile *dirFileFinal[nMethods] = {NULL};
542 TString fileName[nMethods];
543 for(Int_t i=0;i<nMethods;i++)
544 {
545 // form a file name for each method:
546 fileName[i]+="output";
547 fileName[i]+=method[i].Data();
548 fileName[i]+="analysis";
549 dirFileFinal[i] = new TDirectoryFile(fileName[i].Data(),fileName[i].Data());
550 }
551
ce4a88f5 552 // calculating and storing the final results of default flow analysis:
ad87ae62 553 if(MCEP) {mcep->Finish(); mcep->WriteHistograms(dirFileFinal[0]);}
554 if(SP) {sp->Finish(); sp->WriteHistograms(dirFileFinal[1]);}
555 if(GFC) {gfc->Finish(); gfc->WriteHistograms(dirFileFinal[2]);}
556 if(QC) {qc->Finish(); qc->WriteHistograms(dirFileFinal[3]);}
557 if(FQD) {fqd->Finish(); fqd->WriteHistograms(dirFileFinal[4]);}
558 if(LYZ1SUM) {lyz1sum->Finish(); lyz1sum->WriteHistograms(dirFileFinal[5]);}
559 if(LYZ1PROD){lyz1prod->Finish();lyz1prod->WriteHistograms(dirFileFinal[6]);}
560 if(LYZ2SUM) {lyz2sum->Finish(); lyz2sum->WriteHistograms(dirFileFinal[7]);}
561 if(LYZ2PROD){lyz2prod->Finish();lyz2prod->WriteHistograms(dirFileFinal[8]);}
562 if(LYZEP) {lyzep->Finish(); lyzep->WriteHistograms(dirFileFinal[9]);}
d66d46f7 563 if(MH) {mh->Finish(); mh->WriteHistograms(dirFileFinal[10]);}
83bc3e95 564 if(NL) {nl->Finish(); nl->WriteHistograms(dirFileFinal[11]);}
565 if(MCEP_AH) {mcep_ah->Finish(); mcep_ah->WriteHistograms(dirFileFinal[12]);}
93ff27bd 566 //---------------------------------------------------------------------------------------
567
ad87ae62 568 outputFile->Close();
569 delete outputFile;
93ff27bd 570
571 cout<<endl;
572 cout<<endl;
573 cout<<" ---- LANDED SUCCESSFULLY ---- "<<endl;
574 cout<<endl;
575
576 timer.Stop();
577 cout << endl;
578 timer.Print();
579}
580
581void SetupPar(char* pararchivename)
582{
583 //Load par files, create analysis libraries
584 //For testing, if par file already decompressed and modified
585 //classes then do not decompress.
586
587 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
588 TString parpar(Form("%s.par", pararchivename)) ;
589 if ( gSystem->AccessPathName(parpar.Data()) ) {
590 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
591 TString processline(Form(".! make %s", parpar.Data())) ;
592 gROOT->ProcessLine(processline.Data()) ;
593 gSystem->ChangeDirectory(cdir) ;
594 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
595 gROOT->ProcessLine(processline.Data()) ;
596 }
597 if ( gSystem->AccessPathName(pararchivename) ) {
598 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
599 gROOT->ProcessLine(processline.Data());
600 }
601
602 TString ocwd = gSystem->WorkingDirectory();
603 gSystem->ChangeDirectory(pararchivename);
604
605 // check for BUILD.sh and execute
606 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
607 printf("*******************************\n");
608 printf("*** Building PAR archive ***\n");
609 cout<<pararchivename<<endl;
610 printf("*******************************\n");
611
612 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
613 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
614 return -1;
615 }
616 }
617 // check for SETUP.C and execute
618 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
619 printf("*******************************\n");
620 printf("*** Setup PAR archive ***\n");
621 cout<<pararchivename<<endl;
622 printf("*******************************\n");
623 gROOT->Macro("PROOF-INF/SETUP.C");
624 }
625
626 gSystem->ChangeDirectory(ocwd.Data());
627 printf("Current dir: %s\n", ocwd.Data());
628}
629
bdb5c432 630void CheckUserSettings()
631{
632 // Check if user settings make sense before taking off:
633
634 if (LYZ1SUM && LYZ2SUM) {cout<<"WARNING: you cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1. "<<endl; exit(); }
635 if (LYZ1PROD && LYZ2PROD) {cout<<"WARNING: you cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1. "<<endl; exit(); }
636 if (LYZ2SUM && LYZEP) {cout<<"WARNING: you cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2."<<endl; exit(); }
637 if (LYZ1SUM && LYZEP) {cout<<"WARNING: you cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2."<<endl; exit(); }
638
639 if(!uniformAcceptance && phimin1 > phimax1)
640 {
641 cout<<"WARNING: you must have phimin1 < phimax1 !!!!"<<endl;
642 break;
643 }
644
645 if (!uniformAcceptance && !((phimin2 == 0.) && (phimax2 == 0.) && (p2 == 0.)) && (phimin2 < phimax1 || phimin2 > phimax2))
646 {
647 cout<<"WARNING: you must have phimin2 > phimax1 and phimin2 < phimax2 !!!!"<<endl;
648 break;
649 }
650
651 if((phimin1 < 0 || phimin1 > 360) || (phimax1 < 0 || phimax1 > 360) ||
652 (phimin2 < 0 || phimin2 > 360) || (phimax2 < 0 || phimax2 > 360) )
653 {
654 cout<<"WARNING: you must take azimuthal angles from interval [0,360] !!!!"<<endl;
655 break;
656 }
657
658 if((p1 < 0 || p1 > 1) || (p2 < 0 || p2 > 1))
659 {
660 cout<<"WARNING: you must take p1 and p2 from interval [0,1] !!!!"<<endl;
661 break;
662 }
663
664 if(bPtDependentHarmonicV4 && !bPtDependentHarmonicV2))
665 {
666 cout<<"WARNING: V4(pt,eta) is determined as pow(V2(pt,eta),2.) !!!!"<<endl;
667 cout<<" You must also set bPtDependentHarmonicV2 = kTRUE in the macro."<<endl;
668 exit(0);
669 }
670
671 if(bEtaDependentHarmonicV4 && !bEtaDependentHarmonicV2))
672 {
673 cout<<"WARNING: V4(pt,eta) is determined as pow(V2(pt,eta),2.) !!!!"<<endl;
674 cout<<" You must also set bEtaDependentHarmonicV2 = kTRUE in the macro."<<endl;
675 exit(0);
676 }
677
678 if(bPtDependentHarmonicV4 && (bEtaDependentHarmonicV4 != bEtaDependentHarmonicV2))
679 {
680 cout<<"WARNING: V4(pt,eta) is determined as pow(V2(pt,eta),2.) !!!!"<<endl;
681 cout<<" You must also have bEtaDependentHarmonicV2 = bEtaDependentHarmonicV4 in the macro."<<endl;
682 exit(0);
683 }
684
685 if(bEtaDependentHarmonicV4 && (bPtDependentHarmonicV4 != bPtDependentHarmonicV2))
686 {
687 cout<<"WARNING: V4(pt,eta) is determined as pow(V2(pt,eta),2.) !!!!"<<endl;
688 cout<<" You must also have bPtDependentHarmonicV2 = bPtDependentHarmonicV4 in the macro."<<endl;
689 exit(0);
690 }
691
692} // end of void CheckUserSettings()
693
93ff27bd 694void LoadLibraries(const anaModes mode) {
695
696 //--------------------------------------
697 // Load the needed libraries most of them already loaded by aliroot
698 //--------------------------------------
ad87ae62 699 //gSystem->Load("libTree");
5d040cf3 700 gSystem->Load("libGeom");
701 gSystem->Load("libVMC");
702 gSystem->Load("libXMLIO");
703 gSystem->Load("libPhysics");
93ff27bd 704
705 //----------------------------------------------------------
706 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
707 //----------------------------------------------------------
708 if (mode==mLocal) {
709 //--------------------------------------------------------
710 // If you want to use already compiled libraries
711 // in the aliroot distribution
712 //--------------------------------------------------------
713 gSystem->Load("libSTEERBase");
714 gSystem->Load("libESD");
715 gSystem->Load("libAOD");
716 gSystem->Load("libANALYSIS");
717 gSystem->Load("libANALYSISalice");
5d040cf3 718 gSystem->Load("libCORRFW");
719 cerr<<"libCORRFW loaded..."<<endl;
720 gSystem->Load("libPWG2flowCommon");
721 cerr<<"libPWG2flowCommon loaded..."<<endl;
722 gSystem->Load("libPWG2flowTasks");
723 cerr<<"libPWG2flowTasks loaded..."<<endl;
93ff27bd 724 }
725
726 else if (mode == mLocalPAR) {
727 //--------------------------------------------------------
728 //If you want to use root and par files from aliroot
729 //--------------------------------------------------------
730 //If you want to use root and par files from aliroot
731 //--------------------------------------------------------
732 SetupPar("STEERBase");
733 SetupPar("ESD");
734 SetupPar("AOD");
735 SetupPar("ANALYSIS");
736 SetupPar("ANALYSISalice");
737 SetupPar("PWG2AOD");
738 SetupPar("CORRFW");
739 SetupPar("PWG2flowCommon");
740 cerr<<"PWG2flowCommon.par loaded..."<<endl;
741 SetupPar("PWG2flowTasks");
742 cerr<<"PWG2flowTasks.par loaded..."<<endl;
743 }
744
745 //---------------------------------------------------------
746 // <<<<<<<<<< Source mode >>>>>>>>>>>>
747 //---------------------------------------------------------
748 else if (mode==mLocalSource) {
749
750 // In root inline compile
751
93ff27bd 752 // Constants
753 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonConstants.cxx+");
754 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZConstants.cxx+");
755 gROOT->LoadMacro("AliFlowCommon/AliFlowCumuConstants.cxx+");
756
757 // Flow event
758 gROOT->LoadMacro("AliFlowCommon/AliFlowVector.cxx+");
7382279b 759 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimple.cxx+");
760 gROOT->LoadMacro("AliFlowCommon/AliFlowEvent.cxx+");
93ff27bd 761 gROOT->LoadMacro("AliFlowCommon/AliFlowEventSimple.cxx+");
762
763 // Cuts
764 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimpleCuts.cxx+");
765
766 // Output histosgrams
767 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHist.cxx+");
768 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHistResults.cxx+");
769 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist1.cxx+");
770 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist2.cxx+");
771
772 // Functions needed for various methods
773 gROOT->LoadMacro("AliFlowCommon/AliCumulantsFunctions.cxx+");
93ff27bd 774 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZEventPlane.cxx+");
775
776 // Flow Analysis code for various methods
777 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithMCEventPlane.cxx+");
778 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithScalarProduct.cxx+");
779 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithLYZEventPlane.cxx+");
780 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithLeeYangZeros.cxx+");
781 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithCumulants.cxx+");
782 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithQCumulants.cxx+");
ce4a88f5 783 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithFittingQDistribution.cxx+");
ecac11c2 784 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithMixedHarmonics.cxx+");
785 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithNestedLoops.cxx+");
93ff27bd 786
a47dc7e4 787 // Class to fill the FlowEvent on the fly (generate Monte Carlo events)
788 gROOT->LoadMacro("AliFlowCommon/AliFlowEventSimpleMakerOnTheFly.cxx+");
93ff27bd 789
790 cout << "finished loading macros!" << endl;
791
792 }
793
794}
795
796