Line-printer and ASCII table output

Printing a histogram in text mode is required in a number of cases. For example, it can be useful for long batch jobs, where the user is mainly interested in checking the quality of data.

HTL provides a text print helper for this purpose, that is largely reused from the previous HistOOgrams packages.

The following example shows how the print method can be invoked to generate a simple line-printer style representation of a histogram.

#include "HTL/Histograms.h" // Transient histograms.

Histo1D *histot = new Histo1D("Transient Histo_1D", 20, 0.0, 20.0 ); 
HepRef(PHisto2D) histop = 
  new PHisto2D("Persistent Histo_2D", 20, 0.0, 20.0, 20, 0.0, 20.0 ); 
... 
HPrinter hp( cout ); 
hp.print( *histop ); 
hp.print( *histot ); 
delete histot; 

The above example demonstrates the use of the abstract histogram interface: the same helper object can print any histogram that conforms to the interface, regardless of whether it is transient, persistent, 1D, 2D and so forth.

Particularly when working with transient HTL, it can be convenient to dump a histogram in a simple ASCII table that can then be read by standard tools (PAW, Excel, IRIS Explorer...) to plot or fit it.

#include "HTL/Histograms.h" // Transient histograms.

T_Histo1D *histo = new Histo1D("Histo_1D", 20, 0.0, 20.0 ); 
... 
HistoTable1D ht1 ("histo.txt"); 
ht1.write(*histo); 
delete histo;