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