Class HistoData

java.lang.Object
cnuphys.splot.pdata.HistoData

public class HistoData extends Object
Xontainer class for histogram data
Author:
heddle
  • Field Details

  • Constructor Details

    • HistoData

      public HistoData(String name, double valMin, double valMax, int numBins)
      The data for a 1D histogram where the bin spacing is uniform.
      Parameters:
      name - the curve name of the histogram
      valMin - the data min
      valMax - the data max
      numBins - the number of bins
    • HistoData

      public HistoData(String name, double[] grid)
      The data for a 1D histogram where the bin spacing is arbitrary (i.e., not uniform)
      Parameters:
      name - the curve name of the histogram
      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
    • getCount

      public long getCount(int bin)
      Get the count for a given bin
      Parameters:
      bin - the bin
      Returns:
      the count for that bin
    • clear

      public void clear()
      Clear the data
    • getBasicStatistics

      public double[] getBasicStatistics()
      Get the means and standard deviation
      Returns:
      an array with the mean in the 0 index, standard deviation is the 1 index, and rms in the 2 index
    • statStr

      public String statStr()
      A string displaying some statistics
      Parameters:
      useRms - if true use rms, else use sigma
      Returns:
      a string with statistics info
    • getCounts

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

      public long getGoodCount()
      Get the number on entries in the histogram (excluding underflows and overflows)
      Returns:
      the number of entries
    • getTotalCount

      public long getTotalCount()
      Get the total count, including the unders and overs
      Returns:
      the total count, including the unders and overs
    • getUnderCount

      public long getUnderCount()
      Get the number on entries in the histogram that were below the minimum value
      Returns:
      the number of entries below the minimum value
    • getOverCount

      public long getOverCount()
      Get the number on entries in the histogram that were above the maximum value
      Returns:
      the number of entries above the maximum value
    • 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 minimum value. This is the maximum of the range being binned.
      Returns:
      the minimum "x" value
    • getMinY

      public double getMinY()
      Get the minimum "y" value. The y axis corresponds to "counts", so this always returns 0
    • getMaxY

      public double getMaxY()
      Get the maximum "y" value. The y axis corresponds to "counts", so this always returns the count of the bin with the most counts.
    • add

      public void add(double value)
      Add a value to the histogram
      Parameters:
      value - the value to ad
    • setCount

      public void setCount(double val, int count)
      Set a bin to a given count
      Parameters:
      val - the x val will determine bin
      count - the count
    • getNumberBins

      public int getNumberBins()
      Get the number of bins
      Returns:
      the number of bins
    • getBinMidValue

      public double getBinMidValue(int bin)
      Get the "x" value of the middle of the bin
      Parameters:
      bin - the bin in question
      Returns:
      the mid value
    • 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
    • getBin

      public int getBin(double val)
      Get the bin for a given value. Will return the zero-based bin number or UNDERFLOW or OVERFLOW.
      Parameters:
      val - the value.
      Returns:
      return the bin: [0..(numBin-1)] or an error
    • statusString

      public static String statusString(PlotCanvas canvas, HistoData 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
    • GetPolygon

      public static Polygon GetPolygon(PlotCanvas canvas, HistoData histo)
      Get the drawing polygon
      Parameters:
      canvas - the drawing canvas
      histo - the histo data
      Returns:
      the polygon
    • setRmsInHistoLegend

      public void setRmsInHistoLegend(boolean useRMS)
      Set whether we use rms or sigma in histogram legends
      Parameters:
      useRMS - if true use rms, else use sigma
    • useRmsInHistoLegend

      public boolean useRmsInHistoLegend()
      Check whether we use rms or sigma in histogram legends
      Returns:
      true use rms, else use sigma
    • setDrawStatisticalErrors

      public void setDrawStatisticalErrors(boolean statErr)
      Set whether we draw sqrt(n) statistical errors
      Parameters:
      statErr - if true draw statistical errors
    • drawStatisticalErrors

      public boolean drawStatisticalErrors()
      Check whether we draw sqrt(n) statistical errors
      Returns:
      true if true draw statistical errors
    • maxBinString

      public String maxBinString()