jhplot
Class H1D

java.lang.Object
  extended by jhplot.DrawOptions
      extended by jhplot.H1D

public class H1D
extends DrawOptions

Class to create a histogram in one dimension (1D). Based on JAIDA Histogram1D class.


Constructor Summary
H1D()
          Build 1D histogram.
H1D(hep.aida.ref.histogram.Histogram1D h1)
          Create H1D histogram from JAIDA Histogram1D class.
H1D(hep.aida.IHistogram1D h1)
          Create H1D histogram from JAIDA IHistogram1D class
H1D(java.lang.String title, double[] edges)
          Create 1D histogram with variable bin size.
H1D(java.lang.String title, H1D h1d)
          Create H1D from another instance.
H1D(java.lang.String title, int bins, double min, double max)
          Build 1D histogram
H1D(hep.io.root.interfaces.TH1 h1t)
          Create H1D histogram from JAIDA TH1 histogram class
 
Method Summary
 int allEntries()
          Get number of all entries
 double binCenter(int index)
          Get bin centres.
 double[] binCenters()
          Get all bin centers in form of array
 double binEntries(int index)
          Number of entries in a bin with index i
 double binError(int index)
          Error on the bin with index i
 double[] binErrors()
          Get all bin errors of the histogram as an array
 double binHeight(int index)
          Height of the corresponding bin
 double[] binHeights()
          Get all heights of the histogram as an array
 double binLowerEdge(int index)
          Get bin lower edge.
 double[] binLowerEdges()
          Get all lower edges in form of array
 double binMean(int index)
          Mean in a single bin with index
 double binRms(int index)
          RMS of a single bin with index
 double binUpperEdge(int index)
          Get bin upper edge.
 double[] binUpperEdges()
          Get all upper edges in form of array
 H1D copy()
          Make a copy of the data holder
 H1D copy(java.lang.String newtitle)
          Get exact copy of the current histogram.
 int entries()
          Number of in-range entries in the histogram
 int extraEntries()
          Number of under and overflow entries in the histogram.
 void fill(double value)
          Fill histogram with a value
 void fill(double[] values)
          Fill histogram with array of double values
 void fill(double[] values, double[] weights)
          Fill histogram with array of double values.
 void fill(double value, double weight)
          Fill histogram a with weight
 void fill(int[] values)
          Fill histogram with array of integer values
 void fillInvBinSizeWeight(double value)
          Fill histogram with a value, weighting it by inverse of bin size.
 void fillP0D(P0D p0d)
          Fill histogram from P0D array
 hep.aida.ref.histogram.Histogram1D get()
          Get JAIDA histogram
 hep.aida.IAxis getAxis()
          Get histogram Axis class.
 int getBins()
          Get the number of bins
 double getEntropy()
          Returns the entropy of the histogram.
 double getMax()
          Get Maximum value of axis
 double getMin()
          Get Minimum value of the axis
 int getOverflow()
          Number of overflow entries
 double getOverflowlowHight()
          Overflow height
 java.lang.String getTitle()
          get Title of the histogram
 int getUnderflow()
          Number of underflow entries
 double getUnderflowHight()
          Underflow height
 double[][] getValues(int mode)
          Get positions in X,Y and Errors.
 double maxBinHeight()
          Max value of all bins
 double mean()
          Get mean of the histogram
 double minBinHeight()
          Min value of all bins
 H1D oper(double scale)
          Scale of the histogram.
 H1D oper(H1D a, java.lang.String what)
          Various manipulations with histograms (+,-,*,/).
 H1D oper(H1D a, java.lang.String title, java.lang.String what)
          Various manipulations with histograms (+,-,*,/).
 H1D oper(int scale)
          Scale histogram.
 H1D oper(java.lang.String title, double scale)
          Scale the histogram.
 H1D oper(java.lang.String title, int scale)
          Scale the histogram.
 H1D operScale(java.lang.String title, double scaleFactor)
          Scale the histogram.
 H1D operSmooth(boolean isWeighted, int k)
          Smooth the histogram.
 H1D operSmoothGauss(double standardDeviation)
          Computes a Gaussian smoothed version of the histogram.
 void print()
          Print histogram on screen
 double rms()
          Get RMS of histogram
 void setBins(int bins)
          Sets the number of bins
 void setContents(double[] values, double[] errors)
          Sets the content of H1D histogram.
 void setMax(double max)
          Set Maximum value of axis
 void setMeanAndRms(double mean, double rms)
          Sets the Mean and RMS of H1D histogram
 void setMin(double min)
          Set Min value of axis
 void setNEntries(int entries)
          Sets number of entries of H1D histogram.
 void setTitle(java.lang.String title)
          Sets the title
 void setValidEntries(int entries)
          Sets number of valid entries.
 double sumAllBinHeights()
          Sum of all heights
 void toFile(java.lang.String name)
          Write the H1D histogram to a file
 void toTable()
          Print a H1D histogram to a Table in a separate frame.
 void toTable(boolean format)
          Print the H1D histogram to a Table in a separate Frame.
 
