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