ATLAS Offline Software
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
7
class
L1MenuJSONConverter
(
object
):
8
9
def
__init__
(self, l1menu = None, outputFile = None, bgsOutputFile = None, inputFile = None ):
10
self.
menu
= l1menu
11
self.
inputFile
= inputFile
12
self.
outputFile
= outputFile
13
self.
bgsOutputFile
= bgsOutputFile
14
15
def
writeJSON
(self,pretty=False):
16
import
json
17
18
if
not
self.
outputFile
:
19
log.warning(
"Can't write json file since no name was provided"
)
20
return
21
22
# L1Menu json
23
confObj = self.
generateJSON
()
24
with
open( self.
outputFile
, mode=
"wt"
)
as
fh:
25
json.dump(confObj, fh, indent = 4
if
pretty
else
None
, separators=(
','
,
': '
))
26
fh.write(
"\n"
)
27
log.info(
"Wrote %s"
, self.
outputFile
)
28
29
if
self.
bgsOutputFile
is
not
None
:
30
confObj = self.
generateJsonBunchgroupset
()
31
with
open( self.
bgsOutputFile
, mode=
"wt"
)
as
fh:
32
json.dump(confObj, fh, indent = 4
if
pretty
else
None
, separators=(
','
,
': '
))
33
fh.write(
"\n"
)
34
log.info(
"Wrote %s"
, self.
bgsOutputFile
)
35
36
return
self.
outputFile
37
38
39
def
generateJSON
(self):
40
confObj = {
41
"filetype"
:
"l1menu"
,
42
"name"
: self.
menu
.menuName,
43
"run"
: 3,
# will be useful for later (we also record this for Run 1 and 2)
44
"items"
: self.
menu
.items.json(),
45
"thresholds"
: {}
46
}
47
48
# thresholds
49
confObj[
"thresholds"
][
"internal"
] = {
50
"type"
:
"internal"
,
51
"names"
: [ f
"BGRP{bg.internalNumber}"
for
bg
in
self.
menu
.ctp.bunchGroupSet.bunchGroups] + \
52
[ f
"RNDM{i}"
for
i
in
range(0,len(self.
menu
.ctp.random.names)) ],
53
"randoms"
: { f
"RNDM{i}"
: {
"cut"
: c }
for
i,c
in
enumerate( self.
menu
.ctp.random.cuts ) }
54
}
55
56
# run 3 thresholds
57
confObj[
"thresholds"
].update( self.
menu
.thresholds.json() )
58
59
# legacy calo thresholds
60
confObj[
"thresholds"
][
"legacyCalo"
] = self.
menu
.thresholds.jsonLegacy()
61
62
# topo algorithms
63
confObj[
"topoAlgorithms"
] = self.
menu
.topoAlgos.json()
64
65
# board definition
66
confObj[
"boards"
] = self.
menu
.boards.json()
67
68
# connectors definition
69
confObj[
"connectors"
] = self.
menu
.connectors.json()
70
71
# CTP input cabling definition
72
confObj[
"ctp"
] = self.
menu
.ctp.json()
73
74
return
confObj
75
76
77
def
generateJsonBunchgroupset
(self):
78
confObj = {
79
"filetype"
:
"bunchgroupset"
,
80
"name"
: self.
menu
.menuName,
81
"bunchGroups"
: self.
menu
.ctp.bunchGroupSet.json()
82
}
83
return
confObj
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter
Definition
L1Menu2JSON.py:7
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter.inputFile
inputFile
Definition
L1Menu2JSON.py:11
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter.generateJsonBunchgroupset
generateJsonBunchgroupset(self)
Definition
L1Menu2JSON.py:77
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter.menu
menu
Definition
L1Menu2JSON.py:10
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter.generateJSON
generateJSON(self)
Definition
L1Menu2JSON.py:39
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter.bgsOutputFile
bgsOutputFile
Definition
L1Menu2JSON.py:13
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter.writeJSON
writeJSON(self, pretty=False)
Definition
L1Menu2JSON.py:15
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter.__init__
__init__(self, l1menu=None, outputFile=None, bgsOutputFile=None, inputFile=None)
Definition
L1Menu2JSON.py:9
python.L1.Base.L1Menu2JSON.L1MenuJSONConverter.outputFile
outputFile
Definition
L1Menu2JSON.py:12
object
Generated on
for ATLAS Offline Software by
1.14.0