1 enum anaModes {mLocal,mLocalPAR,mPROOF,mGRID};
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
8 // Flow analysis method can be:(set to kTRUE or kFALSE)
10 Bool_t LYZ1SUM = kTRUE;
11 Bool_t LYZ1PROD = kTRUE;
12 Bool_t LYZ2SUM = kFALSE;
13 Bool_t LYZ2PROD = kFALSE;
14 Bool_t LYZEP = kFALSE;
18 Bool_t MCEP = kFALSE; //not for pp
20 Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP};
22 // Analysis type can be ESD, AOD, MC, ESDMC0, ESDMC1
23 const TString type = "ESD";
25 // Boolean to fill/not fill the QA histograms
28 // Boolean to use/not use weights for the Q vector
29 Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)
32 void runFlowTask(Int_t mode=mLocal, Int_t nRuns = 40,
33 //const Char_t* dataDir="/data/alice2/kolk/PP/LHC09a4/81119", Int_t offset = 0)
34 const Char_t* dataDir="/data/alice2/kolk/Therminator_midcentral", Int_t offset = 0)
35 //void runFlowTask(Int_t mode=mPROOF, Int_t nRuns = 10000,
36 // const Char_t* dataDir="/COMMON/COMMON/LHC09a4_run8158X", Int_t offset = 0)
37 //const Char_t* dataDir="/PWG2/akisiel/Therminator_c2030", Int_t offset=0)
44 if (mode==mLocal || mode == mLocalPAR || mode == mGRID) {
45 if (type!="AOD") { TChain* chain = CreateESDChain(dataDir, nRuns, offset);}
46 else { TChain* chain = CreateAODChain(dataDir, nRuns, offset);}
48 //____________________________________________//
49 // Make the analysis manager
50 AliAnalysisManager *mgr = new AliAnalysisManager("FlowAnalysisManager");
53 AliVEventHandler* esdH = new AliESDInputHandler;
54 mgr->SetInputEventHandler(esdH);
58 AliVEventHandler* aodH = new AliAODInputHandler;
59 mgr->SetInputEventHandler(aodH);
62 if (type == "MC" || type == "ESDMC0" || type == "ESDMC1"){
63 AliVEventHandler* esdH = new AliESDInputHandler;
64 mgr->SetInputEventHandler(esdH);
66 AliMCEventHandler *mc = new AliMCEventHandler();
67 mgr->SetMCtruthEventHandler(mc); }
70 //____________________________________________//
72 gROOT->LoadMacro("AddTaskFlow.C");
73 AliAnalysisTaskFlowEvent* taskFE = AddTaskFlow(type,METHODS,QA,WEIGHTS);
75 //____________________________________________//
77 if (!mgr->InitAnalysis()) return;
80 if (mode==mLocal || mode == mLocalPAR) {
81 mgr->StartAnalysis("local",chain);
83 else if (mode==mPROOF) {
84 mgr->StartAnalysis("proof",dataDir,nRuns,offset);
86 else if (mode==mGRID) {
87 mgr->StartAnalysis("local",chain);
96 void LoadLibraries(const anaModes mode) {
98 //--------------------------------------
99 // Load the needed libraries most of them already loaded by aliroot
100 //--------------------------------------
101 gSystem->Load("libTree.so");
102 gSystem->Load("libGeom.so");
103 gSystem->Load("libVMC.so");
104 gSystem->Load("libXMLIO.so");
105 gSystem->Load("libPhysics.so");
107 //----------------------------------------------------------
108 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
109 //----------------------------------------------------------
111 //--------------------------------------------------------
112 // If you want to use already compiled libraries
113 // in the aliroot distribution
114 //--------------------------------------------------------
115 gSystem->Load("libSTEERBase");
116 gSystem->Load("libESD");
117 gSystem->Load("libAOD");
118 gSystem->Load("libANALYSIS");
119 gSystem->Load("libANALYSISalice");
120 gSystem->Load("libCORRFW.so");
121 cerr<<"libCORRFW.so loaded..."<<endl;
122 gSystem->Load("libPWG2flowCommon.so");
123 cerr<<"libPWG2flowCommon.so loaded..."<<endl;
124 gSystem->Load("libPWG2flowTasks.so");
125 cerr<<"libPWG2flowTasks.so loaded..."<<endl;
128 else if (mode == mLocalPAR || mode == mGRID) {
129 //--------------------------------------------------------
130 //If you want to use root and par files from aliroot
131 //--------------------------------------------------------
132 SetupPar("STEERBase");
135 SetupPar("ANALYSIS");
136 SetupPar("ANALYSISalice");
139 SetupPar("PWG2flowCommon");
140 cerr<<"PWG2flowCommon.par loaded..."<<endl;
141 SetupPar("PWG2flowTasks");
142 cerr<<"PWG2flowTasks.par loaded..."<<endl;
145 //---------------------------------------------------------
146 // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
147 //---------------------------------------------------------
148 else if (mode==mPROOF) {
151 // set to debug root versus if needed
152 // TProof::Mgr("alicecaf")->SetROOTVersion("v5-21-01-alice_dbg");
153 // TProof::Mgr("alicecaf")->SetROOTVersion("v5-21-01-alice");
156 // Put appropriate username here
157 // TProof::Reset("proof://snelling@alicecaf.cern.ch");
158 printf("*** Connect to PROOF ***\n");
159 // TProof::Open("abilandz@alicecaf.cern.ch");
160 // TProof::Open("nkolk@alicecaf.cern.ch");
161 TProof::Open("snelling@localhost");
163 // Enable the STEERBase Package
164 // gProof->ClearPackage("STEERBase.par");
165 gProof->UploadPackage("STEERBase.par");
166 gProof->EnablePackage("STEERBase");
167 // Enable the ESD Package
168 // gProof->ClearPackage("ESD.par");
169 gProof->UploadPackage("ESD.par");
170 gProof->EnablePackage("ESD");
171 // Enable the AOD Package
172 // gProof->ClearPackage("AOD.par");
173 gProof->UploadPackage("AOD.par");
174 gProof->EnablePackage("AOD");
175 // Enable the Analysis Package
176 // gProof->ClearPackage("ANALYSIS.par");
177 gProof->UploadPackage("ANALYSIS.par");
178 gProof->EnablePackage("ANALYSIS");
179 // Enable the Analysis Package alice
180 // gProof->ClearPackage("ANALYSISalice.par");
181 gProof->UploadPackage("ANALYSISalice.par");
182 gProof->EnablePackage("ANALYSISalice");
184 // gProof->ClearPackage("PWG2AOD.par");
185 gProof->UploadPackage("PWG2AOD.par");
186 gProof->EnablePackage("PWG2AOD");
187 // Enable the Correction Framework
188 // gProof->ClearPackage("CORRFW.par");
189 gProof->UploadPackage("CORRFW.par");
190 gProof->EnablePackage("CORRFW");
191 // Enable Flow Analysis
192 // gProof->ClearPackage("PWG2flowCommon");
193 gProof->UploadPackage("PWG2flowCommon.par");
194 gProof->EnablePackage("PWG2flowCommon");
195 // gProof->ClearPackage("PWG2flowTasks");
196 gProof->UploadPackage("PWG2flowTasks.par");
197 gProof->EnablePackage("PWG2flowTasks");
199 gProof->ShowEnabledPackages();
204 void SetupPar(char* pararchivename) {
205 //Load par files, create analysis libraries
206 //For testing, if par file already decompressed and modified
207 //classes then do not decompress.
209 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
210 TString parpar(Form("%s.par", pararchivename)) ;
211 if ( gSystem->AccessPathName(parpar.Data()) ) {
212 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
213 TString processline(Form(".! make %s", parpar.Data())) ;
214 gROOT->ProcessLine(processline.Data()) ;
215 gSystem->ChangeDirectory(cdir) ;
216 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
217 gROOT->ProcessLine(processline.Data()) ;
219 if ( gSystem->AccessPathName(pararchivename) ) {
220 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
221 gROOT->ProcessLine(processline.Data());
224 TString ocwd = gSystem->WorkingDirectory();
225 gSystem->ChangeDirectory(pararchivename);
227 // check for BUILD.sh and execute
228 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
229 printf("*******************************\n");
230 printf("*** Building PAR archive ***\n");
231 cout<<pararchivename<<endl;
232 printf("*******************************\n");
233 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
234 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
238 // check for SETUP.C and execute
239 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
240 printf("*******************************\n");
241 printf("*** Setup PAR archive ***\n");
242 cout<<pararchivename<<endl;
243 printf("*******************************\n");
244 gROOT->Macro("PROOF-INF/SETUP.C");
247 gSystem->ChangeDirectory(ocwd.Data());
248 printf("Current dir: %s\n", ocwd.Data());
252 // Helper macros for creating chains
253 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
255 TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
257 // creates chain of files in a given directory or file containing a list.
258 // In case of directory the structure is expected as:
259 // <aDataDir>/<dir0>/AliESDs.root
260 // <aDataDir>/<dir1>/AliESDs.root
266 Long_t id, size, flags, modtime;
267 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
269 printf("%s not found.\n", aDataDir);
273 TChain* chain = new TChain("esdTree");
274 TChain* chaingAlice = 0;
278 TString execDir(gSystem->pwd());
279 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
280 TList* dirList = baseDir->GetListOfFiles();
281 Int_t nDirs = dirList->GetEntries();
282 gSystem->cd(execDir);
286 for (Int_t iDir=0; iDir<nDirs; ++iDir)
288 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
289 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
298 if (count++ == aRuns)
301 TString presentDirName(aDataDir);
302 presentDirName += "/";
303 presentDirName += presentDir->GetName();
304 chain->Add(presentDirName + "/AliESDs.root/esdTree");
305 // cerr<<presentDirName<<endl;
311 // Open the input stream
317 // Read the input list of files and add them to the chain
321 if (!esdfile.Contains("root")) continue; // protection
329 if (count++ == aRuns)
343 // Helper macros for creating chains
344 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
346 TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
348 // creates chain of files in a given directory or file containing a list.
349 // In case of directory the structure is expected as:
350 // <aDataDir>/<dir0>/AliAOD.root
351 // <aDataDir>/<dir1>/AliAOD.root
357 Long_t id, size, flags, modtime;
358 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
360 printf("%s not found.\n", aDataDir);
364 TChain* chain = new TChain("aodTree");
365 TChain* chaingAlice = 0;
369 TString execDir(gSystem->pwd());
370 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
371 TList* dirList = baseDir->GetListOfFiles();
372 Int_t nDirs = dirList->GetEntries();
373 gSystem->cd(execDir);
377 for (Int_t iDir=0; iDir<nDirs; ++iDir)
379 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
380 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
389 if (count++ == aRuns)
392 TString presentDirName(aDataDir);
393 presentDirName += "/";
394 presentDirName += presentDir->GetName();
395 chain->Add(presentDirName + "/AliAOD.root/aodTree");
396 // cerr<<presentDirName<<endl;
402 // Open the input stream
408 // Read the input list of files and add them to the chain
412 if (!aodfile.Contains("root")) continue; // protection
420 if (count++ == aRuns)