hep.aida.ref.histogram
Class VariableAxis

java.lang.Object
  extended by hep.aida.ref.histogram.VariableAxis
All Implemented Interfaces:
IAxis

public class VariableAxis
extends Object
implements IAxis

Variable-width axis; A reference implementation of hep.aida.IAxis.


Field Summary
 
Fields inherited from interface hep.aida.IAxis
OVERFLOW_BIN, UNDERFLOW_BIN
 
Constructor Summary
VariableAxis(double[] edges)
          Constructs and returns an axis with the given bin edges.
 
Method Summary
 double binCenter(int index)
          Get the center of the specified bin.
 double binLowerEdge(int index)
          Get the lower edge of the specified bin.
 int bins()
          The number of bins (excluding underflow and overflow) on the IAxis.
 double binUpperEdge(int index)
          Get the upper edge of the specified bin.
 double binWidth(int index)
          Get the width of the specified bin.
 int coordToIndex(double coord)
          Convert a coordinate on the axis to a bin number.
 boolean equals(Object o)
          Check if two Axis are equal.
 boolean isFixedBinning()
          Check if the IAxis has fixed binning, i.e.
 double lowerEdge()
          Get the lower edge of the IAxis.
 double upperEdge()
          Get the upper edge of the IAxis.
 
Methods inherited from class java.lang.Object
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VariableAxis

public VariableAxis(double[] edges)
Constructs and returns an axis with the given bin edges. Example: edges = (0.2, 1.0, 5.0) yields an axis with 2 in-range bins [0.2,1.0), [1.0,5.0) and 2 extra bins [-inf,0.2), [5.0,inf].

Parameters:
edges - the bin boundaries the partition shall have; must be sorted ascending and must not contain multiple identical elements.
Throws:
IllegalArgumentException - if edges.length < 1.
Method Detail

binCenter

public double binCenter(int index)
Description copied from interface: IAxis
Get the center of the specified bin.

Specified by:
binCenter in interface IAxis
Parameters:
index - The bin number: 0 to bins()-1) for the in-range bins or OVERFLOW or UNDERFLOW.
Returns:
The center of the corresponding bin. For in-range bins the middle of the upper and lower edge of the bin is returned; for out-of-range bins +/- infinity is returned.

binLowerEdge

public double binLowerEdge(int index)
Description copied from interface: IAxis
Get the lower edge of the specified bin.

Specified by:
binLowerEdge in interface IAxis
Parameters:
index - The bin number: 0 to bins()-1 for the in-range bins or OVERFLOW or UNDERFLOW.
Returns:
The lower edge of the corresponding bin; for the underflow bin this is Double.NEGATIVE_INFINITY.

bins

public int bins()
Description copied from interface: IAxis
The number of bins (excluding underflow and overflow) on the IAxis.

Specified by:
bins in interface IAxis
Returns:
The IAxis's number of bins.

binUpperEdge

public double binUpperEdge(int index)
Description copied from interface: IAxis
Get the upper edge of the specified bin.

Specified by:
binUpperEdge in interface IAxis
Parameters:
index - The bin number: 0 to bins()-1 for the in-range bins or OVERFLOW or UNDERFLOW.
Returns:
The upper edge of the corresponding bin; for the overflow bin this is Double.POSITIVE_INFINITY.

binWidth

public double binWidth(int index)
Description copied from interface: IAxis
Get the width of the specified bin.

Specified by:
binWidth in interface IAxis
Parameters:
index - The bin number: 0 to bins()-1) for the in-range bins or OVERFLOW or UNDERFLOW.
Returns:
The width of the corresponding bin.

coordToIndex

public int coordToIndex(double coord)
Description copied from interface: IAxis
Convert a coordinate on the axis to a bin number. If the coordinate is less than the lowerEdge UNDERFLOW is returned; if the coordinate is greater or equal to the upperEdge OVERFLOW is returned.

Specified by:
coordToIndex in interface IAxis
Parameters:
coord - The coordinate to be converted.
Returns:
The corresponding bin number.

lowerEdge

public double lowerEdge()
Description copied from interface: IAxis
Get the lower edge of the IAxis.

Specified by:
lowerEdge in interface IAxis
Returns:
The IAxis's lower edge.

upperEdge

public double upperEdge()
Description copied from interface: IAxis
Get the upper edge of the IAxis.

Specified by:
upperEdge in interface IAxis
Returns:
The IAxis's upper edge.

isFixedBinning

public boolean isFixedBinning()
Description copied from interface: IAxis
Check if the IAxis has fixed binning, i.e. if all the bins have the same width.

Specified by:
isFixedBinning in interface IAxis
Returns:
true if the binning is fixed, false otherwise.

equals

public boolean equals(Object o)
Check if two Axis are equal.

Overrides:
equals in class Object
Parameters:
o - the Object to check
Returns:
true if o is an instance of FixedAxis and it has the same number of bins, minimum and bin width.


jHepWork 3.2 © jWork.org