]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGCF/FLOW/macros/runFlowAnalysisOnTheFly.C
Merge branch 'master' of https://git.cern.ch/reps/AliRoot
[u/mrichter/AliRoot.git] / PWGCF / FLOW / macros / runFlowAnalysisOnTheFly.C
CommitLineData
93417736 1// Settings for the simulation of events 'on the fly':
2// a) Determine how many events you want to create;
3// b) Set random or same seed for random generator;
4// c) Determine multiplicites of events;
5// d) Parametrize the phi distribution;
6// d1) Enable/disable uniform event-wise fluctuations of v2;
7// d2) Enable/diable pt dependence of v2;
8// e) Parametrize the pt distribution;
9// f) Determine how many times each sampled particle will be taken (simulating nonflow);
6d19c373 10// g) Configure detector's:
11// g1) acceptance;
12// g2) efficiency;
93417736 13// h) Decide which flow analysis methods you will use;
14// i) Define simple cuts for Reference Particle (RP) selection;
15// j) Define simple cuts for Particle of Interest (POI) selection;
16// k) Define the ranges for two subevents separated with eta gap (needed only for SP method);
17// l) Enable/disable usage of particle weights.
7fb984f6 18
93417736 19// a) Determine how many events you want to create:
20Int_t iNevts = 1000; // total statistics
7a01f4a7 21
93417736 22// b) Set random or same seed for random generator:
23Bool_t bSameSeed = kFALSE; // if kTRUE, the created events are the same when re-doing flow analysis 'on the fly'
e1911c19 24
93417736 25// c) Determine multiplicites of events:
26// Remark 1: Multiplicity M for each event is sampled uniformly from interval iMinMult <= M < iMaxMult;
27// Remark 2: For constant M of e.g. 500 for each event, set iMinMult = 500 and iMaxMult = 501.
28Int_t iMinMult = 500; // uniformly sampled multiplicity is >= iMinMult
29Int_t iMaxMult = 501; // uniformly sampled multiplicity is < iMaxMult
4d603348 30
93417736 31// d) Parametrize the phi distribution:
32// Remark 1: Hardwired is Fourier-like distribution f(phi) = (1/2pi)(1+sum_{n=1}^{4} 2v_n cos[n(phi-rp)]),
33// where reaction plane (rp) is sampled uniformly for each event from interval [0,2pi]
34Double_t dV1 = 0.0; // constant harmonic v1
35Double_t dV2 = 0.05; // constant harmonic v2
36Double_t dV3 = 0.0; // constant harmonic v3
37Double_t dV4 = 0.0; // constant harmonic v4
dd1d2f85 38Double_t dV5 = 0.0; // constant harmonic v5
39Double_t dV6 = 0.0; // constant harmonic v6
93417736 40// Remark 2: By default all harmonics are constant for each event and for each particle. However, for v2
41// the uniform event-wise fluctuations or pt dependence can be enabled:
42// d1) Enable/disable uniform event-wise fluctuations of v2:
43Bool_t bUniformFluctuationsV2 = kFALSE; // enable uniform event-wise flow fluctuations (set than also dMinV2 and dMaxV2 bellow)
44Double_t dMinV2 = 0.04; // lower boundary on v2, when bUniformFluctuationsV2 = kTRUE
45Double_t dMaxV2 = 0.06; // upper boundary on v2, when bUniformFluctuationsV2 = kTRUE
46// d2) Enable/disable pt dependence of v2:
47Bool_t bPtDependentV2 = kFALSE; // enable pt dependence of v2 (set then also dV2vsPtMax and dV2vsPtCutOff bellow)
48Double_t dV2vsPtCutOff = 2.0; // up to pt = dV2vsPtCutOff v2 is growing linearly as a function of pt
49Double_t dV2vsPtMax = 0.20; // for pt >= dV2vsPtCutOff, v2(pt) = dV2vsPtMax
93ff27bd 50
93417736 51// e) Parametrize the pt distribution:
52// Remark: Hardwired is Boltzmann distribution f(pt) = pt*exp[-sqrt(dMass^2+pt^2)/dT]
53Double_t dMass = 0.13957; // mass in GeV/c^2 (e.g. m_{pions} = 0.13957)
54Double_t dTemperature = 0.44; // "temperature" in GeV/c (increase this parameter to get more high pt particles)
598d292e 55
93417736 56// f) Determine how many times each sampled particle will be taken in the analysis (simulating nonflow):
57Int_t nTimes = 1; // e.g. for nTimes = 2, strong 2-particle nonflow correlations are introduced
7a01f4a7 58
6d19c373 59// g1) Configure detector's acceptance:
93417736 60Bool_t uniformAcceptance = kTRUE; // if kTRUE: detectors has uniform azimuthal acceptance.
61 // if kFALSE: you will simulate detector with non-uniform acceptance in one or
62 // two sectors. For each sector you specify phiMin, phiMax and probability p.
63 // Then all particles emitted in direction phiMin < phi < phiMax will be taken
64 // with probability p. If p = 0, that sector is completely blocked. Set bellow
65 // phiMin1, phiMax1, p1 for the first sector and phiMin2, phiMax2, p2 for the second
66 // sector. If you set phiMin2 = phiMax2 = p2 = 0, only first non-uniform sector is
67 // simulated.
68// 1st non-uniform sector:
69Double_t phiMin1 = 60; // first non-uniform sector starts at this azimuth (in degrees)
70Double_t phiMax1 = 120; // first non-uniform sector ends at this azimuth (in degrees)
71Double_t p1 = 0.5; // probablitity that particles emitted in [phiMin1,phiMax1] are taken
72// 2nd non-uniform sector:
73Double_t phiMin2 = 0.; // first non-uniform sector starts at this azimuth (in degrees)
74Double_t phiMax2 = 0.; // first non-uniform sector ends at this azimuth (in degrees)
75Double_t p2 = 0.; // probablitity that particles emitted in [phiMin2,phiMax2] are taken
7a01f4a7 76
6d19c373 77// g2) Configure detector's efficiency:
78Bool_t uniformEfficiency = kTRUE; // if kTRUE: detectors has uniform pT efficiency
79 // if kFALSE: you will simulate detector with non-uniform pT efficiency.
80 // Then all particles emitted in ptMin <= pt < ptMax will be taken
81 // with probability p, to be specified in lines just below.
82Double_t ptMin = 0.8; // non-uniform efficiency vs pT starts at pT = fPtMin
83Double_t ptMax = 1.2; // non-uniform efficiency vs pT ends at pT = fPtMax
84Double_t p = 0.5; // probablitity that particles emitted in [ptMin,ptMax> are taken
85
93417736 86// h) Decide which flow analysis methods you will use:
87Bool_t MCEP = kTRUE; // Monte Carlo Event Plane
88Bool_t SP = kTRUE; // Scalar Product (a.k.a 'flow analysis with eta gaps')
89Bool_t GFC = kTRUE; // Generating Function Cumulants
90Bool_t QC = kTRUE; // Q-cumulants
91Bool_t FQD = kTRUE; // Fitted q-distribution
92Bool_t LYZ1SUM = kTRUE; // Lee-Yang Zero (sum generating function), first pass over the data
93Bool_t LYZ1PROD = kTRUE; // Lee-Yang Zero (product generating function), first pass over the data
94Bool_t LYZ2SUM = kFALSE; // Lee-Yang Zero (sum generating function), second pass over the data
95Bool_t LYZ2PROD = kFALSE; // Lee-Yang Zero (product generating function), second pass over the data
96Bool_t LYZEP = kFALSE; // Lee-Yang Zero Event Plane
97Bool_t MH = kFALSE; // Mixed Harmonics (used for strong parity violation studies)
98Bool_t NL = kFALSE; // Nested Loops (neeed for debugging, only for developers)
6d19c373 99Bool_t MPC = kTRUE; // Multi-particle correlations (NEW!)
e23cbd39 100
93417736 101// i) Define simple cuts for Reference Particle (RP) selection:
102Double_t ptMinRP = 0.0; // in GeV
103Double_t ptMaxRP = 10.0; // in GeV
104Double_t etaMinRP = -1.;
105Double_t etaMaxRP = 1.;
106Double_t phiMinRP = 0.0; // in degrees
107Double_t phiMaxRP = 360.0; // in degrees
108Bool_t bUseChargeRP = kFALSE; // if kFALSE, RPs with both sign of charges are taken
109Int_t chargeRP = 1; // +1 or -1
e23cbd39 110
93417736 111// j) Define simple cuts for Particle of Interest (POI) selection:
112Double_t ptMinPOI = 0.0; // in GeV
113Double_t ptMaxPOI = 10.0; // in GeV
114Double_t etaMinPOI = -1.; //
115Double_t etaMaxPOI = 1.;
116Double_t phiMinPOI = 0.0; // in degrees
117Double_t phiMaxPOI = 360.0; // in degrees
118Bool_t bUseChargePOI = kFALSE; // if kFALSE, POIs with both sign of charges are taken
119Int_t chargePOI = -1; // +1 or -1
7a01f4a7 120
93417736 121// k) Define the ranges for two subevents separated with eta gap (needed only for SP method):
122Double_t etaMinA = -0.8; // minimum eta of subevent A
123Double_t etaMaxA = -0.5; // maximum eta of subevent A
124Double_t etaMinB = 0.5; // minimum eta of subevent B
125Double_t etaMaxB = 0.8; // maximum eta of subevent B
524798bf 126
93417736 127// l) Enable/disable usage of particle weights:
128Bool_t usePhiWeights = kFALSE; // phi weights
129Bool_t usePtWeights = kFALSE; // pt weights
130Bool_t useEtaWeights = kFALSE; // eta weights
e23cbd39 131
4d603348 132enum anaModes {mLocal,mLocalSource,mLocalPAR};
93ff27bd 133// mLocal: Analyze data on your computer using aliroot
134// mLocalPAR: Analyze data on your computer using root + PAR files
135// mLocalSource: Analyze data on your computer using root + source files
136
93417736 137#include "TStopwatch.h"
138#include "TObjArray"
139#include "Riostream.h"
140#include "TFile.h"
141
142int runFlowAnalysisOnTheFly(Int_t mode=mLocal)
93ff27bd 143{
93417736 144 // Beging analysis 'on the fly'.
93ff27bd 145
93417736 146 // a) Formal necessities....;
147 // b) Initialize the flow event maker 'on the fly';
148 // c) If enabled, access particle weights from external file;
149 // d) Configure the flow analysis methods;
150 // e) Simple cuts for RPs;
151 // f) Simple cuts for POIs;
152 // g) Create and analyse events 'on the fly';
153 // h) Create the output file and directory structure for the final results of all methods;
154 // i) Calculate and store the final results of all methods.
93ff27bd 155
93417736 156 // a) Formal necessities....:
157 CheckUserSettings();
158 WelcomeMessage();
159 TStopwatch timer;
160 timer.Start();
93ff27bd 161 LoadLibraries(mode);
4d603348 162
93417736 163 // b) Initialize the flow event maker 'on the fly':
164 UInt_t uiSeed = 0; // if uiSeed is 0, the seed is determined uniquely in space and time via TUUID
165 if(bSameSeed){uiSeed = 44;}
166 AliFlowEventSimpleMakerOnTheFly* eventMakerOnTheFly = new AliFlowEventSimpleMakerOnTheFly(uiSeed);
167 eventMakerOnTheFly->SetMinMult(iMinMult);
168 eventMakerOnTheFly->SetMaxMult(iMaxMult);
169 eventMakerOnTheFly->SetMass(dMass);
170 eventMakerOnTheFly->SetTemperature(dTemperature);
171 eventMakerOnTheFly->SetV1(dV1);
172 eventMakerOnTheFly->SetV2(dV2);
173 eventMakerOnTheFly->SetV3(dV3);
174 eventMakerOnTheFly->SetV4(dV4);
dd1d2f85 175 eventMakerOnTheFly->SetV5(dV5);
176 eventMakerOnTheFly->SetV6(dV6);
93417736 177 if(bUniformFluctuationsV2)
4d603348 178 {
93417736 179 eventMakerOnTheFly->SetUniformFluctuationsV2(bUniformFluctuationsV2);
180 eventMakerOnTheFly->SetMinV2(dMinV2);
181 eventMakerOnTheFly->SetMaxV2(dMaxV2);
182 }
183 if(bPtDependentV2)
184 {
185 eventMakerOnTheFly->SetPtDependentV2(bPtDependentV2);
186 eventMakerOnTheFly->SetV2vsPtCutOff(dV2vsPtCutOff);
187 eventMakerOnTheFly->SetV2vsPtMax(dV2vsPtMax);
4d603348 188 }
93417736 189 eventMakerOnTheFly->SetSubeventEtaRange(etaMinA,etaMaxA,etaMinB,etaMaxB);
190 eventMakerOnTheFly->SetNTimes(nTimes);
191 if(!uniformAcceptance)
4d603348 192 {
93417736 193 eventMakerOnTheFly->SetUniformAcceptance(kFALSE);
194 eventMakerOnTheFly->SetFirstSectorPhiMin(phiMin1);
195 eventMakerOnTheFly->SetFirstSectorPhiMax(phiMax1);
196 eventMakerOnTheFly->SetFirstSectorProbability(p1);
197 eventMakerOnTheFly->SetSecondSectorPhiMin(phiMin2);
198 eventMakerOnTheFly->SetSecondSectorPhiMax(phiMax2);
199 eventMakerOnTheFly->SetSecondSectorProbability(p2);
200 }
6d19c373 201 if(!uniformEfficiency)
202 {
203 eventMakerOnTheFly->SetUniformEfficiency(kFALSE);
204 eventMakerOnTheFly->SetPtMin(ptMin);
205 eventMakerOnTheFly->SetPtMax(ptMax);
206 eventMakerOnTheFly->SetPtProbability(p);
207 }
4d603348 208 eventMakerOnTheFly->Init();
93417736 209
210 // c) If enabled, access particle weights from external file:
211 TFile *fileWithWeights = NULL;
212 TList *listWithWeights = NULL;
213 if(usePhiWeights||usePtWeights||useEtaWeights)
214 {
215 fileWithWeights = TFile::Open("weights.root","READ");
216 if(fileWithWeights)
217 {
218 listWithWeights = (TList*)fileWithWeights->Get("weights");
219 }
220 else
221 {
222 cout << " WARNING: the file <weights.root> with weights from the previous run was not found."<<endl;
223 break;
224 }
225 } // end of if(usePhiWeights||usePtWeights||useEtaWeights)
226
227 // d) Configure the flow analysis methods:
ce4a88f5 228 AliFlowAnalysisWithQCumulants *qc = NULL;
229 AliFlowAnalysisWithCumulants *gfc = NULL;
230 AliFlowAnalysisWithFittingQDistribution *fqd = NULL;
231 AliFlowAnalysisWithLeeYangZeros *lyz1sum = NULL;
232 AliFlowAnalysisWithLeeYangZeros *lyz1prod = NULL;
233 AliFlowAnalysisWithLeeYangZeros *lyz2sum = NULL;
234 AliFlowAnalysisWithLeeYangZeros *lyz2prod = NULL;
235 AliFlowAnalysisWithLYZEventPlane *lyzep = NULL;
236 AliFlowAnalysisWithScalarProduct *sp = NULL;
d66d46f7 237 AliFlowAnalysisWithMixedHarmonics *mh = NULL;
83bc3e95 238 AliFlowAnalysisWithNestedLoops *nl = NULL;
ce4a88f5 239 AliFlowAnalysisWithMCEventPlane *mcep = NULL;
6d19c373 240 AliFlowAnalysisWithMultiparticleCorrelations *mpc = NULL;
93ff27bd 241 // MCEP = monte carlo event plane
93417736 242 if(MCEP)
d66d46f7 243 {
93417736 244 //AliFlowAnalysisWithMCEventPlane *mcep = new AliFlowAnalysisWithMCEventPlane();
245 mcep = new AliFlowAnalysisWithMCEventPlane();
246 mcep->SetHarmonic(2); // default is v2
247 mcep->Init();
248 } // end of if(MCEP)
249 // SP = Scalar Product
250 if(SP)
d66d46f7 251 {
93417736 252 sp = new AliFlowAnalysisWithScalarProduct();
253 if(listWithWeights){sp->SetWeightsList(listWithWeights);}
254 sp->SetUsePhiWeights(usePhiWeights);
255 sp->SetHarmonic(2);
256 sp->SetApplyCorrectionForNUA(kFALSE);
257 sp->Init();
258 } // end of if(SP)
ce4a88f5 259 // QC = Q-cumulants
93417736 260 if(QC)
261 {
262 qc = new AliFlowAnalysisWithQCumulants();
263 if(listWithWeights){qc->SetWeightsList(listWithWeights);}
264 if(usePhiWeights){qc->SetUsePhiWeights(usePhiWeights);}
265 if(usePtWeights){qc->SetUsePtWeights(usePtWeights);}
266 if(useEtaWeights){qc->SetUseEtaWeights(useEtaWeights);}
267 qc->SetHarmonic(2);
268 qc->SetCalculateDiffFlow(kTRUE);
269 qc->SetCalculate2DDiffFlow(kFALSE); // vs (pt,eta)
270 qc->SetApplyCorrectionForNUA(kFALSE);
271 qc->SetFillMultipleControlHistograms(kFALSE);
272 qc->SetMultiplicityWeight("combinations"); // default (other supported options are "unit" and "multiplicity")
273 qc->SetCalculateCumulantsVsM(kFALSE);
62e36168 274 qc->SetCalculateAllCorrelationsVsM(kFALSE); // calculate all correlations in mixed harmonics "vs M"
93417736 275 qc->SetnBinsMult(10000);
276 qc->SetMinMult(0);
277 qc->SetMaxMult(10000);
62e36168 278 qc->SetBookOnlyBasicCCH(kFALSE); // book only basic common control histograms
279 qc->SetCalculateDiffFlowVsEta(kTRUE); // if you set kFALSE only differential flow vs pt is calculated
dd1d2f85 280 qc->SetCalculateMixedHarmonics(kFALSE); // calculate all multi-partice mixed-harmonics correlators
93417736 281 qc->Init();
282 } // end of if(QC)
93ff27bd 283 // GFC = Generating Function Cumulants
93417736 284 if(GFC)
285 {
286 gfc = new AliFlowAnalysisWithCumulants();
287 if(listWithWeights){gfc->SetWeightsList(listWithWeights);}
288 if(usePhiWeights){gfc->SetUsePhiWeights(usePhiWeights);}
289 if(usePtWeights){gfc->SetUsePtWeights(usePtWeights);}
290 if(useEtaWeights){gfc->SetUseEtaWeights(useEtaWeights);}
291 // calculation vs multiplicity:
292 gfc->SetCalculateVsMultiplicity(kFALSE);
293 gfc->SetnBinsMult(10000);
294 gfc->SetMinMult(0);
295 gfc->SetMaxMult(10000);
296 gfc->SetHarmonic(2);
297 // tuning of interpolating parameters:
298 gfc->SetTuneParameters(kFALSE);
299 Double_t r0[10] = {1.8,1.9,2.0,2.1,2.2,2.3,2.4,2.5,2.6,2.7}; // up to 10 values allowed
300 for(Int_t r=0;r<10;r++){gfc->SetTuningR0(r0[r],r);}
301 gfc->Init();
302 } // end of if(GFC)
93ff27bd 303 // FQD = Fitting q-distribution
93417736 304 if(FQD)
305 {
306 fqd = new AliFlowAnalysisWithFittingQDistribution();
307 if(listWithWeights){fqd->SetWeightsList(listWithWeights);}
308 if(usePhiWeights){fqd->SetUsePhiWeights(usePhiWeights);}
309 fqd->SetHarmonic(2);
310 fqd->Init();
311 } // end of if(FQD)
93ff27bd 312 // LYZ1 = Lee-Yang Zeroes first run
93417736 313 if(LYZ1SUM)
314 {
315 lyz1sum = new AliFlowAnalysisWithLeeYangZeros();
316 lyz1sum->SetFirstRun(kTRUE);
317 lyz1sum->SetUseSum(kTRUE);
318 lyz1sum->Init();
319 } // end of if(LYZ1SUM)
320 if(LYZ1PROD)
321 {
322 lyz1prod = new AliFlowAnalysisWithLeeYangZeros();
323 lyz1prod->SetFirstRun(kTRUE);
324 lyz1prod->SetUseSum(kFALSE);
325 lyz1prod->Init();
326 } // end of if(LYZ1PROD)
93ff27bd 327 // LYZ2 = Lee-Yang Zeroes second run
93417736 328 if(LYZ2SUM)
329 {
330 lyz2sum = new AliFlowAnalysisWithLeeYangZeros();
331 // read the input file from the first run
332 TString inputFileNameLYZ2SUM = "outputLYZ1SUManalysis.root" ;
333 TFile* inputFileLYZ2SUM = new TFile(inputFileNameLYZ2SUM.Data(),"READ");
334 if(!inputFileLYZ2SUM || inputFileLYZ2SUM->IsZombie())
335 {
336 cerr<<" ERROR: To run LYZ2SUM you need the output file from LYZ1SUM. This file is not there! Please run LYZ1SUM first."<<endl;
337 break;
338 } else
339 {
c741f5d0 340 TList* inputListLYZ2SUM = (TList*)inputFileLYZ2SUM->Get("cobjLYZ1SUM");
93417736 341 if(!inputListLYZ2SUM){cout<<"Input list LYZ2SUM is NULL pointer!"<<endl;break;}
342 else
343 {
344 cout<<"LYZ2SUM input file/list read..."<<endl;
345 lyz2sum->SetFirstRunList(inputListLYZ2SUM);
346 lyz2sum->SetFirstRun(kFALSE);
347 lyz2sum->SetUseSum(kTRUE);
348 lyz2sum->Init();
93ff27bd 349 }
350 }
93417736 351 } // end of if(LYZ2SUM)
352 if(LYZ2PROD)
353 {
354 lyz2prod = new AliFlowAnalysisWithLeeYangZeros();
355 // read the input file from the first run
356 TString inputFileNameLYZ2PROD = "outputLYZ1PRODanalysis.root" ;
357 TFile* inputFileLYZ2PROD = new TFile(inputFileNameLYZ2PROD.Data(),"READ");
358 if(!inputFileLYZ2PROD || inputFileLYZ2PROD->IsZombie())
359 {
360 cerr<<" ERROR: To run LYZ2PROD you need the output file from LYZ1PROD. This file is not there! Please run LYZ1PROD first."<<endl;
361 break;
362 } else
363 {
c741f5d0 364 TList* inputListLYZ2PROD = (TList*)inputFileLYZ2PROD->Get("cobjLYZ1PROD");
93417736 365 if(!inputListLYZ2PROD){cout<<"Input list LYZ2PROD is NULL pointer!"<<endl;break;}
366 else
367 {
368 cout<<"LYZ2PROD input file/list read..."<<endl;
369 lyz2prod->SetFirstRunList(inputListLYZ2PROD);
370 lyz2prod->SetFirstRun(kFALSE);
371 lyz2prod->SetUseSum(kFALSE);
372 lyz2prod->Init();
c741f5d0 373 }
374 }
93417736 375 } // end of if(LYZ2PROD)
93ff27bd 376 // LYZEP = Lee-Yang Zeroes event plane
93417736 377 if(LYZEP)
378 {
379 AliFlowLYZEventPlane *ep = new AliFlowLYZEventPlane() ;
380 AliFlowAnalysisWithLYZEventPlane* lyzep = new AliFlowAnalysisWithLYZEventPlane();
93ff27bd 381 // read the input file from the second lyz run
c741f5d0 382 TString inputFileNameLYZEP = "outputLYZ2SUManalysis.root" ;
93ff27bd 383 TFile* inputFileLYZEP = new TFile(inputFileNameLYZEP.Data(),"READ");
384 if(!inputFileLYZEP || inputFileLYZEP->IsZombie()) {
5b40431d 385 cerr << " ERROR: To run LYZEP you need the output file from LYZ2SUM. This file is not there! Please run LYZ2SUM first." << endl ;
93ff27bd 386 break;
387 }
388 else {
c741f5d0 389 TList* inputListLYZEP = (TList*)inputFileLYZEP->Get("cobjLYZ2SUM");
390 if (!inputListLYZEP) {cout<<"Input list LYZEP is NULL pointer!"<<endl; break;}
93ff27bd 391 else {
392 cout<<"LYZEP input file/list read..."<<endl;
393 ep ->SetSecondRunList(inputListLYZEP);
394 lyzep->SetSecondRunList(inputListLYZEP);
395 ep ->Init();
396 lyzep->Init();
397 }
398 }
399 }
93417736 400 // Mixed Harmonics:
401 if(MH)
bdb5c432 402 {
93417736 403 mh = new AliFlowAnalysisWithMixedHarmonics();
404 mh->SetHarmonic(1); // integer n in expression cos[n(2phi1-phi2-phi3)] = v2n*vn^2
405 mh->SetMinMultiplicity(100);
406 mh->SetNoOfMultipicityBins(5);
407 mh->SetMultipicityBinWidth(200);
408 mh->Init();
409 } // end of if(MH)
410 // NL = Nested Loops:
411 if(NL)
e23cbd39 412 {
93417736 413 nl = new AliFlowAnalysisWithNestedLoops();
414 nl->Init();
415 } // end of if(NL)
6d19c373 416 // MPC = Multi-particle correlations
417 if(MPC)
418 {
419 mpc = new AliFlowAnalysisWithMultiparticleCorrelations();
420 // Weights:
421 //TFile *file = TFile::Open("weights.root","READ");
422 //TH1D *weightsHist = (TH1D*) file->FindObjectAny("Phi weights");
423 //mpc->SetPhiWeightsHist(weightsHist);
424 // Control histograms:
425 mpc->SetFillControlHistograms(kTRUE);
426 mpc->SetFillKinematicsHist(kTRUE);
427 // Q-vector:
428 mpc->SetCalculateQvector(kTRUE);
429 // Correlations:
430 mpc->SetCalculateCorrelations(kTRUE);
431 mpc->SetSkipZeroHarmonics(kTRUE);
432 mpc->SetCalculateIsotropic(kTRUE);
433 // Standard candles:
434 mpc->SetCalculateStandardCandles(kTRUE);
435 // Init:
436 mpc->Init();
437 } // end of if(MPC)
438
93417736 439 // e) Simple cuts for RPs:
e1911c19 440 AliFlowTrackSimpleCuts *cutsRP = new AliFlowTrackSimpleCuts();
441 cutsRP->SetPtMax(ptMaxRP);
442 cutsRP->SetPtMin(ptMinRP);
443 cutsRP->SetEtaMax(etaMaxRP);
444 cutsRP->SetEtaMin(etaMinRP);
445 cutsRP->SetPhiMax(phiMaxRP*TMath::Pi()/180.);
446 cutsRP->SetPhiMin(phiMinRP*TMath::Pi()/180.);
93417736 447 if(bUseChargeRP){cutsRP->SetCharge(chargeRP);}
448
449 // f) Simple cuts for POIs:
e1911c19 450 AliFlowTrackSimpleCuts *cutsPOI = new AliFlowTrackSimpleCuts();
451 cutsPOI->SetPtMax(ptMaxPOI);
452 cutsPOI->SetPtMin(ptMinPOI);
453 cutsPOI->SetEtaMax(etaMaxPOI);
454 cutsPOI->SetEtaMin(etaMinPOI);
455 cutsPOI->SetPhiMax(phiMaxPOI*TMath::Pi()/180.);
456 cutsPOI->SetPhiMin(phiMinPOI*TMath::Pi()/180.);
93417736 457 if(bUseChargePOI){cutsPOI->SetCharge(chargePOI);}
e1911c19 458
93417736 459 // g) Create and analyse events 'on the fly':
460 for(Int_t i=0;i<iNevts;i++)
461 {
462 // Creating the event 'on the fly':
463 AliFlowEventSimple *event = eventMakerOnTheFly->CreateEventOnTheFly(cutsRP,cutsPOI);
464 // Passing the created event to flow analysis methods:
465 if(MCEP){mcep->Make(event);}
466 if(QC){qc->Make(event);}
467 if(GFC){gfc->Make(event);}
468 if(FQD){fqd->Make(event);}
469 if(LYZ1SUM){lyz1sum->Make(event);}
470 if(LYZ1PROD){lyz1prod->Make(event);}
471 if(LYZ2SUM){lyz2sum->Make(event);}
472 if(LYZ2PROD){lyz2prod->Make(event);}
473 if(LYZEP){lyzep->Make(event,ep);}
474 if(SP){sp->Make(event);}
475 if(MH){mh->Make(event);}
476 if(NL){nl->Make(event);}
6d19c373 477 if(MPC){mpc->Make(event);}
93417736 478 delete event;
479 } // end of for(Int_t i=0;i<iNevts;i++)
93ff27bd 480
93417736 481 // h) Create the output file and directory structure for the final results of all methods:
ad87ae62 482 TString outputFileName = "AnalysisResults.root";
483 TFile *outputFile = new TFile(outputFileName.Data(),"RECREATE");
6d19c373 484 const Int_t nMethods = 13;
485 TString method[nMethods] = {"MCEP","SP","GFC","QC","FQD","LYZ1SUM","LYZ1PROD","LYZ2SUM","LYZ2PROD","LYZEP","MH","NL","MPC"};
ad87ae62 486 TDirectoryFile *dirFileFinal[nMethods] = {NULL};
487 TString fileName[nMethods];
488 for(Int_t i=0;i<nMethods;i++)
489 {
ad87ae62 490 fileName[i]+="output";
491 fileName[i]+=method[i].Data();
492 fileName[i]+="analysis";
493 dirFileFinal[i] = new TDirectoryFile(fileName[i].Data(),fileName[i].Data());
494 }
495
93417736 496 // i) Calculate and store the final results of all methods:
497 if(MCEP){mcep->Finish();mcep->WriteHistograms(dirFileFinal[0]);}
498 if(SP){sp->Finish();sp->WriteHistograms(dirFileFinal[1]);}
499 if(GFC){gfc->Finish();gfc->WriteHistograms(dirFileFinal[2]);}
500 if(QC){qc->Finish();qc->WriteHistograms(dirFileFinal[3]);}
501 if(FQD){fqd->Finish();fqd->WriteHistograms(dirFileFinal[4]);}
502 if(LYZ1SUM){lyz1sum->Finish();lyz1sum->WriteHistograms(dirFileFinal[5]);}
ad87ae62 503 if(LYZ1PROD){lyz1prod->Finish();lyz1prod->WriteHistograms(dirFileFinal[6]);}
93417736 504 if(LYZ2SUM){lyz2sum->Finish();lyz2sum->WriteHistograms(dirFileFinal[7]);}
ad87ae62 505 if(LYZ2PROD){lyz2prod->Finish();lyz2prod->WriteHistograms(dirFileFinal[8]);}
93417736 506 if(LYZEP){lyzep->Finish();lyzep->WriteHistograms(dirFileFinal[9]);}
507 if(MH){mh->Finish();mh->WriteHistograms(dirFileFinal[10]);}
508 if(NL){nl->Finish();nl->WriteHistograms(dirFileFinal[11]);}
6d19c373 509 if(MPC){mpc->Finish();mpc->WriteHistograms(dirFileFinal[12]);}
93ff27bd 510
ad87ae62 511 outputFile->Close();
512 delete outputFile;
93ff27bd 513
514 cout<<endl;
515 cout<<endl;
516 cout<<" ---- LANDED SUCCESSFULLY ---- "<<endl;
517 cout<<endl;
518
519 timer.Stop();
520 cout << endl;
521 timer.Print();
93417736 522
523} // end of int runFlowAnalysisOnTheFly(Int_t mode=mLocal)
93ff27bd 524
525void SetupPar(char* pararchivename)
526{
527 //Load par files, create analysis libraries
528 //For testing, if par file already decompressed and modified
529 //classes then do not decompress.
530
531 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
532 TString parpar(Form("%s.par", pararchivename)) ;
533 if ( gSystem->AccessPathName(parpar.Data()) ) {
534 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
535 TString processline(Form(".! make %s", parpar.Data())) ;
536 gROOT->ProcessLine(processline.Data()) ;
537 gSystem->ChangeDirectory(cdir) ;
538 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
539 gROOT->ProcessLine(processline.Data()) ;
540 }
541 if ( gSystem->AccessPathName(pararchivename) ) {
542 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
543 gROOT->ProcessLine(processline.Data());
544 }
545
546 TString ocwd = gSystem->WorkingDirectory();
547 gSystem->ChangeDirectory(pararchivename);
548
549 // check for BUILD.sh and execute
550 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
551 printf("*******************************\n");
552 printf("*** Building PAR archive ***\n");
553 cout<<pararchivename<<endl;
554 printf("*******************************\n");
555
556 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
557 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
558 return -1;
559 }
560 }
561 // check for SETUP.C and execute
562 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
563 printf("*******************************\n");
564 printf("*** Setup PAR archive ***\n");
565 cout<<pararchivename<<endl;
566 printf("*******************************\n");
567 gROOT->Macro("PROOF-INF/SETUP.C");
568 }
569
570 gSystem->ChangeDirectory(ocwd.Data());
571 printf("Current dir: %s\n", ocwd.Data());
572}
573
bdb5c432 574void CheckUserSettings()
575{
93417736 576 // Check if user settings make sense before taking off.
bdb5c432 577
93417736 578 if(iNevts <= 0)
bdb5c432 579 {
93417736 580 printf("\n WARNING: nEvts <= 0 !!!! Please check your settings before taking off.\n\n");
581 exit(0);
582 }
583 if(iMinMult < 0.)
584 {
585 printf("\n WARNING: iMinMult < 0 !!!! Please check your settings before taking off.\n\n");
586 exit(0);
bdb5c432 587 }
93417736 588 if(iMaxMult <= 0.)
bdb5c432 589 {
93417736 590 printf("\n WARNING: iMaxMult <= 0 !!!! Please check your settings before taking off.\n\n");
591 exit(0);
bdb5c432 592 }
93417736 593 if(iMinMult >= iMaxMult)
bdb5c432 594 {
93417736 595 printf("\n WARNING: iMinMult >= iMaxMult !!!! Please check your settings before taking off.\n\n");
596 exit(0);
bdb5c432 597 }
93417736 598 if(dMass < 0.)
bdb5c432 599 {
93417736 600 printf("\n WARNING: dMass < 0 !!!! Please check your settings before taking off.\n\n");
601 exit(0);
bdb5c432 602 }
93417736 603 if(dTemperature <= 1e-44)
604 {
605 printf("\n WARNING: dTemperature <= 0 !!!! Please check your settings before taking off.\n\n");
606 exit(0);
598d292e 607 }
93417736 608 if(TMath::Abs(dV1) > 0.5)
609 {
610 printf("\n WARNING: |dV1| > 0.5 !!!! Please check your settings before taking off.\n\n");
611 exit(0);
612 }
613 if(TMath::Abs(dV2) > 0.5)
614 {
615 printf("\n WARNING: |dV2| > 0.5 !!!! Please check your settings before taking off.\n\n");
616 exit(0);
617 }
618 if(TMath::Abs(dV3) > 0.5)
619 {
620 printf("\n WARNING: |dV3| > 0.5 !!!! Please check your settings before taking off.\n\n");
621 exit(0);
622 }
623 if(TMath::Abs(dV4) > 0.5)
bdb5c432 624 {
93417736 625 printf("\n WARNING: |dV4| > 0.5 !!!! Please check your settings before taking off.\n\n");
bdb5c432 626 exit(0);
627 }
dd1d2f85 628 if(TMath::Abs(dV5) > 0.5)
629 {
630 printf("\n WARNING: |dV5| > 0.5 !!!! Please check your settings before taking off.\n\n");
631 exit(0);
632 }
633 if(TMath::Abs(dV6) > 0.5)
634 {
635 printf("\n WARNING: |dV6| > 0.5 !!!! Please check your settings before taking off.\n\n");
636 exit(0);
637 }
93417736 638 if(LYZ1SUM && LYZ2SUM)
bdb5c432 639 {
93417736 640 cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1."<<endl;
bdb5c432 641 exit(0);
642 }
93417736 643 if(LYZ1PROD && LYZ2PROD)
bdb5c432 644 {
93417736 645 cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1."<<endl;
bdb5c432 646 exit(0);
647 }
93417736 648 if(LYZ2SUM && LYZEP)
bdb5c432 649 {
93417736 650 cout<<" WARNING: You cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2."<<endl;
bdb5c432 651 exit(0);
652 }
93417736 653 if(LYZ1SUM && LYZEP)
1f89f68d 654 {
93417736 655 cout<<" WARNING: You cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2."<<endl;
1f89f68d 656 exit(0);
657 }
93417736 658
659 if(!uniformAcceptance && phiMin1 > phiMax1)
660 {
661 cout<<" WARNING: You must have phiMin1 < phiMax1 !!!!"<<endl;
662 exit(0);
663 }
664 if(!uniformAcceptance && !((TMath::Abs(phiMin2) < 1.e-44) && (TMath::Abs(phiMax2) < 1.e-44) && (TMath::Abs(p2) < 1.e-44))
665 && (phiMin2 < phiMax1 || phiMin2 > phiMax2))
666 {
667 cout<<" WARNING: You must have phiMin2 > phiMax1 and phiMin2 < phiMax2 !!!!"<<endl;
668 exit(0);
669 }
670 if((phiMin1 < 0 || phiMin1 > 360) || (phiMax1 < 0 || phiMax1 > 360) ||
671 (phiMin2 < 0 || phiMin2 > 360) || (phiMax2 < 0 || phiMax2 > 360) )
672 {
673 cout<<" WARNING: You must take azimuthal angles from interval [0,360] !!!!"<<endl;
674 exit(0);
675 }
676 if((p1 < 0 || p1 > 1) || (p2 < 0 || p2 > 1))
677 {
678 cout<<" WARNING: you must take p1 and p2 from interval [0,1] !!!!"<<endl;
679 exit(0);
680 }
681 if(bPtDependentV2 && bUniformFluctuationsV2)
682 {
683 cout<<" WARNING: Uniform fluctuations not supported for pt denependent v2 !!!!"<<endl;
684 exit(0);
685 }
686
bdb5c432 687} // end of void CheckUserSettings()
688
93417736 689void WelcomeMessage()
690{
691 // Welcome.
692
693 cout<<endl;
694 cout<<endl;
695 cout<<" ---- ARE YOU READY TO FLY ? ---- "<<endl;
696 cout<<endl;
697
698 gSystem->Sleep(1544);
699
700 cout<<endl;
701 cout<<" ---- BEGIN FLOW ANALYSIS 'ON THE FLY' ---- "<<endl;
702 cout<<endl;
703 cout<<endl;
704
705 gSystem->Sleep(1544);
706
707} // end of void WelcomeMessage()
708
93ff27bd 709void LoadLibraries(const anaModes mode) {
710
711 //--------------------------------------
712 // Load the needed libraries most of them already loaded by aliroot
713 //--------------------------------------
ad87ae62 714 //gSystem->Load("libTree");
5d040cf3 715 gSystem->Load("libGeom");
716 gSystem->Load("libVMC");
717 gSystem->Load("libXMLIO");
718 gSystem->Load("libPhysics");
93ff27bd 719
720 //----------------------------------------------------------
721 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
722 //----------------------------------------------------------
723 if (mode==mLocal) {
724 //--------------------------------------------------------
725 // If you want to use already compiled libraries
726 // in the aliroot distribution
727 //--------------------------------------------------------
728 gSystem->Load("libSTEERBase");
729 gSystem->Load("libESD");
730 gSystem->Load("libAOD");
731 gSystem->Load("libANALYSIS");
732 gSystem->Load("libANALYSISalice");
5d040cf3 733 gSystem->Load("libCORRFW");
734 cerr<<"libCORRFW loaded..."<<endl;
2e311896 735 gSystem->Load("libPWGflowBase");
736 cerr<<"libPWGflowBase loaded..."<<endl;
737 gSystem->Load("libPWGflowTasks");
738 cerr<<"libPWGflowTasks loaded..."<<endl;
93ff27bd 739 }
740
741 else if (mode == mLocalPAR) {
742 //--------------------------------------------------------
743 //If you want to use root and par files from aliroot
744 //--------------------------------------------------------
745 //If you want to use root and par files from aliroot
746 //--------------------------------------------------------
747 SetupPar("STEERBase");
748 SetupPar("ESD");
749 SetupPar("AOD");
750 SetupPar("ANALYSIS");
751 SetupPar("ANALYSISalice");
752 SetupPar("PWG2AOD");
753 SetupPar("CORRFW");
2e311896 754 SetupPar("PWGflowBase");
755 cerr<<"PWGflowBase.par loaded..."<<endl;
756 SetupPar("PWGflowTasks");
757 cerr<<"PWGflowTasks.par loaded..."<<endl;
93ff27bd 758 }
759
760 //---------------------------------------------------------
761 // <<<<<<<<<< Source mode >>>>>>>>>>>>
762 //---------------------------------------------------------
763 else if (mode==mLocalSource) {
764
765 // In root inline compile
766
93ff27bd 767 // Constants
2e311896 768 gROOT->LoadMacro("Base/AliFlowCommonConstants.cxx+");
769 gROOT->LoadMacro("Base/AliFlowLYZConstants.cxx+");
93ff27bd 770
771 // Flow event
2e311896 772 gROOT->LoadMacro("Base/AliFlowVector.cxx+");
773 gROOT->LoadMacro("Base/AliFlowTrackSimple.cxx+");
774 gROOT->LoadMacro("Base/AliFlowTrackSimpleCuts.cxx+");
775 gROOT->LoadMacro("Base/AliFlowEventSimple.cxx+");
93ff27bd 776
777 // Output histosgrams
2e311896 778 gROOT->LoadMacro("Base/AliFlowCommonHist.cxx+");
779 gROOT->LoadMacro("Base/AliFlowCommonHistResults.cxx+");
780 gROOT->LoadMacro("Base/AliFlowLYZHist1.cxx+");
781 gROOT->LoadMacro("Base/AliFlowLYZHist2.cxx+");
93ff27bd 782
783 // Functions needed for various methods
2e311896 784 gROOT->LoadMacro("Base/AliCumulantsFunctions.cxx+");
785 gROOT->LoadMacro("Base/AliFlowLYZEventPlane.cxx+");
93ff27bd 786
787 // Flow Analysis code for various methods
2e311896 788 gROOT->LoadMacro("Base/AliFlowAnalysisWithMCEventPlane.cxx+");
789 gROOT->LoadMacro("Base/AliFlowAnalysisWithScalarProduct.cxx+");
790 gROOT->LoadMacro("Base/AliFlowAnalysisWithLYZEventPlane.cxx+");
791 gROOT->LoadMacro("Base/AliFlowAnalysisWithLeeYangZeros.cxx+");
792 gROOT->LoadMacro("Base/AliFlowAnalysisWithCumulants.cxx+");
793 gROOT->LoadMacro("Base/AliFlowAnalysisWithQCumulants.cxx+");
794 gROOT->LoadMacro("Base/AliFlowAnalysisWithFittingQDistribution.cxx+");
795 gROOT->LoadMacro("Base/AliFlowAnalysisWithMixedHarmonics.cxx+");
796 gROOT->LoadMacro("Base/AliFlowAnalysisWithNestedLoops.cxx+");
93ff27bd 797
a47dc7e4 798 // Class to fill the FlowEvent on the fly (generate Monte Carlo events)
2e311896 799 gROOT->LoadMacro("Base/AliFlowEventSimpleMakerOnTheFly.cxx+");
93ff27bd 800
801 cout << "finished loading macros!" << endl;
802
803 }
804
805}
806
807