TRF++ Utility Classes (package trfutil)

27nov00 1105
Code version 0.63

An introduction to TRF++ may be found at http://www-d0.fnal.gov/~dladams/trf.


Links to code

The description below includes links to the code contained in this package. This version of the code may not be the most recent.

Description

TRF++ package trfutil defines some utilities for use in other TRF++ packages. These classes and functions are not specific to track manipulation or finding. Some or all of these might be replaced with components from packages outside TRF++.

The physical components include:

Their dependencies are illustrated in the physical dependency diagram.

The (not up-to-date) class diagram shows some of the classes and their relationships.

This package depends on the following external packages:

The classes contained in these components are described below. Except where otherwise indicated, each class is contained in the component of the same name. The descriptions here are very brief. See the header files for more details.


Math utilities

The component TRFMath includes the standard header math.h and extends it by adding some mathematical constants (PI, TWOPI and PI2), some physical constants (CLIGHT and BFAC) and two modulus-related functions fmod1 amd fmod2.

There is also a template function is_equal which provides for the comparison of two floating point values allowing for some numerical roundoff.

Vectors and matrices

The next four components define a series of classes for vector and matrix manipulation. These include the base class array which describes a fixed-length array and subclasses nvector, smatrix and matrix which describe vectors, symmetric matrices and non-symmetric matrices, respectively. It is expected that these classes will be replaced and discarded and direct use is discouraged. The current implementation of TRF++ introduces wrappers to hide these classes. See components TrackVector and HitVector in package trfbase.

Random number classes

Function RandomSeed simply returns a new random number seed. Presently this seed is simply generated with the default random number generator.

The class RandomGenerator encapsulates a random number generator. It is contained in the component of the same name. The seed defining the state of the generator may be fetched or reset. Random numbers can be generated according to a flat or Gaussian distribution. Each instance is independent, i.e. uses its own random number engine.

Class RandomRegistry manages a collection of random generators. Generators may be added to the registry at any time. The state of all known generators may be recorded at one time and then recovered at another.

Class RandomSimulator provides the abstract interface for a class which will make use of one or more random generators. It defines a method to return the generators and implements a method to register them.

Match and Quality

Match is an abstract base template class which makes a on-to-one mapping between the elements in two STL containers. Elements in one container are matched with the nearest element in the other container. Concrete classes inherit from this base and provide the method _quality which returns an object of type Quality.

Concrete quality classes inherit from the base class Quality and define the objects and algorithm used to evaluate the quality. There is a method to indicate whether the quality is acceptable and a method that is used to compare one quality with another.

There are two concrete quality subclasses: InvalidQuality and SimpleQuality. Objects of the former type are always invalid and objects of the latter type are always valid and use a double (smaller is better) as their measure of quality. The Match method _quality may implemented in terms of these any time the quality of a match can be expressed in terms of a single discriminant.

Root finders

Class RootFinder is an abstract interface for a class that finds the root of an equation. Specific root-finding algorithms are created by inheriting from this base and implementing the method solve. Class RootFindLinear is an example which uses iterative linear interpolation (regula falsi). The equation to solve is specified by inheriting from a specific algorithm class and implementing the method evaluate.

The class StatusValue is a template for storing a status flag (integer) and a value of any type. Typedefs are provided for type int (StatusInt) and double (StatusDouble). The latter is probably most useful and is the return type for both of the RootFinder methods. It allows a double to be returned along with an index indicating if the called routine failed in some way. By convention, zero means success.

Tuple manager

The class TupleManager manages a file containing histograms and ntuples. There are static methods for creating these or accessing an existing one by name. A single instance of the manager is automatically created when the first histogram or ntuple is created and the file is written out from the destructor when the program terminates. At present, only ntuples (not histograms) are supported and only one file may be created.

The Tuple header file defines the typedef Tuple which describes an ntuple. At present, this corresponds to the CLHEP ntuple class HepTuple.

CpuTimerTuple

The class CpuTimerTuple stores event-based timing information in an ntuple.

EventID

The class EventID holds an event number and provides global access to the last event number.

Object streaming

The header trfstream.h defines some objects which are inserted into output streams. These include: See package objstream for details.

Container printing

STLprint provides functions for printing the contents of containers. There are separate functions for maps and for printing by value when entries are held by pointer.


Questions or comments to dladams@fnal.gov.