hep.analysis
Class Histogram

java.lang.Object
  |
  +--hep.analysis.AbstractNamedObject
        |
        +--hep.analysis.Histogram
All Implemented Interfaces:
NamedObject, java.io.Serializable
Direct Known Subclasses:
DerivedHistogram, EfficiencyPlot, Histogram1D, Histogram2D, ProfilePlot, ScatterPlot

public class Histogram
extends AbstractNamedObject

Class Histogram is used by user analysis programs to create and fill a wide variety of histograms. Histograms must each have unique names assigned to them at creation time.

Each histogram must have its own partition. You can set the partition using the setPartition() method, but if you don't, a default partition will be selected the first time you invoke a fill(..) method. The partition used will depend on which fill method you call. The Histogram class is designed to be easy to fill. If you want to be able to extract information about a histogram after you have filled it you would probably do better to use one of the subclasses of Histogram, which have extra convenience functions for accessing information about the histogram.

See Also:
Serialized Form

Inner classes inherited from class hep.analysis.NamedObject
NamedObject.RenameException
 
Field Summary
protected  Partition m_partition
           
 
Fields inherited from class hep.analysis.AbstractNamedObject
m_parent
 
Constructor Summary
Histogram(java.lang.String name)
          Create a new histogram.
Histogram(java.lang.String name, HistogramFolder parent)
          Create a new histogram in a folder.
Histogram(java.lang.String name, HistogramFolder parent, Partition partition)
          Create a new histogram in a specified folder and with the specified Partition
Histogram(java.lang.String name, Partition partition)
          Create a histogram with a specified partition in the current default histogram folder.
 
Method Summary
 void clear()
          Clears the histogram contents
 void fill(java.util.Date x)
          Fill a histogram with a single date.
 void fill(java.util.Date x, double y)
           
 void fill(double x)
          Fill a histogram with a single double.
 void fill(double x, double y)
           
 void fill(int x)
          Fill a histogram with a single int.
 void fill(java.lang.String x)
          Fill a histogram with a single string.
 void fillW(java.util.Date x, double value)
          Fill a histogram with a single date.
 void fillW(java.util.Date x, double y, double weight)
           
 void fillW(double x, double value)
          Fill a histogram with a single double.
 void fillW(double x, double y, double weight)
           
 void fillW(int x, double value)
          Fill a histogram with a single int.
 void fillW(java.lang.String x, double value)
          Fill a histogram with a single string.
static Histogram find(java.lang.String name)
          Returns the Histogram object with the given name.
static Histogram find(java.lang.String name, HistogramFolder parent)
          Returns the Histogram object with the given name.
protected  Folder getDefaultParent()
          Get default parent is called when an object is read in with no parent Folder.
 int getEntries()
          Get the number of times this histogram has been filled
 Partition getPartition()
          Returns the partition used by this histogram.
 Style getStyle()
          Get the histogram style
 boolean isClearOnRewind()
          True if the histogram should be cleared when the data is rewound
 void partitionDestroyedNotify()
          Notifies the histogram that the partition has been destroyed.
 void setClearOnRewind(boolean value)
          Sets if the histogram should be cleared when the data is rewound.
 void setPartition(Partition p)
          Use this method to set the partition for this histogram.
 void setStyle(Style style)
           
 void show()
          Requests that this histogram be made visible to the user.
 java.lang.String toString()
           
 
Methods inherited from class hep.analysis.AbstractNamedObject
delete, getFolder, getName, rename
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_partition

protected Partition m_partition
Constructor Detail

Histogram

public Histogram(java.lang.String name)
Create a new histogram.
Parameters:
name - The name of the histogram. If a histogram of this name already exists its contents are cleared and a reference to the previously existing histogram is returned.

Histogram

public Histogram(java.lang.String name,
                 HistogramFolder parent)
Create a new histogram in a folder.
Parameters:
name - The name of the histogram. If a histogram of this name already exists its contents are cleared and a reference to the previously existing histogram is returned.
parent - the HistogramFolder in which to store this Hsitogram

Histogram

public Histogram(java.lang.String name,
                 Partition partition)
Create a histogram with a specified partition in the current default histogram folder.

Histogram

public Histogram(java.lang.String name,
                 HistogramFolder parent,
                 Partition partition)
Create a new histogram in a specified folder and with the specified Partition
Method Detail

