HTL - The Histogram Template Library

The Histogram Template Library (HTL) is a C++ class library that provides powerful histogramming functionality.
As the name suggests, it exploits the template facility of C++ and is designed to be compact, extensible, modular and performant.
As such it only deals with histograms - i.e. binned data - and not unbinned or "Ntuple" data. Furthermore, although simple
file-based I/O and "lineprinter" output are supported, it is decoupled from more advanced I/O and visualisation techniques.
In the context of LHC++, such capabilities are provided by other components that fully interoperate with HTL.
HTL comes in two flavours:


 Cern Installation
 Installing/getting HTL from outside Cern
 Building your own version of HTL
 Current release
 Known bugs and limitations
 A Python script to transform HTL output into HBOOK output (author Nikolas Kauer)


HTL installation at Cern

HTL is part of the LHC++ package release. Libraries and include files are located at:


A copy of the checkout repository including examples is located at:


The Windows/NT version of HTL is available on Nice as well at:

Libraries are installed as DLL, but since we exported only a subset of the library, users may find symbols which are not exported. In this case please let us know so that we can export the missing class/methods. A small batch file wich sets up the environment to use HTL is available as:


Have a look at the script, modify it if necessary and just run it from a MS-DOS window. Be aware the NT version relies on Cygnus GNU utilities rather than on Visual C++ projects to compile and link examples (although the underlying compiler is VC++).

Getting HTL from outside Cern

If you're willing to get the whole LHC++ HEP stuff (i.e. excluding Objectivity/DB and Nag C libraries) or a copy of the source code to build your own transient HTL, have a look at our  distribution page .

Building your own version of HTL

In order to build your own version of HTL:

Release status

The current production release is version There are parallel directories named 1.X.Y.Z which contain the latest version of the library. Be aware such directories are by definition instable. A short list of release features is contained in the file README_VERSIONS which exists in the HTL subdirectory.

Inside each HTL release, the file release_notes gives more detailed information about the fixes (from version onwards).

Known Bugs/Limitations


Incorrect bin centers on a slice/projection

The 1D histogram resulting from a slice or projection of a 2D histogram  does contain wrong information for the bin centers. The centers are all equal to 0.5 rather then being set to the true bin center.

X and Y projections of a 2D histogram are swapped

The xProject() and yProject() methods of the 2D helpers are actually producing the wrong projection, i.e. xProject() produces the Y projection and viceversa.

These bugs have been solved in releases and

Problems with NaN

Trying to fill an HTL histogram with a NaN (Not A Number) can result in weird HTL messages such as:

Assertion failed: an_index >= 0 && an_index <= count_, file Even_Partition.cpp, line 103

It's very likely some NaN checking code will be introduced on the next HTL release.

This limitation has been solved in release

Assertion failures doing binary operations

These bugs have been fixed in version

Version (LHC++ 99a release)

These bugs/limitations have been fixed in version (aka Sept99).

A Python script to transform HTL output into HBOOK output

Nikolas Kauer has written a Python script that transforms the "raw" HTL output in the good old HBOOK output ( download )