]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGCF/FLOW/macros/Kinks/runFlowTaskCentralityKinkTrain.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGCF / FLOW / macros / Kinks / runFlowTaskCentralityKinkTrain.C
CommitLineData
8fa6a5fa
MK
1enum anaModes {mLocal,mPROOF,mGrid};
2Int_t binfirst = 0; //where do we start numbering bins
3Int_t binlast = 8; //where do we stop numbering bins
4const Int_t numberOfCentralityBins = 9;
5Float_t centralityArray[numberOfCentralityBins+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.}; // in centrality percentile
6//Int_t centralityArray[numberOfCentralityBins+1] = {41,80,146,245,384,576,835,1203,1471,10000}; // in terms of TPC only reference multiplicity
7
8TString commonOutputFileName = "outputCentrality"; // e.g.: result for centrality bin 0 will be in the file "outputCentrality0.root", etc
9
10void runFlowTaskCentralityKinkTrain( Int_t mode = mLocal,
11 Bool_t useFlowParFiles = kFALSE,
12 Bool_t DATA = kTRUE,
13 const Char_t* dataDir="fileList",
14 Int_t nEvents = 1e4,
15 Int_t offset=0 )
16{
17 // Time:
18 TStopwatch timer;
19 timer.Start();
20
21 // Load needed libraries:
22 LoadLibraries(mode,useFlowParFiles);
23
24 // Create analysis manager:
25 AliAnalysisManager *mgr = new AliAnalysisManager("FlowAnalysisManager");
26
27 // Chains:
28 if(mode == mLocal)
29 {
30 gROOT->LoadMacro("$ALICE_ROOT/PWGUD/macros/CreateESDChain.C");
31 TChain* chain = CreateESDChain(dataDir, nEvents, offset);
32 //TChain* chain = CreateAODChain(dataDir, nEvents, offset);
33 }
34
35 // Connect plug-in to the analysis manager:
36 if(mode == mGrid)
37 {
38 gROOT->LoadMacro("CreateAlienHandler.C");
39 AliAnalysisGrid *alienHandler = CreateAlienHandler(useFlowParFiles);
40 if(!alienHandler) return;
41 mgr->SetGridHandler(alienHandler);
42 }
43
44 // Event handlers:
45 AliVEventHandler* esdH = new AliESDInputHandler;
46 mgr->SetInputEventHandler(esdH);
47 if (!DATA)
48 {
49 AliMCEventHandler *mc = new AliMCEventHandler();
50 mgr->SetMCtruthEventHandler(mc);
51 }
52
53 // Task to check the offline trigger:
63b6cbd0 54 gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskPhysicsSelection.C");
8fa6a5fa
MK
55 AddTaskPhysicsSelection(!DATA);
56
57 //Add the centrality determination task
1c06a186 58 gROOT->LoadMacro("$ALICE_ROOT/OADB/macros/AddTaskCentrality.C");
8fa6a5fa
MK
59 AliCentralitySelectionTask* centSelTask = AddTaskCentrality();
60 if (!DATA) centSelTask->SetMCInput();
61
62 //add the PID response task
63 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
64 AliAnalysisTaskPIDResponse* pidresponsetask = AddTaskPIDResponse(!DATA);
65
66 //Add the TOF tender
67 //gROOT->LoadMacro("$ALICE_ROOT/PWGCF/FLOW/macros/AddTaskTenderTOF.C");
68 //AddTaskTenderTOF();
69
70 // Setup kink analysis per centrality bin:
71 gROOT->LoadMacro("$ALICE_ROOT/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityKink.C");
72 for (Int_t i=binfirst; i<binlast+1; i++)
73 {
74 Float_t lowCentralityBinEdge = centralityArray[i];
75 Float_t highCentralityBinEdge = centralityArray[i+1];
76 AddTaskFlowCentralityKink( lowCentralityBinEdge,
77 highCentralityBinEdge,
78 commonOutputFileName,
79 AliPID::kUnknown,
80 AliFlowTrackCuts::kTOFbeta,
81 -1,2,kTRUE );
82 AddTaskFlowCentralityKink( lowCentralityBinEdge,
83 highCentralityBinEdge,
84 commonOutputFileName,
85 AliPID::kUnknown,
86 AliFlowTrackCuts::kTOFbeta,
87 1,2,kTRUE );
88 AddTaskFlowCentralityKink( lowCentralityBinEdge,
89 highCentralityBinEdge,
90 commonOutputFileName,
91 AliPID::kUnknown,
92 AliFlowTrackCuts::kTOFbeta,
93 -1,3 );
94 AddTaskFlowCentralityKink( lowCentralityBinEdge,
95 highCentralityBinEdge,
96 commonOutputFileName,
97 AliPID::kUnknown,
98 AliFlowTrackCuts::kTOFbeta,
99 1,3 );
100 } // end of for (Int_t i=0; i<numberOfCentralityBins; i++)
101
102 // Setup kaon analysis per centrality bin:
103 gROOT->LoadMacro("$ALICE_ROOT/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityPID.C");
104 for (Int_t i=binfirst; i<binlast+1; i++)
105 {
106 Float_t lowCentralityBinEdge = centralityArray[i];
107 Float_t highCentralityBinEdge = centralityArray[i+1];
108 AddTaskFlowCentralityPID( lowCentralityBinEdge,
109 highCentralityBinEdge,
110 commonOutputFileName,
111 AliPID::kKaon,
112 AliFlowTrackCuts::kTOFbeta,
113 -1,2,kTRUE );
114 AddTaskFlowCentralityPID( lowCentralityBinEdge,
115 highCentralityBinEdge,
116 commonOutputFileName,
117 AliPID::kKaon,
118 AliFlowTrackCuts::kTOFbeta,
119 1,2,kTRUE );
120 AddTaskFlowCentralityPID( lowCentralityBinEdge,
121 highCentralityBinEdge,
122 commonOutputFileName,
123 AliPID::kKaon,
124 AliFlowTrackCuts::kTOFbeta,
125 -1,3 );
126 AddTaskFlowCentralityPID( lowCentralityBinEdge,
127 highCentralityBinEdge,
128 commonOutputFileName,
129 AliPID::kKaon,
130 AliFlowTrackCuts::kTOFbeta,
131 1,3 );
132 } // end of for (Int_t i=0; i<numberOfCentralityBins; i++)
133
134 // Setup He3 analysis per centrality bin:
135 gROOT->LoadMacro("$ALICE_ROOT/PWGCF/FLOW/macros/Kinks/AddTaskFlowCentralityPID.C");
136 for (Int_t i=binfirst; i<binlast+1; i++)
137 {
138 Float_t lowCentralityBinEdge = centralityArray[i];
139 Float_t highCentralityBinEdge = centralityArray[i+1];
140 AddTaskFlowCentralityPID( lowCentralityBinEdge,
141 highCentralityBinEdge,
142 commonOutputFileName,
143 AliPID::kHe3,
144 AliFlowTrackCuts::kTPCNuclei,
145 -1,2,kTRUE );
146 AddTaskFlowCentralityPID( lowCentralityBinEdge,
147 highCentralityBinEdge,
148 commonOutputFileName,
149 AliPID::kHe3,
150 AliFlowTrackCuts::kTPCNuclei,
151 1,2,kTRUE );
152 AddTaskFlowCentralityPID( lowCentralityBinEdge,
153 highCentralityBinEdge,
154 commonOutputFileName,
155 AliPID::kHe3,
156 AliFlowTrackCuts::kTPCNuclei,
157 -1,3 );
158 AddTaskFlowCentralityPID( lowCentralityBinEdge,
159 highCentralityBinEdge,
160 commonOutputFileName,
161 AliPID::kHe3,
162 AliFlowTrackCuts::kTPCNuclei,
163 1,3 );
164 } // end of for (Int_t i=0; i<numberOfCentralityBins; i++)
165
166 // Enable debug printouts:
167 mgr->SetDebugLevel(2);
168 // Run the analysis:
169 if(!mgr->InitAnalysis()) return;
170 mgr->PrintStatus();
171 if(mode == mLocal)
172 {
173 mgr->StartAnalysis("local",chain);
174 }
175 else if(mode == mPROOF)
176 {
177 mgr->StartAnalysis("proof",dataDir,nEvents,offset);
178 }
179 else if(mode == mGrid)
180 {
181 mgr->StartAnalysis("grid");
182 }
183
184 // Print real and CPU time used for analysis:
185 timer.Stop();
186 timer.Print();
187
188} // end of void runFlowTaskCentralityPIDTrain(...)
189
190//===============================================================================================
191/*
192void CrossCheckUserSettings(Bool_t bData)
193{
194 // Check in this method if the user settings make sense.
195 if(LYZ1SUM && LYZ2SUM) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
196 if(LYZ1PROD && LYZ2PROD) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
197 if(LYZ2SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
198 if(LYZ1SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
199} // end of void CrossCheckUserSettings()
200*/
201//===============================================================================================
202
203void LoadLibraries(const anaModes mode, Bool_t useFlowParFiles )
204{
205 //--------------------------------------
206 // Load the needed libraries most of them already loaded by aliroot
207 //--------------------------------------
208
209 gSystem->Load("libCore");
210 gSystem->Load("libTree");
211 gSystem->Load("libGeom");
212 gSystem->Load("libVMC");
213 gSystem->Load("libXMLIO");
214 gSystem->Load("libPhysics");
215 gSystem->Load("libXMLParser");
216 gSystem->Load("libProof");
217 gSystem->Load("libMinuit");
218
219 if (mode==mLocal || mode==mGrid)
220 {
221 gSystem->Load("libSTEERBase");
222 gSystem->Load("libCDB");
223 gSystem->Load("libRAWDatabase");
224 gSystem->Load("libRAWDatarec");
225 gSystem->Load("libESD");
226 gSystem->Load("libAOD");
227 gSystem->Load("libSTEER");
228 gSystem->Load("libANALYSIS");
229 gSystem->Load("libANALYSISalice");
230 gSystem->Load("libTPCbase");
231 gSystem->Load("libTOFbase");
232 gSystem->Load("libTOFrec");
233 gSystem->Load("libTRDbase");
234 gSystem->Load("libVZERObase");
235 gSystem->Load("libVZEROrec");
236 gSystem->Load("libT0base");
237 gSystem->Load("libT0rec");
230b7aff 238 gSystem->Load("libTender");
239 gSystem->Load("libTenderSupplies");
8fa6a5fa
MK
240
241 if (useFlowParFiles)
242 {
243 AliAnalysisAlien::SetupPar("PWGflowBase");
244 AliAnalysisAlien::SetupPar("PWGflowTasks");
245 }
246 else
247 {
248 gSystem->Load("libPWGflowBase");
249 gSystem->Load("libPWGflowTasks");
250 }
251 }
252 else if (mode==mPROOF)
253 {
254 TList* list = new TList();
255 list->Add(new TNamed("ALIROOT_MODE", "ALIROOT"));
256 if (useFlowParFiles)
230b7aff 257 list->Add(new TNamed("ALIROOT_EXTRA_LIBS", "ANALYSIS:ANALYSISalice:Tender:TenderSupplies"));
8fa6a5fa 258 else
230b7aff 259 list->Add(new TNamed("ALIROOT_EXTRA_LIBS", "ANALYSIS:ANALYSISalice:Tender:TenderSupplies:PWGflowBase:PWGflowTasks"));
8fa6a5fa
MK
260
261 //list->Add(new TNamed("ALIROOT_EXTRA_INCLUDES","PWG/FLOW/Base:PWG/FLOW/Tasks"));
262
263 // Connect to proof
264 printf("*** Connect to PROOF ***\n");
265 gEnv->SetValue("XSec.GSI.DelegProxy","2");
266 //TProof* proof = TProof::Open("alice-caf.cern.ch");
267 TProof* proof = TProof::Open("skaf.saske.sk");
268
269 // list the data available
270 //gProof->ShowDataSets("/*/*");
271 //gProof->ShowDataSets("/alice/sim/"); //for MC Data
272 //gProof->ShowDataSets("/alice/data/"); //for REAL Data
273
274 proof->ClearPackages();
275 proof->EnablePackage("VO_ALICE@AliRoot::v4-21-14-AN",list);
276
277 if (useFlowParFiles)
278 {
279 gProof->UploadPackage("PWGflowBase.par");
280 gProof->UploadPackage("PWGflowTasks.par");
281 }
282
283 // Show enables Packages
284 gProof->ShowEnabledPackages();
285 }
286} // end of void LoadLibraries(const anaModes mode)
287
288//===============================================================================================
289
290TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
291{
292 // creates chain of files in a given directory or file containing a list.
293 // In case of directory the structure is expected as:
294 // <aDataDir>/<dir0>/AliAOD.root
295 // <aDataDir>/<dir1>/AliAOD.root
296 // ...
297
298 if (!aDataDir)
299 return 0;
300
301 Long_t id, size, flags, modtime;
302 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
303 {
304 printf("%s not found.\n", aDataDir);
305 return 0;
306 }
307
308 TChain* chain = new TChain("aodTree");
309 TChain* chaingAlice = 0;
310
311 if (flags & 2)
312 {
313 TString execDir(gSystem->pwd());
314 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
315 TList* dirList = baseDir->GetListOfFiles();
316 Int_t nDirs = dirList->GetEntries();
317 gSystem->cd(execDir);
318
319 Int_t count = 0;
320
321 for (Int_t iDir=0; iDir<nDirs; ++iDir)
322 {
323 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
324 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
325 continue;
326
327 if (offset > 0)
328 {
329 --offset;
330 continue;
331 }
332
333 if (count++ == aRuns)
334 break;
335
336 TString presentDirName(aDataDir);
337 presentDirName += "/";
338 presentDirName += presentDir->GetName();
339 chain->Add(presentDirName + "/AliAOD.root/aodTree");
340 // cerr<<presentDirName<<endl;
341 }
342
343 }
344 else
345 {
346 // Open the input stream
347 ifstream in;
348 in.open(aDataDir);
349
350 Int_t count = 0;
351
352 // Read the input list of files and add them to the chain
353 TString aodfile;
354 while(in.good())
355 {
356 in >> aodfile;
357 if (!aodfile.Contains("root")) continue; // protection
358
359 if (offset > 0)
360 {
361 --offset;
362 continue;
363 }
364
365 if (count++ == aRuns)
366 break;
367
368 // add aod file
369 chain->Add(aodfile);
370 }
371
372 in.close();
373 }
374
375 return chain;
376
377} // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
378