FreeHEP API
Version current

hep.aida.ref.histogram
Class Histogram2D

java.lang.Object
  extended byhep.aida.ref.event.AIDAObservable
      extended byhep.aida.ref.ManagedObject
          extended byhep.aida.ref.histogram.AbstractBaseHistogram
              extended byhep.aida.ref.histogram.Histogram
                  extended byhep.aida.ref.histogram.Histogram2D
All Implemented Interfaces:
Connectable, hep.aida.IBaseHistogram, hep.aida.dev.IDevManagedObject, hep.aida.IHistogram, hep.aida.IHistogram2D, hep.aida.IManagedObject, IsObservable

public class Histogram2D
extends Histogram
implements hep.aida.IHistogram2D

Source Code:
Histogram2D.java

Field Summary
 
Fields inherited from class hep.aida.ref.histogram.Histogram
allEntries, isFillable, sumOfWeights, sumOfWeightsSquared, validEntries, X_AXIS, Y_AXIS, Z_AXIS
 
Fields inherited from class hep.aida.ref.ManagedObject
fillable
 
Fields inherited from class hep.aida.ref.event.AIDAObservable
connectionDidChange, isConnected, isValid
 
Constructor Summary
  Histogram2D()
          Create a 2-dimensional Histogram.
  Histogram2D(String name, String title, hep.aida.IAxis xAxis, hep.aida.IAxis yAxis)
          Create a 2-dimensional Histogram.
protected Histogram2D(String name, String title, hep.aida.IAxis xAxis, hep.aida.IAxis yAxis, String options)
          Create a 2-dimensional Histogram.
 
Method Summary
 void add(hep.aida.IHistogram2D hist)
          Modifies this histogram by adding the contents of h to it.
 int binEntries(int indexX, int indexY)
          Number of entries in the corresponding bin (ie the number of times fill was called for this bin).
 int binEntriesX(int indexX)
          Number of entries with a given x bin number (ie the number of times fill was called for these bins).
 int binEntriesY(int indexY)
          Number of entries with a given y bin number (ie the number of times fill was called for these bins).
 double binError(int indexX, int indexY)
          The error on this bin.
 double binHeight(int indexX, int indexY)
          Total height of the corresponding bin.
 double binHeightX(int indexX)
          Total height of the corresponding x bin along y.
 double binHeightY(int indexY)
          Total height of the corresponding y bin along x.
 double binMeanX(int indexX, int indexY)
          Get the mean of a bin along the x axis.
 double binMeanY(int indexX, int indexY)
          Get the mean of a bin along the y axis.
 double binRmsX(int indexX, int indexY)
          Get the RMS of a bin along the x axis.
 double binRmsY(int indexX, int indexY)
          Get the RMS of a bin along the y axis.
 int coordToIndexX(double coordX)
          Convenience method, equivalent to xAxis().coordToIndex(coord).
 int coordToIndexY(double coordY)
          Convenience method, equivalent to yAxis().coordToIndex(coord).
 int extraEntries()
          Get the number of entries in the underflow and overflow bins.
 void fill(double x, double y)
          Fill the Histogram with unit weight.
 void fill(double x, double y, double weight)
          Fill the Histogram.
 void initHistogram2D(hep.aida.IAxis xAxis, hep.aida.IAxis yAxis, String options)
           
 double maxBinHeight()
          Get the maximum height of in-range bins in the Histogram.
 double meanX()
          Get the mean of the whole Histogram as projected on the x axis.
 double meanY()
          Get the mean of the whole Histogram as projected on the y axis.
 double minBinHeight()
          Get the minimum height of in-range bins in the Histogram.
 void reset()
          Reset the Histogram.
 double rmsX()
          Get the RMS of the whole Histogram as projected on the x axis.
 double rmsY()
          Get the RMS of the whole Histogram as projected on the y axis.
 void scale(double scaleFactor)
          Scale the weights and the errors by a given factor.
 void setBinError(int indexX, int indexY, double error)
          Set the error on this bin.
 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.
 void setMeanX(double meanX)
          All the non-AIDA methods should go below this point.
 void setMeanY(double meanY)
           
 void setRmsX(double rmsX)
           
 void setRmsY(double rmsY)
           
 double sumAllBinHeights()
          Get the sum of the bin heights for all the entries, in-range and out-range ones.
 double sumExtraBinHeights()
          Get the sum of the bin heights for all the entries outside the Histogram's range.
 hep.aida.IAxis xAxis()
          Get the X axis.
 hep.aida.IAxis yAxis()
          Get the Y axis.
 
Methods inherited from class hep.aida.ref.histogram.Histogram
allEntries, createEvent, entries, equivalentBinEntries, mapBinNumber, nanEntries, options, setNEntries, setUseOutflows, setValidEntries, sumBinHeights, useOutflows
 
Methods inherited from class hep.aida.ref.histogram.AbstractBaseHistogram
annotation, dimension, setAnnotation, setTitle, title
 
