ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DataQuality
DCSCalculator2
share
test_dcsc.py
Go to the documentation of this file.
1
#! /usr/bin/env python
2
3
from
DCSCalculator2.subdetectors
import
LAr, Lucid, MDT, Pixels, RPC, SCT, TDQ, Tile, TGC, TRT
4
5
from
DQUtils.general
import
timer, kgrind_profile
6
7
from
DQUtils.db
import
fetch_iovs
8
from
DQUtils.iov_arrangement
import
inverse_lblb
9
from
DQUtils.utils
import
pprint_objects
10
from
DQUtils.sugar
import
RunLumi
11
12
from
DQUtils.iov_differences
import
emit_iov_differences
13
14
def
sum_lbs
(iovs):
15
"""
16
Sum the number of luminosity blocks spanned by a run
17
"""
18
return
sum(iov.until - iov.since
for
iov
in
iovs)
19
20
def
print_diff_lumi
(diff):
21
before, after = diff
22
assert
(before.since, before.until) == (after.since, after.until)
23
assert
before._fields == after._fields
24
25
if
not
hasattr(
type
(before),
"_is_empty"
):
type
(before)._is_empty =
False
26
if
not
hasattr(
type
(after),
"_is_empty"
):
type
(after)._is_empty =
False
27
28
print
" "
, before.since, before.until,
29
30
if
before._is_empty:
31
print
" Empty -> Filled"
32
elif
after._is_empty:
33
print
" Filled -> Empty"
34
else
:
35
for
field, val_before, val_after
in
zip(before._fields, before, after):
36
if
val_before != val_after:
37
print
field, val_before,
"->"
, val_after,
38
print
39
40
def
compare_iovs
(a, b):
41
42
a = a.by_channel
43
b = b.by_channel
44
45
for
output_channel
in
sorted(
set
(a.keys() + b.keys())):
46
A = a[output_channel]
47
B = b[output_channel]
48
49
diff = emit_iov_differences(A, B)
50
print
" [BAD] diff iovs ="
, len(diff),
"lbs ="
,
sum_lbs
(zip(*diff)[0])
51
print
" First ten diffs:"
52
for
i
in
diff[:10]:
53
#print i
54
print_diff_lumi
(i)
55
print
56
57
def
main
():
58
run = 144247
# Recent run where CSC gas state was bad.
59
run = 136379
60
run = 155112
# Recent long run (Sat May 15th, 11am -> Sun 16th 8am), 632 lbs
61
run = 156463
62
#run = 155669 # MDT NConfig goes below 600
63
from
sys
import
argv
64
args = argv[1:]
65
if
args:
66
run = int(args[0])
67
since, until = RunLumi(run, 0), RunLumi(run+1, 0)
68
69
with
timer(
"Read LBLB"
):
70
lblb = fetch_iovs(
"LBLB"
, since, until, with_channel=
False
)
71
lbtime = inverse_lblb(lblb)
72
73
#system = SCT() # Works, very slightly discrepant for the config.
74
#system = Pixels() # Works
75
#system = Tile() # Works
76
#system = TDQ() # Works, needs further testing
77
#system = RPC() # Works
78
#system = LAr() # Works, but produces slightly different result. Original gives:
79
# DCSOFL_VAL(since=(155112: 167), until=(155112: 176), channel=215, Code=2L)
80
81
#system = TRT() # Unresolved discrepancies: Wrong NConfig, NWorking off by one in run 155112.
82
83
system =
MDT
()
# Seems to work
84
#system = Magnets() # Needs to be finished
85
#system = Lucid() # Needs to be written
86
87
#print system.mapping.keys()
88
89
with
timer(
"Calculate result for %s"
% system):
90
result = system.run(lbtime)
91
92
print
"Done."
93
print
94
#print result[0]
95
96
print
"Run range:"
, since,
"to"
, until
97
print
"DCSC2 intervals of validity:"
98
pprint_objects(result[:30])
99
print
100
101
output_channels = system.mapping.keys()
102
iovs = fetch_iovs(
"DCSOFL"
, since, until, output_channels)
103
104
#print hex(hash(tuple(iovs))), hex(hash(tuple(result)))
105
106
print
"Original DCSC intervals of validity:"
107
pprint_objects(iovs[:30])
108
109
return
110
111
compare_iovs
(iovs, result)
112
113
#for calc_iov, ref_iov in zip(result, iovs):
114
#print calc_iov.since, calc_iov.until, ref_iov.since, ref_iov.until
115
#pprint_objects(result)
116
117
if
__name__ ==
"__main__"
:
118
119
from
IPython.Shell
import
IPShellEmbed
120
ipython_instance = IPShellEmbed([
"-pdb"
], rc_override=dict(quiet=
True
))
121
122
from
DQUtils.logger
import
init_logging
123
init_logging()
124
125
main
()
MDT
@ MDT
Definition
RegSelEnums.h:31
set
STL class.
test_dcsc.compare_iovs
compare_iovs(a, b)
Definition
test_dcsc.py:40
test_dcsc.main
main()
Definition
test_dcsc.py:57
test_dcsc.print_diff_lumi
print_diff_lumi(diff)
Definition
test_dcsc.py:20
test_dcsc.sum_lbs
sum_lbs(iovs)
Definition
test_dcsc.py:14
type
Generated on
for ATLAS Offline Software by
1.17.0