Histogram arithmetic using Jaida and Java
Code: "jaida_HistogramArithmetic.java". Programming language: Java
DMelt Version 1. Last modified: 12/11/2015. License: Pro
https://datamelt.org/code/cache/jaida_HistogramArithmetic_5366.java
To run this script using the DMelt IDE,
copy the above URL link to the menu [File]→[Read script from URL] of the DMelt IDE.
import hep.aida.*;
import java.util.Random;
public class jaida_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();
}
}
You see the box below because you did not login.