]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG2/FORWARD/analysis2/AliFMDCorrMergingEfficiency.cxx
Fixes for AliForwardCorrectionManager persistency
[u/mrichter/AliRoot.git] / PWG2 / FORWARD / analysis2 / AliFMDCorrMergingEfficiency.cxx
CommitLineData
7984e5f7 1//
2// This class contains the secondary correction and the double hit
3// correction used in low-flux events.
4//
0bd4b00f 5#include "AliFMDCorrMergingEfficiency.h"
6#include <TBrowser.h>
7#include <TH1D.h>
8#include <AliLog.h>
9#include <iostream>
10
11//____________________________________________________________________
12AliFMDCorrMergingEfficiency::AliFMDCorrMergingEfficiency()
13 : fRingArray(),
14 fVertexAxis(0,0,0)
15{
7984e5f7 16 //
17 // Default constructor
18 //
0bd4b00f 19 fRingArray.SetOwner(kTRUE);
20 fRingArray.SetName("rings");
21 fVertexAxis.SetName("vtxAxis");
22 fVertexAxis.SetTitle("v_{z} [cm]");
23
24}
25//____________________________________________________________________
26AliFMDCorrMergingEfficiency::AliFMDCorrMergingEfficiency(const
27 AliFMDCorrMergingEfficiency& o)
28 : TObject(o),
29 fRingArray(o.fRingArray),
30 fVertexAxis(o.fVertexAxis.GetNbins(), o.fVertexAxis.GetXmin(),
31 o.fVertexAxis.GetXmax())
32{
7984e5f7 33 //
34 // Copy constructor
35 //
36 // Parameters:
37 // o Object to copy from
38 //
0bd4b00f 39 fVertexAxis.SetName("vtxAxis");
40 fVertexAxis.SetTitle("v_{z} [cm]");
41}
42//____________________________________________________________________
43AliFMDCorrMergingEfficiency::~AliFMDCorrMergingEfficiency()
44{
7984e5f7 45 //
46 // Destructor
47 //
48 //
0bd4b00f 49 fRingArray.Clear();
50}
51//____________________________________________________________________
52AliFMDCorrMergingEfficiency&
53AliFMDCorrMergingEfficiency::operator=(const AliFMDCorrMergingEfficiency& o)
54{
7984e5f7 55 //
56 // Assignment operator
57 //
58 // Parameters:
59 // o Object to assign from
60 //
61 // Return:
62 // Reference to this object
63 //
0bd4b00f 64 fRingArray = o.fRingArray;
65 SetVertexAxis(o.fVertexAxis);
66
67 return *this;
68}
69//____________________________________________________________________
70TH1D*
71AliFMDCorrMergingEfficiency::GetCorrection(UShort_t d, Char_t r, Double_t v) const
72{
7984e5f7 73 //
74 // Get the secondary correction @f$ c_{r,v}@f$
75 //
76 // Parameters:
77 // d Detector number (1-3)
78 // r Ring identifier (I or O)
79 // v Primary interaction point @f$z@f$ coordinate
80 //
81 // Return:
82 // The correction @f$ c_{r,v}@f$
83 //
0bd4b00f 84 Int_t b = FindVertexBin(v);
85 if (b <= 0) return 0;
86 return GetCorrection(d, r, UShort_t(b));
87}
88//____________________________________________________________________
89TH1D*
90AliFMDCorrMergingEfficiency::GetCorrection(UShort_t d, Char_t r, UShort_t b) const
91{
7984e5f7 92 //
93 // Get the secondary correction @f$ c_{r,v}@f$
94 //
95 // Parameters:
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)
100 //
101 // Return:
102 // The correction @f$ c_{r,v}@f$
103 //
0bd4b00f 104 TObjArray* ringArray = GetRingArray(d, r);
105 if (!ringArray) return 0;
106
107 if (b <= 0 || b > ringArray->GetEntriesFast()) {
108 AliWarning(Form("vertex bin %d out of range [1,%d]",
109 b, ringArray->GetEntriesFast()));
110 return 0;
111 }
112
113 TObject* o = ringArray->At(b-1);
114 if (!o) {
115 AliWarning(Form("No secondary map found for FMD%d%c in vertex bin %d",
116 d,r,b));
117 return 0;
118 }
119 return static_cast<TH1D*>(o);
120}
121
122//____________________________________________________________________
123Int_t
124AliFMDCorrMergingEfficiency::FindVertexBin(Double_t v) const
125{
7984e5f7 126 //
127 // Find the vertex bin that corresponds to the passed vertex
128 //
129 // Parameters:
130 // vertex The interaction points @f$z@f$-coordinate
131 //
132 // Return:
133 // Vertex bin in @f$[1,N_{\mbox{vertex}}]@f$ or negative if
134 // out of range
135 //
0bd4b00f 136 if (fVertexAxis.GetNbins() <= 0) {
137 AliWarning("No vertex array defined");
138 return 0;
139 }
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()));
144 return 0;
145 }
146 return bin;
147}
148//____________________________________________________________________
149Int_t
150AliFMDCorrMergingEfficiency::GetRingIndex(UShort_t d, Char_t r) const
151{
7984e5f7 152 //
153 // Get the index corresponding to the given ring
154 //
155 // Parameters:
156 // d Detector
157 // r Ring
158 //
159 // Return:
160 // Index (0 based) or negative in case of errors
161 //
0bd4b00f 162 switch (d) {
163 case 1: return 0;
164 case 2: return (r == 'I' || r == 'i' ? 1 : 2); break;
165 case 3: return (r == 'I' || r == 'i' ? 3 : 4); break;
166 }
167 AliWarning(Form("Index for FMD%d%c not found", d, r));
168 return -1;
169}
170//____________________________________________________________________
171TObjArray*
172AliFMDCorrMergingEfficiency::GetRingArray(UShort_t d, Char_t r) const
173{
7984e5f7 174 //
175 // Get the ring array corresponding to the specified ring
176 //
177 // Parameters:
178 // d Detector
179 // r Ring
180 //
181 // Return:
182 // Pointer to ring array, or null in case of problems
183 //
0bd4b00f 184 Int_t idx = GetRingIndex(d,r);
185 if (idx < 0) return 0;
186
187 TObject* o = fRingArray.At(idx);
188 if (!o) {
189 AliWarning(Form("No array found for FMD%d%c", d, r));
190 return 0;
191 }
192
193 return static_cast<TObjArray*>(o);
194}
195//____________________________________________________________________
196TObjArray*
197AliFMDCorrMergingEfficiency::GetOrMakeRingArray(UShort_t d, Char_t r)
198{
7984e5f7 199 //
200 // Get the ring array corresponding to the specified ring
201 //
202 // Parameters:
203 // d Detector
204 // r Ring
205 //
206 // Return:
207 // Pointer to ring array, or newly created container
208 //
0bd4b00f 209 Int_t idx = GetRingIndex(d,r);
210 if (idx < 0) return 0;
211
212 TObject* o = fRingArray.At(idx);
213 if (!o) {
214 TObjArray* a = new TObjArray(fVertexAxis.GetNbins());
215 a->SetName(Form("FMD%d%c", d, r));
216 a->SetOwner(kTRUE);
217 fRingArray.AddAtAndExpand(a, idx);
218 return a;
219 }
220
221 return static_cast<TObjArray*>(fRingArray.At(idx));
222}
223
224//____________________________________________________________________
225Bool_t
226AliFMDCorrMergingEfficiency::SetCorrection(UShort_t d, Char_t r,
227 UShort_t b, TH1D* h)
228{
7984e5f7 229 //
230 // Set the secondary map correction @f$ m_{r,v}(\eta)@f$
231 // Note, that the object takes ownership of the passed pointer.
232 //
233 // Parameters:
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$ m_{r,v}(\eta)@f$
239 //
240 // Return:
241 // true if operation succeeded
242 //
0bd4b00f 243 TObjArray* ringArray = GetOrMakeRingArray(d, r);
244 if (!ringArray) return false;
245
246 if (b <= 0 || b > fVertexAxis.GetNbins()) {
247 AliWarning(Form("Vertex bin %3d out of range [1,%3d]",
248 b, fVertexAxis.GetNbins()));
249 return false;
250 }
251 h->SetName(Form("FMD%d%c_vtxbin%03d", d, r, b));
252 h->SetTitle(Form("Secondary map 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);
259 h->SetDirectory(0);
260 h->SetStats(0);
261 ringArray->AddAtAndExpand(h, b-1);
262 return kTRUE;
263}
264//____________________________________________________________________
265Bool_t
266AliFMDCorrMergingEfficiency::SetCorrection(UShort_t d, Char_t r,
267 Double_t v, TH1D* h)
268{
7984e5f7 269 //
270 // Set the secondary map correction @f$ m_{r,v}(\eta)@f$.
271 // Note, that the object takes ownership of the passed pointer.
272 //
273 // Parameters:
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$ m_{r,v}(\eta)@f$
278 //
279 // Return:
280 // true if operation succeeded
281 //
0bd4b00f 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()));
286 return false;
287 }
288 return SetCorrection(d, r, UShort_t(b), h);
289}
290//____________________________________________________________________
291void
292AliFMDCorrMergingEfficiency::Browse(TBrowser* b)
293{
7984e5f7 294 //
295 // Browse this object in the browser
296 //
297 // Parameters:
298 // b
299 //
0bd4b00f 300 b->Add(&fRingArray);
301 b->Add(&fVertexAxis);
302}
303//____________________________________________________________________
304void
305AliFMDCorrMergingEfficiency::Print(Option_t* option) const
306{
7984e5f7 307 //
308 // Print this object
309 //
310 // Parameters:
311 // option
312 //
0bd4b00f 313 std::cout << "Merging efficiency correction" << std::endl;
314 fRingArray.Print(option);
315 fVertexAxis.Print(option);
316}
317
318//____________________________________________________________________
319//
320// EOF
321//