Methods inherited from class hep.aida.ref.ManagedObject
isFillable, name, setFillable, setName, type
 
Methods inherited from class hep.aida.ref.event.AIDAObservable
addListener, fireStateChanged, fireStateChanged, fireStateChanged, isConnected, removeAllListeners, removeListener, setConnected, setIsValidAfterNotify, setValid, setValidForAll
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface hep.aida.IHistogram
allEntries, equivalentBinEntries, sumBinHeights
 
Methods inherited from interface hep.aida.IBaseHistogram
annotation, dimension, entries, nanEntries, setTitle, title
 
Methods inherited from interface hep.aida.ref.event.IsObservable
addListener, removeAllListeners, removeListener, setValid
 
Methods inherited from interface hep.aida.ref.event.Connectable
isConnected, setConnected
 

Constructor Detail

Histogram2D

public Histogram2D()
Create a 2-dimensional Histogram.


Histogram2D

public Histogram2D(String name,
                   String title,
                   hep.aida.IAxis xAxis,
                   hep.aida.IAxis yAxis)
Create a 2-dimensional Histogram.

Parameters:
name - The name of the Histogram as a ManagedObject.
title - The title of the Histogram.
xAxis - The x-axis of the Histogram.
yAxis - The y-axis of the Histogram.

Histogram2D

protected Histogram2D(String name,
                      String title,
                      hep.aida.IAxis xAxis,
                      hep.aida.IAxis yAxis,
                      String options)
Create a 2-dimensional Histogram.

Parameters:
name - The name of the Histogram as a ManagedObject.
title - The title of the Histogram.
xAxis - The x-axis of the Histogram.
yAxis - The y-axis of the Histogram.
options - The options of the Histogram.
Method Detail

fill

public void fill(double x,
                 double y)
Fill the Histogram with unit weight.

Specified by:
fill in interface hep.aida.IHistogram2D
Parameters:
x - The x value to be filled.
y - The y value to be filled.

fill

public void fill(double x,
                 double y,
                 double weight)
Fill the Histogram.

Specified by:
fill in interface hep.aida.IHistogram2D
Parameters:
x - The x value to be filled.
y - The y value to be filled.
weight - The weight for this entry.

reset

public void reset()
Reset the Histogram. After calling this method the Histogram is as it was just created.

Specified by:
reset in interface hep.aida.IBaseHistogram
Overrides:
reset in class Histogram

extraEntries

public int extraEntries()
Get the number of entries in the underflow and overflow bins.

Specified by:
extraEntries in interface hep.aida.IHistogram
Specified by:
extraEntries in class Histogram
Returns:
The number of entries outside the range of the Histogram.

sumAllBinHeights

public double sumAllBinHeights()
Get the sum of the bin heights for all the entries, in-range and out-range ones.

Specified by:
sumAllBinHeights in interface hep.aida.IHistogram
Specified by:
sumAllBinHeights in class Histogram
Returns:
The sum of all the bin's heights.

sumExtraBinHeights

public double sumExtraBinHeights()
Get the sum of the bin heights for all the entries outside the Histogram's range.

Specified by:
sumExtraBinHeights in interface hep.aida.IHistogram
Specified by:
sumExtraBinHeights in class Histogram
Returns:
The sum of the out of range bin's heights.

minBinHeight

public double minBinHeight()
Get the minimum height of in-range bins in the Histogram.

Specified by:
minBinHeight in interface hep.aida.IHistogram
Specified by:
minBinHeight in class Histogram
Returns:
The minimum bin height for in range bins.

maxBinHeight

public double maxBinHeight()
Get the maximum height of in-range bins in the Histogram.

Specified by:
maxBinHeight in interface hep.aida.IHistogram
Specified by:
maxBinHeight in class Histogram
Returns:
The maximum bin height for in range bins.

binEntries

public int binEntries(int indexX,
                      int indexY)
Number of entries in the corresponding bin (ie the number of times fill was called for this bin).

Specified by:
binEntries in interface hep.aida.IHistogram2D
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.

binEntriesX

public int binEntriesX(int indexX)
Number of entries with a given x bin number (ie the number of times fill was called for these bins). Equivalent to projectionX().binEntries(indexX).

Specified by:
binEntriesX in interface hep.aida.IHistogram2D
Parameters:
indexX - the x bin number in the external representation: (0...N-1) or OVERFLOW or UNDERFLOW.
Returns:
The number of entries for the corresponding bins.

binEntriesY

public int binEntriesY(int indexY)
Number of entries with a given y bin number (ie the number of times fill was called for these bins). Equivalent to projectionY().binEntries(indexY).

Specified by:
binEntriesY in interface hep.aida.IHistogram2D
Parameters:
indexY - the y bin number in the external representation: (0...N-1) or OVERFLOW or UNDERFLOW.
Returns:
The number of entries for the corresponding bins.

binHeight

public double binHeight(int indexX,
                        int indexY)
Total height of the corresponding bin.

