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
9 Int_t centralitysel = AliVEvent::kMB | AliVEvent::kCentral | AliVEvent::kSemiCentral;
11 void runFlowTaskCentralityPIDMHTrain( Int_t mode = mLocal,
12 Bool_t useFlowParFiles = kFALSE,
14 const Char_t* dataDir="fileList",
21 // Load needed libraries:
22 LoadLibraries(mode,useFlowParFiles);
24 // Create analysis manager:
25 AliAnalysisManager *mgr = new AliAnalysisManager("FlowAnalysisManager");
29 TChain *chain = new TChain("aodTree");
31 for(Int_t i = 1; i < 10; i++) {
32 filename = "/glusterfs/alice1/alice2/pchrist/HeavyIons/Data/2011/Set";
33 filename += i; filename += "/AliAOD.root";
34 chain->Add(filename.Data());
38 // Connect plug-in to the analysis manager:
41 gROOT->LoadMacro("CreateAlienHandler.C");
42 AliAnalysisGrid *alienHandler = CreateAlienHandler(useFlowParFiles);
43 if(!alienHandler) return;
44 mgr->SetGridHandler(alienHandler);
48 AliVEventHandler* aodH = new AliAODInputHandler;
49 mgr->SetInputEventHandler(aodH);
52 AliMCEventHandler *mc = new AliMCEventHandler();
53 mgr->SetMCtruthEventHandler(mc);
56 // Task to check the offline trigger:
57 //gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
58 //AddTaskPhysicsSelection(!DATA);
60 //Add the centrality determination task
61 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
62 AliCentralitySelectionTask* centSelTask = AddTaskCentrality();
63 if (!DATA) centSelTask->SetMCInput();
65 //add the PID response task
66 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPIDResponse.C");
67 AliAnalysisTaskPIDResponse* pidresponsetask = AddTaskPIDResponse(DATA);
70 //gROOT->LoadMacro("$ALICE_ROOT/PWGCF/FLOW/macros/AddTaskTenderTOF.C");
73 // Setup analysis per centrality bin:
74 //gROOT->LoadMacro("$ALICE_ROOT/PWGCF/FLOW/macros/AddTaskFlowCentralityPIDMH.C");
75 gROOT->LoadMacro("AddTaskFlowCentralityPIDMH.C");
76 for (Int_t i=binfirst; i<binlast+1; i++) {
77 Float_t lowCentralityBinEdge = centralityArray[i];
78 Float_t highCentralityBinEdge = centralityArray[i+1];
79 AddTaskFlowCentralityPIDMH(centralitysel,
81 highCentralityBinEdge,
84 AliFlowTrackCuts::kTOFbayesian,
88 commonOutputFileName);
89 } // end of for (Int_t i=0; i<numberOfCentralityBins; i++)
91 // Enable debug printouts:
92 mgr->SetDebugLevel(2);
94 if(!mgr->InitAnalysis()) return;
98 mgr->StartAnalysis("local",chain);
100 else if(mode == mPROOF)
102 mgr->StartAnalysis("proof",dataDir,nEvents,offset);
104 else if(mode == mGrid)
106 mgr->StartAnalysis("grid");
109 // Print real and CPU time used for analysis:
113 } // end of void runFlowTaskCentralityPIDTrain(...)
115 //===============================================================================================
117 void CrossCheckUserSettings(Bool_t bData)
119 // Check in this method if the user settings make sense.
120 if(LYZ1SUM && LYZ2SUM) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
121 if(LYZ1PROD && LYZ2PROD) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
122 if(LYZ2SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
123 if(LYZ1SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
124 } // end of void CrossCheckUserSettings()
126 //===============================================================================================
128 void LoadLibraries(const anaModes mode, Bool_t useFlowParFiles )
130 //--------------------------------------
131 // Load the needed libraries most of them already loaded by aliroot
132 //--------------------------------------
134 gSystem->Load("libCore");
135 gSystem->Load("libTree");
136 gSystem->Load("libGeom");
137 gSystem->Load("libVMC");
138 gSystem->Load("libXMLIO");
139 gSystem->Load("libPhysics");
140 gSystem->Load("libXMLParser");
141 gSystem->Load("libProof");
142 gSystem->Load("libMinuit");
144 if (mode==mLocal || mode==mGrid)
146 gSystem->Load("libSTEERBase");
147 gSystem->Load("libCDB");
148 gSystem->Load("libRAWDatabase");
149 gSystem->Load("libRAWDatarec");
150 gSystem->Load("libESD");
151 gSystem->Load("libAOD");
152 gSystem->Load("libSTEER");
153 gSystem->Load("libANALYSIS");
154 gSystem->Load("libANALYSISalice");
155 gSystem->Load("libTPCbase");
156 gSystem->Load("libTOFbase");
157 gSystem->Load("libTOFrec");
158 gSystem->Load("libTRDbase");
159 gSystem->Load("libVZERObase");
160 gSystem->Load("libVZEROrec");
161 gSystem->Load("libT0base");
162 gSystem->Load("libT0rec");
163 gSystem->Load("libTENDER");
164 gSystem->Load("libTENDERSupplies");
168 AliAnalysisAlien::SetupPar("PWGflowBase");
169 AliAnalysisAlien::SetupPar("PWGflowTasks");
173 gSystem->Load("libPWGflowBase");
174 gSystem->Load("libPWGflowTasks");
177 else if (mode==mPROOF)
179 TList* list = new TList();
180 list->Add(new TNamed("ALIROOT_MODE", "ALIROOT"));
182 list->Add(new TNamed("ALIROOT_EXTRA_LIBS", "ANALYSIS:ANALYSISalice:TENDER:TENDERSupplies"));
184 list->Add(new TNamed("ALIROOT_EXTRA_LIBS", "ANALYSIS:ANALYSISalice:TENDER:TENDERSupplies:PWGflowBase:PWGflowTasks"));
186 //list->Add(new TNamed("ALIROOT_EXTRA_INCLUDES","PWG/FLOW/Base:PWG/FLOW/Tasks"));
189 printf("*** Connect to PROOF ***\n");
190 gEnv->SetValue("XSec.GSI.DelegProxy","2");
191 //TProof* proof = TProof::Open("alice-caf.cern.ch");
192 TProof* proof = TProof::Open("skaf.saske.sk");
194 // list the data available
195 //gProof->ShowDataSets("/*/*");
196 //gProof->ShowDataSets("/alice/sim/"); //for MC Data
197 //gProof->ShowDataSets("/alice/data/"); //for REAL Data
199 proof->ClearPackages();
200 proof->EnablePackage("VO_ALICE@AliRoot::v4-21-14-AN",list);
204 gProof->UploadPackage("PWGflowBase.par");
205 gProof->UploadPackage("PWGflowTasks.par");
208 // Show enables Packages
209 gProof->ShowEnabledPackages();
211 } // end of void LoadLibraries(const anaModes mode)
213 //===============================================================================================
215 TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
217 // creates chain of files in a given directory or file containing a list.
218 // In case of directory the structure is expected as:
219 // <aDataDir>/<dir0>/AliAOD.root
220 // <aDataDir>/<dir1>/AliAOD.root
226 Long_t id, size, flags, modtime;
227 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
229 printf("%s not found.\n", aDataDir);
233 TChain* chain = new TChain("aodTree");
234 TChain* chaingAlice = 0;
238 TString execDir(gSystem->pwd());
239 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
240 TList* dirList = baseDir->GetListOfFiles();
241 Int_t nDirs = dirList->GetEntries();
242 gSystem->cd(execDir);
246 for (Int_t iDir=0; iDir<nDirs; ++iDir)
248 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
249 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
258 if (count++ == aRuns)
261 TString presentDirName(aDataDir);
262 presentDirName += "/";
263 presentDirName += presentDir->GetName();
264 chain->Add(presentDirName + "/AliAOD.root/aodTree");
265 // cerr<<presentDirName<<endl;
271 // Open the input stream
277 // Read the input list of files and add them to the chain
282 if (!aodfile.Contains("root")) continue; // protection
290 if (count++ == aRuns)
302 } // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)