ATLAS Offline Software
Loading...
Searching...
No Matches
dq_defect_list_iovs Namespace Reference

Functions

 DefectIOV (channel, comment)
 get_project_dict ()
 main ()

Variables

 log

Function Documentation

◆ DefectIOV()

dq_defect_list_iovs.DefectIOV ( channel,
comment )

Definition at line 25 of file dq_defect_list_iovs.py.

25def DefectIOV(channel, comment):
26 "Stores a defect IOV"
27

◆ get_project_dict()

dq_defect_list_iovs.get_project_dict ( )
Try to unpickle project dict from file first, 
unless file doesn't exist or is older than 5 days

Definition at line 28 of file dq_defect_list_iovs.py.

28def get_project_dict():
29 """
30 Try to unpickle project dict from file first,
31 unless file doesn't exist or is older than 5 days
32 """
33 filename = 'project_period_runs.pickle'
34 def get_file_age(name):
35 delta = datetime.fromtimestamp(os.path.getmtime(name)) - datetime.now()
36 return delta.days
37 if os.path.exists(filename) and get_file_age(filename) < 5:
38 print('using existing pickled project dict:', filename)
39 with open(filename) as f:
40 project_dict = pickle.load(f)
41 else:
42 # Make a new pickle file
43 print('storing project:period:runs dictionary to', filename)
44 with open(filename, 'w') as f:
45 project_dict = fetch_project_period_runs()
46 pickle.dump(project_dict, f)
47 return project_dict
48
49
void print(char *figname, TCanvas *c1)

◆ main()

dq_defect_list_iovs.main ( )

Definition at line 50 of file dq_defect_list_iovs.py.

50def main():
51 parser = ArgumentParser(description='List defect IOVs')
52 add_arg = parser.add_argument
53
54 # Specify range to process
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 #add_arg('-r', '--run', default=None, nargs='*', help='Run number(s) to process')
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 # Specify defects to process
63 add_arg('-d', '--defects', default=None, nargs='*',
64 help='Defects to process. Use * for wildcard (default: None)')
65
66 # Other job options
67 add_arg('-c', '--connection-string', default=DEFAULT_CONNECTION_STRING,
68 help='Database connection to use (default: %s)' % DEFAULT_CONNECTION_STRING)
69 #add_arg('-l', '--lumi-tag', default='OflLumi-8TeV-001',
70 #help='Luminosity tag (default: OflLumi-8TeV-001)')
71 add_arg('-t', '--tag', default='HEAD',
72 help='Tag to use (default: HEAD)')
73
74 # Parse arguments
75 args = parser.parse_args()
76
77 # Ranges to query
78 since, until = None, None
79 range_iovs = IOVSet()
80
81 # If specifying runs, use those
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 # Otherwise, use the project and period settings
90 elif args.project:
91 # Fetch the project:period:runs dictionary
92 project_dict = get_project_dict()
93 period_dict = project_dict[args.project]
94 run_set = set()
95 # Use periods if specified
96 if args.period and len(args.period) > 0:
97 for period in args.period:
98 run_set.update(period_dict[period])
99 # Otherwise use all periods in project
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 # debugging
107 print('range to process:')
108 print('since, until =', since, until)
109
110 # Instantiate the DB
111 db = DefectsDB(args.connection_string, tag=args.tag)
112
113 # Fetch the requested defect IOVs
114 defect_iovs = db.retrieve(since, until, channels=args.defects)
115 defect_iovset_list = defect_iovs.by_channel.values()
116
117 # Get the overlap with the range_iovs
118 # Use a dictionary of defect:iovset
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 # Print the results
128 for channel, result in result_dict.items():
129 result.solidify(DefectIOV)
130 print('\n' + channel + '\n')
131 result.pprint()
132
133
#define min(a, b)
Definition cfImp.cxx:40
#define max(a, b)
Definition cfImp.cxx:41
STL class.
STL class.
bool add(const std::string &hname, TKey *tobj)
Definition fastadd.cxx:55
int main()
Definition hello.cxx:18

Variable Documentation

◆ log

dq_defect_list_iovs.log

Definition at line 14 of file dq_defect_list_iovs.py.