ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
EventSelectionAlgorithms
python
EventSelectionConfigDispatch_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
"""Routing tests: each keyword reaches the right algorithm, prefix-collision
4
keywords are not mis-routed, and non-cut lines are skipped. These guard the
5
fragile token-membership dispatch against silent breakage on reordering."""
6
7
import
unittest
8
from
EventSelectionAlgorithms.EventSelectionConfigTestSupport
import
run, selectors, named
9
10
ALL = dict(electrons=
"AnaElectrons"
, muons=
"AnaMuons"
, taus=
"AnaTaus"
,
11
jets=
"AnaJets"
, largeRjets=
"AnaLRJets"
, photons=
"AnaPhotons"
, met=
"AnaMET"
)
12
13
ROUTING = [
14
(
"EL_N 25000 >= 1"
,
"CP::NObjectPtSelectorAlg"
,
"NEL"
),
15
(
"MU_N 25000 >= 1"
,
"CP::NObjectPtSelectorAlg"
,
"NMU"
),
16
(
"JET_N 30000 >= 2"
,
"CP::NObjectPtSelectorAlg"
,
"NJET"
),
17
(
"JET_N_BTAG >= 2"
,
"CP::NObjectPtSelectorAlg"
,
"NBJET"
),
18
(
"JET_N_GHOST B >= 1"
,
"CP::JetNGhostSelectorAlg"
,
"NJETGHOST"
),
19
(
"PH_N 25000 >= 1"
,
"CP::NObjectPtSelectorAlg"
,
"NPH"
),
20
(
"TAU_N 25000 >= 1"
,
"CP::NObjectPtSelectorAlg"
,
"NTAU"
),
21
(
"LJET_N 200000 >= 1"
,
"CP::NObjectPtSelectorAlg"
,
"NLJET"
),
22
(
"LJET_N_GHOST B >= 1"
,
"CP::JetNGhostSelectorAlg"
,
"NLJETGHOST"
),
23
(
"LJETMASS_N 50000 >= 1"
,
"CP::NObjectMassSelectorAlg"
,
"NLJETMASS"
),
24
(
"LJETMASSWINDOW_N 60000 100000 >= 1"
,
"CP::NLargeRJetMassWindowSelectorAlg"
,
"NLJETMASSWINDOW"
),
25
(
"OBJ_N AnaJets 30000 >= 2"
,
"CP::NObjectPtSelectorAlg"
,
"NOBJ"
),
26
(
"SUM_EL_N_MU_N 25000 >= 2"
,
"CP::SumNLeptonPtSelectorAlg"
,
"SUMNELNMU"
),
27
(
"SUM_EL_N_MU_N_TAU_N 25000 >= 2"
,
"CP::SumNLeptonPtSelectorAlg"
,
"SUMNLEPTONS"
),
28
(
"MET > 30000"
,
"CP::MissingETSelectorAlg"
,
"MET"
),
29
(
"MWT > 50000"
,
"CP::TransverseMassSelectorAlg"
,
"MWT"
),
30
(
"MET+MWT > 60000"
,
"CP::MissingETPlusTransverseMassSelectorAlg"
,
"METMWT"
),
31
(
"MLL > 80000"
,
"CP::DileptonInvariantMassSelectorAlg"
,
"MLL_"
),
32
(
"MLLWINDOW 80000 100000"
,
"CP::DileptonInvariantMassWindowSelectorAlg"
,
"MLLWINDOW"
),
33
(
"MLL_OSSF 80000 100000"
,
"CP::DileptonOSSFInvariantMassWindowSelectorAlg"
,
"MLL_OSSF"
),
34
(
"OS"
,
"CP::ChargeSelectorAlg"
,
"_OS_"
),
35
(
"SS"
,
"CP::ChargeSelectorAlg"
,
"_SS_"
),
36
(
"RUN_NUMBER >= 300000"
,
"CP::RunNumberSelectorAlg"
,
"RUN_NUMBER"
),
37
]
38
39
40
class
TestRouting
(unittest.TestCase):
41
def
test_routing
(self):
42
for
line, alg_type, name_sub
in
ROUTING:
43
with
self.subTest(line=line):
44
sel = selectors(
run
(line, containers=ALL, btagDecoration=
"btag"
))
45
self.assertEqual(len(sel), 1, f
"{line} -> {len(sel)} selectors"
)
46
self.assertEqual(sel[0].getType(), alg_type)
47
self.assertIn(name_sub, sel[0].getName())
48
49
def
test_btag_not_routed_as_plain_jet
(self):
50
algs =
run
(
"JET_N_BTAG >= 2"
, containers=ALL, btagDecoration=
"btag"
)
51
self.assertTrue(named(algs,
"NBJET"
))
52
self.assertFalse([a
for
a
in
algs
if
"NJET_"
in
a.getName()])
53
54
def
test_sum_tau_not_routed_as_sum
(self):
55
self.assertTrue(named(
run
(
"SUM_EL_N_MU_N_TAU_N 25000 >= 2"
, containers=ALL),
"SUMNLEPTONS"
))
56
57
def
test_metmwt_not_routed_as_met_or_mwt
(self):
58
sel = selectors(
run
(
"MET+MWT > 60000"
, containers=ALL))
59
self.assertEqual(sel[0].getType(),
"CP::MissingETPlusTransverseMassSelectorAlg"
)
60
61
62
class
TestNonCuts
(unittest.TestCase):
63
def
test_unknown_keyword_raises
(self):
64
self.assertRaises(ValueError, run,
"NOT_A_KEYWORD 1 2 3"
, containers=ALL)
65
66
def
test_comment_and_blank_skipped
(self):
67
algs = selectors(
run
(
"# a comment\n\n \nJET_N 30000 >= 2"
, containers=ALL))
68
self.assertEqual(len(algs), 1)
69
70
71
if
__name__ ==
"__main__"
:
72
unittest.main()
python.EventSelectionConfigDispatch_unitTest.TestNonCuts
Definition
EventSelectionConfigDispatch_unitTest.py:62
python.EventSelectionConfigDispatch_unitTest.TestNonCuts.test_comment_and_blank_skipped
test_comment_and_blank_skipped(self)
Definition
EventSelectionConfigDispatch_unitTest.py:66
python.EventSelectionConfigDispatch_unitTest.TestNonCuts.test_unknown_keyword_raises
test_unknown_keyword_raises(self)
Definition
EventSelectionConfigDispatch_unitTest.py:63
python.EventSelectionConfigDispatch_unitTest.TestRouting
Definition
EventSelectionConfigDispatch_unitTest.py:40
python.EventSelectionConfigDispatch_unitTest.TestRouting.test_metmwt_not_routed_as_met_or_mwt
test_metmwt_not_routed_as_met_or_mwt(self)
Definition
EventSelectionConfigDispatch_unitTest.py:57
python.EventSelectionConfigDispatch_unitTest.TestRouting.test_sum_tau_not_routed_as_sum
test_sum_tau_not_routed_as_sum(self)
Definition
EventSelectionConfigDispatch_unitTest.py:54
python.EventSelectionConfigDispatch_unitTest.TestRouting.test_btag_not_routed_as_plain_jet
test_btag_not_routed_as_plain_jet(self)
Definition
EventSelectionConfigDispatch_unitTest.py:49
python.EventSelectionConfigDispatch_unitTest.TestRouting.test_routing
test_routing(self)
Definition
EventSelectionConfigDispatch_unitTest.py:41
run
int run(int argc, char *argv[])
Definition
ttree2hdf5.cxx:28
Generated on
for ATLAS Offline Software by
1.17.0