Plotting histograms and data arrays using Jaida
Code: "jaida_Tuple.py". Programming language: Python DMelt Version 1. Last modified: 12/08/2015. License: Pro
https://datamelt.org/code/cache/jaida_Tuple_4644.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 java.lang import *
from jhplot import *

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

r = Random()
      
columnNames  = [ "iFlat = 0", " fGauss = 3.", " fFlat =-2." ]
columnClasses = [ Integer.TYPE, Float.TYPE, Float.TYPE ]
      
tuple = tf.create( "tuple", "tupleLabel", columnNames, columnClasses, "");
      
for i in range(10000):
    tuple.fill(0, Integer( r.nextInt(20) ) );
    tuple.fill(1, Float( r.nextGaussian() ) );
    tuple.fill(2, Float( r.nextFloat() ) );
    tuple.addRow();
      
colG = tuple.findColumn("fGauss");
colF = tuple.findColumn("fFlat");
colI = tuple.findColumn("iFlat");
      
h1dI = hf.createHistogram1D("h1dI",50,tuple.columnMin(colI),tuple.columnMax(colI));
h1dF = hf.createHistogram1D("h1dF",50,tuple.columnMin(colF),tuple.columnMax(colF));
h1dG = hf.createHistogram1D("h1dG",50,tuple.columnMin(colG),tuple.columnMax(colG));
h2d = hf.createHistogram2D("h2d",50,tuple.columnMin(colG),tuple.columnMax(colG),
      50,tuple.columnMin(colF),tuple.columnMax(colF));
      
tuple.start();
while tuple.next() :
   h1dI.fill( tuple.getInt(colI) );
   h1dF.fill( tuple.getFloat(colF) );
   h1dG.fill( tuple.getFloat(colG) );
   h2d.fill( tuple.getFloat(colG), tuple.getFloat(colF) );


c1=HPlotter("Fits",800,800,2,2)
c1.visible()

c1.cd(1,1)
c1.draw(h1dI)

c1.cd(2,1)
c1.draw(h1dF)

c1.cd(1,2)
c1.draw(h1dG)

c1.cd(2,2)
c1.draw(h2d)

Ads help maintain this website.