2 // This class contains the acceptance correction due to dead channels
5 #include "AliFMDCorrAcceptance.h"
11 //____________________________________________________________________
12 AliFMDCorrAcceptance::AliFMDCorrAcceptance()
19 // Default constructor
21 fRingArray.SetOwner(kTRUE);
22 fRingArray.SetName("rings");
23 fVertexAxis.SetName("vtxAxis");
24 fVertexAxis.SetTitle("v_{z} [cm]");
27 //____________________________________________________________________
28 AliFMDCorrAcceptance::AliFMDCorrAcceptance(const
29 AliFMDCorrAcceptance& o)
31 fRingArray(o.fRingArray),
33 fVertexAxis(o.fVertexAxis.GetNbins(), o.fVertexAxis.GetXmin(),
34 o.fVertexAxis.GetXmax()),
35 fHasOverflow(o.fHasOverflow)
41 // o Object to copy from
43 fVertexAxis.SetName("vtxAxis");
44 fVertexAxis.SetTitle("v_{z} [cm]");
46 //____________________________________________________________________
47 AliFMDCorrAcceptance::~AliFMDCorrAcceptance()
54 if (fCache) fCache->Clear();
56 //____________________________________________________________________
58 AliFMDCorrAcceptance::operator=(const AliFMDCorrAcceptance& o)
61 // Assignment operator
64 // o Object to assign from
67 // Reference to this object
69 fRingArray = o.fRingArray;
71 fHasOverflow = o.fHasOverflow;
72 SetVertexAxis(o.fVertexAxis);
76 //____________________________________________________________________
78 AliFMDCorrAcceptance::GetCorrection(UShort_t d, Char_t r, Double_t v) const
81 // Get the acceptance correction @f$ a_{r,v}@f$
84 // d Detector number (1-3)
85 // r Ring identifier (I or O)
86 // v Primary interaction point @f$z@f$ coordinate
89 // The correction @f$ a_{r,v}@f$
91 Int_t b = FindVertexBin(v);
93 return GetCorrection(d, r, UShort_t(b));
95 //____________________________________________________________________
97 AliFMDCorrAcceptance::GetCorrection(UShort_t d, Char_t r, UShort_t b) const
100 // Get the acceptance correction @f$ a_{r,v}@f$
103 // d Detector number (1-3)
104 // r Ring identifier (I or O)
105 // b Bin corresponding to the primary interaction point
106 // @f$z@f$ coordinate (1 based)
109 // The correction @f$ a_{r,v}@f$
111 return static_cast<TH2D*>(GetObject(fRingArray, d, r, b));
113 //____________________________________________________________________
115 AliFMDCorrAcceptance::GetPhiAcceptance(UShort_t d, Char_t r, Double_t v) const
118 // Get the acceptance correction @f$ a_{r,v}@f$
121 // d Detector number (1-3)
122 // r Ring identifier (I or O)
123 // v Primary interaction point @f$z@f$ coordinate
126 // The correction @f$ a_{r,v}@f$
128 Int_t b = FindVertexBin(v);
129 if (b <= 0) return 0;
130 return GetPhiAcceptance(d, r, UShort_t(b));
132 //____________________________________________________________________
134 AliFMDCorrAcceptance::GetPhiAcceptance(UShort_t d, Char_t r, UShort_t b) const
137 // Get the acceptance correction @f$ a_{r,v}@f$
140 // d Detector number (1-3)
141 // r Ring identifier (I or O)
142 // b Bin corresponding to the primary interaction point
143 // @f$z@f$ coordinate (1 based)
146 // The correction @f$ a_{r,v}@f$
148 if (!fHasOverflow) return 0;
149 if (!fCache) FillCache();
150 return static_cast<TH1D*>(GetObject(*fCache, d, r, b));
153 //____________________________________________________________________
155 AliFMDCorrAcceptance::FindVertexBin(Double_t v) const
158 // Find the vertex bin that corresponds to the passed vertex
161 // vertex The interaction points @f$z@f$-coordinate
164 // Vertex bin in @f$[1,N_{\mbox{vertex}}]@f$ or negative if
167 if (fVertexAxis.GetNbins() <= 0) {
168 AliWarning("No vertex array defined");
171 Int_t bin = const_cast<TAxis&>(fVertexAxis).FindBin(v);
172 if (bin <= 0 || bin > fVertexAxis.GetNbins()) {
173 AliWarning(Form("vertex %+8.4f out of range [%+8.4f,%+8.4f]",
174 v, fVertexAxis.GetXmin(), fVertexAxis.GetXmax()));
179 //____________________________________________________________________
181 AliFMDCorrAcceptance::GetRingIndex(UShort_t d, Char_t r) const
183 // Get the index corresponding to the given ring
190 // Index (0 based) or negative in case of errors
194 case 2: return (r == 'I' || r == 'i' ? 1 : 2); break;
195 case 3: return (r == 'I' || r == 'i' ? 3 : 4); break;
198 AliWarning(Form("Index for FMD%d%c not found", d, r));
201 //____________________________________________________________________
203 AliFMDCorrAcceptance::GetObject(const TObjArray& m, UShort_t d,
204 Char_t r, UShort_t b) const
207 // Get the object @f$ a_{r,v}@f$
211 // d Detector number (1-3)
212 // r Ring identifier (I or O)
213 // b Bin corresponding to the primary interaction point
214 // @f$z@f$ coordinate (1 based)
217 // The correction @f$ a_{r,v}@f$
219 TObjArray* ringArray = GetRingArray(m, d, r);
220 if (!ringArray) return 0;
222 if (b <= 0 || b > ringArray->GetEntriesFast()) {
223 AliWarning(Form("vertex bin %d out of range [1,%d]",
224 b, ringArray->GetEntriesFast()));
228 TObject* o = ringArray->At(b-1);
231 AliWarning(Form("No dead channels map found for FMD%d%c in vertex bin %d",
235 //____________________________________________________________________
237 AliFMDCorrAcceptance::GetRingArray(const TObjArray& m,
238 UShort_t d, Char_t r) const
241 // Get the ring array corresponding to the specified ring
248 // Pointer to ring array, or null in case of problems
250 Int_t idx = GetRingIndex(d,r);
251 if (idx < 0) return 0;
253 TObject* o = m.At(idx);
255 AliWarning(Form("No array found for FMD%d%c", d, r));
259 return static_cast<TObjArray*>(o);
261 //____________________________________________________________________
263 AliFMDCorrAcceptance::GetOrMakeRingArray(TObjArray& m,
264 UShort_t d, Char_t r) const
267 // Get the ring array corresponding to the specified ring
274 // Pointer to ring array, or newly created container
276 Int_t idx = GetRingIndex(d,r);
277 if (idx < 0) return 0;
279 TObject* o = m.At(idx);
281 TObjArray* a = new TObjArray(fVertexAxis.GetNbins());
282 a->SetName(Form("FMD%d%c", d, r));
284 m.AddAtAndExpand(a, idx);
288 return static_cast<TObjArray*>(m.At(idx));
291 //____________________________________________________________________
293 AliFMDCorrAcceptance::SetCorrection(UShort_t d, Char_t r,
297 // Set the acceptance correction @f$ a_{r,v}(\eta)@f$
298 // Note, that the object takes ownership of the passed pointer.
301 // d Detector number (1-3)
302 // r Ring identifier (I or O)
303 // b Bin corresponding to the primary interaction point
304 // @f$z@f$ coordinate (1 based)
305 // h @f$ a_{r,v}(\eta)@f$
308 // true if operation succeeded
310 TObjArray* ringArray = GetOrMakeRingArray(fRingArray, d, r);
311 if (!ringArray) return false;
313 if (b <= 0 || b > fVertexAxis.GetNbins()) {
314 AliWarning(Form("Vertex bin %3d out of range [1,%3d]",
315 b, fVertexAxis.GetNbins()));
318 h->SetName(Form("FMD%d%c_vtxbin%03d", d, r, b));
319 h->SetTitle(Form("Acceptance correction for FMD%d%c "
320 "in vertex bin %d [%+8.4f,%+8.4f]",
321 d, r, b, fVertexAxis.GetBinLowEdge(b),
322 fVertexAxis.GetBinUpEdge(b)));
323 h->SetXTitle("#eta");
324 h->SetYTitle("N_{strips,OK}/N_{strips}");
325 h->SetFillStyle(3001);
328 ringArray->AddAtAndExpand(h, b-1);
331 //____________________________________________________________________
333 AliFMDCorrAcceptance::SetCorrection(UShort_t d, Char_t r,
337 // Set the acceptance correction @f$ a_{r,v}(\eta)@f$.
338 // Note, that the object takes ownership of the passed pointer.
341 // d Detector number (1-3)
342 // r Ring identifier (I or O)
343 // v Primary interaction point @f$z@f$ coordinate
344 // h @f$ a_{r,v}(\eta)@f$
347 // true if operation succeeded
349 Int_t b = FindVertexBin(v);
350 if (b <= 0 || b > fVertexAxis.GetNbins()) {
351 AliWarning(Form("Vertex %+8.4f out of range [%+8.4f,%+8.4f]",
352 v, fVertexAxis.GetXmin(), fVertexAxis.GetXmax()));
355 return SetCorrection(d, r, UShort_t(b), h);
358 //____________________________________________________________________
360 AliFMDCorrAcceptance::FillCache() const
364 fCache = new TObjArray;
365 fCache->SetOwner(kTRUE);
366 fCache->SetName("cache");
368 Int_t nV = fVertexAxis.GetNbins();
369 for (UShort_t v = 1; v <= nV; v++) {
370 for(UShort_t d = 1; d <= 3;d++) {
371 UShort_t nR = (d == 1 ? 1 : 2);
372 for (UShort_t q = 0; q < nR; q++) {
373 Char_t r = (q == 0 ? 'I' : 'O');
375 TObjArray* a = GetOrMakeRingArray(*fCache, d, r);
377 TH2D* corr = GetCorrection(d, r, v);
380 Int_t nY = corr->GetNbinsY();
381 TH1D* h = corr->ProjectionX("tmp", nY+1, nY+1, "");
382 h->SetName(Form("FMD%d%c_vtxbin%03d", d, r, v));
383 h->SetTitle(Form("#phi acceptance correction for FMD%d%c "
384 "in vertex bin %d [%+8.4f,%+8.4f]",
385 d, r, v, fVertexAxis.GetBinLowEdge(v),
386 fVertexAxis.GetBinUpEdge(v)));
387 h->SetXTitle("#eta");
388 h->SetYTitle("N_{strips}/N_{strips,OK}");
389 h->SetFillStyle(3001);
392 a->AddAtAndExpand(h,v-1);
394 if (fHasOverflow) continue;
396 // Construct the overflow bin from
397 Int_t nX = corr->GetNbinsX();
398 for (Int_t eta = 1; eta <= nX; eta++) {
400 for (Int_t phi = 1; phi <= nY; phi++)
401 sum += corr->GetBinContent(eta, phi);
402 if (nY <= 0) continue;
403 h->SetBinContent(eta, nY/sum);
409 //____________________________________________________________________
411 AliFMDCorrAcceptance::Browse(TBrowser* b)
414 // Browse this object in the browser
420 if (fCache) b->Add(fCache);
421 b->Add(&fVertexAxis);
423 //____________________________________________________________________
425 AliFMDCorrAcceptance::Print(Option_t* option) const
433 std::cout << "Acceptance correction due to dead channels" << std::endl;
434 fRingArray.Print(option);
435 fVertexAxis.Print(option);
438 //____________________________________________________________________