fill

public void fill(double x)
Fill a histogram with a single double. This method creates a SimplePartition if no partition has been set, and fills the partition with the given value.
Parameters:
x - X coordinate
See Also:
SimplePartition

fillW

public void fillW(double x,
                  double value)
Fill a histogram with a single double. This method creates a SimplePartition if no partition has been set, and fills the partition with the given value.
Parameters:
x - X coordinate
value - Value (weight) to be assigned to this fill operation
See Also:
SimplePartition

fill

public void fill(int x)
Fill a histogram with a single int. This method creates a SimpleIntPartition if no partition has been set, and fills the partition with the given value.
Parameters:
x - X coordinate
See Also:
SimpleIntPartition

fillW

public void fillW(int x,
                  double value)
Fill a histogram with a single int. This method creates a SimpleIntPartition if no partition has been set, and fills the partition with the given value.
Parameters:
x - X coordinate
value - Value (weight) to be assigned to this fill operation
See Also:
SimpleIntPartition

fill

public void fill(java.lang.String x)
Fill a histogram with a single string. This method creates a StringPartition if no partition has been set, and fills the partition with the given value.
Parameters:
x - String value to fill
See Also:
StringPartition

fillW

public void fillW(java.lang.String x,
                  double value)
Fill a histogram with a single string. This method creates a StringPartition if no partition has been set, and fills the partition with the given value.
Parameters:
x - String value to fill
value - Value (weight) to be assigned to this fill operation
See Also:
StringPartition

fill

public void fill(java.util.Date x)
Fill a histogram with a single date. This method creates a SimpleDatePartition if no partition has been set, and fills the partition with the given value.
Parameters:
x - Date value to fill
See Also:
SimpleDatePartition

fillW

public void fillW(java.util.Date x,
                  double value)
Fill a histogram with a single date. This method creates a SimpleDatePartition if no partition has been set, and fills the partition with the given value.
Parameters:
x - Date value to fill
value - Value (weight) to be assigned to this fill operation
See Also:
SimpleDatePartition

fill

public void fill(double x,
                 double y)

fillW

public void fillW(double x,
                  double y,
                  double weight)

fill

public void fill(java.util.Date x,
                 double y)

fillW

public void fillW(java.util.Date x,
                  double y,
                  double weight)

show

public void show()
Requests that this histogram be made visible to the user. The effectiveness of the request will depend on the environment in which the job is running.

clear

public void clear()
Clears the histogram contents

getEntries

public int getEntries()
Get the number of times this histogram has been filled

setPartition

public void setPartition(Partition p)
Use this method to set the partition for this histogram. If you do not set a partion, a default partition will be used the first time you call a fill(..) method. The type of partition will depend on which fill(..) method you use. See the notes on the individual fill(..) methods to see which default is used.

partitionDestroyedNotify

public void partitionDestroyedNotify()
Notifies the histogram that the partition has been destroyed.

getPartition

public Partition getPartition()
Returns the partition used by this histogram.

find

public static Histogram find(java.lang.String name)
Returns the Histogram object with the given name. Looks in the default folder. If it doesn't find one, it creates it in the current folder.
Parameters:
name - the name of the histogram to find
Returns:
the Histogram object with the name given by the parameter name.

find

public static Histogram find(java.lang.String name,
                             HistogramFolder parent)
Returns the Histogram object with the given name. Looks in the given folder. If it doesn't find one, it creates it in the named folder.
Parameters:
name - the name of the histogram to find
parent - the folder to look in
Returns:
the Histogram object with the name given by the parameter name.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

setStyle

public void setStyle(Style style)
Parameters:
style - The style to be used when displaying this histogram

getStyle

public Style getStyle()
Get the histogram style
Returns:
The style to be used when displaying this histogram

getDefaultParent

protected Folder getDefaultParent()
Description copied from class: AbstractNamedObject
Get default parent is called when an object is read in with no parent Folder. Concrete classes must provide an implementation of this method.
Overrides:
getDefaultParent in class AbstractNamedObject

isClearOnRewind

public boolean isClearOnRewind()
True if the histogram should be cleared when the data is rewound

setClearOnRewind

public void setClearOnRewind(boolean value)
Sets if the histogram should be cleared when the data is rewound. The histogram will only be cleared if all the folders in which it is contained have thier isClearOnRewind flags set as well.