]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/macros/runAliAnalysisTaskLeeYangZeros.C
cleanup
[u/mrichter/AliRoot.git] / PWG2 / FLOW / macros / runAliAnalysisTaskLeeYangZeros.C
CommitLineData
b6164404 1// from CreateESDChain.C - instead of #include "CreateESDChain.C"
2TChain* CreateESDChain(const char* aDataDir = "ESDfiles.txt", Int_t aRuns = 20, Int_t offset = 0) ;
3void LookupWrite(TChain* chain, const char* target) ;
4
5
b6164404 6
0b7f49e9 7void runAliAnalysisTaskLeeYangZeros(Int_t nRuns = 2, Bool_t firstrun = kTRUE, TString type = "ESD", Bool_t usesum = kTRUE, const Char_t* dataDir="/Users/snelling/alice_data/TherminatorFIX", Int_t offset = 0)
b6164404 8{
448e8856 9 TStopwatch timer;
10 timer.Start();
b6164404 11
12 // include path (to find the .h files when compiling)
0b7f49e9 13 gSystem->AddIncludePath("-I$ALICE_ROOT/include") ;
14 gSystem->AddIncludePath("-I$ROOTSYS/include") ;
b6164404 15
16 // load needed libraries
448e8856 17 gSystem->Load("libTree.so");
18 gSystem->Load("libESD.so");
b6164404 19 cerr<<"libESD loaded..."<<endl;
20 gSystem->Load("libANALYSIS.so");
21 cerr<<"libANALYSIS.so loaded..."<<endl;
b6164404 22 gSystem->Load("libPWG2flow.so");
448e8856 23
0b7f49e9 24 // gROOT->LoadMacro("AliFlowLYZConstants.cxx+");
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("AliFlowLYZHist1.cxx+");
33 // gROOT->LoadMacro("AliFlowLYZHist2.cxx+");
34 // gROOT->LoadMacro("AliFlowAnalysisWithLeeYangZeros.cxx+");
35 // gROOT->LoadMacro("AliAnalysisTaskLeeYangZeros.cxx+");
b6164404 36
37 // create the TChain. CreateESDChain() is defined in CreateESDChain.C
38 TChain* chain = CreateESDChain(dataDir, nRuns, offset);
39 cout<<"chain ("<<chain<<")"<<endl;
b6164404 40
b6164404 41 if (!firstrun){
448e8856 42 // read the input files
43 TString firstRunFileName = "outputFromLeeYangZerosAnalysis" ;
44 firstRunFileName += type;
45 firstRunFileName += "_firstrun.root";
b6164404 46 TFile* fFirstRunFile = new TFile(firstRunFileName.Data(),"READ");
448e8856 47 if(!fFirstRunFile || fFirstRunFile->IsZombie()) { cerr << " ERROR: NO First Run file... " << endl ; }
48 cout<<"input files read..."<<endl;
49 }
b6164404 50 //____________________________________________//
51 // Make the analysis manager
448e8856 52 AliAnalysisManager *mgr = new AliAnalysisManager("TestManager");
53 AliVEventHandler* esdH = new AliESDInputHandler;
54 mgr->SetInputEventHandler(esdH);
55 AliMCEventHandler *mc = new AliMCEventHandler();
56 mgr->SetMCtruthEventHandler(mc);
b6164404 57 //____________________________________________//
58 // 1st LYZ task
448e8856 59 AliAnalysisTaskLeeYangZeros *task1 = new AliAnalysisTaskLeeYangZeros("TaskLeeYangZeros", firstrun);
60 task1->SetAnalysisType(type);
b6164404 61 task1->SetFirstRunLYZ(firstrun); //set to first or second run
62 task1->SetUseSumLYZ(usesum); //set to sum gen.function or product gen.function
b6164404 63 mgr->AddTask(task1);
b6164404 64
65 // Create containers for input/output
66 AliAnalysisDataContainer *cinput1 =
67 mgr->CreateContainer("cchain1",TChain::Class(),AliAnalysisManager::kInputContainer);
448e8856 68 if (!firstrun){ AliAnalysisDataContainer *cinput2 =
69 mgr->CreateContainer("cobj2",TList::Class(),AliAnalysisManager::kInputContainer); }
b6164404 70 AliAnalysisDataContainer *coutput1 =
448e8856 71 mgr->CreateContainer("cobj1", TList::Class(),AliAnalysisManager::kOutputContainer);
b6164404 72
b6164404 73 //____________________________________________//
74 mgr->ConnectInput(task1,0,cinput1);
448e8856 75 if (!firstrun) { mgr->ConnectInput(task1,1,cinput2); }
b6164404 76 mgr->ConnectOutput(task1,0,coutput1);
448e8856 77
78 if (!firstrun){ cinput2->SetData(fFirstRunFile);}
b6164404 79
448e8856 80 if (!mgr->InitAnalysis()) return;
81 mgr->PrintStatus();
82 mgr->StartAnalysis("local",chain);
b6164404 83
448e8856 84 timer.Stop();
85 timer.Print();
b6164404 86}
87
88
89// Helper macros for creating chains
90// from: CreateESDChain.C,v 1.10 jgrosseo Exp
91
92TChain* CreateESDChain(const char* aDataDir, Int_t aRuns, Int_t offset)
93{
94 // creates chain of files in a given directory or file containing a list.
95 // In case of directory the structure is expected as:
96 // <aDataDir>/<dir0>/AliESDs.root
97 // <aDataDir>/<dir1>/AliESDs.root
98 // ...
99
100 if (!aDataDir)
101 return 0;
102
103 Long_t id, size, flags, modtime;
104 if (gSystem->GetPathInfo(aDataDir, &id, &size, &flags, &modtime))
105 {
106 printf("%s not found.\n", aDataDir);
107 return 0;
108 }
109
110 TChain* chain = new TChain("esdTree");
111 TChain* chaingAlice = 0;
112
113 if (flags & 2)
114 {
115 TString execDir(gSystem->pwd());
116 TSystemDirectory* baseDir = new TSystemDirectory(".", aDataDir);
117 TList* dirList = baseDir->GetListOfFiles();
118 Int_t nDirs = dirList->GetEntries();
119 gSystem->cd(execDir);
120
121 Int_t count = 0;
122
123 for (Int_t iDir=0; iDir<nDirs; ++iDir)
124 {
125 TSystemFile* presentDir = (TSystemFile*) dirList->At(iDir);
126 if (!presentDir || !presentDir->IsDirectory() || strcmp(presentDir->GetName(), ".") == 0 || strcmp(presentDir->GetName(), "..") == 0)
127 continue;
128
129 if (offset > 0)
130 {
131 --offset;
132 continue;
133 }
134
135 if (count++ == aRuns)
136 break;
137
138 TString presentDirName(aDataDir);
139 presentDirName += "/";
140 presentDirName += presentDir->GetName();
141 chain->Add(presentDirName + "/AliESDs.root/esdTree");
142 cerr<<presentDirName<<endl;
143 }
144
145 }
146 else
147 {
148 // Open the input stream
149 ifstream in;
150 in.open(aDataDir);
151
152 Int_t count = 0;
153
154 // Read the input list of files and add them to the chain
155 TString esdfile;
156 while(in.good()) {
157 in >> esdfile;
158 if (!esdfile.Contains("root")) continue; // protection
159
160 if (offset > 0)
161 {
162 --offset;
163 continue;
164 }
165
166 if (count++ == aRuns)
167 break;
168
169 // add esd file
170 chain->Add(esdfile);
171 }
172
173 in.close();
174 }
175
176 return chain;
177}
178
179void LookupWrite(TChain* chain, const char* target)
180{
181 // looks up the chain and writes the remaining files to the text file target
182
183 chain->Lookup();
184
185 TObjArray* list = chain->GetListOfFiles();
186 TIterator* iter = list->MakeIterator();
187 TObject* obj = 0;
188
189 ofstream outfile;
190 outfile.open(target);
191
192 while ((obj = iter->Next()))
193 outfile << obj->GetTitle() << "#AliESDs.root" << endl;
194
195 outfile.close();
196
197 delete iter;
198}
199