5 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory
import CompFactory
7 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import jFexInputByteStreamToolCfg
8 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import gFexInputByteStreamToolCfg
9 from AthenaConfiguration.Enums
import Format
12 def L1CalojFEXDecoratorCfg(flags, name="jFexTower2SCellDecorator", jTowersReadKey="L1_jFexDataTowers", ExtraInfo = False, SCMasking = True):
16 decorator = CompFactory.LVL1.jFexTower2SCellDecorator(name)
17 decorator.SCell = flags.Trigger.L1.L1CaloSuperCellContainerName
18 decorator.jTowersReadKey = jTowersReadKey
19 decorator.ExtraInfo = ExtraInfo
20 decorator.SCellMasking = SCMasking
21 acc.addEventAlgo(decorator)
28 acc.addEventAlgo( CompFactory.LVL1.gFexTower2SCellDecorator(name, gTowersReadKey=gTowersReadKey) )
34 if __name__ ==
'__main__':
35 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
36 from AthenaCommon.Logging
import logging
41 parser = argparse.ArgumentParser(prog=
'python -m L1CaloFEXAlgos.L1CaloFEXAlgosConfig',
42 description=
"""Decorator tool for FEX towers athena script.\n\n
43 Example: python -m L1CaloFEXAlgos.L1CaloFEXAlgosConfig --filesInput "data22*" --evtMax 10 --outputs eTOBs """)
44 parser.add_argument(
'--evtMax',type=int,default=-1,help=
"number of events")
45 parser.add_argument(
'--filesInput',nargs=
'+',help=
"input files",required=
True)
46 parser.add_argument(
'--outputLevel',default=
"WARNING",choices={
'INFO',
'WARNING',
'DEBUG',
'VERBOSE'})
47 parser.add_argument(
'--outputs',nargs=
'+',choices={
"jTowers",
"gTowers",
"jTOBs",
"eTOBs",
"eTOBsML"},required=
True, help=
"What data to decode and output.")
48 args = parser.parse_args()
51 log = logging.getLogger(
'L1CaloFEXAlgosConfig')
52 log.setLevel(logging.DEBUG)
54 from AthenaCommon
import Constants
55 algLogLevel = getattr(Constants,args.outputLevel)
58 if any([
"data" in f
for f
in args.filesInput]):
59 flags.Trigger.triggerConfig=
'DB'
61 flags.Exec.OutputLevel = algLogLevel
62 flags.Exec.MaxEvents = args.evtMax
63 flags.Input.Files = [file
for x
in args.filesInput
for file
in glob.glob(x)]
64 flags.Concurrency.NumThreads = 1
65 flags.Concurrency.NumConcurrentEvents = 1
67 if not flags.Input.isMC:
68 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
69 flags.GeoModel.AtlasVersion = defaultGeometryTags.autoconfigure(flags)
71 if any([
"data" in f
for f
in args.filesInput]):
73 flags.Output.AODFileName =
"AOD."+(s.split(
"/")[-1]).
split(
'_SFO')[0]+
"pool.root"
75 flags.Output.AODFileName =
'AOD.pool.root'
77 flags.Trigger.EDMVersion = 3
78 flags.Trigger.doLVL1 =
True
79 flags.Trigger.enableL1CaloPhase1 =
True
82 from AthenaConfiguration.DetectorConfigFlags
import setupDetectorsFromList
89 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
93 from TriggerJobOpts.TriggerByteStreamConfig
import ByteStreamReadCfg
97 from TrigConfigSvc.TrigConfigSvcCfg
import L1ConfigSvcCfg
102 maybeMissingRobs = []
105 auxType = edmType.replace(
'Container',
'AuxContainer')
106 return [f
'{edmType}#{edmName}',
107 f
'{auxType}#{edmName}Aux.']
112 if 'jTOBs' in args.outputs:
113 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import jFexRoiByteStreamToolCfg
115 for module_id
in jFexTool.ROBIDs:
116 maybeMissingRobs.append(module_id)
118 decoderTools += [jFexTool]
124 if 'jTowers' in args.outputs:
126 for module_id
in inputjFexTool.ROBIDs:
127 maybeMissingRobs.append(module_id)
129 decoderTools += [inputjFexTool]
131 outputEDM +=
addEDM(
'xAOD::jFexTowerContainer', inputjFexTool.jTowersWriteKey.Path)
137 if 'eTOBs' in args.outputs:
138 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import eFexByteStreamToolCfg
139 eFexTool = acc.popToolsAndMerge(
eFexByteStreamToolCfg(flags,
'eFexBSDecoder', TOBs=
True, xTOBs=
False, decodeInputs=
False))
140 for module_id
in eFexTool.ROBIDs:
141 maybeMissingRobs.append(module_id)
143 decoderTools += [eFexTool]
145 outputEDM +=
addEDM(
'xAOD::eFexEMRoIContainer', eFexTool.eEMContainerWriteKey.Path)
146 outputEDM +=
addEDM(
'xAOD::eFexTauRoIContainer', eFexTool.eTAUContainerWriteKey.Path)
150 decoderAlg = CompFactory.L1TriggerByteStreamDecoderAlg(name=
"L1TriggerByteStreamDecoder",
151 DecoderTools=decoderTools, OutputLevel=algLogLevel, MaybeMissingROBs=maybeMissingRobs)
152 acc.addEventAlgo(decoderAlg, sequenceName=
'AthAlgSeq')
157 if 'gTOBs' in args.outputs:
158 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import gFexByteStreamToolCfg
160 decoderTools += [gFexTool]
166 if 'gTowers' in args.outputs:
168 decoderTools += [inputgFexTool]
170 outputEDM +=
addEDM(
'xAOD::gFexTowerContainer', inputgFexTool.gTowersWriteKey.Path)
172 decoderAlg = CompFactory.L1TriggerByteStreamDecoderAlg(name=
"L1TriggerByteStreamDecoder",
173 DecoderTools=decoderTools, OutputLevel=algLogLevel)
175 acc.addEventAlgo(decoderAlg, sequenceName=
'AthAlgSeq')
182 from L1CaloFEXSim.L1CaloFEXSimCfg
import ReadSCellFromByteStreamCfg,TriggerTowersInputCfg
189 if 'jTowers' in args.outputs:
191 acc.merge(DecoratorAlgo)
194 if 'eTOBs' in args.outputs:
195 acc.addEventAlgo( CompFactory.LVL1.eFexTOBDecorator(
'eFexTOBDecorator') )
198 if 'eTOBsML' in args.outputs:
199 acc.addEventAlgo( CompFactory.LVL1.eFexTOBDecorator(
'eFexTOBSuperCellDecorator') )
202 if 'gTowers' in args.outputs:
204 acc.merge(gTowerDecoratorAlgo)
208 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
209 log.debug(
'Adding the following output EDM to ItemList: %s', outputEDM)
212 acc.getEventAlgo(
"EventInfoTagBuilder").PropagateInput = (flags.Input.Format != Format.BS)
214 if acc.run().isFailure():