1 #include "TStopwatch.h"
6 //--------------------------------------------------------------------------------------
8 // flow analysis method can be: (set to kTRUE or kFALSE)
12 Bool_t LYZEP = kFALSE;
17 //--------------------------------------------------------------------------------------
19 Bool_t bSameSeed = kFALSE; // use always the same seed for random generators
20 Bool_t bConstantHarmonics = kFALSE; // harmonics V1, V2, V4... are constant (kTRUE) or functions of pt and eta (kFALSE)
22 // Set the event parameters:
23 Int_t iLoops = 1; // number of times to use each track (to simulate nonflow)
25 Int_t iMultiplicityOfRP = 500; // multiplicity of RPs
26 Double_t dMultiplicitySpreadOfRP = 0; // multiplicity spread of RPs
27 Double_t dTemperatureOfRP = 0.44; // 'temperature' of RPs in GeV/c (increase this parameter to get more high pt RPs)
29 //......................................................................................
30 // if you use (pt,eta) dependent harmonics (bConstantHarmonics = kFALSE):
31 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
32 Double_t dV2RPMax = 0.20; // maximum value of V2(pt) for pt >= 2GeV
33 //......................................................................................
35 //......................................................................................
36 // if you use constant harmonics (bConstantHarmonics = kTRUE):
37 Double_t dV2RP = 0.05; // elliptic flow of RPs
38 Double_t dV2SpreadRP = 0.; // elliptic flow spread of RPs
40 Double_t dV1RP = 0.0; // directed flow of RPs
41 Double_t dV1SpreadRP = 0.0; // directed flow spread of RPs
43 Double_t dV4RP = 0.0; // harmonic V4 of RPs (to be improved: name needed)
44 Double_t dV4SpreadRP = 0.0; // harmonic V4's spread of RPs (to be improved: name needed)
45 //......................................................................................
47 enum anaModes {mLocal,mLocalSource,mLocalPAR};
48 // mLocal: Analyze data on your computer using aliroot
49 // mLocalPAR: Analyze data on your computer using root + PAR files
50 // mLocalSource: Analyze data on your computer using root + source files
52 int runFlowAnalysisOnTheFly(Int_t mode=mLocal, Int_t nEvts=100)
57 if (LYZ1 && LYZ2) {cout<<"WARNING: you cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1. "<<endl; exit(); }
58 if (LYZ2 && LYZEP) {cout<<"WARNING: you cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2."<<endl; exit(); }
59 if (LYZ1 && LYZEP) {cout<<"WARNING: you cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2."<<endl; exit(); }
63 cout<<" ---- ARE YOU READY TO FLY ? ---- "<<endl;
67 cout<<" ---- BEGIN FLOW ANALYSIS 'ON THE FLY' ---- "<<endl;
73 // Initialize the seed for random generator
78 sseed = 44; // the default constant value for seed for random generators
84 sseed = dt.GetNanoSec()/1000;
87 //---------------------------------------------------------------------------------------
88 // Initialize the flowevent maker
89 AliFlowEventSimpleMakerOnTheFly* eventMakerOnTheFly = new AliFlowEventSimpleMakerOnTheFly(sseed);
90 eventMakerOnTheFly->Init();
92 //---------------------------------------------------------------------------------------
93 // Initialize all the flow methods:
94 AliFlowAnalysisWithQCumulants *qc = NULL;
95 AliFlowAnalysisWithCumulants *gfc = NULL;
96 AliFittingQDistribution *fqd = NULL;
97 AliFlowAnalysisWithLeeYangZeros *lyz1 = NULL;
98 AliFlowAnalysisWithLeeYangZeros *lyz2 = NULL;
99 AliFlowAnalysisWithLYZEventPlane *lyzep = NULL;
100 AliFlowAnalysisWithScalarProduct *sp = NULL;
101 AliFlowAnalysisWithMCEventPlane *mcep = NULL;
103 // MCEP = monte carlo event plane
105 AliFlowAnalysisWithMCEventPlane *mcep = new AliFlowAnalysisWithMCEventPlane();
111 AliFlowAnalysisWithQCumulants* qc = new AliFlowAnalysisWithQCumulants();
115 // GFC = Generating Function Cumulants
117 AliFlowAnalysisWithCumulants* gfc = new AliFlowAnalysisWithCumulants();
121 // FQD = Fitting q-distribution
123 AliFittingQDistribution* fqd = new AliFittingQDistribution();
127 // SP = Scalar Product
129 AliFlowAnalysisWithScalarProduct* sp = new AliFlowAnalysisWithScalarProduct();
133 // LYZ1 = Lee-Yang Zeroes first run
135 AliFlowAnalysisWithLeeYangZeros* lyz1 = new AliFlowAnalysisWithLeeYangZeros();
136 lyz1->SetFirstRun(kTRUE);
137 lyz1->SetUseSum(kTRUE);
141 // LYZ2 = Lee-Yang Zeroes second run
143 AliFlowAnalysisWithLeeYangZeros* lyz2 = new AliFlowAnalysisWithLeeYangZeros();
144 // read the input file from the first run
145 TString inputFileNameLYZ2 = "outputLYZ1analysis.root" ;
146 TFile* inputFileLYZ2 = new TFile(inputFileNameLYZ2.Data(),"READ");
147 if(!inputFileLYZ2 || inputFileLYZ2->IsZombie()) {
148 cerr << " ERROR: NO First Run file... " << endl ;
152 TList* inputListLYZ2 = (TList*)inputFileLYZ2->Get("cobjLYZ1");
153 if (!inputListLYZ2) {cout<<"Input list is NULL pointer!"<<endl; break;}
155 cout<<"LYZ2 input file/list read..."<<endl;
156 lyz2->SetFirstRunList(inputListLYZ2);
157 lyz2->SetFirstRun(kFALSE);
158 lyz2->SetUseSum(kTRUE);
164 // LYZEP = Lee-Yang Zeroes event plane
166 AliFlowLYZEventPlane* ep = new AliFlowLYZEventPlane() ;
167 AliFlowAnalysisWithLYZEventPlane* lyzep = new AliFlowAnalysisWithLYZEventPlane();
168 // read the input file from the second lyz run
169 TString inputFileNameLYZEP = "outputLYZ2analysis.root" ;
170 TFile* inputFileLYZEP = new TFile(inputFileNameLYZEP.Data(),"READ");
171 if(!inputFileLYZEP || inputFileLYZEP->IsZombie()) {
172 cerr << " ERROR: NO Second Run file... " << endl ;
176 TList* inputListLYZEP = (TList*)inputFileLYZEP->Get("cobjLYZ2");
177 if (!inputListLYZEP) {cout<<"Input list is NULL pointer!"<<endl; break;}
179 cout<<"LYZEP input file/list read..."<<endl;
180 ep ->SetSecondRunList(inputListLYZEP);
181 lyzep->SetSecondRunList(inputListLYZEP);
187 //---------------------------------------------------------------------------------------
189 // set the global event parameters:
190 eventMakerOnTheFly->SetNoOfLoops(iLoops);
191 eventMakerOnTheFly->SetMultiplicityOfRP(iMultiplicityOfRP);
192 eventMakerOnTheFly->SetMultiplicitySpreadOfRP(dMultiplicitySpreadOfRP);
193 eventMakerOnTheFly->SetTemperatureOfRP(dTemperatureOfRP);
195 eventMakerOnTheFly->SetV1RP(dV1RP);
196 eventMakerOnTheFly->SetV1SpreadRP(dV1SpreadRP);
197 eventMakerOnTheFly->SetV4RP(dV4RP);
198 eventMakerOnTheFly->SetV4SpreadRP(dV4SpreadRP);
200 // constant harmonic V2:
201 if(bConstantHarmonics)
203 eventMakerOnTheFly->SetUseConstantHarmonics(bConstantHarmonics);
204 eventMakerOnTheFly->SetV2RP(dV2RP);
205 eventMakerOnTheFly->SetV2SpreadRP(dV2SpreadRP);
207 // (pt,eta) dependent harmonic V2:
208 if(!bConstantHarmonics)
210 eventMakerOnTheFly->SetUseConstantHarmonics(bConstantHarmonics);
211 eventMakerOnTheFly->SetV2RPMax(dV2RPMax);
212 eventMakerOnTheFly->SetPtCutOff(dPtCutOff);
215 //---------------------------------------------------------------------------------------
216 // create and analyze events 'on the fly':
218 for(Int_t i=0;i<nEvts;i++) {
219 // creating the event with above settings:
220 AliFlowEventSimple *event = eventMakerOnTheFly->CreateEventOnTheFly();
222 // analyzing the created event 'on the fly':
223 // do flow analysis for various methods:
224 if(MCEP) mcep->Make(event);
225 if(QC) qc->Make(event);
226 if(GFC) gfc->Make(event);
227 if(FQD) fqd->Make(event);
228 if(LYZ1) lyz1->Make(event);
229 if(LYZ2) lyz2->Make(event);
230 if(LYZEP) lyzep->Make(event,ep);
231 if(SP) sp->Make(event);
234 } // end of for(Int_t i=0;i<nEvts;i++)
235 //---------------------------------------------------------------------------------------
239 //---------------------------------------------------------------------------------------
240 // calculating and storing the final results of flow analysis
241 if(MCEP) {mcep->Finish(); mcep->WriteHistograms("outputMCEPanalysis.root");}
242 if(SP) {sp->Finish(); sp->WriteHistograms("outputSPanalysis.root");}
243 if(QC) {qc->Finish(); qc->WriteHistograms("outputQCanalysis.root");}
244 if(GFC) {gfc->Finish(); gfc->WriteHistograms("outputGFCanalysis.root");}
245 if(FQD) {fqd->Finish(); fqd->WriteHistograms("outputFQDanalysis.root");}
246 if(LYZ1) {lyz1->Finish(); lyz1->WriteHistograms("outputLYZ1analysis.root");}
247 if(LYZ2) {lyz2->Finish(); lyz2->WriteHistograms("outputLYZ2analysis.root");}
248 if(LYZEP) {lyzep->Finish(); lyzep->WriteHistograms("outputLYZEPanalysis.root");}
249 //---------------------------------------------------------------------------------------
255 cout<<" ---- LANDED SUCCESSFULLY ---- "<<endl;
263 void SetupPar(char* pararchivename)
265 //Load par files, create analysis libraries
266 //For testing, if par file already decompressed and modified
267 //classes then do not decompress.
269 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
270 TString parpar(Form("%s.par", pararchivename)) ;
271 if ( gSystem->AccessPathName(parpar.Data()) ) {
272 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
273 TString processline(Form(".! make %s", parpar.Data())) ;
274 gROOT->ProcessLine(processline.Data()) ;
275 gSystem->ChangeDirectory(cdir) ;
276 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
277 gROOT->ProcessLine(processline.Data()) ;
279 if ( gSystem->AccessPathName(pararchivename) ) {
280 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
281 gROOT->ProcessLine(processline.Data());
284 TString ocwd = gSystem->WorkingDirectory();
285 gSystem->ChangeDirectory(pararchivename);
287 // check for BUILD.sh and execute
288 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
289 printf("*******************************\n");
290 printf("*** Building PAR archive ***\n");
291 cout<<pararchivename<<endl;
292 printf("*******************************\n");
294 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
295 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
299 // check for SETUP.C and execute
300 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
301 printf("*******************************\n");
302 printf("*** Setup PAR archive ***\n");
303 cout<<pararchivename<<endl;
304 printf("*******************************\n");
305 gROOT->Macro("PROOF-INF/SETUP.C");
308 gSystem->ChangeDirectory(ocwd.Data());
309 printf("Current dir: %s\n", ocwd.Data());
312 void LoadLibraries(const anaModes mode) {
314 //--------------------------------------
315 // Load the needed libraries most of them already loaded by aliroot
316 //--------------------------------------
317 gSystem->Load("libTree.so");
318 gSystem->Load("libGeom.so");
319 gSystem->Load("libVMC.so");
320 gSystem->Load("libXMLIO.so");
321 gSystem->Load("libPhysics.so");
323 //----------------------------------------------------------
324 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
325 //----------------------------------------------------------
327 //--------------------------------------------------------
328 // If you want to use already compiled libraries
329 // in the aliroot distribution
330 //--------------------------------------------------------
331 gSystem->Load("libSTEERBase");
332 gSystem->Load("libESD");
333 gSystem->Load("libAOD");
334 gSystem->Load("libANALYSIS");
335 gSystem->Load("libANALYSISalice");
336 gSystem->Load("libCORRFW.so");
337 cerr<<"libCORRFW.so loaded..."<<endl;
338 gSystem->Load("libPWG2flowCommon.so");
339 cerr<<"libPWG2flowCommon.so loaded..."<<endl;
340 gSystem->Load("libPWG2flowTasks.so");
341 cerr<<"libPWG2flowTasks.so loaded..."<<endl;
344 else if (mode == mLocalPAR) {
345 //--------------------------------------------------------
346 //If you want to use root and par files from aliroot
347 //--------------------------------------------------------
348 //If you want to use root and par files from aliroot
349 //--------------------------------------------------------
350 SetupPar("STEERBase");
353 SetupPar("ANALYSIS");
354 SetupPar("ANALYSISalice");
357 SetupPar("PWG2flowCommon");
358 cerr<<"PWG2flowCommon.par loaded..."<<endl;
359 SetupPar("PWG2flowTasks");
360 cerr<<"PWG2flowTasks.par loaded..."<<endl;
363 //---------------------------------------------------------
364 // <<<<<<<<<< Source mode >>>>>>>>>>>>
365 //---------------------------------------------------------
366 else if (mode==mLocalSource) {
368 // In root inline compile
372 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonConstants.cxx+");
373 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZConstants.cxx+");
374 gROOT->LoadMacro("AliFlowCommon/AliFlowCumuConstants.cxx+");
377 gROOT->LoadMacro("AliFlowCommon/AliFlowVector.cxx+");
378 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimple.cxx+");
379 gROOT->LoadMacro("AliFlowCommon/AliFlowEventSimple.cxx+");
382 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimpleCuts.cxx+");
384 // Output histosgrams
385 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHist.cxx+");
386 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHistResults.cxx+");
387 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist1.cxx+");
388 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist2.cxx+");
390 // Functions needed for various methods
391 gROOT->LoadMacro("AliFlowCommon/AliCumulantsFunctions.cxx+");
392 gROOT->LoadMacro("AliFlowCommon/AliFittingFunctionsForQDistribution.cxx+");
393 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZEventPlane.cxx+");
395 // Flow Analysis code for various methods
396 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithMCEventPlane.cxx+");
397 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithScalarProduct.cxx+");
398 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithLYZEventPlane.cxx+");
399 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithLeeYangZeros.cxx+");
400 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithCumulants.cxx+");
401 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithQCumulants.cxx+");
402 gROOT->LoadMacro("AliFlowCommon/AliFittingQDistribution.cxx+");
404 // Class to fill the FlowEvent on the fly (generate Monte Carlo events)
405 gROOT->LoadMacro("AliFlowCommon/AliFlowEventSimpleMakerOnTheFly.cxx+");
407 cout << "finished loading macros!" << endl;