Skip to content

Instantly share code, notes, and snippets.

@pgjones
Last active December 15, 2015 10:29
Show Gist options
  • Save pgjones/5245595 to your computer and use it in GitHub Desktop.
Save pgjones/5245595 to your computer and use it in GitHub Desktop.
Load and edit a RAT SOC TTree in python
import ROOT
import rat
import sys
file_ = ROOT.TFile(sys.argv[1])
tree = file_.Get("T")
soc = ROOT.RAT.DS.SOC()
run_tree = file.Get("runT")
tree.SetBranchAddress("soc", soc)
for iEntry in range(0, tree.GetEntries()):
tree.GetEntry(iEntry)
print soc.GetRunID()
# Edit...
new_file = ROOT.TFile(sys.argv[2])
run_tree.Write()
new_tree = ROOT.TTree("T", "SOC Tree")
new_tree.Branch("soc", soc.ClassName(), soc, 32000, 99 )
soc.Fill()
new_tree.Write()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment