Class Histo2DData

java.lang.Object
cnuphys.splot.pdata.Histo2DData

public class Histo2DData extends Object
  • Constructor Details

    • Histo2DData

      public Histo2DData(String name, String xname, String yname, double valMinX, double valMaxX, int numBinsX, double valMinY, double valMaxY, int numBinsY)
      The data for a 2D histogram where the bin spacing is uniform.
      Parameters:
      name - the name
      xname - the x variable name
      yname - the y variable name
      valMin - the data min
      valMax - the data max
      numBins - the number of bins
    • Histo2DData

      public Histo2DData(String name, String xname, String yname, double[] gridX, double[] gridY)
      The data for a 2D histogram where the bin spacing is arbitrary (i.e., not uniform)
      Parameters:
      name - the curve name of the histogram
      xname - the x variable name
      yname - the y variable name
      grid - the binning grid. It must be in ascending order but is otherwise arbitrary.
  • Method Details

    • getName

      public String getName()
      Get the name of the histogram
      Returns:
      the name of the histogram
    • setName

      public void setName(String name)
      Set the name
      Parameters:
      name - the name of the histogram
    • clear

      public void clear()
      Clear the data
    • getCounts

      public long[][] getCounts()
      Get the counts
      Returns:
      the counts array
    • getGoodCount

      public long getGoodCount()
      Get the number on entries in the histogram (excluding out of range)
      Returns:
      the number of entries
    • getTotalCount

      public long getTotalCount()
      Get the total count, including the out of range
      Returns:
      the total count, including the out of range
    • getOutOfRangeCount

      public long getOutOfRangeCount()
      Get the number on entries in the histogram that were out of range
      Returns:
      the number of entries out of range
    • getMinX

      public double getMinX()
      Get the minimum "x" value. This is the minimum of the range being binned.
      Returns:
      the minimum "x" value
    • getMaxX

      public double getMaxX()
      Get the maximum "x" value. This is the maximum of the range being binned.
      Returns:
      the maximum "x" value
    • getMinY

      public double getMinY()
      Get the minimum "y" value. This is the minimum of the range being binned.
      Returns:
      the minimum "x" value
    • getMaxY

      public double getMaxY()
      Get the maximum y value. This is the maximum of the range being binned.
      Returns:
      the maximum "y" value
    • getMinZ

      public double getMinZ()
      Get the minimum "z" value. The z axis corresponds to "counts", so this always returns 0
    • getMaxCount

      public long getMaxCount()
      Get the maximum count of any bin
      Returns:
      the count of the bin with the most counts.
    • add

      public void add(double valueX, double valueY)
      Add a value to the histogram
      Parameters:
      value - the value to ad
    • getNumberBinsX

      public int getNumberBinsX()
      Get the number of x bins
      Returns:
      the number of x bins
    • getNumberBinsY

      public int getNumberBinsY()
      Get the number of x bins
      Returns:
      the number of x bins
    • getBinMidValueX

      public double getBinMidValueX(int bin)
      Get the "x" value of the middle of the bin
      Parameters:
      bin - the bin in question
      Returns:
      the x mid value
    • getBinMidValueY

      public double getBinMidValueY(int bin)
      Get the "y" value of the middle of the bin
      Parameters:
      bin - the bin in question
      Returns:
      the y mid value
    • getBinMaxY

      public double getBinMaxY(int bin)
      Get the "y" value of the right side of the bin
      Parameters:
      bin - the bin in question
      Returns:
      the y value of the right side
    • getBinMaxX

      public double getBinMaxX(int bin)
      Get the "x" value of the right side of the bin
      Parameters:
      bin - the bin in question
      Returns:
      the x value of the right side
    • getBinMinX

      public double getBinMinX(int bin)
      Get the "x" value of the left side of the bin
      Parameters:
      bin - the bin in question
      Returns:
      the x value of the left side
    • getBinMinY

      public double getBinMinY(int bin)
      Get the "y" value of the left side of the bin
      Parameters:
      bin - the bin in question
      Returns:
      the y value of the left side
    • getBinX

      public int getBinX(double val)
      Get the x bin for a given x value. Will return the zero-based bin number or OUTOFRANGE.
      Parameters:
      val - the x value.
      Returns:
      return the x bin: [0..(numBinX-1)] or an error
    • getBinY

      public int getBinY(double val)
      Get the y bin for a given y value. Will return the zero-based bin number or OUTOFRANGE.
      Parameters:
      val - the y value.
      Returns:
      return the y bin: [0..(numBinY-1)] or an error
    • getRectangle

      public Rectangle2D.Double getRectangle(double x, double y)
      Get the world rectangle containing the given x and y values
      Parameters:
      x - the x value
      y - the y value
      Returns:
      the world rectangle, or null.
    • getRectangle

      public Rectangle2D.Double getRectangle(int binX, int binY)
      Get the world rectangle corresponding to the given bins
      Parameters:
      binX - the x bin
      binY - the y bin
      Returns:
      the world rectangle, or null.
    • getFractionalValue

      public double getFractionalValue(int binX, int binY)
      Get the fractional value (fraction of max value) for use in a plot
      Parameters:
      binX - the x bin
      binY - the y bin
      Returns:
      the fractional value (fraction of max value).
    • statusString

      public static String statusString(PlotCanvas canvas, Histo2DData histo, Point mousePoint, Point2D.Double wp)
      Get the status string
      Parameters:
      canvas - the plot canvas
      histo - the histo data object
      mousePoint - where the mouse is
      wp - the data coordinates of the mouse
      Returns:
      a status string
    • getCount

      public long getCount(int xbin, int ybin)
      Get the count for a given bin double
      Parameters:
      xbin - the x bin
      ybin - the y bin
      Returns:
      the count for that bin double
    • getXName

      public String getXName()
      Get the name for the x axis variable
      Returns:
      the name for the x axis variable
    • getYName

      public String getYName()
      Get the name for the y axis variable
      Returns:
      the name for the y axis variable