Specified by:
binHeight in interface hep.aida.IHistogram2D
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.

binHeightX

public double binHeightX(int indexX)
Total height of the corresponding x bin along y. Equivalent to projectionX().binHeight(indexX).

Specified by:
binHeightX in interface hep.aida.IHistogram2D
Parameters:
indexX - The x bin number in the external representation: (0...N-1) or OVERFLOW or UNDERFLOW.
Returns:
The bin height for the corresponding bin.

binHeightY

public double binHeightY(int indexY)
Total height of the corresponding y bin along x. Equivalent to projectionY().binHeight(indexY).

Specified by:
binHeightY in interface hep.aida.IHistogram2D
Parameters:
indexY - The y bin number in the external representation: (0...N-1) or OVERFLOW or UNDERFLOW.
Returns:
The bin height for the corresponding bin.

binError

public double binError(int indexX,
                       int indexY)
The error on this bin.

Specified by:
binError in interface hep.aida.IHistogram2D
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 error on the corresponding bin.

meanX

public double meanX()
Get the mean of the whole Histogram as projected on the x axis. It includes all the entries (in and out of range).

Specified by:
meanX in interface hep.aida.IHistogram2D
Returns:
The mean of the Histogram on the x axis.

meanY

public double meanY()
Get the mean of the whole Histogram as projected on the y axis. It includes all the entries (in and out of range).

Specified by:
meanY in interface hep.aida.IHistogram2D
Returns:
The mean of the Histogram on the y axis.

rmsX

public double rmsX()
Get the RMS of the whole Histogram as projected on the x axis. It includes all the entries (in and out of range).

Specified by:
rmsX in interface hep.aida.IHistogram2D
Returns:
The RMS of the Histogram on the x axis.

rmsY

public double rmsY()
Get the RMS of the whole Histogram as projected on the y axis. It includes all the entries (in and out of range).

Specified by:
rmsY in interface hep.aida.IHistogram2D
Returns:
The RMS of the Histogram on the y axis.

xAxis

public hep.aida.IAxis xAxis()
Get the X axis.

Specified by:
xAxis in interface hep.aida.IHistogram2D
Returns:
The x axis.

yAxis

public hep.aida.IAxis yAxis()
Get the Y axis.

Specified by:
yAxis in interface hep.aida.IHistogram2D
Returns:
The y axis.

coordToIndexX

public int coordToIndexX(double coordX)
Convenience method, equivalent to xAxis().coordToIndex(coord).

Specified by:
coordToIndexX in interface hep.aida.IHistogram2D
Returns:
The bin's index along the x axis corresponding to the position coordX.
See Also:
IAxis.coordToIndex(double)

coordToIndexY

public int coordToIndexY(double coordY)
Convenience method, equivalent to yAxis().coordToIndex(coord).

Specified by:
coordToIndexY in interface hep.aida.IHistogram2D
Returns:
The bin's index along the y axis corresponding to the position coordY.
See Also:
IAxis.coordToIndex(double)

scale

public void scale(double scaleFactor)
Scale the weights and the errors by a given factor.

Specified by:
scale in interface hep.aida.IHistogram
Specified by:
scale in class Histogram
Parameters:
scaleFactor - The scale factor.

add

public void add(hep.aida.IHistogram2D hist)
         throws IllegalArgumentException
Modifies this histogram by adding the contents of h to it.

Specified by:
add in interface hep.aida.IHistogram2D
Parameters:
hist - The histogram to be added to this histogram
Throws:
IllegalArgumentException - if histogram binnings are incompatible

setMeanX

public void setMeanX(double meanX)
All the non-AIDA methods should go below this point.


setRmsX

public void setRmsX(double rmsX)

setMeanY

public void setMeanY(double meanY)

setRmsY

public void setRmsY(double rmsY)

binMeanX

public double binMeanX(int indexX,
                       int indexY)
Get the mean of a bin along the x axis.

Specified by:
binMeanX in interface hep.aida.IHistogram2D
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 mean of the corresponding bin along x. If the bin has zero height, zero is returned.

binMeanY

public double binMeanY(int indexX,
                       int indexY)
Get the mean of a bin along the y axis.

Specified by:
binMeanY in interface hep.aida.IHistogram2D
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 mean of the corresponding bin along y. If the bin has zero height, zero is returned.

binRmsX

public double binRmsX(int indexX,
                      int indexY)
Get the RMS of a bin along the x axis.

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 RMS of the corresponding bin along x. If the bin has zero height, zero is returned.

binRmsY

public double binRmsY(int indexX,
                      int indexY)
Get the RMS of a bin along the y axis.

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 RMS of the corresponding bin along y. If the bin has zero height, zero is returned.

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.

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

initHistogram2D

public void initHistogram2D(hep.aida.IAxis xAxis,
                            hep.aida.IAxis yAxis,
                            String options)

FreeHEP API
Version current

Copyright © 2000-2004 FreeHEP, All Rights Reserved.