1 // Macro redoFinish.C is typically used after the merging macros (mergeOutput.C or
2 // mergeOutputOnGrid.C) have been used to produce the merged, large statistics
3 // file of flow analysis. Results stored in merged file are WRONG because after
4 // merging the results from small statistics files are trivially summed up in all
5 // histograms. This is taken into account and corrected for with macro redoFinish.C.
6 // Another typical use of the macro redoFinish.C is to repeat the call to Finish()
7 // in all classes, but with different values of some settings which might modify
8 // the final results (Example: redo the Finish() and apply correction for detector
9 // effects in QC code because by default this correction is switched off).
11 // Name of the merged, large statistics file obtained with the merging macros:
12 TString mergedFileName = "outputCentralityTrain.root";
13 // Final output file name holding correct final results for large statistics sample:
14 TString outputFileName = "AnalysisResults.root";
15 // Methods for which the flow analysis will be redone:
16 const Int_t nMethods = 12;
17 TString method[nMethods] = {"MCEP","SP","GFC","QC","FQD","LYZ1SUM","LYZ1PROD","LYZ2SUM","LYZ2PROD","LYZEP","MH","NL"};
18 // Methods for which some settings can be modified before redoing Finish():
20 Bool_t bApplyCorrectionForNUA = kFALSE; // apply correction for non-uniform acceptance
21 Bool_t bApplyCorrectionForNUAVsM = kFALSE; // apply correction for non-uniform acceptance in each multiplicity bin independently
22 Bool_t bPropagateErrorAlsoFromNIT = kFALSE; // propagate error also from non-isotropic terms
23 Bool_t bMinimumBiasReferenceFlow = kTRUE; // store in CRH for reference flow the result obtained wihout rebinning in multiplicity (kTRUE)
25 enum libModes {mLocal,mLocalSource};
27 void redoFinish(TString type="ESD global", Int_t mode=mLocal)
29 // type: type of analysis can be ESD, AOD, MC, ....
30 // (if type="" output files are from simulation 'on the fly')
31 // mode: if mode = mLocal: analyze data on your computer using aliroot
32 // if mode = mLocalSource: analyze data on your computer using root + source files
34 // Load needed libraries:
35 LoadLibrariesRF(mode);
37 // Accessing <mergedFileName>:
38 TString mergedFileFullPathName(gSystem->pwd());
39 mergedFileFullPathName+="/";
40 mergedFileFullPathName+=mergedFileName.Data();
41 TFile *mergedFile = NULL;
42 if(gSystem->AccessPathName(mergedFileFullPathName.Data(),kFileExists))
45 cout<<" WARNING: Couldn't find a file: "<<mergedFileName.Data()<<endl;
46 cout<<" in directory "<<gSystem->pwd()<<" !!!!"<<endl;
52 // Create temporarily copy of <mergedFileName> if neccessary:
53 if(!(mergedFileName == outputFileName))
55 TSystemFile *fileTemp = new TSystemFile(mergedFileFullPathName.Data(),".");
56 fileTemp->Copy("mergedAnalysisResultsTemp.root");
59 // Access <mergedFileName>:
60 mergedFile = TFile::Open(mergedFileFullPathName.Data(),"UPDATE");
63 // Access from <mergedFileName> the merged TDirectoryFile's for each method and from them the lists holding histograms:
64 for(Int_t i=0; i<nMethods; i++)
66 TString directoryName("");
67 TDirectory* directory = NULL;
69 // Form a file name for each method:
70 directoryName+="output";
71 directoryName+=method[i].Data();
72 directoryName+="analysis";
73 directoryName+=type.Data();
75 directory = (TDirectory*)mergedFile->FindObjectAny(directoryName.Data());
76 // Form a list name for each method:
79 cout<<" WARNING: Couldn't find a TDirectory "<<directoryName.Data()<<" in file "<<mergedFileName.Data()<<endl;
83 TList* listTemp = directory->GetListOfKeys();
86 cout<<" WARNING: Accessing TList from TDirectoryFile failed for method "<<method[i].Data()<<" !!!!"<<endl;
87 cout<<" Did you actually specify "<<method[i].Data()<<" in the analysis?"<<endl;
92 for (Int_t icent=0; icent<listTemp->GetEntries(); icent++)
94 TList* list = dynamic_cast<TList*>(directory->Get(listTemp->At(icent)->GetName()));
98 if(TString(list->GetName()).Contains("cobjMCEP"))
100 AliFlowAnalysisWithMCEventPlane* mcep = new AliFlowAnalysisWithMCEventPlane();
101 mcep->GetOutputHistograms(list);
103 directory->Add(list,kTRUE);
104 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
107 else if(TString(list->GetName()).Contains("cobjSP"))
109 AliFlowAnalysisWithScalarProduct* sp = new AliFlowAnalysisWithScalarProduct();
110 sp->GetOutputHistograms(list);
112 directory->Add(list,kTRUE);
113 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
116 else if(TString(list->GetName()).Contains("cobjGFC"))
118 AliFlowAnalysisWithCumulants* gfc = new AliFlowAnalysisWithCumulants();
119 gfc->GetOutputHistograms(list);
121 directory->Add(list,kTRUE);
122 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
125 else if(TString(list->GetName()).Contains("cobjQC"))
127 AliFlowAnalysisWithQCumulants* qc = new AliFlowAnalysisWithQCumulants();
128 qc->GetOutputHistograms(list);
129 qc->GetIntFlowFlags()->SetBinContent(3,(Int_t)bApplyCorrectionForNUA);
130 qc->GetIntFlowFlags()->SetBinContent(8,(Int_t)bApplyCorrectionForNUAVsM);
131 qc->GetIntFlowFlags()->SetBinContent(9,(Int_t)bPropagateErrorAlsoFromNIT);
132 qc->GetIntFlowFlags()->SetBinContent(11,(Int_t)bMinimumBiasReferenceFlow);
134 directory->Add(list,kTRUE);
135 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
138 else if(TString(list->GetName()).Contains("cobjFQD"))
140 AliFlowAnalysisWithFittingQDistribution* fqd = new AliFlowAnalysisWithFittingQDistribution();
141 fqd->GetOutputHistograms(list);
143 directory->Add(list,kTRUE);
144 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
147 else if(TString(list->GetName()).Contains("cobjLYZ1SUM"))
149 AliFlowAnalysisWithLeeYangZeros* lyz1sum = new AliFlowAnalysisWithLeeYangZeros();
150 lyz1sum->SetFirstRun(kTRUE);
151 lyz1sum->SetUseSum(kTRUE);
152 lyz1sum->GetOutputHistograms(list);
154 directory->Add(list,kTRUE);
155 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
158 else if(TString(list->GetName()).Contains("cobjLYZ2SUM"))
160 AliFlowAnalysisWithLeeYangZeros* lyz2sum = new AliFlowAnalysisWithLeeYangZeros();
161 lyz2sum->SetFirstRun(kFALSE);
162 lyz2sum->SetUseSum(kTRUE);
163 lyz2sum->GetOutputHistograms(list);
165 directory->Add(list,kTRUE);
166 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
169 else if(TString(list->GetName()).Contains("cobjLYZ1PROD"))
171 AliFlowAnalysisWithLeeYangZeros* lyz1prod = new AliFlowAnalysisWithLeeYangZeros();
172 lyz1prod->SetFirstRun(kTRUE);
173 lyz1prod->SetUseSum(kFALSE);
174 lyz1prod->GetOutputHistograms(list);
176 directory->Add(list,kTRUE);
177 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
180 else if(TString(list->GetName()).Contains("cobjLYZ2PROD"))
182 AliFlowAnalysisWithLeeYangZeros* lyz2prod = new AliFlowAnalysisWithLeeYangZeros();
183 lyz2prod->SetFirstRun(kFALSE);
184 lyz2prod->SetUseSum(kFALSE);
185 lyz2prod->GetOutputHistograms(list);
187 directory->Add(list,kTRUE);
188 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
191 else if(TString(list->GetName()).Contains("cobjLYZEP"))
193 AliFlowAnalysisWithLYZEventPlane* lyzep = new AliFlowAnalysisWithLYZEventPlane();
194 lyzep->GetOutputHistograms(list);
196 directory->Add(list,kTRUE);
197 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
200 else if(TString(list->GetName()).Contains("cobjMH"))
202 AliFlowAnalysisWithMixedHarmonics* mh = new AliFlowAnalysisWithMixedHarmonics();
203 mh->GetOutputHistograms(list);
205 directory->Add(list,kTRUE);
206 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
209 else if(TString(list->GetName()).Contains("cobjNL"))
211 AliFlowAnalysisWithNestedLoops* nl = new AliFlowAnalysisWithNestedLoops();
212 nl->GetOutputHistograms(list);
214 directory->Add(list,kTRUE);
215 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
218 }// end of for(Int_t i=0;i<nMethods;i++)
220 // Close the final output file:
223 // Giving the final names if neccessary:
224 if(!(mergedFileName == outputFileName))
226 TSystemFile *outputFileFinal = new TSystemFile(mergedFileName.Data(),".");
227 outputFileFinal->Rename(outputFileName.Data());
228 delete outputFileFinal;
229 TSystemFile *mergedFileFinal = new TSystemFile("mergedAnalysisResultsTemp.root",".");
230 mergedFileFinal->Rename(mergedFileName.Data());
231 delete mergedFileFinal;
232 } // end of if(!(mergedFileName == outputFileName))
236 } // end of void redoFinish(Int_t mode=mLocal)
238 void LoadLibrariesRF(const libModes mode)
241 //--------------------------------------
242 // Load the needed libraries most of them already loaded by aliroot
243 //--------------------------------------
244 //gSystem->Load("libTree");
245 gSystem->Load("libGeom");
246 gSystem->Load("libVMC");
247 gSystem->Load("libXMLIO");
248 gSystem->Load("libPhysics");
250 //----------------------------------------------------------
251 // >>>>>>>>>>> Local mode <<<<<<<<<<<<<<
252 //----------------------------------------------------------
255 //--------------------------------------------------------
256 // If you want to use already compiled libraries
257 // in the aliroot distribution
258 //--------------------------------------------------------
260 //==================================================================================
261 //load needed libraries:
262 gSystem->AddIncludePath("-I$ROOTSYS/include");
263 //gSystem->Load("libTree");
266 gSystem->AddIncludePath("-I$ALICE_ROOT/include");
267 gSystem->Load("libANALYSIS");
268 gSystem->Load("libPWG2flowCommon");
269 //cerr<<"libPWG2flowCommon loaded ..."<<endl;
273 else if (mode==mLocalSource)
276 // In root inline compile
279 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonConstants.cxx+");
280 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZConstants.cxx+");
283 gROOT->LoadMacro("AliFlowCommon/AliFlowVector.cxx+");
284 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimple.cxx+");
285 gROOT->LoadMacro("AliFlowCommon/AliFlowTrackSimpleCuts.cxx+");
286 gROOT->LoadMacro("AliFlowCommon/AliFlowEventSimple.cxx+");
289 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHist.cxx+");
290 gROOT->LoadMacro("AliFlowCommon/AliFlowCommonHistResults.cxx+");
291 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist1.cxx+");
292 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZHist2.cxx+");
294 // Functions needed for various methods
295 gROOT->LoadMacro("AliFlowCommon/AliCumulantsFunctions.cxx+");
296 gROOT->LoadMacro("AliFlowCommon/AliFlowLYZEventPlane.cxx+");
298 // Flow Analysis code for various methods
299 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithMCEventPlane.cxx+");
300 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithScalarProduct.cxx+");
301 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithLYZEventPlane.cxx+");
302 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithLeeYangZeros.cxx+");
303 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithCumulants.cxx+");
304 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithQCumulants.cxx+");
305 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithFittingQDistribution.cxx+");
306 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithMixedHarmonics.cxx+");
307 gROOT->LoadMacro("AliFlowCommon/AliFlowAnalysisWithNestedLoops.cxx+");
309 cout << "finished loading macros!" << endl;
311 } // end of else if (mode==mLocalSource)
313 } // end of void LoadLibrariesRF(const libModes mode)