handle bash args properly using arrays
[u/mrichter/AliRoot.git] / PWGPP / analysisQA / processCFv2vsPt.C
CommitLineData
948b38b2 1/***************************************************************
2 processCFv2vsPt.C
3 Post Processing of Flow QA task in Analysis QA train
4 Clone copy of v2vsPt_0d.C from Ante
5
6 Modification Done // sjena
7 To save file and putting ani unique naming convention
8
9***************************************************************/
10
11// Name of the merged, large statistics file obtained with the merging macros:
12TString mergedFileName = "AnalysisResults.root";
13
14// Final output file name holding correct final results for large statistics sample:
15TString outputFileName = "AnalysisResults.root";
16
17void processCFv2vsPt(const char *filePath = "AnalysisResults.root",
18 TString suffix="eps",
19 const char *outfile="CFv2vsPt_output.root") {
20 // Load flow libraries:
21 gSystem->Load("libPWGflowBase");
22
23 // Let's go:
24 TString mergedFileFullPathName(filePath);
25 TFile *mergedFile = NULL;
26 if(gSystem->AccessPathName(mergedFileFullPathName.Data(),kFileExists))
27 {
28 cout<<endl;
29 cout<<" WARNING: Couldn't find a file: "<<mergedFileFullPathName.Data()<<endl;
30 cout<<endl;
31 exit(0);
32 } else
33 {
34 // Create temporarily copy of <mergedFileName> if neccessary:
35 if(!(mergedFileName == outputFileName))
36 {
37 TSystemFile *fileTemp = new TSystemFile(mergedFileFullPathName.Data(),".");
38 fileTemp->Copy("mergedAnalysisResultsTemp.root");
39 delete fileTemp;
40 }
41 // Access <mergedFileName>:
42 mergedFile = TFile::Open(mergedFileFullPathName.Data(),"UPDATE");
43 }
44
45 // Accessing the file and updating it:
46 TList* mergedFileKeys = mergedFile->GetListOfKeys();
47 for(Int_t i=0; i<mergedFileKeys->GetEntries(); i++)
48 {
49 TDirectory* directory = dynamic_cast<TDirectory*>(mergedFile->Get(mergedFileKeys->At(i)->GetName()));
50 if (!directory) continue;
51 TList* listTemp = directory->GetListOfKeys();
52 if(!listTemp) continue;
53 for (Int_t icent=0; icent<listTemp->GetEntries(); icent++)
54 {
55 TList* list = dynamic_cast<TList*>(directory->Get(listTemp->At(icent)->GetName()));
56 if (!list) continue;
57 // QC:
58 if(TString(list->GetName()).Contains("QC"))
59 {
60 AliFlowAnalysisWithQCumulants* qc = new AliFlowAnalysisWithQCumulants();
61 qc->GetOutputHistograms(list);
62 Bool_t bApplyCorrectionForNUA = kFALSE; // apply correction for non-uniform acceptance
63 qc->GetIntFlowFlags()->SetBinContent(3,(Int_t)bApplyCorrectionForNUA);
64 qc->Finish();
65 directory->Add(list,kTRUE);
66 directory->Write(directory->GetName(),TObject::kSingleKey+TObject::kWriteDelete);
67 } // if(TString(list->GetName()).Contains("QC"))
68 } // for (Int_t icent=0; icent<listTemp->GetEntries(); icent++)
69 } // for(Int_t i=0; i<mergedFileKeys->GetEntries(); i++)
70
71 // Close the final output file:
72 delete mergedFile;
73
74 // Changing the final name, if neccessary:
75 if(!(mergedFileName == outputFileName))
76 {
77 TSystemFile *outputFileFinal = new TSystemFile(mergedFileName.Data(),".");
78 outputFileFinal->Rename(outputFileName.Data());
79 delete outputFileFinal;
80 TSystemFile *mergedFileFinal = new TSystemFile("mergedAnalysisResultsTemp.root",".");
81 mergedFileFinal->Rename(mergedFileName.Data());
82 delete mergedFileFinal;
83 } // end of if(!(mergedFileName == outputFileName))
84
85 // Finally, make some nice plots...:
86 // Access "v2 vs. pT" histogram from the specified output file:
87 TFile *f = TFile::Open(filePath,"READ");
88
89 TDirectoryFile *df = (TDirectoryFile*)f->FindObjectAny("outputQCanalysisTPCstandalone");
90 TList *l = NULL;
91 TList *listTemp = df->GetListOfKeys();
92 if(listTemp && listTemp->GetEntries() == 1)
93 {
94 TString listName = listTemp->At(0)->GetName();
95 df->GetObject(listName.Data(),l);
96 }
97 TList *diffFlowList = dynamic_cast<TList*> l->FindObject("Differential Flow");
98 diffFlowList = dynamic_cast<TList*> diffFlowList->FindObject("Results");
99 diffFlowList = dynamic_cast<TList*> diffFlowList->FindObject("Differential flow (POI, p_{T})");
100
101 // v2{2} vs. pT:
102 TH1D *v22 = dynamic_cast<TH1D*> diffFlowList->FindObject("fDiffFlow, POI, p_{T}, v'{2}");
103 v22->SetMarkerStyle(kFullCircle);
104 v22->SetMarkerColor(kBlue);
105 v22->SetLineColor(kBlue);
106
107 // v2{4} vs. pT:
108 TH1D *v24 = dynamic_cast<TH1D*> diffFlowList->FindObject("fDiffFlow, POI, p_{T}, v'{4}");
109 v24->SetMarkerStyle(kFullSquare);
110 v24->SetMarkerColor(kRed);
111 v24->SetLineColor(kRed);
112
113 // Legend:
114 TLegend *legend = new TLegend(0.15,0.67,0.37,0.87);
115 legend->SetFillStyle(0); // white legend background
116 legend->SetTextSize(0.04);
117 legend->SetBorderSize(0.0);
118 //legend->SetTextFont(22);
119 legend->SetMargin(0.1);
120 //legend->AddEntry(inputValues_g,"theoretical/input values","p");
121 legend->AddEntry(v22,"v_{2}{2}","p");
122 legend->AddEntry(v24,"v_{2}{4}","p");
123
124 // Style histogram:
125 TH1D *hist = new TH1D("","",10,0.,10.);
126 hist->SetStats(kFALSE);
127 hist->SetTitle("");
128 hist->GetXaxis()->SetTitle("p_{T}");
129 hist->GetYaxis()->SetRangeUser(0.0,0.3044);
130
131 // Final drawing:
132 // v2 vs. pT:
133 TCanvas *c1 = new TCanvas("c1","v2 vs. pT");
134 hist->Draw();
135 legend->Draw("same");
136 v22->Draw("psame");
137 v24->Draw("psame");
138
139 c1->SaveAs(Form("fig_cf_flow_fDiffFlow.%s",suffix.Data()));
140
141 // Bias from non-uniform azimuthal acceptance (NUA):
142 TList *intFlowList = dynamic_cast<TList*> l->FindObject("Integrated Flow");
143 intFlowList = dynamic_cast<TList*> intFlowList->FindObject("Results");
144 TH1D *fIntFlowDetectorBias = dynamic_cast<TH1D*> intFlowList->FindObject("fIntFlowDetectorBias");
145 fIntFlowDetectorBias->SetStats(kFALSE);
146 fIntFlowDetectorBias->SetTitle("Quantifying bias from non-uniform acceptance");
147 fIntFlowDetectorBias->SetFillColor(kBlue-10);
148 fIntFlowDetectorBias->GetXaxis()->SetRangeUser(0.,2.);
149 fIntFlowDetectorBias->GetYaxis()->SetRangeUser(0.8044,1.0544);
150 fIntFlowDetectorBias->SetBinError(1,0.); // stat. errors need to be reimplemented
151 fIntFlowDetectorBias->SetBinError(2,0.); // stat. errors need to be reimplemented
152
153 // Final drawing:
154 TCanvas *c2 = new TCanvas("c2","NUA");
155 fIntFlowDetectorBias->Draw();
156
157 c2->SaveAs(Form("fig_cf_flow_IntFlowDetectorBias.%s",suffix.Data()));
158
159 f->Close();
160
161 cout<<endl;
162
163 //Added by sjena
164 TFile *fout = TFile::Open(outfile,"UPDATE");
165 fout->ls();
166
167 TDirectoryFile *cdd = NULL;
168 cdd = (TDirectoryFile*)fout->Get("CF");
169 if(!cdd) {
170 Printf("Warning: CF <dir> doesn't exist, creating a new one");
171 cdd = (TDirectoryFile*)fout->mkdir("CF");
172 }
173 cdd->cd();
174 cdd->ls();
175
176
177 v22->SetName(Form("fig_cf_flow_22", v22->GetName()));
178 // v22->SetName(Form("fig_cf_flow_fDiffFlow22"));
179 v22->Write();
180
181 v24->SetName(Form("fig_cf_flow_24", v24->GetName()));
182 // v24->SetName(Form("fig_cf_flow_fDiffFlow24"));
183 v24->Write();
184
185 fIntFlowDetectorBias->SetName(Form("fig_cf_flow_IntFlowDetectorBias", fIntFlowDetectorBias->GetName()));
186 fIntFlowDetectorBias->Write();
187
188 fout->cd();
189 fout->Close();
190
191
192
193} // void void v2vsPt_0d()
194