ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
Algorithms
EventSelectionAlgorithms
python
EventSelectionConfigSumLeptons_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 SUM_EL_N_MU_N and SUM_EL_N_MU_N_TAU_N (SumNLeptonPtSelectorAlg)."""
4
5
import
unittest
6
from
EventSelectionAlgorithms.EventSelectionConfigTestSupport
import
run, named, prop
7
8
ELMU = {
"electrons"
:
"AnaElectrons"
,
"muons"
:
"AnaMuons"
}
9
ELMUTAU = {
"electrons"
:
"AnaElectrons"
,
"muons"
:
"AnaMuons"
,
"taus"
:
"AnaTaus"
}
10
11
12
class
TestSumElMu
(unittest.TestCase):
13
def
test_shared_threshold_4arg
(self):
14
algs = named(
run
(
"SUM_EL_N_MU_N 25000 >= 2"
, containers=ELMU),
"SUMNELNMU"
)
15
self.assertEqual(len(algs), 1)
16
self.assertEqual(algs[0].getType(),
"CP::SumNLeptonPtSelectorAlg"
)
17
self.assertEqual(prop(algs[0],
"minPtEl"
), 25000.0)
18
self.assertEqual(prop(algs[0],
"minPtMu"
), 25000.0)
19
self.assertEqual(prop(algs[0],
"count"
), 2)
20
21
def
test_separate_thresholds_5arg
(self):
22
algs = named(
run
(
"SUM_EL_N_MU_N 25000 27000 >= 2"
, containers=ELMU),
"SUMNELNMU"
)
23
self.assertEqual(prop(algs[0],
"minPtEl"
), 25000.0)
24
self.assertEqual(prop(algs[0],
"minPtMu"
), 27000.0)
25
26
def
test_extra_selections_7arg
(self):
27
algs = named(
run
(
"SUM_EL_N_MU_N elsel musel 25000 27000 >= 2"
, containers=ELMU),
"SUMNELNMU"
)
28
self.assertIn(
"elsel"
, prop(algs[0],
"electronSelection"
))
29
self.assertIn(
"musel"
, prop(algs[0],
"muonSelection"
))
30
self.assertEqual(prop(algs[0],
"count"
), 2)
31
32
def
test_missing_input
(self):
33
self.assertRaises(ValueError, run,
"SUM_EL_N_MU_N 25000 >= 2"
)
34
35
def
test_bad_argcount
(self):
36
self.assertRaises(ValueError, run,
"SUM_EL_N_MU_N 25000 27000 28000 >= 2"
, containers=ELMU)
37
38
39
class
TestSumElMuTau
(unittest.TestCase):
40
def
test_shared_threshold_4arg
(self):
41
algs = named(
run
(
"SUM_EL_N_MU_N_TAU_N 25000 >= 3"
, containers=ELMUTAU),
"SUMNLEPTONS"
)
42
self.assertEqual(prop(algs[0],
"minPtEl"
), 25000.0)
43
self.assertEqual(prop(algs[0],
"minPtMu"
), 25000.0)
44
self.assertEqual(prop(algs[0],
"minPtTau"
), 25000.0)
45
self.assertEqual(prop(algs[0],
"count"
), 3)
46
47
def
test_separate_thresholds_6arg
(self):
48
algs = named(
run
(
"SUM_EL_N_MU_N_TAU_N 25000 27000 30000 >= 3"
, containers=ELMUTAU),
"SUMNLEPTONS"
)
49
self.assertEqual(prop(algs[0],
"minPtEl"
), 25000.0)
50
self.assertEqual(prop(algs[0],
"minPtMu"
), 27000.0)
51
self.assertEqual(prop(algs[0],
"minPtTau"
), 30000.0)
52
53
def
test_extra_selections_9arg
(self):
54
algs = named(
run
(
"SUM_EL_N_MU_N_TAU_N esel msel tsel 25000 27000 30000 >= 3"
,
55
containers=ELMUTAU),
"SUMNLEPTONS"
)
56
self.assertIn(
"esel"
, prop(algs[0],
"electronSelection"
))
57
self.assertIn(
"msel"
, prop(algs[0],
"muonSelection"
))
58
self.assertIn(
"tsel"
, prop(algs[0],
"tauSelection"
))
59
60
def
test_bad_argcount
(self):
61
self.assertRaises(ValueError, run,
"SUM_EL_N_MU_N_TAU_N 25000 27000 >= 3"
, containers=ELMUTAU)
62
63
64
class
TestSumDressedProperties
(unittest.TestCase):
65
"""useDressedProperties must be enabled when ANY input lepton container is a
66
truth container (not just the electron one)."""
67
68
def
test_set_when_muons_are_truth
(self):
69
algs = named(
run
(
"SUM_EL_N_MU_N 25000 >= 2"
,
70
containers={
"electrons"
:
"AnaElectrons"
,
"muons"
:
"AnaTruthMuons"
}),
"SUMNELNMU"
)
71
self.assertTrue(prop(algs[0],
"useDressedProperties"
))
72
73
def
test_truth_tau_does_not_set_dressed
(self):
74
# dressed kinematics exist only for truth electrons and muons,
75
# so a truth tau must NOT enable them.
76
algs = named(
run
(
"SUM_EL_N_MU_N_TAU_N 25000 >= 3"
,
77
containers={
"electrons"
:
"AnaElectrons"
,
"muons"
:
"AnaMuons"
,
78
"taus"
:
"AnaTruthTaus"
}),
"SUMNLEPTONS"
)
79
self.assertFalse(prop(algs[0],
"useDressedProperties"
,
False
))
80
81
def
test_set_when_muons_are_truth_with_taus_present
(self):
82
algs = named(
run
(
"SUM_EL_N_MU_N_TAU_N 25000 >= 3"
,
83
containers={
"electrons"
:
"AnaElectrons"
,
"muons"
:
"AnaTruthMuons"
,
84
"taus"
:
"AnaTaus"
}),
"SUMNLEPTONS"
)
85
self.assertTrue(prop(algs[0],
"useDressedProperties"
))
86
87
def
test_unset_when_all_reco
(self):
88
algs = named(
run
(
"SUM_EL_N_MU_N 25000 >= 2"
, containers=ELMU),
"SUMNELNMU"
)
89
self.assertFalse(prop(algs[0],
"useDressedProperties"
,
False
))
90
91
92
if
__name__ ==
"__main__"
:
93
unittest.main()
python.EventSelectionConfigSumLeptons_unitTest.TestSumDressedProperties
Definition
EventSelectionConfigSumLeptons_unitTest.py:64
python.EventSelectionConfigSumLeptons_unitTest.TestSumDressedProperties.test_set_when_muons_are_truth
test_set_when_muons_are_truth(self)
Definition
EventSelectionConfigSumLeptons_unitTest.py:68
python.EventSelectionConfigSumLeptons_unitTest.TestSumDressedProperties.test_unset_when_all_reco
test_unset_when_all_reco(self)
Definition
EventSelectionConfigSumLeptons_unitTest.py:87
python.EventSelectionConfigSumLeptons_unitTest.TestSumDressedProperties.test_set_when_muons_are_truth_with_taus_present
test_set_when_muons_are_truth_with_taus_present(self)
Definition
EventSelectionConfigSumLeptons_unitTest.py:81
python.EventSelectionConfigSumLeptons_unitTest.TestSumDressedProperties.test_truth_tau_does_not_set_dressed
test_truth_tau_does_not_set_dressed(self)
Definition
EventSelectionConfigSumLeptons_unitTest.py:73
python.EventSelectionConfigSumLeptons_unitTest.TestSumElMuTau
Definition
EventSelectionConfigSumLeptons_unitTest.py:39
python.EventSelectionConfigSumLeptons_unitTest.TestSumElMuTau.test_extra_selections_9arg
test_extra_selections_9arg(self)
Definition
EventSelectionConfigSumLeptons_unitTest.py:53
python.EventSelectionConfigSumLeptons_unitTest.TestSumElMuTau.test_shared_threshold_4arg
test_shared_threshold_4arg(self)
Definition
EventSelectionConfigSumLeptons_unitTest.py:40
python.EventSelectionConfigSumLeptons_unitTest.TestSumElMuTau.test_bad_argcount
test_bad_argcount(self)
Definition
EventSelectionConfigSumLeptons_unitTest.py:60
python.EventSelectionConfigSumLeptons_unitTest.TestSumElMuTau.test_separate_thresholds_6arg
test_separate_thresholds_6arg(self)
Definition
EventSelectionConfigSumLeptons_unitTest.py:47
python.EventSelectionConfigSumLeptons_unitTest.TestSumElMu
Definition
EventSelectionConfigSumLeptons_unitTest.py:12
python.EventSelectionConfigSumLeptons_unitTest.TestSumElMu.test_bad_argcount
test_bad_argcount(self)
Definition
EventSelectionConfigSumLeptons_unitTest.py:35
python.EventSelectionConfigSumLeptons_unitTest.TestSumElMu.test_separate_thresholds_5arg
test_separate_thresholds_5arg(self)
Definition
EventSelectionConfigSumLeptons_unitTest.py:21
python.EventSelectionConfigSumLeptons_unitTest.TestSumElMu.test_shared_threshold_4arg
test_shared_threshold_4arg(self)
Definition
EventSelectionConfigSumLeptons_unitTest.py:13
python.EventSelectionConfigSumLeptons_unitTest.TestSumElMu.test_missing_input
test_missing_input(self)
Definition
EventSelectionConfigSumLeptons_unitTest.py:32
python.EventSelectionConfigSumLeptons_unitTest.TestSumElMu.test_extra_selections_7arg
test_extra_selections_7arg(self)
Definition
EventSelectionConfigSumLeptons_unitTest.py:26
run
int run(int argc, char *argv[])
Definition
ttree2hdf5.cxx:28
Generated on
for ATLAS Offline Software by
1.17.0