ATLAS Offline Software
FexEmulatedTowersConfig.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 #
4 
5 from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
6 from AthenaConfiguration.ComponentFactory import CompFactory
7 from AthenaConfiguration.Enums import Format
8 
9 def jFexEmulatedTowersCfg(flags, name="jFexEmulatedTowerMaker",writeKey="L1_jFexEmulatedTowers"):
10  """
11  Config for emulating jFex input data from LATOME readout
12  """
14 
15  emulator = CompFactory.LVL1.jFexEmulatedTowers(name)
16  emulator.SCell = flags.Trigger.L1.L1CaloSuperCellContainerName
17  emulator.jTowersWriteKey = writeKey
18  emulator.isDATA = not flags.Input.isMC
19  acc.addEventAlgo(emulator)
20 
21  return acc
22 
23 def eFexEmulatedTowersCfg(flags, name, writeKey = "L1_eFexEmulatedTowers"):
24  """
25  Config for emulating eFex input data from LATOME readout
26  """
28 
29  emulator = CompFactory.LVL1.eFexTowerBuilder(name,ApplyMasking=not flags.Input.isMC)
30  emulator.eFexContainerWriteKey = writeKey
31  acc.addEventAlgo(emulator)
32 
33  return acc
34 
35 
36 if __name__ == '__main__':
37  from AthenaConfiguration.AllConfigFlags import initConfigFlags
38  from AthenaCommon.Logging import logging
39  import glob
40  import sys
41 
42  import argparse
43  parser = argparse.ArgumentParser(prog='python -m L1CaloFEXAlgos.FexEmulatedTowersConfig',
44  description="""Emulator tools for FEX towers athena script.\n\n
45  Example: python -m L1CaloFEXAlgos.FexEmulatedTowersConfig --filesInput "data22*" --evtMax 10 --outputs jTowers """)
46  parser.add_argument('--evtMax',type=int,default=-1,help="number of events")
47  parser.add_argument('--filesInput',nargs='+',help="input files",required=True)
48  parser.add_argument('--outputs',nargs='+',choices={"jTowers","eTowers"},required=True, help="What data to decode and emulate")
49  parser.add_argument('--outputLevel',default="WARNING",choices={ 'INFO','WARNING','DEBUG','VERBOSE'})
50  args = parser.parse_args()
51 
52 
53  log = logging.getLogger('FexEmulatedTowersConfig')
54  log.setLevel(logging.DEBUG)
55 
56  from AthenaCommon import Constants
57  algLogLevel = getattr(Constants,args.outputLevel)
58 
59  flags = initConfigFlags()
60  if any(["data" in f for f in args.filesInput]):
61  flags.Trigger.triggerConfig='DB'
62 
63  flags.Exec.OutputLevel = algLogLevel
64  flags.Exec.MaxEvents = args.evtMax
65  flags.Input.Files = [file for x in args.filesInput for file in glob.glob(x)]
66  flags.Concurrency.NumThreads = 1
67  flags.Concurrency.NumConcurrentEvents = 1
68 
69  if not flags.Input.isMC:
70  from AthenaConfiguration.TestDefaults import defaultGeometryTags
71  flags.GeoModel.AtlasVersion = defaultGeometryTags.autoconfigure(flags)
72 
73  if any(["data" in f for f in args.filesInput]):
74  s=args.filesInput[0].replace('*','').replace('.data','')
75  flags.Output.AODFileName = "AOD."+(s.split("/")[-1]).split('_SFO')[0]+"pool.root"
76  else:
77  flags.Output.AODFileName = 'AOD.pool.root'
78 
79  flags.Trigger.EDMVersion = 3
80  flags.Trigger.doLVL1 = True
81  flags.Trigger.enableL1CaloPhase1 = True
82 
83  # Enable only calo for this test
84  from AthenaConfiguration.DetectorConfigFlags import setupDetectorsFromList
85  setupDetectorsFromList(flags,['LAr','Tile','MBTS'],True)
86 
87  flags.lock()
88 
89 
90  # Set up the main service "acc"
91  from AthenaConfiguration.MainServicesConfig import MainServicesCfg
92  acc = MainServicesCfg(flags)
93 
94  # The decoderAlg needs to load ByteStreamMetadata for the detector mask
95  from TriggerJobOpts.TriggerByteStreamConfig import ByteStreamReadCfg
96  acc.merge(ByteStreamReadCfg(flags))
97 
98 
99  # Generate run3 L1 menu
100  from TrigConfigSvc.TrigConfigSvcCfg import L1ConfigSvcCfg
101  acc.merge(L1ConfigSvcCfg(flags))
102 
103  decoderTools = []
104  outputEDM = []
105  maybeMissingRobs = []
106 
107  def addEDM(edmType, edmName):
108  auxType = edmType.replace('Container','AuxContainer')
109  return [f'{edmType}#{edmName}',
110  f'{auxType}#{edmName}Aux.']
111 
112 
113 
116 
117  # Decodes LATOME into SCell container
118  from L1CaloFEXSim.L1CaloFEXSimCfg import ReadSCellFromByteStreamCfg,TriggerTowersInputCfg
119  acc.merge(ReadSCellFromByteStreamCfg(flags))
120 
121  # Creates the TriggerTower container
122  acc.merge(TriggerTowersInputCfg(flags))
123 
124 
125 
128  if 'jTowers' in args.outputs:
129  acc.merge(jFexEmulatedTowersCfg(flags,'jFexEmulatedTowers'))
130  outputEDM += addEDM('xAOD::jFexTowerContainer', 'L1_jFexEmulatedTowers')
131 
132  # decode any data towers for comparison with emulated
133  from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig import jFexInputByteStreamToolCfg
134  inputjFexTool = acc.popToolsAndMerge(jFexInputByteStreamToolCfg(flags, 'jFexInputBSDecoder'))
135  for module_id in inputjFexTool.ROBIDs:
136  maybeMissingRobs.append(module_id)
137 
138  decoderTools += [inputjFexTool]
139  # saving/adding the jTower xAOD container
140  outputEDM += addEDM('xAOD::jFexTowerContainer', inputjFexTool.jTowersWriteKey.Path)
141 
142 
145  if 'eTowers' in args.outputs:
146  acc.merge(eFexEmulatedTowersCfg(flags,'L1_eFexEmulatedTowers'))
147  outputEDM += addEDM('xAOD::eFexTowerContainer', 'L1_eFexEmulatedTowers')
148 
149  # decode any data towers for comparison with emulated
150  from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig import eFexByteStreamToolCfg
151  inputeFexTool = acc.popToolsAndMerge(eFexByteStreamToolCfg(
152  flags,'eFexBSDecoder',TOBs=False,xTOBs=False,decodeInputs=True))
153  for module_id in inputeFexTool.ROBIDs:
154  maybeMissingRobs.append(module_id)
155 
156  decoderTools += [inputeFexTool]
157  # saving/adding the eTower xAOD container
158  outputEDM += addEDM('xAOD::eFexTowerContainer', 'L1_eFexDataTowers')
159 
160  #
161  decoderAlg = CompFactory.L1TriggerByteStreamDecoderAlg(name="L1TriggerByteStreamDecoder",
162  DecoderTools=decoderTools, OutputLevel=algLogLevel,
163  MaybeMissingROBs=maybeMissingRobs)
164 
165  acc.addEventAlgo(decoderAlg, sequenceName='AthAlgSeq')
166 
167 
168  # Saving containers
169  from OutputStreamAthenaPool.OutputStreamConfig import OutputStreamCfg
170  log.debug('Adding the following output EDM to ItemList: %s', outputEDM)
171  acc.merge(OutputStreamCfg(flags, 'AOD', ItemList=outputEDM))
172 
173  acc.getEventAlgo("EventInfoTagBuilder").PropagateInput = (flags.Input.Format != Format.BS)
174 
175  if acc.run().isFailure():
176  sys.exit(1)
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
L1CaloFEXSimCfg.ReadSCellFromByteStreamCfg
def ReadSCellFromByteStreamCfg(flags, key='SCell', SCmask=True)
Definition: L1CaloFEXSimCfg.py:24
L1CaloFEXSimCfg.TriggerTowersInputCfg
def TriggerTowersInputCfg(flags)
Definition: L1CaloFEXSimCfg.py:64
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.OutputStreamConfig.OutputStreamCfg
def OutputStreamCfg(flags, streamName, ItemList=[], MetadataItemList=[], disableEventTag=False, trigNavThinningSvc=None, takeItemsFromInput=False, extendProvenanceRecord=True, AcceptAlgs=[], HelperTools=[])
Definition: OutputStreamConfig.py:12
python.ByteStreamConfig.ByteStreamReadCfg
def ByteStreamReadCfg(flags, type_names=None)
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:25
L1CaloFEXByteStreamConfig.jFexInputByteStreamToolCfg
def jFexInputByteStreamToolCfg(flags, name, *writeBS=False)
Definition: L1CaloFEXByteStreamConfig.py:232
FexEmulatedTowersConfig.eFexEmulatedTowersCfg
def eFexEmulatedTowersCfg(flags, name, writeKey="L1_eFexEmulatedTowers")
Definition: FexEmulatedTowersConfig.py:23
python.DetectorConfigFlags.setupDetectorsFromList
def setupDetectorsFromList(flags, detectors, toggle_geometry=False, validate_only=False)
Definition: DetectorConfigFlags.py:354
python.MainServicesConfig.MainServicesCfg
def MainServicesCfg(flags, LoopMgr='AthenaEventLoopMgr')
Definition: MainServicesConfig.py:260
python.TrigConfigSvcCfg.L1ConfigSvcCfg
def L1ConfigSvcCfg(flags)
Definition: TrigConfigSvcCfg.py:198
FexEmulatedTowersConfig.addEDM
def addEDM(edmType, edmName)
Definition: FexEmulatedTowersConfig.py:107
python.AllConfigFlags.initConfigFlags
def initConfigFlags()
Definition: AllConfigFlags.py:19
FexEmulatedTowersConfig.jFexEmulatedTowersCfg
def jFexEmulatedTowersCfg(flags, name="jFexEmulatedTowerMaker", writeKey="L1_jFexEmulatedTowers")
Definition: FexEmulatedTowersConfig.py:9
L1CaloFEXByteStreamConfig.eFexByteStreamToolCfg
def eFexByteStreamToolCfg(flags, name, *writeBS=False, TOBs=True, xTOBs=False, multiSlice=False, decodeInputs=False)
Definition: L1CaloFEXByteStreamConfig.py:8
Trk::split
@ split
Definition: LayerMaterialProperties.h:38