]>
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; |
18 | Bool_t MCEP = kTRUE; //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) |
ce4a88f5 | 36 | void runFlowTask(Int_t mode=mPROOF, Int_t nRuns = 1000000, |
37 | const Char_t* dataDir="/COMMON/COMMON/LHC09a14_0.9TeV_0.5T", Int_t offset = 0) | |
38 | //const Char_t* dataDir="/PWG2/akisiel/Therminator_midcentral_ESD", 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 | 104 | void 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 | |
2aa4ebcd | 160 | //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a_dbg"); |
161 | TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a"); | |
162 | ||
93329510 | 163 | |
164 | // Connect to proof | |
165 | // Put appropriate username here | |
166 | // TProof::Reset("proof://snelling@alicecaf.cern.ch"); | |
167 | printf("*** Connect to PROOF ***\n"); | |
168 | // TProof::Open("abilandz@alicecaf.cern.ch"); | |
169 | // TProof::Open("nkolk@alicecaf.cern.ch"); | |
170 | TProof::Open("snelling@localhost"); | |
171 | ||
172 | // Enable the STEERBase Package | |
173 | // gProof->ClearPackage("STEERBase.par"); | |
174 | gProof->UploadPackage("STEERBase.par"); | |
175 | gProof->EnablePackage("STEERBase"); | |
176 | // Enable the ESD Package | |
177 | // gProof->ClearPackage("ESD.par"); | |
178 | gProof->UploadPackage("ESD.par"); | |
179 | gProof->EnablePackage("ESD"); | |
180 | // Enable the AOD Package | |
181 | // gProof->ClearPackage("AOD.par"); | |
182 | gProof->UploadPackage("AOD.par"); | |
183 | gProof->EnablePackage("AOD"); | |
184 | // Enable the Analysis Package | |
185 | // gProof->ClearPackage("ANALYSIS.par"); | |
186 | gProof->UploadPackage("ANALYSIS.par"); | |
187 | gProof->EnablePackage("ANALYSIS"); | |
188 | // Enable the Analysis Package alice | |
189 | // gProof->ClearPackage("ANALYSISalice.par"); | |
190 | gProof->UploadPackage("ANALYSISalice.par"); | |
191 | gProof->EnablePackage("ANALYSISalice"); | |
192 | // Load the PWG2 AOD | |
193 | // gProof->ClearPackage("PWG2AOD.par"); | |
194 | gProof->UploadPackage("PWG2AOD.par"); | |
195 | gProof->EnablePackage("PWG2AOD"); | |
196 | // Enable the Correction Framework | |
197 | // gProof->ClearPackage("CORRFW.par"); | |
198 | gProof->UploadPackage("CORRFW.par"); | |
199 | gProof->EnablePackage("CORRFW"); | |
200 | // Enable Flow Analysis | |
2aa4ebcd | 201 | gProof->ClearPackage("PWG2flowCommon"); |
93329510 | 202 | gProof->UploadPackage("PWG2flowCommon.par"); |
203 | gProof->EnablePackage("PWG2flowCommon"); | |
2aa4ebcd | 204 | gProof->ClearPackage("PWG2flowTasks"); |
93329510 | 205 | gProof->UploadPackage("PWG2flowTasks.par"); |
206 | gProof->EnablePackage("PWG2flowTasks"); | |
207 | // | |
208 | gProof->ShowEnabledPackages(); | |
209 | } | |
210 | ||
73160af6 | 211 | } |
212 | ||
213 | void SetupPar(char* pararchivename) { | |
93329510 | 214 | //Load par files, create analysis libraries |
215 | //For testing, if par file already decompressed and modified | |
216 | //classes then do not decompress. | |
217 | ||
218 | TString cdir(Form("%s", gSystem->WorkingDirectory() )) ; | |
219 | TString parpar(Form("%s.par", pararchivename)) ; | |
220 | if ( gSystem->AccessPathName(parpar.Data()) ) { | |
221 | gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ; | |
222 | TString processline(Form(".! make %s", parpar.Data())) ; | |
223 | gROOT->ProcessLine(processline.Data()) ; | |
224 | gSystem->ChangeDirectory(cdir) ; | |
225 | processline = Form(".! mv /tmp/%s .", parpar.Data()) ; | |
226 | gROOT->ProcessLine(processline.Data()) ; | |
227 | } | |
228 | if ( gSystem->AccessPathName(pararchivename) ) { | |
229 | TString processline = Form(".! tar xvzf %s",parpar.Data()) ; | |
230 | gROOT->ProcessLine(processline.Data()); | |
231 | } | |
232 | ||
233 | TString ocwd = gSystem->WorkingDirectory(); | |
234 | gSystem->ChangeDirectory(pararchivename); | |
235 | ||
236 | // check for BUILD.sh and execute | |
237 | if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) { | |
238 | printf("*******************************\n"); | |
239 | printf("*** Building PAR archive ***\n"); | |
240 | cout<<pararchivename<<endl; | |
241 | printf("*******************************\n"); | |
242 | if (gSystem->Exec("PROOF-INF/BUILD.sh")) { | |
243 | Error("runProcess","Cannot Build the PAR Archive! - Abort!"); | |
244 | return -1; | |
245 | } | |
246 | } | |
247 | // check for SETUP.C and execute | |
248 | if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) { | |
249 | printf("*******************************\n"); | |
250 | printf("*** Setup PAR archive ***\n"); | |
251 | cout<<pararchivename<<endl; | |
252 | printf("*******************************\n"); | |
253 | gROOT->Macro("PROOF-INF/SETUP.C"); | |
254 | } | |
255 | ||
256 | gSystem->ChangeDirectory(ocwd.Data()); | |
257 | printf("Current dir: %s\n", ocwd.Data()); | |
73160af6 | 258 | } |
259 | ||
260 | ||
261 | // Helper macros for creating chains | |
262 | // from: CreateESDChain.C,v 1.10 jgrosseo Exp | |
263 | ||
264 | TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset) | |
265 | { | |
93329510 | 266 | // creates chain of files in a given directory or file containing a list. |
267 | // In case of directory the structure is expected as: | |
268 | // <aDataDir>/<dir0>/AliESDs.root | |
269 | // <aDataDir>/<dir1>/AliESDs.root | |
270 | // ... | |
271 | ||
272 | if (!aDataDir) | |
273 | return 0; | |
274 | ||
275 | Long_t id, size, flags, modtime; | |
276 | if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime)) | |
277 | { | |
278 | printf("%s not found.\n", aDataDir); | |
279 | return 0; | |
280 | } | |
281 | ||
282 | TChain* chain = new TChain("esdTree"); | |
283 | TChain* chaingAlice = 0; | |
284 | ||
285 | if (flags & 2) | |
286 | { | |
287 | TString execDir(gSystem->pwd()); | |
288 | TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir); | |
289 | TList* dirList = baseDir->GetListOfFiles(); | |
290 | Int_t nDirs = dirList->GetEntries(); | |
291 | gSystem->cd(execDir); | |
292 | ||
293 | Int_t count = 0; | |
294 | ||
295 | for (Int_t iDir=0; iDir<nDirs; ++iDir) | |
73160af6 | 296 | { |
297 | TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir); | |
298 | if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0) | |
299 | continue; | |
300 | ||
301 | if (offset > 0) | |
302 | { | |
303 | --offset; | |
304 | continue; | |
305 | } | |
306 | ||
307 | if (count++ == aRuns) | |
308 | break; | |
309 | ||
310 | TString presentDirName(aDataDir); | |
311 | presentDirName += "/"; | |
312 | presentDirName += presentDir->GetName(); | |
313 | chain->Add(presentDirName + "/AliESDs.root/esdTree"); | |
314 | // cerr<<presentDirName<<endl; | |
315 | } | |
93329510 | 316 | |
317 | } | |
318 | else | |
319 | { | |
320 | // Open the input stream | |
321 | ifstream in; | |
322 | in.open(aDataDir); | |
323 | ||
324 | Int_t count = 0; | |
325 | ||
326 | // Read the input list of files and add them to the chain | |
327 | TString esdfile; | |
328 | while(in.good()) { | |
73160af6 | 329 | in >> esdfile; |
330 | if (!esdfile.Contains("root")) continue; // protection | |
331 | ||
332 | if (offset > 0) | |
333 | { | |
334 | --offset; | |
335 | continue; | |
336 | } | |
337 | ||
338 | if (count++ == aRuns) | |
339 | break; | |
340 | ||
93329510 | 341 | // add esd file |
73160af6 | 342 | chain->Add(esdfile); |
93329510 | 343 | } |
344 | ||
345 | in.close(); | |
346 | } | |
347 | ||
348 | return chain; | |
73160af6 | 349 | } |
350 | ||
93329510 | 351 | |
73160af6 | 352 | // Helper macros for creating chains |
353 | // from: CreateESDChain.C,v 1.10 jgrosseo Exp | |
354 | ||
355 | TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset) | |
356 | { | |
93329510 | 357 | // creates chain of files in a given directory or file containing a list. |
358 | // In case of directory the structure is expected as: | |
359 | // <aDataDir>/<dir0>/AliAOD.root | |
360 | // <aDataDir>/<dir1>/AliAOD.root | |
361 | // ... | |
362 | ||
363 | if (!aDataDir) | |
364 | return 0; | |
365 | ||
366 | Long_t id, size, flags, modtime; | |
367 | if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime)) | |
368 | { | |
369 | printf("%s not found.\n", aDataDir); | |
370 | return 0; | |
371 | } | |
372 | ||
373 | TChain* chain = new TChain("aodTree"); | |
374 | TChain* chaingAlice = 0; | |
375 | ||
376 | if (flags & 2) | |
377 | { | |
378 | TString execDir(gSystem->pwd()); | |
379 | TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir); | |
380 | TList* dirList = baseDir->GetListOfFiles(); | |
381 | Int_t nDirs = dirList->GetEntries(); | |
382 | gSystem->cd(execDir); | |
383 | ||
384 | Int_t count = 0; | |
385 | ||
386 | for (Int_t iDir=0; iDir<nDirs; ++iDir) | |
73160af6 | 387 | { |
388 | TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir); | |
389 | if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0) | |
390 | continue; | |
391 | ||
392 | if (offset > 0) | |
393 | { | |
394 | --offset; | |
395 | continue; | |
396 | } | |
397 | ||
398 | if (count++ == aRuns) | |
399 | break; | |
400 | ||
401 | TString presentDirName(aDataDir); | |
402 | presentDirName += "/"; | |
403 | presentDirName += presentDir->GetName(); | |
404 | chain->Add(presentDirName + "/AliAOD.root/aodTree"); | |
405 | // cerr<<presentDirName<<endl; | |
406 | } | |
93329510 | 407 | |
408 | } | |
409 | else | |
410 | { | |
411 | // Open the input stream | |
412 | ifstream in; | |
413 | in.open(aDataDir); | |
414 | ||
415 | Int_t count = 0; | |
416 | ||
417 | // Read the input list of files and add them to the chain | |
418 | TString aodfile; | |
419 | while(in.good()) { | |
73160af6 | 420 | in >> aodfile; |
421 | if (!aodfile.Contains("root")) continue; // protection | |
422 | ||
423 | if (offset > 0) | |
424 | { | |
425 | --offset; | |
426 | continue; | |
427 | } | |
428 | ||
429 | if (count++ == aRuns) | |
430 | break; | |
431 | ||
93329510 | 432 | // add aod file |
73160af6 | 433 | chain->Add(aodfile); |
93329510 | 434 | } |
435 | ||
436 | in.close(); | |
437 | } | |
438 | ||
439 | return chain; | |
73160af6 | 440 | } |
441 |