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 runFlowTaskCentralityPIDTrain(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 runFlowTaskCentralityPIDTrain( Int_t mode = mGrid,
22 Bool_t useFlowParFiles = kTRUE,
24 //const Char_t* dataDir="/data/alice2/ab/grid/21-16/TEST/data/",
25 const Char_t* dataDir="/data/alice2/mikolaj/flowPaper/data/137161/",
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 gROOT->LoadMacro("$ALICE_ROOT/PWG0/CreateESDChain.C");
45 TChain* chain = CreateESDChain(dataDir, nEvents, offset);
46 //TChain* chain = CreateAODChain(dataDir, nEvents, offset);
49 // Connect plug-in to the analysis manager:
52 gROOT->LoadMacro("CreateAlienHandler.C");
53 AliAnalysisGrid *alienHandler = CreateAlienHandler(useFlowParFiles);
54 if(!alienHandler) return;
55 mgr->SetGridHandler(alienHandler);
59 AliVEventHandler* esdH = new AliESDInputHandler;
60 mgr->SetInputEventHandler(esdH);
63 AliMCEventHandler *mc = new AliMCEventHandler();
64 mgr->SetMCtruthEventHandler(mc);
67 // Task to check the offline trigger:
68 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
69 AddTaskPhysicsSelection(!DATA);
71 //Add the centrality determination task
72 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
76 gROOT->LoadMacro("$ALICE_ROOT/PWG2/FLOW/macros/AddTaskTenderTOF.C");
79 // Setup analysis per centrality bin:
80 gROOT->LoadMacro("AddTaskFlowCentralityPID.C");
81 for (Int_t i=binfirst; i<binlast+1; i++)
83 Float_t lowCentralityBinEdge = centralityArray[i];
84 Float_t highCentralityBinEdge = centralityArray[i+1];
85 AddTaskFlowCentralityPID( lowCentralityBinEdge,
86 highCentralityBinEdge,
89 AliFlowTrackCuts::kTOFbetaSimple,
91 AddTaskFlowCentralityPID( lowCentralityBinEdge,
92 highCentralityBinEdge,
95 AliFlowTrackCuts::kTOFbetaSimple,
97 AddTaskFlowCentralityPID( lowCentralityBinEdge,
98 highCentralityBinEdge,
101 AliFlowTrackCuts::kTOFbetaSimple,
103 AddTaskFlowCentralityPID( lowCentralityBinEdge,
104 highCentralityBinEdge,
105 commonOutputFileName,
107 AliFlowTrackCuts::kTOFbetaSimple,
109 AddTaskFlowCentralityPID( lowCentralityBinEdge,
110 highCentralityBinEdge,
111 commonOutputFileName,
113 AliFlowTrackCuts::kTOFbetaSimple,
115 AddTaskFlowCentralityPID( lowCentralityBinEdge,
116 highCentralityBinEdge,
117 commonOutputFileName,
119 AliFlowTrackCuts::kTOFbetaSimple,
121 AddTaskFlowCentralityPID( lowCentralityBinEdge,
122 highCentralityBinEdge,
123 commonOutputFileName,
125 AliFlowTrackCuts::kTOFbetaSimple,
127 AddTaskFlowCentralityPID( lowCentralityBinEdge,
128 highCentralityBinEdge,
129 commonOutputFileName,
131 AliFlowTrackCuts::kTOFbetaSimple,
133 AddTaskFlowCentralityPID( lowCentralityBinEdge,
134 highCentralityBinEdge,
135 commonOutputFileName,
137 AliFlowTrackCuts::kTOFbetaSimple,
139 AddTaskFlowCentralityPID( lowCentralityBinEdge,
140 highCentralityBinEdge,
141 commonOutputFileName,
143 AliFlowTrackCuts::kTOFbetaSimple,
145 AddTaskFlowCentralityPID( lowCentralityBinEdge,
146 highCentralityBinEdge,
147 commonOutputFileName,
149 AliFlowTrackCuts::kTOFbetaSimple,
151 AddTaskFlowCentralityPID( lowCentralityBinEdge,
152 highCentralityBinEdge,
153 commonOutputFileName,
155 AliFlowTrackCuts::kTOFbetaSimple,
157 } // end of for (Int_t i=0; i<numberOfCentralityBins; i++)
159 // Enable debug printouts:
160 mgr->SetDebugLevel(2);
162 if(!mgr->InitAnalysis()) return;
166 mgr->StartAnalysis("local",chain);
168 else if(mode == mPROOF)
170 mgr->StartAnalysis("proof",dataDir,nEvents,offset);
172 else if(mode == mGrid)
174 mgr->StartAnalysis("grid");
177 // Print real and CPU time used for analysis:
181 } // end of void runFlowTaskCentralityPIDTrain(...)
183 //===============================================================================================
185 void CrossCheckUserSettings(Bool_t bData)
187 // Check in this method if the user settings make sense.
188 if(LYZ1SUM && LYZ2SUM) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
189 if(LYZ1PROD && LYZ2PROD) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
190 if(LYZ2SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
191 if(LYZ1SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
192 } // end of void CrossCheckUserSettings()
194 //===============================================================================================
196 void LoadLibraries(const anaModes mode, Bool_t useFlowParFiles )
198 //--------------------------------------
199 // Load the needed libraries most of them already loaded by aliroot
200 //--------------------------------------
202 gSystem->Load("libCore");
203 gSystem->Load("libTree");
204 gSystem->Load("libGeom");
205 gSystem->Load("libVMC");
206 gSystem->Load("libXMLIO");
207 gSystem->Load("libPhysics");
208 gSystem->Load("libXMLParser");
209 gSystem->Load("libProof");
210 gSystem->Load("libMinuit");
212 if (mode==mLocal || mode==mGrid)
214 gSystem->Load("libSTEERBase");
215 gSystem->Load("libCDB");
216 gSystem->Load("libRAWDatabase");
217 gSystem->Load("libRAWDatarec");
218 gSystem->Load("libESD");
219 gSystem->Load("libAOD");
220 gSystem->Load("libSTEER");
221 gSystem->Load("libANALYSIS");
222 gSystem->Load("libANALYSISalice");
223 gSystem->Load("libTOFbase");
224 gSystem->Load("libTOFrec");
225 gSystem->Load("libTRDbase");
226 gSystem->Load("libVZERObase");
227 gSystem->Load("libVZEROrec");
228 gSystem->Load("libT0base");
229 gSystem->Load("libT0rec");
230 gSystem->Load("libTENDER");
231 gSystem->Load("libTENDERSupplies");
235 AliAnalysisAlien::SetupPar("PWG2flowCommon");
236 AliAnalysisAlien::SetupPar("PWG2flowTasks");
240 gSystem->Load("libPWG2flowCommon");
241 gSystem->Load("libPWG2flowTasks");
244 else if (mode==mPROOF)
246 TList* list = new TList();
247 list->Add(new TNamed("ALIROOT_MODE", "ALIROOT"));
249 list->Add(new TNamed("ALIROOT_EXTRA_LIBS", "ANALYSIS:ANALYSISalice:TENDER:TENDERSupplies"));
251 list->Add(new TNamed("ALIROOT_EXTRA_LIBS", "ANALYSIS:ANALYSISalice:TENDER:TENDERSupplies:PWG2flowCommon:PWG2flowTasks"));
253 //list->Add(new TNamed("ALIROOT_EXTRA_INCLUDES","PWG2/FLOW/AliFlowCommon:PWG2/FLOW/AliFlowTasks"));
256 printf("*** Connect to PROOF ***\n");
257 gEnv->SetValue("XSec.GSI.DelegProxy","2");
258 //TProof* proof = TProof::Open("alice-caf.cern.ch");
259 TProof* proof = TProof::Open("skaf.saske.sk");
261 // list the data available
262 //gProof->ShowDataSets("/*/*");
263 //gProof->ShowDataSets("/alice/sim/"); //for MC Data
264 //gProof->ShowDataSets("/alice/data/"); //for REAL Data
266 proof->ClearPackages();
267 proof->EnablePackage("VO_ALICE@AliRoot::v4-21-14-AN",list);
271 gProof->UploadPackage("PWG2flowCommon.par");
272 gProof->UploadPackage("PWG2flowTasks.par");
275 // Show enables Packages
276 gProof->ShowEnabledPackages();
278 } // end of void LoadLibraries(const anaModes mode)
280 //===============================================================================================
282 TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
284 // creates chain of files in a given directory or file containing a list.
285 // In case of directory the structure is expected as:
286 // <aDataDir>/<dir0>/AliAOD.root
287 // <aDataDir>/<dir1>/AliAOD.root
293 Long_t id, size, flags, modtime;
294 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
296 printf("%s not found.\n", aDataDir);
300 TChain* chain = new TChain("aodTree");
301 TChain* chaingAlice = 0;
305 TString execDir(gSystem->pwd());
306 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
307 TList* dirList = baseDir->GetListOfFiles();
308 Int_t nDirs = dirList->GetEntries();
309 gSystem->cd(execDir);
313 for (Int_t iDir=0; iDir<nDirs; ++iDir)
315 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
316 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
325 if (count++ == aRuns)
328 TString presentDirName(aDataDir);
329 presentDirName += "/";
330 presentDirName += presentDir->GetName();
331 chain->Add(presentDirName + "/AliAOD.root/aodTree");
332 // cerr<<presentDirName<<endl;
338 // Open the input stream
344 // Read the input list of files and add them to the chain
349 if (!aodfile.Contains("root")) continue; // protection
357 if (count++ == aRuns)
369 } // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)