2 @brief Implementation of an Axis in a Flow "histogram" */
3 #include "flow/AliFMDFlowAxis.h"
6 //====================================================================
7 AliFMDFlowAxis::AliFMDFlowAxis(UShort_t n, Double_t* bins)
11 fBins = new Double_t[fN+1];
12 for (UInt_t i = 0; i <= fN; i++) fBins[i] = bins[i];
14 //____________________________________________________________________
15 AliFMDFlowAxis::AliFMDFlowAxis(UShort_t n, Double_t min, Double_t max)
19 fBins = new Double_t[fN+1];
20 Double_t dx = (max-min)/fN;
21 for (UInt_t i = 0; i <= fN; i++) fBins[i] = min + i * dx;
23 //____________________________________________________________________
24 AliFMDFlowAxis::AliFMDFlowAxis(const AliFMDFlowAxis& other)
28 fBins = new Double_t[fN+1];
29 for (UInt_t i = 0; i <= fN; i++) fBins[i] = other.fBins[i];
31 //____________________________________________________________________
33 AliFMDFlowAxis::operator=(const AliFMDFlowAxis& other)
35 if (fBins) delete [] fBins;
37 fBins = new Double_t[fN+1];
38 for (UInt_t i = 0; i <= fN; i++) fBins[i] = other.fBins[i];
41 //____________________________________________________________________
42 AliFMDFlowAxis::~AliFMDFlowAxis()
44 if (fBins) delete [] fBins;
47 //____________________________________________________________________
49 AliFMDFlowAxis::FindBin(Double_t x) const
51 if (x < fBins[0]) return -1;
52 if (x > fBins[fN]) return -1;
53 UInt_t above, below, middle;
56 while((above - below) > 1) {
57 middle = (above + below) / 2;
58 if (x == fBins[middle-1]) return middle-1;
59 if (x < fBins[middle-1]) above = middle;
64 //____________________________________________________________________
66 AliFMDFlowAxis::BinWidth(UShort_t i) const
68 if (i >= fN) return 0;
69 return (fBins[i+1] - fBins[i]);
71 //____________________________________________________________________
73 AliFMDFlowAxis::BinCenter(UShort_t i) const
75 if (i >= fN) return 0;
76 return fBins[i] + BinWidth(i) / 2;
78 //____________________________________________________________________
80 AliFMDFlowAxis::BinLower(UShort_t i) const
82 if (i >= fN) return 0;
85 //____________________________________________________________________
87 AliFMDFlowAxis::BinUpper(UShort_t i) const
89 if (i >= fN) return 0;
93 //____________________________________________________________________