AIDA supports 1D, 2D and 3D histograms. Creating histograms is quite straightforward using the methods in IHistogramFactory.
Histograms support arithmetic operations, in particular add, subtract, multiply and divide. In all cases the operation is applied bin-by-bin, and the histograms involved in the operation must have the same binning. The input histograms are unchanged, and a new histogram is created as the result of the operation. All of the arithmetic operations are methods of IHistogramFactory to reflect the fact that a new histogram is always created as a result of the operation. For multi-dimensional histograms it is also possible to create slices and projections.
The following example illustrates using histograms:
import hep.aida.*; import java.util.Random; public class HistogramArithmetic { public static void main(String[] argv) { IAnalysisFactory af = IAnalysisFactory.create(); IHistogramFactory hf = af.createHistogramFactory(af.createTreeFactory().create()); IHistogram1D h1 = hf.createHistogram1D("test 1d",50,-3,6); IHistogram1D h2 = hf.createHistogram1D("test 2d",50,-3,6); Random r = new Random(); for (int i=0; i<10000; i++) { h1.fill(r.nextGaussian()); h2.fill(3+r.nextGaussian()); } IHistogram1D plus = hf.add("h1+h2",h1,h2); IHistogram1D minus = hf.subtract("h1-h2",h1,h2); IHistogram1D mul = hf.multiply("h1*h2",h1,h2); IHistogram1D div = hf.divide("h1 over h2",h1,h2); IPlotter plotter = af.createPlotterFactory().create("Plot"); plotter.createRegions(2,2,0); plotter.region(0).plot(plus); plotter.region(1).plot(minus); plotter.region(2).plot(mul); plotter.region(3).plot(div); plotter.show(); } }
Table of Contents -- Next Section