Methods inherited from class jhplot.DrawOptions
copyLinePars, getBinWidth, getDrawOption, getDrawOptions, getLegend, getLineParm, getNameX, getNameY, getNameZ, getType, printDrawOptions, printDrawOptions, setBinWidth, setColor, setDrawLine, setDrawOption, setDrawSymbol, setErr, setErrAll, setErrColor, setErrColorX, setErrColorY, setErrFill, setErrFillColor, setErrFillColor, setErrSys, setErrSysFill, setErrSysFillColor, setErrSysFillColor, setErrSysX, setErrSysY, setErrTicSize, setErrX, setErrY, setFill, setFillColor, setFillColorTransparency, setGraphStyle, setLegend, setNameX, setNameY, setNameZ, setPenDash, setPenDash, setPenWidth, setPenWidthErr, setPenWidthErrSys, setStyle, setSymbol, setSymbolSize, setType
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

H1D

public H1D()
Build 1D histogram. Default constructor. Does not do anything.


H1D

public H1D(java.lang.String title,
           int bins,
           double min,
           double max)
Build 1D histogram

Parameters:
title - Title
bins - Number of bins
min - Minimum value
max - Maximum value

H1D

public H1D(java.lang.String title,
           double[] edges)
Create 1D histogram with variable bin size.

Parameters:
title - Title of histogram.
edges - edges

H1D

public H1D(hep.aida.ref.histogram.Histogram1D h1)
Create H1D histogram from JAIDA Histogram1D class.

Parameters:
h1 - Histogram1D histogram from JAIDA

H1D

public H1D(hep.aida.IHistogram1D h1)
Create H1D histogram from JAIDA IHistogram1D class

Parameters:
h1 - IHistogram1D histogram from JAIDA

H1D

public H1D(java.lang.String title,
           H1D h1d)
Create H1D from another instance.

Parameters:
title - new title
h1d - input H1D

H1D

public H1D(hep.io.root.interfaces.TH1 h1t)
Create H1D histogram from JAIDA TH1 histogram class

Parameters:
h1t - TH1 histogram from JAIDA
Method Detail

print

public void print()
Print histogram on screen


toTable

public void toTable()
Print a H1D histogram to a Table in a separate frame. The numbers are formatted to scientific format. One can sort and search the data in this table (cannot be modified).


fillP0D

public void fillP0D(P0D p0d)
Fill histogram from P0D array

Parameters:
p0d - input P0D array

getAxis

public hep.aida.IAxis getAxis()
Get histogram Axis class.

Returns:
Axis used for this histogram.

binCenter

public double binCenter(int index)
Get bin centres.

Parameters:
index - bin index
Returns:
bin centre.

binCenters

public double[] binCenters()
Get all bin centers in form of array

Returns:
double[] array of bin centers

binLowerEdge

public double binLowerEdge(int index)
Get bin lower edge.

Parameters:
index - bin index
Returns:
lower edge

binLowerEdges

public double[] binLowerEdges()
Get all lower edges in form of array

Returns:
double[] array of low edges

binUpperEdge

public double binUpperEdge(int index)
Get bin upper edge.

Parameters:
index - bin index
Returns:
upper edge

binUpperEdges

public double[] binUpperEdges()
Get all upper edges in form of array

Returns:
double[] array of upper edges

toTable

