]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGCF/FLOW/macros/redoFinish.C
initial checkin of the new flow development - from an OLD diff!
[u/mrichter/AliRoot.git] / PWGCF / FLOW / macros / redoFinish.C
CommitLineData
441ea1cf 1// Macro redoFinish.C is typically used after the merging macros (mergeOutput.C or
021fb870 2// mergeOutputOnGrid.C) have been used to produce the merged, large statistics
441ea1cf 3// file of flow analysis. Results stored in merged file are WRONG because after
021fb870 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).
10
441ea1cf 11// Name of the merged, large statistics file obtained with the merging macros:
50040ed6 12TString mergedFileName = "mergedAnalysisResults.root";
021fb870 13// Final output file name holding correct final results for large statistics sample:
441ea1cf 14TString outputFileName = "AnalysisResults.root";
499fe731 15
021fb870 16Bool_t bApplyCorrectionForNUA = kFALSE; // apply correction for non-uniform acceptance
17Bool_t bApplyCorrectionForNUAVsM = kFALSE; // apply correction for non-uniform acceptance in each multiplicity bin independently
18Bool_t bPropagateErrorAlsoFromNIT = kFALSE; // propagate error also from non-isotropic terms
b77b6434 19Bool_t bMinimumBiasReferenceFlow = kTRUE; // store in CRH for reference flow the result obtained wihout rebinning in multiplicity (kTRUE)
851b1aa6 20Bool_t checkForCommonHistResults = kTRUE; // check explicitely if the TList AliFlowCommonHistResults is available in the output
ad87ae62 21
499fe731 22void redoFinish()
6a6afe42 23{
499fe731 24 LoadLibraries();
ad87ae62 25
441ea1cf 26 TString mergedFileFullPathName(gSystem->pwd());
27 mergedFileFullPathName+="/";
28 mergedFileFullPathName+=mergedFileName.Data();
29 TFile *mergedFile = NULL;
30 if(gSystem->AccessPathName(mergedFileFullPathName.Data(),kFileExists))
31 {
32 cout<<endl;
33 cout<<" WARNING: Couldn't find a file: "<<mergedFileName.Data()<<endl;
34 cout<<" in directory "<<gSystem->pwd()<<" !!!!"<<endl;
35 cout<<endl;
36 exit(0);
37 }
38 else
39 {
021fb870 40 // Create temporarily copy of <mergedFileName> if neccessary:
41 if(!(mergedFileName == outputFileName))
42 {
441ea1cf 43 TSystemFile *fileTemp = new TSystemFile(mergedFileFullPathName.Data(),".");
8fa6a5fa 44 gSystem->Unlink("mergedAnalysisResultsTemp.root");
441ea1cf 45 fileTemp->Copy("mergedAnalysisResultsTemp.root");
46 delete fileTemp;
021fb870 47 }
48 // Access <mergedFileName>:
49 mergedFile = TFile::Open(mergedFileFullPathName.Data(),"UPDATE");
441ea1cf 50 }
51
52 // Access from <mergedFileName> the merged TDirectoryFile's for each method and from them the lists holding histograms:
499fe731 53
54 TList* mergedFileKeys = mergedFile->GetListOfKeys();
55 for(Int_t i=0; i<mergedFileKeys->GetEntries(); i++)
ad87ae62 56 {
499fe731 57 TDirectory* directory = dynamic_cast<TDirectory*>(mergedFile->Get(mergedFileKeys->At(i)->GetName()));
58 if (!directory) continue;
ad87ae62 59
441ea1cf 60 TList* listTemp = directory->GetListOfKeys();
8da4b0c9 61 if(!listTemp) continue;
441ea1cf 62 for (Int_t icent=0; icent<listTemp->GetEntries(); icent++)
63 {
64 TList* list = dynamic_cast<TList*>(directory->Get(listTemp->At(icent)->GetName()));
65 if (!list) continue;
851b1aa6 66 if(checkForCommonHistResults && (!CheckForCommonHistResults(list))) continue;
441ea1cf 67 ////////////////////
499fe731 68 if(TString(list->GetName()).Contains("MCEP"))
441ea1cf 69 {
70 AliFlowAnalysisWithMCEventPlane* mcep = new AliFlowAnalysisWithMCEventPlane();
71 mcep->GetOutputHistograms(list);
72 mcep->Finish();
73 directory->Add(list,kTRUE);
74 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
75 }
76 // SP:
499fe731 77 else if(TString(list->GetName()).Contains("SP"))
441ea1cf 78 {
79 AliFlowAnalysisWithScalarProduct* sp = new AliFlowAnalysisWithScalarProduct();
80 sp->GetOutputHistograms(list);
388c12f9 81 sp->GetHistProConfig()->SetBinContent(1,(Int_t)bApplyCorrectionForNUA*
82 sp->GetHistProConfig()->GetEntries());
441ea1cf 83 sp->Finish();
84 directory->Add(list,kTRUE);
85 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
86 }
87 // GFC:
499fe731 88 else if(TString(list->GetName()).Contains("GFC"))
441ea1cf 89 {
90 AliFlowAnalysisWithCumulants* gfc = new AliFlowAnalysisWithCumulants();
91 gfc->GetOutputHistograms(list);
92 gfc->Finish();
93 directory->Add(list,kTRUE);
94 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
95 }
96 // QC:
499fe731 97 else if(TString(list->GetName()).Contains("QC"))
441ea1cf 98 {
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);
105 qc->Finish();
106 directory->Add(list,kTRUE);
107 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
108 }
109 // FQD:
499fe731 110 else if(TString(list->GetName()).Contains("FQD"))
441ea1cf 111 {
112 AliFlowAnalysisWithFittingQDistribution* fqd = new AliFlowAnalysisWithFittingQDistribution();
113 fqd->GetOutputHistograms(list);
114 fqd->Finish(kTRUE);
115 directory->Add(list,kTRUE);
116 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
117 }
118 // LYZ1SUM:
499fe731 119 else if(TString(list->GetName()).Contains("LYZ1SUM"))
441ea1cf 120 {
121 AliFlowAnalysisWithLeeYangZeros* lyz1sum = new AliFlowAnalysisWithLeeYangZeros();
122 lyz1sum->SetFirstRun(kTRUE);
123 lyz1sum->SetUseSum(kTRUE);
124 lyz1sum->GetOutputHistograms(list);
125 lyz1sum->Finish();
126 directory->Add(list,kTRUE);
127 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
128 }
129 // LYZ2SUM:
499fe731 130 else if(TString(list->GetName()).Contains("LYZ2SUM"))
441ea1cf 131 {
132 AliFlowAnalysisWithLeeYangZeros* lyz2sum = new AliFlowAnalysisWithLeeYangZeros();
133 lyz2sum->SetFirstRun(kFALSE);
134 lyz2sum->SetUseSum(kTRUE);
135 lyz2sum->GetOutputHistograms(list);
136 lyz2sum->Finish();
137 directory->Add(list,kTRUE);
138 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
139 }
140 // LYZ1PROD:
499fe731 141 else if(TString(list->GetName()).Contains("LYZ1PROD"))
441ea1cf 142 {
143 AliFlowAnalysisWithLeeYangZeros* lyz1prod = new AliFlowAnalysisWithLeeYangZeros();
144 lyz1prod->SetFirstRun(kTRUE);
145 lyz1prod->SetUseSum(kFALSE);
146 lyz1prod->GetOutputHistograms(list);
147 lyz1prod->Finish();
148 directory->Add(list,kTRUE);
149 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
150 }
151 // LYZ2PROD:
499fe731 152 else if(TString(list->GetName()).Contains("LYZ2PROD"))
441ea1cf 153 {
154 AliFlowAnalysisWithLeeYangZeros* lyz2prod = new AliFlowAnalysisWithLeeYangZeros();
155 lyz2prod->SetFirstRun(kFALSE);
156 lyz2prod->SetUseSum(kFALSE);
157 lyz2prod->GetOutputHistograms(list);
158 lyz2prod->Finish();
159 directory->Add(list,kTRUE);
160 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
161 }
162 // LYZEP:
499fe731 163 else if(TString(list->GetName()).Contains("LYZEP"))
441ea1cf 164 {
165 AliFlowAnalysisWithLYZEventPlane* lyzep = new AliFlowAnalysisWithLYZEventPlane();
166 lyzep->GetOutputHistograms(list);
167 lyzep->Finish();
168 directory->Add(list,kTRUE);
169 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
170 }
171 // MH:
499fe731 172 else if(TString(list->GetName()).Contains("MH"))
441ea1cf 173 {
174 AliFlowAnalysisWithMixedHarmonics* mh = new AliFlowAnalysisWithMixedHarmonics();
175 mh->GetOutputHistograms(list);
50040ed6 176 mh->GetAnalysisSettings()->SetBinContent(1,(Int_t)bApplyCorrectionForNUA);
441ea1cf 177 mh->Finish();
178 directory->Add(list,kTRUE);
179 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
180 }
181 // NL:
499fe731 182 else if(TString(list->GetName()).Contains("NL"))
441ea1cf 183 {
184 AliFlowAnalysisWithNestedLoops* nl = new AliFlowAnalysisWithNestedLoops();
185 nl->GetOutputHistograms(list);
186 nl->Finish();
187 directory->Add(list,kTRUE);
188 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
189 }
190 }//for icent
499fe731 191 }//
441ea1cf 192
193 // Close the final output file:
194 delete mergedFile;
195
196 // Giving the final names if neccessary:
197 if(!(mergedFileName == outputFileName))
198 {
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))
206
207 cout<<endl;
9455e15e 208
021fb870 209} // end of void redoFinish(Int_t mode=mLocal)
441ea1cf 210
499fe731 211void LoadLibraries()
441ea1cf 212{
6a6afe42 213 //--------------------------------------
214 // Load the needed libraries most of them already loaded by aliroot
215 //--------------------------------------
ad87ae62 216 //gSystem->Load("libTree");
5d040cf3 217 gSystem->Load("libGeom");
218 gSystem->Load("libVMC");
219 gSystem->Load("libXMLIO");
220 gSystem->Load("libPhysics");
441ea1cf 221
499fe731 222 // for AliRoot
223 gSystem->Load("libANALYSIS");
224 gSystem->Load("libANALYSISalice");
2e311896 225 gSystem->Load("libPWGflowBase");
226 gSystem->Load("libPWGflowTasks");
ad87ae62 227} // end of void LoadLibrariesRF(const libModes mode)
6a6afe42 228
851b1aa6 229Bool_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;
232 return kFALSE;
233}