ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigValidation
TrigP1Test
python
TrigP1TestSteps.py
Go to the documentation of this file.
1
#
2
# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
#
4
5
'''
6
Definitions of additional validation steps in Trigger ART tests relevant only for TrigP1Test.
7
The main common check steps are defined in the TrigValSteering.CheckSteps module.
8
'''
9
10
from
TrigValTools.TrigValSteering
import
Step, CheckSteps
11
from
TrigValTools.TrigValSteering.Common
import
get_logger
12
import
os
13
import
inspect
14
import
json
15
import
re
16
17
class
TrigBSDumpGrepStep
(Step.Step):
18
'''
19
Extra step based on grepping trigbs_dumpHLTContentInBS.py output
20
and comparing the line count to expected value
21
'''
22
23
def
__init__
(self, name='TrigBSDumpGrep'):
24
super(TrigBSDumpGrepStep, self).
__init__
(name)
25
self.
executable
=
'trigbs_dumpHLTContentInBS_run3.py'
26
self.
file_name_base
=
'output'
27
self.
auto_report_result
=
True
28
self.
required
=
True
29
self.
regex
=
''
30
self.
comparator
=
lambda
n: n > 0
31
32
def
run
(self, dry_run=False):
33
if
dry_run:
34
self.log.info(
'Skipping %s in dry run'
, self.
name
)
35
self.
result
= 0
36
return
self.
result
,
'# (internal) {} -> skipped'
.format(self.
name
)
37
file_name =
None
38
for
ls_file
in
os.listdir(
'.'
):
39
if
self.
file_name_base
in
ls_file:
40
file_name = ls_file
41
if
file_name
is
None
:
42
self.log.
error
(
'%s cannot find the BS output file'
, self.
name
)
43
self.
result
= 1
44
if
self.
auto_report_result
:
45
self.report_result()
46
return
self.
result
,
'# (internal) {} -> failed'
.format(self.
name
)
47
self.log.
debug
(
'%s found BS file %s'
, self.
name
, file_name)
48
self.args +=
' '
+ file_name
49
self.args +=
' | grep "{}" | wc -l'
.format(self.
regex
)
50
51
old_auto_report = self.
auto_report_result
52
self.
auto_report_result
=
False
53
ret, cmd = super(TrigBSDumpGrepStep, self).
run
(dry_run)
54
self.
auto_report_result
= old_auto_report
55
56
if
ret != 0:
57
self.log.
error
(
'%s failed'
, self.
name
)
58
if
self.
auto_report_result
:
59
self.report_result()
60
return
self.
result
, cmd
61
62
if
not
os.path.isfile(self.get_log_file_name()):
63
self.log.
error
(
'%s failed, the file %s is missing'
,
64
self.
name
, self.get_log_file_name())
65
self.
result
= 1
66
if
self.
auto_report_result
:
67
self.report_result()
68
return
self.
result
, cmd
69
70
num =
None
71
with
open(self.get_log_file_name())
as
log_file:
72
num = eval(log_file.read())
73
if
not
self.
comparator
(num)
or
num
is
None
:
74
self.log.
error
(
'%s failed the comparison'
, self.
name
)
75
self.
result
= 1
76
if
self.
auto_report_result
:
77
self.report_result()
78
return
self.
result
, cmd
79
80
compare_str_list = inspect.getsource(self.
comparator
).
split
(
':'
)
81
compare_str =
''
.join(compare_str_list[1:])
82
compare_str = compare_str.strip()
83
self.log.info(
'Comparison %s for num=%s gives True'
, compare_str, num)
84
self.
result
= 0
85
if
self.
auto_report_result
:
86
self.report_result()
87
return
self.
result
, cmd
88
89
90
class
ExtractExpertMonitoring
(CheckSteps.InputDependentStep):
91
'''
92
Step which extracts the EXPERT directory from an online monitoring file
93
produced by OH server into an offline-like expert-monitoring.root
94
'''
95
def
__init__
(self, name='ExtractExpertMonitoring'):
96
super(ExtractExpertMonitoring, self).
__init__
(name)
97
self.
input_file
=
None
98
self.
path_prefix
=
None
99
self.
required
=
True
100
self.
executable
=
'rootcp'
101
self.
args
=
'--recreate -r'
102
self.
output_stream
= Step.Step.OutputStream.STDOUT_ONLY
103
104
def
configure
(self, test):
105
self.
args
+=
' {:s}:{:s}/*Histogramming/EXPERT/* expert-monitoring.root'
.format(self.
input_file
, self.
path_prefix
or
''
)
106
super(ExtractExpertMonitoring, self).
configure
(test)
107
108
109
def
check_hlt_properties
(filename='HLTJobOptions.db.json'):
110
'''Check a few important job options in the JSON file'''
111
112
log = get_logger()
113
114
with
open(filename)
as
f:
115
props = json.load(f)[
'properties'
]
116
117
def
checkprop(comp, prop, regex):
118
value = props[comp][prop]
119
if
re.match(regex, value)
is
None
:
120
log.error(
'Property "%s.%s" does not match "%s". Current value: "%s"'
, comp, prop, regex, value)
121
return
False
122
return
True
123
124
checks = [
125
checkprop(
'IOVDbSvc'
,
'CacheAlign'
,
'0'
),
126
checkprop(
'IOVDbSvc'
,
'CacheRun'
,
'0'
),
127
checkprop(
'IOVDbSvc'
,
'CacheTime'
,
'0'
),
128
checkprop(
'AtlasFieldMapCondAlg'
,
'LoadMapOnStart'
,
'True'
),
129
checkprop(
'IOVDbSvc'
,
'Folders'
,
r'.*/TRIGGER/LUMI/HLTPrefLumi\s*<extensible/>.*'
),
130
checkprop(
'IOVDbSvc'
,
'Folders'
,
r'.*/Indet/Onl/Beampos\s*<extensible/>.*'
),
131
checkprop(
'IOVDbSvc'
,
'Folders'
,
r'.*/TRIGGER/HLT/PrescaleKey <tag>HEAD</tag>\s*<extensible/>.*'
),
132
]
133
return
0
if
all(checks)
else
1
134
135
136
def
default_check_steps_OHMon
(test, hist_path):
137
steps = []
138
# Extract expert-monitoring.root file from OH server output
139
extract_hist =
ExtractExpertMonitoring
()
140
hist_path_split = hist_path.split(
':'
)
141
if
len(hist_path_split) > 1:
142
extract_hist.input_file = hist_path_split[0]
143
extract_hist.path_prefix = hist_path_split[1]
144
else
:
145
extract_hist.input_file = hist_path
146
steps.append(extract_hist)
147
# Default check steps
148
steps.extend(CheckSteps.default_check_steps(test))
149
# Remove histogram merging step
150
matches = [step
for
step
in
steps
if
step.name ==
'HistMerge'
]
151
for
hm_step
in
matches:
152
steps.remove(hm_step)
153
return
steps
154
155
def
filterBS
(stream_name, extra_args = ''):
156
'''Extract ByteStream data for a given stream from a file with multiple streams'''
157
from
TrigValTools.TrigValSteering
import
ExecStep
158
from
TrigValTools.TrigValSteering.Common
import
find_file
159
filterStep = ExecStep.ExecStep(
'FilterBS_'
+stream_name)
160
filterStep.type =
'other'
161
filterStep.executable =
'trigbs_extractStream.py'
162
filterStep.input =
''
163
filterStep.args = f
'{extra_args} -s {stream_name} '
+ find_file(
'data*_SingleStream.daq.RAW.*_output.*.data'
, max_files=
None
)
164
return
filterStep
165
166
def
decodeBS
(stream_name, moduleID=0):
167
'''Deserialise HLT data from ByteStream and save to an ESD file'''
168
from
TrigValTools.TrigValSteering
import
ExecStep
169
from
TrigValTools.TrigValSteering.Common
import
find_file
170
decodeStep = ExecStep.ExecStep(
'DecodeBS_'
+stream_name)
171
decodeStep.type =
'other'
172
decodeStep.executable =
'python'
173
decodeStep.input =
''
174
decodeStep.explicit_input =
True
175
decodeStep.args = f
'-m TrigP1Test.DecodeBS --moduleID={moduleID} --filesInput='
+ find_file(f
'data*_{stream_name}.*.data'
)
176
return
decodeStep
debug
const bool debug
Definition
MakeUncertaintyPlots.cxx:53
python.TrigP1TestSteps.ExtractExpertMonitoring
Definition
TrigP1TestSteps.py:90
python.TrigP1TestSteps.ExtractExpertMonitoring.args
str args
Definition
TrigP1TestSteps.py:101
python.TrigP1TestSteps.ExtractExpertMonitoring.__init__
__init__(self, name='ExtractExpertMonitoring')
Definition
TrigP1TestSteps.py:95
python.TrigP1TestSteps.ExtractExpertMonitoring.configure
configure(self, test)
Definition
TrigP1TestSteps.py:104
python.TrigP1TestSteps.ExtractExpertMonitoring.output_stream
output_stream
Definition
TrigP1TestSteps.py:102
python.TrigP1TestSteps.ExtractExpertMonitoring.required
bool required
Definition
TrigP1TestSteps.py:99
python.TrigP1TestSteps.ExtractExpertMonitoring.input_file
input_file
Definition
TrigP1TestSteps.py:97
python.TrigP1TestSteps.ExtractExpertMonitoring.executable
str executable
Definition
TrigP1TestSteps.py:100
python.TrigP1TestSteps.ExtractExpertMonitoring.path_prefix
path_prefix
Definition
TrigP1TestSteps.py:98
python.TrigP1TestSteps.TrigBSDumpGrepStep
Definition
TrigP1TestSteps.py:17
python.TrigP1TestSteps.TrigBSDumpGrepStep.regex
str regex
Definition
TrigP1TestSteps.py:29
python.TrigP1TestSteps.TrigBSDumpGrepStep.name
name
Definition
TrigP1TestSteps.py:34
python.TrigP1TestSteps.TrigBSDumpGrepStep.result
int result
Definition
TrigP1TestSteps.py:35
python.TrigP1TestSteps.TrigBSDumpGrepStep.auto_report_result
bool auto_report_result
Definition
TrigP1TestSteps.py:27
python.TrigP1TestSteps.TrigBSDumpGrepStep.file_name_base
str file_name_base
Definition
TrigP1TestSteps.py:26
python.TrigP1TestSteps.TrigBSDumpGrepStep.run
run(self, dry_run=False)
Definition
TrigP1TestSteps.py:32
python.TrigP1TestSteps.TrigBSDumpGrepStep.__init__
__init__(self, name='TrigBSDumpGrep')
Definition
TrigP1TestSteps.py:23
python.TrigP1TestSteps.TrigBSDumpGrepStep.comparator
int comparator
Definition
TrigP1TestSteps.py:30
python.TrigP1TestSteps.TrigBSDumpGrepStep.executable
str executable
Definition
TrigP1TestSteps.py:25
python.TrigP1TestSteps.TrigBSDumpGrepStep.required
bool required
Definition
TrigP1TestSteps.py:28
split
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition
hcg.cxx:179
error
Definition
IImpactPoint3dEstimator.h:72
python.TrigP1TestSteps.decodeBS
decodeBS(stream_name, moduleID=0)
Definition
TrigP1TestSteps.py:166
python.TrigP1TestSteps.filterBS
filterBS(stream_name, extra_args='')
Definition
TrigP1TestSteps.py:155
python.TrigP1TestSteps.check_hlt_properties
check_hlt_properties(filename='HLTJobOptions.db.json')
Definition
TrigP1TestSteps.py:109
python.TrigP1TestSteps.default_check_steps_OHMon
default_check_steps_OHMon(test, hist_path)
Definition
TrigP1TestSteps.py:136
Generated on
for ATLAS Offline Software by
1.17.0