ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TriggerCommon
TriggerMenuMT
python
L1
Base
L1Menu2JSON.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2
3
from
AthenaCommon.Logging
import
logging
4
log = logging.getLogger(__name__)
5
6
from
.L1Menu
import
L1Menu
as
L1MenuRun3
7
from
.L1MenuRun4
import
L1MenuRun4
8
class
L1MenuJSONConverter
:
9
10
def
__init__
(self, l1menu: L1MenuRun3 | L1MenuRun4, outputFile =
None
, bgsOutputFile =
None
, inputFile =
None
):
11
self.
menu
: L1MenuRun3 | L1MenuRun4 = l1menu
12
self.
inputFile
= inputFile
13
self.
outputFile
= outputFile
14
self.
bgsOutputFile
= bgsOutputFile
15
16
def
writeJSON
(self,pretty=False):
17
import
json
18
19
if
not
self.
outputFile
:
20
log.warning(
"Can't write json file since no name was provided"
)
21
return
22
23
# L1Menu json
24
confObj = self.
generateJSON
()
25
with
open( self.
outputFile
, mode=
"wt"
)
as
fh:
26
json.dump(confObj, fh, indent = 4
if
pretty
else
None
, separators=(
','
,
': '
))
27
fh.write(
"\n"
)
28
log.info(
"Wrote %s"
, self.
outputFile
)
29
30
if
self.
bgsOutputFile
is
not
None
:
31
confObj = self.
generateJsonBunchgroupset
()
32
with
open( self.
bgsOutputFile
, mode=
"wt"
)
as
fh:
33
json.dump(confObj, fh, indent = 4
if
pretty
else
None
, separators=(
','
,
': '
))
34
fh.write(
"\n"
)
35
log.info(
"Wrote %s"
, self.
bgsOutputFile
)
36
37
return
self.
outputFile
38
39
40
def
generateJSON
(self):
41
if
isinstance(self.
menu
, L1MenuRun4):
42
return
self.
generateJSONRun4
(self.
menu
)
43
else
:
44
return
self.
generateJSONRun3
(self.
menu
)
45
46
def
generateJSONRun4
(self, menu: L1MenuRun4):
47
confObj = {
48
"filetype"
:
"l1menu"
,
49
"name"
: menu.menuName,
50
"run"
: 4,
51
"items"
: menu.items.json(),
52
"thresholds"
: {}
53
}
54
55
# thresholds
56
confObj[
"thresholds"
][
"internal"
] = {
57
"type"
:
"internal"
,
58
"names"
: [ f
"BGRP{bg.internalNumber}"
for
bg
in
menu.ctp.bunchGroupSet.bunchGroups] + \
59
[ f
"RNDM{i}"
for
i
in
range(0,len(menu.ctp.random.names)) ],
60
"randoms"
: { f
"RNDM{i}"
: {
"cut"
: c }
for
i,c
in
enumerate(menu.ctp.random.cuts ) }
61
}
62
confObj[
"thresholds"
].update(menu.thresholds.json() )
63
64
confObj[
"global"
] = menu.globalAlgos.json()
65
66
# board definition
67
confObj[
"boards"
] = menu.boards.json()
68
69
# connectors definition
70
confObj[
"connectors"
] = menu.connectors.json()
71
72
# CTP input cabling definition
73
# confObj["ctp"] = menu.ctp.json()
74
75
return
confObj
76
77
def
generateJSONRun3
(self, menu: L1MenuRun3):
78
confObj = {
79
"filetype"
:
"l1menu"
,
80
"name"
: menu.menuName,
81
"run"
: 3,
# will be useful for later (we also record this for Run 1 and 2)
82
"items"
: menu.items.json(),
83
"thresholds"
: {}
84
}
85
86
# thresholds
87
confObj[
"thresholds"
][
"internal"
] = {
88
"type"
:
"internal"
,
89
"names"
: [ f
"BGRP{bg.internalNumber}"
for
bg
in
menu.ctp.bunchGroupSet.bunchGroups] + \
90
[ f
"RNDM{i}"
for
i
in
range(0,len(menu.ctp.random.names)) ],
91
"randoms"
: { f
"RNDM{i}"
: {
"cut"
: c }
for
i,c
in
enumerate( menu.ctp.random.cuts ) }
92
}
93
94
# run 3 thresholds
95
confObj[
"thresholds"
].update( menu.thresholds.json() )
96
97
# legacy calo thresholds
98
confObj[
"thresholds"
][
"legacyCalo"
] = menu.thresholds.jsonLegacy()
99
100
# topo algorithms
101
confObj[
"topoAlgorithms"
] = menu.topoAlgos.json()
102
103
# board definition
104
confObj[
"boards"
] = menu.boards.json()
105
106
# connectors definition
107
confObj[
"connectors"
] = menu.connectors.json()
108
109
# CTP input cabling definition
110
confObj[
"ctp"
] = menu.ctp.json()
111
112
return
confObj
113
114
def
generateJsonBunchgroupset
(self):
115
confObj = {
116
"filetype"
:
"bunchgroupset"
,
117
"name"
: self.
menu
.menuName,
118
"bunchGroups"
: self.
menu
.ctp.bunchGroupSet.json()
119
}
120
return
confObj
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter
Definition
L1Menu2JSON.py:8
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter.inputFile
inputFile
Definition
L1Menu2JSON.py:12
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter.generateJsonBunchgroupset
generateJsonBunchgroupset(self)
Definition
L1Menu2JSON.py:114
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter.menu
L1MenuRun3|L1MenuRun4 menu
Definition
L1Menu2JSON.py:11
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter.generateJSON
generateJSON(self)
Definition
L1Menu2JSON.py:40
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter.bgsOutputFile
bgsOutputFile
Definition
L1Menu2JSON.py:14
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter.generateJSONRun3
generateJSONRun3(self, L1MenuRun3 menu)
Definition
L1Menu2JSON.py:77
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter.generateJSONRun4
generateJSONRun4(self, L1MenuRun4 menu)
Definition
L1Menu2JSON.py:46
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter.writeJSON
writeJSON(self, pretty=False)
Definition
L1Menu2JSON.py:16
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter.__init__
__init__(self, L1MenuRun3|L1MenuRun4 l1menu, outputFile=None, bgsOutputFile=None, inputFile=None)
Definition
L1Menu2JSON.py:10
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter.outputFile
outputFile
Definition
L1Menu2JSON.py:13
Generated on
for ATLAS Offline Software by
1.17.0