Beispiel #1
0
f = root_open("chaintest1.root", "recreate")

tree = Tree("test")
branches = {'x': 'F', 'y': 'F', 'z': 'F', 'i': 'I'}
tree.create_branches(branches)

for i in range(10000):
    tree.x = gauss(.5, 1.)
    tree.y = gauss(.3, 2.)
    tree.z = gauss(13., 42.)
    tree.i = i
    tree.fill()

# Make a histogram of x when y > 1
hist1 = Hist(100, -10, 10, name='hist1')
tree.Draw('x', 'y > 1', hist=hist1)
hist1.SetDirectory(0)  # memory resident
print("The first tree has {0:f} entries where y > 1".format(hist1.Integral()))

tree.write()
f.close()

print("Creating test tree in chaintest2.root")
f = root_open("chaintest2.root", "recreate")

tree = Tree("test")
tree.create_branches(branches)

for i in range(10000):
    tree.x = gauss(.5, 1.)
    tree.y = gauss(.3, 2.)
Beispiel #2
0
print "Creating test tree in chaintest1.root"
f = open("chaintest1.root", "recreate")

tree = Tree("test")
tree.create_branches([('x', 'F'), ('y', 'F'), ('z', 'F'), ('i', 'I')])

for i in xrange(10000):
    tree.x = gauss(.5, 1.)
    tree.y = gauss(.3, 2.)
    tree.z = gauss(13., 42.)
    tree.i = i
    tree.fill()

# Make a histogram of x when y > 1
hist1 = tree.Draw('x', 'y > 1', min=-10, max=10, bins=100).Clone()
hist1.SetName('hist1')
hist1.SetDirectory(0)  # memory resident
print "The first tree has %f entries where y > 1" % hist1.Integral()

tree.write()
f.close()

print "Creating test tree in chaintest2.root"
f = open("chaintest2.root", "recreate")

tree = Tree("test")
tree.create_branches([('x', 'F'), ('y', 'F'), ('z', 'F'), ('i', 'I')])

for i in xrange(10000):
    tree.x = gauss(.5, 1.)