1 #include "TStopwatch.h"
6 //--------------------------------------------------------------------------------------
8 // flow analysis method can be: (set to kTRUE or kFALSE)
12 Bool_t LYZEP = kFALSE;
17 //--------------------------------------------------------------------------------------
20 // use weights for Q-vector:
21 Bool_t usePhiWeights = kFALSE; // phi weights (correction for non-uniform azimuthal acceptance)
22 Bool_t usePtWeights = kFALSE; // pt weights
23 Bool_t useEtaWeights = kFALSE; // eta weights
25 // Parameters for the simulation of events 'on the fly':
26 Bool_t bSameSeed = kFALSE; // use always the same seed for random generators.
27 // usage od same seed (kTRUE) is relevant in two cases:
28 // 1.) If you want to use LYZ method to calcualte differential flow;
29 // 2.) If you want to use phi weights for GFC, QC and FQD
31 Bool_t bConstantHarmonics = kTRUE; // harmonics V1, V2, V4... are constant (kTRUE) or functions of pt and eta (kFALSE)
33 Int_t iLoops = 1; // number of times to use each track (to simulate nonflow)
35 Bool_t bMultDistrOfRPsIsGauss = kTRUE; // 1.) if kTRUE = multiplicitiy of RPs is sampled e-b-e from Gaussian distribution with
36 // mean = iMultiplicityOfRP and spread = dMultiplicitySpreadOfRP
37 // 2.) if kFALSE = multiplicitiy of RPs is sampled e-b-e uniformly from
38 // interval [iMinMultOfRP,iMaxMultOfRP]
39 // 3.) for a fixed multiplicity use Gaussian with zero spread or use uniform with iMinMult=iMaxMult
41 Int_t iMultiplicityOfRP = 500; // mean multiplicity of RPs (if sampled from Gaussian)
42 Double_t dMultiplicitySpreadOfRP = 0; // multiplicity spread of RPs (if sampled from Gaussian)
43 Int_t iMinMultOfRP = 400; // minimal multiplicity of RPs (if sampled uniformly)
44 Int_t iMaxMultOfRP = 600; // maximal multiplicity of RPs (if sampled uniformly)
46 Double_t dTemperatureOfRP = 0.44; // 'temperature' of RPs in GeV/c (increase this parameter to get more high pt RPs)
48 //......................................................................................
49 // if you use (pt,eta) dependent harmonics (bConstantHarmonics = kFALSE):
50 Double_t dPtCutOff = 2.0; // V2(pt) is linear up to pt = 2 GeV and for pt > 2 GeV it is constant: V2(pt) = dVRPMax
51 Double_t dV2RPMax = 0.20; // maximum value of V2(pt) for pt >= 2GeV
52 //......................................................................................
54 //......................................................................................
55 // if you use constant harmonics (bConstantHarmonics = kTRUE):
56 Double_t dV2RP = 0.05; // elliptic flow of RPs
57 Double_t dV2SpreadRP = 0.; // elliptic flow spread of RPs
59 Double_t dV1RP = 0.0; // directed flow of RPs
60 Double_t dV1SpreadRP = 0.0; // directed flow spread of RPs
62 Double_t dV4RP = 0.0; // harmonic V4 of RPs (to be improved: name needed)
63 Double_t dV4SpreadRP = 0.0; // harmonic V4's spread of RPs (to be improved: name needed)
64 //......................................................................................
66 enum anaModes {mLocal,mLocalSource,mLocalPAR};
67 // mLocal: Analyze data on your computer using aliroot
68 // mLocalPAR: Analyze data on your computer using root + PAR files
69 // mLocalSource: Analyze data on your computer using root + source files
71 int runFlowAnalysisOnTheFly(Int_t mode=mLocal, Int_t nEvts=440)
76 if (LYZ1 && LYZ2) {cout<<"WARNING: you cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1. "<<endl; exit(); }
77 if (LYZ2 && LYZEP) {cout<<"WARNING: you cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2."<<endl; exit(); }
78 if (LYZ1 && LYZEP) {cout<<"WARNING: you cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2."<<endl; exit(); }
82 cout<<" ---- ARE YOU READY TO FLY ? ---- "<<endl;
86 cout<<" ---- BEGIN FLOW ANALYSIS 'ON THE FLY' ---- "<<endl;
92 // Initialize the seed for random generator
97 sseed = 44; // the default constant value for seed for random generators
103 sseed = dt.GetNanoSec()/1000;
106 //---------------------------------------------------------------------------------------
107 // If the weights are used:
108 TFile *fileWithWeights = NULL;
109 TList *listWithWeights = NULL;
111 if(usePhiWeights||usePtWeights||useEtaWeights) {
112 fileWithWeights = TFile::Open("weights.root","READ");
113 if(fileWithWeights) {
114 listWithWeights = (TList*)fileWithWeights->Get("weights");
117 {cout << " WARNING: the file <weights.root> with weights from the previous run was not found."<<endl;
122 //---------------------------------------------------------------------------------------
123 // Initialize the flowevent maker
124 AliFlowEventSimpleMakerOnTheFly* eventMakerOnTheFly = new AliFlowEventSimpleMakerOnTheFly(sseed);
125 eventMakerOnTheFly->Init();
127 //---------------------------------------------------------------------------------------
128 // Initialize all the flow methods:
129 AliFlowAnalysisWithQCumulants *qc = NULL;
130 AliFlowAnalysisWithCumulants *gfc = NULL;
131 AliFittingQDistribution *fqd = NULL;
132 AliFlowAnalysisWithLeeYangZeros *lyz1 = NULL;
133 AliFlowAnalysisWithLeeYangZeros *lyz2 = NULL;
134 AliFlowAnalysisWithLYZEventPlane *lyzep = NULL;
135 AliFlowAnalysisWithScalarProduct *sp = NULL;
136 AliFlowAnalysisWithMCEventPlane *mcep = NULL;
138 // MCEP = monte carlo event plane
140 AliFlowAnalysisWithMCEventPlane *mcep = new AliFlowAnalysisWithMCEventPlane();
146 AliFlowAnalysisWithQCumulants* qc = new AliFlowAnalysisWithQCumulants();
148 if(listWithWeights) qc->SetWeightsList(listWithWeights);
149 if(usePhiWeights) qc->SetUsePhiWeights(usePhiWeights);
150 if(usePtWeights) qc->SetUsePtWeights(usePtWeights);
151 if(useEtaWeights) qc->SetUseEtaWeights(useEtaWeights);
154 // GFC = Generating Function Cumulants
156 AliFlowAnalysisWithCumulants* gfc = new AliFlowAnalysisWithCumulants();
158 if(listWithWeights) gfc->SetWeightsList(listWithWeights);
159 if(usePhiWeights) gfc->SetUsePhiWeights(usePhiWeights);
160 if(usePtWeights) gfc->SetUsePtWeights(usePtWeights);
161 if(useEtaWeights) gfc->SetUseEtaWeights(useEtaWeights);
164 // FQD = Fitting q-distribution
166 AliFittingQDistribution* fqd = new AliFittingQDistribution();
168 if(listWithWeights) fqd->SetWeightsList(listWithWeights);
169 if(usePhiWeights) fqd->SetUsePhiWeights(usePhiWeights);
172 // SP = Scalar Product
174 AliFlowAnalysisWithScalarProduct* sp = new AliFlowAnalysisWithScalarProduct();
178 // LYZ1 = Lee-Yang Zeroes first run
180 AliFlowAnalysisWithLeeYangZeros* lyz1 = new AliFlowAnalysisWithLeeYangZeros();
181 lyz1->SetFirstRun(kTRUE);
182 lyz1->SetUseSum(kTRUE);
186 // LYZ2 = Lee-Yang Zeroes second run
188 AliFlowAnalysisWithLeeYangZeros* lyz2 = new AliFlowAnalysisWithLeeYangZeros();
189 // read the input file from the first run
190 TString inputFileNameLYZ2 = "outputLYZ1analysis.root" ;
191 TFile* inputFileLYZ2 = new TFile(inputFileNameLYZ2.Data(),"READ");
192 if(!inputFileLYZ2 || inputFileLYZ2->IsZombie()) {
193 cerr << " ERROR: NO First Run file... " << endl ;
197 TList* inputListLYZ2 = (TList*)inputFileLYZ2->Get("cobjLYZ1");
198 if (!inputListLYZ2) {cout<<"Input list is NULL pointer!"<<endl; break;}
200 cout<<"LYZ2 input file/list read..."<<endl;
201 lyz2->SetFirstRunList(inputListLYZ2);
202 lyz2->SetFirstRun(kFALSE);
203 lyz2->SetUseSum(kTRUE);
209 // LYZEP = Lee-Yang Zeroes event plane
211 AliFlowLYZEventPlane* ep = new AliFlowLYZEventPlane() ;
212 AliFlowAnalysisWithLYZEventPlane* lyzep = new AliFlowAnalysisWithLYZEventPlane();
213 // read the input file from the second lyz run
214 TString inputFileNameLYZEP = "outputLYZ2analysis.root" ;
215 TFile* inputFileLYZEP = new TFile(inputFileNameLYZEP.Data(),"READ");
216 if(!inputFileLYZEP || inputFileLYZEP->IsZombie()) {
217 cerr << " ERROR: NO Second Run file... " << endl ;
221 TList* inputListLYZEP = (TList*)inputFileLYZEP->Get("cobjLYZ2");
222 if (!inputListLYZEP) {cout<<"Input list is NULL pointer!"<<endl; break;}
224 cout<<"LYZEP input file/list read..."<<endl;
225 ep ->SetSecondRunList(inputListLYZEP);
226 lyzep->SetSecondRunList(inputListLYZEP);
232 //---------------------------------------------------------------------------------------
234 // set the global event parameters:
235 eventMakerOnTheFly->SetNoOfLoops(iLoops);
237 if(bMultDistrOfRPsIsGauss)
239 eventMakerOnTheFly->SetMultDistrOfRPsIsGauss(bMultDistrOfRPsIsGauss);
240 eventMakerOnTheFly->SetMultiplicityOfRP(iMultiplicityOfRP);
241 eventMakerOnTheFly->SetMultiplicitySpreadOfRP(dMultiplicitySpreadOfRP);
244 eventMakerOnTheFly->SetMultDistrOfRPsIsGauss(bMultDistrOfRPsIsGauss);
245 eventMakerOnTheFly->SetMinMultOfRP(iMinMultOfRP);
246 eventMakerOnTheFly->SetMaxMultOfRP(iMaxMultOfRP);
249 eventMakerOnTheFly->SetTemperatureOfRP(dTemperatureOfRP);
251 eventMakerOnTheFly->SetV1RP(dV1RP);
252 eventMakerOnTheFly->SetV1SpreadRP(dV1SpreadRP);
253 eventMakerOnTheFly->SetV4RP(dV4RP);
254 eventMakerOnTheFly->SetV4SpreadRP(dV4SpreadRP);
256 // constant harmonic V2:
257 if(bConstantHarmonics)
259 eventMakerOnTheFly->SetUseConstantHarmonics(bConstantHarmonics);
260 eventMakerOnTheFly->SetV2RP(dV2RP);
261 eventMakerOnTheFly->SetV2SpreadRP(dV2SpreadRP);
263 // (pt,eta) dependent harmonic V2:
264 if(!bConstantHarmonics)
266 eventMakerOnTheFly->SetUseConstantHarmonics(bConstantHarmonics);
267 eventMakerOnTheFly->SetV2RPMax(dV2RPMax);
268 eventMakerOnTheFly->SetPtCutOff(dPtCutOff);
271 //---------------------------------------------------------------------------------------
272 // create and analyze events 'on the fly':
274 for(Int_t i=0;i<nEvts;i++) {
275 // creating the event with above settings:
276 AliFlowEventSimple *event = eventMakerOnTheFly->CreateEventOnTheFly();
278 // analyzing the created event 'on the fly':
279 // do flow analysis for various methods:
280 if(MCEP) mcep->Make(event);
281 if(QC) qc->Make(event);
282 if(GFC) gfc->Make(event);
283 if(FQD) fqd->Make(event);
284 if(LYZ1) lyz1->Make(event);
285 if(LYZ2) lyz2->Make(event);
286 if(LYZEP) lyzep->Make(event,ep);
287 if(SP) sp->Make(event);
290 } // end of for(Int_t i=0;i<nEvts;i++)
291 //---------------------------------------------------------------------------------------
295 //---------------------------------------------------------------------------------------
296 // calculating and storing the final results of flow analysis
297 if(MCEP) {mcep->Finish(); mcep->WriteHistograms("outputMCEPanalysis.root");}
298 if(SP) {sp->Finish(); sp->WriteHistograms("outputSPanalysis.root");}
299 if(QC) {qc->Finish(); qc->WriteHistograms("outputQCanalysis.root");}
300 if(GFC) {gfc->Finish(); gfc->WriteHistograms("outputGFCanalysis.root");}
301 if(FQD) {fqd->Finish(); fqd->WriteHistograms("outputFQDanalysis.root");}
302 if(LYZ1) {lyz1->Finish(); lyz1->WriteHistograms("outputLYZ1analysis.root");}
303 if(LYZ2) {lyz2->Finish(); lyz2->WriteHistograms("outputLYZ2analysis.root");}
304 if(LYZEP) {lyzep->Finish(); lyzep->WriteHistograms("outputLYZEPanalysis.root");}
305 //---------------------------------------------------------------------------------------
311 cout<<" ---- LANDED SUCCESSFULLY ---- "<<endl;
319 void SetupPar(char* pararchivename)
321 //Load par files, create analysis libraries
322 //For testing, if par file already decompressed and modified
323 //classes then do not decompress.
325 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
326 TString parpar(Form("%s.par", pararchivename)) ;
327 if ( gSystem->AccessPathName(parpar.Data()) ) {
328 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
329 TString processline(Form(".! make %s", parpar.Data())) ;
330 gROOT->ProcessLine(processline.Data()) ;
331 gSystem->ChangeDirectory(cdir) ;
332 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
333 gROOT->ProcessLine(processline.Data()) ;
335 if ( gSystem->AccessPathName(pararchivename) ) {
336 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
337 gROOT->ProcessLine(processline.Data());
340 TString ocwd = gSystem->WorkingDirectory();
341 gSystem->ChangeDirectory(pararchivename);
343 // check for BUILD.sh and execute
344 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
345 printf("*******************************\n");
346 printf("*** Building PAR archive ***\n");
347 cout<<pararchivename<<endl;
348 printf("*******************************\n");
350 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
351 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
355 // check for SETUP.C and execute
356 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
357 printf("*******************************\n");
358 printf("*** Setup PAR archive ***\n");
359 cout<<pararchivename<<endl;
360 printf("*******************************\n");
361 gROOT->Macro("PROOF-INF/SETUP.C");
364 gSystem->ChangeDirectory(ocwd.Data());
365 printf("Current dir: %s\n", ocwd.Data());
368 void LoadLibraries(const anaModes mode) {
370 //--------------------------------------
371 // Load the needed libraries most of them already loaded by aliroot
372 //--------------------------------------
373 gSystem->Load("libTree.so");
374 gSystem->Load("libGeom.so");
375 gSystem->Load("libVMC.so");
376 gSystem->Load("libXMLIO.so");
377 gSystem->Load("libPhysics.so");
379 //----------------------------------------------------------
380 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
381 //----------------------------------------------------------
383 //--------------------------------------------------------
384 // If you want to use already compiled libraries
385 // in the aliroot distribution
386 //--------------------------------------------------------
387 gSystem->Load("libSTEERBase");
388 gSystem->Load("libESD");
389 gSystem->Load("libAOD");
390 gSystem->Load("libANALYSIS");
391 gSystem->Load("libANALYSISalice");
392 gSystem->Load("libCORRFW.so");
393 cerr<<"libCORRFW.so loaded..."<<endl;
394 gSystem->Load("libPWG2flowCommon.so");
395 cerr<<"libPWG2flowCommon.so loaded..."<<endl;
396 gSystem->Load("libPWG2flowTasks.so");
397 cerr<<"libPWG2flowTasks.so loaded..."<<endl;
400 else if (mode == mLocalPAR) {
401 //--------------------------------------------------------
402 //If you want to use root and par files from aliroot
403 //--------------------------------------------------------
404 //If you want to use root and par files from aliroot
405 //--------------------------------------------------------
406 SetupPar("STEERBase");
409 SetupPar("ANALYSIS");
410 SetupPar("ANALYSISalice");
413 SetupPar("PWG2flowCommon");
414 cerr<<"PWG2flowCommon.par loaded..."<<endl;
415 SetupPar("PWG2flowTasks");
416 cerr<<"PWG2flowTasks.par loaded..."<<endl;
419 //---------------------------------------------------------
420 // <<<<<<<<<< Source mode >>>>>>>>>>>>
421 //---------------------------------------------------------
422 else if (mode==mLocalSource) {
424 // In root inline compile
428 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonConstants.cxx+");
429 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZConstants.cxx+");
430 gROOT->LoadMacro("AliFlowCommon/AliFlowCumuConstants.cxx+");
433 gROOT->LoadMacro("AliFlowCommon/AliFlowVector.cxx+");
434 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimple.cxx+");
435 gROOT->LoadMacro("AliFlowCommon/AliFlowEventSimple.cxx+");
438 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimpleCuts.cxx+");
440 // Output histosgrams
441 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHist.cxx+");
442 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHistResults.cxx+");
443 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist1.cxx+");
444 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist2.cxx+");
446 // Functions needed for various methods
447 gROOT->LoadMacro("AliFlowCommon/AliCumulantsFunctions.cxx+");
448 gROOT->LoadMacro("AliFlowCommon/AliFittingFunctionsForQDistribution.cxx+");
449 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZEventPlane.cxx+");
451 // Flow Analysis code for various methods
452 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithMCEventPlane.cxx+");
453 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithScalarProduct.cxx+");
454 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithLYZEventPlane.cxx+");
455 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithLeeYangZeros.cxx+");
456 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithCumulants.cxx+");
457 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithQCumulants.cxx+");
458 gROOT->LoadMacro("AliFlowCommon/AliFittingQDistribution.cxx+");
460 // Class to fill the FlowEvent on the fly (generate Monte Carlo events)
461 gROOT->LoadMacro("AliFlowCommon/AliFlowEventSimpleMakerOnTheFly.cxx+");
463 cout << "finished loading macros!" << endl;