Histogram operations using Jaida
Source code name: "histo_jaida.py"
Programming language: Python
Topic: Histograms/1D
DMelt Version 1. Last modified: 12/12/2015. License: Pro
https://datamelt.org/code/cache/histo_jaida_7638.py
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.


 
from hep.aida import IAnalysisFactory 
from java.util import Random
from jhplot import *

af   = IAnalysisFactory.create();
tree = af.createTreeFactory().create();
hf   = af.createHistogramFactory(tree);

r = Random(12345)
h1 = hf.createHistogram1D("test 1d",50,-3,6)
h2 = hf.createHistogram1D("test 2d",50,-3,6)
      
for i in range(10000):
   h1.fill(r.nextGaussian())
   h2.fill(3+r.nextGaussian())

plus = hf.add("h1+h2",h1,h2)
minus = hf.subtract("h1-h2",h1,h2)
mul = hf.multiply("h1*h2",h1,h2)
div = hf.divide("h1 divded by h2",h1,h2)


c1=HPlotter("ScansAndContour.py plot",700,600)
c1.visible()
plotter = c1.getPlotter()
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)


You see the box below because you did not login.