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