]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/corrs/DrawCorrAcc2.C
Fixed references from PWG2 -> PWGLF - very efficiently done using ETags.
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / corrs / DrawCorrAcc2.C
CommitLineData
9ecab72f 1/**
2 * @file
3 *
4 * Scripts to draw energy loss fits from correction object file
5 *
bd6f5206 6 * @ingroup pwglf_forward_scripts_corr
9ecab72f 7 */
8/**
9 * Clear canvas
10 *
11 * @param c Canvas to clear
12 *
bd6f5206 13 * @ingroup pwglf_forward_scripts_corr
9ecab72f 14 */
15void
16ClearCanvas(TCanvas* c)
17{
18 c->SetLeftMargin(.1);
19 c->SetRightMargin(.05);
20 c->SetBottomMargin(.1);
21 c->SetTopMargin(.05);
22 c->Clear();
23}
24
25/**
26 * Draw energy loss fits to a multi-page PDF.
27 *
28 * @par Input:
29 * The input file is expected to contain a AliFMDCorrELossFit object
970b1a8a 30 * named @c elossfits in the top level directory.
9ecab72f 31 *
970b1a8a 32 * @par Output:
9ecab72f 33 * A multi-page PDF. Note, that the PDF generated by ROOT in this way
34 * is broken (cannot be read by Acrobat Reader on Windows and MacOSX)
35 * and one should pass it through a filter to correct these problems.
36 *
37 * @param fname File name
38 * @param option Drawing options
39 *
bd6f5206 40 * @ingroup pwglf_forward_scripts_corr
9ecab72f 41 */
42void
43DrawCorrAcc2(const char* fname, const char* option="colz")
44{
45 //__________________________________________________________________
46 // Load libraries and object
bd6f5206 47 gROOT->Macro("$ALICE_ROOT/PWGLF/FORWARD/analysis2/scripts/LoadLibs.C");
9ecab72f 48
49 TFile* file = TFile::Open(fname, "READ");
50 if (!file) {
51 Error("DrawCorrAcc", "Failed to open %s", fname);
52 return;
53 }
54 TString pname(fname);
55 pname.ReplaceAll(".root", ".pdf");
56
57 const char* objName =
58 AliForwardCorrectionManager::Instance()
59 .GetObjectName(AliForwardCorrectionManager::kAcceptance);
60 AliFMDCorrAcceptance* corr =
61 static_cast<AliFMDCorrAcceptance*>(file->Get(objName));
62 if (!corr) {
63 Error("DrawCorrAcc", "Object '%s' not found in %s", objName, fname);
64 return;
65 }
66
67 //__________________________________________________________________
68 // Create a canvas
69 // TCanvas* c = new TCanvas("c", "c", 800 / TMath::Sqrt(2), 800);
70 TCanvas* c = new TCanvas("c", "c", 800, 800 / TMath::Sqrt(2));
71 c->SetFillColor(0);
72 c->SetBorderSize(0);
73 c->SetBorderMode(0);
74
75 gStyle->SetOptStat(0);
76 gStyle->SetTitleColor(0);
77 gStyle->SetTitleStyle(0);
78 gStyle->SetTitleBorderSize(0);
79 gStyle->SetTitleX(.1);
80 gStyle->SetTitleY(1);
81 gStyle->SetTitleW(.8);
82 gStyle->SetTitleH(.09);
83 gStyle->SetFrameFillColor(kWhite);
84 gStyle->SetFrameBorderSize(1);
85 gStyle->SetFrameBorderMode(1);
86 gStyle->SetPalette(1);
87
88 ClearCanvas(c);
89 const TAxis& vtxAxis = corr->GetVertexAxis();
90 Int_t nVtx = vtxAxis.GetNbins();
91 c->Divide((nVtx+2)/3, 3, 0, 0);
92 Int_t ipad = 0;
93
94 //__________________________________________________________________
95 // Draw all corrections
96 for (UShort_t v = 1; v <= nVtx; v++) {
97 ipad++;
98 if (ipad == 1 || ipad == 12) ipad++;
99
100 TVirtualPad* p = c->cd(ipad);
101 p->SetFillColor(kWhite);
102
103 THStack* stack = new THStack(Form("vtx%02d", v),
104 Form("%+5.1f<v_{z}<%+5.1f",
105 vtxAxis.GetBinLowEdge(v),
106 vtxAxis.GetBinUpEdge(v)));
107 for (UShort_t d = 1; d <= 3; d++) {
108 UShort_t nQ = (d == 1 ? 1 : 2);
109 for (UShort_t q = 0; q < nQ; q++) {
110 Char_t r = (q == 0 ? 'I' : 'O');
111
112 TH2* h1 = corr->GetCorrection(d, r, v);
113 if (!h1) {
114 Warning("DrawCorrAcc", "No correction for r=%c, v=%d", r, v);
115 continue;
116 }
117 TH1* hh = h1->ProjectionX(Form("FMD%d%c", d, r));
118 hh->Scale(1. / h1->GetNbinsY());
119 hh->SetDirectory(0);
120 hh->SetMarkerColor(AliForwardUtil::RingColor(d, r));
121
122 stack->Add(hh);
123 }
124 }
125 stack->SetMaximum(1.2);
126 stack->Draw("nostack");
127 }
128 //__________________________________________________________________
129 // Close output file
130 c->SaveAs("acceptance.png");
131}
132//
133// EOF
134//