Package hep.aida.ref

Class Histogram2D

All Implemented Interfaces:
IHistogram, IHistogram2D, Serializable

public class Histogram2D extends AbstractHistogram2D implements IHistogram2D
A reference implementation of hep.aida.IHistogram2D. The goal is to provide a clear implementation rather than the most efficient implementation. However, performance seems fine - filling 6 * 10^5 points/sec, both using FixedAxis or VariableAxis.
Version:
1.0, 23/03/2000
See Also:
  • Field Details

    • heights

      private double[][] heights
    • errors

      private double[][] errors
    • entries

      private int[][] entries
    • nEntry

      private int nEntry
    • sumWeight

      private double sumWeight
    • sumWeightSquared

      private double sumWeightSquared
    • meanX

      private double meanX
    • rmsX

      private double rmsX
    • meanY

      private double meanY
    • rmsY

      private double rmsY
  • Constructor Details

    • Histogram2D

      public Histogram2D(String title, double[] xEdges, double[] yEdges)
      Creates a variable-width histogram. Example: xEdges = (0.2, 1.0, 5.0, 6.0), yEdges = (-5, 0, 7) yields 3*2 in-range bins.
      Parameters:
      title - The histogram title.
      xEdges - the bin boundaries the x-axis shall have; must be sorted ascending and must not contain multiple identical elements.
      yEdges - the bin boundaries the y-axis shall have; must be sorted ascending and must not contain multiple identical elements.
      Throws:
      IllegalArgumentException - if xEdges.length invalid input: '<' 1 || yEdges.length invalid input: '<' 1.
    • Histogram2D

      public Histogram2D(String title, int xBins, double xMin, double xMax, int yBins, double yMin, double yMax)
      Creates a fixed-width histogram.
      Parameters:
      title - The histogram title.
      xBins - The number of bins on the X axis.
      xMin - The minimum value on the X axis.
      xMax - The maximum value on the X axis.
      yBins - The number of bins on the Y axis.
      yMin - The minimum value on the Y axis.
      yMax - The maximum value on the Y axis.
    • Histogram2D

      public Histogram2D(String title, IAxis xAxis, IAxis yAxis)
      Creates a histogram with the given axis binning.
      Parameters:
      title - The histogram title.
      xAxis - The x-axis description to be used for binning.
      yAxis - The y-axis description to be used for binning.
  • Method Details

    • allEntries

      public int allEntries()
      Description copied from interface: IHistogram
      Number of all entries in all (both in-range and under/overflow) bins in the histogram.
      Specified by:
      allEntries in interface IHistogram
      Overrides:
      allEntries in class AbstractHistogram2D
    • binEntries

      public int binEntries(int indexX, int indexY)
      Description copied from interface: IHistogram2D
      The number of entries (ie the number of times fill was called for this bin).
      Specified by:
      binEntries in interface IHistogram2D
      Parameters:
      indexX - the x bin number (0...Nx-1) or OVERFLOW or UNDERFLOW.
      indexY - the y bin number (0...Ny-1) or OVERFLOW or UNDERFLOW.
    • binError

      public double binError(int indexX, int indexY)
      Description copied from interface: IHistogram2D
      The error on this bin.
      Specified by:
      binError in interface IHistogram2D
      Parameters:
      indexX - the x bin number (0...Nx-1) or OVERFLOW or UNDERFLOW.
      indexY - the y bin number (0...Ny-1) or OVERFLOW or UNDERFLOW.
    • binHeight

      public double binHeight(int indexX, int indexY)
      Description copied from interface: IHistogram2D
      Total height of the corresponding bin (ie the sum of the weights in this bin).
      Specified by:
      binHeight in interface IHistogram2D
      Parameters:
      indexX - the x bin number (0...Nx-1) or OVERFLOW or UNDERFLOW.
      indexY - the y bin number (0...Ny-1) or OVERFLOW or UNDERFLOW.
    • equivalentBinEntries

      public double equivalentBinEntries()
      Description copied from interface: IHistogram
      Number of equivalent entries.
      Specified by:
      equivalentBinEntries in interface IHistogram
      Returns:
      SUM[ weight ] ^ 2 / SUM[ weight^2 ].
    • fill

      public void fill(double x, double y)
      Description copied from interface: IHistogram2D
      Fill the histogram with weight 1.
      Specified by:
      fill in interface IHistogram2D
      Overrides:
      fill in class AbstractHistogram2D
    • fill

      public void fill(double x, double y, double weight)
      Description copied from interface: IHistogram2D
      Fill the histogram with specified weight.
      Specified by:
      fill in interface IHistogram2D
    • internalSliceX

      protected IHistogram1D internalSliceX(String title, int indexY1, int indexY2)
      The precise meaning of the arguments to the public slice methods is somewhat ambiguous, so we define this internal slice method and clearly specify its arguments.

      Note 0indexY1 and indexY2 use our INTERNAL bin numbering scheme Note 1The slice is done between indexY1 and indexY2 INCLUSIVE Note 2indexY1 and indexY2 may include the use of under and over flow bins Note 3There is no note 3 (yet)

      Specified by:
      internalSliceX in class AbstractHistogram2D
    • internalSliceY

      protected IHistogram1D internalSliceY(String title, int indexX1, int indexX2)
      The precise meaning of the arguments to the public slice methods is somewhat ambiguous, so we define this internal slice method and clearly specify its arguments.

      Note 0indexX1 and indexX2 use our INTERNAL bin numbering scheme Note 1The slice is done between indexX1 and indexX2 INCLUSIVE Note 2indexX1 and indexX2 may include the use of under and over flow bins Note 3There is no note 3 (yet)

      Specified by:
      internalSliceY in class AbstractHistogram2D
    • meanX

      public double meanX()
      Description copied from interface: IHistogram2D
      Returns the mean of the histogram, as calculated on filling-time projected on the X axis.
      Specified by:
      meanX in interface IHistogram2D
    • meanY

      public double meanY()
      Description copied from interface: IHistogram2D
      Returns the mean of the histogram, as calculated on filling-time projected on the Y axis.
      Specified by:
      meanY in interface IHistogram2D
    • reset

      public void reset()
      Description copied from interface: IHistogram
      Reset contents; as if just constructed.
      Specified by:
      reset in interface IHistogram
    • rmsX

      public double rmsX()
      Description copied from interface: IHistogram2D
      Returns the rms of the histogram as calculated on filling-time projected on the X axis.
      Specified by:
      rmsX in interface IHistogram2D
    • rmsY

      public double rmsY()
      Description copied from interface: IHistogram2D
      Returns the rms of the histogram as calculated on filling-time projected on the Y axis.
      Specified by:
      rmsY in interface IHistogram2D
    • setContents

      void setContents(int[][] entries, double[][] heights, double[][] errors)
      Used internally for creating slices and projections
    • sumAllBinHeights

      public double sumAllBinHeights()
      Description copied from interface: IHistogram
      Sum of all (both in-range and under/overflow) bin heights in the histogram.
      Specified by:
      sumAllBinHeights in interface IHistogram
      Overrides:
      sumAllBinHeights in class AbstractHistogram2D