AliPhysics  a56b849 (a56b849)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliFMDCorrMergingEfficiency.cxx
Go to the documentation of this file.
1 //
2 // This class contains the secondary correction and the double hit
3 // correction used in low-flux events.
4 //
6 #include <TBrowser.h>
7 #include <TH1D.h>
8 #include <AliLog.h>
9 #include <iostream>
10 
11 //____________________________________________________________________
13  : fRingArray(),
14  fVertexAxis(0,0,0)
15 {
16  //
17  // Default constructor
18  //
19  fRingArray.SetOwner(kTRUE);
20  fRingArray.SetName("rings");
21  fVertexAxis.SetName("vtxAxis");
22  fVertexAxis.SetTitle("v_{z} [cm]");
23 
24 }
25 //____________________________________________________________________
28  : TObject(o),
29  fRingArray(o.fRingArray),
30  fVertexAxis(o.fVertexAxis.GetNbins(), o.fVertexAxis.GetXmin(),
31  o.fVertexAxis.GetXmax())
32 {
33  //
34  // Copy constructor
35  //
36  // Parameters:
37  // o Object to copy from
38  //
39  fVertexAxis.SetName("vtxAxis");
40  fVertexAxis.SetTitle("v_{z} [cm]");
41 }
42 //____________________________________________________________________
44 {
45  //
46  // Destructor
47  //
48  //
49  fRingArray.Clear();
50 }
51 //____________________________________________________________________
54 {
55  //
56  // Assignment operator
57  //
58  // Parameters:
59  // o Object to assign from
60  //
61  // Return:
62  // Reference to this object
63  //
66 
67  return *this;
68 }
69 //____________________________________________________________________
70 TH1D*
72 {
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  //
84  Int_t b = FindVertexBin(v);
85  if (b <= 0) return 0;
86  return GetCorrection(d, r, UShort_t(b));
87 }
88 //____________________________________________________________________
89 TH1D*
91 {
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  //
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 //____________________________________________________________________
123 Int_t
125 {
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  //
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 //____________________________________________________________________
149 Int_t
151 {
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  //
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 //____________________________________________________________________
171 TObjArray*
173 {
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  //
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 //____________________________________________________________________
196 TObjArray*
198 {
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  //
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 //____________________________________________________________________
225 Bool_t
227  UShort_t b, TH1D* h)
228 {
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  //
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 //____________________________________________________________________
265 Bool_t
267  Double_t v, TH1D* h)
268 {
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  //
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 //____________________________________________________________________
291 void
293 {
294  //
295  // Browse this object in the browser
296  //
297  // Parameters:
298  // b
299  //
300  b->Add(&fRingArray);
301  b->Add(&fVertexAxis);
302 }
303 //____________________________________________________________________
304 void
306 {
307  //
308  // Print this object
309  //
310  // Parameters:
311  // option
312  //
313  std::cout << "Merging efficiency correction" << std::endl;
314  fRingArray.Print(option);
315  fVertexAxis.Print(option);
316 }
317 
318 //____________________________________________________________________
319 //
320 // EOF
321 //
double Double_t
Definition: External.C:58
Bool_t SetCorrection(UShort_t d, Char_t r, Double_t v, TH1D *h)
char Char_t
Definition: External.C:18
TH1D * GetCorrection(UShort_t d, Char_t r, Double_t v) const
int Int_t
Definition: External.C:63
Int_t GetRingIndex(UShort_t d, Char_t r) const
Definition: External.C:212
TObjArray * GetOrMakeRingArray(UShort_t d, Char_t r)
TObjArray * GetRingArray(UShort_t d, Char_t r) const
AliFMDCorrMergingEfficiency & operator=(const AliFMDCorrMergingEfficiency &o)
unsigned short UShort_t
Definition: External.C:28
void Print(Option_t *option="R") const
const char Option_t
Definition: External.C:48
Int_t FindVertexBin(Double_t vertex) const
bool Bool_t
Definition: External.C:53