2 // This class contains the secondary correction and the double hit
3 // correction used in low-flux events.
5 #include "AliFMDCorrSecondaryMap.h"
11 //____________________________________________________________________
12 AliFMDCorrSecondaryMap::AliFMDCorrSecondaryMap()
18 // Default constructor
20 fRingArray.SetOwner(kTRUE);
21 fRingArray.SetName("rings");
22 fVertexAxis.SetName("vertexAxis");
23 fVertexAxis.SetTitle("v_{z} [cm]");
24 fEtaAxis.SetName("etaAxis");
25 fEtaAxis.SetTitle("#eta");
28 //____________________________________________________________________
29 AliFMDCorrSecondaryMap::AliFMDCorrSecondaryMap(const
30 AliFMDCorrSecondaryMap& o)
32 fRingArray(o.fRingArray),
33 fVertexAxis(o.fVertexAxis.GetNbins(), o.fVertexAxis.GetXmin(),
34 o.fVertexAxis.GetXmax()),
35 fEtaAxis(o.fEtaAxis.GetNbins(), o.fEtaAxis.GetXmin(),
42 // o Object to copy from
44 fVertexAxis.SetName("vertexAxis");
45 fVertexAxis.SetTitle("v_{z} [cm]");
46 fEtaAxis.SetName("etaAxis");
47 fEtaAxis.SetTitle("v_{z} [cm]");
49 //____________________________________________________________________
50 AliFMDCorrSecondaryMap::~AliFMDCorrSecondaryMap()
58 //____________________________________________________________________
59 AliFMDCorrSecondaryMap&
60 AliFMDCorrSecondaryMap::operator=(const AliFMDCorrSecondaryMap& o)
63 // Assignment operator
66 // o Object to assign from
69 // Reference to this object
71 fRingArray = o.fRingArray;
72 SetVertexAxis(o.fVertexAxis);
73 SetEtaAxis(o.fEtaAxis);
77 //____________________________________________________________________
79 AliFMDCorrSecondaryMap::GetCorrection(UShort_t d, Char_t r, Double_t v) const
82 // Get the secondary correction @f$ c_{r,v}@f$
85 // d Detector number (1-3)
86 // r Ring identifier (I or O)
87 // v Primary interaction point @f$z@f$ coordinate
90 // The correction @f$ c_{r,v}@f$
92 Int_t b = FindVertexBin(v);
94 return GetCorrection(d, r, UShort_t(b));
96 //____________________________________________________________________
98 AliFMDCorrSecondaryMap::GetCorrection(UShort_t d, Char_t r, UShort_t b) const
101 // Get the secondary correction @f$ c_{r,v}@f$
104 // d Detector number (1-3)
105 // r Ring identifier (I or O)
106 // b Bin corresponding to the primary interaction point
107 // @f$z@f$ coordinate (1 based)
110 // The correction @f$ c_{r,v}@f$
112 TObjArray* ringArray = GetRingArray(d, r);
113 if (!ringArray) return 0;
115 if (b <= 0 || b > ringArray->GetEntriesFast()) {
116 AliWarning(Form("vertex bin %d out of range [1,%d]",
117 b, ringArray->GetEntriesFast()));
121 TObject* o = ringArray->At(b-1);
123 AliWarning(Form("No secondary map found for FMD%d%c in vertex bin %d",
127 return static_cast<TH2D*>(o);
130 //____________________________________________________________________
132 AliFMDCorrSecondaryMap::FindVertexBin(Double_t v) const
135 // Find the vertex bin that corresponds to the passed vertex
138 // vertex The interaction points @f$z@f$-coordinate
141 // Vertex bin in @f$[1,N_{\mbox{vertex}}]@f$ or negative if
144 if (fVertexAxis.GetNbins() <= 0) {
145 AliWarning("No vertex array defined");
148 Int_t bin = const_cast<TAxis&>(fVertexAxis).FindBin(v);
149 if (bin <= 0 || bin > fVertexAxis.GetNbins()) {
150 AliWarning(Form("vertex %+8.4f out of range [%+8.4f,%+8.4f]",
151 v, fVertexAxis.GetXmin(), fVertexAxis.GetXmax()));
156 //____________________________________________________________________
158 AliFMDCorrSecondaryMap::GetRingIndex(UShort_t d, Char_t r) const
161 // Get the index corresponding to the given ring
168 // Index (0 based) or negative in case of errors
172 case 2: return (r == 'I' || r == 'i' ? 1 : 2); break;
173 case 3: return (r == 'I' || r == 'i' ? 3 : 4); break;
175 AliWarning(Form("Index for FMD%d%c not found", d, r));
178 //____________________________________________________________________
180 AliFMDCorrSecondaryMap::GetRingArray(UShort_t d, Char_t r) const
183 // Get the ring array corresponding to the specified ring
190 // Pointer to ring array, or null in case of problems
192 Int_t idx = GetRingIndex(d,r);
193 if (idx < 0) return 0;
195 TObject* o = fRingArray.At(idx);
197 AliWarning(Form("No array found for FMD%d%c", d, r));
201 return static_cast<TObjArray*>(o);
203 //____________________________________________________________________
205 AliFMDCorrSecondaryMap::GetOrMakeRingArray(UShort_t d, Char_t r)
208 // Get the ring array corresponding to the specified ring
215 // Pointer to ring array, or newly created container
217 Int_t idx = GetRingIndex(d,r);
218 if (idx < 0) return 0;
220 TObject* o = fRingArray.At(idx);
222 TObjArray* a = new TObjArray(fVertexAxis.GetNbins());
223 a->SetName(Form("FMD%d%c", d, r));
225 fRingArray.AddAtAndExpand(a, idx);
229 return static_cast<TObjArray*>(fRingArray.At(idx));
232 //____________________________________________________________________
234 AliFMDCorrSecondaryMap::SetCorrection(UShort_t d, Char_t r,
238 // Set the secondary map correction @f$ c_{r,v}(\eta,\varphi)@f$
239 // Note, that the object takes ownership of the passed pointer.
242 // d Detector number (1-3)
243 // r Ring identifier (I or O)
244 // b Bin corresponding to the primary interaction point
245 // @f$z@f$ coordinate (1 based)
246 // h @f$ c_{r,v}(\eta,\varphi)@f$
249 // true if operation succeeded
251 TObjArray* ringArray = GetOrMakeRingArray(d, r);
252 if (!ringArray) return false;
254 if (b <= 0 || b > fVertexAxis.GetNbins()) {
255 AliWarning(Form("Vertex bin %3d out of range [1,%3d]",
256 b, fVertexAxis.GetNbins()));
259 h->SetName(Form("FMD%d%c_vtxbin%03d", d, r, b));
260 h->SetTitle(Form("Secondary map correction for FMD%d%c "
261 "in vertex bin %d [%+8.4f,%+8.4f]",
262 d, r, b, fVertexAxis.GetBinLowEdge(b),
263 fVertexAxis.GetBinUpEdge(b)));
264 h->SetXTitle("#eta");
265 h->SetYTitle("#phi [radians]");
266 h->SetZTitle("#sum_{i} N_{ch,i,primary} / #sum_{i} N_{ch,i,FMD}");
269 ringArray->AddAtAndExpand(h, b-1);
272 //____________________________________________________________________
274 AliFMDCorrSecondaryMap::SetCorrection(UShort_t d, Char_t r,
278 // Set the secondary map correction @f$ c_{r,v}(\eta,\varphi)@f$.
279 // Note, that the object takes ownership of the passed pointer.
282 // d Detector number (1-3)
283 // r Ring identifier (I or O)
284 // v Primary interaction point @f$z@f$ coordinate
285 // h @f$ c_{r,v}(\eta,\varphi)@f$
288 // true if operation succeeded
290 Int_t b = FindVertexBin(v);
291 if (b <= 0 || b > fVertexAxis.GetNbins()) {
292 AliWarning(Form("Vertex %+8.4f out of range [%+8.4f,%+8.4f]",
293 v, fVertexAxis.GetXmin(), fVertexAxis.GetXmax()));
296 return SetCorrection(d, r, UShort_t(b), h);
298 //____________________________________________________________________
300 AliFMDCorrSecondaryMap::Browse(TBrowser* b)
303 // Browse this object in the browser
309 b->Add(&fVertexAxis);
312 //____________________________________________________________________
314 AliFMDCorrSecondaryMap::Print(Option_t* option) const
322 std::cout << "Secondary correction map" << std::endl;
323 fRingArray.Print(option);
324 fVertexAxis.Print(option);
325 fEtaAxis.Print(option);
328 //____________________________________________________________________