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