1 // from CreateESDChain.C - instead of #include "CreateESDChain.C"
2 TChain* CreateESDChain(const char* aDataDir = "ESDfiles.txt", Int_t aRuns = 20, Int_t offset = 0) ;
3 void LookupWrite(TChain* chain, const char* target) ;
7 void runAliAnalysisTaskMCEventPlane(Int_t nRuns = 2, TString type = "MC", const Char_t* dataDir="/Users/snelling/alice_data/TherminatorFIX", Int_t offset = 0)
13 // include path (to find the .h files when compiling)
14 gSystem->AddIncludePath("-I$ALICE_ROOT/include") ;
15 gSystem->AddIncludePath("-I$ROOTSYS/include") ;
17 // load needed libraries
18 gSystem->Load("libTree.so");
19 gSystem->Load("libESD.so");
20 cerr<<"libESD loaded..."<<endl;
21 gSystem->Load("libANALYSIS.so");
22 cerr<<"libANALYSIS.so loaded..."<<endl;
23 gSystem->Load("libPWG2flow.so");
25 // gROOT->LoadMacro("AliFlowCommonConstants.cxx+");
26 // gROOT->LoadMacro("AliFlowVector.cxx+");
27 // gROOT->LoadMacro("AliFlowTrackSimple.cxx+");
28 // gROOT->LoadMacro("AliFlowEventSimple.cxx+");
29 // gROOT->LoadMacro("AliFlowEventSimpleMaker.cxx+");
30 // gROOT->LoadMacro("AliFlowCommonHist.cxx+");
31 // gROOT->LoadMacro("AliFlowCommonHistResults.cxx+");
32 // gROOT->LoadMacro("AliFlowAnalysisWithMCEventPlane.cxx+");
33 // gROOT->LoadMacro("AliAnalysisTaskMCEventPlane.cxx+");
35 // create the TChain. CreateESDChain() is defined in CreateESDChain.C
36 TChain* chain = CreateESDChain(dataDir, nRuns, offset);
37 cout<<"chain ("<<chain<<")"<<endl;
39 //____________________________________________//
40 // Make the analysis manager
41 AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
42 if (type == "ESD" || type == "ESDMC0" || type == "ESDMC1" || type == "MC" ) {
43 AliVEventHandler* esdH = new AliESDInputHandler;
44 mgr->SetInputEventHandler(esdH);
47 AliVEventHandler* aodH = new AliAODInputHandler;
48 mgr->SetInputEventHandler(aodH);
50 AliMCEventHandler *mc = new AliMCEventHandler();
51 mgr->SetMCtruthEventHandler(mc);
52 //____________________________________________//
54 AliAnalysisTaskMCEventPlane *task1 = new AliAnalysisTaskMCEventPlane("TaskMCEventPlane");
55 task1->SetAnalysisType(type);
58 // Create containers for input/output
59 AliAnalysisDataContainer *cinput1 =
60 mgr->CreateContainer("cchain1",TChain::Class(),AliAnalysisManager::kInputContainer);
61 AliAnalysisDataContainer *coutput1 =
62 mgr->CreateContainer("cobj1", TList::Class(),AliAnalysisManager::kOutputContainer);
64 //____________________________________________//
65 mgr->ConnectInput(task1,0,cinput1);
66 mgr->ConnectOutput(task1,0,coutput1);
68 if (!mgr->InitAnalysis()) return;
70 mgr->StartAnalysis("local",chain);
77 // Helper macros for creating chains
78 // from: CreateESDChain.C,v 1.10 jgrosseo Exp
80 TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
82 // creates chain of files in a given directory or file containing a list.
83 // In case of directory the structure is expected as:
84 // <aDataDir>/<dir0>/AliESDs.root
85 // <aDataDir>/<dir1>/AliESDs.root
91 Long_t id, size, flags, modtime;
92 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
94 printf("%s not found.\n", aDataDir);
98 TChain* chain = new TChain("esdTree");
99 TChain* chaingAlice = 0;
103 TString execDir(gSystem->pwd());
104 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
105 TList* dirList = baseDir->GetListOfFiles();
106 Int_t nDirs = dirList->GetEntries();
107 gSystem->cd(execDir);
111 for (Int_t iDir=0; iDir<nDirs; ++iDir)
113 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
114 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
123 if (count++ == aRuns)
126 TString presentDirName(aDataDir);
127 presentDirName += "/";
128 presentDirName += presentDir->GetName();
129 chain->Add(presentDirName + "/AliESDs.root/esdTree");
130 cerr<<presentDirName<<endl;
136 // Open the input stream
142 // Read the input list of files and add them to the chain
146 if (!esdfile.Contains("root")) continue; // protection
154 if (count++ == aRuns)
167 void LookupWrite(TChain* chain, const char* target)
169 // looks up the chain and writes the remaining files to the text file target
173 TObjArray* list = chain->GetListOfFiles();
174 TIterator* iter = list->MakeIterator();
178 outfile.open(target);
180 while ((obj = iter->Next()))
181 outfile << obj->GetTitle() << "#AliESDs.root" << endl;