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";
29 if(trig==6) strTrigger = "kMB";
31 TString strTrigger2 = "";
32 if(trig==1) strTrigger2 = "kCentral";
33 if(trig==2) strTrigger2 = "kSemiCentral";
34 if(trig==3) strTrigger2 = "kMBkCentralSemiCentral";
35 if(trig==4) strTrigger2 = "kEMCEJE";
36 if(trig==5) strTrigger2 = "kINT7";
37 if(trig==6) strTrigger2 = "kMB";
39 Int_t globStTrackType = 0;
41 Int_t globCnoSPDTrackType = 7;
42 Int_t globCnoSPDCuts = 5;
44 TFile * f1 = TFile::Open(strFileIn.Data());
47 TList *histsGlobSt = 0x0;
48 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()));
51 Printf(">>>> ERROR: histsGlobSt is not Available");
55 TH1F *fNEventSelGlobSt = histsGlobSt->FindObject("fNEventSel");
56 float NEventsGlobSt = fNEventSelGlobSt->GetEntries();
58 TList *histsGlobCnoSPD = 0x0;
59 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()));
60 //histsGlobCnoSPD->Print();
61 TH1F *fNEventSelGlobCnoSPD = histsGlobCnoSPD->FindObject("fNEventSel");
62 float NEventsGlobCnoSPD = fNEventSelGlobCnoSPD->GetEntries();
66 if(NEventsGlobCnoSPD==0)
67 NEventsGlobCnoSPD=0.1;
69 //---------------------------------------------------------------------------------------------------
70 // phi distribution of hybrid tracks
71 //---------------------------------------------------------------------------------------------------
73 TH2F *fPtPhiGlobSt = histsGlobSt->FindObject("fPtPhi");
74 TH2F *fPtPhiGlobCnoSPD = histsGlobCnoSPD->FindObject("fPtPhi");
75 fPtPhiGlobSt->SetXTitle("p_{T,track} [GeV]");
76 fPtPhiGlobSt->SetYTitle("#varphi");
77 fPtPhiGlobCnoSPD->SetXTitle("p_{T,track} [GeV]");
78 fPtPhiGlobCnoSPD->SetYTitle("#varphi");
80 TCanvas *c2 =new TCanvas("c2","c2: Phi",600,450);
82 if(ptmin>0.) binMin = fPtPhiGlobSt->GetXaxis()->FindBin(ptmin+0.00001);
83 TH1D *fPhiGlobSt = fPtPhiGlobSt->ProjectionY("fPhiGlobSt",binMin,fPtPhiGlobSt->GetNbinsX());
84 TH1D *fPhiGlobCnoSPD = fPtPhiGlobCnoSPD->ProjectionY("fPhiGlobCnoSPD",binMin,fPtPhiGlobSt->GetNbinsX());
86 fPhiGlobSt->SetLineColor(2);
87 fPhiGlobSt->SetLineWidth(3);
89 fPhiGlobCnoSPD->SetLineStyle(1);
90 fPhiGlobCnoSPD->SetLineColor(4);
91 fPhiGlobCnoSPD->SetLineWidth(3);
93 TH1D *fPhiGlobSum = fPhiGlobSt->Clone();
94 fPhiGlobSum->SetTitle("fPhiGlobSum");
95 fPhiGlobSum->SetName("fPhiGlobSum");
96 fPhiGlobSum->Add(fPhiGlobCnoSPD);
98 fPhiGlobSt->Scale(1./NEventsGlobSt,"width");
99 fPhiGlobCnoSPD->Scale(1./NEventsGlobSt,"width");
100 fPhiGlobSum->Scale(1./NEventsGlobSt,"width");
102 gPad->SetLeftMargin(0.2);
103 gPad->SetRightMargin(0.02);
104 gPad->SetBottomMargin(0.12);
106 TH1F *frame2 = gPad->DrawFrame(0.,0.,2.*TMath::Pi(),fPhiGlobSum->GetBinContent(fPhiGlobSum->GetMaximumBin())*1.5);
107 frame2->SetXTitle("#varphi");
108 frame2->SetYTitle("#frac{1}{N_{evts}} #frac{dN}{d#varphi}");
109 frame2->GetXaxis()->SetTitleSize(0.06);
110 frame2->GetYaxis()->SetTitleSize(0.06);
111 frame2->GetXaxis()->SetTitleOffset(0.75);
112 frame2->GetYaxis()->SetTitleOffset(1.4);
114 fPhiGlobSt->DrawCopy("same");
115 fPhiGlobCnoSPD->DrawCopy("same");
117 fPhiGlobSum->SetLineColor(1);
118 fPhiGlobSum->SetMarkerColor(1);
119 fPhiGlobSum->DrawCopy("same");
121 TLegend *leg2 = NULL;
122 if(run>0) leg2 = new TLegend(0.22,0.65,0.88,0.88,Form("Hybrid tracks. run:%d",run));
123 else leg2 = new TLegend(0.22,0.65,0.88,0.88,"Hybrid tracks");
124 leg2->SetFillColor(10);
125 leg2->SetBorderSize(0);
126 leg2->SetFillStyle(0);
127 leg2->SetTextSize(0.06);
128 leg2->AddEntry(fPhiGlobSt,"w/ SPD & ITSrefit","l");
129 leg2->AddEntry(fPhiGlobCnoSPD,"w/o SPD & w/ ITSrefit","l");
130 leg2->AddEntry(fPhiGlobSum,"sum","l");
134 textNEvents.SetNDC();
135 textNEvents.DrawLatex(0.52,0.42,Form("#it{N}_{events} = %.0f",NEventsGlobSt));
137 c2->SaveAs(Form("%sPhiCent%d%sRun%d.%s",prefix.Data(),cent,strTrigger.Data(),run,suffix.Data()));
139 //---------------------------------------------------------------------------------------------------
140 // pt distribution of hybrid tracks
141 //---------------------------------------------------------------------------------------------------
143 TCanvas *c1 =new TCanvas("c1","c1: Phi",600,450);
145 if(ptmin>0.) binMin = fPtPhiGlobSt->GetXaxis()->FindBin(ptmin+0.00001);
146 TH1D *fPtGlobSt = fPtPhiGlobSt->ProjectionX("fPtGlobSt");
147 TH1D *fPtGlobCnoSPD = fPtPhiGlobCnoSPD->ProjectionX("fPtGlobCnoSPD");
149 fPtGlobSt->SetLineColor(2);
150 fPtGlobSt->SetLineWidth(3);
152 fPtGlobCnoSPD->SetLineStyle(1);
153 fPtGlobCnoSPD->SetLineColor(4);
154 fPtGlobCnoSPD->SetLineWidth(3);
156 TH1D *fPtGlobSum = fPtGlobSt->Clone();
157 fPtGlobSum->SetTitle("fPtGlobSum");
158 fPtGlobSum->SetName("fPtGlobSum");
159 fPtGlobSum->Add(fPtGlobCnoSPD);
161 fPtGlobSt->Scale(1./NEventsGlobSt,"width");
162 fPtGlobCnoSPD->Scale(1./NEventsGlobSt,"width");
163 fPtGlobSum->Scale(1./NEventsGlobSt,"width");
165 gPad->SetLeftMargin(0.2);
166 gPad->SetRightMargin(0.02);
167 gPad->SetBottomMargin(0.12);
169 TH1F *frame1 = gPad->DrawFrame(0.,1e-7,100.,fPtGlobSum->GetBinContent(fPtGlobSum->GetMaximumBin())*1.5);
170 frame1->SetXTitle("p_{T} [GeV]");
171 frame1->SetYTitle("#frac{1}{N_{evts}}#frac{dN}{dp_{T}} [GeV^{-1}]");
172 frame1->GetXaxis()->SetTitleSize(0.06);
173 frame1->GetYaxis()->SetTitleSize(0.06);
174 frame1->GetXaxis()->SetTitleOffset(0.75);
175 frame1->GetYaxis()->SetTitleOffset(1.4);
179 fPtGlobSt->DrawCopy("same");
180 fPtGlobCnoSPD->DrawCopy("same");
182 fPtGlobSum->SetLineColor(1);
183 fPtGlobSum->SetMarkerColor(1);
184 fPtGlobSum->DrawCopy("same");
186 TLegend *leg1 = NULL;
187 if(run>0) leg1 = new TLegend(0.35,0.65,0.88,0.88,Form("Hybrid tracks. run:%d",run));
188 else leg1 = new TLegend(0.35,0.65,0.88,0.88,"Hybrid tracks");
189 leg1->SetFillColor(10);
190 leg1->SetBorderSize(0);
191 leg1->SetFillStyle(0);
192 leg1->SetTextSize(0.06);
193 leg1->AddEntry(fPtGlobSt,"w/ SPD & ITSrefit","l");
194 leg1->AddEntry(fPtGlobCnoSPD,"w/o SPD & w/ ITSrefit","l");
195 leg1->AddEntry(fPtGlobSum,"sum","l");
199 textNEvents.SetNDC();
200 textNEvents.DrawLatex(0.55,0.45,Form("#it{N}_{events} = %.0f",NEventsGlobSt));
202 c1->SaveAs(Form("%sPtCent%d%sRun%d.%s",prefix.Data(),cent,strTrigger.Data(),run,suffix.Data()));
204 //---------------------------------------------------------------------------------------------------
206 //---------------------------------------------------------------------------------------------------
209 TProfile *fProfPtPtSigma1PtGlobSt = histsGlobSt->FindObject("fProfPtPtSigma1Pt");
210 TProfile *fProfPtPtSigma1PtGlobCnoSPD = histsGlobCnoSPD->FindObject("fProfPtPtSigma1Pt");
212 fProfPtPtSigma1PtGlobSt->SetTitle("fProfPtPtSigma1PtGlobSt");
213 fProfPtPtSigma1PtGlobSt->SetName("fProfPtPtSigma1PtGlobSt");
214 fProfPtPtSigma1PtGlobCnoSPD->SetTitle("fProfPtPtSigma1PtGlobCnoSPD");
215 fProfPtPtSigma1PtGlobCnoSPD->SetName("fProfPtPtSigma1PtGlobCnoSPD");
217 for(Int_t i =1 ; i<fProfPtPtSigma1PtGlobSt->GetNbinsX(); i++) {
218 if(fProfPtPtSigma1PtGlobSt->GetBinEffectiveEntries(i)<10.) {
219 fProfPtPtSigma1PtGlobSt->SetBinContent(i,0);
220 fProfPtPtSigma1PtGlobSt->SetBinError(i,0);
222 if(fProfPtPtSigma1PtGlobCnoSPD->GetBinEffectiveEntries(i)<10.) {
223 fProfPtPtSigma1PtGlobCnoSPD->SetBinContent(i,0);
224 fProfPtPtSigma1PtGlobCnoSPD->SetBinError(i,0);
228 TCanvas *c3 =new TCanvas("c3","c3: pT resolution",600,450);
229 gPad->SetLeftMargin(0.12);
230 gPad->SetRightMargin(0.02);
231 gPad->SetBottomMargin(0.12);
232 TH1F *frame3 = gPad->DrawFrame(0.,0.,100.,0.3);
233 frame3->SetXTitle("#it{p}_{T,track} [GeV/c]");
234 frame3->SetYTitle("#it{p}_{T,track}#sigma(1/#it{p}_{T,track})");
235 frame3->GetXaxis()->SetTitleSize(0.06);
236 frame3->GetYaxis()->SetTitleSize(0.06);
237 frame3->GetXaxis()->SetTitleOffset(0.8);
238 frame3->GetYaxis()->SetTitleOffset(0.8);
240 fProfPtPtSigma1PtGlobSt->SetLineColor(2);
241 fProfPtPtSigma1PtGlobSt->SetLineWidth(3);
242 fProfPtPtSigma1PtGlobSt->SetMarkerStyle(21);
243 fProfPtPtSigma1PtGlobSt->SetMarkerColor(2);
245 fProfPtPtSigma1PtGlobCnoSPD->SetLineColor(4);
246 fProfPtPtSigma1PtGlobCnoSPD->SetLineWidth(3);
247 fProfPtPtSigma1PtGlobCnoSPD->SetMarkerStyle(24);
248 fProfPtPtSigma1PtGlobCnoSPD->SetMarkerColor(4);
250 fProfPtPtSigma1PtGlobSt->DrawCopy("same");
251 fProfPtPtSigma1PtGlobCnoSPD->DrawCopy("same");
253 TLegend *leg3 = NULL;
254 if(run>0) leg3 = new TLegend(0.16,0.6,0.88,0.88,Form("Hybrid tracks. run:%d",run));
255 else leg3 = new TLegend(0.16,0.6,0.88,0.88,"Hybrid tracks");
256 leg3->SetFillColor(10);
257 leg3->SetBorderSize(0);
258 leg3->SetFillStyle(0);
259 leg3->SetTextSize(0.06);
260 leg3->AddEntry(fProfPtPtSigma1PtGlobSt,"w/ SPD & ITSrefit","lp");
261 leg3->AddEntry(fProfPtPtSigma1PtGlobCnoSPD,"w/o SPD & w/ ITSrefit","lp");
264 c3->SaveAs(Form("%sPtResolutionCent%d%sRun%d.%s",prefix.Data(),cent,strTrigger.Data(),run,suffix.Data()));
266 //---------------------------------------------------------------------------------------------------
267 // WRITE OUTPUT TO ROOT FILE
268 //---------------------------------------------------------------------------------------------------
270 // Modifed by satya to have unique name of objects and same name of file
272 // TFile *histOut = new TFile(Form("%sHybridCent%d%sRun%d.root",prefix.Data(),cent,strTrigger.Data(),run),"RECREATE");
277 TFile *fout = TFile::Open(outfile,"UPDATE");
280 TDirectoryFile *cdd = NULL;
281 cdd = (TDirectoryFile*)fout->Get("JE");
283 Printf("Warning: JE <dir> doesn't exist, creating a new one");
284 cdd = (TDirectoryFile*)fout->mkdir("JE");
289 fPtGlobSt->SetName(Form("%s%s",prefix.Data(), fPtGlobSt->GetName()));
291 fPtGlobCnoSPD->SetName(Form("%s%s",prefix.Data(), fPtGlobCnoSPD->GetName()));
292 fPtGlobCnoSPD->Write();
293 fPtGlobSum->SetName(Form("%s%s",prefix.Data(), fPtGlobSum->GetName()));
295 fPhiGlobSt->SetName(Form("%s%s",prefix.Data(), fPhiGlobSt->GetName()));
297 fPhiGlobCnoSPD->SetName(Form("%s%s",prefix.Data(), fPhiGlobCnoSPD->GetName()));
298 fPhiGlobCnoSPD->Write();
299 fPhiGlobSum->SetName(Form("%s%s",prefix.Data(), fPhiGlobSum->GetName()));
300 fPhiGlobSum->Write();
301 fProfPtPtSigma1PtGlobSt->SetName(Form("%s%s",prefix.Data(), fProfPtPtSigma1PtGlobSt->GetName()));
302 fProfPtPtSigma1PtGlobSt->Write();
303 fProfPtPtSigma1PtGlobCnoSPD->SetName(Form("%s%s",prefix.Data(), fProfPtPtSigma1PtGlobCnoSPD->GetName()));
304 fProfPtPtSigma1PtGlobCnoSPD->Write();