public void toTable(boolean format)
Print the H1D histogram to a Table in a separate Frame. One can sort and search the data in this table (but not modify)

Parameters:
format - if true, the numbers will be formatted using the Java scientific format.

toFile

public void toFile(java.lang.String name)
Write the H1D histogram to a file

Parameters:
name - File name

setContents

public void setContents(double[] values,
                        double[] errors)
Sets the content of H1D histogram. Start from 1 to bins+2.

Parameters:
values - array with values in Y (dimension: bins + 2)
errors - array with errors on Y (dimension: bins + 2)

setMeanAndRms

public void setMeanAndRms(double mean,
                          double rms)
Sets the Mean and RMS of H1D histogram

Parameters:
mean - mean of the histogram
rms - RMS to be set

setNEntries

public void setNEntries(int entries)
Sets number of entries of H1D histogram.

Parameters:
entries - Number of entries

setValidEntries

public void setValidEntries(int entries)
Sets number of valid entries.

Parameters:
entries - Number of valid entries

setTitle

public void setTitle(java.lang.String title)
Sets the title

Overrides:
setTitle in class DrawOptions
Parameters:
title - Title

getTitle

public java.lang.String getTitle()
get Title of the histogram

Overrides:
getTitle in class DrawOptions
Returns:
Title of histogram

get

public hep.aida.ref.histogram.Histogram1D get()
Get JAIDA histogram

Returns:
JAIDA Histogram1D histogram

setMin

public void setMin(double min)
Set Min value of axis

Parameters:
min - Minimum value of axis

getMin

public double getMin()
Get Minimum value of the axis

Returns:
Minimum value of the axis

setMax

public void setMax(double max)
Set Maximum value of axis

Parameters:
max - Maximum value of axis

getMax

public double getMax()
Get Maximum value of axis

Returns:
Maximum value of axis

setBins

public void setBins(int bins)
Sets the number of bins

Parameters:
bins - Number of bins

getBins

public int getBins()
Get the number of bins

Returns:
Number of bins

fill

public void fill(double value)
Fill histogram with a value

Parameters:
value - Value to be filled

fill

public void fill(double[] values)
Fill histogram with array of double values

Parameters:
values - array of double values

fill

public void fill(double[] values,
                 double[] weights)
Fill histogram with array of double values. Take into account weights.

Parameters:
values - array of double values
weights - array of double weights

fill

public void fill(int[] values)
Fill histogram with array of integer values

Parameters:
values - array of integer values

fill

public void fill(double value,
                 double weight)
Fill histogram a with weight

Parameters:
value - Value to be filled
weight - Weight of the value

mean

public double mean()
Get mean of the histogram

Returns:
Mean of histogram

rms

public double rms()
Get RMS of histogram

Returns:
RMS of histogram

allEntries

public int allEntries()
Get number of all entries

Returns:
Number of all entries

extraEntries

public int extraEntries()
Number of under and overflow entries in the histogram.

Returns:
Number of under and overflow entries

entries

public int entries()
Number of in-range entries in the histogram

Returns:
Number of in-range entries

getUnderflow

public int getUnderflow()
Number of underflow entries

Returns:
Number of underflow

getUnderflowHight

public double getUnderflowHight()
Underflow height

Returns:
height of underflow

getOverflowlowHight

public double getOverflowlowHight()
Overflow height

Returns:
Height of underflow

getOverflow

public int getOverflow()
Number of overflow entries

Returns:
Number of overflow entries

oper

public H1D oper(double scale)
Scale of the histogram. No new object created.

Parameters:
scale - Scaling factor
Returns:
same histogram but scaled.

fillInvBinSizeWeight

public void fillInvBinSizeWeight(double value)
Fill histogram with a value, weighting it by inverse of bin size. Should be useful for histograms with irregular binning.

Parameters:
value - Value to filled histogram with.

oper

public H1D oper(int scale)
Scale histogram. Keep original title. Note: no new object created.

Parameters:
scale - Scale factor
Returns:
same histogram but scale.

oper

public H1D oper(java.lang.String title,
                int scale)
Scale the histogram. Note: no new histogram object created.

Parameters:
title - New title
scale - Scale factor
Returns:
same histogram but scaled.

