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 = kTRUE; //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 = 100,
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 //const Char_t* dataDir="/Users/snelling/alice_data/Therminator_midcentral", Int_t offset = 0)
36 void runFlowTask(Int_t mode=mPROOF, Int_t nRuns = 1000000,
37 //const Char_t* dataDir="/COMMON/COMMON/LHC09a14_0.9TeV_0.5T", Int_t offset = 0)
38 //const Char_t* dataDir="/COMMON/COMMON/LHC08c11_10TeV_0.5T", Int_t offset = 0)
39 //const Char_t* dataDir="/PWG2/akisiel/Therminator_midcentral_ESD", Int_t offset=0)
40 const Char_t* dataDir="/COMMON/COMMON/LHC09a4_run8101X", Int_t offset = 0)
49 if (mode==mLocal || mode == mLocalPAR || mode == mGRID) {
50 if (type!="AOD") { TChain* chain = CreateESDChain(dataDir, nRuns, offset);}
51 else { TChain* chain = CreateAODChain(dataDir, nRuns, offset);}
53 //____________________________________________//
54 // Make the analysis manager
55 AliAnalysisManager *mgr = new AliAnalysisManager("FlowAnalysisManager");
58 AliVEventHandler* esdH = new AliESDInputHandler;
59 mgr->SetInputEventHandler(esdH);
61 AliMCEventHandler *mc = new AliMCEventHandler();
62 mgr->SetMCtruthEventHandler(mc);
66 AliVEventHandler* aodH = new AliAODInputHandler;
67 mgr->SetInputEventHandler(aodH);
69 AliMCEventHandler *mc = new AliMCEventHandler();
70 mgr->SetMCtruthEventHandler(mc);
73 if (type == "MC" || type == "ESDMC0" || type == "ESDMC1"){
74 AliVEventHandler* esdH = new AliESDInputHandler;
75 mgr->SetInputEventHandler(esdH);
77 AliMCEventHandler *mc = new AliMCEventHandler();
78 mgr->SetMCtruthEventHandler(mc);
82 //____________________________________________//
84 gROOT->LoadMacro("AddTaskFlow.C");
85 AliAnalysisTaskFlowEvent* taskFE = AddTaskFlow(type,METHODS,QA,WEIGHTS);
87 //____________________________________________//
89 if (!mgr->InitAnalysis()) return;
92 if (mode==mLocal || mode == mLocalPAR) {
93 mgr->StartAnalysis("local",chain);
95 else if (mode==mPROOF) {
96 mgr->StartAnalysis("proof",dataDir,nRuns,offset);
98 else if (mode==mGRID) {
99 mgr->StartAnalysis("local",chain);
108 void LoadLibraries(const anaModes mode) {
110 //--------------------------------------
111 // Load the needed libraries most of them already loaded by aliroot
112 //--------------------------------------
113 gSystem->Load("libTree.so");
114 gSystem->Load("libGeom.so");
115 gSystem->Load("libVMC.so");
116 gSystem->Load("libXMLIO.so");
117 gSystem->Load("libPhysics.so");
119 //----------------------------------------------------------
120 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
121 //----------------------------------------------------------
123 //--------------------------------------------------------
124 // If you want to use already compiled libraries
125 // in the aliroot distribution
126 //--------------------------------------------------------
127 gSystem->Load("libSTEERBase");
128 gSystem->Load("libESD");
129 gSystem->Load("libAOD");
130 gSystem->Load("libANALYSIS");
131 gSystem->Load("libANALYSISalice");
132 gSystem->Load("libCORRFW.so");
133 cerr<<"libCORRFW.so loaded..."<<endl;
134 gSystem->Load("libPWG2flowCommon.so");
135 cerr<<"libPWG2flowCommon.so loaded..."<<endl;
136 gSystem->Load("libPWG2flowTasks.so");
137 cerr<<"libPWG2flowTasks.so loaded..."<<endl;
140 else if (mode == mLocalPAR || mode == mGRID) {
141 //--------------------------------------------------------
142 //If you want to use root and par files from aliroot
143 //--------------------------------------------------------
144 SetupPar("STEERBase");
147 SetupPar("ANALYSIS");
148 SetupPar("ANALYSISalice");
151 SetupPar("PWG2flowCommon");
152 cerr<<"PWG2flowCommon.par loaded..."<<endl;
153 SetupPar("PWG2flowTasks");
154 cerr<<"PWG2flowTasks.par loaded..."<<endl;
157 //---------------------------------------------------------
158 // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
159 //---------------------------------------------------------
160 else if (mode==mPROOF) {
163 // set to debug root versus if needed
164 //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a_dbg");
165 //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a");
167 //TProof::Reset("proof://snelling@alicecaf.cern.ch");
169 printf("*** Connect to PROOF ***\n");
170 // Put appropriate username here
171 //TProof::Open("abilandz@alicecaf.cern.ch");
172 //TProof::Open("nkolk@alicecaf.cern.ch");
173 TProof::Open("snelling@localhost");
174 // list the data available
175 //gProof->ShowDataSets("/*/*");
177 // Clear the Packages
178 gProof->ClearPackage("STEERBase.par");
179 gProof->ClearPackage("ESD.par");
180 gProof->ClearPackage("AOD.par");
181 gProof->ClearPackage("ANALYSIS.par");
182 gProof->ClearPackage("ANALYSISalice.par");
183 gProof->ClearPackage("PWG2AOD.par");
184 gProof->ClearPackage("CORRFW.par");
185 gProof->ClearPackage("PWG2flowCommon");
186 gProof->ClearPackage("PWG2flowTasks");
189 // Upload the Packages
190 gProof->UploadPackage("STEERBase.par");
191 gProof->UploadPackage("ESD.par");
192 gProof->UploadPackage("AOD.par");
193 gProof->UploadPackage("ANALYSIS.par");
194 gProof->UploadPackage("ANALYSISalice.par");
195 gProof->UploadPackage("PWG2AOD.par");
196 gProof->UploadPackage("CORRFW.par");
197 gProof->UploadPackage("PWG2flowCommon.par");
198 gProof->UploadPackage("PWG2flowTasks.par");
200 // Enable the Packages
201 gProof->EnablePackage("STEERBase");
202 gProof->EnablePackage("ESD");
203 gProof->EnablePackage("AOD");
204 gProof->EnablePackage("ANALYSIS");
205 gProof->EnablePackage("ANALYSISalice");
206 gProof->EnablePackage("PWG2AOD");
207 gProof->EnablePackage("CORRFW");
208 gProof->EnablePackage("PWG2flowCommon");
209 gProof->EnablePackage("PWG2flowTasks");
211 // Show enables Packages
212 gProof->ShowEnabledPackages();
217 void SetupPar(char* pararchivename) {
218 //Load par files, create analysis libraries
219 //For testing, if par file already decompressed and modified
220 //classes then do not decompress.
222 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
223 TString parpar(Form("%s.par", pararchivename)) ;
224 if ( gSystem->AccessPathName(parpar.Data()) ) {
225 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
226 TString processline(Form(".! make %s", parpar.Data())) ;
227 gROOT->ProcessLine(processline.Data()) ;
228 gSystem->ChangeDirectory(cdir) ;
229 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
230 gROOT->ProcessLine(processline.Data()) ;
232 if ( gSystem->AccessPathName(pararchivename) ) {
233 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
234 gROOT->ProcessLine(processline.Data());
237 TString ocwd = gSystem->WorkingDirectory();
238 gSystem->ChangeDirectory(pararchivename);
240 // check for BUILD.sh and execute
241 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
242 printf("*******************************\n");
243 printf("*** Building PAR archive ***\n");
244 cout<<pararchivename<<endl;
245 printf("*******************************\n");
246 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
247 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
251 // check for SETUP.C and execute
252 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
253 printf("*******************************\n");
254 printf("*** Setup PAR archive ***\n");
255 cout<<pararchivename<<endl;
256 printf("*******************************\n");
257 gROOT->Macro("PROOF-INF/SETUP.C");
260 gSystem->ChangeDirectory(ocwd.Data());
261 printf("Current dir: %s\n", ocwd.Data());
265 // Helper macros for creating chains
266 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
268 TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
270 // creates chain of files in a given directory or file containing a list.
271 // In case of directory the structure is expected as:
272 // <aDataDir>/<dir0>/AliESDs.root
273 // <aDataDir>/<dir1>/AliESDs.root
279 Long_t id, size, flags, modtime;
280 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
282 printf("%s not found.\n", aDataDir);
286 TChain* chain = new TChain("esdTree");
287 TChain* chaingAlice = 0;
291 TString execDir(gSystem->pwd());
292 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
293 TList* dirList = baseDir->GetListOfFiles();
294 Int_t nDirs = dirList->GetEntries();
295 gSystem->cd(execDir);
299 for (Int_t iDir=0; iDir<nDirs; ++iDir)
301 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
302 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
311 if (count++ == aRuns)
314 TString presentDirName(aDataDir);
315 presentDirName += "/";
316 presentDirName += presentDir->GetName();
317 chain->Add(presentDirName + "/AliESDs.root/esdTree");
318 // cerr<<presentDirName<<endl;
324 // Open the input stream
330 // Read the input list of files and add them to the chain
334 if (!esdfile.Contains("root")) continue; // protection
342 if (count++ == aRuns)
356 // Helper macros for creating chains
357 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
359 TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
361 // creates chain of files in a given directory or file containing a list.
362 // In case of directory the structure is expected as:
363 // <aDataDir>/<dir0>/AliAOD.root
364 // <aDataDir>/<dir1>/AliAOD.root
370 Long_t id, size, flags, modtime;
371 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
373 printf("%s not found.\n", aDataDir);
377 TChain* chain = new TChain("aodTree");
378 TChain* chaingAlice = 0;
382 TString execDir(gSystem->pwd());
383 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
384 TList* dirList = baseDir->GetListOfFiles();
385 Int_t nDirs = dirList->GetEntries();
386 gSystem->cd(execDir);
390 for (Int_t iDir=0; iDir<nDirs; ++iDir)
392 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
393 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
402 if (count++ == aRuns)
405 TString presentDirName(aDataDir);
406 presentDirName += "/";
407 presentDirName += presentDir->GetName();
408 chain->Add(presentDirName + "/AliAOD.root/aodTree");
409 // cerr<<presentDirName<<endl;
415 // Open the input stream
421 // Read the input list of files and add them to the chain
425 if (!aodfile.Contains("root")) continue; // protection
433 if (count++ == aRuns)