1 enum anaModes {mLocal,mLocalPAR,mPROOF,mGrid,mGridPAR};
2 //mLocal: Analyze locally files in your computer using aliroot
3 //mLocalPAR: Analyze locally files in your computer using root + PAR files
4 //mPROOF: Analyze CAF files with PROOF
5 //mGrid: Analyze files on Grid via AliEn plug-in and using precompiled FLOW libraries
6 // (Remark: When using this mode set also Bool_t bUseParFiles = kFALSE; in CreateAlienHandler.C)
7 //mGridPAR: Analyze files on Grid via AliEn plug-in and using par files for FLOW package
8 // (Remark: when using this mode set also Bool_t bUseParFiles = kTRUE; in CreateAlienHandler.C)
10 // CENTRALITY DEFINITION
11 //Int_t binfirst = 4; //where do we start numbering bins
12 //Int_t binlast = 6; //where do we stop numbering bins
13 //const Int_t numberOfCentralityBins = 9;
14 Int_t binfirst = 0; //where do we start numbering bins
15 Int_t binlast = 8; //where do we stop numbering bins
16 const Int_t numberOfCentralityBins = 9;
17 Float_t centralityArray[numberOfCentralityBins+1] = {0.,5.,10.,20.,30.,40.,50.,60.,70.,80.}; // in centrality percentile
18 //Int_t centralityArray[numberOfCentralityBins+1] = {41,80,146,245,384,576,835,1203,1471,10000}; // in terms of TPC only reference multiplicity
20 TString commonOutputFileName = "outputCentrality"; // e.g.: result for centrality bin 0 will be in the file "outputCentrality0.root", etc
23 //void runFlowTaskCentralityTrain(Int_t mode=mLocal, Int_t nRuns = 10,
24 //Bool_t DATA = kFALSE, const Char_t* dataDir="/Users/snelling/alice_data/Therminator_midcentral", Int_t offset = 0)
26 void runFlowTaskCentralityTrain4Candidates(Int_t mode = mGridPAR, Int_t nRuns = 50000000,
27 Bool_t DATA = kTRUE, const Char_t* dataDir="/alice/data/LHC10h_000137161_p1_plusplusplus", Int_t offset=0)
28 //void runFlowTaskCentralityTrain4Candidates(Int_t mode = mLocal, Int_t nRuns = 50000000,
29 // Bool_t DATA = kTRUE, const Char_t* dataDir="./data/", Int_t offset=0)
30 //void runFlowTaskCentralityTrain(Int_t mode = mGridPAR, Bool_t DATA = kTRUE)
35 // Cross-check user settings before starting:
36 // CrossCheckUserSettings(DATA);
37 // Load needed libraries:
39 // Create and configure the AliEn plug-in:
40 if(mode == mGrid || mode == mGridPAR)
42 gROOT->LoadMacro("CreateAlienHandler.C");
43 AliAnalysisGrid *alienHandler = CreateAlienHandler();
44 if(!alienHandler) return;
47 if(mode == mLocal || mode == mLocalPAR) {
48 // TChain* chain = CreateESDChain(dataDir, nRuns, offset);
49 TChain* chain = new TChain();
50 chain->Add("~/alice/datasets/Pb/AliESDs.root/esdTree");
51 //TChain* chain = CreateAODChain(dataDir, nRuns, offset);
54 // Create analysis manager:
55 AliAnalysisManager *mgr = new AliAnalysisManager("FlowAnalysisManager");
56 // Connect plug-in to the analysis manager:
57 if(mode == mGrid || mode == mGridPAR)
59 mgr->SetGridHandler(alienHandler);
63 AliVEventHandler* esdH = new AliESDInputHandler;
64 mgr->SetInputEventHandler(esdH);
66 AliMCEventHandler *mc = new AliMCEventHandler();
67 mgr->SetMCtruthEventHandler(mc);
70 // Task to check the offline trigger:
71 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
72 AddTaskPhysicsSelection(!DATA);
74 //Add the centrality determination task
75 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskCentrality.C");
78 // Setup analysis per centrality bin:
79 gROOT->LoadMacro("AddTaskFlowCentrality4Candidates.C");
80 for (Int_t i=binfirst; i<binlast+1; i++)
82 Float_t lowCentralityBinEdge = centralityArray[i];
83 Float_t highCentralityBinEdge = centralityArray[i+1];
84 Printf("\nWagon for centrality bin %i: %.0f-%.0f",i,lowCentralityBinEdge,highCentralityBinEdge);
85 AddTaskFlowCentrality4Candidates( lowCentralityBinEdge,
86 highCentralityBinEdge,
89 AddTaskFlowCentrality4Candidates( lowCentralityBinEdge,
90 highCentralityBinEdge,
93 AddTaskFlowCentrality4Candidates( lowCentralityBinEdge,
94 highCentralityBinEdge,
97 } // end of for (Int_t i=0; i<numberOfCentralityBins; i++)
99 // Enable debug printouts:
100 mgr->SetDebugLevel(2);
102 if(!mgr->InitAnalysis()) return;
104 if(mode == mLocal || mode == mLocalPAR) {
105 mgr->StartAnalysis("local",chain);
106 } else if(mode == mPROOF) {
107 mgr->StartAnalysis("proof",dataDir,nRuns,offset);
108 } else if(mode == mGrid || mode == mGridPAR) {
109 mgr->StartAnalysis("grid");
112 // Print real and CPU time used for analysis:
116 } // end of void runFlowTaskCentralityTrain(...)
118 //===============================================================================================
120 void CrossCheckUserSettings(Bool_t bData)
122 // Check in this method if the user settings make sense.
123 if(LYZ1SUM && LYZ2SUM) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
124 if(LYZ1PROD && LYZ2PROD) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
125 if(LYZ2SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
126 if(LYZ1SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
127 } // end of void CrossCheckUserSettings()
129 //===============================================================================================
131 void LoadLibraries(const anaModes mode)
133 //--------------------------------------
134 // Load the needed libraries most of them already loaded by aliroot
135 //--------------------------------------
137 gSystem->Load("libCore");
138 gSystem->Load("libTree");
139 gSystem->Load("libGeom");
140 gSystem->Load("libVMC");
141 gSystem->Load("libXMLIO");
142 gSystem->Load("libPhysics");
143 gSystem->Load("libXMLParser");
144 gSystem->Load("libProof");
146 if (mode==mLocal || mode==mGrid || mode == mGridPAR || mode == mLocalPAR )
148 gSystem->Load("libSTEERBase");
149 gSystem->Load("libCDB");
150 gSystem->Load("libRAWDatabase");
151 gSystem->Load("libRAWDatarec");
152 gSystem->Load("libESD");
153 gSystem->Load("libAOD");
154 gSystem->Load("libSTEER");
155 gSystem->Load("libANALYSIS");
156 gSystem->Load("libANALYSISalice");
157 gSystem->Load("libTOFbase");
158 gSystem->Load("libTOFrec");
160 if (mode == mLocal || mode == mGrid)
162 gSystem->Load("libPWGflowBase");
163 gSystem->Load("libPWGflowTasks");
165 if (mode == mLocalPAR || mode == mGridPAR )
167 AliAnalysisAlien::SetupPar("PWGflowBase");
168 AliAnalysisAlien::SetupPar("PWGflowTasks");
172 //---------------------------------------------------------
173 // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
174 //---------------------------------------------------------
175 else if (mode==mPROOF) {
176 // set to debug root versus if needed
177 //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a_dbg");
178 //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a");
179 //TProof::Reset("proof://snelling@alicecaf.cern.ch");
181 printf("*** Connect to PROOF ***\n");
182 gEnv->SetValue("XSec.GSI.DelegProxy","2");
183 TProof::Open("mkrzewic@alice-caf.cern.ch");
184 //TProof::Open("mkrzewic@skaf.saske.sk");
185 // list the data available
186 //gProof->ShowDataSets("/*/*");
187 //gProof->ShowDataSets("/alice/sim/"); //for MC Data
188 //gProof->ShowDataSets("/alice/data/"); //for REAL Data
190 // Clear the Packages
192 gProof->ClearPackage("STEERBase.par");
193 gProof->ClearPackage("ESD.par");
194 gProof->ClearPackage("AOD.par");
196 //gProof->ClearPackage("ANALYSIS.par");
197 //gProof->ClearPackage("ANALYSISalice.par");
198 //gProof->ClearPackage("CORRFW.par");
200 gProof->ClearPackage("PWGflowBase");
201 gProof->ClearPackage("PWGflowTasks");
203 // Upload the Packages
204 //gProof->UploadPackage("STEERBase.par");
205 //gProof->UploadPackage("ESD.par");
206 //gProof->UploadPackage("AOD.par");
208 //gProof->UploadPackage("ANALYSIS.par");
209 //gProof->UploadPackage("ANALYSISalice.par");
210 gProof->UploadPackage("CORRFW.par");
211 gProof->UploadPackage("PWGflowBase.par");
212 gProof->UploadPackage("PWGflowTasks.par");
213 gProof->UploadPackage("ALIRECO.par");
215 // Enable the Packages
216 // The global package
217 TList* list = new TList();
218 list->Add(new TNamed("ALIROOT_EXTRA_INCLUDES","RAW:OCDB:STEER:TOF"));
219 gProof->EnablePackage("VO_ALICE@AliRoot::v4-21-07-AN",list);
220 gProof->EnablePackage("ALIRECO");
221 //gProof->EnablePackage("ANALYSIS");
222 //gProof->EnablePackage("ANALYSISalice");
223 //gProof->EnablePackage("CORRFW");
224 gProof->EnablePackage("PWGflowBase");
225 gProof->EnablePackage("PWGflowTasks");
227 // Show enables Packages
228 gProof->ShowEnabledPackages();
231 } // end of void LoadLibraries(const anaModes mode)
233 // Helper macros for creating chains
234 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
236 TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
238 // creates chain of files in a given directory or file containing a list.
239 // In case of directory the structure is expected as:
240 // <aDataDir>/<dir0>/AliESDs.root
241 // <aDataDir>/<dir1>/AliESDs.root
247 Long_t id, size, flags, modtime;
248 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
250 printf("%s not found.\n", aDataDir);
254 TChain* chain = new TChain("esdTree");
255 TChain* chaingAlice = 0;
259 TString execDir(gSystem->pwd());
260 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
261 TList* dirList = baseDir->GetListOfFiles();
262 Int_t nDirs = dirList->GetEntries();
263 gSystem->cd(execDir);
267 for (Int_t iDir=0; iDir<nDirs; ++iDir)
269 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
270 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
279 if (count++ == aRuns)
282 TString presentDirName(aDataDir);
283 presentDirName += "/";
284 presentDirName += presentDir->GetName();
285 chain->Add(presentDirName + "/AliESDs.root/esdTree");
286 // cerr<<presentDirName<<endl;
292 // Open the input stream
298 // Read the input list of files and add them to the chain
302 if (!esdfile.Contains("root")) continue; // protection
310 if (count++ == aRuns)
322 } // end of TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
324 //===============================================================================================
326 TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
328 // creates chain of files in a given directory or file containing a list.
329 // In case of directory the structure is expected as:
330 // <aDataDir>/<dir0>/AliAOD.root
331 // <aDataDir>/<dir1>/AliAOD.root
337 Long_t id, size, flags, modtime;
338 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
340 printf("%s not found.\n", aDataDir);
344 TChain* chain = new TChain("aodTree");
345 TChain* chaingAlice = 0;
349 TString execDir(gSystem->pwd());
350 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
351 TList* dirList = baseDir->GetListOfFiles();
352 Int_t nDirs = dirList->GetEntries();
353 gSystem->cd(execDir);
357 for (Int_t iDir=0; iDir<nDirs; ++iDir)
359 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
360 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
369 if (count++ == aRuns)
372 TString presentDirName(aDataDir);
373 presentDirName += "/";
374 presentDirName += presentDir->GetName();
375 chain->Add(presentDirName + "/AliAOD.root/aodTree");
376 // cerr<<presentDirName<<endl;
382 // Open the input stream
388 // Read the input list of files and add them to the chain
392 if (!aodfile.Contains("root")) continue; // protection
400 if (count++ == aRuns)
412 } // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)