51 parser = ArgumentParser(description='List defect IOVs')
52 add_arg = parser.add_argument
53
54
55 add_arg('-p', '--project', default='data15_13TeV',
56 help='Data project (default: data15_13TeV)')
57 add_arg('-P', '--period', default=None, nargs='*', help='Data period(s)')
58
59 add_arg('-r', '--run', default=None, type=int, help='Run number to process')
60 add_arg('-R', '--range', help='Inclusive run range: e.g. 150000-151000')
61
62
63 add_arg('-d', '--defects', default=None, nargs='*',
64 help='Defects to process. Use * for wildcard (default: None)')
65
66
67 add_arg('-c', '--connection-string', default=DEFAULT_CONNECTION_STRING,
68 help='Database connection to use (default: %s)' % DEFAULT_CONNECTION_STRING)
69
70
71 add_arg('-t', '--tag', default='HEAD',
72 help='Tag to use (default: HEAD)')
73
74
75 args = parser.parse_args()
76
77
78 since, until = None, None
79 range_iovs = IOVSet()
80
81
82 if args.run:
83 since, until = (args.run, 0), (args.run+1, 0)
84 range_iovs = IOVSet.from_runs([args.run])
85 elif args.range:
86 run1, run2 =
map(int, args.range.split(
'-'))
87 since, until = (run1, 0), (run2, 0)
88 range_iovs = IOVSet([ RANGEIOV_VAL(RunLumi(since), RunLumi(until)) ])
89
90 elif args.project:
91
92 project_dict = get_project_dict()
93 period_dict = project_dict[args.project]
95
96 if args.period and len(args.period) > 0:
97 for period in args.period:
98 run_set.update(period_dict[period])
99
100 else:
101 for period, runs in period_dict.items():
102 run_set.update(runs)
103 since, until = (
min(run_set), 0), (
max(run_set)+1, 0)
104 range_iovs = IOVSet.from_runs(run_set)
105
106
107 print(
'range to process:')
108 print(
'since, until =', since, until)
109
110
111 db = DefectsDB(args.connection_string, tag=args.tag)
112
113
114 defect_iovs = db.retrieve(since, until, channels=args.defects)
115 defect_iovset_list = defect_iovs.by_channel.values()
116
117
118
119 result_dict = defaultdict(IOVSet)
120 for since, until, states in process_iovs(range_iovs, *defect_iovset_list):
121 in_range, defects = states[0], states[1:]
122 if in_range:
123 for d in defects:
124 if d:
125 result_dict[d.channel].
add(since, until, d.channel, d.comment)
126
127
128 for channel, result in result_dict.items():
129 result.solidify(DefectIOV)
130 print(
'\n' + channel +
'\n')
131 result.pprint()
132
133
bool add(const std::string &hname, TKey *tobj)