Accessing existing Histograms and Ntuples

Accessing existing Histograms and Ntuples


Although the primary use of this Histograms package is to create and fill Histograms and Ntuples, for later use by viewing tools, two further capabilities are provided: This page addresses issues concerning access to existing Histograms and Ntuples.

Constructing an object refering to an existing Histogram

As in the case of creating a fresh Histogram (or Ntuple), the constructor must specify which HepFileManager instance to use, and which Histogram within that manager to connect to. For an existing Histogram, the constructor need not supply all the details characterizing the Histogram (bins, ranges, and so forth).

  1. It is recommended that the user invoke manager methods to check that the required Histogram (or Ntuple) exists: Methods accepting an id instead of the title are also provided:

  2. Methods of the manager are available to create each type of a Histogram without supplying characteristics: These method names have "new" in them, refering to the fact that this Histogram object is newly created for this program, and the pointer should be deleted when the Histogram access is no longer needed.

    The characteristics of the Histogram will be obtained automatically from the manager, and set for the constructed Histogram. Each Histogram class has methods to access this class information.

  3. The user may instead provide the full specification of the characteristics of a Histogram. If the Histogram exists, and the characteristics supplied conflict with those known to the manager for that Histogram, an exception will be thrown.

  4. The user may now utilize read-access methods such as to find the contents of the bins.
    The user may also continue to fill the Histogram (that is, "update" the data) by invoking its accumulate() method.

Constructing an object refering to an existing Histogram

The pertinent difference between accessing existing Ntuples and accessing existing Histograms stems from the way an Ntuple is specified. The characteristics of an Ntuple are not fully specified in its constructor: A series of methods defining blocks and columns, and selecting storage strategies, must be called before data accumulation may commence.

FlatNtuple

Since the constructor for a fresh FlatNtuple does contain definition of its characteristics, a FlatNtuple behaves like a Histogram in this respect. Cosntructors are available to construct a FlatNtuple (which must match an existing one in the manager) without supplying characteristics:

The post-constructor characteristic definition methods for a FlatNuple specify only storage strategies. The user should not invoke these when accessing an existing FlatNtuple; attempting to define inconstistent characteristics will throw an exception.

Ntuple

Unlike Histograms and FlatNuples, general Ntuples must invoke methods after construction to define characteristics. Even retrieving data from an existing Ntuple requires specification of column and block information for those columns/blocks desired.

  1. The HepNtuple object is constructed. This is the same whether a fresh or existing Ntuple is desired, though an existing Ntuple may be selected by id rather than title. Again, this can be done by a method of
  2. The characteristics of any columns and blocks the user will wish to access must be supplied. For each column, the basic column method, should be called: Note that this not only defines the column tag (which one could get from the manager in priciple), but also specifies a "designated variable) to use when placing the retrieved value.
    None of the optional methods to define packing, array dimensions, index or default should be called for existing Ntuples; if they are called, conflicting information will throw an exception.

    For each block that may be accessed as a whole block, the user must invoke the method to define that block:

    Unless the method supplying CHForm to define all its columns is used, each column within the block must also be defined, as above.

    Finally, if the Ntuple is to be updated (adding more rows), or if the data will be retrieved by entire row, each block in the Ntuple must be defined.


Return to Zoom Histograms Package Documentation

Mark Fischler
Last modified: Fri May 30 1997