1 enum anaModes {mLocal,mPROOF,mGrid};
2 Int_t binfirst = 0; //where do we start numbering bins
3 Int_t binlast = 8; //where do we stop numbering bins
4 const Int_t numberOfCentralityBins = 9;
5 Float_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
8 TString commonOutputFileName = "outputCentrality"; // e.g.: result for centrality bin 0 will be in the file "outputCentrality0.root", etc
10 void runFlowTaskCentralityPIDTrain( Int_t mode = mLocal,
11 Bool_t useFlowParFiles = kFALSE,
13 const Char_t* dataDir="fileList",
21 // Load needed libraries:
22 LoadLibraries(mode,useFlowParFiles);
24 // Create analysis manager:
25 AliAnalysisManager *mgr = new AliAnalysisManager("FlowAnalysisManager");
30 gROOT->LoadMacro("$ALICE_ROOT/PWGUD/macros/CreateESDChain.C");
31 TChain* chain = CreateESDChain(dataDir, nEvents, offset);
32 //TChain* chain = CreateAODChain(dataDir, nEvents, offset);
35 // Connect plug-in to the analysis manager:
38 gROOT->LoadMacro("CreateAlienHandler.C");
39 AliAnalysisGrid *alienHandler = CreateAlienHandler(useFlowParFiles);
40 if(!alienHandler) return;
41 mgr->SetGridHandler(alienHandler);
45 AliVEventHandler* esdH = new AliESDInputHandler;
46 mgr->SetInputEventHandler(esdH);
49 AliMCEventHandler *mc = new AliMCEventHandler();
50 mgr->SetMCtruthEventHandler(mc);
53 // Task to check the offline trigger:
54 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
55 AddTaskPhysicsSelection(!DATA);
57 //Add the centrality determination task
58 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
59 AliCentralitySelectionTask* centSelTask = AddTaskCentrality();
60 if (!DATA) centSelTask->SetMCInput();
62 //add the PID response task
63 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
64 AliAnalysisTaskPIDResponse* pidresponsetask = AddTaskPIDResponse(!DATA);
67 //gROOT->LoadMacro("$ALICE_ROOT/PWGCF/FLOW/macros/AddTaskTenderTOF.C");
70 // Setup analysis per centrality bin:
71 gROOT->LoadMacro("AddTaskFlowCentralityPID.C");
72 for (Int_t i=binfirst; i<binlast+1; i++)
74 Float_t lowCentralityBinEdge = centralityArray[i];
75 Float_t highCentralityBinEdge = centralityArray[i+1];
76 AddTaskFlowCentralityPID( lowCentralityBinEdge,
77 highCentralityBinEdge,
80 AliFlowTrackCuts::kTOFbeta,
82 AddTaskFlowCentralityPID( lowCentralityBinEdge,
83 highCentralityBinEdge,
86 AliFlowTrackCuts::kTOFbeta,
88 AddTaskFlowCentralityPID( lowCentralityBinEdge,
89 highCentralityBinEdge,
92 AliFlowTrackCuts::kTOFbeta,
94 AddTaskFlowCentralityPID( lowCentralityBinEdge,
95 highCentralityBinEdge,
98 AliFlowTrackCuts::kTOFbeta,
100 AddTaskFlowCentralityPID( lowCentralityBinEdge,
101 highCentralityBinEdge,
102 commonOutputFileName,
104 AliFlowTrackCuts::kTOFbeta,
106 AddTaskFlowCentralityPID( lowCentralityBinEdge,
107 highCentralityBinEdge,
108 commonOutputFileName,
110 AliFlowTrackCuts::kTOFbeta,
112 AddTaskFlowCentralityPID( lowCentralityBinEdge,
113 highCentralityBinEdge,
114 commonOutputFileName,
116 AliFlowTrackCuts::kTOFbeta,
118 AddTaskFlowCentralityPID( lowCentralityBinEdge,
119 highCentralityBinEdge,
120 commonOutputFileName,
122 AliFlowTrackCuts::kTOFbeta,
124 AddTaskFlowCentralityPID( lowCentralityBinEdge,
125 highCentralityBinEdge,
126 commonOutputFileName,
128 AliFlowTrackCuts::kTOFbeta,
130 AddTaskFlowCentralityPID( lowCentralityBinEdge,
131 highCentralityBinEdge,
132 commonOutputFileName,
134 AliFlowTrackCuts::kTOFbeta,
136 AddTaskFlowCentralityPID( lowCentralityBinEdge,
137 highCentralityBinEdge,
138 commonOutputFileName,
140 AliFlowTrackCuts::kTOFbeta,
142 AddTaskFlowCentralityPID( lowCentralityBinEdge,
143 highCentralityBinEdge,
144 commonOutputFileName,
146 AliFlowTrackCuts::kTOFbeta,
148 } // end of for (Int_t i=0; i<numberOfCentralityBins; i++)
150 // Enable debug printouts:
151 mgr->SetDebugLevel(2);
153 if(!mgr->InitAnalysis()) return;
157 mgr->StartAnalysis("local",chain);
159 else if(mode == mPROOF)
161 mgr->StartAnalysis("proof",dataDir,nEvents,offset);
163 else if(mode == mGrid)
165 mgr->StartAnalysis("grid");
168 // Print real and CPU time used for analysis:
172 } // end of void runFlowTaskCentralityPIDTrain(...)
174 //===============================================================================================
176 void CrossCheckUserSettings(Bool_t bData)
178 // Check in this method if the user settings make sense.
179 if(LYZ1SUM && LYZ2SUM) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
180 if(LYZ1PROD && LYZ2PROD) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
181 if(LYZ2SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
182 if(LYZ1SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
183 } // end of void CrossCheckUserSettings()
185 //===============================================================================================
187 void LoadLibraries(const anaModes mode, Bool_t useFlowParFiles )
189 //--------------------------------------
190 // Load the needed libraries most of them already loaded by aliroot
191 //--------------------------------------
193 gSystem->Load("libCore");
194 gSystem->Load("libTree");
195 gSystem->Load("libGeom");
196 gSystem->Load("libVMC");
197 gSystem->Load("libXMLIO");
198 gSystem->Load("libPhysics");
199 gSystem->Load("libXMLParser");
200 gSystem->Load("libProof");
201 gSystem->Load("libMinuit");
203 if (mode==mLocal || mode==mGrid)
205 gSystem->Load("libSTEERBase");
206 gSystem->Load("libCDB");
207 gSystem->Load("libRAWDatabase");
208 gSystem->Load("libRAWDatarec");
209 gSystem->Load("libESD");
210 gSystem->Load("libAOD");
211 gSystem->Load("libSTEER");
212 gSystem->Load("libANALYSIS");
213 gSystem->Load("libANALYSISalice");
214 gSystem->Load("libTPCbase");
215 gSystem->Load("libTOFbase");
216 gSystem->Load("libTOFrec");
217 gSystem->Load("libTRDbase");
218 gSystem->Load("libVZERObase");
219 gSystem->Load("libVZEROrec");
220 gSystem->Load("libT0base");
221 gSystem->Load("libT0rec");
222 gSystem->Load("libTENDER");
223 gSystem->Load("libTENDERSupplies");
227 AliAnalysisAlien::SetupPar("PWGflowBase");
228 AliAnalysisAlien::SetupPar("PWGflowTasks");
232 gSystem->Load("libPWGflowBase");
233 gSystem->Load("libPWGflowTasks");
236 else if (mode==mPROOF)
238 TList* list = new TList();
239 list->Add(new TNamed("ALIROOT_MODE", "ALIROOT"));
241 list->Add(new TNamed("ALIROOT_EXTRA_LIBS", "ANALYSIS:ANALYSISalice:TENDER:TENDERSupplies"));
243 list->Add(new TNamed("ALIROOT_EXTRA_LIBS", "ANALYSIS:ANALYSISalice:TENDER:TENDERSupplies:PWGflowBase:PWGflowTasks"));
245 //list->Add(new TNamed("ALIROOT_EXTRA_INCLUDES","PWG/FLOW/Base:PWG/FLOW/Tasks"));
248 printf("*** Connect to PROOF ***\n");
249 gEnv->SetValue("XSec.GSI.DelegProxy","2");
250 //TProof* proof = TProof::Open("alice-caf.cern.ch");
251 TProof* proof = TProof::Open("skaf.saske.sk");
253 // list the data available
254 //gProof->ShowDataSets("/*/*");
255 //gProof->ShowDataSets("/alice/sim/"); //for MC Data
256 //gProof->ShowDataSets("/alice/data/"); //for REAL Data
258 proof->ClearPackages();
259 proof->EnablePackage("VO_ALICE@AliRoot::v4-21-14-AN",list);
263 gProof->UploadPackage("PWGflowBase.par");
264 gProof->UploadPackage("PWGflowTasks.par");
267 // Show enables Packages
268 gProof->ShowEnabledPackages();
270 } // end of void LoadLibraries(const anaModes mode)
272 //===============================================================================================
274 TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
276 // creates chain of files in a given directory or file containing a list.
277 // In case of directory the structure is expected as:
278 // <aDataDir>/<dir0>/AliAOD.root
279 // <aDataDir>/<dir1>/AliAOD.root
285 Long_t id, size, flags, modtime;
286 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
288 printf("%s not found.\n", aDataDir);
292 TChain* chain = new TChain("aodTree");
293 TChain* chaingAlice = 0;
297 TString execDir(gSystem->pwd());
298 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
299 TList* dirList = baseDir->GetListOfFiles();
300 Int_t nDirs = dirList->GetEntries();
301 gSystem->cd(execDir);
305 for (Int_t iDir=0; iDir<nDirs; ++iDir)
307 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
308 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
317 if (count++ == aRuns)
320 TString presentDirName(aDataDir);
321 presentDirName += "/";
322 presentDirName += presentDir->GetName();
323 chain->Add(presentDirName + "/AliAOD.root/aodTree");
324 // cerr<<presentDirName<<endl;
330 // Open the input stream
336 // Read the input list of files and add them to the chain
341 if (!aodfile.Contains("root")) continue; // protection
349 if (count++ == aRuns)
361 } // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)