Histogram operations (subtract,add,multiply,divide) using H1D
Code: "histo3_oper.py". Programming language: Python
DMelt Version 1. Last modified: 12/11/2015. License: Pro
https://datamelt.org/code/cache/histo3_oper_7110.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 java.awt import Color,Font
from java.util import Random
from jhplot import HPlot,H1D
c1 = HPlot("Canvas",600,400,3,1)
c1.setGTitle("Histogram operations", Color.blue)
c1.visible(1)
c1.setAutoRangeAll()
h1 = H1D("e^{+}e^{-} → W^+{}W^{-} → 4 jets",10, -2.0, 2.0)
h2 = H1D("e^{+}e^{-} → W^+{}W^{-} → 4 jets",10, -2.0, 2.0)
rand = Random()
# fill histogram
for i in range(5000):
h1.fill(rand.nextGaussian())
if (i<2000): h2.fill(rand.nextGaussian())
c1.cd(1,1)
c1.draw(h1);
h3=h1.oper(h2,"subtract","-")
h3.setColor(Color.red)
c1.draw(h3);
h4=h1.oper(h2,"add","+")
h4.setColor(Color.blue)
c1.draw(h4);
# it is implemented in JAIDA?
c1.cd(2,1)
h5=h1.oper(h2,"multiply","*")
h5.setColor(Color.green)
c1.draw(h5)
c1.cd(3,1)
h6=h1.oper(h2,"divide","/")
c1.draw(h6)
You see the box below because you did not login.