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) )
32 def eFexTOBDecoratorCfg(flags, name, eFexEMRoIContainer = "L1_eEMRoI", eFexTauRoIContainer = "L1_eTauRoI", ExtraInputs = []):
34 Configure the eFEX TOB decorator algorithm
35 Requires the eFEXTOBEtTool
39 decorator = CompFactory.LVL1.eFexTOBDecorator(name, eFexEMRoIContainer = eFexEMRoIContainer, eFexTauRoIContainer = eFexTauRoIContainer)
42 if eFexEMRoIContainer !=
"L1_eEMRoI":
43 decorator.RetaCoreDecDecorKey = eFexEMRoIContainer+
".RetaCoreDec"
44 decorator.RetaEnvDecDecorKey = eFexEMRoIContainer+
".RetaEnvDec"
45 decorator.RetaEMDecDecorKey = eFexEMRoIContainer+
".RhadEMDec"
46 decorator.RhadHadDecDecorKey = eFexEMRoIContainer+
".RhadHadDec"
47 decorator.WstotDenDecDecorKey = eFexEMRoIContainer+
".WstotDenDec"
48 decorator.WstotNumDecDecorKey = eFexEMRoIContainer+
".WstotNumDec"
49 decorator.ClusterSCellEtSumsDecorKey = eFexEMRoIContainer+
".ClusterSCellEtSums"
51 if eFexEMRoIContainer !=
"L1_eTauRoI":
52 decorator.RCoreDecorKey = eFexTauRoIContainer+
".RCoreDec"
53 decorator.REnvDecorKey = eFexTauRoIContainer+
".REnvDec"
54 decorator.REMCoreDecorKey = eFexTauRoIContainer+
".REMCoreDec"
55 decorator.REMHadDecorKey = eFexTauRoIContainer+
".REMHadDec"
57 decorator.ExtraInputs = ExtraInputs
59 acc.addEventAlgo(decorator)
66 Configure the eFEX TOB decorator algorithm
67 Requires the eFEXTOBEtTool
71 decorator = CompFactory.LVL1.eFexTOBSuperCellDecorator(name, eFexEMRoIContainer = eFexEMRoIContainer, eFexTauRoIContainer = eFexTauRoIContainer)
73 acc.addEventAlgo(decorator)
79 if __name__ ==
'__main__':
80 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
81 from AthenaCommon.Logging
import logging
86 parser = argparse.ArgumentParser(prog=
'python -m L1CaloFEXAlgos.L1CaloFEXAlgosConfig',
87 description=
"""Decorator tool for FEX towers athena script.\n\n
88 Example: python -m L1CaloFEXAlgos.L1CaloFEXAlgosConfig --filesInput "data22*" --evtMax 10 --outputs eTOBs """)
89 parser.add_argument(
'--evtMax',type=int,default=-1,help=
"number of events")
90 parser.add_argument(
'--filesInput',nargs=
'+',help=
"input files",required=
True)
91 parser.add_argument(
'--outputLevel',default=
"WARNING",choices={
'INFO',
'WARNING',
'DEBUG',
'VERBOSE'})
92 parser.add_argument(
'--outputs',nargs=
'+',choices={
"jTowers",
"gTowers",
"jTOBs",
"eTOBs",
"eTOBsML"},required=
True, help=
"What data to decode and output.")
93 args = parser.parse_args()
96 log = logging.getLogger(
'L1CaloFEXAlgosConfig')
97 log.setLevel(logging.DEBUG)
99 from AthenaCommon
import Constants
100 algLogLevel = getattr(Constants,args.outputLevel)
103 if any([
"data" in f
for f
in args.filesInput]):
104 flags.Trigger.triggerConfig=
'DB'
106 flags.Exec.OutputLevel = algLogLevel
107 flags.Exec.MaxEvents = args.evtMax
108 flags.Input.Files = [file
for x
in args.filesInput
for file
in glob.glob(x)]
109 flags.Concurrency.NumThreads = 1
110 flags.Concurrency.NumConcurrentEvents = 1
112 if not flags.Input.isMC:
113 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
114 flags.GeoModel.AtlasVersion = defaultGeometryTags.autoconfigure(flags)
116 if any([
"data" in f
for f
in args.filesInput]):
118 flags.Output.AODFileName =
"AOD."+(s.split(
"/")[-1]).
split(
'_SFO')[0]+
"pool.root"
120 flags.Output.AODFileName =
'AOD.pool.root'
122 flags.Trigger.EDMVersion = 3
123 flags.Trigger.doLVL1 =
True
124 flags.Trigger.enableL1CaloPhase1 =
True
127 from AthenaConfiguration.DetectorConfigFlags
import setupDetectorsFromList
134 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
138 from TriggerJobOpts.TriggerByteStreamConfig
import ByteStreamReadCfg
142 from TrigConfigSvc.TrigConfigSvcCfg
import L1ConfigSvcCfg
147 maybeMissingRobs = []
150 auxType = edmType.replace(
'Container',
'AuxContainer')
151 return [f
'{edmType}#{edmName}',
152 f
'{auxType}#{edmName}Aux.']
157 if 'jTOBs' in args.outputs:
158 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import jFexRoiByteStreamToolCfg
160 for module_id
in jFexTool.ROBIDs:
161 maybeMissingRobs.append(module_id)
163 decoderTools += [jFexTool]
169 if 'jTowers' in args.outputs:
171 for module_id
in inputjFexTool.ROBIDs:
172 maybeMissingRobs.append(module_id)
174 decoderTools += [inputjFexTool]
176 outputEDM +=
addEDM(
'xAOD::jFexTowerContainer', inputjFexTool.jTowersWriteKey.Path)
182 if 'eTOBs' in args.outputs:
183 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import eFexByteStreamToolCfg
184 eFexTool = acc.popToolsAndMerge(
eFexByteStreamToolCfg(flags,
'eFexBSDecoder', TOBs=
True, xTOBs=
False, decodeInputs=
False))
185 for module_id
in eFexTool.ROBIDs:
186 maybeMissingRobs.append(module_id)
188 decoderTools += [eFexTool]
190 outputEDM +=
addEDM(
'xAOD::eFexEMRoIContainer', eFexTool.eEMContainerWriteKey.Path)
191 outputEDM +=
addEDM(
'xAOD::eFexTauRoIContainer', eFexTool.eTAUContainerWriteKey.Path)
195 decoderAlg = CompFactory.L1TriggerByteStreamDecoderAlg(name=
"L1TriggerByteStreamDecoder",
196 DecoderTools=decoderTools, OutputLevel=algLogLevel, MaybeMissingROBs=maybeMissingRobs)
197 acc.addEventAlgo(decoderAlg, sequenceName=
'AthAlgSeq')
202 if 'gTOBs' in args.outputs:
203 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import gFexByteStreamToolCfg
205 decoderTools += [gFexTool]
211 if 'gTowers' in args.outputs:
213 decoderTools += [inputgFexTool]
215 outputEDM +=
addEDM(
'xAOD::gFexTowerContainer', inputgFexTool.gTowersWriteKey.Path)
217 decoderAlg = CompFactory.L1TriggerByteStreamDecoderAlg(name=
"L1TriggerByteStreamDecoder",
218 DecoderTools=decoderTools, OutputLevel=algLogLevel)
220 acc.addEventAlgo(decoderAlg, sequenceName=
'AthAlgSeq')
227 from L1CaloFEXSim.L1CaloFEXSimCfg
import ReadSCellFromByteStreamCfg,TriggerTowersInputCfg
234 if 'jTowers' in args.outputs:
236 acc.merge(DecoratorAlgo)
239 if 'eTOBs' in args.outputs:
241 acc.merge(DecoratorAlgo)
244 if 'eTOBsML' in args.outputs:
246 acc.merge(DecoratorAlgo)
249 if 'gTowers' in args.outputs:
251 acc.merge(gTowerDecoratorAlgo)
255 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
256 log.debug(
'Adding the following output EDM to ItemList: %s', outputEDM)
259 acc.getEventAlgo(
"EventInfoTagBuilder").PropagateInput = (flags.Input.Format != Format.BS)
261 if acc.run().isFailure():