9 return [key.GetName()
for key
in gDirectory.GetListOfKeys()]
10 TFile.GetKeyNames = GetKeyNames
14 print "Too few arguments. Expected the following:"
15 print " 1. Output file"
16 print " 2. Primary input file (to be overwritten in parts)"
17 print " 3. New input file (to use to overwrite parts)"
18 print " 4. Optional: whether to interpret new histograms (TRUE) as additions or to exit (FALSE)"
21 outFile = TFile.Open(sys.argv[1],
"RECREATE")
22 primaryFile = TFile.Open(sys.argv[2],
"READ")
23 updateFile = TFile.Open(sys.argv[3],
"READ")
24 addNew =
True if len(sys.argv) > 4
and (sys.argv[4] ==
"TRUE" or sys.argv[4] ==
"True" or sys.argv[4] ==
"true")
else False
29 for histName
in updateFile.GetKeyNames():
30 hist = updateFile.Get(histName)
32 updates[histName] = hist
37 for histName
in updates.keys():
38 if not histName
in primaryFile.GetKeyNames():
40 print "Failed to find the original histogram to replace for key =",histName
43 newHists.append(histName)
46 for histName
in primaryFile.GetKeyNames():
48 if histName
in updates.keys():
49 print "Updating component:",histName
50 hist = updates[histName]
52 hist = primaryFile.Get(histName)
58 for newHist
in newHists:
59 print "Adding new component:",newHist
60 hist = updates[newHist]