]>
Commit | Line | Data |
---|---|---|
5c09ff70 | 1 | enum anaModes {mLocal,mLocalPAR,mPROOF,mGrid,mGridPAR}; |
daf66719 | 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 | |
5c09ff70 | 5 | //mGrid: Analyze files on Grid via AliEn plug-in and using precompiled FLOW libraries |
6 | // (Remark: When using this mode set also Bool_t bUseParFiles = kFALSE; in CreateAlienHandler.C) | |
7 | //mGridPAR: Analyze files on Grid via AliEn plug-in and using par files for FLOW package | |
8 | // (Remark: when using this mode set also Bool_t bUseParFiles = kTRUE; in CreateAlienHandler.C) | |
9 | ||
10 | // CENTRALITY DEFINITION | |
27b5ccf2 | 11 | const Int_t numberOfCentralityBins = 1; |
12 | Int_t centralityArray[numberOfCentralityBins+1] = {0,10000}; // in terms of reference multiplicity | |
5c09ff70 | 13 | TString commonOutputFileName = "outputCentrality"; // e.g.: result for centrality bin 0 will be in the file "outputCentrality0.root", etc |
daf66719 | 14 | |
d178bd1f | 15 | void runFlowTaskCentralityTrain(Int_t mode=mLocal, Int_t nRuns = 10, |
16 | Bool_t DATA = kFALSE, const Char_t* dataDir="/Users/snelling/alice_data/Therminator_midcentral", Int_t offset = 0) | |
daf66719 | 17 | |
59dab33a | 18 | //void runFlowTaskCentralityTrain(Int_t mode = mPROOF, Int_t nRuns = 50000000, |
59dab33a | 19 | //Bool_t DATA = kFALSE, const Char_t* dataDir="/PWG4/morsch/HIJING_CENT_4EV", Int_t offset=0) //hijing Pb Pb pilot |
daf66719 | 20 | |
d178bd1f | 21 | //void runFlowTaskCentralityTrain(Int_t mode = mGrid, Bool_t DATA = kFALSE) |
daf66719 | 22 | { |
5c09ff70 | 23 | // Time: |
daf66719 | 24 | TStopwatch timer; |
25 | timer.Start(); | |
5c09ff70 | 26 | // Cross-check user settings before starting: |
d178bd1f | 27 | // CrossCheckUserSettings(DATA); |
5c09ff70 | 28 | // Load needed libraries: |
daf66719 | 29 | LoadLibraries(mode); |
5c09ff70 | 30 | // Create and configure the AliEn plug-in: |
31 | if(mode == mGrid || mode == mGridPAR) | |
d178bd1f | 32 | { |
33 | gROOT->LoadMacro("CreateAlienHandler.C"); | |
34 | AliAnalysisGrid *alienHandler = CreateAlienHandler(); | |
35 | if(!alienHandler) return; | |
36 | } | |
5c09ff70 | 37 | // Chains: |
d178bd1f | 38 | if(mode == mLocal || mode == mLocalPAR) { |
39 | TChain* chain = CreateESDChain(dataDir, nRuns, offset); | |
40 | //TChain* chain = CreateAODChain(dataDir, nRuns, offset); | |
59dab33a | 41 | } |
42 | ||
5c09ff70 | 43 | // Create analysis manager: |
44 | AliAnalysisManager *mgr = new AliAnalysisManager("FlowAnalysisManager"); | |
45 | // Connect plug-in to the analysis manager: | |
46 | if(mode == mGrid || mode == mGridPAR) | |
d178bd1f | 47 | { |
48 | mgr->SetGridHandler(alienHandler); | |
49 | } | |
50 | ||
5c09ff70 | 51 | // Event handlers: |
d178bd1f | 52 | AliVEventHandler* esdH = new AliESDInputHandler; |
53 | mgr->SetInputEventHandler(esdH); | |
54 | AliMCEventHandler *mc = new AliMCEventHandler(); | |
55 | mgr->SetMCtruthEventHandler(mc); | |
56 | ||
5c09ff70 | 57 | // Load the analysis task: |
59dab33a | 58 | gROOT->LoadMacro("AddTaskFlowCentrality.C"); |
d178bd1f | 59 | |
5c09ff70 | 60 | // Setup analysis per centrality bin: |
daf66719 | 61 | for (Int_t i=0; i<numberOfCentralityBins; i++) |
62 | { | |
63 | Int_t lowCentralityBinEdge = centralityArray[i]; | |
64 | Int_t highCentralityBinEdge = centralityArray[i+1]; | |
5c09ff70 | 65 | TString filename(commonOutputFileName.Data()); |
daf66719 | 66 | filename += i; |
67 | //TDirectory* dir = new TDirectory(filename.Data(),""); | |
68 | filename += ".root"; | |
5c09ff70 | 69 | Printf("\nWagon for centrality bin %i:",i); |
d178bd1f | 70 | AddTaskFlowCentrality( lowCentralityBinEdge, |
daf66719 | 71 | highCentralityBinEdge, |
72 | filename ); | |
5c09ff70 | 73 | |
74 | } // end of for (Int_t i=0; i<numberOfCentralityBins; i++) | |
d178bd1f | 75 | |
5c09ff70 | 76 | // Task to check the offline trigger: |
d178bd1f | 77 | if(mode == mLocal || mode == mGrid || mode == mGridPAR) { |
78 | gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); | |
79 | } else if(mode == mPROOF || mode == mLocalPAR) { | |
80 | gROOT->LoadMacro("AddTaskPhysicsSelection.C"); | |
81 | } | |
82 | ||
daf66719 | 83 | AliPhysicsSelectionTask* physicsSelTask = AddTaskPhysicsSelection(); |
5c09ff70 | 84 | if(!DATA){physicsSelTask->GetPhysicsSelection()->SetAnalyzeMC();} |
85 | // Enable debug printouts: | |
daf66719 | 86 | mgr->SetDebugLevel(2); |
5c09ff70 | 87 | // Run the analysis: |
88 | if(!mgr->InitAnalysis()) return; | |
daf66719 | 89 | mgr->PrintStatus(); |
d178bd1f | 90 | if(mode == mLocal || mode == mLocalPAR) { |
91 | mgr->StartAnalysis("local",chain); | |
92 | } else if(mode == mPROOF) { | |
93 | mgr->StartAnalysis("proof",dataDir,nRuns,offset); | |
94 | } else if(mode == mGrid || mode == mGridPAR) { | |
95 | mgr->StartAnalysis("grid"); | |
96 | } | |
97 | ||
5c09ff70 | 98 | // Print real and CPU time used for analysis: |
daf66719 | 99 | timer.Stop(); |
5c09ff70 | 100 | timer.Print(); |
daf66719 | 101 | |
5c09ff70 | 102 | } // end of void runFlowTaskCentralityTrain(...) |
103 | ||
104 | //=============================================================================================== | |
d178bd1f | 105 | /* |
daf66719 | 106 | void CrossCheckUserSettings(Bool_t bData) |
107 | { | |
d178bd1f | 108 | // Check in this method if the user settings make sense. |
5c09ff70 | 109 | if(LYZ1SUM && LYZ2SUM) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); } |
110 | if(LYZ1PROD && LYZ2PROD) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); } | |
111 | if(LYZ2SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); } | |
112 | if(LYZ1SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); } | |
daf66719 | 113 | } // end of void CrossCheckUserSettings() |
d178bd1f | 114 | */ |
5c09ff70 | 115 | //=============================================================================================== |
116 | ||
117 | void LoadLibraries(const anaModes mode) | |
118 | { | |
daf66719 | 119 | //-------------------------------------- |
120 | // Load the needed libraries most of them already loaded by aliroot | |
121 | //-------------------------------------- | |
5c09ff70 | 122 | //gSystem->Load("libTree"); |
daf66719 | 123 | gSystem->Load("libGeom"); |
124 | gSystem->Load("libVMC"); | |
125 | gSystem->Load("libXMLIO"); | |
126 | gSystem->Load("libPhysics"); | |
127 | ||
128 | //---------------------------------------------------------- | |
129 | // >>>>>>>>>>> Local mode <<<<<<<<<<<<<< | |
130 | //---------------------------------------------------------- | |
5c09ff70 | 131 | if (mode==mLocal || mode==mGrid || mode == mGridPAR) { |
daf66719 | 132 | //-------------------------------------------------------- |
133 | // If you want to use already compiled libraries | |
134 | // in the aliroot distribution | |
135 | //-------------------------------------------------------- | |
136 | gSystem->Load("libSTEERBase"); | |
137 | gSystem->Load("libESD"); | |
138 | gSystem->Load("libAOD"); | |
139 | gSystem->Load("libANALYSIS"); | |
140 | gSystem->Load("libANALYSISalice"); | |
141 | gSystem->Load("libCORRFW"); | |
142 | gSystem->Load("libPWG2forward"); | |
5c09ff70 | 143 | if(mode==mLocal || mode==mGrid) |
144 | { | |
145 | gSystem->Load("libPWG2flowCommon"); | |
146 | cerr<<"libPWG2flowCommon loaded..."<<endl; | |
147 | gSystem->Load("libPWG2flowTasks"); | |
148 | cerr<<"libPWG2flowTasks loaded..."<<endl; | |
daf66719 | 149 | } |
5c09ff70 | 150 | if(mode==mGridPAR) |
151 | { | |
152 | SetupPar("PWG2flowCommon"); | |
153 | cerr<<"PWG2flowCommon.par loaded..."<<endl; | |
154 | SetupPar("PWG2flowTasks"); | |
155 | cerr<<"PWG2flowTasks.par loaded..."<<endl; | |
daf66719 | 156 | } |
157 | } | |
158 | ||
159 | else if (mode == mLocalPAR) { | |
160 | //-------------------------------------------------------- | |
161 | //If you want to use root and par files from aliroot | |
162 | //-------------------------------------------------------- | |
163 | SetupPar("STEERBase"); | |
164 | SetupPar("ESD"); | |
165 | SetupPar("AOD"); | |
166 | SetupPar("ANALYSIS"); | |
167 | SetupPar("ANALYSISalice"); | |
168 | SetupPar("CORRFW"); | |
169 | SetupPar("PWG2flowCommon"); | |
170 | cerr<<"PWG2flowCommon.par loaded..."<<endl; | |
171 | SetupPar("PWG2flowTasks"); | |
172 | cerr<<"PWG2flowTasks.par loaded..."<<endl; | |
173 | } | |
174 | ||
175 | //--------------------------------------------------------- | |
176 | // <<<<<<<<<< PROOF mode >>>>>>>>>>>> | |
177 | //--------------------------------------------------------- | |
178 | else if (mode==mPROOF) { | |
179 | // | |
180 | //gEnv->SetValue("XSec.GSI.DelegProxy","2"); | |
181 | // set to debug root versus if needed | |
182 | //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a_dbg"); | |
183 | //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a"); | |
184 | //TProof::Reset("proof://snelling@alicecaf.cern.ch"); | |
185 | // Connect to proof | |
186 | printf("*** Connect to PROOF ***\n"); | |
187 | gEnv->SetValue("XSec.GSI.DelegProxy","2"); | |
188 | // Put appropriate username here | |
189 | //TProof::Open("abilandz@alicecaf.cern.ch"); | |
190 | //TProof::Open("nkolk@alicecaf.cern.ch"); | |
191 | //TProof::Open("snelling@localhost"); | |
192 | TProof::Open("alice-caf.cern.ch"); | |
193 | //TProof::Open("skaf.saske.sk"); | |
194 | //TProof::Open("prf000-iep-grid.saske.sk"); | |
195 | //Info("runSKAF.C","Loading libs on proof (may take while, around 1 min) ..."); | |
196 | // list the data available | |
197 | //gProof->ShowDataSets("/*/*"); | |
198 | //gProof->ShowDataSets("/alice/sim/"); //for MC Data | |
199 | //gProof->ShowDataSets("/alice/data/"); //for REAL Data | |
200 | ||
201 | // Clear the Packages | |
202 | ||
203 | gProof->ClearPackage("STEERBase.par"); | |
204 | gProof->ClearPackage("ESD.par"); | |
205 | gProof->ClearPackage("AOD.par"); | |
206 | gProof->ClearPackage("ANALYSIS.par"); | |
207 | gProof->ClearPackage("ANALYSISalice.par"); | |
208 | gProof->ClearPackage("CORRFW.par"); | |
209 | ||
210 | gProof->ClearPackage("PWG2flowCommon"); | |
211 | gProof->ClearPackage("PWG2flowTasks"); | |
212 | ||
213 | // Upload the Packages | |
214 | gProof->UploadPackage("STEERBase.par"); | |
215 | gProof->UploadPackage("ESD.par"); | |
216 | gProof->UploadPackage("AOD.par"); | |
217 | ||
218 | gProof->UploadPackage("ANALYSIS.par"); | |
219 | gProof->UploadPackage("ANALYSISalice.par"); | |
220 | gProof->UploadPackage("CORRFW.par"); | |
221 | gProof->UploadPackage("PWG2flowCommon.par"); | |
222 | gProof->UploadPackage("PWG2flowTasks.par"); | |
223 | ||
224 | // Enable the Packages | |
225 | // The global package | |
226 | //gProof->EnablePackage("aliroot_v4-19-05-AN",kTRUE); | |
227 | // Or separate | |
228 | ||
229 | gProof->EnablePackage("STEERBase"); | |
230 | gProof->EnablePackage("ESD"); | |
231 | gProof->EnablePackage("AOD"); | |
232 | ||
233 | // Always needed | |
234 | gProof->EnablePackage("ANALYSIS"); | |
235 | gProof->EnablePackage("ANALYSISalice"); | |
236 | gProof->EnablePackage("CORRFW"); | |
237 | gProof->EnablePackage("PWG2flowCommon"); | |
238 | gProof->EnablePackage("PWG2flowTasks"); | |
239 | ||
240 | // Show enables Packages | |
241 | gProof->ShowEnabledPackages(); | |
242 | } | |
243 | ||
5c09ff70 | 244 | } // end of void LoadLibraries(const anaModes mode) |
245 | ||
246 | //=============================================================================================== | |
daf66719 | 247 | |
5c09ff70 | 248 | void SetupPar(char* pararchivename) |
249 | { | |
daf66719 | 250 | //Load par files, create analysis libraries |
251 | //For testing, if par file already decompressed and modified | |
252 | //classes then do not decompress. | |
253 | ||
254 | TString cdir(Form("%s", gSystem->WorkingDirectory() )) ; | |
255 | TString parpar(Form("%s.par", pararchivename)) ; | |
256 | if ( gSystem->AccessPathName(parpar.Data()) ) { | |
257 | gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ; | |
258 | TString processline(Form(".! make %s", parpar.Data())) ; | |
259 | gROOT->ProcessLine(processline.Data()) ; | |
260 | gSystem->ChangeDirectory(cdir) ; | |
261 | processline = Form(".! mv /tmp/%s .", parpar.Data()) ; | |
262 | gROOT->ProcessLine(processline.Data()) ; | |
263 | } | |
264 | if ( gSystem->AccessPathName(pararchivename) ) { | |
265 | TString processline = Form(".! tar xvzf %s",parpar.Data()) ; | |
266 | gROOT->ProcessLine(processline.Data()); | |
267 | } | |
268 | ||
269 | TString ocwd = gSystem->WorkingDirectory(); | |
270 | gSystem->ChangeDirectory(pararchivename); | |
271 | ||
272 | // check for BUILD.sh and execute | |
273 | if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) { | |
274 | printf("*******************************\n"); | |
275 | printf("*** Building PAR archive ***\n"); | |
276 | cout<<pararchivename<<endl; | |
277 | printf("*******************************\n"); | |
278 | if (gSystem->Exec("PROOF-INF/BUILD.sh")) { | |
279 | Error("runProcess","Cannot Build the PAR Archive! - Abort!"); | |
280 | return -1; | |
281 | } | |
282 | } | |
283 | // check for SETUP.C and execute | |
284 | if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) { | |
285 | printf("*******************************\n"); | |
286 | printf("*** Setup PAR archive ***\n"); | |
287 | cout<<pararchivename<<endl; | |
288 | printf("*******************************\n"); | |
289 | gROOT->Macro("PROOF-INF/SETUP.C"); | |
290 | } | |
291 | ||
292 | gSystem->ChangeDirectory(ocwd.Data()); | |
293 | printf("Current dir: %s\n", ocwd.Data()); | |
daf66719 | 294 | |
5c09ff70 | 295 | } // end of void SetupPar(char* pararchivename) |
296 | ||
297 | //=============================================================================================== | |
daf66719 | 298 | |
299 | // Helper macros for creating chains | |
300 | // from: CreateESDChain.C,v 1.10 jgrosseo Exp | |
301 | ||
302 | TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset) | |
303 | { | |
304 | // creates chain of files in a given directory or file containing a list. | |
305 | // In case of directory the structure is expected as: | |
306 | // <aDataDir>/<dir0>/AliESDs.root | |
307 | // <aDataDir>/<dir1>/AliESDs.root | |
308 | // ... | |
309 | ||
310 | if (!aDataDir) | |
311 | return 0; | |
312 | ||
313 | Long_t id, size, flags, modtime; | |
314 | if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime)) | |
315 | { | |
316 | printf("%s not found.\n", aDataDir); | |
317 | return 0; | |
318 | } | |
319 | ||
320 | TChain* chain = new TChain("esdTree"); | |
321 | TChain* chaingAlice = 0; | |
322 | ||
323 | if (flags & 2) | |
324 | { | |
325 | TString execDir(gSystem->pwd()); | |
326 | TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir); | |
327 | TList* dirList = baseDir->GetListOfFiles(); | |
328 | Int_t nDirs = dirList->GetEntries(); | |
329 | gSystem->cd(execDir); | |
330 | ||
331 | Int_t count = 0; | |
332 | ||
333 | for (Int_t iDir=0; iDir<nDirs; ++iDir) | |
334 | { | |
335 | TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir); | |
336 | if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0) | |
337 | continue; | |
338 | ||
339 | if (offset > 0) | |
340 | { | |
341 | --offset; | |
342 | continue; | |
343 | } | |
344 | ||
345 | if (count++ == aRuns) | |
346 | break; | |
347 | ||
348 | TString presentDirName(aDataDir); | |
349 | presentDirName += "/"; | |
350 | presentDirName += presentDir->GetName(); | |
351 | chain->Add(presentDirName + "/AliESDs.root/esdTree"); | |
352 | // cerr<<presentDirName<<endl; | |
353 | } | |
354 | ||
355 | } | |
356 | else | |
357 | { | |
358 | // Open the input stream | |
359 | ifstream in; | |
360 | in.open(aDataDir); | |
361 | ||
362 | Int_t count = 0; | |
363 | ||
364 | // Read the input list of files and add them to the chain | |
365 | TString esdfile; | |
366 | while(in.good()) { | |
367 | in >> esdfile; | |
368 | if (!esdfile.Contains("root")) continue; // protection | |
369 | ||
370 | if (offset > 0) | |
371 | { | |
372 | --offset; | |
373 | continue; | |
374 | } | |
375 | ||
376 | if (count++ == aRuns) | |
377 | break; | |
378 | ||
379 | // add esd file | |
380 | chain->Add(esdfile); | |
381 | } | |
382 | ||
383 | in.close(); | |
384 | } | |
385 | ||
386 | return chain; | |
daf66719 | 387 | |
5c09ff70 | 388 | } // end of TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset) |
daf66719 | 389 | |
5c09ff70 | 390 | //=============================================================================================== |
daf66719 | 391 | |
392 | TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset) | |
393 | { | |
394 | // creates chain of files in a given directory or file containing a list. | |
395 | // In case of directory the structure is expected as: | |
396 | // <aDataDir>/<dir0>/AliAOD.root | |
397 | // <aDataDir>/<dir1>/AliAOD.root | |
398 | // ... | |
399 | ||
400 | if (!aDataDir) | |
401 | return 0; | |
402 | ||
403 | Long_t id, size, flags, modtime; | |
404 | if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime)) | |
405 | { | |
406 | printf("%s not found.\n", aDataDir); | |
407 | return 0; | |
408 | } | |
409 | ||
410 | TChain* chain = new TChain("aodTree"); | |
411 | TChain* chaingAlice = 0; | |
412 | ||
413 | if (flags & 2) | |
414 | { | |
415 | TString execDir(gSystem->pwd()); | |
416 | TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir); | |
417 | TList* dirList = baseDir->GetListOfFiles(); | |
418 | Int_t nDirs = dirList->GetEntries(); | |
419 | gSystem->cd(execDir); | |
420 | ||
421 | Int_t count = 0; | |
422 | ||
423 | for (Int_t iDir=0; iDir<nDirs; ++iDir) | |
424 | { | |
425 | TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir); | |
426 | if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0) | |
427 | continue; | |
428 | ||
429 | if (offset > 0) | |
430 | { | |
431 | --offset; | |
432 | continue; | |
433 | } | |
434 | ||
435 | if (count++ == aRuns) | |
436 | break; | |
437 | ||
438 | TString presentDirName(aDataDir); | |
439 | presentDirName += "/"; | |
440 | presentDirName += presentDir->GetName(); | |
441 | chain->Add(presentDirName + "/AliAOD.root/aodTree"); | |
442 | // cerr<<presentDirName<<endl; | |
443 | } | |
444 | ||
445 | } | |
446 | else | |
447 | { | |
448 | // Open the input stream | |
449 | ifstream in; | |
450 | in.open(aDataDir); | |
451 | ||
452 | Int_t count = 0; | |
453 | ||
454 | // Read the input list of files and add them to the chain | |
455 | TString aodfile; | |
456 | while(in.good()) { | |
457 | in >> aodfile; | |
458 | if (!aodfile.Contains("root")) continue; // protection | |
459 | ||
460 | if (offset > 0) | |
461 | { | |
462 | --offset; | |
463 | continue; | |
464 | } | |
465 | ||
466 | if (count++ == aRuns) | |
467 | break; | |
468 | ||
469 | // add aod file | |
470 | chain->Add(aodfile); | |
471 | } | |
472 | ||
473 | in.close(); | |
474 | } | |
475 | ||
476 | return chain; | |
5c09ff70 | 477 | |
478 | } // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset) | |
daf66719 | 479 |