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 = "mergedAnalysisResults.root";
13 // Final output file name holding correct final results for large statistics sample:
14 TString outputFileName = "AnalysisResults.root";
16 Bool_t bApplyCorrectionForNUA = kFALSE; // apply correction for non-uniform acceptance
17 Bool_t bApplyCorrectionForNUAVsM = kFALSE; // apply correction for non-uniform acceptance in each multiplicity bin independently
18 Bool_t bPropagateErrorAlsoFromNIT = kFALSE; // propagate error also from non-isotropic terms
19 Bool_t bMinimumBiasReferenceFlow = kTRUE; // store in CRH for reference flow the result obtained wihout rebinning in multiplicity (kTRUE)
20 Bool_t checkForCommonHistResults = kTRUE; // check explicitely if the TList AliFlowCommonHistResults is available in the output
26 TString mergedFileFullPathName(gSystem->pwd());
27 mergedFileFullPathName+="/";
28 mergedFileFullPathName+=mergedFileName.Data();
29 TFile *mergedFile = NULL;
30 if(gSystem->AccessPathName(mergedFileFullPathName.Data(),kFileExists))
33 cout<<" WARNING: Couldn't find a file: "<<mergedFileName.Data()<<endl;
34 cout<<" in directory "<<gSystem->pwd()<<" !!!!"<<endl;
40 // Create temporarily copy of <mergedFileName> if neccessary:
41 if(!(mergedFileName == outputFileName))
43 TSystemFile *fileTemp = new TSystemFile(mergedFileFullPathName.Data(),".");
44 fileTemp->Copy("mergedAnalysisResultsTemp.root");
47 // Access <mergedFileName>:
48 mergedFile = TFile::Open(mergedFileFullPathName.Data(),"UPDATE");
51 // Access from <mergedFileName> the merged TDirectoryFile's for each method and from them the lists holding histograms:
53 TList* mergedFileKeys = mergedFile->GetListOfKeys();
54 for(Int_t i=0; i<mergedFileKeys->GetEntries(); i++)
56 TDirectory* directory = dynamic_cast<TDirectory*>(mergedFile->Get(mergedFileKeys->At(i)->GetName()));
57 if (!directory) continue;
59 TList* listTemp = directory->GetListOfKeys();
60 if(!listTemp) continue;
61 for (Int_t icent=0; icent<listTemp->GetEntries(); icent++)
63 TList* list = dynamic_cast<TList*>(directory->Get(listTemp->At(icent)->GetName()));
65 if(checkForCommonHistResults && (!CheckForCommonHistResults(list))) continue;
67 if(TString(list->GetName()).Contains("MCEP"))
69 AliFlowAnalysisWithMCEventPlane* mcep = new AliFlowAnalysisWithMCEventPlane();
70 mcep->GetOutputHistograms(list);
72 directory->Add(list,kTRUE);
73 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
76 else if(TString(list->GetName()).Contains("SP"))
78 AliFlowAnalysisWithScalarProduct* sp = new AliFlowAnalysisWithScalarProduct();
79 sp->GetOutputHistograms(list);
80 //sp->GetHistProFlags()->SetBinContent(1,(Int_t)bApplyCorrectionForNUA);
82 directory->Add(list,kTRUE);
83 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
86 else if(TString(list->GetName()).Contains("GFC"))
88 AliFlowAnalysisWithCumulants* gfc = new AliFlowAnalysisWithCumulants();
89 gfc->GetOutputHistograms(list);
91 directory->Add(list,kTRUE);
92 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
95 else if(TString(list->GetName()).Contains("QC"))
97 AliFlowAnalysisWithQCumulants* qc = new AliFlowAnalysisWithQCumulants();
98 qc->GetOutputHistograms(list);
99 qc->GetIntFlowFlags()->SetBinContent(3,(Int_t)bApplyCorrectionForNUA);
100 qc->GetIntFlowFlags()->SetBinContent(8,(Int_t)bApplyCorrectionForNUAVsM);
101 qc->GetIntFlowFlags()->SetBinContent(9,(Int_t)bPropagateErrorAlsoFromNIT);
102 qc->GetIntFlowFlags()->SetBinContent(11,(Int_t)bMinimumBiasReferenceFlow);
104 directory->Add(list,kTRUE);
105 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
108 else if(TString(list->GetName()).Contains("FQD"))
110 AliFlowAnalysisWithFittingQDistribution* fqd = new AliFlowAnalysisWithFittingQDistribution();
111 fqd->GetOutputHistograms(list);
113 directory->Add(list,kTRUE);
114 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
117 else if(TString(list->GetName()).Contains("LYZ1SUM"))
119 AliFlowAnalysisWithLeeYangZeros* lyz1sum = new AliFlowAnalysisWithLeeYangZeros();
120 lyz1sum->SetFirstRun(kTRUE);
121 lyz1sum->SetUseSum(kTRUE);
122 lyz1sum->GetOutputHistograms(list);
124 directory->Add(list,kTRUE);
125 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
128 else if(TString(list->GetName()).Contains("LYZ2SUM"))
130 AliFlowAnalysisWithLeeYangZeros* lyz2sum = new AliFlowAnalysisWithLeeYangZeros();
131 lyz2sum->SetFirstRun(kFALSE);
132 lyz2sum->SetUseSum(kTRUE);
133 lyz2sum->GetOutputHistograms(list);
135 directory->Add(list,kTRUE);
136 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
139 else if(TString(list->GetName()).Contains("LYZ1PROD"))
141 AliFlowAnalysisWithLeeYangZeros* lyz1prod = new AliFlowAnalysisWithLeeYangZeros();
142 lyz1prod->SetFirstRun(kTRUE);
143 lyz1prod->SetUseSum(kFALSE);
144 lyz1prod->GetOutputHistograms(list);
146 directory->Add(list,kTRUE);
147 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
150 else if(TString(list->GetName()).Contains("LYZ2PROD"))
152 AliFlowAnalysisWithLeeYangZeros* lyz2prod = new AliFlowAnalysisWithLeeYangZeros();
153 lyz2prod->SetFirstRun(kFALSE);
154 lyz2prod->SetUseSum(kFALSE);
155 lyz2prod->GetOutputHistograms(list);
157 directory->Add(list,kTRUE);
158 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
161 else if(TString(list->GetName()).Contains("LYZEP"))
163 AliFlowAnalysisWithLYZEventPlane* lyzep = new AliFlowAnalysisWithLYZEventPlane();
164 lyzep->GetOutputHistograms(list);
166 directory->Add(list,kTRUE);
167 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
170 else if(TString(list->GetName()).Contains("MH"))
172 AliFlowAnalysisWithMixedHarmonics* mh = new AliFlowAnalysisWithMixedHarmonics();
173 mh->GetOutputHistograms(list);
174 mh->GetAnalysisSettings()->SetBinContent(1,(Int_t)bApplyCorrectionForNUA);
176 directory->Add(list,kTRUE);
177 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
180 else if(TString(list->GetName()).Contains("NL"))
182 AliFlowAnalysisWithNestedLoops* nl = new AliFlowAnalysisWithNestedLoops();
183 nl->GetOutputHistograms(list);
185 directory->Add(list,kTRUE);
186 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
191 // Close the final output file:
194 // Giving the final names if neccessary:
195 if(!(mergedFileName == outputFileName))
197 TSystemFile *outputFileFinal = new TSystemFile(mergedFileName.Data(),".");
198 outputFileFinal->Rename(outputFileName.Data());
199 delete outputFileFinal;
200 TSystemFile *mergedFileFinal = new TSystemFile("mergedAnalysisResultsTemp.root",".");
201 mergedFileFinal->Rename(mergedFileName.Data());
202 delete mergedFileFinal;
203 } // end of if(!(mergedFileName == outputFileName))
207 } // end of void redoFinish(Int_t mode=mLocal)
211 //--------------------------------------
212 // Load the needed libraries most of them already loaded by aliroot
213 //--------------------------------------
214 //gSystem->Load("libTree");
215 gSystem->Load("libGeom");
216 gSystem->Load("libVMC");
217 gSystem->Load("libXMLIO");
218 gSystem->Load("libPhysics");
221 gSystem->Load("libANALYSIS");
222 gSystem->Load("libANALYSISalice");
223 gSystem->Load("libPWGflowBase");
224 gSystem->Load("libPWGflowTasks");
225 } // end of void LoadLibrariesRF(const libModes mode)
227 Bool_t CheckForCommonHistResults(TList* list) {
228 // check for common hist results. Redmer Alexander Bertens, r.a.bertens@cern.ch
229 for(Int_t i(0); i < list->GetEntries(); i++) if(((list->At(i))->IsA())->GetBaseClass("AliFlowCommonHistResults")) return kTRUE;