2 // This class contains the secondary correction and the double hit
3 // correction used in low-flux events.
5 #include "AliFMDCorrVertexBias.h"
11 //____________________________________________________________________
12 AliFMDCorrVertexBias::AliFMDCorrVertexBias()
17 // Default constructor
19 fVertexArray.SetOwner(kTRUE);
20 fVertexArray.SetName("rings");
21 fVertexAxis.SetName("vtxAxis");
22 fVertexAxis.SetTitle("v_{z} [cm]");
25 //____________________________________________________________________
26 AliFMDCorrVertexBias::AliFMDCorrVertexBias(const AliFMDCorrVertexBias& o)
28 fVertexArray(o.fVertexArray),
29 fVertexAxis(o.fVertexAxis.GetNbins(), o.fVertexAxis.GetXmin(),
30 o.fVertexAxis.GetXmax())
36 // o Object to copy from
38 fVertexAxis.SetName("vtxAxis");
39 fVertexAxis.SetTitle("v_{z} [cm]");
41 //____________________________________________________________________
42 AliFMDCorrVertexBias::~AliFMDCorrVertexBias()
50 //____________________________________________________________________
52 AliFMDCorrVertexBias::operator=(const AliFMDCorrVertexBias& o)
55 // Assignment operator
58 // o Object to assign from
61 // Reference to this object
63 fVertexArray = o.fVertexArray;
64 SetVertexAxis(o.fVertexAxis);
68 //____________________________________________________________________
70 AliFMDCorrVertexBias::GetCorrection(Char_t r, Double_t v) const
73 // Get the vertex bias correction @f$ b_{v}@f$
76 // r Ring type (I or O)
77 // v Primary interaction point @f$z@f$ coordinate
80 // The correction @f$ b_{v}@f$
82 Int_t b = FindVertexBin(v);
84 return GetCorrection(r, UShort_t(b));
86 //____________________________________________________________________
88 AliFMDCorrVertexBias::GetCorrection(Char_t r, UShort_t b) const
91 // Get the vertex bias correction @f$ b_{v}@f$
94 // r Ring type (I or O)
95 // b Bin corresponding to the primary interaction point
96 // @f$z@f$ coordinate (1 based)
99 // The correction @f$ b_{v}@f$
101 TObjArray* vertexarray = GetVertexArray(b);
102 if (!vertexarray) return 0;
106 case 'i': case 'I': idx = 0; break;
107 case 'o': case 'O': idx = 1; break;
110 AliWarning(Form("Unknown ting type %c, not one of [iIoO]", r));
114 TObject* o = vertexarray->At(idx);
116 AliWarning(Form("No vertex bias found for ring type %c in vertex bin %d",
120 return static_cast<TH2D*>(o);
123 //____________________________________________________________________
125 AliFMDCorrVertexBias::FindVertexBin(Double_t v) const
128 // Find the vertex bin that corresponds to the passed vertex
131 // vertex The interaction points @f$z@f$-coordinate
134 // Vertex bin in @f$[1,N_{\mbox{vertex}}]@f$ or negative if
137 if (fVertexAxis.GetNbins() <= 0) {
138 AliWarning("No vertex array defined");
141 Int_t bin = const_cast<TAxis&>(fVertexAxis).FindBin(v);
142 if (bin <= 0 || bin > fVertexAxis.GetNbins()) {
143 AliWarning(Form("vertex %+8.4f out of range [%+8.4f,%+8.4f]",
144 v, fVertexAxis.GetXmin(), fVertexAxis.GetXmax()));
149 //____________________________________________________________________
151 AliFMDCorrVertexBias::GetVertexArray(UShort_t v) const
154 // Get the vertex array corresponding to the specified ring
157 // v vertex bin (1 based)
160 // Pointer to vertex array, or null in case of problems
162 if (v <= 0 || v > fVertexAxis.GetNbins()) {
163 AliWarning(Form("vertex bin %d out of range [1,%d]",
164 v, fVertexAxis.GetNbins()));
168 TObject* o = fVertexArray.At(v-1);
170 AliWarning(Form("No array found for vertex bin %d", v));
174 return static_cast<TObjArray*>(o);
176 //____________________________________________________________________
178 AliFMDCorrVertexBias::GetOrMakeVertexArray(UShort_t v)
181 // Get the vertex array corresponding to the specified ring
184 // v vertex bin (1 based)
187 // Pointer to vertex array, or newly created container
189 if (v <= 0 || v > fVertexAxis.GetNbins()) {
190 AliWarning(Form("vertex bin %d out of range [1,%d]",
191 v, fVertexAxis.GetNbins()));
195 TObject* o = fVertexArray.At(v-1);
197 TObjArray* a = new TObjArray(fVertexAxis.GetNbins());
198 a->SetName(Form("vertexbin%02d", v));
200 fVertexArray.AddAtAndExpand(a, v-1);
204 return static_cast<TObjArray*>(fVertexArray.At(v-1));
207 //____________________________________________________________________
209 AliFMDCorrVertexBias::SetCorrection(Char_t r, UShort_t b, TH2D* h)
212 // Set the vertex bias correction @f$ b_{v}(\eta,\varphi)@f$
213 // Note, that the object takes ownership of the passed pointer.
216 // r Ring type (I or O)
217 // b Bin corresponding to the primary interaction point
218 // @f$z@f$ coordinate (1 based)
219 // h @f$ b_{v}(\eta,\varphi)@f$
222 // true if operation succeeded
224 TObjArray* vertexarray = GetOrMakeVertexArray(b);
225 if (!vertexarray) return false;
230 case 'i': case 'I': idx = 0; break;
231 case 'o': case 'O': idx = 1; break;
234 AliWarning(Form("Unknown ting type %c, not one of [iIoO]", r));
237 h->SetName(Form("FMDX%c", r));
238 h->SetTitle(Form("Vertex bias correction for %c rings "
239 "in vertex bin %d [%+8.4f,%+8.4f]",
240 r, b, fVertexAxis.GetBinLowEdge(b),
241 fVertexAxis.GetBinUpEdge(b)));
242 h->SetXTitle("#eta");
243 h->SetYTitle("#phi [radians]");
244 h->SetZTitle("1/N_{t}#sum_{i}^{N_{tv}} N_{ch,i,primary} / "
245 "1/N_{v}#sum_{i}^{N_{v}} N_{ch,i,primary}");
249 vertexarray->AddAtAndExpand(h, idx);
252 //____________________________________________________________________
254 AliFMDCorrVertexBias::SetCorrection(Char_t r, Double_t v, TH2D* h)
257 // Set the vertex bias correction @f$ b_{v}(\eta,\varphi)@f$.
258 // Note, that the object takes ownership of the passed pointer.
261 // r Ring type (I or O)
262 // v Primary interaction point @f$z@f$ coordinate
263 // h @f$ b_{v}(\eta,\varphi)@f$
266 // true if operation succeeded
268 Int_t b = FindVertexBin(v);
269 if (b <= 0 || b > fVertexAxis.GetNbins()) {
270 AliWarning(Form("Vertex %+8.4f out of range [%+8.4f,%+8.4f]",
271 v, fVertexAxis.GetXmin(), fVertexAxis.GetXmax()));
274 return SetCorrection(r, UShort_t(b), h);
276 //____________________________________________________________________
278 AliFMDCorrVertexBias::Browse(TBrowser* b)
281 // Browse this object in the browser
286 b->Add(&fVertexArray);
287 b->Add(&fVertexAxis);
289 //____________________________________________________________________
291 AliFMDCorrVertexBias::Print(Option_t* option) const
299 std::cout << "Vertex bias correction" << std::endl;
300 fVertexArray.Print(option);
301 fVertexAxis.Print(option);
304 //____________________________________________________________________