1 /*********************************************************
3 Post processing macro for the JET Track QA
6 *********************************************************/
9 const Float_t ptmin = 0.0 ;
10 void processJETrackQA(TString strFileIn = "AnalysisResults.root",
11 TString suffix = "eps",
16 const char *outfile ="JETrackQA_output.root") {
18 gStyle->SetOptStat(0);
19 gStyle->SetOptTitle(0);
21 TString prefix = "fig_je_TrackQA_";
23 TString strTrigger = "";
24 if(trig==1) strTrigger = "kCentral";
25 if(trig==2) strTrigger = "kSemiCentral";
26 if(trig==3) strTrigger = "kMBkCentralkSemiCentral";
27 if(trig==4) strTrigger = "kEMCEJE";
28 if(trig==5) strTrigger = "kINT7";
30 TString strTrigger2 = "";
31 if(trig==1) strTrigger2 = "kCentral";
32 if(trig==2) strTrigger2 = "kSemiCentral";
33 if(trig==3) strTrigger2 = "kMBkCentralSemiCentral";
34 if(trig==4) strTrigger2 = "kEMCEJE";
35 if(trig==5) strTrigger2 = "kINT7";
37 Int_t globStTrackType = 0;
39 Int_t globCnoSPDTrackType = 7;
40 Int_t globCnoSPDCuts = 5;
42 TFile * f1 = TFile::Open(strFileIn.Data());
45 TList *histsGlobSt = 0x0;
46 histsGlobSt = (TList*)f1->Get(Form("PWG4_HighPtTrackQACent%dTrackType%dCuts%d%s/qa_histsQAtrackCent%dType%dcuts%d%s",cent,globStTrackType,globStCuts,strTrigger.Data(),cent,globStTrackType,globStCuts,strTrigger2.Data()));
49 Printf(">>>> ERROR: histsGlobSt is not Available");
53 TH1F *fNEventSelGlobSt = histsGlobSt->FindObject("fNEventSel");
54 float NEventsGlobSt = fNEventSelGlobSt->GetEntries();
56 TList *histsGlobCnoSPD = 0x0;
57 histsGlobCnoSPD = (TList*)f1->Get(Form("PWG4_HighPtTrackQACent%dTrackType%dCuts%d%s/qa_histsQAtrackCent%dType%dcuts%d%s",cent,globCnoSPDTrackType,globCnoSPDCuts,strTrigger.Data(),cent,globCnoSPDTrackType,globCnoSPDCuts,strTrigger2.Data()));
58 //histsGlobCnoSPD->Print();
59 TH1F *fNEventSelGlobCnoSPD = histsGlobCnoSPD->FindObject("fNEventSel");
60 float NEventsGlobCnoSPD = fNEventSelGlobCnoSPD->GetEntries();
62 //---------------------------------------------------------------------------------------------------
63 // phi distribution of hybrid tracks
64 //---------------------------------------------------------------------------------------------------
66 TH2F *fPtPhiGlobSt = histsGlobSt->FindObject("fPtPhi");
67 TH2F *fPtPhiGlobCnoSPD = histsGlobCnoSPD->FindObject("fPtPhi");
68 fPtPhiGlobSt->SetXTitle("p_{T,track} [GeV]");
69 fPtPhiGlobSt->SetYTitle("#varphi");
70 fPtPhiGlobCnoSPD->SetXTitle("p_{T,track} [GeV]");
71 fPtPhiGlobCnoSPD->SetYTitle("#varphi");
73 TCanvas *c2 =new TCanvas("c2","c2: Phi",600,450);
75 if(ptmin>0.) binMin = fPtPhiGlobSt->GetXaxis()->FindBin(ptmin+0.00001);
76 TH1D *fPhiGlobSt = fPtPhiGlobSt->ProjectionY("fPhiGlobSt",binMin,fPtPhiGlobSt->GetNbinsX());
77 TH1D *fPhiGlobCnoSPD = fPtPhiGlobCnoSPD->ProjectionY("fPhiGlobCnoSPD",binMin,fPtPhiGlobSt->GetNbinsX());
79 fPhiGlobSt->SetLineColor(2);
80 fPhiGlobSt->SetLineWidth(3);
82 fPhiGlobCnoSPD->SetLineStyle(1);
83 fPhiGlobCnoSPD->SetLineColor(4);
84 fPhiGlobCnoSPD->SetLineWidth(3);
86 TH1D *fPhiGlobSum = fPhiGlobSt->Clone();
87 fPhiGlobSum->SetTitle("fPhiGlobSum");
88 fPhiGlobSum->SetName("fPhiGlobSum");
89 fPhiGlobSum->Add(fPhiGlobCnoSPD);
91 fPhiGlobSt->Scale(1./NEventsGlobSt,"width");
92 fPhiGlobCnoSPD->Scale(1./NEventsGlobSt,"width");
93 fPhiGlobSum->Scale(1./NEventsGlobSt,"width");
95 gPad->SetLeftMargin(0.2);
96 gPad->SetRightMargin(0.02);
97 gPad->SetBottomMargin(0.12);
99 TH1F *frame2 = gPad->DrawFrame(0.,0.,2.*TMath::Pi(),fPhiGlobSum->GetBinContent(fPhiGlobSum->GetMaximumBin())*1.5);
100 frame2->SetXTitle("#varphi");
101 frame2->SetYTitle("#frac{1}{N_{evts}} #frac{dN}{d#varphi}");
102 frame2->GetXaxis()->SetTitleSize(0.06);
103 frame2->GetYaxis()->SetTitleSize(0.06);
104 frame2->GetXaxis()->SetTitleOffset(0.75);
105 frame2->GetYaxis()->SetTitleOffset(1.4);
107 fPhiGlobSt->DrawCopy("same");
108 fPhiGlobCnoSPD->DrawCopy("same");
110 fPhiGlobSum->SetLineColor(1);
111 fPhiGlobSum->SetMarkerColor(1);
112 fPhiGlobSum->DrawCopy("same");
114 TLegend *leg2 = NULL;
115 if(run>0) leg2 = new TLegend(0.22,0.65,0.88,0.88,Form("Hybrid tracks. run:%d",run));
116 else leg2 = new TLegend(0.22,0.65,0.88,0.88,"Hybrid tracks");
117 leg2->SetFillColor(10);
118 leg2->SetBorderSize(0);
119 leg2->SetFillStyle(0);
120 leg2->SetTextSize(0.06);
121 leg2->AddEntry(fPhiGlobSt,"w/ SPD & ITSrefit","l");
122 leg2->AddEntry(fPhiGlobCnoSPD,"w/o SPD & w/ ITSrefit","l");
123 leg2->AddEntry(fPhiGlobSum,"sum","l");
127 textNEvents.SetNDC();
128 textNEvents.DrawLatex(0.52,0.42,Form("#it{N}_{events} = %.0f",NEventsGlobSt));
130 c2->SaveAs(Form("%sPhiCent%d%sRun%d.%s",prefix.Data(),cent,strTrigger.Data(),run,suffix.Data()));
132 //---------------------------------------------------------------------------------------------------
133 // pt distribution of hybrid tracks
134 //---------------------------------------------------------------------------------------------------
136 TCanvas *c1 =new TCanvas("c1","c1: Phi",600,450);
138 if(ptmin>0.) binMin = fPtPhiGlobSt->GetXaxis()->FindBin(ptmin+0.00001);
139 TH1D *fPtGlobSt = fPtPhiGlobSt->ProjectionX("fPtGlobSt");
140 TH1D *fPtGlobCnoSPD = fPtPhiGlobCnoSPD->ProjectionX("fPtGlobCnoSPD");
142 fPtGlobSt->SetLineColor(2);
143 fPtGlobSt->SetLineWidth(3);
145 fPtGlobCnoSPD->SetLineStyle(1);
146 fPtGlobCnoSPD->SetLineColor(4);
147 fPtGlobCnoSPD->SetLineWidth(3);
149 TH1D *fPtGlobSum = fPtGlobSt->Clone();
150 fPtGlobSum->SetTitle("fPtGlobSum");
151 fPtGlobSum->SetName("fPtGlobSum");
152 fPtGlobSum->Add(fPtGlobCnoSPD);
154 fPtGlobSt->Scale(1./NEventsGlobSt,"width");
155 fPtGlobCnoSPD->Scale(1./NEventsGlobSt,"width");
156 fPtGlobSum->Scale(1./NEventsGlobSt,"width");
158 gPad->SetLeftMargin(0.2);
159 gPad->SetRightMargin(0.02);
160 gPad->SetBottomMargin(0.12);
162 TH1F *frame1 = gPad->DrawFrame(0.,1e-7,100.,fPtGlobSum->GetBinContent(fPtGlobSum->GetMaximumBin())*1.5);
163 frame1->SetXTitle("p_{T} [GeV]");
164 frame1->SetYTitle("#frac{1}{N_{evts}}#frac{dN}{dp_{T}} [GeV^{-1}]");
165 frame1->GetXaxis()->SetTitleSize(0.06);
166 frame1->GetYaxis()->SetTitleSize(0.06);
167 frame1->GetXaxis()->SetTitleOffset(0.75);
168 frame1->GetYaxis()->SetTitleOffset(1.4);
172 fPtGlobSt->DrawCopy("same");
173 fPtGlobCnoSPD->DrawCopy("same");
175 fPtGlobSum->SetLineColor(1);
176 fPtGlobSum->SetMarkerColor(1);
177 fPtGlobSum->DrawCopy("same");
179 TLegend *leg1 = NULL;
180 if(run>0) leg1 = new TLegend(0.35,0.65,0.88,0.88,Form("Hybrid tracks. run:%d",run));
181 else leg1 = new TLegend(0.35,0.65,0.88,0.88,"Hybrid tracks");
182 leg1->SetFillColor(10);
183 leg1->SetBorderSize(0);
184 leg1->SetFillStyle(0);
185 leg1->SetTextSize(0.06);
186 leg1->AddEntry(fPtGlobSt,"w/ SPD & ITSrefit","l");
187 leg1->AddEntry(fPtGlobCnoSPD,"w/o SPD & w/ ITSrefit","l");
188 leg1->AddEntry(fPtGlobSum,"sum","l");
192 textNEvents.SetNDC();
193 textNEvents.DrawLatex(0.55,0.45,Form("#it{N}_{events} = %.0f",NEventsGlobSt));
195 c1->SaveAs(Form("%sPtCent%d%sRun%d.%s",prefix.Data(),cent,strTrigger.Data(),run,suffix.Data()));
197 //---------------------------------------------------------------------------------------------------
199 //---------------------------------------------------------------------------------------------------
202 TProfile *fProfPtPtSigma1PtGlobSt = histsGlobSt->FindObject("fProfPtPtSigma1Pt");
203 TProfile *fProfPtPtSigma1PtGlobCnoSPD = histsGlobCnoSPD->FindObject("fProfPtPtSigma1Pt");
205 fProfPtPtSigma1PtGlobSt->SetTitle("fProfPtPtSigma1PtGlobSt");
206 fProfPtPtSigma1PtGlobSt->SetName("fProfPtPtSigma1PtGlobSt");
207 fProfPtPtSigma1PtGlobCnoSPD->SetTitle("fProfPtPtSigma1PtGlobCnoSPD");
208 fProfPtPtSigma1PtGlobCnoSPD->SetName("fProfPtPtSigma1PtGlobCnoSPD");
210 for(Int_t i =1 ; i<fProfPtPtSigma1PtGlobSt->GetNbinsX(); i++) {
211 if(fProfPtPtSigma1PtGlobSt->GetBinEffectiveEntries(i)<10.) {
212 fProfPtPtSigma1PtGlobSt->SetBinContent(i,0);
213 fProfPtPtSigma1PtGlobSt->SetBinError(i,0);
215 if(fProfPtPtSigma1PtGlobCnoSPD->GetBinEffectiveEntries(i)<10.) {
216 fProfPtPtSigma1PtGlobCnoSPD->SetBinContent(i,0);
217 fProfPtPtSigma1PtGlobCnoSPD->SetBinError(i,0);
221 TCanvas *c3 =new TCanvas("c3","c3: pT resolution",600,450);
222 gPad->SetLeftMargin(0.12);
223 gPad->SetRightMargin(0.02);
224 gPad->SetBottomMargin(0.12);
225 TH1F *frame3 = gPad->DrawFrame(0.,0.,100.,0.3);
226 frame3->SetXTitle("#it{p}_{T,track} [GeV/c]");
227 frame3->SetYTitle("#it{p}_{T,track}#sigma(1/#it{p}_{T,track})");
228 frame3->GetXaxis()->SetTitleSize(0.06);
229 frame3->GetYaxis()->SetTitleSize(0.06);
230 frame3->GetXaxis()->SetTitleOffset(0.8);
231 frame3->GetYaxis()->SetTitleOffset(0.8);
233 fProfPtPtSigma1PtGlobSt->SetLineColor(2);
234 fProfPtPtSigma1PtGlobSt->SetLineWidth(3);
235 fProfPtPtSigma1PtGlobSt->SetMarkerStyle(21);
236 fProfPtPtSigma1PtGlobSt->SetMarkerColor(2);
238 fProfPtPtSigma1PtGlobCnoSPD->SetLineColor(4);
239 fProfPtPtSigma1PtGlobCnoSPD->SetLineWidth(3);
240 fProfPtPtSigma1PtGlobCnoSPD->SetMarkerStyle(24);
241 fProfPtPtSigma1PtGlobCnoSPD->SetMarkerColor(4);
243 fProfPtPtSigma1PtGlobSt->DrawCopy("same");
244 fProfPtPtSigma1PtGlobCnoSPD->DrawCopy("same");
246 TLegend *leg3 = NULL;
247 if(run>0) leg3 = new TLegend(0.16,0.6,0.88,0.88,Form("Hybrid tracks. run:%d",run));
248 else leg3 = new TLegend(0.16,0.6,0.88,0.88,"Hybrid tracks");
249 leg3->SetFillColor(10);
250 leg3->SetBorderSize(0);
251 leg3->SetFillStyle(0);
252 leg3->SetTextSize(0.06);
253 leg3->AddEntry(fProfPtPtSigma1PtGlobSt,"w/ SPD & ITSrefit","lp");
254 leg3->AddEntry(fProfPtPtSigma1PtGlobCnoSPD,"w/o SPD & w/ ITSrefit","lp");
257 c3->SaveAs(Form("%sPtResolutionCent%d%sRun%d.%s",prefix.Data(),cent,strTrigger.Data(),run,suffix.Data()));
259 //---------------------------------------------------------------------------------------------------
260 // WRITE OUTPUT TO ROOT FILE
261 //---------------------------------------------------------------------------------------------------
263 // Modifed by satya to have unique name of objects and same name of file
265 // TFile *histOut = new TFile(Form("%sHybridCent%d%sRun%d.root",prefix.Data(),cent,strTrigger.Data(),run),"RECREATE");
270 TFile *fout = TFile::Open(outfile,"UPDATE");
273 TDirectoryFile *cdd = NULL;
274 cdd = (TDirectoryFile*)fout->Get("JE");
276 Printf("Warning: JE <dir> doesn't exist, creating a new one");
277 cdd = (TDirectoryFile*)fout->mkdir("JE");
282 fPtGlobSt->SetName(Form("%s%s",prefix.Data(), fPtGlobSt->GetName()));
284 fPtGlobCnoSPD->SetName(Form("%s%s",prefix.Data(), fPtGlobCnoSPD->GetName()));
285 fPtGlobCnoSPD->Write();
286 fPtGlobSum->SetName(Form("%s%s",prefix.Data(), fPtGlobSum->GetName()));
288 fPhiGlobSt->SetName(Form("%s%s",prefix.Data(), fPhiGlobSt->GetName()));
290 fPhiGlobCnoSPD->SetName(Form("%s%s",prefix.Data(), fPhiGlobCnoSPD->GetName()));
291 fPhiGlobCnoSPD->Write();
292 fPhiGlobSum->SetName(Form("%s%s",prefix.Data(), fPhiGlobSum->GetName()));
293 fPhiGlobSum->Write();
294 fProfPtPtSigma1PtGlobSt->SetName(Form("%s%s",prefix.Data(), fProfPtPtSigma1PtGlobSt->GetName()));
295 fProfPtPtSigma1PtGlobSt->Write();
296 fProfPtPtSigma1PtGlobCnoSPD->SetName(Form("%s%s",prefix.Data(), fProfPtPtSigma1PtGlobCnoSPD->GetName()));
297 fProfPtPtSigma1PtGlobCnoSPD->Write();