4 from AthenaConfiguration.ComponentAccumulator
import ComponentAccumulator
5 from AthenaConfiguration.ComponentFactory
import CompFactory
6 from AthenaCommon.Logging
import logging
9 '''Configure reading SCell container from a Pool file like RDO or ESD'''
18 from LArGeoAlgsNV.LArGMConfig
import LArGMCfg
28 from TileGeoModel.TileGMConfig
import TileGMCfg
29 from LArGeoAlgsNV.LArGMConfig
import LArGMCfg
30 from LArCabling.LArCablingConfig
import LArLATOMEMappingCfg
31 from LArCabling.LArCablingConfig
import LArOnOffIdMappingSCCfg
32 from LArCellRec.LArRAWtoSuperCellConfig
import LArRAWtoSuperCellCfg
39 decoderTool = CompFactory.LArLATOMEDecoder(
'LArLATOMEDecoder', ProtectSourceId =
True)
40 decoderAlg = CompFactory.LArRawSCDataReadingAlg(
'LArRawSCDataReadingAlg', LATOMEDecoder=decoderTool)
41 acc.addEventAlgo(decoderAlg)
49 Configure the eFEX TOB Et Tool which recalculates isolation variables
50 The tool requires eTowers as inputs (add eTowerMaker algorithm)
59 eFEXTOBEtTool = CompFactory.LVL1.eFEXTOBEtTool
60 acc.setPrivateTools(eFEXTOBEtTool())
65 '''Configuration to provide TriggerTowers as input to the Fex simulation'''
66 from AthenaConfiguration.Enums
import Format
67 if flags.Input.Format
is Format.POOL:
69 from TrigT1CaloSim.TrigT1CaloSimRun2Config
import Run2TriggerTowerMakerCfg
73 from TrigT1CaloByteStream.LVL1CaloRun2ByteStreamConfig
import LVL1CaloRun2ReadBSCfg
77 def L1CaloFEXSimCfg(flags, eFexTowerInputs = ["L1_eFexDataTowers","L1_eFexEmulatedTowers"],deadMaterialCorrections=True, outputSuffix="", simulateAltTau=False):
78 from AthenaConfiguration.Enums
import Format
80 if not simulateAltTau
and flags.DQ.Environment ==
"tier0":
85 log = logging.getLogger(
'L1CaloFEXSimCfg')
89 sCellType = flags.Trigger.L1.L1CaloSuperCellContainerName
90 if flags.Input.Format
is Format.POOL:
92 if 'L1_eFexEmulatedTowers' in eFexTowerInputs
and "L1_eFexEmulatedTowers" not in flags.Input.Collections:
96 eFexTowerInputs = [l
for l
in eFexTowerInputs
if l !=
"L1_eFexDataTowers"]
98 from AthenaConfiguration.Enums
import LHCPeriod
99 if flags.GeoModel.Run
is LHCPeriod.Run2:
101 from TrigT1CaloFexPerf.EmulationConfig
import emulateSC_Cfg
105 if 'L1_eFexEmulatedTowers' in eFexTowerInputs
and "L1_eFexEmulatedTowers" not in flags.Input.Collections:
109 if "xAODTriggerTowers" not in flags.Input.Collections:
112 if 'L1_eFexEmulatedTowers' in eFexTowerInputs
and "L1_eFexEmulatedTowers" not in flags.Input.Collections:
113 acc.addEventAlgo( CompFactory.LVL1.eFexTowerBuilder(
"L1_eFexEmulatedTowers",CaloCellContainerReadKey=sCellType,ApplyMasking=
not flags.Input.isMC) )
115 if flags.Trigger.L1.doeFex:
116 if eFexTowerInputs==[]:
118 eFEXInputs = CompFactory.LVL1.eTowerMakerFromSuperCells(
'eTowerMakerFromSuperCells',
119 eSuperCellTowerMapperTool = CompFactory.LVL1.eSuperCellTowerMapper(
'eSuperCellTowerMapper', SCell=sCellType))
122 if (
not flags.Trigger.L1.doCaloInputs)
and eFexTowerInputs[0] ==
"L1_eFexDataTowers" and (
"L1_eFexDataTowers" not in flags.Input.Collections):
123 if len(eFexTowerInputs)==1:
124 log.fatal(
"Requested L1_eFexDataTowers but Trigger.L1.doCaloInputs is False, but not secondary collection given")
127 log.warning(
"Requested L1_eFexDataTowers but Trigger.L1.doCaloInputs is False, falling back to secondary")
128 eFexTowerInputs[0] = eFexTowerInputs[1]
129 eFexTowerInputs[1] =
""
130 eFEXInputs = CompFactory.LVL1.eTowerMakerFromEfexTowers(
'eTowerMakerFromEfexTowers')
131 eFEXInputs.InputTowers = eFexTowerInputs[0]
132 eFEXInputs.SecondaryInputTowers = eFexTowerInputs[1]
if len(eFexTowerInputs) > 1
else ""
134 eFEX = CompFactory.LVL1.eFEXDriver(
'eFEXDriver')
135 eFEX.eFEXSysSimTool = CompFactory.LVL1.eFEXSysSim(
'eFEXSysSimTool')
136 eFEX.eFEXSysSimTool.eFEXSimTool = CompFactory.LVL1.eFEXSim(
'eFEXSimTool')
137 eFEX.eFEXSysSimTool.eFEXSimTool.eFEXFPGATool = CompFactory.LVL1.eFEXFPGA(
'eFEXFPGATool')
138 eFEX.eFEXSysSimTool.eFEXSimTool.eFEXFPGATool.eFEXegAlgoTool = CompFactory.LVL1.eFEXegAlgo(
'eFEXegAlgoTool',dmCorr=deadMaterialCorrections)
139 eFEX.eFEXSysSimTool.eFEXSimTool.eFEXFPGATool.eFEXtauAlgoTool = CompFactory.LVL1.eFEXtauAlgo(
"eFEXtauAlgo")
144 eFEX.eFEXSysSimTool.eFEXSimTool.eFEXFPGATool.eFEXtauBDTAlgoTool = CompFactory.LVL1.eFEXtauBDTAlgo(
"eFEXtauBDTAlgo", BDTJsonConfigPath=
"bdt_config_v16.json")
146 from IOVDbSvc.IOVDbSvcConfig
import addFolders
148 acc.merge(
addFolders(flags,
"/TRIGGER/L1Calo/V1/Calibration/EfexNoiseCuts",
"TRIGGER_OFL" if flags.Input.isMC
else "TRIGGER_ONL",className=
"CondAttrListCollection"))
149 eFEXInputs.NoiseCutsKey =
"/TRIGGER/L1Calo/V1/Calibration/EfexNoiseCuts"
150 acc.merge(
addFolders(flags,
"/TRIGGER/L1Calo/V1/Calibration/EfexEnergyCalib",
"TRIGGER_OFL" if flags.Input.isMC
else "TRIGGER_ONL",className=
"CondAttrListCollection"))
151 eFEX.eFEXSysSimTool.eFEXSimTool.eFEXFPGATool.eFEXegAlgoTool.DMCorrectionsKey =
"/TRIGGER/L1Calo/V1/Calibration/EfexEnergyCalib"
153 acc.addEventAlgo(eFEXInputs)
154 acc.addEventAlgo(eFEX)
157 eFEX.eFEXSysSimTool.Key_eFexAltTauOutputContainer=
"L1_eTauRoIAlt"
158 eFEX.eFEXSysSimTool.Key_eFexAltTauxTOBOutputContainer=
"L1_eTauxRoIAlt"
161 if flags.Trigger.L1.dojFex:
163 if flags.Input.Format
is not Format.POOL:
164 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import jFexInputByteStreamToolCfg
167 maybeMissingRobs = []
170 for module_id
in inputjFexTool.ROBIDs:
171 maybeMissingRobs.append(module_id)
173 decoderTools += [inputjFexTool]
174 decoderAlg = CompFactory.L1TriggerByteStreamDecoderAlg(name=
"L1TriggerByteStreamDecoder", DecoderTools=[inputjFexTool], MaybeMissingROBs=maybeMissingRobs)
175 acc.addEventAlgo(decoderAlg)
177 if "L1_jFexEmulatedTowers" not in flags.Input.Collections:
178 from L1CaloFEXAlgos.FexEmulatedTowersConfig
import jFexEmulatedTowersCfg
181 from L1CaloFEXCond.L1CaloFEXCondConfig
import jFexDBConfig
184 jFEXInputs = CompFactory.LVL1.jTowerMakerFromJfexTowers(
'jTowerMakerFromJfexTowers')
185 jFEXInputs.IsMC = flags.Input.isMC
186 jFEXInputs.jSuperCellTowerMapperTool = CompFactory.LVL1.jSuperCellTowerMapper(
'jSuperCellTowerMapper', SCell=sCellType)
187 jFEXInputs.jSuperCellTowerMapperTool.SCellMasking =
not flags.Input.isMC
189 jFEX = CompFactory.LVL1.jFEXDriver(
'jFEXDriver',jFEXSysSimTool=CompFactory.LVL1.jFEXSysSim(
190 'jFEXSysSimTool',jFEXSimTool=CompFactory.LVL1.jFEXSim(
191 'LVL1::jFEXSim',jFEXFPGATool=CompFactory.LVL1.jFEXFPGA(
192 'LVL1::jFEXFPGA',IjFEXFormTOBsTool=CompFactory.LVL1.jFEXFormTOBs(
193 'LVL1::jFEXFormTOBs',IsMC=flags.Input.isMC)))))
194 acc.addEventAlgo(jFEXInputs)
195 acc.addEventAlgo(jFEX)
198 if flags.Trigger.L1.dogFex:
200 if flags.Input.Format
is not Format.POOL:
201 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import gFexInputByteStreamToolCfg
204 maybeMissingRobs = []
207 for module_id
in inputgFexTool.ROBIDs:
208 maybeMissingRobs.append(module_id)
210 decoderTools += [inputgFexTool]
211 decoderAlg = CompFactory.L1TriggerByteStreamDecoderAlg(name=
"L1TriggerByteStreamDecoder", DecoderTools=[inputgFexTool], MaybeMissingROBs=maybeMissingRobs)
212 acc.addEventAlgo(decoderAlg)
214 gFEXInputs = CompFactory.LVL1.gTowerMakerFromGfexTowers(
'gTowerMakerFromGfexTowers')
215 gFEXInputs.IsMC = flags.Input.isMC
216 gFEXInputs.gSuperCellTowerMapperTool = CompFactory.LVL1.gSuperCellTowerMapper(
'gSuperCellTowerMapper', SCell=sCellType)
217 gFEXInputs.gSuperCellTowerMapperTool.SCellMasking =
not flags.Input.isMC
219 gFEXInputs50 = CompFactory.LVL1.gTowerMakerFromGfexTowers(
'gTowerMakerFromGfexTowers50')
220 gFEXInputs50.InputDataTowers =
"L1_gFexDataTowers50"
221 gFEXInputs50.MyGTowers =
"gTower50Container"
222 gFEXInputs50.IsMC = flags.Input.isMC
223 gFEXInputs50.gSuperCellTowerMapperTool = CompFactory.LVL1.gSuperCellTowerMapper(
'gSuperCellTowerMapper50', SCell=sCellType)
224 gFEXInputs50.gSuperCellTowerMapperTool.SCellMasking =
not flags.Input.isMC
226 from L1CaloFEXCond.L1CaloFEXCondConfig
import gFexDBConfig
229 gFEX = CompFactory.LVL1.gFEXDriver(
'gFEXDriver')
230 gFEX.gFEXSysSimTool = CompFactory.LVL1.gFEXSysSim(
'gFEXSysSimTool')
231 acc.addEventAlgo(gFEXInputs)
232 acc.addEventAlgo(gFEXInputs50)
233 acc.addEventAlgo(gFEX)
235 if flags.Trigger.doHLT:
239 from TrigEDMConfig.TriggerEDM
import recordable
241 assert key==
recordable(key), f
'recordable() check failed for {key}'
242 if flags.Trigger.L1.doeFex:
243 check(eFEX.eFEXSysSimTool.Key_eFexEMOutputContainer)
244 check(eFEX.eFEXSysSimTool.Key_eFexTauOutputContainer)
246 check(eFEX.eFEXSysSimTool.Key_eFexAltTauOutputContainer)
247 if flags.Trigger.L1.dojFex:
248 check(jFEX.jFEXSysSimTool.Key_jFexSRJetOutputContainer)
249 check(jFEX.jFEXSysSimTool.Key_jFexLRJetOutputContainer)
250 check(jFEX.jFEXSysSimTool.Key_jFexTauOutputContainer)
251 check(jFEX.jFEXSysSimTool.Key_jFexSumETOutputContainer)
252 check(jFEX.jFEXSysSimTool.Key_jFexMETOutputContainer)
253 check(jFEX.jFEXSysSimTool.Key_jFexFwdElOutputContainer)
254 if flags.Trigger.L1.dogFex:
255 check(gFEX.gFEXSysSimTool.Key_gFexSRJetOutputContainer)
256 check(gFEX.gFEXSysSimTool.Key_gFexLRJetOutputContainer)
257 check(gFEX.gFEXSysSimTool.Key_gFexRhoOutputContainer)
258 check(gFEX.gFEXSysSimTool.Key_gScalarEJwojOutputContainer)
259 check(gFEX.gFEXSysSimTool.Key_gMETComponentsJwojOutputContainer)
260 check(gFEX.gFEXSysSimTool.Key_gMHTComponentsJwojOutputContainer)
261 check(gFEX.gFEXSysSimTool.Key_gMSTComponentsJwojOutputContainer)
262 check(gFEX.gFEXSysSimTool.Key_gMETComponentsNoiseCutOutputContainer)
263 check(gFEX.gFEXSysSimTool.Key_gMETComponentsRmsOutputContainer)
264 check(gFEX.gFEXSysSimTool.Key_gScalarENoiseCutOutputContainer)
265 check(gFEX.gFEXSysSimTool.Key_gScalarERmsOutputContainer)
270 Add 'Sim' to the standard handle path and include user-specified suffix
273 if not key.endswith(
"Sim"): key +=
"Sim"
276 if flags.Trigger.L1.doeFex:
277 eFEX.eFEXSysSimTool.Key_eFexEMOutputContainer=
getSimHandle(
"L1_eEMRoI")
278 eFEX.eFEXSysSimTool.Key_eFexTauOutputContainer=
getSimHandle(
"L1_eTauRoI")
279 eFEX.eFEXSysSimTool.Key_eFexEMxTOBOutputContainer=
getSimHandle(
"L1_eEMxRoI")
280 eFEX.eFEXSysSimTool.Key_eFexTauxTOBOutputContainer=
getSimHandle(
"L1_eTauxRoI")
282 eFEX.eFEXSysSimTool.Key_eFexAltTauOutputContainer=
getSimHandle(
"L1_eTauRoIAlt")
283 eFEX.eFEXSysSimTool.Key_eFexAltTauxTOBOutputContainer=
getSimHandle(
"L1_eTauxRoIAlt")
285 if flags.Trigger.L1.dojFex:
286 jFEX.jFEXSysSimTool.Key_jFexSRJetOutputContainer=
getSimHandle(
"L1_jFexSRJetRoI")
287 jFEX.jFEXSysSimTool.Key_jFexLRJetOutputContainer=
getSimHandle(
"L1_jFexLRJetRoI")
288 jFEX.jFEXSysSimTool.Key_jFexTauOutputContainer=
getSimHandle(
"L1_jFexTauRoI")
289 jFEX.jFEXSysSimTool.Key_jFexSumETOutputContainer=
getSimHandle(
"L1_jFexSumETRoI")
290 jFEX.jFEXSysSimTool.Key_jFexMETOutputContainer=
getSimHandle(
"L1_jFexMETRoI")
291 jFEX.jFEXSysSimTool.Key_jFexFwdElOutputContainer=
getSimHandle(
"L1_jFexFwdElRoI")
292 jFEX.jFEXSysSimTool.Key_xTobOutKey_jJ=
getSimHandle(
"L1_jFexSRJetxRoI")
293 jFEX.jFEXSysSimTool.Key_xTobOutKey_jLJ=
getSimHandle(
"L1_jFexLRJetxRoI")
294 jFEX.jFEXSysSimTool.Key_xTobOutKey_jTau=
getSimHandle(
"L1_jFexTauxRoI")
295 jFEX.jFEXSysSimTool.Key_xTobOutKey_jEM=
getSimHandle(
"L1_jFexFwdElxRoI")
296 if flags.Trigger.L1.dogFex:
297 gFEX.gFEXSysSimTool.Key_gFexSRJetOutputContainer=
getSimHandle(
"L1_gFexSRJetRoI")
298 gFEX.gFEXSysSimTool.Key_gFexLRJetOutputContainer=
getSimHandle(
"L1_gFexLRJetRoI")
299 gFEX.gFEXSysSimTool.Key_gFexRhoOutputContainer=
getSimHandle(
"L1_gFexRhoRoI")
300 gFEX.gFEXSysSimTool.Key_gScalarEJwojOutputContainer=
getSimHandle(
"L1_gScalarEJwoj")
301 gFEX.gFEXSysSimTool.Key_gMETComponentsJwojOutputContainer=
getSimHandle(
"L1_gMETComponentsJwoj")
302 gFEX.gFEXSysSimTool.Key_gMHTComponentsJwojOutputContainer=
getSimHandle(
"L1_gMHTComponentsJwoj")
303 gFEX.gFEXSysSimTool.Key_gMSTComponentsJwojOutputContainer=
getSimHandle(
"L1_gMSTComponentsJwoj")
304 gFEX.gFEXSysSimTool.Key_gMETComponentsNoiseCutOutputContainer=
getSimHandle(
"L1_gMETComponentsNoiseCut")
305 gFEX.gFEXSysSimTool.Key_gMETComponentsRmsOutputContainer=
getSimHandle(
"L1_gMETComponentsRms")
306 gFEX.gFEXSysSimTool.Key_gScalarENoiseCutOutputContainer=
getSimHandle(
"L1_gScalarENoiseCut")
307 gFEX.gFEXSysSimTool.Key_gScalarERmsOutputContainer=
getSimHandle(
"L1_gScalarERms")
312 if __name__ ==
'__main__':
317 p = argparse.ArgumentParser()
318 p.add_argument(
'-i',
'--input',
321 help=
'Key of the input from TrigValInputs to be used, default=%(default)s')
322 p.add_argument(
'-e',
'--execute',
324 help=
'After building the configuration, also process a few events')
325 p.add_argument(
'-n',
'--nevents',
329 help=
'Number of events to process if --execute is used, default=%(default)s')
330 p.add_argument(
'-d',
'--efexdebug',
332 help=
'Activate DEBUG mode for eFEX driver .. this option is required by a unit test')
334 args = p.parse_args()
339 from AthenaConfiguration.AllConfigFlags
import initConfigFlags
340 from TrigValTools.TrigValSteering
import Input
344 flags.Common.isOnline =
True
345 flags.Input.Files = [args.input]
if os.path.isfile(args.input)
else Input.get_input(args.input).paths
346 if not flags.Input.isMC:
347 from AthenaConfiguration.TestDefaults
import defaultGeometryTags
348 flags.GeoModel.AtlasVersion = defaultGeometryTags.autoconfigure(flags)
349 from AthenaConfiguration.Enums
import LHCPeriod
350 flags.IOVDb.GlobalTag =
'CONDBR2-HLTP-2023-01' if flags.GeoModel.Run
is LHCPeriod.Run3
else 'CONDBR2-HLTP-2018-04'
352 flags.IOVDb.GlobalTag =
'OFLCOND-MC23-SDR-RUN3-05'
353 flags.Output.AODFileName =
'AOD.pool.root'
354 flags.Exec.MaxEvents = args.nevents
355 flags.Concurrency.NumThreads = 1
356 flags.Concurrency.NumConcurrentEvents = 1
357 flags.Scheduler.ShowDataDeps =
True
358 flags.Scheduler.CheckDependencies =
True
359 flags.Scheduler.ShowDataFlow =
True
360 flags.Trigger.EDMVersion = 3
361 flags.Trigger.doLVL1 =
True
362 flags.Trigger.enableL1CaloPhase1 =
True
363 flags.Trigger.triggerConfig =
'FILE'
366 from AthenaConfiguration.DetectorConfigFlags
import setupDetectorFlags
374 from AthenaConfiguration.MainServicesConfig
import MainServicesCfg
377 from AthenaConfiguration.Enums
import Format
378 if flags.Input.Format == Format.POOL:
379 from AthenaPoolCnvSvc.PoolReadConfig
import PoolReadCfg
382 from TriggerJobOpts.TriggerByteStreamConfig
import ByteStreamReadCfg
385 from TrigConfigSvc.TrigConfigSvcCfg
import L1ConfigSvcCfg, generateL1Menu, createL1PrescalesFileFromMenu
390 from OutputStreamAthenaPool.OutputStreamConfig
import OutputStreamCfg
392 'xAOD::eFexEMRoIContainer#L1_eEMRoI',
'xAOD::eFexEMRoIAuxContainer#L1_eEMRoIAux.',
393 'xAOD::eFexTauRoIContainer#L1_eTauRoI',
'xAOD::eFexTauRoIAuxContainer#L1_eTauRoIAux.',
394 'xAOD::jFexTauRoIContainer#L1_jFexTauRoI',
'xAOD::jFexTauRoIAuxContainer#L1_jFexTauRoIAux.',
395 'xAOD::jFexSRJetRoIContainer#L1_jFexSRJetRoI',
'xAOD::jFexSRJetRoIAuxContainer#L1_jFexSRJetRoIAux.',
396 'xAOD::jFexLRJetRoIContainer#L1_jFexLRJetRoI',
'xAOD::jFexLRJetRoIAuxContainer#L1_jFexLRJetRoIAux.',
397 'xAOD::jFexMETRoIContainer#L1_jFexMETRoI',
'xAOD::jFexMETRoIAuxContainer#L1_jFexMETRoIAux.',
398 'xAOD::jFexSumETRoIContainer#L1_jFexSumETRoI',
'xAOD::jFexSumETRoIAuxContainer#L1_jFexSumETRoIAux.',
399 'xAOD::gFexJetRoIContainer#L1_gFexSRJetRoI',
'xAOD::gFexJetRoIAuxContainer#L1_gFexSRJetRoIAux.',
400 'xAOD::gFexJetRoIContainer#L1_gFexLRJetRoI',
'xAOD::gFexJetRoIAuxContainer#L1_gFexLRJetRoIAux.',
401 'xAOD::gFexJetRoIContainer#L1_gFexRhoRoI',
'xAOD::gFexJetRoIAuxContainer#L1_gFexRhoRoIAux.',
402 'xAOD::gFexGlobalRoIContainer#L1_gScalarEJwoj',
'xAOD::gFexGlobalRoIAuxContainer#L1_gScalarEJwojAux.',
403 'xAOD::gFexGlobalRoIContainer#L1_gMETComponentsJwoj',
'xAOD::gFexGlobalRoIAuxContainer#L1_gMETComponentsJwojAux.',
404 'xAOD::gFexGlobalRoIContainer#L1_gMHTComponentsJwoj',
'xAOD::gFexGlobalRoIAuxContainer#L1_gMHTComponentsJwojAux.',
405 'xAOD::gFexGlobalRoIContainer#L1_gMSTComponentsJwoj',
'xAOD::gFexGlobalRoIAuxContainer#L1_gMSTComponentsJwojAux.',
406 'xAOD::gFexGlobalRoIContainer#L1_gMETComponentsNoiseCut',
'xAOD::gFexGlobalRoIAuxContainer#L1_gMETComponentsNoiseCutAux.',
407 'xAOD::gFexGlobalRoIContainer#L1_gMETComponentsRms',
'xAOD::gFexGlobalRoIAuxContainer#L1_gMETComponentsRmsAux.',
408 'xAOD::gFexGlobalRoIContainer#L1_gScalarENoiseCut',
'xAOD::gFexGlobalRoIAuxContainer#L1_gScalarENoiseCutAux.',
409 'xAOD::gFexGlobalRoIContainer#L1_gScalarERms',
'xAOD::gFexGlobalRoIAuxContainer#L1_gScalarERmsAux.',
420 acc.getEventAlgo(
"eFEXDriver").OutputLevel = DEBUG
425 with open(
"L1Sim.pkl",
"wb")
as f: