]>
Commit | Line | Data |
---|---|---|
7984e5f7 | 1 | // |
2 | // This class contains the secondary correction and the double hit | |
3 | // correction used in low-flux events. | |
4 | // | |
0bd4b00f | 5 | #include "AliFMDCorrVertexBias.h" |
6 | #include <TBrowser.h> | |
7 | #include <TH2D.h> | |
8 | #include <AliLog.h> | |
9 | #include <iostream> | |
10 | ||
11 | //____________________________________________________________________ | |
12 | AliFMDCorrVertexBias::AliFMDCorrVertexBias() | |
13 | : fVertexArray(), | |
14 | fVertexAxis(0,0,0) | |
15 | { | |
7984e5f7 | 16 | // |
17 | // Default constructor | |
18 | // | |
0bd4b00f | 19 | fVertexArray.SetOwner(kTRUE); |
20 | fVertexArray.SetName("rings"); | |
21 | fVertexAxis.SetName("vtxAxis"); | |
22 | fVertexAxis.SetTitle("v_{z} [cm]"); | |
23 | ||
24 | } | |
25 | //____________________________________________________________________ | |
26 | AliFMDCorrVertexBias::AliFMDCorrVertexBias(const AliFMDCorrVertexBias& o) | |
27 | : TObject(o), | |
28 | fVertexArray(o.fVertexArray), | |
29 | fVertexAxis(o.fVertexAxis.GetNbins(), o.fVertexAxis.GetXmin(), | |
30 | o.fVertexAxis.GetXmax()) | |
31 | { | |
7984e5f7 | 32 | // |
33 | // Copy constructor | |
34 | // | |
35 | // Parameters: | |
36 | // o Object to copy from | |
37 | // | |
0bd4b00f | 38 | fVertexAxis.SetName("vtxAxis"); |
39 | fVertexAxis.SetTitle("v_{z} [cm]"); | |
40 | } | |
41 | //____________________________________________________________________ | |
42 | AliFMDCorrVertexBias::~AliFMDCorrVertexBias() | |
43 | { | |
7984e5f7 | 44 | // |
45 | // Destructor | |
46 | // | |
47 | // | |
0bd4b00f | 48 | fVertexArray.Clear(); |
49 | } | |
50 | //____________________________________________________________________ | |
51 | AliFMDCorrVertexBias& | |
52 | AliFMDCorrVertexBias::operator=(const AliFMDCorrVertexBias& o) | |
53 | { | |
7984e5f7 | 54 | // |
55 | // Assignment operator | |
56 | // | |
57 | // Parameters: | |
58 | // o Object to assign from | |
59 | // | |
60 | // Return: | |
61 | // Reference to this object | |
62 | // | |
0bd4b00f | 63 | fVertexArray = o.fVertexArray; |
64 | SetVertexAxis(o.fVertexAxis); | |
65 | ||
66 | return *this; | |
67 | } | |
68 | //____________________________________________________________________ | |
69 | TH2D* | |
70 | AliFMDCorrVertexBias::GetCorrection(Char_t r, Double_t v) const | |
71 | { | |
7984e5f7 | 72 | // |
73 | // Get the vertex bias correction @f$ b_{v}@f$ | |
74 | // | |
75 | // Parameters: | |
76 | // r Ring type (I or O) | |
77 | // v Primary interaction point @f$z@f$ coordinate | |
78 | // | |
79 | // Return: | |
80 | // The correction @f$ b_{v}@f$ | |
81 | // | |
0bd4b00f | 82 | Int_t b = FindVertexBin(v); |
83 | if (b <= 0) return 0; | |
84 | return GetCorrection(r, UShort_t(b)); | |
85 | } | |
86 | //____________________________________________________________________ | |
87 | TH2D* | |
88 | AliFMDCorrVertexBias::GetCorrection(Char_t r, UShort_t b) const | |
89 | { | |
7984e5f7 | 90 | // |
91 | // Get the vertex bias correction @f$ b_{v}@f$ | |
92 | // | |
93 | // Parameters: | |
94 | // r Ring type (I or O) | |
95 | // b Bin corresponding to the primary interaction point | |
96 | // @f$z@f$ coordinate (1 based) | |
97 | // | |
98 | // Return: | |
99 | // The correction @f$ b_{v}@f$ | |
100 | // | |
0bd4b00f | 101 | TObjArray* vertexarray = GetVertexArray(b); |
102 | if (!vertexarray) return 0; | |
103 | ||
104 | Int_t idx = -1; | |
105 | switch (r) { | |
106 | case 'i': case 'I': idx = 0; break; | |
107 | case 'o': case 'O': idx = 1; break; | |
108 | } | |
109 | if (idx < 0) { | |
110 | AliWarning(Form("Unknown ting type %c, not one of [iIoO]", r)); | |
111 | return 0; | |
112 | } | |
113 | ||
114 | TObject* o = vertexarray->At(idx); | |
115 | if (!o) { | |
116 | AliWarning(Form("No vertex bias found for ring type %c in vertex bin %d", | |
117 | r,b)); | |
118 | return 0; | |
119 | } | |
120 | return static_cast<TH2D*>(o); | |
121 | } | |
122 | ||
123 | //____________________________________________________________________ | |
124 | Int_t | |
125 | AliFMDCorrVertexBias::FindVertexBin(Double_t v) const | |
126 | { | |
7984e5f7 | 127 | // |
128 | // Find the vertex bin that corresponds to the passed vertex | |
129 | // | |
130 | // Parameters: | |
131 | // vertex The interaction points @f$z@f$-coordinate | |
132 | // | |
133 | // Return: | |
134 | // Vertex bin in @f$[1,N_{\mbox{vertex}}]@f$ or negative if | |
135 | // out of range | |
136 | // | |
0bd4b00f | 137 | if (fVertexAxis.GetNbins() <= 0) { |
138 | AliWarning("No vertex array defined"); | |
139 | return 0; | |
140 | } | |
141 | Int_t bin = const_cast<TAxis&>(fVertexAxis).FindBin(v); | |
142 | if (bin <= 0 || bin > fVertexAxis.GetNbins()) { | |
143 | AliWarning(Form("vertex %+8.4f out of range [%+8.4f,%+8.4f]", | |
144 | v, fVertexAxis.GetXmin(), fVertexAxis.GetXmax())); | |
145 | return 0; | |
146 | } | |
147 | return bin; | |
148 | } | |
149 | //____________________________________________________________________ | |
150 | TObjArray* | |
151 | AliFMDCorrVertexBias::GetVertexArray(UShort_t v) const | |
152 | { | |
7984e5f7 | 153 | // |
154 | // Get the vertex array corresponding to the specified ring | |
155 | // | |
156 | // Parameters: | |
157 | // v vertex bin (1 based) | |
158 | // | |
159 | // Return: | |
160 | // Pointer to vertex array, or null in case of problems | |
161 | // | |
0bd4b00f | 162 | if (v <= 0 || v > fVertexAxis.GetNbins()) { |
163 | AliWarning(Form("vertex bin %d out of range [1,%d]", | |
164 | v, fVertexAxis.GetNbins())); | |
165 | return 0; | |
166 | } | |
167 | ||
168 | TObject* o = fVertexArray.At(v-1); | |
169 | if (!o) { | |
170 | AliWarning(Form("No array found for vertex bin %d", v)); | |
171 | return 0; | |
172 | } | |
173 | ||
174 | return static_cast<TObjArray*>(o); | |
175 | } | |
176 | //____________________________________________________________________ | |
177 | TObjArray* | |
178 | AliFMDCorrVertexBias::GetOrMakeVertexArray(UShort_t v) | |
179 | { | |
7984e5f7 | 180 | // |
181 | // Get the vertex array corresponding to the specified ring | |
182 | // | |
183 | // Parameters: | |
184 | // v vertex bin (1 based) | |
185 | // | |
186 | // Return: | |
187 | // Pointer to vertex array, or newly created container | |
188 | // | |
0bd4b00f | 189 | if (v <= 0 || v > fVertexAxis.GetNbins()) { |
190 | AliWarning(Form("vertex bin %d out of range [1,%d]", | |
191 | v, fVertexAxis.GetNbins())); | |
192 | return 0; | |
193 | } | |
194 | ||
195 | TObject* o = fVertexArray.At(v-1); | |
196 | if (!o) { | |
197 | TObjArray* a = new TObjArray(fVertexAxis.GetNbins()); | |
198 | a->SetName(Form("vertexbin%02d", v)); | |
199 | a->SetOwner(kTRUE); | |
200 | fVertexArray.AddAtAndExpand(a, v-1); | |
201 | return a; | |
202 | } | |
203 | ||
204 | return static_cast<TObjArray*>(fVertexArray.At(v-1)); | |
205 | } | |
206 | ||
207 | //____________________________________________________________________ | |
208 | Bool_t | |
209 | AliFMDCorrVertexBias::SetCorrection(Char_t r, UShort_t b, TH2D* h) | |
210 | { | |
7984e5f7 | 211 | // |
212 | // Set the vertex bias correction @f$ b_{v}(\eta,\varphi)@f$ | |
213 | // Note, that the object takes ownership of the passed pointer. | |
214 | // | |
215 | // Parameters: | |
216 | // r Ring type (I or O) | |
217 | // b Bin corresponding to the primary interaction point | |
218 | // @f$z@f$ coordinate (1 based) | |
219 | // h @f$ b_{v}(\eta,\varphi)@f$ | |
220 | // | |
221 | // Return: | |
222 | // true if operation succeeded | |
223 | // | |
0bd4b00f | 224 | TObjArray* vertexarray = GetOrMakeVertexArray(b); |
225 | if (!vertexarray) return false; | |
226 | ||
227 | ||
228 | Int_t idx = -1; | |
229 | switch (r) { | |
230 | case 'i': case 'I': idx = 0; break; | |
231 | case 'o': case 'O': idx = 1; break; | |
232 | } | |
233 | if (idx < 0) { | |
234 | AliWarning(Form("Unknown ting type %c, not one of [iIoO]", r)); | |
235 | return false; | |
236 | } | |
237 | h->SetName(Form("FMDX%c", r)); | |
238 | h->SetTitle(Form("Vertex bias correction for %c rings " | |
239 | "in vertex bin %d [%+8.4f,%+8.4f]", | |
240 | r, b, fVertexAxis.GetBinLowEdge(b), | |
241 | fVertexAxis.GetBinUpEdge(b))); | |
242 | h->SetXTitle("#eta"); | |
243 | h->SetYTitle("#phi [radians]"); | |
244 | h->SetZTitle("1/N_{t}#sum_{i}^{N_{tv}} N_{ch,i,primary} / " | |
245 | "1/N_{v}#sum_{i}^{N_{v}} N_{ch,i,primary}"); | |
246 | h->SetDirectory(0); | |
247 | h->SetStats(0); | |
248 | ||
249 | vertexarray->AddAtAndExpand(h, idx); | |
250 | return kTRUE; | |
251 | } | |
252 | //____________________________________________________________________ | |
253 | Bool_t | |
254 | AliFMDCorrVertexBias::SetCorrection(Char_t r, Double_t v, TH2D* h) | |
255 | { | |
7984e5f7 | 256 | // |
257 | // Set the vertex bias correction @f$ b_{v}(\eta,\varphi)@f$. | |
258 | // Note, that the object takes ownership of the passed pointer. | |
259 | // | |
260 | // Parameters: | |
261 | // r Ring type (I or O) | |
262 | // v Primary interaction point @f$z@f$ coordinate | |
263 | // h @f$ b_{v}(\eta,\varphi)@f$ | |
264 | // | |
265 | // Return: | |
266 | // true if operation succeeded | |
267 | // | |
0bd4b00f | 268 | Int_t b = FindVertexBin(v); |
269 | if (b <= 0 || b > fVertexAxis.GetNbins()) { | |
270 | AliWarning(Form("Vertex %+8.4f out of range [%+8.4f,%+8.4f]", | |
271 | v, fVertexAxis.GetXmin(), fVertexAxis.GetXmax())); | |
272 | return false; | |
273 | } | |
274 | return SetCorrection(r, UShort_t(b), h); | |
275 | } | |
276 | //____________________________________________________________________ | |
277 | void | |
278 | AliFMDCorrVertexBias::Browse(TBrowser* b) | |
279 | { | |
7984e5f7 | 280 | // |
281 | // Browse this object in the browser | |
282 | // | |
283 | // Parameters: | |
284 | // b | |
285 | // | |
0bd4b00f | 286 | b->Add(&fVertexArray); |
287 | b->Add(&fVertexAxis); | |
288 | } | |
289 | //____________________________________________________________________ | |
290 | void | |
291 | AliFMDCorrVertexBias::Print(Option_t* option) const | |
292 | { | |
7984e5f7 | 293 | // |
294 | // Print this object | |
295 | // | |
296 | // Parameters: | |
297 | // option | |
298 | // | |
0bd4b00f | 299 | std::cout << "Vertex bias correction" << std::endl; |
300 | fVertexArray.Print(option); | |
301 | fVertexAxis.Print(option); | |
302 | } | |
303 | ||
304 | //____________________________________________________________________ | |
305 | // | |
306 | // EOF | |
307 | // |