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 gSystem->Unlink("mergedAnalysisResultsTemp.root");
45 fileTemp->Copy("mergedAnalysisResultsTemp.root");
48 // Access <mergedFileName>:
49 mergedFile = TFile::Open(mergedFileFullPathName.Data(),"UPDATE");
52 // Access from <mergedFileName> the merged TDirectoryFile's for each method and from them the lists holding histograms:
54 TList* mergedFileKeys = mergedFile->GetListOfKeys();
55 for(Int_t i=0; i<mergedFileKeys->GetEntries(); i++)
57 TDirectory* directory = dynamic_cast<TDirectory*>(mergedFile->Get(mergedFileKeys->At(i)->GetName()));
58 if (!directory) continue;
60 TList* listTemp = directory->GetListOfKeys();
61 if(!listTemp) continue;
62 for (Int_t icent=0; icent<listTemp->GetEntries(); icent++)
64 TList* list = dynamic_cast<TList*>(directory->Get(listTemp->At(icent)->GetName()));
66 if(checkForCommonHistResults && (!CheckForCommonHistResults(list))) continue;
68 if(TString(list->GetName()).Contains("MCEP"))
70 AliFlowAnalysisWithMCEventPlane* mcep = new AliFlowAnalysisWithMCEventPlane();
71 mcep->GetOutputHistograms(list);
73 directory->Add(list,kTRUE);
74 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
77 else if(TString(list->GetName()).Contains("SP"))
79 AliFlowAnalysisWithScalarProduct* sp = new AliFlowAnalysisWithScalarProduct();
80 sp->GetOutputHistograms(list);
81 sp->GetHistProConfig()->SetBinContent(1,(Int_t)bApplyCorrectionForNUA*
82 sp->GetHistProConfig()->GetEntries());
84 directory->Add(list,kTRUE);
85 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
88 else if(TString(list->GetName()).Contains("GFC"))
90 AliFlowAnalysisWithCumulants* gfc = new AliFlowAnalysisWithCumulants();
91 gfc->GetOutputHistograms(list);
93 directory->Add(list,kTRUE);
94 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
97 else if(TString(list->GetName()).Contains("QC"))
99 AliFlowAnalysisWithQCumulants* qc = new AliFlowAnalysisWithQCumulants();
100 qc->GetOutputHistograms(list);
101 qc->GetIntFlowFlags()->SetBinContent(3,(Int_t)bApplyCorrectionForNUA);
102 qc->GetIntFlowFlags()->SetBinContent(8,(Int_t)bApplyCorrectionForNUAVsM);
103 qc->GetIntFlowFlags()->SetBinContent(9,(Int_t)bPropagateErrorAlsoFromNIT);
104 qc->GetIntFlowFlags()->SetBinContent(11,(Int_t)bMinimumBiasReferenceFlow);
106 directory->Add(list,kTRUE);
107 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
110 else if(TString(list->GetName()).Contains("FQD"))
112 AliFlowAnalysisWithFittingQDistribution* fqd = new AliFlowAnalysisWithFittingQDistribution();
113 fqd->GetOutputHistograms(list);
115 directory->Add(list,kTRUE);
116 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
119 else if(TString(list->GetName()).Contains("LYZ1SUM"))
121 AliFlowAnalysisWithLeeYangZeros* lyz1sum = new AliFlowAnalysisWithLeeYangZeros();
122 lyz1sum->SetFirstRun(kTRUE);
123 lyz1sum->SetUseSum(kTRUE);
124 lyz1sum->GetOutputHistograms(list);
126 directory->Add(list,kTRUE);
127 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
130 else if(TString(list->GetName()).Contains("LYZ2SUM"))
132 AliFlowAnalysisWithLeeYangZeros* lyz2sum = new AliFlowAnalysisWithLeeYangZeros();
133 lyz2sum->SetFirstRun(kFALSE);
134 lyz2sum->SetUseSum(kTRUE);
135 lyz2sum->GetOutputHistograms(list);
137 directory->Add(list,kTRUE);
138 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
141 else if(TString(list->GetName()).Contains("LYZ1PROD"))
143 AliFlowAnalysisWithLeeYangZeros* lyz1prod = new AliFlowAnalysisWithLeeYangZeros();
144 lyz1prod->SetFirstRun(kTRUE);
145 lyz1prod->SetUseSum(kFALSE);
146 lyz1prod->GetOutputHistograms(list);
148 directory->Add(list,kTRUE);
149 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
152 else if(TString(list->GetName()).Contains("LYZ2PROD"))
154 AliFlowAnalysisWithLeeYangZeros* lyz2prod = new AliFlowAnalysisWithLeeYangZeros();
155 lyz2prod->SetFirstRun(kFALSE);
156 lyz2prod->SetUseSum(kFALSE);
157 lyz2prod->GetOutputHistograms(list);
159 directory->Add(list,kTRUE);
160 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
163 else if(TString(list->GetName()).Contains("LYZEP"))
165 AliFlowAnalysisWithLYZEventPlane* lyzep = new AliFlowAnalysisWithLYZEventPlane();
166 lyzep->GetOutputHistograms(list);
168 directory->Add(list,kTRUE);
169 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
172 else if(TString(list->GetName()).Contains("MH"))
174 AliFlowAnalysisWithMixedHarmonics* mh = new AliFlowAnalysisWithMixedHarmonics();
175 mh->GetOutputHistograms(list);
176 mh->GetAnalysisSettings()->SetBinContent(1,(Int_t)bApplyCorrectionForNUA);
178 directory->Add(list,kTRUE);
179 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
182 else if(TString(list->GetName()).Contains("NL"))
184 AliFlowAnalysisWithNestedLoops* nl = new AliFlowAnalysisWithNestedLoops();
185 nl->GetOutputHistograms(list);
187 directory->Add(list,kTRUE);
188 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
193 // Close the final output file:
196 // Giving the final names if neccessary:
197 if(!(mergedFileName == outputFileName))
199 TSystemFile *outputFileFinal = new TSystemFile(mergedFileName.Data(),".");
200 outputFileFinal->Rename(outputFileName.Data());
201 delete outputFileFinal;
202 TSystemFile *mergedFileFinal = new TSystemFile("mergedAnalysisResultsTemp.root",".");
203 mergedFileFinal->Rename(mergedFileName.Data());
204 delete mergedFileFinal;
205 } // end of if(!(mergedFileName == outputFileName))
209 } // end of void redoFinish(Int_t mode=mLocal)
213 //--------------------------------------
214 // Load the needed libraries most of them already loaded by aliroot
215 //--------------------------------------
216 //gSystem->Load("libTree");
217 gSystem->Load("libGeom");
218 gSystem->Load("libVMC");
219 gSystem->Load("libXMLIO");
220 gSystem->Load("libPhysics");
223 gSystem->Load("libANALYSIS");
224 gSystem->Load("libANALYSISalice");
225 gSystem->Load("libPWGflowBase");
226 gSystem->Load("libPWGflowTasks");
227 } // end of void LoadLibrariesRF(const libModes mode)
229 Bool_t CheckForCommonHistResults(TList* list) {
230 // check for common hist results. Redmer Alexander Bertens, r.a.bertens@cern.ch
231 for(Int_t i(0); i < list->GetEntries(); i++) if(((list->At(i))->IsA())->GetBaseClass("AliFlowCommonHistResults")) return kTRUE;