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 = mGrid,
11 Bool_t useFlowParFiles = kTRUE,
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/PWG0/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();
61 if (DATA) centSelTask->SetPass(1);
63 //add the PID response task
64 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
65 AliAnalysisTaskPIDResponse* pidresponsetask = AddTaskPIDResponse(!DATA)
68 gROOT->LoadMacro("$ALICE_ROOT/PWG/FLOW/macros/AddTaskTenderTOF.C");
71 // Setup analysis per centrality bin:
72 gROOT->LoadMacro("AddTaskFlowCentralityPID.C");
73 for (Int_t i=binfirst; i<binlast+1; i++)
75 Float_t lowCentralityBinEdge = centralityArray[i];
76 Float_t highCentralityBinEdge = centralityArray[i+1];
77 AddTaskFlowCentralityPID( lowCentralityBinEdge,
78 highCentralityBinEdge,
81 AliFlowTrackCuts::kTOFbeta,
83 AddTaskFlowCentralityPID( lowCentralityBinEdge,
84 highCentralityBinEdge,
87 AliFlowTrackCuts::kTOFbeta,
89 AddTaskFlowCentralityPID( lowCentralityBinEdge,
90 highCentralityBinEdge,
93 AliFlowTrackCuts::kTOFbeta,
95 AddTaskFlowCentralityPID( lowCentralityBinEdge,
96 highCentralityBinEdge,
99 AliFlowTrackCuts::kTOFbeta,
101 AddTaskFlowCentralityPID( lowCentralityBinEdge,
102 highCentralityBinEdge,
103 commonOutputFileName,
105 AliFlowTrackCuts::kTOFbeta,
107 AddTaskFlowCentralityPID( lowCentralityBinEdge,
108 highCentralityBinEdge,
109 commonOutputFileName,
111 AliFlowTrackCuts::kTOFbeta,
113 AddTaskFlowCentralityPID( lowCentralityBinEdge,
114 highCentralityBinEdge,
115 commonOutputFileName,
117 AliFlowTrackCuts::kTOFbeta,
119 AddTaskFlowCentralityPID( lowCentralityBinEdge,
120 highCentralityBinEdge,
121 commonOutputFileName,
123 AliFlowTrackCuts::kTOFbeta,
125 AddTaskFlowCentralityPID( lowCentralityBinEdge,
126 highCentralityBinEdge,
127 commonOutputFileName,
129 AliFlowTrackCuts::kTOFbeta,
131 AddTaskFlowCentralityPID( lowCentralityBinEdge,
132 highCentralityBinEdge,
133 commonOutputFileName,
135 AliFlowTrackCuts::kTOFbeta,
137 AddTaskFlowCentralityPID( lowCentralityBinEdge,
138 highCentralityBinEdge,
139 commonOutputFileName,
141 AliFlowTrackCuts::kTOFbeta,
143 AddTaskFlowCentralityPID( lowCentralityBinEdge,
144 highCentralityBinEdge,
145 commonOutputFileName,
147 AliFlowTrackCuts::kTOFbeta,
149 } // end of for (Int_t i=0; i<numberOfCentralityBins; i++)
151 // Enable debug printouts:
152 mgr->SetDebugLevel(2);
154 if(!mgr->InitAnalysis()) return;
158 mgr->StartAnalysis("local",chain);
160 else if(mode == mPROOF)
162 mgr->StartAnalysis("proof",dataDir,nEvents,offset);
164 else if(mode == mGrid)
166 mgr->StartAnalysis("grid");
169 // Print real and CPU time used for analysis:
173 } // end of void runFlowTaskCentralityPIDTrain(...)
175 //===============================================================================================
177 void CrossCheckUserSettings(Bool_t bData)
179 // Check in this method if the user settings make sense.
180 if(LYZ1SUM && LYZ2SUM) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
181 if(LYZ1PROD && LYZ2PROD) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
182 if(LYZ2SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
183 if(LYZ1SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
184 } // end of void CrossCheckUserSettings()
186 //===============================================================================================
188 void LoadLibraries(const anaModes mode, Bool_t useFlowParFiles )
190 //--------------------------------------
191 // Load the needed libraries most of them already loaded by aliroot
192 //--------------------------------------
194 gSystem->Load("libCore");
195 gSystem->Load("libTree");
196 gSystem->Load("libGeom");
197 gSystem->Load("libVMC");
198 gSystem->Load("libXMLIO");
199 gSystem->Load("libPhysics");
200 gSystem->Load("libXMLParser");
201 gSystem->Load("libProof");
202 gSystem->Load("libMinuit");
204 if (mode==mLocal || mode==mGrid)
206 gSystem->Load("libSTEERBase");
207 gSystem->Load("libCDB");
208 gSystem->Load("libRAWDatabase");
209 gSystem->Load("libRAWDatarec");
210 gSystem->Load("libESD");
211 gSystem->Load("libAOD");
212 gSystem->Load("libSTEER");
213 gSystem->Load("libANALYSIS");
214 gSystem->Load("libANALYSISalice");
215 gSystem->Load("libTPCbase");
216 gSystem->Load("libTOFbase");
217 gSystem->Load("libTOFrec");
218 gSystem->Load("libTRDbase");
219 gSystem->Load("libVZERObase");
220 gSystem->Load("libVZEROrec");
221 gSystem->Load("libT0base");
222 gSystem->Load("libT0rec");
223 gSystem->Load("libTENDER");
224 gSystem->Load("libTENDERSupplies");
228 AliAnalysisAlien::SetupPar("PWGflowBase");
229 AliAnalysisAlien::SetupPar("PWGflowTasks");
233 gSystem->Load("libPWGflowBase");
234 gSystem->Load("libPWGflowTasks");
237 else if (mode==mPROOF)
239 TList* list = new TList();
240 list->Add(new TNamed("ALIROOT_MODE", "ALIROOT"));
242 list->Add(new TNamed("ALIROOT_EXTRA_LIBS", "ANALYSIS:ANALYSISalice:TENDER:TENDERSupplies"));
244 list->Add(new TNamed("ALIROOT_EXTRA_LIBS", "ANALYSIS:ANALYSISalice:TENDER:TENDERSupplies:PWGflowBase:PWGflowTasks"));
246 //list->Add(new TNamed("ALIROOT_EXTRA_INCLUDES","PWG/FLOW/Base:PWG/FLOW/Tasks"));
249 printf("*** Connect to PROOF ***\n");
250 gEnv->SetValue("XSec.GSI.DelegProxy","2");
251 //TProof* proof = TProof::Open("alice-caf.cern.ch");
252 TProof* proof = TProof::Open("skaf.saske.sk");
254 // list the data available
255 //gProof->ShowDataSets("/*/*");
256 //gProof->ShowDataSets("/alice/sim/"); //for MC Data
257 //gProof->ShowDataSets("/alice/data/"); //for REAL Data
259 proof->ClearPackages();
260 proof->EnablePackage("VO_ALICE@AliRoot::v4-21-14-AN",list);
264 gProof->UploadPackage("PWGflowBase.par");
265 gProof->UploadPackage("PWGflowTasks.par");
268 // Show enables Packages
269 gProof->ShowEnabledPackages();
271 } // end of void LoadLibraries(const anaModes mode)
273 //===============================================================================================
275 TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
277 // creates chain of files in a given directory or file containing a list.
278 // In case of directory the structure is expected as:
279 // <aDataDir>/<dir0>/AliAOD.root
280 // <aDataDir>/<dir1>/AliAOD.root
286 Long_t id, size, flags, modtime;
287 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
289 printf("%s not found.\n", aDataDir);
293 TChain* chain = new TChain("aodTree");
294 TChain* chaingAlice = 0;
298 TString execDir(gSystem->pwd());
299 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
300 TList* dirList = baseDir->GetListOfFiles();
301 Int_t nDirs = dirList->GetEntries();
302 gSystem->cd(execDir);
306 for (Int_t iDir=0; iDir<nDirs; ++iDir)
308 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
309 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
318 if (count++ == aRuns)
321 TString presentDirName(aDataDir);
322 presentDirName += "/";
323 presentDirName += presentDir->GetName();
324 chain->Add(presentDirName + "/AliAOD.root/aodTree");
325 // cerr<<presentDirName<<endl;
331 // Open the input stream
337 // Read the input list of files and add them to the chain
342 if (!aodfile.Contains("root")) continue; // protection
350 if (count++ == aRuns)
362 } // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)