]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FLOW/macros/redoFinish.C
also working locally in root
[u/mrichter/AliRoot.git] / PWG2 / FLOW / macros / redoFinish.C
CommitLineData
ad87ae62 1// Macro redoFinish.C is used after macro mergeOutput.C has been used for merging.
2// Before using this macro first read the explanation at the beginning of macro mergeOutput.C.
3
6a6afe42 4enum libModes {mLocal,mLocalSource};
5
57340a27 6void redoFinish(TString type="ESD", Int_t mode=mLocal)
6a6afe42 7{
ad87ae62 8 // type: type of analysis can be ESD, AOD, MC, ESDMC0, ESDMC1
9 // (if type="" output files are from MC simulation (default))
10 // mode: if mode = mLocal: analyze data on your computer using aliroot
11 // if mode = mLocalSource: analyze data on your computer using root + source files
12
57340a27 13 // Name of merged, large statistics file obtained with macro mergeOutput.C:
14 TString mergedFileName = "mergedAnalysisResults.root";
15 // Final output file name holding final results for large statistics sample:
16 TString outputFileName = "AnalysisResults.root";
6a6afe42 17
ad87ae62 18 const Int_t nMethods = 10;
19 TString method[nMethods] = {"MCEP","SP","GFC","QC","FQD","LYZ1SUM","LYZ1PROD","LYZ2SUM","LYZ2PROD","LYZEP"};
9455e15e 20
57340a27 21 // Load needed libraries:
ad87ae62 22 LoadLibrariesRF(mode);
57340a27 23
24 // Accessing the merged, large statistics file obtained with macro mergeOutput.C.
25 // On this file the flow analysis will be redone, its content modified to store
26 // the correct final results and eventually renamed into TString outputFileName.
6a6afe42 27 TString pwd(gSystem->pwd());
28 pwd+="/";
ad87ae62 29 pwd+=mergedFileName.Data();
30 TFile *mergedFile = NULL;
31 if(gSystem->AccessPathName(pwd.Data(),kFileExists))
6a6afe42 32 {
ad87ae62 33 cout<<"WARNING: You do not have a merged output file:"<<endl;
34 cout<<" "<<pwd.Data()<<endl;
57340a27 35 cout<<endl;
36 cout<<"In order to get that file use macro mergeOutput.C first."<<endl;
37 cout<<endl;
ad87ae62 38 exit(0);
6a6afe42 39 } else
40 {
57340a27 41 // Create temporarily copy of "mergedAnalysisResults.root":
42 TSystemFile *fileTemp = new TSystemFile(mergedFileName.Data(),".");
43 fileTemp->Copy("mergedAnalysisResultsTemp.root");
44 delete fileTemp;
45 // Access merged file:
46 mergedFile = TFile::Open(pwd.Data(),"UPDATE");
6a6afe42 47 }
57340a27 48
49 // Access from mergedFile the merged files for each method and from them the lists holding histograms:
ad87ae62 50 TString fileName[nMethods];
51 TDirectoryFile *dirFile[nMethods] = {NULL};
52 TString listName[nMethods];
53 TList *list[nMethods] = {NULL};
54 for(Int_t i=0;i<nMethods;i++)
55 {
57340a27 56 // Form a file name for each method:
ad87ae62 57 fileName[i]+="output";
58 fileName[i]+=method[i].Data();
59 fileName[i]+="analysis";
60 fileName[i]+=type.Data();
57340a27 61 // Access this file:
ad87ae62 62 dirFile[i] = (TDirectoryFile*)mergedFile->FindObjectAny(fileName[i].Data());
57340a27 63 // Form a list name for each method:
ad87ae62 64 listName[i]+="cobj";
65 listName[i]+=method[i].Data();
57340a27 66 // Access this list:
ad87ae62 67 if(dirFile[i])
68 {
69 dirFile[i]->GetObject(listName[i].Data(),list[i]);
57340a27 70 } else
71 {
72 cout<<"WARNING: Couldn't find a file "<<fileName[i].Data()<<".root !!!!"<<endl;
73 }
74 } // End of for(Int_t i=0;i<nMethods;i++)
ad87ae62 75
57340a27 76 // Redo finish for each method (REMARK: this implementation can be dramatically improved!):
ad87ae62 77 // MCEP:
78 for(Int_t i=0;i<nMethods;i++)
9455e15e 79 {
ad87ae62 80 if(list[i] && strcmp(list[i]->GetName(),"cobjMCEP")==0)
9455e15e 81 {
ad87ae62 82 AliFlowAnalysisWithMCEventPlane* mcep = new AliFlowAnalysisWithMCEventPlane();
83 mcep->GetOutputHistograms(list[i]);
84 mcep->Finish();
57340a27 85 dirFile[i]->Add(list[i],kTRUE);
86 dirFile[i]->Write(dirFile[i]->GetName(),TObject::kSingleKey+TObject::kOverwrite);
ad87ae62 87 }
88 // SP:
89 else if(list[i] && strcmp(list[i]->GetName(),"cobjSP")==0)
9455e15e 90 {
ad87ae62 91 AliFlowAnalysisWithScalarProduct* sp = new AliFlowAnalysisWithScalarProduct();
92 sp->GetOutputHistograms(list[i]);
93 sp->Finish();
57340a27 94 dirFile[i]->Add(list[i],kTRUE);
95 dirFile[i]->Write(dirFile[i]->GetName(),TObject::kSingleKey+TObject::kOverwrite);
ad87ae62 96 }
97 // GFC:
98 else if(list[i] && strcmp(list[i]->GetName(),"cobjGFC")==0)
99 {
100 AliFlowAnalysisWithCumulants* gfc = new AliFlowAnalysisWithCumulants();
101 gfc->GetOutputHistograms(list[i]);
102 gfc->Finish();
57340a27 103 dirFile[i]->Add(list[i],kTRUE);
104 dirFile[i]->Write(dirFile[i]->GetName(),TObject::kSingleKey+TObject::kOverwrite);
ad87ae62 105 }
106 // QC:
107 else if(list[i] && strcmp(list[i]->GetName(),"cobjQC")==0)
108 {
109 AliFlowAnalysisWithQCumulants* qc = new AliFlowAnalysisWithQCumulants();
110 qc->GetOutputHistograms(list[i]);
111 qc->Finish();
57340a27 112 dirFile[i]->Add(list[i],kTRUE);
113 dirFile[i]->Write(dirFile[i]->GetName(),TObject::kSingleKey+TObject::kOverwrite);
ad87ae62 114 }
115 // FQD:
116 else if(list[i] && strcmp(list[i]->GetName(),"cobjFQD")==0)
117 {
118 AliFlowAnalysisWithFittingQDistribution* fqd = new AliFlowAnalysisWithFittingQDistribution();
119 fqd->GetOutputHistograms(list[i]);
120 fqd->Finish(kTRUE);
57340a27 121 dirFile[i]->Add(list[i],kTRUE);
122 dirFile[i]->Write(dirFile[i]->GetName(),TObject::kSingleKey+TObject::kOverwrite);
ad87ae62 123 }
124 // LYZ1SUM:
125 else if(list[i] && strcmp(list[i]->GetName(),"cobjLYZ1SUM")==0)
126 {
127 AliFlowAnalysisWithLeeYangZeros* lyz1sum = new AliFlowAnalysisWithLeeYangZeros();
128 lyz1sum->SetFirstRun(kTRUE);
129 lyz1sum->SetUseSum(kTRUE);
130 lyz1sum->GetOutputHistograms(list[i]);
131 lyz1sum->Finish();
57340a27 132 dirFile[i]->Add(list[i],kTRUE);
133 dirFile[i]->Write(dirFile[i]->GetName(),TObject::kSingleKey+TObject::kOverwrite);
ad87ae62 134 }
135 // LYZ2SUM:
136 else if(list[i] && strcmp(list[i]->GetName(),"cobjLYZ2SUM")==0)
137 {
138 AliFlowAnalysisWithLeeYangZeros* lyz2sum = new AliFlowAnalysisWithLeeYangZeros();
139 lyz2sum->SetFirstRun(kFALSE);
140 lyz2sum->SetUseSum(kTRUE);
141 lyz2sum->GetOutputHistograms(list[i]);
142 lyz2sum->Finish();
57340a27 143 dirFile[i]->Add(list[i],kTRUE);
144 dirFile[i]->Write(dirFile[i]->GetName(),TObject::kSingleKey+TObject::kOverwrite);
ad87ae62 145 }
146 // LYZ1PROD:
147 else if(list[i] && strcmp(list[i]->GetName(),"cobjLYZ1PROD")==0)
148 {
149 AliFlowAnalysisWithLeeYangZeros* lyz1prod = new AliFlowAnalysisWithLeeYangZeros();
150 lyz1prod->SetFirstRun(kTRUE);
151 lyz1prod->SetUseSum(kFALSE);
152 lyz1prod->GetOutputHistograms(list[i]);
153 lyz1prod->Finish();
57340a27 154 dirFile[i]->Add(list[i],kTRUE);
155 dirFile[i]->Write(dirFile[i]->GetName(),TObject::kSingleKey+TObject::kOverwrite);
ad87ae62 156 }
157 // LYZ2PROD:
158 else if(list[i] && strcmp(list[i]->GetName(),"cobjLYZ2PROD")==0)
159 {
160 AliFlowAnalysisWithLeeYangZeros* lyz2prod = new AliFlowAnalysisWithLeeYangZeros();
161 lyz2prod->SetFirstRun(kFALSE);
162 lyz2prod->SetUseSum(kFALSE);
163 lyz2prod->GetOutputHistograms(list[i]);
164 lyz2prod->Finish();
57340a27 165 dirFile[i]->Add(list[i],kTRUE);
166 dirFile[i]->Write(dirFile[i]->GetName(),TObject::kSingleKey+TObject::kOverwrite);
ad87ae62 167 }
168 // LYZEP:
169 else if(list[i] && strcmp(list[i]->GetName(),"cobjLYZEP")==0)
170 {
171 AliFlowAnalysisWithLYZEventPlane* lyzep = new AliFlowAnalysisWithLYZEventPlane();
172 lyzep->GetOutputHistograms(list[i]);
173 lyzep->Finish();
57340a27 174 dirFile[i]->Add(list[i],kTRUE);
175 dirFile[i]->Write(dirFile[i]->GetName(),TObject::kSingleKey+TObject::kOverwrite);
ad87ae62 176 }
57340a27 177 } // End of for(Int_t i=0;i<nMethods;i++)
9455e15e 178
57340a27 179 // Close the final output file:
180 mergedFile->Close();
181 delete mergedFile;
182
183 // Giving the final names:
184 TSystemFile *outputFileFinal = new TSystemFile(mergedFileName.Data(),".");
185 outputFileFinal->Rename(outputFileName.Data());
186 delete outputFileFinal;
187 TSystemFile *mergedFileFinal = new TSystemFile("mergedAnalysisResultsTemp.root",".");
188 mergedFileFinal->Rename(mergedFileName.Data());
189 delete mergedFileFinal;
ad87ae62 190
57340a27 191} // End of void redoFinish(Int_t mode=mLocal)
6a6afe42 192
ad87ae62 193void LoadLibrariesRF(const libModes mode) {
6a6afe42 194
195 //--------------------------------------
196 // Load the needed libraries most of them already loaded by aliroot
197 //--------------------------------------
ad87ae62 198 //gSystem->Load("libTree");
5d040cf3 199 gSystem->Load("libGeom");
200 gSystem->Load("libVMC");
201 gSystem->Load("libXMLIO");
202 gSystem->Load("libPhysics");
6a6afe42 203
204 //----------------------------------------------------------
205 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
206 //----------------------------------------------------------
207 if (mode==mLocal) {
208 //--------------------------------------------------------
209 // If you want to use already compiled libraries
210 // in the aliroot distribution
211 //--------------------------------------------------------
212
213 //==================================================================================
214 //load needed libraries:
215 gSystem->AddIncludePath("-I$ROOTSYS/include");
ad87ae62 216 //gSystem->Load("libTree");
6a6afe42 217
218 // for AliRoot
219 gSystem->AddIncludePath("-I$ALICE_ROOT/include");
5d040cf3 220 gSystem->Load("libANALYSIS");
221 gSystem->Load("libPWG2flowCommon");
ad87ae62 222 //cerr<<"libPWG2flowCommon loaded ..."<<endl;
6a6afe42 223
224 }
225
226 else if (mode==mLocalSource) {
227
228 // In root inline compile
229
230 // Constants
231 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonConstants.cxx+");
232 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZConstants.cxx+");
233 gROOT->LoadMacro("AliFlowCommon/AliFlowCumuConstants.cxx+");
234
235 // Flow event
236 gROOT->LoadMacro("AliFlowCommon/AliFlowVector.cxx+");
237 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimple.cxx+");
238 gROOT->LoadMacro("AliFlowCommon/AliFlowEventSimple.cxx+");
239
240 // Cuts
241 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimpleCuts.cxx+");
242
d91df799 243 // Output histograms
6a6afe42 244 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHist.cxx+");
245 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHistResults.cxx+");
246 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist1.cxx+");
247 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist2.cxx+");
d91df799 248
249 // Functions needed for various methods
250 gROOT->LoadMacro("AliFlowCommon/AliCumulantsFunctions.cxx+");
251 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZEventPlane.cxx+");
252
253 // Flow Analysis code for various methods
254 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithMCEventPlane.cxx+");
255 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithScalarProduct.cxx+");
256 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithLYZEventPlane.cxx+");
257 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithLeeYangZeros.cxx+");
258 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithCumulants.cxx+");
259 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithQCumulants.cxx+");
260 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithFittingQDistribution.cxx+");
6a6afe42 261
262 cout << "finished loading macros!" << endl;
263
264 } // end of else if (mode==mLocalSource)
265
ad87ae62 266} // end of void LoadLibrariesRF(const libModes mode)
6a6afe42 267
268