from ROOT import TFile file = TFile("tree.root",'update') # make directory if it does not exist dir = file.GetDirectory("dir") if not dir: print ">>> created dir" dir = file.mkdir("dir") # make this directory the current one: everything you write will be saved here dir.cd() # make tree, histogram, ... file.Write("",TFile.kOverwrite) file.Close()