10 #define LWH_VariAxis_H
39 for (
int i = 0, N = edges.size(); i < N; ++i ) binco[edges[i]] = 0;
40 std::map<double,int>::iterator it = binco.begin();
41 for (
int i = 0, N = edges.size(); i < N; ++i ) (it++)->second = i;
48 : IAxis(a), binco(a.binco) {}
67 if ( binco.size() )
return binco.begin()->first;
77 if ( !binco.size() )
return 0;
78 std::map<double,int>::const_iterator last = binco.end();
79 return (--last)->first;
87 int bins()
const {
return binco.size() - 1; }
97 std::pair<double,double>
binEdges(
int index)
const {
98 std::pair<double,double> edges(0.0, 0.0);
99 if ( !binco.size() )
return edges;
100 std::map<double,int>::const_iterator lo = binco.end();
101 std::map<double,int>::const_iterator up = binco.begin();
102 if ( index >= 0 )
while ( index-- >= 0 && up != binco.end() ) lo = up++;
103 edges.first = ( lo == binco.end() )? -std::numeric_limits<double>::max():
105 edges.second = ( up == binco.end() )? std::numeric_limits<double>::max():
119 return binEdges(index).first;
131 return binEdges(index).second;
142 std::pair<double,double> edges = binEdges(index);
143 return edges.second - edges.first;
156 std::map<double,int>::const_iterator up = binco.upper_bound(coord);
157 if ( up == binco.begin() )
return UNDERFLOW_BIN;
158 else if ( up == binco.end() )
return OVERFLOW_BIN;
159 else return up->second - 1;
167 std::pair<double,double> edges = binEdges(index);
168 return (edges.second + edges.first)/2.0;
double lowerEdge() const
Get the lower edge of the IAxis.
double binLowerEdge(int index) const
Get the lower edge of the specified bin.
double binUpperEdge(int index) const
Get the upper edge of the specified bin.
int bins() const
The number of bins (excluding underflow and overflow) on the IAxis.
std::pair< double, double > binEdges(int index) const
Get the lower edge of the specified bin.
bool isFixedBinning() const
Check if the IAxis has fixed binning, i.e.
std::map< double, int > binco
A map relating the lower edge of a bin to the corresponding bin number.
double binWidth(int index) const
Get the width of the specified bin.
int coordToIndex(double coord) const
Convert a coordinate on the axis to a bin number.
An VariAxis represents a binned histogram axis.
virtual ~VariAxis()
Destructor.
The LWH namespace contains a Light-Weight Histogram package which implements the most rudimentary his...
double binMidPoint(int index) const
Return the midpoint of the specified bin.
VariAxis(const VariAxis &a)
Copy constructor.
VariAxis(const std::vector< double > &edges)
Standard constructor.
double upperEdge() const
Get the upper edge of the IAxis.