oper

public H1D oper(java.lang.String title,
                double scale)
Scale the histogram. Note: no new object created.

Parameters:
title - New title
scale - Scale factor
Returns:
same histogram but scaled.

operScale

public H1D operScale(java.lang.String title,
                     double scaleFactor)
Scale the histogram. Note: no new object created.

Parameters:
title - New title
scaleFactor - Scale factor
Returns:
the same H1D histogram object but scaled

operSmooth

public H1D operSmooth(boolean isWeighted,
                      int k)
Smooth the histogram.

Each band of the histogram is smoothed by averaging over a moving window of a size specified by the method parameter: if the value of the parameter is k then the width of the window is 2*k + 1. If the window runs off the end of the histogram only those values which intersect the histogram are taken into consideration. The smoothing may optionally be weighted to favor the central value using a "triangular" weighting. For example, for a value of k equal to 2 the central bin would have weight 1/3, the adjacent bins 2/9, and the next adjacent bins 1/9. Errors are kept the same as before.

Parameters:
isWeighted - Whether bins will be weighted using a triangular weighting scheme favoring bins near the central bin.
k - The smoothing parameter which must be non-negative. If zero, the histogram object will be returned with no smoothing applied.
Returns:
A smoothed version of the histogram.

operSmoothGauss

public H1D operSmoothGauss(double standardDeviation)
Computes a Gaussian smoothed version of the histogram.

Each band of the histogram is smoothed by discrete convolution with a kernel approximating a Gaussian impulse response with the specified standard deviation.

Parameters:
standardDeviation - The standard deviation of the Gaussian smoothing kernel which must be non-negative or an IllegalArgumentException will be thrown. If zero, the histogram object will be returned with no smoothing applied.
Returns:
A Gaussian smoothed version of the histogram.

getEntropy

public double getEntropy()
Returns the entropy of the histogram.

The entropy is defined to be the negation of the sum of the products of the probability associated with each bin with the base-2 log of the probability.

Returns:
The entropy of the histogram.

copy

public H1D copy()
Make a copy of the data holder

Returns:
New data holder

copy

public H1D 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

binEntries

public double binEntries(int index)
Number of entries in a bin with index i

Parameters:
index - Bin index
Returns:
Number of entries

binError

public double binError(int index)
Error on the bin with index i

Parameters:
index - Bin index
Returns:
Error

binHeight

public double binHeight(int index)
Height of the corresponding bin

Parameters:
index - Bin index
Returns:
Bin Height

binHeights

public double[] binHeights()
Get all heights of the histogram as an array

Returns:
array with histogram heights.

binErrors

public double[] binErrors()
Get all bin errors of the histogram as an array

Returns:
array with histogram errors.

binMean

public double binMean(int index)
Mean in a single bin with index

Parameters:
index - Bin index
Returns:
Mean value inside of this bin

binRms

public double binRms(int index)
RMS of a single bin with index

Parameters:
index - Bin index
Returns:
RMS of this bin

maxBinHeight

public double maxBinHeight()
Max value of all bins

Returns:
Max value

minBinHeight

public double minBinHeight()
Min value of all bins

Returns:
Min value

sumAllBinHeights

public double sumAllBinHeights()
Sum of all heights

Returns:
Sum of all Heights

oper

public H1D oper(H1D a,
                java.lang.String what)
Various manipulations with histograms (+,-,*,/). Keep the original title. No new histogram object created.

Parameters:
a - H1D histogram.
what - String representing the operation: "+" add a histogram to the original "-" subtract a histogram from the original "*" multiply "/" divide
Returns:
modified H1D histogram

getValues

public double[][] getValues(int mode)
Get positions in X,Y and Errors. For x, we take mean values

Parameters:
mode - if =1, take center of the bins. In all other cases - mean value in each bin
Returns:
array with X,Y, and Error on Y, double[3][bins];

oper

public H1D oper(H1D a,
                java.lang.String title,
                java.lang.String what)
Various manipulations with histograms (+,-,*,/). Note: no new object will be created.

Parameters:
a - H1D histogram.
title - New Title
Returns:
same H1D object but modified


jHepWork 1.1 (C) Chekanov