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