]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - PWG2/FLOW/macros/runFlowTask.C
hooks for PMD flow analysis
[u/mrichter/AliRoot.git] / PWG2 / FLOW / macros / runFlowTask.C
... / ...
CommitLineData
1enum 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// (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
11Bool_t kUseCentrality = kFALSE;
12Int_t binfirst = -1; //if kUseCentrality then change accordingly
13Int_t binlast = -1; //if kUseCentrality then change accordingly
14const Int_t numberOfCentralityBins = 9;
15Float_t centralityArray[numberOfCentralityBins+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.}; // in centrality percentile
16//Int_t centralityArray[numberOfCentralityBins+1] = {41,80,146,245,384,576,835,1203,1471,10000}; // in terms of TPC only reference multiplicity
17
18TString commonOutputFileName = "outputCentrality"; // e.g.: result for centrality bin 0 will be in the file "outputCentrality0.root", etc
19
20
21//void runFlowTask(Int_t mode=mLocal, Int_t nRuns = 10,
22//Bool_t DATA = kFALSE, const Char_t* dataDir="/Users/snelling/alice_data/Therminator_midcentral", Int_t offset = 0)
23
24//void runFlowTask(Int_t mode = mGridPAR, Int_t nRuns = 50000000,
25// Bool_t DATA = kTRUE, const Char_t* dataDir="/alice/data/LHC10h_000137161_p1_plusplusplus", Int_t offset=0)
26void runFlowTask(Int_t mode = mLocal, Int_t nRuns = 50000000,
27 Bool_t DATA = kTRUE, const Char_t* dataDir="./data/", Int_t offset=0)
28//void runFlowTask(Int_t mode = mGridPAR, Bool_t DATA = kTRUE)
29{
30 // Time:
31 TStopwatch timer;
32 timer.Start();
33 // Cross-check user settings before starting:
34 // CrossCheckUserSettings(DATA);
35 // Load needed libraries:
36 LoadLibraries(mode);
37 // Create and configure the AliEn plug-in:
38 if(mode == mGrid || mode == mGridPAR)
39 {
40 gROOT->LoadMacro("CreateAlienHandler.C");
41 AliAnalysisGrid *alienHandler = CreateAlienHandler();
42 if(!alienHandler) return;
43 }
44 // Chains:
45 if(mode == mLocal || mode == mLocalPAR) {
46 TChain *chain = new TChain("esdTree");
47 chain->Add("/home/pchrist/ALICE/HeavyIons/Data/137161/Set1/AliESDs.root");
48 //TChain* chain = CreateESDChain(dataDir, nRuns, offset);
49 //TChain* chain = CreateAODChain(dataDir, nRuns, offset);
50 }
51
52 // Create analysis manager:
53 AliAnalysisManager *mgr = new AliAnalysisManager("FlowAnalysisManager");
54 // Connect plug-in to the analysis manager:
55 if(mode == mGrid || mode == mGridPAR)
56 {
57 mgr->SetGridHandler(alienHandler);
58 }
59
60 // Event handlers:
61 AliVEventHandler* esdH = new AliESDInputHandler;
62 mgr->SetInputEventHandler(esdH);
63 if (!DATA) {
64 AliMCEventHandler *mc = new AliMCEventHandler();
65 mgr->SetMCtruthEventHandler(mc);
66 }
67
68 // Task to check the offline trigger:
69 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
70 AddTaskPhysicsSelection(!DATA);
71
72 //Add the centrality determination task
73 if(kUseCentrality) {
74 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
75 AddTaskCentrality();
76 }
77
78 //Add the TOF tender
79 //gROOT->LoadMacro("$ALICE_ROOT/PWG2/FLOW/macros/AddTaskTenderFlow.C");
80 //AddTaskTenderFlow();
81
82 // Setup analysis and usage of centrality bins
83 gROOT->LoadMacro("AddTaskFlow.C");
84 Float_t kLowCentralityBin = -1.;
85 Float_t kHighCentralityBin = -1;
86 if(kUseCentrality) {
87 kLowCentralityBin = centralityArray[binfirst];
88 kHighCentralityBin = centralityArray[binlast];
89 }
90 AddTaskFlow(kLowCentralityBin,
91 kHighCentralityBin,
92 commonOutputFileName );
93
94 // Enable debug printouts:
95 mgr->SetDebugLevel(2);
96 // Run the analysis:
97 if(!mgr->InitAnalysis()) return;
98 mgr->PrintStatus();
99 if(mode == mLocal || mode == mLocalPAR) {
100 mgr->StartAnalysis("local",chain);
101 } else if(mode == mPROOF) {
102 mgr->StartAnalysis("proof",dataDir,nRuns,offset);
103 } else if(mode == mGrid || mode == mGridPAR) {
104 mgr->StartAnalysis("grid");
105 }
106
107 // Print real and CPU time used for analysis:
108 timer.Stop();
109 timer.Print();
110
111} // end of void runFlowTask(...)
112
113//===============================================================================================
114/*
115void CrossCheckUserSettings(Bool_t bData)
116{
117 // Check in this method if the user settings make sense.
118 if(LYZ1SUM && LYZ2SUM) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
119 if(LYZ1PROD && LYZ2PROD) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
120 if(LYZ2SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
121 if(LYZ1SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
122} // end of void CrossCheckUserSettings()
123*/
124//===============================================================================================
125
126void LoadLibraries(const anaModes mode)
127{
128 //--------------------------------------
129 // Load the needed libraries most of them already loaded by aliroot
130 //--------------------------------------
131
132 gSystem->Load("libCore");
133 gSystem->Load("libTree");
134 gSystem->Load("libGeom");
135 gSystem->Load("libVMC");
136 gSystem->Load("libXMLIO");
137 gSystem->Load("libPhysics");
138 gSystem->Load("libXMLParser");
139 gSystem->Load("libProof");
140 gSystem->Load("libMinuit");
141
142 if (mode==mLocal || mode==mGrid || mode == mGridPAR || mode == mLocalPAR )
143 {
144 gSystem->Load("libSTEERBase");
145 gSystem->Load("libCDB");
146 gSystem->Load("libRAWDatabase");
147 gSystem->Load("libRAWDatarec");
148 gSystem->Load("libESD");
149 gSystem->Load("libAOD");
150 gSystem->Load("libSTEER");
151 gSystem->Load("libANALYSIS");
152 gSystem->Load("libANALYSISalice");
153 gSystem->Load("libTOFbase");
154 gSystem->Load("libTOFrec");
155 gSystem->Load("libTENDER");
156
157 if (mode == mLocal || mode == mGrid)
158 {
159 gSystem->Load("libTENDERSupplies");
160 gSystem->Load("libPWG2flowCommon");
161 gSystem->Load("libPWG2flowTasks");
162 }
163 if (mode == mLocalPAR || mode == mGridPAR )
164 {
165 AliAnalysisAlien::SetupPar("TENDERSupplies");
166 AliAnalysisAlien::SetupPar("PWG2flowCommon");
167 AliAnalysisAlien::SetupPar("PWG2flowTasks");
168 }
169 }
170
171 //---------------------------------------------------------
172 // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
173 //---------------------------------------------------------
174 else if (mode==mPROOF) {
175 // set to debug root versus if needed
176 //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a_dbg");
177 //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a");
178 //TProof::Reset("proof://snelling@alicecaf.cern.ch");
179 // Connect to proof
180 printf("*** Connect to PROOF ***\n");
181 gEnv->SetValue("XSec.GSI.DelegProxy","2");
182 TProof::Open("mkrzewic@alice-caf.cern.ch");
183 //TProof::Open("mkrzewic@skaf.saske.sk");
184 // list the data available
185 //gProof->ShowDataSets("/*/*");
186 //gProof->ShowDataSets("/alice/sim/"); //for MC Data
187 //gProof->ShowDataSets("/alice/data/"); //for REAL Data
188
189 // Clear the Packages
190 /*
191 gProof->ClearPackage("STEERBase.par");
192 gProof->ClearPackage("ESD.par");
193 gProof->ClearPackage("AOD.par");
194 */
195 //gProof->ClearPackage("ANALYSIS.par");
196 //gProof->ClearPackage("ANALYSISalice.par");
197 //gProof->ClearPackage("CORRFW.par");
198
199 gProof->ClearPackage("PWG2flowCommon");
200 gProof->ClearPackage("PWG2flowTasks");
201
202 // Upload the Packages
203 //gProof->UploadPackage("STEERBase.par");
204 //gProof->UploadPackage("ESD.par");
205 //gProof->UploadPackage("AOD.par");
206
207 //gProof->UploadPackage("ANALYSIS.par");
208 //gProof->UploadPackage("ANALYSISalice.par");
209 gProof->UploadPackage("CORRFW.par");
210 gProof->UploadPackage("PWG2flowCommon.par");
211 gProof->UploadPackage("PWG2flowTasks.par");
212 gProof->UploadPackage("ALIRECO.par");
213
214 // Enable the Packages
215 // The global package
216 TList* list = new TList();
217 list->Add(new TNamed("ALIROOT_EXTRA_INCLUDES","RAW:OCDB:STEER:TOF"));
218 gProof->EnablePackage("VO_ALICE@AliRoot::v4-21-07-AN",list);
219 gProof->EnablePackage("ALIRECO");
220 //gProof->EnablePackage("ANALYSIS");
221 //gProof->EnablePackage("ANALYSISalice");
222 //gProof->EnablePackage("CORRFW");
223 gProof->EnablePackage("PWG2flowCommon");
224 gProof->EnablePackage("PWG2flowTasks");
225
226 // Show enables Packages
227 gProof->ShowEnabledPackages();
228 }
229
230} // end of void LoadLibraries(const anaModes mode)
231
232// Helper macros for creating chains
233// from: CreateESDChain.C,v 1.10 jgrosseo Exp
234
235TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
236{
237 // creates chain of files in a given directory or file containing a list.
238 // In case of directory the structure is expected as:
239 // <aDataDir>/<dir0>/AliESDs.root
240 // <aDataDir>/<dir1>/AliESDs.root
241 // ...
242
243 if (!aDataDir)
244 return 0;
245
246 Long_t id, size, flags, modtime;
247 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
248 {
249 printf("%s not found.\n", aDataDir);
250 return 0;
251 }
252
253 TChain* chain = new TChain("esdTree");
254 TChain* chaingAlice = 0;
255
256 if (flags & 2)
257 {
258 TString execDir(gSystem->pwd());
259 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
260 TList* dirList = baseDir->GetListOfFiles();
261 Int_t nDirs = dirList->GetEntries();
262 gSystem->cd(execDir);
263
264 Int_t count = 0;
265
266 for (Int_t iDir=0; iDir<nDirs; ++iDir)
267 {
268 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
269 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
270 continue;
271
272 if (offset > 0)
273 {
274 --offset;
275 continue;
276 }
277
278 if (count++ == aRuns)
279 break;
280
281 TString presentDirName(aDataDir);
282 presentDirName += "/";
283 presentDirName += presentDir->GetName();
284 chain->Add(presentDirName + "/AliESDs.root/esdTree");
285 // cerr<<presentDirName<<endl;
286 }
287
288 }
289 else
290 {
291 // Open the input stream
292 ifstream in;
293 in.open(aDataDir);
294
295 Int_t count = 0;
296
297 // Read the input list of files and add them to the chain
298 TString esdfile;
299 while(in.good()) {
300 in >> esdfile;
301 if (!esdfile.Contains("root")) continue; // protection
302
303 if (offset > 0)
304 {
305 --offset;
306 continue;
307 }
308
309 if (count++ == aRuns)
310 break;
311
312 // add esd file
313 chain->Add(esdfile);
314 }
315
316 in.close();
317 }
318
319 return chain;
320
321} // end of TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
322
323//===============================================================================================
324
325TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
326{
327 // creates chain of files in a given directory or file containing a list.
328 // In case of directory the structure is expected as:
329 // <aDataDir>/<dir0>/AliAOD.root
330 // <aDataDir>/<dir1>/AliAOD.root
331 // ...
332
333 if (!aDataDir)
334 return 0;
335
336 Long_t id, size, flags, modtime;
337 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
338 {
339 printf("%s not found.\n", aDataDir);
340 return 0;
341 }
342
343 TChain* chain = new TChain("aodTree");
344 TChain* chaingAlice = 0;
345
346 if (flags & 2)
347 {
348 TString execDir(gSystem->pwd());
349 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
350 TList* dirList = baseDir->GetListOfFiles();
351 Int_t nDirs = dirList->GetEntries();
352 gSystem->cd(execDir);
353
354 Int_t count = 0;
355
356 for (Int_t iDir=0; iDir<nDirs; ++iDir)
357 {
358 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
359 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
360 continue;
361
362 if (offset > 0)
363 {
364 --offset;
365 continue;
366 }
367
368 if (count++ == aRuns)
369 break;
370
371 TString presentDirName(aDataDir);
372 presentDirName += "/";
373 presentDirName += presentDir->GetName();
374 chain->Add(presentDirName + "/AliAOD.root/aodTree");
375 // cerr<<presentDirName<<endl;
376 }
377
378 }
379 else
380 {
381 // Open the input stream
382 ifstream in;
383 in.open(aDataDir);
384
385 Int_t count = 0;
386
387 // Read the input list of files and add them to the chain
388 TString aodfile;
389 while(in.good()) {
390 in >> aodfile;
391 if (!aodfile.Contains("root")) continue; // protection
392
393 if (offset > 0)
394 {
395 --offset;
396 continue;
397 }
398
399 if (count++ == aRuns)
400 break;
401
402 // add aod file
403 chain->Add(aodfile);
404 }
405
406 in.close();
407 }
408
409 return chain;
410
411} // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
412