3 Script prints out histogram names that are in one ROOT file but not in another. 5 Author: Albertas Gimbutas, Vilnius University (LT) 6 e-mail: albertasgim@gmail.com 8 from datetime
import datetime, timedelta
9 from optparse
import OptionParser
12 """Adds current directory file (histogram) names to ``names_list``. Then 13 recursively calls itself for every current directory sub-directories.""" 14 for key
in directory.GetListOfKeys():
15 subdir = directory.Get(key.GetName())
20 filename = directory.GetPath().
split(
':')[1] +
': ' + subdir.GetName()
21 names_list.add(filename)
24 """Returns all file (histogram) names, which are found in <root_file_name>.""" 25 from ROOT
import TFile
26 root_file = TFile(root_file_name)
27 root_directory = root_file.GetDirectory(
"DQMData")
34 """Prints file (histogram) names that are in <file1> and not in <file2>.""" 35 print "Missing files:" 40 if name
not in content2:
44 print " All files match." 48 parser = OptionParser(usage=
'usage: %prog <root_file1> <root_file2> [options]')
49 parser.add_option(
'-t',
'--time', action=
'store_true', default=
False,
50 dest=
'show_exec_time', help=
'Show execution time.')
51 (options, args) = parser.parse_args()
55 parser.error(
"You have to specify two root files. e.g. ``dqm_diff.py file1.root file2.root``.")
58 start = datetime.now()
60 if options.show_exec_time:
61 print 'Execution time:',
str(timedelta(seconds=(datetime.now() - start).seconds))
def get_content(root_file_name)
def dqm_diff(filename1, filename2)
def collect_directory_filenames(directory, names_list)