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 //mGridPAR: Analyze files on Grid via AliEn plug-in and using par files for FLOW package
9 // Flow analysis method can be:(set to kTRUE or kFALSE)
10 Bool_t MCEP = kTRUE; // correlation with Monte Carlo reaction plane
11 Bool_t SP = kTRUE; // scalar product method (similar to eventplane method)
12 Bool_t GFC = kTRUE; // cumulants based on generating function
13 Bool_t QC = kTRUE; // cumulants using Q vectors
14 Bool_t FQD = kTRUE; // fit of the distribution of the Q vector (only integrated v)
15 Bool_t LYZ1SUM = kTRUE; // Lee Yang Zeroes using sum generating function (integrated v)
16 Bool_t LYZ1PROD = kTRUE; // Lee Yang Zeroes using product generating function (integrated v)
17 Bool_t LYZ2SUM = kFALSE; // Lee Yang Zeroes using sum generating function (second pass differential v)
18 Bool_t LYZ2PROD = kFALSE; // Lee Yang Zeroes using product generating function (second pass differential v)
19 Bool_t LYZEP = kFALSE; // Lee Yang Zeroes Event plane using sum generating function (gives eventplane + weight)
20 Bool_t MH = kTRUE; // azimuthal correlators in mixed harmonics
21 Bool_t NL = kFALSE; // nested loops (for instance distribution of phi1-phi2 for all distinct pairs)
23 Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP,MH,NL};
25 // Analysis type can be ESD, AOD, MC, ESDMCkineESD, ESDMCkineMC, MK
26 const TString type = "ESD";
28 // Boolean to fill/not fill the QA histograms
31 // Boolean to use/not use weights for the Q vector
32 Bool_t WEIGHTS[] = {kFALSE,kFALSE,kFALSE}; //Phi, v'(pt), v'(eta)
34 //void runFlowTask(Int_t mode=mLocal, Int_t nRuns = 2,
35 //Bool_t DATA = kTRUE, const Char_t* dataDir="/data/alice2/kolk/PP/data/LHC09d/104892/test", Int_t offset = 0)
36 //Bool_t DATA = kFALSE, const Char_t* dataDir="/data/alice3/ab/sim/LHC10d4", Int_t offset = 0) // pythia
37 // Bool_t DATA = kFALSE, const Char_t* dataDir="/data/alice2/kolk/PP/LHC09d10/104873", Int_t offset = 0)
39 //void runFlowTask(Int_t mode = mPROOF, Int_t nRuns = 50000000,
40 //Bool_t DATA = kFALSE, const Char_t* dataDir="/PWG2/akisiel/Therminator_midcentral_ESD", Int_t offset=0)
41 //Bool_t DATA = kFALSE, const Char_t* dataDir="/PWG2/akisiel/LHC10d6_0.9TeV_EPOS_12502X", Int_t offset=0)
42 //Bool_t DATA = kFALSE, const Char_t* dataDir="/alice/sim/LHC10d2_117048", Int_t offset=0) //phojet 7 TeV
43 //Bool_t DATA = kTRUE, const Char_t* dataDir="/alice/data/LHC09d_000104792_p6", Int_t offset=0) //data 0.9 TeV
44 //Bool_t DATA = kFALSE, const Char_t* dataDir="/PWG4/morsch/HIJING_CENT_4EV", Int_t offset=0) //hijing Pb Pb pilot
46 void runFlowTask(Int_t mode = mGrid, Bool_t DATA = kFALSE)
51 // Cross-check user settings before starting:
52 CrossCheckUserSettings(DATA);
53 // Load needed libraries:
55 // Create and configure the AliEn plug-in:
56 if(mode == mGrid || mode == mGridPAR)
58 gROOT->LoadMacro("CreateAlienHandler.C");
59 AliAnalysisGrid *alienHandler = CreateAlienHandler();
60 if (!alienHandler) return;
63 if(mode==mLocal || mode == mLocalPAR)
65 if (type!="AOD") { TChain* chain = CreateESDChain(dataDir, nRuns, offset);}
66 else { TChain* chain = CreateAODChain(dataDir, nRuns, offset);}
69 // Create analysis manager:
70 AliAnalysisManager *mgr = new AliAnalysisManager("FlowAnalysisManager");
71 // Connect plug-in to the analysis manager:
72 if(mode == mGrid || mode == mGridPAR)
74 mgr->SetGridHandler(alienHandler);
79 AliVEventHandler* esdH = new AliESDInputHandler;
80 mgr->SetInputEventHandler(esdH);
83 AliMCEventHandler *mc = new AliMCEventHandler();
84 mgr->SetMCtruthEventHandler(mc);
86 } // end of if(type == "ESD")
89 AliVEventHandler* aodH = new AliAODInputHandler;
90 mgr->SetInputEventHandler(aodH);
93 AliMCEventHandler *mc = new AliMCEventHandler();
94 mgr->SetMCtruthEventHandler(mc);
96 } // end of if(type == "AOD")
97 if(type == "MC" || type == "ESDMCkineESD" || type == "ESDMCkineMC")
99 AliVEventHandler* esdH = new AliESDInputHandler;
100 mgr->SetInputEventHandler(esdH);
101 AliMCEventHandler *mc = new AliMCEventHandler();
102 mgr->SetMCtruthEventHandler(mc);
103 } // end of if(type == "MC" || type == "ESDMCkineESD" || type == "ESDMCkineMC")
104 // Load the analysis task:
105 gROOT->LoadMacro("AddTaskFlow.C");
106 AliAnalysisTaskFlowEvent* taskFE = AddTaskFlow(type,METHODS,QA,WEIGHTS);
107 // Task to check the offline trigger:
108 if(mode == mLocal || mode == mGrid || mode == mGridPAR)
110 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C");
111 } else if (mode == mPROOF || mode == mLocalPAR)
113 gROOT->LoadMacro("AddTaskPhysicsSelection.C");
115 AliPhysicsSelectionTask* physicsSelTask = AddTaskPhysicsSelection();
116 if(!DATA){physicsSelTask->GetPhysicsSelection()->SetAnalyzeMC();}
117 // Enable debug printouts:
118 mgr->SetDebugLevel(2);
121 if(!mgr->InitAnalysis()){return;}
123 if(mode == mLocal || mode == mLocalPAR)
125 mgr->StartAnalysis("local",chain);
126 } else if(mode == mPROOF)
128 mgr->StartAnalysis("proof",dataDir,nRuns,offset);
129 } else if(mode == mGrid || mode == mGridPAR)
131 mgr->StartAnalysis("grid");
133 // Print real and CPU time used for analysis:
137 } // end of void runFlowTask(...)
139 //===============================================================================================
141 void CrossCheckUserSettings(Bool_t bData)
143 // Check in this method if the user settings make sense.
145 if(MCEP==kTRUE && bData==kTRUE)
148 cout<<"WARNING: In real datasets there is no Monte Carlo information available !!!!"<<endl;
149 cout<<" Set for real data analysis DATA = kTRUE and MCEP = kFALSE in the macro."<<endl;
154 if(LYZ1SUM && LYZ2SUM) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
155 if(LYZ1PROD && LYZ2PROD) {cout<<" WARNING: You cannot run LYZ1 and LYZ2 at the same time! LYZ2 needs the output from LYZ1 !!!!"<<endl; exit(0); }
156 if(LYZ2SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ2 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
157 if(LYZ1SUM && LYZEP) {cout<<" WARNING: You cannot run LYZ1 and LYZEP at the same time! LYZEP needs the output from LYZ2 !!!!"<<endl; exit(0); }
159 } // end of void CrossCheckUserSettings()
161 //===============================================================================================
163 void LoadLibraries(const anaModes mode)
165 //--------------------------------------
166 // Load the needed libraries most of them already loaded by aliroot
167 //--------------------------------------
168 gSystem->Load("libTree");
169 gSystem->Load("libGeom");
170 gSystem->Load("libVMC");
171 gSystem->Load("libXMLIO");
172 gSystem->Load("libPhysics");
174 //----------------------------------------------------------
175 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
176 //----------------------------------------------------------
177 if (mode==mLocal || mode==mGrid || mode == mGridPAR) {
178 //--------------------------------------------------------
179 // If you want to use already compiled libraries
180 // in the aliroot distribution
181 //--------------------------------------------------------
182 gSystem->Load("libSTEERBase");
183 gSystem->Load("libESD");
184 gSystem->Load("libAOD");
185 gSystem->Load("libANALYSIS");
186 gSystem->Load("libANALYSISalice");
187 gSystem->Load("libCORRFW");
188 gSystem->Load("libPWG2forward");
189 if(mode==mLocal || mode==mGrid)
191 gSystem->Load("libPWG2flowCommon");
192 cerr<<"libPWG2flowCommon loaded..."<<endl;
193 gSystem->Load("libPWG2flowTasks");
194 cerr<<"libPWG2flowTasks loaded..."<<endl;
198 SetupPar("PWG2flowCommon");
199 cerr<<"PWG2flowCommon.par loaded..."<<endl;
200 SetupPar("PWG2flowTasks");
201 cerr<<"PWG2flowTasks.par loaded..."<<endl;
205 else if (mode == mLocalPAR) {
206 //--------------------------------------------------------
207 //If you want to use root and par files from aliroot
208 //--------------------------------------------------------
209 SetupPar("STEERBase");
212 SetupPar("ANALYSIS");
213 SetupPar("ANALYSISalice");
215 SetupPar("PWG2flowCommon");
216 cerr<<"PWG2flowCommon.par loaded..."<<endl;
217 SetupPar("PWG2flowTasks");
218 cerr<<"PWG2flowTasks.par loaded..."<<endl;
221 //---------------------------------------------------------
222 // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
223 //---------------------------------------------------------
224 else if (mode==mPROOF) {
226 //gEnv->SetValue("XSec.GSI.DelegProxy","2");
227 // set to debug root versus if needed
228 //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a_dbg");
229 //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a");
230 //TProof::Reset("proof://snelling@alicecaf.cern.ch");
232 printf("*** Connect to PROOF ***\n");
233 gEnv->SetValue("XSec.GSI.DelegProxy","2");
234 // Put appropriate username here
235 //TProof::Open("abilandz@alicecaf.cern.ch");
236 //TProof::Open("nkolk@alicecaf.cern.ch");
237 //TProof::Open("snelling@localhost");
238 TProof::Open("alice-caf.cern.ch");
239 //TProof::Open("skaf.saske.sk");
240 //TProof::Open("prf000-iep-grid.saske.sk");
241 //Info("runSKAF.C","Loading libs on proof (may take while, around 1 min) ...");
242 // list the data available
243 //gProof->ShowDataSets("/*/*");
244 //gProof->ShowDataSets("/alice/sim/"); //for MC Data
245 //gProof->ShowDataSets("/alice/data/"); //for REAL Data
247 // Clear the Packages
249 gProof->ClearPackage("STEERBase.par");
250 gProof->ClearPackage("ESD.par");
251 gProof->ClearPackage("AOD.par");
252 gProof->ClearPackage("ANALYSIS.par");
253 gProof->ClearPackage("ANALYSISalice.par");
254 gProof->ClearPackage("CORRFW.par");
256 gProof->ClearPackage("PWG2flowCommon");
257 gProof->ClearPackage("PWG2flowTasks");
259 // Upload the Packages
260 gProof->UploadPackage("STEERBase.par");
261 gProof->UploadPackage("ESD.par");
262 gProof->UploadPackage("AOD.par");
264 gProof->UploadPackage("ANALYSIS.par");
265 gProof->UploadPackage("ANALYSISalice.par");
266 gProof->UploadPackage("CORRFW.par");
267 gProof->UploadPackage("PWG2flowCommon.par");
268 gProof->UploadPackage("PWG2flowTasks.par");
270 // Enable the Packages
271 // The global package
272 //gProof->EnablePackage("aliroot_v4-19-05-AN",kTRUE);
275 gProof->EnablePackage("STEERBase");
276 gProof->EnablePackage("ESD");
277 gProof->EnablePackage("AOD");
280 gProof->EnablePackage("ANALYSIS");
281 gProof->EnablePackage("ANALYSISalice");
282 gProof->EnablePackage("CORRFW");
283 gProof->EnablePackage("PWG2flowCommon");
284 gProof->EnablePackage("PWG2flowTasks");
286 // Show enables Packages
287 gProof->ShowEnabledPackages();
290 } // end of void LoadLibraries(const anaModes mode)
292 //===============================================================================================
294 void SetupPar(char* pararchivename) {
295 //Load par files, create analysis libraries
296 //For testing, if par file already decompressed and modified
297 //classes then do not decompress.
299 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
300 TString parpar(Form("%s.par", pararchivename)) ;
301 if ( gSystem->AccessPathName(parpar.Data()) ) {
302 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
303 TString processline(Form(".! make %s", parpar.Data())) ;
304 gROOT->ProcessLine(processline.Data()) ;
305 gSystem->ChangeDirectory(cdir) ;
306 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
307 gROOT->ProcessLine(processline.Data()) ;
309 if ( gSystem->AccessPathName(pararchivename) ) {
310 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
311 gROOT->ProcessLine(processline.Data());
314 TString ocwd = gSystem->WorkingDirectory();
315 gSystem->ChangeDirectory(pararchivename);
317 // check for BUILD.sh and execute
318 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
319 printf("*******************************\n");
320 printf("*** Building PAR archive ***\n");
321 cout<<pararchivename<<endl;
322 printf("*******************************\n");
323 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
324 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
328 // check for SETUP.C and execute
329 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
330 printf("*******************************\n");
331 printf("*** Setup PAR archive ***\n");
332 cout<<pararchivename<<endl;
333 printf("*******************************\n");
334 gROOT->Macro("PROOF-INF/SETUP.C");
337 gSystem->ChangeDirectory(ocwd.Data());
338 printf("Current dir: %s\n", ocwd.Data());
340 } // end of void SetupPar(char* pararchivename)
342 //===============================================================================================
344 // Helper macros for creating chains
345 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
347 TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
349 // creates chain of files in a given directory or file containing a list.
350 // In case of directory the structure is expected as:
351 // <aDataDir>/<dir0>/AliESDs.root
352 // <aDataDir>/<dir1>/AliESDs.root
358 Long_t id, size, flags, modtime;
359 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
361 printf("%s not found.\n", aDataDir);
365 TChain* chain = new TChain("esdTree");
366 TChain* chaingAlice = 0;
370 TString execDir(gSystem->pwd());
371 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
372 TList* dirList = baseDir->GetListOfFiles();
373 Int_t nDirs = dirList->GetEntries();
374 gSystem->cd(execDir);
378 for (Int_t iDir=0; iDir<nDirs; ++iDir)
380 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
381 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
390 if (count++ == aRuns)
393 TString presentDirName(aDataDir);
394 presentDirName += "/";
395 presentDirName += presentDir->GetName();
396 chain->Add(presentDirName + "/AliESDs.root/esdTree");
397 // cerr<<presentDirName<<endl;
403 // Open the input stream
409 // Read the input list of files and add them to the chain
413 if (!esdfile.Contains("root")) continue; // protection
421 if (count++ == aRuns)
433 } // end of TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
435 //===============================================================================================
437 TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
439 // creates chain of files in a given directory or file containing a list.
440 // In case of directory the structure is expected as:
441 // <aDataDir>/<dir0>/AliAOD.root
442 // <aDataDir>/<dir1>/AliAOD.root
448 Long_t id, size, flags, modtime;
449 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
451 printf("%s not found.\n", aDataDir);
455 TChain* chain = new TChain("aodTree");
456 TChain* chaingAlice = 0;
460 TString execDir(gSystem->pwd());
461 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
462 TList* dirList = baseDir->GetListOfFiles();
463 Int_t nDirs = dirList->GetEntries();
464 gSystem->cd(execDir);
468 for (Int_t iDir=0; iDir<nDirs; ++iDir)
470 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
471 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
480 if (count++ == aRuns)
483 TString presentDirName(aDataDir);
484 presentDirName += "/";
485 presentDirName += presentDir->GetName();
486 chain->Add(presentDirName + "/AliAOD.root/aodTree");
487 // cerr<<presentDirName<<endl;
493 // Open the input stream
499 // Read the input list of files and add them to the chain
503 if (!aodfile.Contains("root")) continue; // protection
511 if (count++ == aRuns)
523 } // end of TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)