]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/macros/runFlowTask.C
Adding "+" after the definition of the AliTOFRecoParam class.
[u/mrichter/AliRoot.git] / PWG2 / FLOW / macros / runFlowTask.C
CommitLineData
73160af6 1enum anaModes {mLocal,mLocalPAR,mPROOF,mGRID};
2//mLocal: Analyze locally files in your computer using aliroot
3//mLocalPAR: Analyze locally files in your computer using root + PAR files
4//mPROOF: Analyze CAF files with PROOF
5
73160af6 6// RUN SETTINGS
93329510 7
73160af6 8// Flow analysis method can be:(set to kTRUE or kFALSE)
56857739 9Bool_t SP = kTRUE;
10Bool_t LYZ1SUM = kTRUE;
11Bool_t LYZ1PROD = kTRUE;
c741f5d0 12Bool_t LYZ2SUM = kFALSE;
56857739 13Bool_t LYZ2PROD = kFALSE;
c741f5d0 14Bool_t LYZEP = kFALSE;
56857739 15Bool_t GFC = kTRUE;
16Bool_t QC = kTRUE;
421e92de 17Bool_t FQD = kTRUE;
18Bool_t MCEP = kTRUE; //not for pp
c741f5d0 19
20Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP};
93329510 21
22// Analysis type can be ESD, AOD, MC, ESDMC0, ESDMC1
23const TString type = "ESD";
73160af6 24
25// Boolean to fill/not fill the QA histograms
93329510 26Bool_t QA = kTRUE;
73160af6 27
93329510 28// Boolean to use/not use weights for the Q vector
29Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)
73160af6 30
31
421e92de 32void runFlowTask(Int_t mode=mLocal, Int_t nRuns = 100,
c741f5d0 33 //const Char_t* dataDir="/data/alice2/kolk/PP/LHC09a4/81119", Int_t offset = 0)
421e92de 34 //const Char_t* dataDir="/data/alice2/kolk/Therminator_midcentral", Int_t offset = 0)
35 const Char_t* dataDir="/Users/snelling/alice_data/Therminator_midcentral", Int_t offset = 0)
c741f5d0 36//void runFlowTask(Int_t mode=mPROOF, Int_t nRuns = 10000,
93329510 37 // const Char_t* dataDir="/COMMON/COMMON/LHC09a4_run8158X", Int_t offset = 0)
c741f5d0 38 //const Char_t* dataDir="/PWG2/akisiel/Therminator_c2030", Int_t offset=0)
73160af6 39{
73160af6 40 TStopwatch timer;
41 timer.Start();
93329510 42
73160af6 43 LoadLibraries(mode);
93329510 44
73160af6 45 if (mode==mLocal || mode == mLocalPAR || mode == mGRID) {
93329510 46 if (type!="AOD") { TChain* chain = CreateESDChain(dataDir, nRuns, offset);}
73160af6 47 else { TChain* chain = CreateAODChain(dataDir, nRuns, offset);}
48 }
73160af6 49 //____________________________________________//
50 // Make the analysis manager
51 AliAnalysisManager *mgr = new AliAnalysisManager("FlowAnalysisManager");
93329510 52
73160af6 53 if (type == "ESD"){
54 AliVEventHandler* esdH = new AliESDInputHandler;
55 mgr->SetInputEventHandler(esdH);
4a1a86a5 56
57 AliMCEventHandler *mc = new AliMCEventHandler();
58 mgr->SetMCtruthEventHandler(mc);
93329510 59 }
73160af6 60
61 if (type == "AOD"){
62 AliVEventHandler* aodH = new AliAODInputHandler;
63 mgr->SetInputEventHandler(aodH);
4a1a86a5 64
65 AliMCEventHandler *mc = new AliMCEventHandler();
66 mgr->SetMCtruthEventHandler(mc);
93329510 67 }
73160af6 68
69 if (type == "MC" || type == "ESDMC0" || type == "ESDMC1"){
70 AliVEventHandler* esdH = new AliESDInputHandler;
71 mgr->SetInputEventHandler(esdH);
72
73 AliMCEventHandler *mc = new AliMCEventHandler();
4a1a86a5 74 mgr->SetMCtruthEventHandler(mc);
75 }
73160af6 76
73160af6 77
73160af6 78 //____________________________________________//
93329510 79 // Load the tasks
80 gROOT->LoadMacro("AddTaskFlow.C");
81 AliAnalysisTaskFlowEvent* taskFE = AddTaskFlow(type,METHODS,QA,WEIGHTS);
82
83 //____________________________________________//
73160af6 84 // Run the analysis
73160af6 85 if (!mgr->InitAnalysis()) return;
86 mgr->PrintStatus();
87
88 if (mode==mLocal || mode == mLocalPAR) {
89 mgr->StartAnalysis("local",chain);
90 }
91 else if (mode==mPROOF) {
73160af6 92 mgr->StartAnalysis("proof",dataDir,nRuns,offset);
93 }
94 else if (mode==mGRID) {
95 mgr->StartAnalysis("local",chain);
96 }
97
98 timer.Stop();
99 timer.Print();
93329510 100
73160af6 101}
102
73160af6 103
93329510 104void LoadLibraries(const anaModes mode) {
105
106 //--------------------------------------
107 // Load the needed libraries most of them already loaded by aliroot
108 //--------------------------------------
109 gSystem->Load("libTree.so");
110 gSystem->Load("libGeom.so");
111 gSystem->Load("libVMC.so");
112 gSystem->Load("libXMLIO.so");
113 gSystem->Load("libPhysics.so");
114
115 //----------------------------------------------------------
116 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
117 //----------------------------------------------------------
118 if (mode==mLocal) {
119 //--------------------------------------------------------
120 // If you want to use already compiled libraries
121 // in the aliroot distribution
122 //--------------------------------------------------------
123 gSystem->Load("libSTEERBase");
124 gSystem->Load("libESD");
125 gSystem->Load("libAOD");
126 gSystem->Load("libANALYSIS");
127 gSystem->Load("libANALYSISalice");
128 gSystem->Load("libCORRFW.so");
129 cerr<<"libCORRFW.so loaded..."<<endl;
130 gSystem->Load("libPWG2flowCommon.so");
131 cerr<<"libPWG2flowCommon.so loaded..."<<endl;
132 gSystem->Load("libPWG2flowTasks.so");
133 cerr<<"libPWG2flowTasks.so loaded..."<<endl;
134 }
135
136 else if (mode == mLocalPAR || mode == mGRID) {
137 //--------------------------------------------------------
138 //If you want to use root and par files from aliroot
139 //--------------------------------------------------------
140 SetupPar("STEERBase");
141 SetupPar("ESD");
142 SetupPar("AOD");
143 SetupPar("ANALYSIS");
144 SetupPar("ANALYSISalice");
145 SetupPar("PWG2AOD");
146 SetupPar("CORRFW");
147 SetupPar("PWG2flowCommon");
148 cerr<<"PWG2flowCommon.par loaded..."<<endl;
149 SetupPar("PWG2flowTasks");
150 cerr<<"PWG2flowTasks.par loaded..."<<endl;
151 }
152
153 //---------------------------------------------------------
154 // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
155 //---------------------------------------------------------
156 else if (mode==mPROOF) {
157 //
158
159 // set to debug root versus if needed
160 // TProof::Mgr("alicecaf")->SetROOTVersion("v5-21-01-alice_dbg");
161 // TProof::Mgr("alicecaf")->SetROOTVersion("v5-21-01-alice");
162
163 // Connect to proof
164 // Put appropriate username here
165 // TProof::Reset("proof://snelling@alicecaf.cern.ch");
166 printf("*** Connect to PROOF ***\n");
167 // TProof::Open("abilandz@alicecaf.cern.ch");
168 // TProof::Open("nkolk@alicecaf.cern.ch");
169 TProof::Open("snelling@localhost");
170
171 // Enable the STEERBase Package
172 // gProof->ClearPackage("STEERBase.par");
173 gProof->UploadPackage("STEERBase.par");
174 gProof->EnablePackage("STEERBase");
175 // Enable the ESD Package
176 // gProof->ClearPackage("ESD.par");
177 gProof->UploadPackage("ESD.par");
178 gProof->EnablePackage("ESD");
179 // Enable the AOD Package
180 // gProof->ClearPackage("AOD.par");
181 gProof->UploadPackage("AOD.par");
182 gProof->EnablePackage("AOD");
183 // Enable the Analysis Package
184 // gProof->ClearPackage("ANALYSIS.par");
185 gProof->UploadPackage("ANALYSIS.par");
186 gProof->EnablePackage("ANALYSIS");
187 // Enable the Analysis Package alice
188 // gProof->ClearPackage("ANALYSISalice.par");
189 gProof->UploadPackage("ANALYSISalice.par");
190 gProof->EnablePackage("ANALYSISalice");
191 // Load the PWG2 AOD
192 // gProof->ClearPackage("PWG2AOD.par");
193 gProof->UploadPackage("PWG2AOD.par");
194 gProof->EnablePackage("PWG2AOD");
195 // Enable the Correction Framework
196 // gProof->ClearPackage("CORRFW.par");
197 gProof->UploadPackage("CORRFW.par");
198 gProof->EnablePackage("CORRFW");
199 // Enable Flow Analysis
200 // gProof->ClearPackage("PWG2flowCommon");
201 gProof->UploadPackage("PWG2flowCommon.par");
202 gProof->EnablePackage("PWG2flowCommon");
203 // gProof->ClearPackage("PWG2flowTasks");
204 gProof->UploadPackage("PWG2flowTasks.par");
205 gProof->EnablePackage("PWG2flowTasks");
206 //
207 gProof->ShowEnabledPackages();
208 }
209
73160af6 210}
211
212void SetupPar(char* pararchivename) {
93329510 213 //Load par files, create analysis libraries
214 //For testing, if par file already decompressed and modified
215 //classes then do not decompress.
216
217 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
218 TString parpar(Form("%s.par", pararchivename)) ;
219 if ( gSystem->AccessPathName(parpar.Data()) ) {
220 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
221 TString processline(Form(".! make %s", parpar.Data())) ;
222 gROOT->ProcessLine(processline.Data()) ;
223 gSystem->ChangeDirectory(cdir) ;
224 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
225 gROOT->ProcessLine(processline.Data()) ;
226 }
227 if ( gSystem->AccessPathName(pararchivename) ) {
228 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
229 gROOT->ProcessLine(processline.Data());
230 }
231
232 TString ocwd = gSystem->WorkingDirectory();
233 gSystem->ChangeDirectory(pararchivename);
234
235 // check for BUILD.sh and execute
236 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
237 printf("*******************************\n");
238 printf("*** Building PAR archive ***\n");
239 cout<<pararchivename<<endl;
240 printf("*******************************\n");
241 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
242 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
243 return -1;
244 }
245 }
246 // check for SETUP.C and execute
247 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
248 printf("*******************************\n");
249 printf("*** Setup PAR archive ***\n");
250 cout<<pararchivename<<endl;
251 printf("*******************************\n");
252 gROOT->Macro("PROOF-INF/SETUP.C");
253 }
254
255 gSystem->ChangeDirectory(ocwd.Data());
256 printf("Current dir: %s\n", ocwd.Data());
73160af6 257}
258
259
260// Helper macros for creating chains
261// from: CreateESDChain.C,v 1.10 jgrosseo Exp
262
263TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
264{
93329510 265 // creates chain of files in a given directory or file containing a list.
266 // In case of directory the structure is expected as:
267 // <aDataDir>/<dir0>/AliESDs.root
268 // <aDataDir>/<dir1>/AliESDs.root
269 // ...
270
271 if (!aDataDir)
272 return 0;
273
274 Long_t id, size, flags, modtime;
275 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
276 {
277 printf("%s not found.\n", aDataDir);
278 return 0;
279 }
280
281 TChain* chain = new TChain("esdTree");
282 TChain* chaingAlice = 0;
283
284 if (flags & 2)
285 {
286 TString execDir(gSystem->pwd());
287 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
288 TList* dirList = baseDir->GetListOfFiles();
289 Int_t nDirs = dirList->GetEntries();
290 gSystem->cd(execDir);
291
292 Int_t count = 0;
293
294 for (Int_t iDir=0; iDir<nDirs; ++iDir)
73160af6 295 {
296 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
297 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
298 continue;
299
300 if (offset > 0)
301 {
302 --offset;
303 continue;
304 }
305
306 if (count++ == aRuns)
307 break;
308
309 TString presentDirName(aDataDir);
310 presentDirName += "/";
311 presentDirName += presentDir->GetName();
312 chain->Add(presentDirName + "/AliESDs.root/esdTree");
313 // cerr<<presentDirName<<endl;
314 }
93329510 315
316 }
317 else
318 {
319 // Open the input stream
320 ifstream in;
321 in.open(aDataDir);
322
323 Int_t count = 0;
324
325 // Read the input list of files and add them to the chain
326 TString esdfile;
327 while(in.good()) {
73160af6 328 in >> esdfile;
329 if (!esdfile.Contains("root")) continue; // protection
330
331 if (offset > 0)
332 {
333 --offset;
334 continue;
335 }
336
337 if (count++ == aRuns)
338 break;
339
93329510 340 // add esd file
73160af6 341 chain->Add(esdfile);
93329510 342 }
343
344 in.close();
345 }
346
347 return chain;
73160af6 348}
349
93329510 350
73160af6 351// Helper macros for creating chains
352// from: CreateESDChain.C,v 1.10 jgrosseo Exp
353
354TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
355{
93329510 356 // creates chain of files in a given directory or file containing a list.
357 // In case of directory the structure is expected as:
358 // <aDataDir>/<dir0>/AliAOD.root
359 // <aDataDir>/<dir1>/AliAOD.root
360 // ...
361
362 if (!aDataDir)
363 return 0;
364
365 Long_t id, size, flags, modtime;
366 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
367 {
368 printf("%s not found.\n", aDataDir);
369 return 0;
370 }
371
372 TChain* chain = new TChain("aodTree");
373 TChain* chaingAlice = 0;
374
375 if (flags & 2)
376 {
377 TString execDir(gSystem->pwd());
378 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
379 TList* dirList = baseDir->GetListOfFiles();
380 Int_t nDirs = dirList->GetEntries();
381 gSystem->cd(execDir);
382
383 Int_t count = 0;
384
385 for (Int_t iDir=0; iDir<nDirs; ++iDir)
73160af6 386 {
387 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
388 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
389 continue;
390
391 if (offset > 0)
392 {
393 --offset;
394 continue;
395 }
396
397 if (count++ == aRuns)
398 break;
399
400 TString presentDirName(aDataDir);
401 presentDirName += "/";
402 presentDirName += presentDir->GetName();
403 chain->Add(presentDirName + "/AliAOD.root/aodTree");
404 // cerr<<presentDirName<<endl;
405 }
93329510 406
407 }
408 else
409 {
410 // Open the input stream
411 ifstream in;
412 in.open(aDataDir);
413
414 Int_t count = 0;
415
416 // Read the input list of files and add them to the chain
417 TString aodfile;
418 while(in.good()) {
73160af6 419 in >> aodfile;
420 if (!aodfile.Contains("root")) continue; // protection
421
422 if (offset > 0)
423 {
424 --offset;
425 continue;
426 }
427
428 if (count++ == aRuns)
429 break;
430
93329510 431 // add aod file
73160af6 432 chain->Add(aodfile);
93329510 433 }
434
435 in.close();
436 }
437
438 return chain;
73160af6 439}
440