ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
EventSelectionAlgorithms
python
EventSelectionConfigDilepton_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
"""Unit tests for dilepton/charge selectors: MLL, MLLWINDOW, MLL_OSSF, OS, SS,
4
including reco-vs-truth container routing."""
5
6
import
unittest
7
from
EventSelectionAlgorithms.EventSelectionConfigTestSupport
import
run, named, prop
8
9
ELMU = {
"electrons"
:
"AnaElectrons"
,
"muons"
:
"AnaMuons"
}
10
11
12
class
TestMLL
(unittest.TestCase):
13
def
test_mll
(self):
14
algs = named(
run
(
"MLL > 80000"
, containers=ELMU),
"MLL_"
)
15
self.assertEqual(len(algs), 1)
16
self.assertEqual(algs[0].getType(),
"CP::DileptonInvariantMassSelectorAlg"
)
17
self.assertEqual(prop(algs[0],
"sign"
),
"GT"
)
18
self.assertEqual(prop(algs[0],
"refMLL"
), 80000.0)
19
20
def
test_missing_input
(self):
21
self.assertRaises(ValueError, run,
"MLL > 80000"
)
22
23
24
class
TestMLLWindow
(unittest.TestCase):
25
def
test_window
(self):
26
algs = named(
run
(
"MLLWINDOW 80000 100000"
, containers=ELMU),
"MLLWINDOW"
)
27
self.assertEqual(algs[0].getType(),
"CP::DileptonInvariantMassWindowSelectorAlg"
)
28
self.assertEqual(prop(algs[0],
"lowMLL"
), 80000.0)
29
self.assertEqual(prop(algs[0],
"highMLL"
), 100000.0)
30
self.assertFalse(prop(algs[0],
"vetoMode"
,
False
))
31
32
def
test_veto
(self):
33
algs = named(
run
(
"MLLWINDOW 80000 100000 veto"
, containers=ELMU),
"MLLWINDOW"
)
34
self.assertTrue(prop(algs[0],
"vetoMode"
))
35
36
37
class
TestMLLOSSF
(unittest.TestCase):
38
def
test_ossf
(self):
39
algs = named(
run
(
"MLL_OSSF 80000 100000"
, containers=ELMU),
"MLL_OSSF"
)
40
self.assertEqual(algs[0].getType(),
"CP::DileptonOSSFInvariantMassWindowSelectorAlg"
)
41
self.assertEqual(prop(algs[0],
"lowMll"
), 80000.0)
42
self.assertEqual(prop(algs[0],
"highMll"
), 100000.0)
43
self.assertFalse(prop(algs[0],
"vetoMode"
,
False
))
44
45
def
test_veto
(self):
46
algs = named(
run
(
"MLL_OSSF 80000 100000 veto"
, containers=ELMU),
"MLL_OSSF"
)
47
self.assertTrue(prop(algs[0],
"vetoMode"
))
48
49
def
test_truth_routing
(self):
50
algs = named(
run
(
"MLL_OSSF 80000 100000"
,
51
containers={
"electrons"
:
"AnaTruthElectrons"
,
"muons"
:
"AnaTruthMuons"
}),
"MLL_OSSF"
)
52
# truth containers must populate the truth* handles, not the reco ones
53
self.assertNotEqual(prop(algs[0],
"truthElectrons"
,
""
),
""
)
54
self.assertNotEqual(prop(algs[0],
"truthMuons"
,
""
),
""
)
55
56
57
class
TestCharge
(unittest.TestCase):
58
def
test_os_ss
(self):
59
for
kw, osmode
in
[(
"OS"
,
True
), (
"SS"
,
False
)]:
60
with
self.subTest(kw=kw):
61
algs = named(
run
(kw, containers=ELMU), f
"_{kw}_"
)
62
self.assertEqual(algs[0].getType(),
"CP::ChargeSelectorAlg"
)
63
self.assertEqual(prop(algs[0],
"OS"
), osmode)
64
65
def
test_truth_routing
(self):
66
algs = named(
run
(
"OS"
, containers={
"electrons"
:
"AnaTruthElectrons"
}),
"_OS_"
)
67
self.assertNotEqual(prop(algs[0],
"truthElectrons"
,
""
),
""
)
68
69
def
test_missing_input
(self):
70
self.assertRaises(ValueError, run,
"OS"
)
71
72
def
test_subset_selector
(self):
73
# "OS el" restricts the charge computation to electrons only
74
algs = named(
run
(
"OS el"
, containers=ELMU),
"_OS_"
)
75
self.assertNotEqual(prop(algs[0],
"electrons"
,
""
),
""
)
76
self.assertEqual(prop(algs[0],
"muons"
,
""
),
""
)
77
78
79
if
__name__ ==
"__main__"
:
80
unittest.main()
python.EventSelectionConfigDilepton_unitTest.TestCharge
Definition
EventSelectionConfigDilepton_unitTest.py:57
python.EventSelectionConfigDilepton_unitTest.TestCharge.test_subset_selector
test_subset_selector(self)
Definition
EventSelectionConfigDilepton_unitTest.py:72
python.EventSelectionConfigDilepton_unitTest.TestCharge.test_missing_input
test_missing_input(self)
Definition
EventSelectionConfigDilepton_unitTest.py:69
python.EventSelectionConfigDilepton_unitTest.TestCharge.test_os_ss
test_os_ss(self)
Definition
EventSelectionConfigDilepton_unitTest.py:58
python.EventSelectionConfigDilepton_unitTest.TestCharge.test_truth_routing
test_truth_routing(self)
Definition
EventSelectionConfigDilepton_unitTest.py:65
python.EventSelectionConfigDilepton_unitTest.TestMLLOSSF
Definition
EventSelectionConfigDilepton_unitTest.py:37
python.EventSelectionConfigDilepton_unitTest.TestMLLOSSF.test_truth_routing
test_truth_routing(self)
Definition
EventSelectionConfigDilepton_unitTest.py:49
python.EventSelectionConfigDilepton_unitTest.TestMLLOSSF.test_veto
test_veto(self)
Definition
EventSelectionConfigDilepton_unitTest.py:45
python.EventSelectionConfigDilepton_unitTest.TestMLLOSSF.test_ossf
test_ossf(self)
Definition
EventSelectionConfigDilepton_unitTest.py:38
python.EventSelectionConfigDilepton_unitTest.TestMLLWindow
Definition
EventSelectionConfigDilepton_unitTest.py:24
python.EventSelectionConfigDilepton_unitTest.TestMLLWindow.test_veto
test_veto(self)
Definition
EventSelectionConfigDilepton_unitTest.py:32
python.EventSelectionConfigDilepton_unitTest.TestMLLWindow.test_window
test_window(self)
Definition
EventSelectionConfigDilepton_unitTest.py:25
python.EventSelectionConfigDilepton_unitTest.TestMLL
Definition
EventSelectionConfigDilepton_unitTest.py:12
python.EventSelectionConfigDilepton_unitTest.TestMLL.test_missing_input
test_missing_input(self)
Definition
EventSelectionConfigDilepton_unitTest.py:20
python.EventSelectionConfigDilepton_unitTest.TestMLL.test_mll
test_mll(self)
Definition
EventSelectionConfigDilepton_unitTest.py:13
run
int run(int argc, char *argv[])
Definition
ttree2hdf5.cxx:28
Generated on
for ATLAS Offline Software by
1.17.0