1 enum anaModes {mLocal,mPROOF,mGrid};
2 //mLocal: Analyze locally files in your computer using aliroot
3 //mPROOF: Analyze CAF files with PROOF
4 //mGrid: Analyze files on Grid via AliEn plug-in and using precompiled FLOW libraries
6 // CENTRALITY DEFINITION
7 //Int_t binfirst = 4; //where do we start numbering bins
8 //Int_t binlast = 6; //where do we stop numbering bins
9 //const Int_t numberOfCentralityBins = 9;
10 Int_t binfirst = 0; //where do we start numbering bins
11 Int_t binlast = 8; //where do we stop numbering bins
12 const Int_t numberOfCentralityBins = 9;
13 Float_t centralityArray[numberOfCentralityBins+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.}; // in centrality percentile
14 //Int_t centralityArray[numberOfCentralityBins+1] = {41,80,146,245,384,576,835,1203,1471,10000}; // in terms of TPC only reference multiplicity
16 TString commonOutputFileName = "outputCentrality"; // e.g.: result for centrality bin 0 will be in the file "outputCentrality0.root", etc
18 //void runFlowTaskCentralityTrain(Int_t mode=mLocal, Int_t nEvents = 10,
19 //Bool_t DATA = kFALSE, const Char_t* dataDir="/Users/snelling/alice_data/Therminator_midcentral", Int_t offset = 0)
21 void runFlowTaskCentralityTrain( Int_t mode = mPROOF,
22 Bool_t useFlowParFiles = kFALSE,
24 const Char_t* dataDir = "/alice/data/LHC10h_000137162_p1_plusplusplus#esdTree",
27 Bool_t useTender = kFALSE )
32 // Cross-check user settings before starting:
33 // CrossCheckUserSettings(DATA);
35 // Load needed libraries:
36 LoadLibraries(mode,useFlowParFiles);
38 // Create analysis manager:
39 AliAnalysisManager *mgr = new AliAnalysisManager("FlowAnalysisManager");
44 TChain* chain = CreateESDChain(dataDir, nEvents, offset);
45 //TChain* chain = CreateAODChain(dataDir, nEvents, offset);
48 // Connect plug-in to the analysis manager:
51 gROOT->LoadMacro("CreateAlienHandler.C");
52 AliAnalysisGrid *alienHandler = CreateAlienHandler(useFlowParFiles);
53 if(!alienHandler) return;
54 mgr->SetGridHandler(alienHandler);
58 AliVEventHandler* esdH = new AliESDInputHandler;
59 mgr->SetInputEventHandler(esdH);
62 AliMCEventHandler *mc = new AliMCEventHandler();
63 mgr->SetMCtruthEventHandler(mc);
66 // Task to check the offline trigger:
67 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
68 AddTaskPhysicsSelection(!DATA);
70 //Add the centrality determination task
71 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
72 AliCentralitySelectionTask* centSelTask = AddTaskCentrality();
73 if (!DATA) centSelTask->SetMCInput();
74 if (DATA) centSelTask->SetPass(1);
80 gROOT->LoadMacro("$ALICE_ROOT/PWG/FLOW/macros/AddTaskTenderFlow.C");
84 // Setup analysis per centrality bin:
85 gROOT->LoadMacro("AddTaskFlowCentrality.C");
86 for (Int_t i=binfirst; i<binlast+1; i++)
88 Float_t lowCentralityBinEdge = centralityArray[i];
89 Float_t highCentralityBinEdge = centralityArray[i+1];
90 Printf("\nWagon for centrality bin %i: %.0f-%.0f",i,lowCentralityBinEdge,highCentralityBinEdge);
91 AddTaskFlowCentrality( lowCentralityBinEdge,
92 highCentralityBinEdge,
93 commonOutputFileName );
94 } // end of for (Int_t i=0; i<numberOfCentralityBins; i++)
96 // Enable debug printouts:
97 mgr->SetDebugLevel(2);
99 if(!mgr->InitAnalysis()) return;
103 mgr->StartAnalysis("local",chain);
105 else if(mode == mPROOF)
107 mgr->StartAnalysis("proof",dataDir,nEvents,offset);
109 else if(mode == mGrid)
111 mgr->StartAnalysis("grid");
114 // Print real and CPU time used for analysis:
118 } // end of void runFlowTaskCentralityTrain(...)
120 //===============================================================================================
122 void CrossCheckUserSettings(Bool_t bData)
124 // Check in this method if the user settings make sense.
125 if(LYZ1SUM && LYZ2SUM) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
126 if(LYZ1PROD && LYZ2PROD) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
127 if(LYZ2SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
128 if(LYZ1SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
129 } // end of void CrossCheckUserSettings()
131 //===============================================================================================
133 void LoadLibraries(const anaModes mode, Bool_t useFlowParFiles )
135 //--------------------------------------
136 // Load the needed libraries most of them already loaded by aliroot
137 //--------------------------------------
139 gSystem->Load("libCore");
140 gSystem->Load("libTree");
141 gSystem->Load("libGeom");
142 gSystem->Load("libVMC");
143 gSystem->Load("libXMLIO");
144 gSystem->Load("libPhysics");
145 gSystem->Load("libXMLParser");
146 gSystem->Load("libProof");
147 gSystem->Load("libMinuit");
149 if (mode==mLocal || mode==mGrid)
151 gSystem->Load("libSTEERBase");
152 gSystem->Load("libCDB");
153 gSystem->Load("libRAWDatabase");
154 gSystem->Load("libRAWDatarec");
155 gSystem->Load("libESD");
156 gSystem->Load("libAOD");
157 gSystem->Load("libSTEER");
158 gSystem->Load("libANALYSIS");
159 gSystem->Load("libANALYSISalice");
160 gSystem->Load("libTPCbase");
161 gSystem->Load("libTOFbase");
162 gSystem->Load("libTOFrec");
163 gSystem->Load("libTRDbase");
164 gSystem->Load("libVZERObase");
165 gSystem->Load("libVZEROrec");
166 gSystem->Load("libT0base");
167 gSystem->Load("libT0rec");
168 gSystem->Load("libTENDER");
169 gSystem->Load("libTENDERSupplies");
173 AliAnalysisAlien::SetupPar("PWGflowBase");
174 AliAnalysisAlien::SetupPar("PWGflowTasks");
178 gSystem->Load("libPWGflowBase");
179 gSystem->Load("libPWGflowTasks");
182 else if (mode==mPROOF)
184 TList* list = new TList();
185 list->Add(new TNamed("ALIROOT_MODE", "ALIROOT"));
187 list->Add(new TNamed("ALIROOT_EXTRA_LIBS", "ANALYSIS:ANALYSISalice:TENDER:TENDERSupplies"));
189 list->Add(new TNamed("ALIROOT_EXTRA_LIBS", "ANALYSIS:ANALYSISalice:TENDER:TENDERSupplies:PWGflowBase:PWGflowTasks"));
191 //list->Add(new TNamed("ALIROOT_EXTRA_INCLUDES","PWG/FLOW/Base:PWG/FLOW/Tasks"));
194 printf("*** Connect to PROOF ***\n");
195 gEnv->SetValue("XSec.GSI.DelegProxy","2");
196 //TProof* proof = TProof::Open("alice-caf.cern.ch");
197 TProof* proof = TProof::Open("skaf.saske.sk");
199 // list the data available
200 //gProof->ShowDataSets("/*/*");
201 //gProof->ShowDataSets("/alice/sim/"); //for MC Data
202 //gProof->ShowDataSets("/alice/data/"); //for REAL Data
204 proof->ClearPackages();
205 proof->EnablePackage("VO_ALICE@AliRoot::v4-21-14-AN",list);
209 gProof->UploadPackage("PWGflowBase.par");
210 gProof->UploadPackage("PWGflowTasks.par");
213 // Show enables Packages
214 gProof->ShowEnabledPackages();
216 } // end of void LoadLibraries(const anaModes mode)
218 // Helper macros for creating chains
219 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
220 TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
222 // creates chain of files in a given directory or file containing a list.
223 // In case of directory the structure is expected as:
224 // <aDataDir>/<dir0>/AliESDs.root
225 // <aDataDir>/<dir1>/AliESDs.root
231 Long_t id, size, flags, modtime;
232 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
234 printf("%s not found.\n", aDataDir);
238 TChain* chain = new TChain("esdTree");
239 TChain* chaingAlice = 0;
243 TString execDir(gSystem->pwd());
244 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
245 TList* dirList = baseDir->GetListOfFiles();
246 Int_t nDirs = dirList->GetEntries();
247 gSystem->cd(execDir);
251 for (Int_t iDir=0; iDir<nDirs; ++iDir)
253 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
254 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
263 if (count++ == aRuns)
266 TString presentDirName(aDataDir);
267 presentDirName += "/";
268 presentDirName += presentDir->GetName();
269 chain->Add(presentDirName + "/AliESDs.root/esdTree");
270 // cerr<<presentDirName<<endl;
276 // Open the input stream
282 // Read the input list of files and add them to the chain
287 if (!esdfile.Contains("root")) continue; // protection
295 if (count++ == aRuns)
307 } // end of TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
309 //===============================================================================================
311 TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
313 // creates chain of files in a given directory or file containing a list.
314 // In case of directory the structure is expected as:
315 // <aDataDir>/<dir0>/AliAOD.root
316 // <aDataDir>/<dir1>/AliAOD.root
322 Long_t id, size, flags, modtime;
323 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
325 printf("%s not found.\n", aDataDir);
329 TChain* chain = new TChain("aodTree");
330 TChain* chaingAlice = 0;
334 TString execDir(gSystem->pwd());
335 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
336 TList* dirList = baseDir->GetListOfFiles();
337 Int_t nDirs = dirList->GetEntries();
338 gSystem->cd(execDir);
342 for (Int_t iDir=0; iDir<nDirs; ++iDir)
344 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
345 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
354 if (count++ == aRuns)
357 TString presentDirName(aDataDir);
358 presentDirName += "/";
359 presentDirName += presentDir->GetName();
360 chain->Add(presentDirName + "/AliAOD.root/aodTree");
361 // cerr<<presentDirName<<endl;
367 // Open the input stream
373 // Read the input list of files and add them to the chain
378 if (!aodfile.Contains("root")) continue; // protection
386 if (count++ == aRuns)
398 } // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)