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 from L1CaloFEXSim.L1CaloFEXSimCfg
import eFEXTOBEtToolCfg
42 decorator = CompFactory.LVL1.eFexTOBDecorator(name, eFexEMRoIContainer = eFexEMRoIContainer, eFexTauRoIContainer = eFexTauRoIContainer)
45 if eFexEMRoIContainer !=
"L1_eEMRoI":
46 decorator.RetaCoreDecDecorKey = eFexEMRoIContainer+
".RetaCoreDec"
47 decorator.RetaEnvDecDecorKey = eFexEMRoIContainer+
".RetaEnvDec"
48 decorator.RetaEMDecDecorKey = eFexEMRoIContainer+
".RhadEMDec"
49 decorator.RhadHadDecDecorKey = eFexEMRoIContainer+
".RhadHadDec"
50 decorator.WstotDenDecDecorKey = eFexEMRoIContainer+
".WstotDenDec"
51 decorator.WstotNumDecDecorKey = eFexEMRoIContainer+
".WstotNumDec"
52 decorator.ClusterEtSumPSDecorKey = eFexEMRoIContainer+
".ClusterEtSumPS"
53 decorator.ClusterEtSumL1DecorKey = eFexEMRoIContainer+
".ClusterEtSumL1"
54 decorator.ClusterEtSumL2DecorKey = eFexEMRoIContainer+
".ClusterEtSumL2"
55 decorator.ClusterEtSumL3DecorKey = eFexEMRoIContainer+
".ClusterEtSumL3"
57 if eFexEMRoIContainer !=
"L1_eTauRoI":
58 decorator.RCoreDecorKey = eFexTauRoIContainer+
".RCoreDec"
59 decorator.REnvDecorKey = eFexTauRoIContainer+
".REnvDec"
60 decorator.REMCoreDecorKey = eFexTauRoIContainer+
".REMCoreDec"
61 decorator.REMHadDecorKey = eFexTauRoIContainer+
".REMHadDec"
63 decorator.ExtraInputs = ExtraInputs
65 acc.addEventAlgo(decorator)
69 if __name__ ==
'__main__':
70 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
71 from AthenaCommon.Logging
import logging
76 parser = argparse.ArgumentParser(prog=
'python -m L1CaloFEXAlgos.L1CaloFEXAlgosConfig',
77 description=
"""Decorator tool for FEX towers athena script.\n\n
78 Example: python -m L1CaloFEXAlgos.L1CaloFEXAlgosConfig --filesInput "data22*" --evtMax 10 --outputs eTOBs """)
79 parser.add_argument(
'--evtMax',type=int,default=-1,help=
"number of events")
80 parser.add_argument(
'--filesInput',nargs=
'+',help=
"input files",required=
True)
81 parser.add_argument(
'--outputLevel',default=
"WARNING",choices={
'INFO',
'WARNING',
'DEBUG',
'VERBOSE'})
82 parser.add_argument(
'--outputs',nargs=
'+',choices={
"jTowers",
"gTowers",
"jTOBs",
"eTOBs"},required=
True, help=
"What data to decode and output.")
83 args = parser.parse_args()
86 log = logging.getLogger(
'L1CaloFEXAlgosConfig')
87 log.setLevel(logging.DEBUG)
89 from AthenaCommon
import Constants
90 algLogLevel = getattr(Constants,args.outputLevel)
93 if any([
"data" in f
for f
in args.filesInput]):
94 flags.Trigger.triggerConfig=
'DB'
96 flags.Exec.OutputLevel = algLogLevel
97 flags.Exec.MaxEvents = args.evtMax
98 flags.Input.Files = [file
for x
in args.filesInput
for file
in glob.glob(x)]
99 flags.Concurrency.NumThreads = 1
100 flags.Concurrency.NumConcurrentEvents = 1
102 if not flags.Input.isMC:
103 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
104 flags.GeoModel.AtlasVersion = defaultGeometryTags.autoconfigure(flags)
106 if any([
"data" in f
for f
in args.filesInput]):
108 flags.Output.AODFileName =
"AOD."+(s.split(
"/")[-1]).
split(
'_SFO')[0]+
"pool.root"
110 flags.Output.AODFileName =
'AOD.pool.root'
112 flags.Trigger.EDMVersion = 3
113 flags.Trigger.doLVL1 =
True
114 flags.Trigger.enableL1CaloPhase1 =
True
117 from AthenaConfiguration.DetectorConfigFlags
import setupDetectorsFromList
124 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
128 from TriggerJobOpts.TriggerByteStreamConfig
import ByteStreamReadCfg
132 from TrigConfigSvc.TrigConfigSvcCfg
import L1ConfigSvcCfg
137 maybeMissingRobs = []
140 auxType = edmType.replace(
'Container',
'AuxContainer')
141 return [f
'{edmType}#{edmName}',
142 f
'{auxType}#{edmName}Aux.']
147 if 'jTOBs' in args.outputs:
148 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import jFexRoiByteStreamToolCfg
150 for module_id
in jFexTool.ROBIDs:
151 maybeMissingRobs.append(module_id)
153 decoderTools += [jFexTool]
159 if 'jTowers' in args.outputs:
161 for module_id
in inputjFexTool.ROBIDs:
162 maybeMissingRobs.append(module_id)
164 decoderTools += [inputjFexTool]
166 outputEDM +=
addEDM(
'xAOD::jFexTowerContainer', inputjFexTool.jTowersWriteKey.Path)
172 if 'eTOBs' in args.outputs:
173 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import eFexByteStreamToolCfg
174 eFexTool = acc.popToolsAndMerge(
eFexByteStreamToolCfg(flags,
'eFexBSDecoder', TOBs=
True, xTOBs=
False, decodeInputs=
False))
175 for module_id
in eFexTool.ROBIDs:
176 maybeMissingRobs.append(module_id)
178 decoderTools += [eFexTool]
180 outputEDM +=
addEDM(
'xAOD::eFexEMRoIContainer', eFexTool.eEMContainerWriteKey.Path)
181 outputEDM +=
addEDM(
'xAOD::eFexTauRoIContainer', eFexTool.eTAUContainerWriteKey.Path)
185 decoderAlg = CompFactory.L1TriggerByteStreamDecoderAlg(name=
"L1TriggerByteStreamDecoder",
186 DecoderTools=decoderTools, OutputLevel=algLogLevel, MaybeMissingROBs=maybeMissingRobs)
187 acc.addEventAlgo(decoderAlg, sequenceName=
'AthAlgSeq')
192 if 'gTOBs' in args.outputs:
193 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import gFexByteStreamToolCfg
195 decoderTools += [gFexTool]
201 if 'gTowers' in args.outputs:
203 decoderTools += [inputgFexTool]
205 outputEDM +=
addEDM(
'xAOD::gFexTowerContainer', inputgFexTool.gTowersWriteKey.Path)
207 decoderAlg = CompFactory.L1TriggerByteStreamDecoderAlg(name=
"L1TriggerByteStreamDecoder",
208 DecoderTools=decoderTools, OutputLevel=algLogLevel)
210 acc.addEventAlgo(decoderAlg, sequenceName=
'AthAlgSeq')
217 from L1CaloFEXSim.L1CaloFEXSimCfg
import ReadSCellFromByteStreamCfg,TriggerTowersInputCfg
224 if 'jTowers' in args.outputs:
226 acc.merge(DecoratorAlgo)
229 if 'eTOBs' in args.outputs:
231 acc.merge(DecoratorAlgo)
234 if 'gTowers' in args.outputs:
236 acc.merge(gTowerDecoratorAlgo)
240 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
241 log.debug(
'Adding the following output EDM to ItemList: %s', outputEDM)
244 acc.getEventAlgo(
"EventInfoTagBuilder").PropagateInput = (flags.Input.Format != Format.BS)
246 if acc.run().isFailure():