11 return [key.GetName()
for key
in gDirectory.GetListOfKeys()]
12 TFile.GetKeyNames = GetKeyNames
16 print "Too few arguments. Expected the following:"
17 print " 1. Output root file"
18 print " 2+ Input root files"
21 outFileName = sys.argv[1]
22 inFileNames = sys.argv[2:]
24 if not outFileName.endswith(
".root"):
25 print "Output file doesn't appear to be a root file:",outFile
26 print "Blocking for safety"
28 for aFileName
in inFileNames:
29 if not aFileName.endswith(
".root"):
30 print "Input file doesn't appear to be a root file:",aFileName
31 print "Blocking for safety"
33 if not os.path.isfile(aFileName):
34 print "Input file doesn't exist:",aFileName
35 print "Blocking for safety"
38 outFile = TFile(outFileName,
"RECREATE")
43 for aFileName
in inFileNames:
44 print "Reading file:",aFileName
45 aFile = TFile(aFileName,
"READ")
47 for histName
in aFile.GetKeyNames():
48 if histName
not in uniqueHistos.keys():
49 hist = aFile.Get(histName)
55 uniqueHistos[histName] = hist
58 hist = aFile.Get(histName)
59 hist.Add(uniqueHistos[histName],-1)
60 areDifferent = ( math.fabs(hist.GetMinimum()) > 1.e-8
or math.fabs(hist.GetMaximum()) > 1.e-8 )
63 print "[ERROR] Two non-identical histograms with the same name were provided: %s"%(histName)
67 print "[SAFE] Skipping non-unique histogram name which is identical to the old one: %s"%(histName)