Documentation of 'jhplot.H2D' Java class.
H2D
jhplot

Class H2D

  • All Implemented Interfaces:
    java.io.Serializable


    public class H2D
    extends DrawOptions
    implements java.io.Serializable
    Histogram in two dimensions (2D). Main class to create a 2D histogram. Each bin in 2D is characterized by 2 indexes, i and j. This class is a direct extension of the H1D used for 1D case. Use the get() method to access JAIDA Histogram2D histogram class.
    See Also:
    Serialized Form
    • Constructor Detail

      • H2D

        public H2D(java.lang.String title,
                   int binsX,
                   double minX,
                   double maxX,
                   int binsY,
                   double minY,
                   double maxY)
        Create 2D histogram
        Parameters:
        title - Title
        binsX - Number of bins in X
        minX - Min value in X
        maxX - Max value in X
        binsY - Number of bins in Y
        minY - Min value in Y
        maxY - Max value in Y
      • H2D

        public H2D(IHistogram2D h1)
        Create H2D histogram from JAIDA IHistogram2D class
        Parameters:
        h1 - IHistogram2D histogram from JAIDA
      • H2D

        public H2D(Cloud2D c2d,
                   int binX,
                   int binY)
        Create H2D histogram from Cloud2D.
        Parameters:
        c2d - Cloud2D
        binX - number of bins in X
        binY - number of bins in Y
      • H2D

        public H2D(java.lang.String title,
                   double[] edgesX,
                   double[] edgesY)
        Create a 2D histogram using variable size bins in X and Y
        Parameters:
        title - - bin titles
        edgesX - - array with bin edges in X
        edgesY - - array with bin edges in Y
      • H2D

        public H2D(java.lang.String title,
                   IAxis xAx,
                   IAxis yAy)
        Define H2D in terms of axis
        Parameters:
        title - title
        xAx - Axis for X
        yAy - Axis for Y
      • H2D

        public H2D(Histogram2D h1)
        Create a H2D histogram from JAIDA histogram
        Parameters:
        h1 - Histogram2D histogram
      • H2D

        public H2D(hep.io.root.interfaces.TH2 h2t)
        Create H2D histogram from JAIDA TH1 histogram class
        Parameters:
        h1t - TH1 histogram from JAIDA
    • Method Detail

      • get

        public Histogram2D get()
        Get the JAIDA Histogram2D
        Returns:
        Histogram2D
      • setRmsY

        public void setRmsY(double rmsY)
        Set RMS on Y
        Parameters:
        rmsY - RMS on Y
      • setMeanY

        public void setMeanY(double mean)
        Set mean on Y
        Parameters:
        mean - on Y
      • getRmsY

        public double getRmsY()
        Get RMS on Y
      • getMeanY

        public double getMeanY()
        Get mean on Y
      • getMeanX

        public double getMeanX()
        Get mean on X.
      • getRmsX

        public double getRmsX()
        Get RMS on X
      • setNEntries

        public void setNEntries(int entries)
        Set all entries.
        Parameters:
        entries - entries
      • setValidEntries

        public void setValidEntries(int entries)
        Set in-range entries.
        Parameters:
        entries - entries
      • setRmsX

        public void setRmsX(double rmsX)
        Set RMS on X.
      • setMeanX

        public void setMeanX(double mean)
        Set mean on X.
        Parameters:
        mean - on X
      • setContents

        public void setContents(double[][] heights,
                                double[][] errors)
        Set content of H2D histogram
        Parameters:
        heights - heights
        errors - errors
      • setContents

        public void setContents(double[][] heights,
                                double[][] errors,
                                int[][] entries,
                                double[][] meanXs,
                                double[][] rmsXs,
                                double[][] meanYs,
                                double[][] rmsYs)
        Set the content of the whole Histogram at once. This is a convenience method for saving/restoring Histograms. Of the arguments below the heights array cannot be null. The errors array should in general be non-null, but this depends on the specific binner. The entries array can be null, in which case the entry of a bin is taken to be the integer part of the height. If the means array is null, the mean is defaulted to the geometric center of the bin. If the rms array is null, the rms is taken to be the bin width over the root of 12.
        Parameters:
        heights - The bin heights
        errors - The bin errors
        entries - The bin entries
        meanXs - The means of the bin along the x axis
        rmsXs - The rmss of the bin along the x axis
        meanYs - The means of the bin along the y axis
        rmsYs - The rmss of the bin along the y axis
      • fill

        public void fill(double value1,
                         double value2)
        Fill H2D histogram assuming all weights are unity.
        Parameters:
        value1 - value in X
        value2 - value in Y
      • fillGauss

        public void fillGauss(int TotNumber,
                              double meanX,
                              double sdX,
                              double meanY,
                              double sdY)
        Fill the histogram with random numbers from Gaussian (Normal) distribution. Seed is taken from time.
        Parameters:
        TotNumber - number generated events
        meanX - mean of the gaussian in X
        sdX - standard deviation in X
        meanY - mean of the gaussian in Y
        sdY - standard deviation in Y
      • fillRnd

        public void fillRnd(int TotNumber,
                            double meanX,
                            double widthX,
                            double meanY,
                            double widthY)
        Fill the histogram with random numbers from fralt distribution. Seed is taken from time. Using mean=0 and width=1 will give a flat distribution between 0 and 1.
        Parameters:
        TotNumber - number generated events
        meanX - mean of the distribution in X
        widthX - width of the distribution in X
        meanY - mean of the distribution in Y
        widthY - width of the distribution in Y
      • fill

        public void fill(int TotNumber,
                         AbstractDistribution random1,
                         AbstractDistribution random2)
        Fill the histogram with random numbers. Random generators are taken from cern.jet.random.*. Examples: Beta, Binominal, Poisson, BreitWigner,ChiSquare,Empirical Exponential, Gamma, Hyperbolic, Logarithmic, Normal, NegativeBinomial
        Parameters:
        TotNumber - number generated events
        random1 - generator for X
        random1 - generator for Y
      • setBinError

        public void setBinError(int indexX,
                                int indexY,
                                double error)
        Set the error on this bin.
        Parameters:
        indexX - the bin number (0...N-1) or OVERFLOW or UNDERFLOW.
        indexY - the bin number (0...N-1) or OVERFLOW or UNDERFLOW.
        error - the error.
      • binHeight

        public double binHeight(int indexX,
                                int indexY)
        Total height of the corresponding bin.
        Parameters:
        indexX - The x bin number in the external representation: (0...N-1) or OVERFLOW or UNDERFLOW.
        indexY - The y bin number in the external representation: (0...N-1) or OVERFLOW or UNDERFLOW.
        Returns:
        The bin height for the corresponding bin.
      • extraEntries

        public int extraEntries()
        Get the number of entries in the underflow and overflow bins.
        Returns:
        The number of entries outside the range of the Histogram.
      • sumExtraBinHeights

        public double sumExtraBinHeights()
        Get the sum of the bin heights for all the entries outside the Histogram's range.
        Returns:
        The sum of the out of range bin's heights.
      • sumAllBinHeights

        public double sumAllBinHeights()
        Get the sum of the bin heights for all the entries, in-range and out-range ones.
        Returns:
        The sum of all the bin's heights.
      • getBinsX

        public int getBinsX()
        Get the number of bins in X
        Returns:
        binsX number of bins in X
      • getBinsY

        public int getBinsY()
        Get the number of bins in Y
        Returns:
        binsY number of bins in Y
      • getMinX

        public double getMinX()
        Get min value of axis in X
        Returns:
        min value of X axis
      • getMaxX

        public double getMaxX()
        Get max value of axis in X
        Returns:
        max value of X axis
      • getMaxY

        public double getMaxY()
        Get max value of Y axis
        Returns:
        max value of Y axis
      • getMinY

        public double getMinY()
        Get min value of Y axis
        Returns:
        min value of X axis
      • getUnderflowEntriesY

        public int getUnderflowEntriesY()
        Get underflow entries in Y
        Returns:
        underflow in Y
      • getUnderflowHeightY

        public double getUnderflowHeightY()
        Get underflow height in Y
        Returns:
        underflow height in Y
      • getUnderflowHeightX

        public double getUnderflowHeightX()
        Get underflow height in X
        Returns:
        underflow height in X
      • getUnderflowEntriesX

        public int getUnderflowEntriesX()
        Get underflow entries in X
        Returns:
        underflow in X
      • getOverflowEntriesY

        public int getOverflowEntriesY()
        Get overflow entries in Y
        Returns:
        overflow in Y
      • getOverflowHeightY

        public double getOverflowHeightY()
        Get overflow height in Y
        Returns:
        overflow in Y
      • getOverflowEntriesX

        public int getOverflowEntriesX()
        Get overflow entries in Y
        Returns:
        overflow in Y
      • getOverflowHeightX

        public double getOverflowHeightX()
        Get overflow entries in Y
        Returns:
        overflow in Y
      • getLowerEdgeX

        public double getLowerEdgeX(int index)
        Get lower edge of the bin in X
        Parameters:
        index - of the bin
        Returns:
        lower edge of the bin
      • oper

        public H2D oper(H2D a,
                        java.lang.String title,
                        java.lang.String what)
        Various manipulations with histograms (+,-,*,/). Note: no new object will be created.
        Parameters:
        a - H2D histogram.
        title - New Title
        Returns:
        same H2D object but modified
      • scale

        public void scale(java.lang.String title,
                          double scaleFactor)
        Scale the histogram.
        Parameters:
        title - New title
        scaleFactor - Scale factor
      • operScale

        public H2D operScale(java.lang.String title,
                             double scaleFactor)
        Scale the histogram and return scaled object.
        Parameters:
        title - New title
        scaleFactor - Scale factor
      • getUpperEdgeX

        public double getUpperEdgeX(int index)
        Get upper edge of the bin in X
        Parameters:
        index - of the bin
        Returns:
        lower edge of the bin
      • getUpperEdgeY

        public double getUpperEdgeY(int index)
        Get upper edge of the bin in Y
        Parameters:
        index - of the bin
        Returns:
        lower edge of the bin
      • getLowerEdgeY

        public double getLowerEdgeY(int index)
        Get lower edge of the bins in Y
        Parameters:
        index - of the bin
        Returns:
        lower edge of the bin
      • getStat

        public java.util.Map<java.lang.String,java.lang.Double> getStat()
        Calculate complete statistics for this histogram for the X or Y Unlike other methods (like mean or rms), it performs calculations on the existing histogram, thus the method is somewhat slow. It return mean, error on the mean, RMS, variance, standard deviation.

        The key for the output map are: mean, error, rms, variance, stddev etc. Print the keys of this map to get the full access to statistics.

        Returns:
        map representing histogram statistics
      • allEntries

        public int allEntries()
        Get number of all entries
        Returns:
        Number of all entries
      • entries

        public int entries()
        Number of in-range entries in the histogram
        Returns:
        Number of in-range entries
      • getAxisX

        public IAxis getAxisX()
        Get IAxis in X
        Returns:
        axis in X
      • getAxisY

        public IAxis getAxisY()
        Get IAxis in Y
        Returns:
        axis in Y
      • clear

        public void clear()
      • binHeights

        public double[][] binHeights()
        Get bin heights as 2D array. Note 0 index bin means 1st bin etc.
        Returns:
        bin heights as 2D array
      • binErrors

        public double[][] binErrors()
        Get errors on heights as 2D array. Note 0 index bin means 1st bin etc.
        Returns:
        errors on heights as 2D array
      • binMeansX

        public double[][] binMeansX()
        Get mean position for X axis as 2D array. Note 0 index bin means 1st bin etc.
        Returns:
        X mean positions as 2D array
      • getLowerEdgesX

        public double[] getLowerEdgesX()
        Get lower edges for X bins as 1D array. Note 0 index bin means 1st bin etc.
        Returns:
        lower edges for X positions as 1D array
      • getLowerEdgesY

        public double[] getLowerEdgesY()
        Get lower edges for Y bins as 1D array. Note 0 index bin means 1st bin etc.
        Returns:
        lower edges for Y positions as 1D array
      • binMeansY

        public double[][] binMeansY()
        Get mean position for Y axis as 2D array. Note 0 index bin means 1st bin etc.
        Returns:
        Y mean positions as 2D array
      • binMeans

        public double[] binMeans(int i,
                                 int j)
        Get bin mean position at the location (i,i)
        Parameters:
        i - bin position in X
        j - bin position in Y
        Returns:
        bin mean in X and Y (2D array).
      • copy

        public H2D copy(java.lang.String newtitle)
        Get exact copy of the current histogram. This means it makes a new object.
        Parameters:
        newtitle - New title
        Returns:
        a new copy of the histogram
      • getDensity

        public H2D getDensity()
        Get a density distribution dividing each bin of the histogram by the bin width and the total number of heights for all bins.
        Returns:
        density distribution
      • binEntries

        public int binEntries(int indexX,
                              int indexY)
        Number of entries in the corresponding bin (i.e. the number of times fill was called for this bin).
        Parameters:
        indexX - the x bin number in the external representation: (0...N-1) or OVERFLOW or UNDERFLOW.
        indexY - the y bin number in the external representation: (0...N-1) or OVERFLOW or UNDERFLOW.
        Returns:
        The number of entries for the corresponding bin.
      • binError

        public double binError(int indexX,
                               int indexY)
        Error of the corresponding bin.
        Parameters:
        indexX - the x bin number in the external representation: (0...N-1) or OVERFLOW or UNDERFLOW.
        indexY - the y bin number in the external representation: (0...N-1) or OVERFLOW or UNDERFLOW.
        Returns:
        errors for the corresponding bin.
      • fill

        public void fill(double value1,
                         double value2,
                         double weight)
        Fill H2D histogram with weights
        Parameters:
        value1 - value in X
        value2 - value in Y
        weight - weight
      • fill

        public void fill(double[] value1,
                         double[] value2)
        Fill H2D histogram from 2 arrays (X amd Y). Assume weights =1.
        Parameters:
        value1 - array with values in X
        value2 - array with values in Y
      • fill

        public void fill(Cloud2D c2d)
        Fill H2D histogram from Cloud2D.
        Parameters:
        c2d - input Cloud2D array with values in X
      • fill

        public void fill(P0D value1,
                         P0D value2)
        Fill H2D histogram from 2 arrays. Assume weights =1.
        Parameters:
        value1 - array with values in X
        value2 - array with values in Y
      • fill

        public void fill(P0I value1,
                         P0I value2)
        Fill H2D histogram from 2 arrays. Assume weights =1.
        Parameters:
        value1 - array with values in X
        value2 - array with values in Y
      • fill

        public void fill(double[] value1,
                         double[] value2,
                         double[] weights)
        Fill H2D histogram from arrays. Weights are defined by the third array. Sizes of the arrays must be the same.
        Parameters:
        value1 - array with values in X
        value2 - array with values in Y
        weights - weights
      • findBinX

        public int findBinX(double x)
        Convert a coordinate X on the axis to a bin number
        Parameters:
        x - coordinate on axis
        Returns:
        index of the corresponding bin
      • findBinY

        public int findBinY(double y)
        Convert a coordinate Y on the axis to a bin number
        Parameters:
        y - coordinate on axis
        Returns:
        index of the corresponding bin
      • integralRange

        public double integralRange(double xMin,
                                    double xMax,
                                    double yMin,
                                    double yMax,
                                    boolean timesBinWidth)
        Integrate histogram in the range. The integral is computed as the sum of bin contents in the range.
        Parameters:
        xMin - Min value for X integration (included to integration)
        xMax - Max index for X integration (included to integration)
        yMin - Min index for Y integration (included to integration)
        yMax - Max index for Y integration (included to integration)
        timesBinWidth - If true, the integral is the sum of the bin contents multiplied by the bin width in x.
        Returns:
        integral (sum of all heights)
      • getProbability

        public H2D getProbability()
        Return q probability distribution derived from a histogram. The histogram is scaled by the sum of all contents.
        Returns:
        probability distribution
      • copy

        public H2D copy()
        Make a copy of the data holder
        Returns:
        New data holder
      • scale

        public void scale(double scaleFactor)
        Scale the histogram.
        Parameters:
        scaleFactor - Scale factor
      • integral

        public double integral(int BinMinX,
                               int BinMaxX,
                               int BinMinY,
                               int BinMaxY)
        Integrate histogram between two indices. The integral is computed as the sum of bin contents in the range.
        Parameters:
        BinMinX - Min index for X integration (included to integration, start from 1)
        BinMaxX - Max index for X integration (included to integration)
        BinMinY - Min index for Y integration (included to integration, start from 1)
        BinMaxY - Max index for Y integration (included to integration)
        Returns:
        integral (sum of all heights)
      • integral

        public double integral(int BinMinX,
                               int BinMaxX,
                               int BinMinY,
                               int BinMaxY,
                               boolean timesBinWidth)
        Integrate histogram between two indices. The integral is computed as the sum of bin contents in the range if the last parameter is false. If it is true, he integral is the sum of the bin contents multiplied by the bin width in x.
        Parameters:
        BinMinX - Min index for X integration (included to integration, start from 1)
        BinMaxX - Max index for X integration (included to integration)
        BinMinY - Min index for Y integration (included to integration, start from 1)
        BinMaxY - Max index for Y integration (included to integration)
        timesBinWidth - If true, the integral is the sum of the bin contents multiplied by the bin width in x.
        Returns:
        integral (sum of all heights)
      • compareChi2

        public java.util.Map<java.lang.String,java.lang.Double> compareChi2(F2D f1)
        Compare the histogram with a function. The comparison tests hypotheses that the histogram represent identical distribution with a function using Pearson's chi-squared test. The number chi2/ndf gives the estimate (values close to 1 indicates similarity between 2 histograms.). the function and histogram are identical if chi2=0. Chi2/ndf and p-value probability is 1. Maken sure that statistical errors are included correctly. Data with zero errors will be ignored.
        Parameters:
        f1 - function to compare to.
        Returns:
        map with the result. It gives Chi2, gives number of degrees of freedom (ndf), probability ("quality", or p-value).
      • compareChi2

        public java.util.Map<java.lang.String,java.lang.Double> compareChi2(H2D h2)
        Compare two 2D histograms. Comparison of two histograms test hypotheses that two histograms represent identical distributions. It calculates Chi2 between 2 histograms taking into account errors on the heights of the bins. The number chi2/ndf gives the estimate (values close to 1 indicates similarity between 2 histograms.) Two histograms are identical if chi2=0. Chi2/ndf]. Probability (p-value) is 1. Make sure that both histograms have error (or set them to small values).
        Parameters:
        h2 - second histogram to compare
        Returns:
        results. It gives Chi2, the number of degrees of freedom (ndf), and probability ("quality", or p-value).
      • doc

        public void doc()
        Show online documentation.

DMelt 3.0 © DataMelt by jWork.ORG