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)
9 Bool_t MCEP = kTRUE; // correlation with Monte Carlo reaction plane
10 Bool_t SP = kTRUE; // scalar product method (similar to eventplane method)
11 Bool_t GFC = kTRUE; // cumulants based on generating function
12 Bool_t QC = kTRUE; // cumulants using Q vectors
13 Bool_t FQD = kTRUE; // fit of the distribution of the Q vector (only integrated v)
14 Bool_t LYZ1SUM = kTRUE; // Lee Yang Zeroes using sum generating function (integrated v)
15 Bool_t LYZ1PROD = kTRUE; // Lee Yang Zeroes using product generating function (integrated v)
16 Bool_t LYZ2SUM = kFALSE; // Lee Yang Zeroes using sum generating function (second pass differential v)
17 Bool_t LYZ2PROD = kFALSE; // Lee Yang Zeroes using product generating function (second pass differential v)
18 Bool_t LYZEP = kFALSE; // Lee Yang Zeroes Event plane using sum generating function (gives eventplane + weight)
19 Bool_t MH = kTRUE; // azimuthal correlators in mixed harmonics
20 Bool_t NL = kTRUE; // nested loops (for instance distribution of phi1-phi2 for all distinct pairs)
22 Bool_t METHODS[] = {SP,LYZ1SUM,LYZ1PROD,LYZ2SUM,LYZ2PROD,LYZEP,GFC,QC,FQD,MCEP,MH,NL};
24 // Analysis type can be ESD, AOD, MC, ESDMCkineESD, ESDMCkineMC
25 const TString type = "ESD";
27 // Boolean to fill/not fill the QA histograms
30 // Boolean to use/not use weights for the Q vector
31 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/alice2/kolk/PP/LHC09d10/104873", Int_t offset = 0)
38 void runFlowTask(Int_t mode = mPROOF, Int_t nRuns = 50000000,
39 //Bool_t DATA = kFALSE, const Char_t* dataDir="/PWG2/akisiel/Therminator_midcentral_ESD", Int_t offset=0)
40 //Bool_t DATA = kFALSE, const Char_t* dataDir="/PWG2/akisiel/LHC10d6_0.9TeV_EPOS_12502X", Int_t offset=0)
41 //Bool_t DATA = kFALSE, const Char_t* dataDir="/alice/sim/LHC10d2_117048", Int_t offset=0) //phojet 7 TeV
42 //Bool_t DATA = kTRUE, const Char_t* dataDir="/alice/data/LHC09d_000104792_p6", Int_t offset=0) //data 0.9 TeV
43 Bool_t DATA = kFALSE, const Char_t* dataDir="/PWG4/morsch/HIJING_CENT_4EV", Int_t offset=0) //hijing Pb Pb pilot
45 //void runFlowTask(Int_t mode = mGRID, Bool_t DATA = kTRUE)
50 CrossCheckUserSettings(DATA);
55 // Create and configure the alien handler plugin
56 gROOT->LoadMacro("CreateAlienHandler.C");
57 AliAnalysisGrid *alienHandler = CreateAlienHandler();
58 if (!alienHandler) return;
61 if (mode==mLocal || mode == mLocalPAR) {
62 if (type!="AOD") { TChain* chain = CreateESDChain(dataDir, nRuns, offset);}
63 else { TChain* chain = CreateAODChain(dataDir, nRuns, offset);}
65 //____________________________________________//
66 // Make the analysis manager
67 AliAnalysisManager *mgr = new AliAnalysisManager("FlowAnalysisManager");
70 // Connect plug-in to the analysis manager
71 mgr->SetGridHandler(alienHandler);
75 AliVEventHandler* esdH = new AliESDInputHandler;
76 mgr->SetInputEventHandler(esdH);
78 AliMCEventHandler *mc = new AliMCEventHandler();
79 mgr->SetMCtruthEventHandler(mc);
84 AliVEventHandler* aodH = new AliAODInputHandler;
85 mgr->SetInputEventHandler(aodH);
87 AliMCEventHandler *mc = new AliMCEventHandler();
88 mgr->SetMCtruthEventHandler(mc);
92 if (type == "MC" || type == "ESDMCkineESD" || type == "ESDMCkineMC"){
93 AliVEventHandler* esdH = new AliESDInputHandler;
94 mgr->SetInputEventHandler(esdH);
96 AliMCEventHandler *mc = new AliMCEventHandler();
97 mgr->SetMCtruthEventHandler(mc);
100 //____________________________________________//
101 // Load the analysis task
102 gROOT->LoadMacro("AddTaskFlow.C");
103 AliAnalysisTaskFlowEvent* taskFE = AddTaskFlow(type,METHODS,QA,WEIGHTS);
106 // Task to check the offline trigger
107 if (mode == mLocal || mode == mGRID) {
108 gROOT->LoadMacro("$ALICE_ROOT/ANALYSIS/macros/AddTaskPhysicsSelection.C"); }
109 else if (mode == mPROOF || mode == mLocalPAR) {
110 gROOT->LoadMacro("AddTaskPhysicsSelection.C"); }
111 AliPhysicsSelectionTask* physicsSelTask = AddTaskPhysicsSelection();
112 if (!DATA) {physicsSelTask->GetPhysicsSelection()->SetAnalyzeMC();}
115 // Enable debug printouts
116 mgr->SetDebugLevel(2);
119 //____________________________________________//
121 if (!mgr->InitAnalysis()) return;
124 if (mode == mLocal || mode == mLocalPAR) {
125 mgr->StartAnalysis("local",chain);
127 else if (mode == mPROOF) {
128 mgr->StartAnalysis("proof",dataDir,nRuns,offset);
130 else if (mode == mGRID) {
131 mgr->StartAnalysis("grid");
139 void CrossCheckUserSettings(Bool_t bData)
141 // Check in this method if the user settings make sense.
143 if(MCEP==kTRUE && bData==kTRUE)
146 cout<<"WARNING: In real datasets there is no Monte Carlo information available !!!!"<<endl;
147 cout<<" Set for real data analysis DATA = kTRUE and MCEP = kFALSE in the macro."<<endl;
152 } // end of void CrossCheckUserSettings()
154 void LoadLibraries(const anaModes mode) {
156 //--------------------------------------
157 // Load the needed libraries most of them already loaded by aliroot
158 //--------------------------------------
159 gSystem->Load("libTree");
160 gSystem->Load("libGeom");
161 gSystem->Load("libVMC");
162 gSystem->Load("libXMLIO");
163 gSystem->Load("libPhysics");
165 //----------------------------------------------------------
166 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
167 //----------------------------------------------------------
168 if (mode==mLocal || mode==mGRID) {
169 //--------------------------------------------------------
170 // If you want to use already compiled libraries
171 // in the aliroot distribution
172 //--------------------------------------------------------
173 gSystem->Load("libSTEERBase");
174 gSystem->Load("libESD");
175 gSystem->Load("libAOD");
176 gSystem->Load("libANALYSIS");
177 gSystem->Load("libANALYSISalice");
178 gSystem->Load("libCORRFW");
179 gSystem->Load("libPWG2forward");
181 gSystem->Load("libPWG2flowCommon");
182 cerr<<"libPWG2flowCommon loaded..."<<endl;
183 gSystem->Load("libPWG2flowTasks");
184 cerr<<"libPWG2flowTasks loaded..."<<endl;
187 SetupPar("PWG2flowCommon");
188 cerr<<"PWG2flowCommon.par loaded..."<<endl;
189 SetupPar("PWG2flowTasks");
190 cerr<<"PWG2flowTasks.par loaded..."<<endl;
194 else if (mode == mLocalPAR) {
195 //--------------------------------------------------------
196 //If you want to use root and par files from aliroot
197 //--------------------------------------------------------
198 SetupPar("STEERBase");
201 SetupPar("ANALYSIS");
202 SetupPar("ANALYSISalice");
204 SetupPar("PWG2flowCommon");
205 cerr<<"PWG2flowCommon.par loaded..."<<endl;
206 SetupPar("PWG2flowTasks");
207 cerr<<"PWG2flowTasks.par loaded..."<<endl;
210 //---------------------------------------------------------
211 // <<<<<<<<<< PROOF mode >>>>>>>>>>>>
212 //---------------------------------------------------------
213 else if (mode==mPROOF) {
215 //gEnv->SetValue("XSec.GSI.DelegProxy","2");
216 // set to debug root versus if needed
217 //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a_dbg");
218 //TProof::Mgr("alicecaf")->SetROOTVersion("v5-24-00a");
219 //TProof::Reset("proof://snelling@alicecaf.cern.ch");
221 printf("*** Connect to PROOF ***\n");
222 gEnv->SetValue("XSec.GSI.DelegProxy","2");
223 // Put appropriate username here
224 //TProof::Open("abilandz@alicecaf.cern.ch");
225 //TProof::Open("nkolk@alicecaf.cern.ch");
226 //TProof::Open("snelling@localhost");
227 TProof::Open("alice-caf.cern.ch");
228 //TProof::Open("skaf.saske.sk");
229 //TProof::Open("prf000-iep-grid.saske.sk");
230 //Info("runSKAF.C","Loading libs on proof (may take while, around 1 min) ...");
231 // list the data available
232 //gProof->ShowDataSets("/*/*");
233 //gProof->ShowDataSets("/alice/sim/"); //for MC Data
234 //gProof->ShowDataSets("/alice/data/"); //for REAL Data
236 // Clear the Packages
238 gProof->ClearPackage("STEERBase.par");
239 gProof->ClearPackage("ESD.par");
240 gProof->ClearPackage("AOD.par");
241 gProof->ClearPackage("ANALYSIS.par");
242 gProof->ClearPackage("ANALYSISalice.par");
243 gProof->ClearPackage("CORRFW.par");
245 gProof->ClearPackage("PWG2flowCommon");
246 gProof->ClearPackage("PWG2flowTasks");
248 // Upload the Packages
249 gProof->UploadPackage("STEERBase.par");
250 gProof->UploadPackage("ESD.par");
251 gProof->UploadPackage("AOD.par");
253 gProof->UploadPackage("ANALYSIS.par");
254 gProof->UploadPackage("ANALYSISalice.par");
255 gProof->UploadPackage("CORRFW.par");
256 gProof->UploadPackage("PWG2flowCommon.par");
257 gProof->UploadPackage("PWG2flowTasks.par");
259 // Enable the Packages
260 // The global package
261 //gProof->EnablePackage("aliroot_v4-19-05-AN",kTRUE);
264 gProof->EnablePackage("STEERBase");
265 gProof->EnablePackage("ESD");
266 gProof->EnablePackage("AOD");
269 gProof->EnablePackage("ANALYSIS");
270 gProof->EnablePackage("ANALYSISalice");
271 gProof->EnablePackage("CORRFW");
272 gProof->EnablePackage("PWG2flowCommon");
273 gProof->EnablePackage("PWG2flowTasks");
275 // Show enables Packages
276 gProof->ShowEnabledPackages();
281 void SetupPar(char* pararchivename) {
282 //Load par files, create analysis libraries
283 //For testing, if par file already decompressed and modified
284 //classes then do not decompress.
286 TString cdir(Form("%s", gSystem->WorkingDirectory() )) ;
287 TString parpar(Form("%s.par", pararchivename)) ;
288 if ( gSystem->AccessPathName(parpar.Data()) ) {
289 gSystem->ChangeDirectory(gSystem->Getenv("ALICE_ROOT")) ;
290 TString processline(Form(".! make %s", parpar.Data())) ;
291 gROOT->ProcessLine(processline.Data()) ;
292 gSystem->ChangeDirectory(cdir) ;
293 processline = Form(".! mv /tmp/%s .", parpar.Data()) ;
294 gROOT->ProcessLine(processline.Data()) ;
296 if ( gSystem->AccessPathName(pararchivename) ) {
297 TString processline = Form(".! tar xvzf %s",parpar.Data()) ;
298 gROOT->ProcessLine(processline.Data());
301 TString ocwd = gSystem->WorkingDirectory();
302 gSystem->ChangeDirectory(pararchivename);
304 // check for BUILD.sh and execute
305 if (!gSystem->AccessPathName("PROOF-INF/BUILD.sh")) {
306 printf("*******************************\n");
307 printf("*** Building PAR archive ***\n");
308 cout<<pararchivename<<endl;
309 printf("*******************************\n");
310 if (gSystem->Exec("PROOF-INF/BUILD.sh")) {
311 Error("runProcess","Cannot Build the PAR Archive! - Abort!");
315 // check for SETUP.C and execute
316 if (!gSystem->AccessPathName("PROOF-INF/SETUP.C")) {
317 printf("*******************************\n");
318 printf("*** Setup PAR archive ***\n");
319 cout<<pararchivename<<endl;
320 printf("*******************************\n");
321 gROOT->Macro("PROOF-INF/SETUP.C");
324 gSystem->ChangeDirectory(ocwd.Data());
325 printf("Current dir: %s\n", ocwd.Data());
329 // Helper macros for creating chains
330 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
332 TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
334 // creates chain of files in a given directory or file containing a list.
335 // In case of directory the structure is expected as:
336 // <aDataDir>/<dir0>/AliESDs.root
337 // <aDataDir>/<dir1>/AliESDs.root
343 Long_t id, size, flags, modtime;
344 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
346 printf("%s not found.\n", aDataDir);
350 TChain* chain = new TChain("esdTree");
351 TChain* chaingAlice = 0;
355 TString execDir(gSystem->pwd());
356 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
357 TList* dirList = baseDir->GetListOfFiles();
358 Int_t nDirs = dirList->GetEntries();
359 gSystem->cd(execDir);
363 for (Int_t iDir=0; iDir<nDirs; ++iDir)
365 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
366 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
375 if (count++ == aRuns)
378 TString presentDirName(aDataDir);
379 presentDirName += "/";
380 presentDirName += presentDir->GetName();
381 chain->Add(presentDirName + "/AliESDs.root/esdTree");
382 // cerr<<presentDirName<<endl;
388 // Open the input stream
394 // Read the input list of files and add them to the chain
398 if (!esdfile.Contains("root")) continue; // protection
406 if (count++ == aRuns)
420 // Helper macros for creating chains
421 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
423 TChain* CreateAODChain(const char* aDataDir, Int_t aRuns, Int_t offset)
425 // creates chain of files in a given directory or file containing a list.
426 // In case of directory the structure is expected as:
427 // <aDataDir>/<dir0>/AliAOD.root
428 // <aDataDir>/<dir1>/AliAOD.root
434 Long_t id, size, flags, modtime;
435 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
437 printf("%s not found.\n", aDataDir);
441 TChain* chain = new TChain("aodTree");
442 TChain* chaingAlice = 0;
446 TString execDir(gSystem->pwd());
447 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
448 TList* dirList = baseDir->GetListOfFiles();
449 Int_t nDirs = dirList->GetEntries();
450 gSystem->cd(execDir);
454 for (Int_t iDir=0; iDir<nDirs; ++iDir)
456 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
457 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
466 if (count++ == aRuns)
469 TString presentDirName(aDataDir);
470 presentDirName += "/";
471 presentDirName += presentDir->GetName();
472 chain->Add(presentDirName + "/AliAOD.root/aodTree");
473 // cerr<<presentDirName<<endl;
479 // Open the input stream
485 // Read the input list of files and add them to the chain
489 if (!aodfile.Contains("root")) continue; // protection
497 if (count++ == aRuns)