2 @brief Implementation of an Axis in a Flow "histogram" */
3 #include "flow/AliFMDFlowAxis.h"
8 //====================================================================
9 AliFMDFlowAxis::AliFMDFlowAxis(UShort_t n, Double_t* bins)
13 fBins = new Double_t[fN+1];
14 for (UInt_t i = 0; i <= fN; i++) fBins[i] = bins[i];
16 //____________________________________________________________________
17 AliFMDFlowAxis::AliFMDFlowAxis(UShort_t n, Double_t min, Double_t max)
21 fBins = new Double_t[fN+1];
22 Double_t dx = (max-min)/fN;
23 for (UInt_t i = 0; i <= fN; i++) fBins[i] = min + i * dx;
25 //____________________________________________________________________
26 AliFMDFlowAxis::AliFMDFlowAxis(const AliFMDFlowAxis& other)
30 fBins = new Double_t[fN+1];
31 for (UInt_t i = 0; i <= fN; i++) fBins[i] = other.fBins[i];
33 //____________________________________________________________________
35 AliFMDFlowAxis::operator=(const AliFMDFlowAxis& other)
37 if (fBins) delete [] fBins;
39 fBins = new Double_t[fN+1];
40 for (UInt_t i = 0; i <= fN; i++) fBins[i] = other.fBins[i];
43 //____________________________________________________________________
44 AliFMDFlowAxis::~AliFMDFlowAxis()
46 if (fBins) delete [] fBins;
49 //____________________________________________________________________
51 AliFMDFlowAxis::FindBin(Double_t x) const
53 if (x < fBins[0]) return -1;
54 if (x > fBins[fN]) return -1;
55 UInt_t above, below, middle;
58 while((above - below) > 1) {
59 middle = (above + below) / 2;
60 if (x == fBins[middle-1]) return middle-1;
61 if (x < fBins[middle-1]) above = middle;
66 //____________________________________________________________________
68 AliFMDFlowAxis::BinWidth(UShort_t i) const
70 if (i >= fN) return 0;
71 return (fBins[i+1] - fBins[i]);
73 //____________________________________________________________________
75 AliFMDFlowAxis::BinCenter(UShort_t i) const
77 if (i >= fN) return 0;
78 return fBins[i] + BinWidth(i) / 2;
80 //____________________________________________________________________
82 AliFMDFlowAxis::BinLower(UShort_t i) const
84 if (i >= fN) return 0;
87 //____________________________________________________________________
89 AliFMDFlowAxis::BinUpper(UShort_t i) const
91 if (i >= fN) return 0;
95 //____________________________________________________________________
97 AliFMDFlowAxis::Print(Option_t*) const
99 std::ios_base::fmtflags old_flags = std::cout.setf(std::ios_base::fixed,
100 std::ios_base::floatfield);
101 for (UShort_t i = 0; i < fN; i++)
102 std::cout << std::setw(5) << BinLower(i) << " - "
103 << std::setw(5) << BinUpper(i) << std::endl;
104 std::cout.setf(old_flags, std::ios_base::floatfield);
108 //____________________________________________________________________