]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGLF/FORWARD/analysis2/AliFMDCorrAcceptance.cxx
Chiara O. implemented a way to bypass HIJING internal calculation
[u/mrichter/AliRoot.git] / PWGLF / FORWARD / analysis2 / AliFMDCorrAcceptance.cxx
CommitLineData
1298ee54 1//
8973b4ed 2// This class contains the acceptance correction due to dead channels
1298ee54 3//
4//
8973b4ed 5#include "AliFMDCorrAcceptance.h"
1298ee54 6#include <TBrowser.h>
7#include <TH2D.h>
8#include <AliLog.h>
9#include <iostream>
10
11//____________________________________________________________________
8973b4ed 12AliFMDCorrAcceptance::AliFMDCorrAcceptance()
1298ee54 13 : fRingArray(),
9b5cc785 14 fCache(0),
15 fVertexAxis(0,0,0),
16 fHasOverflow(false)
1298ee54 17{
18 //
19 // Default constructor
20 //
21 fRingArray.SetOwner(kTRUE);
22 fRingArray.SetName("rings");
23 fVertexAxis.SetName("vtxAxis");
24 fVertexAxis.SetTitle("v_{z} [cm]");
25
26}
27//____________________________________________________________________
8973b4ed 28AliFMDCorrAcceptance::AliFMDCorrAcceptance(const
29 AliFMDCorrAcceptance& o)
1298ee54 30 : TObject(o),
31 fRingArray(o.fRingArray),
9b5cc785 32 fCache(o.fCache),
1298ee54 33 fVertexAxis(o.fVertexAxis.GetNbins(), o.fVertexAxis.GetXmin(),
9b5cc785 34 o.fVertexAxis.GetXmax()),
35 fHasOverflow(o.fHasOverflow)
1298ee54 36{
37 //
38 // Copy constructor
39 //
40 // Parameters:
41 // o Object to copy from
42 //
43 fVertexAxis.SetName("vtxAxis");
44 fVertexAxis.SetTitle("v_{z} [cm]");
45}
46//____________________________________________________________________
8973b4ed 47AliFMDCorrAcceptance::~AliFMDCorrAcceptance()
1298ee54 48{
49 //
50 // Destructor
51 //
52 //
53 fRingArray.Clear();
9b5cc785 54 if (fCache) fCache->Clear();
1298ee54 55}
56//____________________________________________________________________
8973b4ed 57AliFMDCorrAcceptance&
58AliFMDCorrAcceptance::operator=(const AliFMDCorrAcceptance& o)
1298ee54 59{
60 //
61 // Assignment operator
62 //
63 // Parameters:
64 // o Object to assign from
65 //
66 // Return:
67 // Reference to this object
68 //
73b32206 69 if (&o == this) return *this;
70
1298ee54 71 fRingArray = o.fRingArray;
9b5cc785 72 fCache = o.fCache;
73 fHasOverflow = o.fHasOverflow;
1298ee54 74 SetVertexAxis(o.fVertexAxis);
75
76 return *this;
77}
78//____________________________________________________________________
79TH2D*
8973b4ed 80AliFMDCorrAcceptance::GetCorrection(UShort_t d, Char_t r, Double_t v) const
1298ee54 81{
82 //
8973b4ed 83 // Get the acceptance correction @f$ a_{r,v}@f$
1298ee54 84 //
85 // Parameters:
86 // d Detector number (1-3)
87 // r Ring identifier (I or O)
88 // v Primary interaction point @f$z@f$ coordinate
89 //
90 // Return:
8973b4ed 91 // The correction @f$ a_{r,v}@f$
1298ee54 92 //
93 Int_t b = FindVertexBin(v);
94 if (b <= 0) return 0;
95 return GetCorrection(d, r, UShort_t(b));
96}
97//____________________________________________________________________
98TH2D*
8973b4ed 99AliFMDCorrAcceptance::GetCorrection(UShort_t d, Char_t r, UShort_t b) const
1298ee54 100{
101 //
8973b4ed 102 // Get the acceptance correction @f$ a_{r,v}@f$
1298ee54 103 //
104 // Parameters:
105 // d Detector number (1-3)
106 // r Ring identifier (I or O)
107 // b Bin corresponding to the primary interaction point
108 // @f$z@f$ coordinate (1 based)
109 //
110 // Return:
8973b4ed 111 // The correction @f$ a_{r,v}@f$
1298ee54 112 //
9b5cc785 113 return static_cast<TH2D*>(GetObject(fRingArray, d, r, b));
114}
115//____________________________________________________________________
116TH1D*
117AliFMDCorrAcceptance::GetPhiAcceptance(UShort_t d, Char_t r, Double_t v) const
118{
119 //
120 // Get the acceptance correction @f$ a_{r,v}@f$
121 //
122 // Parameters:
123 // d Detector number (1-3)
124 // r Ring identifier (I or O)
125 // v Primary interaction point @f$z@f$ coordinate
126 //
127 // Return:
128 // The correction @f$ a_{r,v}@f$
129 //
130 Int_t b = FindVertexBin(v);
131 if (b <= 0) return 0;
132 return GetPhiAcceptance(d, r, UShort_t(b));
133}
134//____________________________________________________________________
135TH1D*
136AliFMDCorrAcceptance::GetPhiAcceptance(UShort_t d, Char_t r, UShort_t b) const
137{
138 //
139 // Get the acceptance correction @f$ a_{r,v}@f$
140 //
141 // Parameters:
142 // d Detector number (1-3)
143 // r Ring identifier (I or O)
144 // b Bin corresponding to the primary interaction point
145 // @f$z@f$ coordinate (1 based)
146 //
147 // Return:
148 // The correction @f$ a_{r,v}@f$
149 //
150 if (!fHasOverflow) return 0;
151 if (!fCache) FillCache();
152 return static_cast<TH1D*>(GetObject(*fCache, d, r, b));
1298ee54 153}
154
155//____________________________________________________________________
156Int_t
8973b4ed 157AliFMDCorrAcceptance::FindVertexBin(Double_t v) const
1298ee54 158{
159 //
160 // Find the vertex bin that corresponds to the passed vertex
161 //
162 // Parameters:
163 // vertex The interaction points @f$z@f$-coordinate
164 //
165 // Return:
166 // Vertex bin in @f$[1,N_{\mbox{vertex}}]@f$ or negative if
167 // out of range
168 //
169 if (fVertexAxis.GetNbins() <= 0) {
170 AliWarning("No vertex array defined");
171 return 0;
172 }
173 Int_t bin = const_cast<TAxis&>(fVertexAxis).FindBin(v);
174 if (bin <= 0 || bin > fVertexAxis.GetNbins()) {
175 AliWarning(Form("vertex %+8.4f out of range [%+8.4f,%+8.4f]",
176 v, fVertexAxis.GetXmin(), fVertexAxis.GetXmax()));
177 return 0;
178 }
179 return bin;
180}
181//____________________________________________________________________
182Int_t
8973b4ed 183AliFMDCorrAcceptance::GetRingIndex(UShort_t d, Char_t r) const
1298ee54 184{
1298ee54 185 // Get the index corresponding to the given ring
186 //
187 // Parameters:
188 // d Detector
189 // r Ring
190 //
191 // Return:
192 // Index (0 based) or negative in case of errors
193 //
194 switch (d) {
195 case 1: return 0;
196 case 2: return (r == 'I' || r == 'i' ? 1 : 2); break;
197 case 3: return (r == 'I' || r == 'i' ? 3 : 4); break;
9b5cc785 198
1298ee54 199 }
200 AliWarning(Form("Index for FMD%d%c not found", d, r));
201 return -1;
202}
203//____________________________________________________________________
9b5cc785 204TObject*
205AliFMDCorrAcceptance::GetObject(const TObjArray& m, UShort_t d,
206 Char_t r, UShort_t b) const
207{
208 //
209 // Get the object @f$ a_{r,v}@f$
210 //
211 // Parameters:
212 // m Mother list
213 // d Detector number (1-3)
214 // r Ring identifier (I or O)
215 // b Bin corresponding to the primary interaction point
216 // @f$z@f$ coordinate (1 based)
217 //
218 // Return:
219 // The correction @f$ a_{r,v}@f$
220 //
221 TObjArray* ringArray = GetRingArray(m, d, r);
222 if (!ringArray) return 0;
223
224 if (b <= 0 || b > ringArray->GetEntriesFast()) {
225 AliWarning(Form("vertex bin %d out of range [1,%d]",
226 b, ringArray->GetEntriesFast()));
227 return 0;
228 }
229
230 TObject* o = ringArray->At(b-1);
231 if (o) return o;
232
233 AliWarning(Form("No dead channels map found for FMD%d%c in vertex bin %d",
234 d,r,b));
235 return 0;
236}
237//____________________________________________________________________
1298ee54 238TObjArray*
9b5cc785 239AliFMDCorrAcceptance::GetRingArray(const TObjArray& m,
240 UShort_t d, Char_t r) const
1298ee54 241{
242 //
243 // Get the ring array corresponding to the specified ring
244 //
245 // Parameters:
246 // d Detector
247 // r Ring
248 //
249 // Return:
250 // Pointer to ring array, or null in case of problems
251 //
252 Int_t idx = GetRingIndex(d,r);
253 if (idx < 0) return 0;
254
9b5cc785 255 TObject* o = m.At(idx);
1298ee54 256 if (!o) {
257 AliWarning(Form("No array found for FMD%d%c", d, r));
258 return 0;
259 }
260
261 return static_cast<TObjArray*>(o);
262}
263//____________________________________________________________________
264TObjArray*
9b5cc785 265AliFMDCorrAcceptance::GetOrMakeRingArray(TObjArray& m,
266 UShort_t d, Char_t r) const
1298ee54 267{
268 //
269 // Get the ring array corresponding to the specified ring
270 //
271 // Parameters:
272 // d Detector
273 // r Ring
274 //
275 // Return:
276 // Pointer to ring array, or newly created container
277 //
278 Int_t idx = GetRingIndex(d,r);
279 if (idx < 0) return 0;
280
9b5cc785 281 TObject* o = m.At(idx);
1298ee54 282 if (!o) {
283 TObjArray* a = new TObjArray(fVertexAxis.GetNbins());
284 a->SetName(Form("FMD%d%c", d, r));
285 a->SetOwner(kTRUE);
9b5cc785 286 m.AddAtAndExpand(a, idx);
1298ee54 287 return a;
288 }
289
9b5cc785 290 return static_cast<TObjArray*>(m.At(idx));
1298ee54 291}
292
293//____________________________________________________________________
294Bool_t
8973b4ed 295AliFMDCorrAcceptance::SetCorrection(UShort_t d, Char_t r,
296 UShort_t b, TH2D* h)
1298ee54 297{
298 //
8973b4ed 299 // Set the acceptance correction @f$ a_{r,v}(\eta)@f$
1298ee54 300 // Note, that the object takes ownership of the passed pointer.
301 //
302 // Parameters:
303 // d Detector number (1-3)
304 // r Ring identifier (I or O)
305 // b Bin corresponding to the primary interaction point
306 // @f$z@f$ coordinate (1 based)
8973b4ed 307 // h @f$ a_{r,v}(\eta)@f$
1298ee54 308 //
309 // Return:
310 // true if operation succeeded
311 //
9b5cc785 312 TObjArray* ringArray = GetOrMakeRingArray(fRingArray, d, r);
1298ee54 313 if (!ringArray) return false;
314
315 if (b <= 0 || b > fVertexAxis.GetNbins()) {
316 AliWarning(Form("Vertex bin %3d out of range [1,%3d]",
317 b, fVertexAxis.GetNbins()));
318 return false;
319 }
320 h->SetName(Form("FMD%d%c_vtxbin%03d", d, r, b));
8973b4ed 321 h->SetTitle(Form("Acceptance correction for FMD%d%c "
1298ee54 322 "in vertex bin %d [%+8.4f,%+8.4f]",
323 d, r, b, fVertexAxis.GetBinLowEdge(b),
324 fVertexAxis.GetBinUpEdge(b)));
325 h->SetXTitle("#eta");
9b5cc785 326 h->SetYTitle("N_{strips,OK}/N_{strips}");
1298ee54 327 h->SetFillStyle(3001);
328 h->SetDirectory(0);
329 h->SetStats(0);
330 ringArray->AddAtAndExpand(h, b-1);
331 return kTRUE;
332}
333//____________________________________________________________________
334Bool_t
8973b4ed 335AliFMDCorrAcceptance::SetCorrection(UShort_t d, Char_t r,
336 Double_t v, TH2D* h)
1298ee54 337{
338 //
8973b4ed 339 // Set the acceptance correction @f$ a_{r,v}(\eta)@f$.
1298ee54 340 // Note, that the object takes ownership of the passed pointer.
341 //
342 // Parameters:
343 // d Detector number (1-3)
344 // r Ring identifier (I or O)
345 // v Primary interaction point @f$z@f$ coordinate
8973b4ed 346 // h @f$ a_{r,v}(\eta)@f$
1298ee54 347 //
348 // Return:
349 // true if operation succeeded
350 //
351 Int_t b = FindVertexBin(v);
352 if (b <= 0 || b > fVertexAxis.GetNbins()) {
353 AliWarning(Form("Vertex %+8.4f out of range [%+8.4f,%+8.4f]",
354 v, fVertexAxis.GetXmin(), fVertexAxis.GetXmax()));
355 return false;
356 }
357 return SetCorrection(d, r, UShort_t(b), h);
358}
9b5cc785 359
360//____________________________________________________________________
361void
362AliFMDCorrAcceptance::FillCache() const
363{
364 if (fCache) return;
365
366 fCache = new TObjArray;
367 fCache->SetOwner(kTRUE);
368 fCache->SetName("cache");
369
370 Int_t nV = fVertexAxis.GetNbins();
371 for (UShort_t v = 1; v <= nV; v++) {
372 for(UShort_t d = 1; d <= 3;d++) {
373 UShort_t nR = (d == 1 ? 1 : 2);
374 for (UShort_t q = 0; q < nR; q++) {
375 Char_t r = (q == 0 ? 'I' : 'O');
376
377 TObjArray* a = GetOrMakeRingArray(*fCache, d, r);
378
379 TH2D* corr = GetCorrection(d, r, v);
380 if (!corr) continue;
381
382 Int_t nY = corr->GetNbinsY();
383 TH1D* h = corr->ProjectionX("tmp", nY+1, nY+1, "");
384 h->SetName(Form("FMD%d%c_vtxbin%03d", d, r, v));
385 h->SetTitle(Form("#phi acceptance correction for FMD%d%c "
386 "in vertex bin %d [%+8.4f,%+8.4f]",
387 d, r, v, fVertexAxis.GetBinLowEdge(v),
388 fVertexAxis.GetBinUpEdge(v)));
389 h->SetXTitle("#eta");
390 h->SetYTitle("N_{strips}/N_{strips,OK}");
391 h->SetFillStyle(3001);
392 h->SetDirectory(0);
393 h->SetStats(0);
394 a->AddAtAndExpand(h,v-1);
395
396 if (fHasOverflow) continue;
397
398 // Construct the overflow bin from
399 Int_t nX = corr->GetNbinsX();
400 for (Int_t eta = 1; eta <= nX; eta++) {
401 Double_t sum = 0;
402 for (Int_t phi = 1; phi <= nY; phi++)
403 sum += corr->GetBinContent(eta, phi);
404 if (nY <= 0) continue;
405 h->SetBinContent(eta, nY/sum);
406 } // for eta
407 } // for q
408 } // for d
409 } // for v
410}
1298ee54 411//____________________________________________________________________
412void
8973b4ed 413AliFMDCorrAcceptance::Browse(TBrowser* b)
1298ee54 414{
415 //
416 // Browse this object in the browser
417 //
418 // Parameters:
419 // b
420 //
421 b->Add(&fRingArray);
9b5cc785 422 if (fCache) b->Add(fCache);
1298ee54 423 b->Add(&fVertexAxis);
424}
425//____________________________________________________________________
426void
8973b4ed 427AliFMDCorrAcceptance::Print(Option_t* option) const
1298ee54 428{
429 //
430 // Print this object
431 //
432 // Parameters:
433 // option
434 //
8973b4ed 435 std::cout << "Acceptance correction due to dead channels" << std::endl;
1298ee54 436 fRingArray.Print(option);
437 fVertexAxis.Print(option);
438}
439
440//____________________________________________________________________
441//
442// EOF
443//