This is a simple script which take //one// input argument and creates a file with a tree. import sys from ROOT import TFile, TTree, gRandom from array import array if len(sys.argv)<2: print ">>> ERROR! No input arguments given." exit(1) print ">>> input = \"%s\""%(sys.argv[1]) name = sys.argv[1] file = TFile("tree_%s.root"%(name), 'recreate') tree = TTree("tree_name", "tree title") px = array('d',[0]) phi = array('d',[0]) tree.Branch("px", px, 'normal/D') tree.Branch("phi", phi, 'uniform/D') print ">>> filling tree \"%s\""%(tree.GetName()) for i in xrange(10000): px[0] = gRandom.Gaus(20,2) phi[0] = gRandom.Uniform(2*3.1416) tree.Fill() print ">>> write to file \"%s\""%(file.GetName()) file.Write() file.Close() print ">>> done"