2 // This class contains the acceptance correction due to dead channels
5 #include "AliFMDCorrAcceptance.h"
11 //____________________________________________________________________
12 AliFMDCorrAcceptance::AliFMDCorrAcceptance()
17 // Default constructor
19 fRingArray.SetOwner(kTRUE);
20 fRingArray.SetName("rings");
21 fVertexAxis.SetName("vtxAxis");
22 fVertexAxis.SetTitle("v_{z} [cm]");
25 //____________________________________________________________________
26 AliFMDCorrAcceptance::AliFMDCorrAcceptance(const
27 AliFMDCorrAcceptance& o)
29 fRingArray(o.fRingArray),
30 fVertexAxis(o.fVertexAxis.GetNbins(), o.fVertexAxis.GetXmin(),
31 o.fVertexAxis.GetXmax())
37 // o Object to copy from
39 fVertexAxis.SetName("vtxAxis");
40 fVertexAxis.SetTitle("v_{z} [cm]");
42 //____________________________________________________________________
43 AliFMDCorrAcceptance::~AliFMDCorrAcceptance()
51 //____________________________________________________________________
53 AliFMDCorrAcceptance::operator=(const AliFMDCorrAcceptance& o)
56 // Assignment operator
59 // o Object to assign from
62 // Reference to this object
64 fRingArray = o.fRingArray;
65 SetVertexAxis(o.fVertexAxis);
69 //____________________________________________________________________
71 AliFMDCorrAcceptance::GetCorrection(UShort_t d, Char_t r, Double_t v) const
74 // Get the acceptance correction @f$ a_{r,v}@f$
77 // d Detector number (1-3)
78 // r Ring identifier (I or O)
79 // v Primary interaction point @f$z@f$ coordinate
82 // The correction @f$ a_{r,v}@f$
84 Int_t b = FindVertexBin(v);
86 return GetCorrection(d, r, UShort_t(b));
88 //____________________________________________________________________
90 AliFMDCorrAcceptance::GetCorrection(UShort_t d, Char_t r, UShort_t b) const
93 // Get the acceptance correction @f$ a_{r,v}@f$
96 // d Detector number (1-3)
97 // r Ring identifier (I or O)
98 // b Bin corresponding to the primary interaction point
99 // @f$z@f$ coordinate (1 based)
102 // The correction @f$ a_{r,v}@f$
104 TObjArray* ringArray = GetRingArray(d, r);
105 if (!ringArray) return 0;
107 if (b <= 0 || b > ringArray->GetEntriesFast()) {
108 AliWarning(Form("vertex bin %d out of range [1,%d]",
109 b, ringArray->GetEntriesFast()));
113 TObject* o = ringArray->At(b-1);
115 AliWarning(Form("No dead channels map found for FMD%d%c in vertex bin %d",
119 return static_cast<TH2D*>(o);
122 //____________________________________________________________________
124 AliFMDCorrAcceptance::FindVertexBin(Double_t v) const
127 // Find the vertex bin that corresponds to the passed vertex
130 // vertex The interaction points @f$z@f$-coordinate
133 // Vertex bin in @f$[1,N_{\mbox{vertex}}]@f$ or negative if
136 if (fVertexAxis.GetNbins() <= 0) {
137 AliWarning("No vertex array defined");
140 Int_t bin = const_cast<TAxis&>(fVertexAxis).FindBin(v);
141 if (bin <= 0 || bin > fVertexAxis.GetNbins()) {
142 AliWarning(Form("vertex %+8.4f out of range [%+8.4f,%+8.4f]",
143 v, fVertexAxis.GetXmin(), fVertexAxis.GetXmax()));
148 //____________________________________________________________________
150 AliFMDCorrAcceptance::GetRingIndex(UShort_t d, Char_t r) const
153 // Get the index corresponding to the given ring
160 // Index (0 based) or negative in case of errors
164 case 2: return (r == 'I' || r == 'i' ? 1 : 2); break;
165 case 3: return (r == 'I' || r == 'i' ? 3 : 4); break;
167 AliWarning(Form("Index for FMD%d%c not found", d, r));
170 //____________________________________________________________________
172 AliFMDCorrAcceptance::GetRingArray(UShort_t d, Char_t r) const
175 // Get the ring array corresponding to the specified ring
182 // Pointer to ring array, or null in case of problems
184 Int_t idx = GetRingIndex(d,r);
185 if (idx < 0) return 0;
187 TObject* o = fRingArray.At(idx);
189 AliWarning(Form("No array found for FMD%d%c", d, r));
193 return static_cast<TObjArray*>(o);
195 //____________________________________________________________________
197 AliFMDCorrAcceptance::GetOrMakeRingArray(UShort_t d, Char_t r)
200 // Get the ring array corresponding to the specified ring
207 // Pointer to ring array, or newly created container
209 Int_t idx = GetRingIndex(d,r);
210 if (idx < 0) return 0;
212 TObject* o = fRingArray.At(idx);
214 TObjArray* a = new TObjArray(fVertexAxis.GetNbins());
215 a->SetName(Form("FMD%d%c", d, r));
217 fRingArray.AddAtAndExpand(a, idx);
221 return static_cast<TObjArray*>(fRingArray.At(idx));
224 //____________________________________________________________________
226 AliFMDCorrAcceptance::SetCorrection(UShort_t d, Char_t r,
230 // Set the acceptance correction @f$ a_{r,v}(\eta)@f$
231 // Note, that the object takes ownership of the passed pointer.
234 // d Detector number (1-3)
235 // r Ring identifier (I or O)
236 // b Bin corresponding to the primary interaction point
237 // @f$z@f$ coordinate (1 based)
238 // h @f$ a_{r,v}(\eta)@f$
241 // true if operation succeeded
243 TObjArray* ringArray = GetOrMakeRingArray(d, r);
244 if (!ringArray) return false;
246 if (b <= 0 || b > fVertexAxis.GetNbins()) {
247 AliWarning(Form("Vertex bin %3d out of range [1,%3d]",
248 b, fVertexAxis.GetNbins()));
251 h->SetName(Form("FMD%d%c_vtxbin%03d", d, r, b));
252 h->SetTitle(Form("Acceptance correction for FMD%d%c "
253 "in vertex bin %d [%+8.4f,%+8.4f]",
254 d, r, b, fVertexAxis.GetBinLowEdge(b),
255 fVertexAxis.GetBinUpEdge(b)));
256 h->SetXTitle("#eta");
257 h->SetYTitle("dN_{ch}/d#eta / sum_i N_{ch,i}");
258 h->SetFillStyle(3001);
261 ringArray->AddAtAndExpand(h, b-1);
264 //____________________________________________________________________
266 AliFMDCorrAcceptance::SetCorrection(UShort_t d, Char_t r,
270 // Set the acceptance correction @f$ a_{r,v}(\eta)@f$.
271 // Note, that the object takes ownership of the passed pointer.
274 // d Detector number (1-3)
275 // r Ring identifier (I or O)
276 // v Primary interaction point @f$z@f$ coordinate
277 // h @f$ a_{r,v}(\eta)@f$
280 // true if operation succeeded
282 Int_t b = FindVertexBin(v);
283 if (b <= 0 || b > fVertexAxis.GetNbins()) {
284 AliWarning(Form("Vertex %+8.4f out of range [%+8.4f,%+8.4f]",
285 v, fVertexAxis.GetXmin(), fVertexAxis.GetXmax()));
288 return SetCorrection(d, r, UShort_t(b), h);
290 //____________________________________________________________________
292 AliFMDCorrAcceptance::Browse(TBrowser* b)
295 // Browse this object in the browser
301 b->Add(&fVertexAxis);
303 //____________________________________________________________________
305 AliFMDCorrAcceptance::Print(Option_t* option) const
313 std::cout << "Acceptance correction due to dead channels" << std::endl;
314 fRingArray.Print(option);
315 fVertexAxis.Print(option);
318 //____________________________________________________________________