4 * Scripts to draw energy loss fits from correction object file
6 * @ingroup pwglf_forward_scripts_corr
12 # include <TObjArray.h>
20 # include "AliForwardCorrectionManager.h"
21 # include "AliFMDCorrAcceptance.h"
22 # include "AliForwardUtil.h"
30 * @param c Canvas to clear
32 * @ingroup pwglf_forward_scripts_corr
35 ClearCanvas(TCanvas* c)
38 c->SetRightMargin(.05);
39 c->SetBottomMargin(.1);
45 DrawSummary(TObjArray* stacks, TCanvas* c)
47 if (!stacks) return false;
48 // --- Make summary page -------------------------------------------
50 Int_t nVtx = 10; // stacks->GetEntries();
52 c->Divide(3, (nVtx+2)/3, 0, 0);
54 for (UShort_t v = 1; v <= nVtx; v++) {
57 if (ipad == 1 || ipad == 12) ipad++;
59 THStack* stack = static_cast<THStack*>(stacks->At(v-1));
61 Error("", "No stack at v=%d", v-1);
64 TVirtualPad* pad = c->cd(ipad);
66 Error("", "No pad at %d", ipad);
69 pad->SetFillColor(kWhite);
71 stack->SetMaximum(1.2);
72 stack->Draw("nostack hist");
81 * Draw energy loss fits to a multi-page PDF.
84 * The input file is expected to contain a AliFMDCorrELossFit object
85 * named @c elossfits in the top level directory.
88 * A multi-page PDF. Note, that the PDF generated by ROOT in this way
89 * is broken (cannot be read by Acrobat Reader on Windows and MacOSX)
90 * and one should pass it through a filter to correct these problems.
92 * @param fname File name
93 * @param option Drawing options
95 * @ingroup pwglf_forward_scripts_corr
98 DrawCorrAcc(const char* fname, const char* option="colz")
100 //__________________________________________________________________
101 // Load libraries and object
103 gROOT->Macro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C");
106 TFile* file = TFile::Open(fname, "READ");
108 Error("DrawCorrAcc", "Failed to open %s", fname);
111 TString pname(fname);
112 pname.ReplaceAll(".root", ".pdf");
114 const char* objName =
115 AliForwardCorrectionManager::Instance()
116 .GetObjectName(AliForwardCorrectionManager::kAcceptance);
117 AliFMDCorrAcceptance* corr =
118 static_cast<AliFMDCorrAcceptance*>(file->Get(objName));
120 Error("DrawCorrAcc", "Object '%s' not found in %s", objName, fname);
124 //__________________________________________________________________
126 TCanvas* c = new TCanvas("c", "c", 800 / TMath::Sqrt(2), 800);
130 c->Print(Form("%s[", pname.Data()));
132 gStyle->SetOptStat(0);
133 gStyle->SetTitleColor(0);
134 gStyle->SetTitleStyle(0);
135 gStyle->SetTitleBorderSize(0);
136 gStyle->SetTitleX(.5);
137 gStyle->SetTitleY(1);
138 gStyle->SetTitleW(.8);
139 gStyle->SetTitleH(.09);
140 gStyle->SetFrameFillColor(kWhite);
141 gStyle->SetFrameBorderSize(1);
142 gStyle->SetFrameBorderMode(1);
143 gStyle->SetPalette(1);
146 //__________________________________________________________________
147 // Create a title page
148 TLatex* ll = new TLatex(.5,.8, fname);
149 ll->SetTextAlign(22);
150 ll->SetTextSize(0.03);
154 TLatex* l = new TLatex(.5,.8, fname);
156 l->SetTextSize(0.03);
159 l->DrawLatex(0.2, 0.70, "Acceptance due to dead channels");
161 l->DrawLatex(0.5, 0.60, "c_{v,r}(#eta,#phi)=#frac{"
162 "#sum active strips#in(#eta,#phi)}{"
163 "#sum strips#in(#eta,#phi)}");
165 c->Print(pname.Data(), "Title:Title page");
169 //__________________________________________________________________
170 // Draw all corrections
171 const TAxis& vtxAxis = corr->GetVertexAxis();
172 Int_t nVtx = vtxAxis.GetNbins();
174 // --- Create stacks for summaries ---------------------------------
175 TObjArray* stacks = new TObjArray(nVtx);
176 TObjArray* stacks2 = (corr->HasOverflow() ? new TObjArray(nVtx) : 0);
177 for (UShort_t v = 1; v <= nVtx; v++) {
178 THStack* stack = new THStack(Form("vtx%02d", v),
179 Form("%+5.1f<v_{z}<%+5.1f",
180 vtxAxis.GetBinLowEdge(v),
181 vtxAxis.GetBinUpEdge(v)));
182 stacks->AddAt(stack, v-1);
183 if (!stacks2) continue;
184 stacks2->AddAt(stack->Clone(), v-1);
187 // --- Loop over detectors -----------------------------------------
188 for (UShort_t d = 1; d <= 3; d++) {
189 UShort_t nQ = (d == 1 ? 1 : 2);
190 for (UShort_t q = 0; q < nQ; q++) {
191 Char_t r = (q == 0 ? 'I' : 'O');
194 c->Divide(2, (nVtx+1)/2);
195 for (UShort_t v=1; v <= nVtx; v++) {
196 TVirtualPad* p = c->cd(v);
197 p->SetFillColor(kWhite);
199 TH2* h2 = corr->GetCorrection(d, r, v);
201 Warning("DrawCorrAcc", "No correction for r=%c, v=%d", r, v);
206 Int_t nY = h2->GetNbinsY();
207 TH1* hh = h2->ProjectionX(Form("FMD%d%c", d, r), 1, nY);
210 hh->SetMarkerColor(AliForwardUtil::RingColor(d, r));
211 hh->SetLineColor(AliForwardUtil::RingColor(d, r));
212 hh->SetFillColor(AliForwardUtil::RingColor(d, r));
213 hh->SetFillStyle(3001);
215 THStack* stack = static_cast<THStack*>(stacks->At(v-1));
217 Error("", "No stack at v=%d", v-1);
223 Warning("", "No phi acceptance defined");
226 stack = static_cast<THStack*>(stacks2->At(v-1));
228 Error("", "No stack at v=%d", v-1);
231 TH1* hp = corr->GetPhiAcceptance(d, r, v);
233 Error("", "No phi acceptance at v=%d", v-1);
237 hp->SetMarkerColor(AliForwardUtil::RingColor(d, r));
238 hp->SetLineColor(AliForwardUtil::RingColor(d, r));
239 hp->SetFillColor(AliForwardUtil::RingColor(d, r));
240 hp->SetFillStyle(3001);
241 Info("", "Adding phi acceptance plot %d", hp->GetEntries());
245 c->Print(pname.Data(), Form("Title:FMD%d%c", d, r));
249 if (DrawSummary(stacks2, c))
250 c->Print(pname.Data(), "Title:Summary2");
251 if (DrawSummary(stacks, c))
252 c->Print(pname.Data(), "Title:Summary");
254 //__________________________________________________________________
256 c->Print(Form("%s]", pname.Data()));