5 from __future__
import print_function
8 Compare beamspot DQ defects between various databases and tags
10 __author__ =
'Carl Gwilliam'
12 __usage__ =
'''%prog [options] [database1] [database2]
14 Database can be either connection string or db file:
16 e.g COOLOFL_INDET/CONDBR2 (default)
21 dqCompare.py --rl 190236 ~atlidbs/jobs/data11_7TeV.00190236.express_express/DB_BEAMSPOT.x155_c779/data11_7TeV.00190236.express_express-DB_BEAMSPOT.x155_c779.AveBeamSpot-beamspot.db/BEAMSPOT
25 from DQUtils
import fetch_iovs, process_iovs
26 from DQUtils.sugar
import IOVSet,RANGEIOV_VAL,RunLumiType
28 from optparse
import OptionParser
29 parser = OptionParser(usage=__usage__, version=__version__)
30 parser.add_option(
'-f',
'--folder', dest=
'folder', default=
'/Indet/Beampos', help=
'Folder name (default: /Indet/Beampos)')
31 parser.add_option(
'',
'--tag1', dest=
'tag1', default=
'nominal', help=
'Tag to compare (default: nominal)')
32 parser.add_option(
'',
'--tag2', dest=
'tag2', default=
'IndetBeampos-ES1-UPD2-03', help=
'Tag to compare to (default: IndetBeampos-ES1-UPD2-03)')
33 parser.add_option(
'',
'--rl', dest=
'runMin', type=
'int', default=
None, help=
'Start run number (default: None)')
34 parser.add_option(
'',
'--ru', dest=
'runMax', type=
'int', default=
None, help=
'Start run number (default: None)')
35 parser.add_option(
'',
'--statusonly', dest=
'statusonly', action=
'store_true', default=
False, help=
'only show runs with differences in status (default: False)')
36 parser.add_option(
'-s',
'--summary', dest=
'summary', action=
'store_true', default=
False, help=
'only show summary of runs with differences (default: False)')
37 parser.add_option(
'',
'--span', dest=
'span', action=
'store_true', default=
False, help=
'Allows IoVs spanning run boundaries (default: False)')
38 (options,args) = parser.parse_args()
40 db1 = args[0]
if len(args)==1
else 'COOLOFL_INDET/CONDBR2'
41 db2 = args[1]
if len(args)==2
else 'COOLOFL_INDET/CONDBR2'
44 f1 =
"%s::%s" % (db1, options.folder)
45 f2 =
"%s::%s" % (db2, options.folder)
49 print (
" * ", f1, options.tag1)
50 print (
" * ", f2, options.tag2)
53 if options.runMin
is not None:
55 if options.runMax
is not None:
56 runs = options.runMin, options.runMax
58 tag1iovs =
fetch_iovs(f1, runs=runs, tag=options.tag1)
59 tag2iovs =
fetch_iovs(f2, runs=runs, tag=options.tag2)
69 for since, until, (t1, t2)
in process_iovs(tag1iovs, tag2iovs):
72 if not options.span
and since.run != until.run:
continue
81 if (t1.status == 0
or t2.status == 0)
and (t1.status != t2.status):
82 if options.statusonly
and not options.summary:
83 print (since, until, t1.status, t2.status)
87 if not options.statusonly:
88 for i, field
in enumerate(t1._fields):
95 if not options.summary:
96 print (since, until, field, t1[i], t2[i])
97 affected_runs.add(since.run)
100 if not options.statusonly:
101 print (
"Runs with differences (%s):" % len(affected_runs),
", ".
join(map(str,
sorted(affected_runs))))
103 print (
"Runs with different status (and one non-zero):",
", ".
join(map(str,
sorted(ar2))))
105 if __name__ ==
"__main__":