1 #include "TStopwatch.h"
6 //--------------------------------------------------------------------------------------
8 // flow analysis method can be: (set to kTRUE or kFALSE)
12 Bool_t LYZEP = kFALSE;
17 //--------------------------------------------------------------------------------------
19 //......................................................................................
20 // Set the event parameters:
21 Int_t iLoops = 1; // number of times to use each track (to simulate nonflow)
22 Int_t iMultiplicityOfRP = 500; // multiplicity of RPs
23 Double_t dMultiplicitySpreadOfRP = 0; // multiplicity spread of RPs
25 Double_t dV2RP = 0.05; // elliptic flow of RPs
26 Double_t dV2SpreadRP = 0.; // elliptic flow spread of RPs
28 Double_t dV1RP = 0.0; // directed flow of RPs
29 Double_t dV1SpreadRP = 0.0; // directed flow spread of RPs
30 //......................................................................................
32 enum anaModes {mLocal,mLocalSource,mLocalPAR,};
33 // mLocal: Analyze data on your computer using aliroot
34 // mLocalPAR: Analyze data on your computer using root + PAR files
35 // mLocalSource: Analyze data on your computer using root + source files
37 int runFlowAnalysisOnTheFly(Int_t mode=mLocal, Int_t nEvts=100)
42 if (LYZ1 && LYZ2) {cout<<"WARNING: you cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1. "<<endl; exit(); }
43 if (LYZ2 && LYZEP) {cout<<"WARNING: you cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2."<<endl; exit(); }
44 if (LYZ1 && LYZEP) {cout<<"WARNING: you cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2."<<endl; exit(); }
48 cout<<" ---- ARE YOU READY TO FLY ? ---- "<<endl;
52 cout<<" ---- BEGIN FLOW ANALYSIS 'ON THE FLY' ---- "<<endl;
58 // Initialize the random generator
60 UInt_t sseed = dt.GetNanoSec()/1000;
62 //---------------------------------------------------------------------------------------
63 // Initialize the flowevent maker
64 AliFlowEventSimpleMakerOnTheFly* eventMakerOnTheFly = new AliFlowEventSimpleMakerOnTheFly(sseed);
66 //---------------------------------------------------------------------------------------
67 // Initialize all the flow methods:
68 AliFlowAnalysisWithQCumulants *qc = NULL;
69 AliFlowAnalysisWithCumulants *gfc = NULL;
70 AliFittingQDistribution *fqd = NULL;
71 AliFlowAnalysisWithLeeYangZeros *lyz1 = NULL;
72 AliFlowAnalysisWithLeeYangZeros *lyz2 = NULL;
73 AliFlowAnalysisWithLYZEventPlane *lyzep = NULL;
74 AliFlowAnalysisWithScalarProduct *sp = NULL;
75 AliFlowAnalysisWithMCEventPlane *mcep = NULL;
77 // MCEP = monte carlo event plane
79 AliFlowAnalysisWithMCEventPlane *mcep = new AliFlowAnalysisWithMCEventPlane();
85 AliFlowAnalysisWithQCumulants* qc = new AliFlowAnalysisWithQCumulants();
89 // GFC = Generating Function Cumulants
91 AliFlowAnalysisWithCumulants* gfc = new AliFlowAnalysisWithCumulants();
95 // FQD = Fitting q-distribution
97 AliFittingQDistribution* fqd = new AliFittingQDistribution();
101 // SP = Scalar Product
103 AliFlowAnalysisWithScalarProduct* sp = new AliFlowAnalysisWithScalarProduct();
107 // LYZ1 = Lee-Yang Zeroes first run
109 AliFlowAnalysisWithLeeYangZeros* lyz1 = new AliFlowAnalysisWithLeeYangZeros();
110 lyz1->SetFirstRun(kTRUE);
111 lyz1->SetUseSum(kTRUE);
115 // LYZ2 = Lee-Yang Zeroes second run
117 AliFlowAnalysisWithLeeYangZeros* lyz2 = new AliFlowAnalysisWithLeeYangZeros();
118 // read the input file from the first run
119 TString inputFileNameLYZ2 = "outputLYZ1analysis.root" ;
120 TFile* inputFileLYZ2 = new TFile(inputFileNameLYZ2.Data(),"READ");
121 if(!inputFileLYZ2 || inputFileLYZ2->IsZombie()) {
122 cerr << " ERROR: NO First Run file... " << endl ;
126 TList* inputListLYZ2 = (TList*)inputFileLYZ2->Get("cobjLYZ1");
127 if (!inputListLYZ2) {cout<<"Input list is NULL pointer!"<<endl; break;}
129 cout<<"LYZ2 input file/list read..."<<endl;
130 lyz2->SetFirstRunList(inputListLYZ2);
131 lyz2->SetFirstRun(kFALSE);
132 lyz2->SetUseSum(kTRUE);
138 // LYZEP = Lee-Yang Zeroes event plane
140 AliFlowLYZEventPlane* ep = new AliFlowLYZEventPlane() ;
141 AliFlowAnalysisWithLYZEventPlane* lyzep = new AliFlowAnalysisWithLYZEventPlane();
142 // read the input file from the second lyz run
143 TString inputFileNameLYZEP = "outputLYZ2analysis.root" ;
144 TFile* inputFileLYZEP = new TFile(inputFileNameLYZEP.Data(),"READ");
145 if(!inputFileLYZEP || inputFileLYZEP->IsZombie()) {
146 cerr << " ERROR: NO Second Run file... " << endl ;
150 TList* inputListLYZEP = (TList*)inputFileLYZEP->Get("cobjLYZ2");
151 if (!inputListLYZEP) {cout<<"Input list is NULL pointer!"<<endl; break;}
153 cout<<"LYZEP input file/list read..."<<endl;
154 ep ->SetSecondRunList(inputListLYZEP);
155 lyzep->SetSecondRunList(inputListLYZEP);
161 //---------------------------------------------------------------------------------------
163 // set the global event parameters:
164 eventMakerOnTheFly->SetNoOfLoops(iLoops);
165 eventMakerOnTheFly->SetMultiplicityOfRP(iMultiplicityOfRP);
166 eventMakerOnTheFly->SetMultiplicitySpreadOfRP(dMultiplicitySpreadOfRP);
167 eventMakerOnTheFly->SetV1RP(dV1RP);
168 eventMakerOnTheFly->SetV1SpreadRP(dV1SpreadRP);
169 eventMakerOnTheFly->SetV2RP(dV2RP);
170 eventMakerOnTheFly->SetV2SpreadRP(dV2SpreadRP);
172 //---------------------------------------------------------------------------------------
173 // create and analyze events 'on the fly':
175 for(Int_t i=0;i<nEvts;i++) {
176 // creating the event with above settings:
177 AliFlowEventSimple *event = eventMakerOnTheFly->CreateEventOnTheFly();
179 // analyzing the created event 'on the fly':
180 // do flow analysis for various methods:
181 if(MCEP) mcep->Make(event);
182 if(QC) qc->Make(event);
183 if(GFC) gfc->Make(event);
184 if(FQD) fqd->Make(event);
185 if(LYZ1) lyz1->Make(event);
186 if(LYZ2) lyz2->Make(event);
187 if(LYZEP) lyzep->Make(event,ep);
188 if(SP) sp->Make(event);
191 } // end of for(Int_t i=0;i<nEvts;i++)
192 //---------------------------------------------------------------------------------------
196 //---------------------------------------------------------------------------------------
197 // calculating and storing the final results of flow analysis
198 if(MCEP) {mcep->Finish(); mcep->WriteHistograms("outputMCEPanalysis.root");}
199 if(SP) {sp->Finish(); sp->WriteHistograms("outputSPanalysis.root");}
200 if(QC) {qc->Finish(); qc->WriteHistograms("outputQCanalysis.root");}
201 if(GFC) {gfc->Finish(); gfc->WriteHistograms("outputGFCanalysis.root");}
202 if(FQD) {fqd->Finish(); fqd->WriteHistograms("outputFQDanalysis.root");}
203 if(LYZ1) {lyz1->Finish(); lyz1->WriteHistograms("outputLYZ1analysis.root");}
204 if(LYZ2) {lyz2->Finish(); lyz2->WriteHistograms("outputLYZ2analysis.root");}
205 if(LYZEP) {lyzep->Finish(); lyzep->WriteHistograms("outputLYZEPanalysis.root");}
206 //---------------------------------------------------------------------------------------
212 cout<<" ---- LANDED SUCCESSFULLY ---- "<<endl;
220 void SetupPar(char* pararchivename)
222 //Load par files, create analysis libraries
223 //For testing, if par file already decompressed and modified
224 //classes then do not decompress.
226 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
227 TString parpar(Form("%s.par", pararchivename)) ;
228 if ( gSystem->AccessPathName(parpar.Data()) ) {
229 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
230 TString processline(Form(".! make %s", parpar.Data())) ;
231 gROOT->ProcessLine(processline.Data()) ;
232 gSystem->ChangeDirectory(cdir) ;
233 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
234 gROOT->ProcessLine(processline.Data()) ;
236 if ( gSystem->AccessPathName(pararchivename) ) {
237 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
238 gROOT->ProcessLine(processline.Data());
241 TString ocwd = gSystem->WorkingDirectory();
242 gSystem->ChangeDirectory(pararchivename);
244 // check for BUILD.sh and execute
245 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
246 printf("*******************************\n");
247 printf("*** Building PAR archive ***\n");
248 cout<<pararchivename<<endl;
249 printf("*******************************\n");
251 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
252 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
256 // check for SETUP.C and execute
257 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
258 printf("*******************************\n");
259 printf("*** Setup PAR archive ***\n");
260 cout<<pararchivename<<endl;
261 printf("*******************************\n");
262 gROOT->Macro("PROOF-INF/SETUP.C");
265 gSystem->ChangeDirectory(ocwd.Data());
266 printf("Current dir: %s\n", ocwd.Data());
269 void LoadLibraries(const anaModes mode) {
271 //--------------------------------------
272 // Load the needed libraries most of them already loaded by aliroot
273 //--------------------------------------
274 gSystem->Load("libTree.so");
275 gSystem->Load("libGeom.so");
276 gSystem->Load("libVMC.so");
277 gSystem->Load("libXMLIO.so");
278 gSystem->Load("libPhysics.so");
280 //----------------------------------------------------------
281 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
282 //----------------------------------------------------------
284 //--------------------------------------------------------
285 // If you want to use already compiled libraries
286 // in the aliroot distribution
287 //--------------------------------------------------------
288 gSystem->Load("libSTEERBase");
289 gSystem->Load("libESD");
290 gSystem->Load("libAOD");
291 gSystem->Load("libANALYSIS");
292 gSystem->Load("libANALYSISalice");
293 gSystem->Load("libCORRFW.so");
294 cerr<<"libCORRFW.so loaded..."<<endl;
295 gSystem->Load("libPWG2flowCommon.so");
296 cerr<<"libPWG2flowCommon.so loaded..."<<endl;
297 gSystem->Load("libPWG2flowTasks.so");
298 cerr<<"libPWG2flowTasks.so loaded..."<<endl;
301 else if (mode == mLocalPAR) {
302 //--------------------------------------------------------
303 //If you want to use root and par files from aliroot
304 //--------------------------------------------------------
305 //If you want to use root and par files from aliroot
306 //--------------------------------------------------------
307 SetupPar("STEERBase");
310 SetupPar("ANALYSIS");
311 SetupPar("ANALYSISalice");
314 SetupPar("PWG2flowCommon");
315 cerr<<"PWG2flowCommon.par loaded..."<<endl;
316 SetupPar("PWG2flowTasks");
317 cerr<<"PWG2flowTasks.par loaded..."<<endl;
320 //---------------------------------------------------------
321 // <<<<<<<<<< Source mode >>>>>>>>>>>>
322 //---------------------------------------------------------
323 else if (mode==mLocalSource) {
325 // In root inline compile
329 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonConstants.cxx+");
330 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZConstants.cxx+");
331 gROOT->LoadMacro("AliFlowCommon/AliFlowCumuConstants.cxx+");
334 gROOT->LoadMacro("AliFlowCommon/AliFlowVector.cxx+");
335 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimple.cxx+");
336 gROOT->LoadMacro("AliFlowCommon/AliFlowEventSimple.cxx+");
339 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimpleCuts.cxx+");
341 // Output histosgrams
342 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHist.cxx+");
343 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHistResults.cxx+");
344 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist1.cxx+");
345 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist2.cxx+");
347 // Functions needed for various methods
348 gROOT->LoadMacro("AliFlowCommon/AliCumulantsFunctions.cxx+");
349 gROOT->LoadMacro("AliFlowCommon/AliFittingFunctionsForQDistribution.cxx+");
350 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZEventPlane.cxx+");
352 // Flow Analysis code for various methods
353 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithMCEventPlane.cxx+");
354 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithScalarProduct.cxx+");
355 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithLYZEventPlane.cxx+");
356 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithLeeYangZeros.cxx+");
357 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithCumulants.cxx+");
358 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithQCumulants.cxx+");
359 gROOT->LoadMacro("AliFlowCommon/AliFittingQDistribution.cxx+");
361 // Class to fill the FlowEvent without aliroot dependence
362 // can be found in the directory FlowEventMakers
363 gROOT->LoadMacro("FlowEventMakers/FlowEventSimpleMaker.cxx+");
365 cout << "finished loading macros!" << endl;