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