]>
Commit | Line | Data |
---|---|---|
0f84fefb | 1 | /** |
2 | * @file CompareCorrs.C | |
3 | * @author Christian Holm Christensen <cholm@dalsgaard.hehi.nbi.dk> | |
4 | * @date Fri Jan 28 23:01:59 2011 | |
5 | * | |
6 | * @brief Utilities for comparing correction objects | |
7 | * | |
970b1a8a | 8 | * |
bd6f5206 | 9 | * @ingroup pwglf_forward_scripts_corr |
0f84fefb | 10 | * |
11 | */ | |
12 | #ifndef __CINT__ | |
13 | #include <TCanvas.h> | |
14 | #include <TFile.h> | |
15 | #include <TLatex.h> | |
16 | #include <TStyle.h> | |
17 | #include <TMath.h> | |
18 | #include "AliForwardCorrectionManager.h" | |
19 | #endif | |
20 | ||
21 | ||
22 | //====================================================================== | |
970b1a8a | 23 | /** |
5e4ba1bb | 24 | * A canvas |
970b1a8a | 25 | * |
26 | * | |
bd6f5206 | 27 | * @ingroup pwglf_forward_scripts_corr |
970b1a8a | 28 | */ |
0f84fefb | 29 | struct Canvas |
30 | { | |
31 | //____________________________________________________________________ | |
5e4ba1bb | 32 | /** |
33 | * CTOR | |
34 | * | |
35 | * @param name Name | |
36 | * @param title Title | |
37 | * @param n1 N1, | |
38 | * @param n2 N2 | |
39 | */ | |
0f84fefb | 40 | Canvas(const char* name, const char* title, |
41 | const char* n1, const char* n2) | |
42 | : fName(name), | |
43 | fTitle(title), | |
44 | fN1(n1), | |
45 | fN2(n2), | |
46 | fCanvas(0), | |
47 | fBody(0) | |
48 | { | |
49 | gStyle->SetPalette(1); | |
50 | gStyle->SetTitleX(.10); | |
51 | gStyle->SetTitleY(.99); | |
52 | gStyle->SetTitleW(.85); | |
53 | gStyle->SetTitleH(.085); | |
54 | gStyle->SetTitleFillColor(0); | |
55 | gStyle->SetTitleBorderSize(0); | |
56 | } | |
57 | //____________________________________________________________________ | |
5e4ba1bb | 58 | /** |
59 | * Open it | |
60 | * | |
61 | */ | |
0f84fefb | 62 | void Open() |
63 | { | |
64 | fCanvas = new TCanvas(fName, fTitle, 800, TMath::Sqrt(2)*800); | |
65 | fCanvas->SetFillColor(0); | |
66 | ||
67 | fCanvas->Print("comparison.pdf[", "pdf"); | |
68 | } | |
69 | //____________________________________________________________________ | |
5e4ba1bb | 70 | /** |
71 | * Clear pad | |
72 | * | |
73 | * @param nPad Pad number | |
74 | * @param d Detector | |
75 | * @param r Ring | |
76 | * | |
77 | * @return Pointer to pad | |
78 | */ | |
0f84fefb | 79 | TPad* |
80 | Clear(UShort_t nPad, UShort_t d, Char_t r) | |
81 | { | |
82 | fCanvas->Clear(); | |
83 | TPad* top = new TPad("top", "Top", 0, .95, 1, 1, 0, 0); | |
84 | top->Draw(); | |
85 | top->cd(); | |
86 | ||
87 | TLatex* l = new TLatex(.5, .5, Form("%s for FMD%d%c (%s / %s)", | |
88 | fTitle, d, r, fN1, fN2)); | |
89 | l->SetNDC(); | |
90 | l->SetTextAlign(22); | |
91 | l->SetTextSize(0.3); | |
92 | l->Draw(); | |
93 | ||
94 | fCanvas->cd(); | |
95 | fBody = new TPad("body", "Body", 0, 0, 1, .95, 0, 0); | |
96 | fBody->SetTopMargin(0.05); | |
97 | fBody->SetRightMargin(0.05); | |
98 | fBody->Divide(2, (nPad+1)/2, 0.001, 0.001); | |
99 | fBody->Draw(); | |
100 | ||
101 | return fBody; | |
102 | } | |
103 | //____________________________________________________________________ | |
5e4ba1bb | 104 | /** |
105 | * Change to pad | |
106 | * | |
107 | * @param i Pad number | |
108 | * | |
109 | * @return Pointer to pad | |
110 | */ | |
0f84fefb | 111 | TVirtualPad* cd(Int_t i) |
112 | { | |
113 | if (!fBody) return 0; | |
114 | ||
115 | return fBody->cd(i); | |
116 | } | |
117 | //____________________________________________________________________ | |
5e4ba1bb | 118 | /** |
119 | * Print information | |
120 | * | |
121 | * @param d Detector | |
122 | * @param r Ring | |
123 | * @param extra more stuff | |
124 | */ | |
0f84fefb | 125 | void Print(UShort_t d, Char_t r, const char* extra="") |
126 | { | |
127 | fCanvas->Print("comparison.pdf", | |
128 | Form("Title:FMD%d%c %s", d, r, extra)); | |
129 | } | |
130 | //____________________________________________________________________ | |
5e4ba1bb | 131 | /** |
132 | * Close it | |
133 | * | |
134 | */ | |
0f84fefb | 135 | void Close() |
136 | { | |
137 | fCanvas->Print("comparison.pdf]", "pdf"); | |
138 | } | |
139 | //____________________________________________________________________ | |
5e4ba1bb | 140 | /// NAme |
0f84fefb | 141 | const char* fName; |
5e4ba1bb | 142 | /// Title |
0f84fefb | 143 | const char* fTitle; |
5e4ba1bb | 144 | /// N1 |
0f84fefb | 145 | const char* fN1; |
5e4ba1bb | 146 | /// N2 |
0f84fefb | 147 | const char* fN2; |
5e4ba1bb | 148 | /// Canvas |
0f84fefb | 149 | TCanvas* fCanvas; |
5e4ba1bb | 150 | /// Body |
0f84fefb | 151 | TPad* fBody; |
152 | }; | |
153 | ||
154 | //====================================================================== | |
970b1a8a | 155 | /** |
156 | * | |
157 | * | |
158 | * @param what | |
159 | * @param fn1 | |
160 | * @param fn2 | |
161 | * @param o1 | |
162 | * @param o2 | |
163 | * | |
bd6f5206 | 164 | * @ingroup pwglf_forward_scripts_corr |
970b1a8a | 165 | */ |
0f84fefb | 166 | void |
167 | GetObjects(UShort_t what, | |
168 | const char* fn1, const char* fn2, | |
169 | TObject*& o1, TObject*& o2) | |
170 | { | |
171 | // --- Open files -------------------------------------------------- | |
172 | TFile* file1 = TFile::Open(fn1, "READ"); | |
173 | TFile* file2 = TFile::Open(fn2, "READ"); | |
174 | ||
175 | if (!file1) { | |
176 | Error("CompareSecMaps", "File %s cannot be opened", fn1); | |
177 | return; | |
178 | } | |
179 | ||
180 | if (!file2) { | |
181 | Error("CompareSecMaps", "File %s cannot be opened", fn2); | |
182 | return; | |
183 | } | |
184 | ||
185 | // --- Find Objects ------------------------------------------------ | |
186 | AliForwardCorrectionManager::ECorrection ewhat = what; | |
187 | // (AliForwardCorrectionManager::ECorrection)what; | |
188 | const char* objName = | |
189 | AliForwardCorrectionManager::Instance().GetObjectName(ewhat); | |
190 | ||
191 | o1 = file1->Get(objName); | |
192 | o2 = file2->Get(objName); | |
193 | ||
194 | if (!o1) { | |
195 | Error("CompareSecMaps", "File %s does not contain an object named %s", | |
196 | fn1, objName); | |
197 | return; | |
198 | } | |
199 | if (!o2) { | |
200 | Error("CompareSecMaps", "File %s does not contain an object named %s", | |
201 | fn2, objName); | |
202 | return; | |
203 | } | |
204 | }; | |
205 | ||
206 | ||
207 | ||
970b1a8a | 208 | // |
209 | // EOF | |
210 | // |