1 #include "TStopwatch.h"
6 //--------------------------------------------------------------------------------------
8 // flow analysis method can be: (set to kTRUE or kFALSE)
12 Bool_t LYZEP = kFALSE;
17 //--------------------------------------------------------------------------------------
19 //.................................................................................
21 // Set the event parameters:
22 Int_t iMultiplicityOfRP = 4400; // multiplicity of RPs
24 //.................................................................................
28 enum anaModes {mLocal,mLocalSource,mLocalPAR,};
29 // mLocal: Analyze data on your computer using aliroot
30 // mLocalPAR: Analyze data on your computer using root + PAR files
31 // mLocalSource: Analyze data on your computer using root + source files
33 int runFlowAnalysisOnTheFly(Int_t mode=mLocal, Int_t nEvts=1)
38 if (LYZ1 && LYZ2) {cout<<"WARNING: you cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1. "<<endl; exit(); }
39 if (LYZ2 && LYZEP) {cout<<"WARNING: you cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2."<<endl; exit(); }
40 if (LYZ1 && LYZEP) {cout<<"WARNING: you cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2."<<endl; exit(); }
44 cout<<" ---- ARE YOU READY TO FLY ? ---- "<<endl;
48 cout<<" ---- BEGIN FLOW ANALYSIS 'ON THE FLY' ---- "<<endl;
55 //---------------------------------------------------------------------------------------
56 // Initialize the flowevent maker
57 AliFlowEventSimpleMakerOnTheFly* eventMakerOnTheFly = new AliFlowEventSimpleMakerOnTheFly();
60 //---------------------------------------------------------------------------------------
61 // Initialize all the flow methods:
62 AliFlowAnalysisWithQCumulants *qc = NULL;
63 AliFlowAnalysisWithCumulants *gfc = NULL;
64 AliFittingQDistribution *fqd = NULL;
65 AliFlowAnalysisWithLeeYangZeros *lyz1 = NULL;
66 AliFlowAnalysisWithLeeYangZeros *lyz2 = NULL;
67 AliFlowAnalysisWithLYZEventPlane *lyzep = NULL;
68 AliFlowAnalysisWithScalarProduct *sp = NULL;
69 AliFlowAnalysisWithMCEventPlane *mcep = NULL;
71 // MCEP = monte carlo event plane
73 AliFlowAnalysisWithMCEventPlane *mcep = new AliFlowAnalysisWithMCEventPlane();
79 AliFlowAnalysisWithQCumulants* qc = new AliFlowAnalysisWithQCumulants();
83 // GFC = Generating Function Cumulants
85 AliFlowAnalysisWithCumulants* gfc = new AliFlowAnalysisWithCumulants();
89 // FQD = Fitting q-distribution
91 AliFittingQDistribution* fqd = new AliFittingQDistribution();
95 // SP = Scalar Product
97 AliFlowAnalysisWithScalarProduct* sp = new AliFlowAnalysisWithScalarProduct();
101 // LYZ1 = Lee-Yang Zeroes first run
103 AliFlowAnalysisWithLeeYangZeros* lyz1 = new AliFlowAnalysisWithLeeYangZeros();
104 lyz1->SetFirstRun(kTRUE);
105 lyz1->SetUseSum(kTRUE);
109 // LYZ2 = Lee-Yang Zeroes second run
111 AliFlowAnalysisWithLeeYangZeros* lyz2 = new AliFlowAnalysisWithLeeYangZeros();
112 // read the input file from the first run
113 TString inputFileNameLYZ2 = "outputLYZ1analysis.root" ;
114 TFile* inputFileLYZ2 = new TFile(inputFileNameLYZ2.Data(),"READ");
115 if(!inputFileLYZ2 || inputFileLYZ2->IsZombie()) {
116 cerr << " ERROR: NO First Run file... " << endl ;
120 TList* inputListLYZ2 = (TList*)inputFileLYZ2->Get("cobjLYZ1");
121 if (!inputListLYZ2) {cout<<"Input list is NULL pointer!"<<endl; break;}
123 cout<<"LYZ2 input file/list read..."<<endl;
124 lyz2->SetFirstRunList(inputListLYZ2);
125 lyz2->SetFirstRun(kFALSE);
126 lyz2->SetUseSum(kTRUE);
132 // LYZEP = Lee-Yang Zeroes event plane
134 AliFlowLYZEventPlane* ep = new AliFlowLYZEventPlane() ;
135 AliFlowAnalysisWithLYZEventPlane* lyzep = new AliFlowAnalysisWithLYZEventPlane();
136 // read the input file from the second lyz run
137 TString inputFileNameLYZEP = "outputLYZ2analysis.root" ;
138 TFile* inputFileLYZEP = new TFile(inputFileNameLYZEP.Data(),"READ");
139 if(!inputFileLYZEP || inputFileLYZEP->IsZombie()) {
140 cerr << " ERROR: NO Second Run file... " << endl ;
144 TList* inputListLYZEP = (TList*)inputFileLYZEP->Get("cobjLYZ2");
145 if (!inputListLYZEP) {cout<<"Input list is NULL pointer!"<<endl; break;}
147 cout<<"LYZEP input file/list read..."<<endl;
148 ep ->SetSecondRunList(inputListLYZEP);
149 lyzep->SetSecondRunList(inputListLYZEP);
155 //---------------------------------------------------------------------------------------
158 //---------------------------------------------------------------------------------------
159 // create and analyze events 'on the fly':
161 // set the global event parameters:
162 eventMakerOnTheFly->SetMultiplicityOfRP(iMultiplicityOfRP);
164 for(Int_t i=0;i<nEvts;i++) {
165 // creating the event with above settings:
168 cout<<" ---- CREATING EVENT No "<<i+1<<" ---- "<<endl;
171 AliFlowEventSimple *event = eventMakerOnTheFly->CreateEventOnTheFly();
172 cout<<" .... done .... "<<endl;
174 // analyzing the created event 'on the fly':
176 cout<<" ---- ANALYZING EVENT No "<<i+1<<" ---- "<<endl;
179 // do flow analysis for various methods:
180 if(MCEP) mcep->Make(event);
181 if(QC) qc->Make(event);
182 if(GFC) gfc->Make(event);
183 if(FQD) fqd->Make(event);
184 if(LYZ1) lyz1->Make(event);
185 if(LYZ2) lyz2->Make(event);
186 if(LYZEP) lyzep->Make(event,ep);
187 if(SP) sp->Make(event);
189 cout<<" .... done .... "<<endl;
193 } // end of for(Int_t i=0;i<nEvts;i++)
194 //---------------------------------------------------------------------------------------
198 //---------------------------------------------------------------------------------------
199 // calculating and storing the final results of flow analysis
200 if(MCEP) {mcep->Finish(); mcep->WriteHistograms("outputMCEPanalysis.root");}
201 if(SP) {sp->Finish(); sp->WriteHistograms("outputSPanalysis.root");}
202 if(QC) {qc->Finish(); qc->WriteHistograms("outputQCanalysis.root");}
203 if(GFC) {gfc->Finish(); gfc->WriteHistograms("outputGFCanalysis.root");}
204 if(FQD) {fqd->Finish(); fqd->WriteHistograms("outputFQDanalysis.root");}
205 if(LYZ1) {lyz1->Finish(); lyz1->WriteHistograms("outputLYZ1analysis.root");}
206 if(LYZ2) {lyz2->Finish(); lyz2->WriteHistograms("outputLYZ2analysis.root");}
207 if(LYZEP) {lyzep->Finish(); lyzep->WriteHistograms("outputLYZEPanalysis.root");}
208 //---------------------------------------------------------------------------------------
214 cout<<" ---- LANDED SUCCESSFULLY ---- "<<endl;
222 void SetupPar(char* pararchivename)
224 //Load par files, create analysis libraries
225 //For testing, if par file already decompressed and modified
226 //classes then do not decompress.
228 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
229 TString parpar(Form("%s.par", pararchivename)) ;
230 if ( gSystem->AccessPathName(parpar.Data()) ) {
231 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
232 TString processline(Form(".! make %s", parpar.Data())) ;
233 gROOT->ProcessLine(processline.Data()) ;
234 gSystem->ChangeDirectory(cdir) ;
235 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
236 gROOT->ProcessLine(processline.Data()) ;
238 if ( gSystem->AccessPathName(pararchivename) ) {
239 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
240 gROOT->ProcessLine(processline.Data());
243 TString ocwd = gSystem->WorkingDirectory();
244 gSystem->ChangeDirectory(pararchivename);
246 // check for BUILD.sh and execute
247 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
248 printf("*******************************\n");
249 printf("*** Building PAR archive ***\n");
250 cout<<pararchivename<<endl;
251 printf("*******************************\n");
253 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
254 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
258 // check for SETUP.C and execute
259 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
260 printf("*******************************\n");
261 printf("*** Setup PAR archive ***\n");
262 cout<<pararchivename<<endl;
263 printf("*******************************\n");
264 gROOT->Macro("PROOF-INF/SETUP.C");
267 gSystem->ChangeDirectory(ocwd.Data());
268 printf("Current dir: %s\n", ocwd.Data());
271 void LoadLibraries(const anaModes mode) {
273 //--------------------------------------
274 // Load the needed libraries most of them already loaded by aliroot
275 //--------------------------------------
276 gSystem->Load("libTree.so");
277 gSystem->Load("libGeom.so");
278 gSystem->Load("libVMC.so");
279 gSystem->Load("libXMLIO.so");
280 gSystem->Load("libPhysics.so");
282 //----------------------------------------------------------
283 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
284 //----------------------------------------------------------
286 //--------------------------------------------------------
287 // If you want to use already compiled libraries
288 // in the aliroot distribution
289 //--------------------------------------------------------
290 gSystem->Load("libSTEERBase");
291 gSystem->Load("libESD");
292 gSystem->Load("libAOD");
293 gSystem->Load("libANALYSIS");
294 gSystem->Load("libANALYSISalice");
295 gSystem->Load("libCORRFW.so");
296 cerr<<"libCORRFW.so loaded..."<<endl;
297 gSystem->Load("libPWG2flowCommon.so");
298 cerr<<"libPWG2flowCommon.so loaded..."<<endl;
299 gSystem->Load("libPWG2flowTasks.so");
300 cerr<<"libPWG2flowTasks.so loaded..."<<endl;
303 else if (mode == mLocalPAR) {
304 //--------------------------------------------------------
305 //If you want to use root and par files from aliroot
306 //--------------------------------------------------------
307 //If you want to use root and par files from aliroot
308 //--------------------------------------------------------
309 SetupPar("STEERBase");
312 SetupPar("ANALYSIS");
313 SetupPar("ANALYSISalice");
316 SetupPar("PWG2flowCommon");
317 cerr<<"PWG2flowCommon.par loaded..."<<endl;
318 SetupPar("PWG2flowTasks");
319 cerr<<"PWG2flowTasks.par loaded..."<<endl;
322 //---------------------------------------------------------
323 // <<<<<<<<<< Source mode >>>>>>>>>>>>
324 //---------------------------------------------------------
325 else if (mode==mLocalSource) {
327 // In root inline compile
331 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonConstants.cxx+");
332 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZConstants.cxx+");
333 gROOT->LoadMacro("AliFlowCommon/AliFlowCumuConstants.cxx+");
336 gROOT->LoadMacro("AliFlowCommon/AliFlowVector.cxx+");
337 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimple.cxx+");
338 gROOT->LoadMacro("AliFlowCommon/AliFlowEventSimple.cxx+");
341 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimpleCuts.cxx+");
343 // Output histosgrams
344 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHist.cxx+");
345 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHistResults.cxx+");
346 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist1.cxx+");
347 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist2.cxx+");
349 // Functions needed for various methods
350 gROOT->LoadMacro("AliFlowCommon/AliCumulantsFunctions.cxx+");
351 gROOT->LoadMacro("AliFlowCommon/AliFittingFunctionsForQDistribution.cxx+");
352 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZEventPlane.cxx+");
354 // Flow Analysis code for various methods
355 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithMCEventPlane.cxx+");
356 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithScalarProduct.cxx+");
357 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithLYZEventPlane.cxx+");
358 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithLeeYangZeros.cxx+");
359 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithCumulants.cxx+");
360 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithQCumulants.cxx+");
361 gROOT->LoadMacro("AliFlowCommon/AliFittingQDistribution.cxx+");
363 // Class to fill the FlowEvent without aliroot dependence
364 // can be found in the directory FlowEventMakers
365 gROOT->LoadMacro("FlowEventMakers/FlowEventSimpleMaker.cxx+");
367 cout << "finished loading macros!" << endl;