]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWGHF/hfe/macros/PerformanceSpectrumUncorr.C
Merge branch 'feature-movesplit'
[u/mrichter/AliRoot.git] / PWGHF / hfe / macros / PerformanceSpectrumUncorr.C
1 const Double_t ptmin = 0.2;
2 const Double_t ptmax = 5.;
3
4 void DefineTPChisto(TH2 *h2, const char *yname);
5 void ALICEWorkInProgress(TCanvas *c, TString date = "today");
6 void PerformanceSpectrumUncorr(const Char_t *fname = "HFEtask.root"){
7
8   gROOT->SetStyle("Plain");
9   gStyle->SetTitleFillColor(0);
10   gStyle->SetTitleBorderSize(0);
11   gStyle->SetTitleX(0.1);
12   gStyle->SetTitleY(0.96);
13
14   TFile *in = TFile::Open(fname);
15   TList *res = (TList *)in->Get("HFE_Results");
16   TList *qa = (TList *)in->Get("HFE_QA");
17   gROOT->cd();
18   AliHFEcontainer *tcont = dynamic_cast<AliHFEcontainer *>(res->FindObject("trackContainer"));
19   AliCFContainer *c = tcont->GetCFContainer("recTrackContReco");
20   AliCFContainer *cb = tcont->GetCFContainer("hadronicBackground");
21
22   TH1 *spec = c->Project(c->GetNStep() - 1, 0);
23   spec->GetXaxis()->SetTitle("p_{T} / GeV/c");
24   spec->GetYaxis()->SetTitle("#frac{dN}{dp_{T}} / (GeV/c)^{-1}");
25   spec->GetXaxis()->SetRangeUser(ptmin, ptmax);
26   spec->GetYaxis()->SetTitleOffset(1.1);
27   spec->SetTitle();
28   spec->SetStats(kFALSE);
29
30   spec->SetLineColor(kBlue);
31   spec->SetLineWidth(1);
32   spec->SetMarkerColor(kBlue);
33   spec->SetMarkerStyle(22);
34
35   // Produce background subtracted spectrum
36   AliCFDataGrid tracks("tracks", "track grid", *c, c->GetNStep() - 1);
37   AliCFDataGrid background("background", "background grid", *cb, 1);
38   tracks.ApplyBGCorrection(background);
39   TH1 *spec_subtracted = tracks.Project(0);
40   spec_subtracted->GetXaxis()->SetTitle("p_{T} / GeV/c");
41   spec_subtracted->GetYaxis()->SetTitle("#frac{dN}{dp_{T}} / (GeV/c)^{-1}");
42   spec_subtracted->GetXaxis()->SetRangeUser(ptmin, ptmax);
43   spec_subtracted->GetYaxis()->SetTitleOffset(1.1);
44   spec_subtracted->SetTitle();
45   spec_subtracted->SetStats(kFALSE);
46   spec_subtracted->SetLineColor(kRed);
47   spec_subtracted->SetLineWidth(1);
48   spec_subtracted->SetMarkerColor(kRed);
49   spec_subtracted->SetMarkerStyle(22);
50
51   TLegend *leg = new TLegend(0.2, 0.25, 0.4, 0.35);
52   leg->SetBorderSize(0);
53   leg->SetFillStyle(0);
54   leg->AddEntry(spec, "Raw Spectrum", "p");
55   leg->AddEntry(spec_subtracted, "Spectrum after background subtraction", "p");
56  
57   TCanvas *c1 = new TCanvas("cspec", "Single-inclusive electron spectrum", 1200, 750);
58   c1->cd();
59   c1->SetLogy();
60   c1->SetGridx(kFALSE);
61   c1->SetGridy(kFALSE);
62   spec->Draw("ep");
63   spec_subtracted->Draw("epsame");
64   leg->Draw();
65   ALICEWorkInProgress(c1, "today");
66
67   // PID
68   TList *pidqa = (TList *)qa->FindObject("HFEpidQA");
69   AliHFEtpcPIDqa *tpcqa = (AliHFEtpcPIDqa *)pidqa->FindObject("TPCQA");
70   AliHFEtofPIDqa *tofqa = (AliHFEtofPIDqa *)pidqa->FindObject("TOFQA");
71
72   // Make Plots for TPC
73   // Create histograms by projecting the THnSparse
74   TH2 *hTPCall = tpcqa->MakeSpectrumdEdx(AliHFEdetPIDqa::kBeforePID);
75   TH2 *hTPCselected = tpcqa->MakeSpectrumdEdx(AliHFEdetPIDqa::kAfterPID);
76   TH2 *hTPCsigmaAll = tpcqa->MakeSpectrumNSigma(AliHFEdetPIDqa::kBeforePID);
77   TH2* hTPCsigmaSelected = tpcqa->MakeSpectrumNSigma(AliHFEdetPIDqa::kAfterPID);
78   // Make Plots for TOF
79   TH2 *hTOFsigmaAll = tofqa->MakeSpectrumNSigma(AliHFEdetPIDqa::kBeforePID);
80   TH2 *hTOFsigmaSelected = tofqa->MakeSpectrumNSigma(AliHFEdetPIDqa::kAfterPID);
81
82   hTPCsigmaAll->SetTitle("TPC n#sigma around the electron line");
83   hTPCsigmaSelected->SetTitle("TPC n#sigma around the electron line for selected tracks");
84   hTOFsigmaAll->SetTitle("TOF n#sigma around the electron line");
85   hTOFsigmaSelected->SetTitle("TOF n#sigma around the electron line for selected tracks");
86   DefineTPChisto(hTPCall, "TPC Signal / a.u");
87   DefineTPChisto(hTPCselected, "TPC Signal / a.u.");
88   DefineTPChisto(hTPCsigmaAll, "TPC Sigma");
89   DefineTPChisto(hTPCsigmaSelected, "TPC Sigma");
90
91   // Also make nice histograms for TOF
92   DefineTPChisto(hTOFsigmaAll, "TOF Sigma");
93   DefineTPChisto(hTOFsigmaSelected, "TOF Sigma");
94
95   // Plot them
96   TCanvas *c2 = new TCanvas("cTPCall", "TPC Signal for all tracks", 640, 480);
97   c2->cd();
98   c2->SetGridx(kFALSE);
99   c2->SetGridy(kFALSE);
100   c2->SetLogx();
101   c2->SetLogz();
102   hTPCall->GetYaxis()->SetRangeUser(40., 100.);
103   hTPCall->Draw("colz");
104   ALICEWorkInProgress(c2, "today");
105
106   TCanvas *c3 = new TCanvas("cTPCsel", "TPC Signal for selected tracks", 640, 480);
107   c3->cd();
108   c3->SetGridx(kFALSE);
109   c3->SetGridy(kFALSE);
110   c3->SetLogx();
111   c3->SetLogz();
112   hTPCselected->GetYaxis()->SetRangeUser(40., 100.);
113   hTPCselected->Draw("colz");
114   ALICEWorkInProgress(c3, "today");
115
116   TCanvas *c4 = new TCanvas("cTPCsigAll", "TPC Sigma for all tracks", 640, 480);
117   c4->cd();
118   c4->SetGridx(kFALSE);
119   c4->SetGridy(kFALSE);
120   c4->SetLogx();
121   c4->SetLogz();
122   //hTPCsigmaAll->GetYaxis()->SetRangeUser(-3.5, 5.);
123   hTPCsigmaAll->Draw("colz");
124   ALICEWorkInProgress(c4, "today");
125
126   TCanvas *c5 = new TCanvas("cTPCsigSel", "TPC Sigma for selected tracks", 640, 480);
127   c5->cd();
128   c5->SetGridx(kFALSE);
129   c5->SetGridy(kFALSE);
130   c5->SetLogx();
131   c5->SetLogz();
132   hTPCsigmaSelected->GetYaxis()->SetRangeUser(-3.5, 5.);
133   hTPCsigmaSelected->Draw("colz");
134   ALICEWorkInProgress(c5, "today");
135
136   TCanvas *c6 = new TCanvas("cTOFsigAll", "TOF Sigma for all tracks", 640, 480);
137   c6->cd();
138   c6->SetGridx(kFALSE);
139   c6->SetGridy(kFALSE);
140   c6->SetLogx();
141   c6->SetLogz();
142   hTOFsigmaAll->Draw("colz");
143   ALICEWorkInProgress(c6, "today");
144
145   TCanvas *c7 = new TCanvas("cTOFsigSel", "TOF Sigma for selected tracks", 640, 480);
146   c7->cd();
147   c7->SetGridx(kFALSE);
148   c7->SetGridy(kFALSE);
149   c7->SetLogx();
150   c7->SetLogz();
151   //hTOFsigmaSelected->GetYaxis()->SetRangeUser(-3, 3);
152   hTOFsigmaSelected->Draw("colz");
153   ALICEWorkInProgress(c7, "today");
154
155   TFile *output = new TFile("Performance.root", "RECREATE");
156   output->cd();
157   spec->Write();
158   hTPCall->Write();
159   hTPCselected->Write();
160   hTPCsigmaAll->Write();
161   hTPCsigmaSelected->Write();
162   c1->Write();
163   c2->Write();
164   c3->Write();
165   c4->Write();
166   c5->Write();
167   c6->Write();
168   c7->Write();
169   output->Close();
170   delete output;
171 }
172
173 void DefineTPChisto(TH2 *h, const char *yaxis){
174   h->SetStats(kFALSE);
175   h->GetXaxis()->SetRangeUser(ptmin, ptmax);
176   h->GetXaxis()->SetMoreLogLabels();
177   h->GetXaxis()->SetNoExponent();
178   h->GetXaxis()->SetTitle("p / GeV/c");
179   h->GetYaxis()->SetTitle(yaxis);
180 }
181
182 void ALICEWorkInProgress(TCanvas *c,TString today){
183  //date must be in the form: 04/05/2010
184  if(today=="today"){
185    TDatime startt;                                                                                                                                                        
186    int date=startt.GetDate();
187
188    int y=date/10000;
189    int m=(date%10000)/100;
190    int d=date%100;
191
192
193    today="";
194    today+=d;
195    if(m<10)
196      today.Append("/0");
197    else today.Append("/");
198    today+=m;
199    today.Append("/");
200    today+=y;  
201
202  }
203  TPad *myPadLogo = new TPad("myPadLogo", "Pad for ALICE Logo",0.67,0.65,0.82,0.89);
204  //  myPadLogo->SetFillColor(2); 
205  myPadLogo->SetBorderMode(0);
206  myPadLogo->SetBorderSize(2);
207  myPadLogo->SetFrameBorderMode(0);
208  myPadLogo->SetLeftMargin(0.0);
209  myPadLogo->SetTopMargin(0.0);
210  myPadLogo->SetBottomMargin(0.0);
211  myPadLogo->SetRightMargin(0.0);
212  myPadLogo->Draw();
213  myPadLogo->cd();
214  TASImage *myAliceLogo = new TASImage("/u/mfasel/work/electron/Spectrum/alice_logo.png");
215  myAliceLogo->Draw();
216  c->cd();
217  TPaveText* t1=new TPaveText(0.59,0.59,0.89,0.66,"NDC");
218  t1->SetFillStyle(0);
219  t1->SetBorderSize(0);
220  t1->AddText(0.,0.,"ALICE Performance");
221  t1->SetTextColor(kRed);
222  t1->SetTextFont(42);
223  t1->Draw();
224  TPaveText* t2=new TPaveText(0.59,0.54,0.89,0.60,"NDC");
225  t2->SetFillStyle(0);
226  t2->SetBorderSize(0);
227  t2->SetTextColor(kRed);
228  t2->SetTextFont(52);
229  t2->AddText(0.,0.,today.Data());
230  t2->Draw();
231 }
232