ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
EventSelectionAlgorithms
python
EventSelectionConfigChaining_unitTest.py
Go to the documentation of this file.
1
#!/usr/bin/env python
2
# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
"""Cross-cut behaviour: preselection chaining, EVENTFLAG, GLOBALTRIGMATCH,
4
IMPORT, RUN_NUMBER dataType dependence, SAVE, and a debugMode smoke test."""
5
6
import
unittest
7
from
EventSelectionAlgorithms.EventSelectionConfigTestSupport
import
run, selectors, named, prop, DataType
8
9
10
class
TestPreselectionChaining
(unittest.TestCase):
11
def
test_chains_sequentially
(self):
12
algs = selectors(
run
(
"EL_N 25000 >= 1\nJET_N 30000 >= 2\nMET > 30000"
,
13
containers={
"electrons"
:
"AnaElectrons"
,
"jets"
:
"AnaJets"
,
"met"
:
"AnaMET"
}))
14
el = named(algs,
"NEL"
)[0]
15
jet = named(algs,
"NJET"
)[0]
16
met = named(algs,
"MET"
)[0]
17
self.assertEqual(prop(el,
"eventPreselection"
,
""
),
""
)
18
self.assertIn(
"NEL_1"
, prop(jet,
"eventPreselection"
))
19
self.assertIn(
"NJET_2"
, prop(met,
"eventPreselection"
))
20
21
def
test_seeded_by_preselection_option
(self):
22
algs = named(
run
(
"JET_N 30000 >= 2"
, containers={
"jets"
:
"AnaJets"
},
23
preselection=
"pass_common_%SYS%"
),
"NJET"
)
24
self.assertIn(
"pass_common"
, prop(algs[0],
"eventPreselection"
))
25
26
27
class
TestFlags
(unittest.TestCase):
28
def
test_eventflag_feeds_next_cut
(self):
29
algs = named(
run
(
"EVENTFLAG mytrigger_%SYS%\nJET_N 30000 >= 2"
,
30
containers={
"jets"
:
"AnaJets"
}),
"NJET"
)
31
self.assertIn(
"mytrigger"
, prop(algs[0],
"eventPreselection"
))
32
33
def
test_globaltrigmatch_default
(self):
34
algs = named(
run
(
"GLOBALTRIGMATCH\nJET_N 30000 >= 2"
,
35
containers={
"jets"
:
"AnaJets"
}),
"NJET"
)
36
self.assertIn(
"globalTriggerMatch"
, prop(algs[0],
"eventPreselection"
))
37
38
def
test_globaltrigmatch_postfix
(self):
39
algs = named(
run
(
"GLOBALTRIGMATCH _LooseID\nJET_N 30000 >= 2"
,
40
containers={
"jets"
:
"AnaJets"
}),
"NJET"
)
41
self.assertIn(
"globalTriggerMatch_LooseID"
, prop(algs[0],
"eventPreselection"
))
42
43
def
test_import_feeds_next_cut
(self):
44
algs = named(
run
(
"IMPORT presel\nJET_N 30000 >= 2"
,
45
containers={
"jets"
:
"AnaJets"
}),
"NJET"
)
46
self.assertIn(
"pass_presel"
, prop(algs[0],
"eventPreselection"
))
47
48
49
class
TestRunNumber
(unittest.TestCase):
50
def
test_random_run_number_depends_on_datatype
(self):
51
for
dt, expected
in
[(DataType.Data,
False
), (DataType.FullSim,
True
)]:
52
with
self.subTest(dataType=dt):
53
algs = named(
run
(
"RUN_NUMBER >= 300000"
, dataType=dt),
"RUN_NUMBER"
)
54
self.assertEqual(prop(algs[0],
"useRandomRunNumber"
), expected)
55
56
def
test_properties
(self):
57
algs = named(
run
(
"RUN_NUMBER >= 300000"
),
"RUN_NUMBER"
)
58
self.assertEqual(prop(algs[0],
"sign"
),
"GE"
)
59
self.assertEqual(prop(algs[0],
"runNumber"
), 300000)
60
61
62
class
TestSave
(unittest.TestCase):
63
def
test_implicit_save_emitted_without_save_line
(self):
64
# the event filter is now created automatically at the end of a block
65
algs =
run
(
"EL_N 25000 >= 1"
, containers={
"electrons"
:
"AnaElectrons"
})
66
save = [a
for
a
in
algs
if
a.getType() ==
"CP::SaveFilterAlg"
]
67
self.assertEqual(len(save), 1)
68
self.assertEqual(prop(save[0],
"selectionName"
),
"pass_SR_%SYS%,as_char"
)
69
self.assertEqual(prop(save[0],
"decorationName"
),
"ntuplepass_SR_%SYS%"
)
70
self.assertTrue(prop(save[0],
"noFilter"
))
71
72
def
test_explicit_save_is_deprecated_but_honoured
(self):
73
with
self.assertWarns(FutureWarning):
74
algs =
run
(
"EL_N 25000 >= 1\nSAVE"
, containers={
"electrons"
:
"AnaElectrons"
})
75
save = [a
for
a
in
algs
if
a.getType() ==
"CP::SaveFilterAlg"
]
76
self.assertEqual(len(save), 1)
# not doubled by the implicit one
77
78
def
test_save_bad_argcount
(self):
79
self.assertRaises(ValueError, run,
"EL_N 25000 >= 1\nSAVE now"
,
80
containers={
"electrons"
:
"AnaElectrons"
})
81
82
83
class
TestDebugMode
(unittest.TestCase):
84
def
test_debugmode_runs_and_keeps_selectors
(self):
85
# debugMode registers a per-cut output branch; here we assert it does not
86
# perturb the selector algorithms or raise during configuration.
87
algs = selectors(
run
(
"JET_N 30000 >= 2"
, containers={
"jets"
:
"AnaJets"
}, debugMode=
True
))
88
self.assertEqual(len(named(algs,
"NJET"
)), 1)
89
90
91
if
__name__ ==
"__main__"
:
92
unittest.main()
python.EventSelectionConfigChaining_unitTest.TestDebugMode
Definition
EventSelectionConfigChaining_unitTest.py:83
python.EventSelectionConfigChaining_unitTest.TestDebugMode.test_debugmode_runs_and_keeps_selectors
test_debugmode_runs_and_keeps_selectors(self)
Definition
EventSelectionConfigChaining_unitTest.py:84
python.EventSelectionConfigChaining_unitTest.TestFlags
Definition
EventSelectionConfigChaining_unitTest.py:27
python.EventSelectionConfigChaining_unitTest.TestFlags.test_globaltrigmatch_default
test_globaltrigmatch_default(self)
Definition
EventSelectionConfigChaining_unitTest.py:33
python.EventSelectionConfigChaining_unitTest.TestFlags.test_globaltrigmatch_postfix
test_globaltrigmatch_postfix(self)
Definition
EventSelectionConfigChaining_unitTest.py:38
python.EventSelectionConfigChaining_unitTest.TestFlags.test_eventflag_feeds_next_cut
test_eventflag_feeds_next_cut(self)
Definition
EventSelectionConfigChaining_unitTest.py:28
python.EventSelectionConfigChaining_unitTest.TestFlags.test_import_feeds_next_cut
test_import_feeds_next_cut(self)
Definition
EventSelectionConfigChaining_unitTest.py:43
python.EventSelectionConfigChaining_unitTest.TestPreselectionChaining
Definition
EventSelectionConfigChaining_unitTest.py:10
python.EventSelectionConfigChaining_unitTest.TestPreselectionChaining.test_chains_sequentially
test_chains_sequentially(self)
Definition
EventSelectionConfigChaining_unitTest.py:11
python.EventSelectionConfigChaining_unitTest.TestPreselectionChaining.test_seeded_by_preselection_option
test_seeded_by_preselection_option(self)
Definition
EventSelectionConfigChaining_unitTest.py:21
python.EventSelectionConfigChaining_unitTest.TestRunNumber
Definition
EventSelectionConfigChaining_unitTest.py:49
python.EventSelectionConfigChaining_unitTest.TestRunNumber.test_properties
test_properties(self)
Definition
EventSelectionConfigChaining_unitTest.py:56
python.EventSelectionConfigChaining_unitTest.TestRunNumber.test_random_run_number_depends_on_datatype
test_random_run_number_depends_on_datatype(self)
Definition
EventSelectionConfigChaining_unitTest.py:50
python.EventSelectionConfigChaining_unitTest.TestSave
Definition
EventSelectionConfigChaining_unitTest.py:62
python.EventSelectionConfigChaining_unitTest.TestSave.test_implicit_save_emitted_without_save_line
test_implicit_save_emitted_without_save_line(self)
Definition
EventSelectionConfigChaining_unitTest.py:63
python.EventSelectionConfigChaining_unitTest.TestSave.test_save_bad_argcount
test_save_bad_argcount(self)
Definition
EventSelectionConfigChaining_unitTest.py:78
python.EventSelectionConfigChaining_unitTest.TestSave.test_explicit_save_is_deprecated_but_honoured
test_explicit_save_is_deprecated_but_honoured(self)
Definition
EventSelectionConfigChaining_unitTest.py:72
run
int run(int argc, char *argv[])
Definition
ttree2hdf5.cxx:28
Generated on
for ATLAS Offline Software by
1.17.0