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