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 iMultiplicityOfRP = 500; // multiplicity of RPs
22 Double_t dMultiplicitySpreadOfRP = 100; // multiplicity spread of RPs
24 Double_t dV2RP = 0.05; // elliptic flow of RPs
25 Double_t dV2SpreadRP = 0.001; // elliptic flow spread of RPs
27 Double_t dV1RP = 0.0; // directed flow of RPs
28 Double_t dV1SpreadRP = 0.0; // directed flow spread of RPs
29 //......................................................................................
31 enum anaModes {mLocal,mLocalSource,mLocalPAR,};
32 // mLocal: Analyze data on your computer using aliroot
33 // mLocalPAR: Analyze data on your computer using root + PAR files
34 // mLocalSource: Analyze data on your computer using root + source files
36 int runFlowAnalysisOnTheFly(Int_t mode=mLocal, Int_t nEvts=100)
41 if (LYZ1 && LYZ2) {cout<<"WARNING: you cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1. "<<endl; exit(); }
42 if (LYZ2 && LYZEP) {cout<<"WARNING: you cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2."<<endl; exit(); }
43 if (LYZ1 && LYZEP) {cout<<"WARNING: you cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2."<<endl; exit(); }
47 cout<<" ---- ARE YOU READY TO FLY ? ---- "<<endl;
51 cout<<" ---- BEGIN FLOW ANALYSIS 'ON THE FLY' ---- "<<endl;
57 // Initialize the random generator
59 UInt_t sseed = dt.GetNanoSec()/1000;
61 //---------------------------------------------------------------------------------------
62 // Initialize the flowevent maker
63 AliFlowEventSimpleMakerOnTheFly* eventMakerOnTheFly = new AliFlowEventSimpleMakerOnTheFly(sseed);
65 //---------------------------------------------------------------------------------------
66 // Initialize all the flow methods:
67 AliFlowAnalysisWithQCumulants *qc = NULL;
68 AliFlowAnalysisWithCumulants *gfc = NULL;
69 AliFittingQDistribution *fqd = NULL;
70 AliFlowAnalysisWithLeeYangZeros *lyz1 = NULL;
71 AliFlowAnalysisWithLeeYangZeros *lyz2 = NULL;
72 AliFlowAnalysisWithLYZEventPlane *lyzep = NULL;
73 AliFlowAnalysisWithScalarProduct *sp = NULL;
74 AliFlowAnalysisWithMCEventPlane *mcep = NULL;
76 // MCEP = monte carlo event plane
78 AliFlowAnalysisWithMCEventPlane *mcep = new AliFlowAnalysisWithMCEventPlane();
84 AliFlowAnalysisWithQCumulants* qc = new AliFlowAnalysisWithQCumulants();
88 // GFC = Generating Function Cumulants
90 AliFlowAnalysisWithCumulants* gfc = new AliFlowAnalysisWithCumulants();
94 // FQD = Fitting q-distribution
96 AliFittingQDistribution* fqd = new AliFittingQDistribution();
100 // SP = Scalar Product
102 AliFlowAnalysisWithScalarProduct* sp = new AliFlowAnalysisWithScalarProduct();
106 // LYZ1 = Lee-Yang Zeroes first run
108 AliFlowAnalysisWithLeeYangZeros* lyz1 = new AliFlowAnalysisWithLeeYangZeros();
109 lyz1->SetFirstRun(kTRUE);
110 lyz1->SetUseSum(kTRUE);
114 // LYZ2 = Lee-Yang Zeroes second run
116 AliFlowAnalysisWithLeeYangZeros* lyz2 = new AliFlowAnalysisWithLeeYangZeros();
117 // read the input file from the first run
118 TString inputFileNameLYZ2 = "outputLYZ1analysis.root" ;
119 TFile* inputFileLYZ2 = new TFile(inputFileNameLYZ2.Data(),"READ");
120 if(!inputFileLYZ2 || inputFileLYZ2->IsZombie()) {
121 cerr << " ERROR: NO First Run file... " << endl ;
125 TList* inputListLYZ2 = (TList*)inputFileLYZ2->Get("cobjLYZ1");
126 if (!inputListLYZ2) {cout<<"Input list is NULL pointer!"<<endl; break;}
128 cout<<"LYZ2 input file/list read..."<<endl;
129 lyz2->SetFirstRunList(inputListLYZ2);
130 lyz2->SetFirstRun(kFALSE);
131 lyz2->SetUseSum(kTRUE);
137 // LYZEP = Lee-Yang Zeroes event plane
139 AliFlowLYZEventPlane* ep = new AliFlowLYZEventPlane() ;
140 AliFlowAnalysisWithLYZEventPlane* lyzep = new AliFlowAnalysisWithLYZEventPlane();
141 // read the input file from the second lyz run
142 TString inputFileNameLYZEP = "outputLYZ2analysis.root" ;
143 TFile* inputFileLYZEP = new TFile(inputFileNameLYZEP.Data(),"READ");
144 if(!inputFileLYZEP || inputFileLYZEP->IsZombie()) {
145 cerr << " ERROR: NO Second Run file... " << endl ;
149 TList* inputListLYZEP = (TList*)inputFileLYZEP->Get("cobjLYZ2");
150 if (!inputListLYZEP) {cout<<"Input list is NULL pointer!"<<endl; break;}
152 cout<<"LYZEP input file/list read..."<<endl;
153 ep ->SetSecondRunList(inputListLYZEP);
154 lyzep->SetSecondRunList(inputListLYZEP);
160 //---------------------------------------------------------------------------------------
162 // set the global event parameters:
163 eventMakerOnTheFly->SetMultiplicityOfRP(iMultiplicityOfRP);
164 eventMakerOnTheFly->SetMultiplicitySpreadOfRP(dMultiplicitySpreadOfRP);
165 eventMakerOnTheFly->SetV1RP(dV1RP);
166 eventMakerOnTheFly->SetV1SpreadRP(dV1SpreadRP);
167 eventMakerOnTheFly->SetV2RP(dV2RP);
168 eventMakerOnTheFly->SetV2SpreadRP(dV2SpreadRP);
170 //---------------------------------------------------------------------------------------
171 // create and analyze events 'on the fly':
173 for(Int_t i=0;i<nEvts;i++) {
174 // creating the event with above settings:
175 AliFlowEventSimple *event = eventMakerOnTheFly->CreateEventOnTheFly();
177 // analyzing the created event 'on the fly':
178 // do flow analysis for various methods:
179 if(MCEP) mcep->Make(event);
180 if(QC) qc->Make(event);
181 if(GFC) gfc->Make(event);
182 if(FQD) fqd->Make(event);
183 if(LYZ1) lyz1->Make(event);
184 if(LYZ2) lyz2->Make(event);
185 if(LYZEP) lyzep->Make(event,ep);
186 if(SP) sp->Make(event);
189 } // end of for(Int_t i=0;i<nEvts;i++)
190 //---------------------------------------------------------------------------------------
194 //---------------------------------------------------------------------------------------
195 // calculating and storing the final results of flow analysis
196 if(MCEP) {mcep->Finish(); mcep->WriteHistograms("outputMCEPanalysis.root");}
197 if(SP) {sp->Finish(); sp->WriteHistograms("outputSPanalysis.root");}
198 if(QC) {qc->Finish(); qc->WriteHistograms("outputQCanalysis.root");}
199 if(GFC) {gfc->Finish(); gfc->WriteHistograms("outputGFCanalysis.root");}
200 if(FQD) {fqd->Finish(); fqd->WriteHistograms("outputFQDanalysis.root");}
201 if(LYZ1) {lyz1->Finish(); lyz1->WriteHistograms("outputLYZ1analysis.root");}
202 if(LYZ2) {lyz2->Finish(); lyz2->WriteHistograms("outputLYZ2analysis.root");}
203 if(LYZEP) {lyzep->Finish(); lyzep->WriteHistograms("outputLYZEPanalysis.root");}
204 //---------------------------------------------------------------------------------------
210 cout<<" ---- LANDED SUCCESSFULLY ---- "<<endl;
218 void SetupPar(char* pararchivename)
220 //Load par files, create analysis libraries
221 //For testing, if par file already decompressed and modified
222 //classes then do not decompress.
224 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
225 TString parpar(Form("%s.par", pararchivename)) ;
226 if ( gSystem->AccessPathName(parpar.Data()) ) {
227 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
228 TString processline(Form(".! make %s", parpar.Data())) ;
229 gROOT->ProcessLine(processline.Data()) ;
230 gSystem->ChangeDirectory(cdir) ;
231 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
232 gROOT->ProcessLine(processline.Data()) ;
234 if ( gSystem->AccessPathName(pararchivename) ) {
235 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
236 gROOT->ProcessLine(processline.Data());
239 TString ocwd = gSystem->WorkingDirectory();
240 gSystem->ChangeDirectory(pararchivename);
242 // check for BUILD.sh and execute
243 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
244 printf("*******************************\n");
245 printf("*** Building PAR archive ***\n");
246 cout<<pararchivename<<endl;
247 printf("*******************************\n");
249 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
250 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
254 // check for SETUP.C and execute
255 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
256 printf("*******************************\n");
257 printf("*** Setup PAR archive ***\n");
258 cout<<pararchivename<<endl;
259 printf("*******************************\n");
260 gROOT->Macro("PROOF-INF/SETUP.C");
263 gSystem->ChangeDirectory(ocwd.Data());
264 printf("Current dir: %s\n", ocwd.Data());
267 void LoadLibraries(const anaModes mode) {
269 //--------------------------------------
270 // Load the needed libraries most of them already loaded by aliroot
271 //--------------------------------------
272 gSystem->Load("libTree.so");
273 gSystem->Load("libGeom.so");
274 gSystem->Load("libVMC.so");
275 gSystem->Load("libXMLIO.so");
276 gSystem->Load("libPhysics.so");
278 //----------------------------------------------------------
279 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
280 //----------------------------------------------------------
282 //--------------------------------------------------------
283 // If you want to use already compiled libraries
284 // in the aliroot distribution
285 //--------------------------------------------------------
286 gSystem->Load("libSTEERBase");
287 gSystem->Load("libESD");
288 gSystem->Load("libAOD");
289 gSystem->Load("libANALYSIS");
290 gSystem->Load("libANALYSISalice");
291 gSystem->Load("libCORRFW.so");
292 cerr<<"libCORRFW.so loaded..."<<endl;
293 gSystem->Load("libPWG2flowCommon.so");
294 cerr<<"libPWG2flowCommon.so loaded..."<<endl;
295 gSystem->Load("libPWG2flowTasks.so");
296 cerr<<"libPWG2flowTasks.so loaded..."<<endl;
299 else if (mode == mLocalPAR) {
300 //--------------------------------------------------------
301 //If you want to use root and par files from aliroot
302 //--------------------------------------------------------
303 //If you want to use root and par files from aliroot
304 //--------------------------------------------------------
305 SetupPar("STEERBase");
308 SetupPar("ANALYSIS");
309 SetupPar("ANALYSISalice");
312 SetupPar("PWG2flowCommon");
313 cerr<<"PWG2flowCommon.par loaded..."<<endl;
314 SetupPar("PWG2flowTasks");
315 cerr<<"PWG2flowTasks.par loaded..."<<endl;
318 //---------------------------------------------------------
319 // <<<<<<<<<< Source mode >>>>>>>>>>>>
320 //---------------------------------------------------------
321 else if (mode==mLocalSource) {
323 // In root inline compile
327 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonConstants.cxx+");
328 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZConstants.cxx+");
329 gROOT->LoadMacro("AliFlowCommon/AliFlowCumuConstants.cxx+");
332 gROOT->LoadMacro("AliFlowCommon/AliFlowVector.cxx+");
333 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimple.cxx+");
334 gROOT->LoadMacro("AliFlowCommon/AliFlowEventSimple.cxx+");
337 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimpleCuts.cxx+");
339 // Output histosgrams
340 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHist.cxx+");
341 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHistResults.cxx+");
342 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist1.cxx+");
343 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist2.cxx+");
345 // Functions needed for various methods
346 gROOT->LoadMacro("AliFlowCommon/AliCumulantsFunctions.cxx+");
347 gROOT->LoadMacro("AliFlowCommon/AliFittingFunctionsForQDistribution.cxx+");
348 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZEventPlane.cxx+");
350 // Flow Analysis code for various methods
351 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithMCEventPlane.cxx+");
352 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithScalarProduct.cxx+");
353 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithLYZEventPlane.cxx+");
354 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithLeeYangZeros.cxx+");
355 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithCumulants.cxx+");
356 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithQCumulants.cxx+");
357 gROOT->LoadMacro("AliFlowCommon/AliFittingQDistribution.cxx+");
359 // Class to fill the FlowEvent without aliroot dependence
360 // can be found in the directory FlowEventMakers
361 gROOT->LoadMacro("FlowEventMakers/FlowEventSimpleMaker.cxx+");
363 cout << "finished loading macros!" << endl;