76def L1CaloFEXSimCfg(flags, eFexTowerInputs = ["L1_eFexDataTowers","L1_eFexEmulatedTowers"],deadMaterialCorrections=True, outputSuffix="", simulateAltTau=False):
77 from AthenaConfiguration.Enums
import Format
79 if not simulateAltTau
and flags.DQ.Environment ==
"tier0":
82 acc = ComponentAccumulator()
84 log = logging.getLogger(
'L1CaloFEXSimCfg')
88 sCellType = flags.Trigger.L1.L1CaloSuperCellContainerName
89 if flags.Input.Format
is Format.POOL:
91 if 'L1_eFexEmulatedTowers' in eFexTowerInputs
and "L1_eFexEmulatedTowers" not in flags.Input.Collections:
95 eFexTowerInputs = [l
for l
in eFexTowerInputs
if l !=
"L1_eFexDataTowers"]
97 from AthenaConfiguration.Enums
import LHCPeriod
98 if flags.GeoModel.Run
is LHCPeriod.Run2:
100 from TrigT1CaloFexPerf.EmulationConfig
import emulateSC_Cfg
101 acc.merge(emulateSC_Cfg(flags))
104 if 'L1_eFexEmulatedTowers' in eFexTowerInputs
and "L1_eFexEmulatedTowers" not in flags.Input.Collections:
108 if "xAODTriggerTowers" not in flags.Input.Collections:
112 if not flags.Input.isMC
and len(flags.Input.RunNumbers)>0:
114 runinfo = getLArDTInfoForRun(flags.Input.RunNumbers[0], connstring=
"COOLONL_LAR/CONDBR2")
115 doV6Mapping = (runinfo.FWversion()==6)
117 if doV6Mapping
and len(flags.Input.RunNumbers)>0:
119 from IOVDbSvc.IOVDbSvcConfig
import addOverride
120 acc.merge( addOverride(flags,folder=
"/LAR/Identifier/LatomeMapping",tag=
"LARIdentifierLatomeMapping-fw6") )
123 if flags.Trigger.L1.doeFex:
124 if 'L1_eFexEmulatedTowers' in eFexTowerInputs
and "L1_eFexEmulatedTowers" not in flags.Input.Collections:
125 builderAlg = CompFactory.LVL1.eFexTowerBuilder(
"L1_eFexEmulatedTowers",UseLATOMEv6Mapping=doV6Mapping,
126 CaloCellContainerReadKey=sCellType,ApplyMasking=
not flags.Input.isMC)
127 if flags.Input.isMC: builderAlg.LArLatomeHeaderKey=
""
128 elif doV6Mapping
or len(flags.Input.RunNumbers)==0:
129 builderAlg.MappingFile=
''
131 from LArByteStream.LArRawSCDataReadingConfig
import LArRawSCDataReadingCfg
132 acc.merge(LArRawSCDataReadingCfg(flags))
135 acc.addEventAlgo( builderAlg )
137 if eFexTowerInputs==[]:
139 eFEXInputs = CompFactory.LVL1.eTowerMakerFromSuperCells(
'eTowerMakerFromSuperCells',
140 eSuperCellTowerMapperTool = CompFactory.LVL1.eSuperCellTowerMapper(
'eSuperCellTowerMapper', SCell=sCellType))
143 if (
not flags.Trigger.L1.doCaloInputs)
and eFexTowerInputs[0] ==
"L1_eFexDataTowers" and (
"L1_eFexDataTowers" not in flags.Input.Collections):
144 if len(eFexTowerInputs)==1:
145 log.fatal(
"Requested L1_eFexDataTowers but Trigger.L1.doCaloInputs is False, but not secondary collection given")
148 log.warning(
"Requested L1_eFexDataTowers but Trigger.L1.doCaloInputs is False, falling back to secondary")
149 eFexTowerInputs[0] = eFexTowerInputs[1]
150 eFexTowerInputs[1] =
""
151 eFEXInputs = CompFactory.LVL1.eTowerMakerFromEfexTowers(
'eTowerMakerFromEfexTowers')
152 eFEXInputs.InputTowers = eFexTowerInputs[0]
153 eFEXInputs.SecondaryInputTowers = eFexTowerInputs[1]
if len(eFexTowerInputs) > 1
else ""
155 eFEX = CompFactory.LVL1.eFEXDriver(
'eFEXDriver')
156 eFEX.eFEXSysSimTool = CompFactory.LVL1.eFEXSysSim(
'eFEXSysSimTool')
157 eFEX.eFEXSysSimTool.eFEXSimTool = CompFactory.LVL1.eFEXSim(
'eFEXSimTool')
158 eFEX.eFEXSysSimTool.eFEXSimTool.eFEXFPGATool = CompFactory.LVL1.eFEXFPGA(
'eFEXFPGATool')
161 from TrigConfigSvc.TriggerConfigAccess
import getL1MenuAccess
162 L1_menu = getL1MenuAccess(flags)
164 em_algoVersion = L1_menu.thresholdExtraInfo(
"eEM").
get(
"algoVersion", 0)
165 tau_algoVersion = L1_menu.thresholdExtraInfo(
"eTAU").
get(
"algoVersion", 0)
167 from PathResolver
import PathResolver
168 bdtConfigJsonPath =
PathResolver.FindCalibFile(
"Run3L1CaloSimulation/L1CaloFEXSim/eTAU/" + (
"bdt_config_v17.json" if tau_algoVersion==2
else "bdt_config_v16.json"))
170 eFEX.eFEXSysSimTool.eFEXSimTool.eFEXFPGATool.eFEXegAlgoTool = CompFactory.LVL1.eFEXegAlgo(
'eFEXegAlgoTool',algoVersion=em_algoVersion,dmCorr=deadMaterialCorrections)
171 eFEX.eFEXSysSimTool.eFEXSimTool.eFEXFPGATool.eFEXtauAlgoTool = CompFactory.LVL1.eFEXtauAlgo(
"eFEXtauAlgo")
172 eFEX.eFEXSysSimTool.eFEXSimTool.eFEXFPGATool.eFEXtauBDTAlgoTool = CompFactory.LVL1.eFEXtauBDTAlgo(
"eFEXtauBDTAlgo", BDTJsonConfigPath=bdtConfigJsonPath)
182 from IOVDbSvc.IOVDbSvcConfig
import addFolders
184 acc.merge(addFolders(flags,
"/TRIGGER/L1Calo/V1/Calibration/EfexNoiseCuts",
"TRIGGER_OFL" if flags.Input.isMC
else "TRIGGER_ONL",className=
"CondAttrListCollection"))
185 eFEXInputs.NoiseCutsKey =
"/TRIGGER/L1Calo/V1/Calibration/EfexNoiseCuts"
186 acc.merge(addFolders(flags,
"/TRIGGER/L1Calo/V1/Calibration/EfexEnergyCalib",
"TRIGGER_OFL" if flags.Input.isMC
else "TRIGGER_ONL",className=
"CondAttrListCollection"))
187 eFEX.eFEXSysSimTool.eFEXSimTool.eFEXFPGATool.eFEXegAlgoTool.DMCorrectionsKey =
"/TRIGGER/L1Calo/V1/Calibration/EfexEnergyCalib"
189 acc.addEventAlgo(eFEXInputs)
190 acc.addEventAlgo(eFEX)
193 eFEX.eFEXSysSimTool.Key_eFexAltTauOutputContainer=
"L1_eTauRoIAlt"
194 eFEX.eFEXSysSimTool.Key_eFexAltTauxTOBOutputContainer=
"L1_eTauxRoIAlt"
197 if flags.Trigger.L1.dojFex:
199 if flags.Input.Format
is not Format.POOL:
200 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import jFexInputByteStreamToolCfg
201 inputjFexTool = acc.popToolsAndMerge(jFexInputByteStreamToolCfg(flags,
'jFexInputBSDecoderTool'))
203 maybeMissingRobs = []
206 for module_id
in inputjFexTool.ROBIDs:
207 maybeMissingRobs.append(module_id)
209 decoderTools += [inputjFexTool]
210 decoderAlg = CompFactory.L1TriggerByteStreamDecoderAlg(name=
"L1TriggerByteStreamDecoder", DecoderTools=[inputjFexTool], MaybeMissingROBs=maybeMissingRobs)
211 acc.addEventAlgo(decoderAlg)
213 if "L1_jFexEmulatedTowers" not in flags.Input.Collections:
214 from L1CaloFEXAlgos.FexEmulatedTowersConfig
import jFexEmulatedTowersCfg
215 acc.merge(jFexEmulatedTowersCfg(flags))
217 from L1CaloFEXCond.L1CaloFEXCondConfig
import jFexDBConfig
218 acc.merge(jFexDBConfig(flags))
220 jFEXInputs = CompFactory.LVL1.jTowerMakerFromJfexTowers(
'jTowerMakerFromJfexTowers')
221 jFEXInputs.IsMC = flags.Input.isMC
222 jFEXInputs.jSuperCellTowerMapperTool = CompFactory.LVL1.jSuperCellTowerMapper(
'jSuperCellTowerMapper', SCell=sCellType)
223 jFEXInputs.jSuperCellTowerMapperTool.SCellMasking =
not flags.Input.isMC
225 jFEX = CompFactory.LVL1.jFEXDriver(
'jFEXDriver',jFEXSysSimTool=CompFactory.LVL1.jFEXSysSim(
226 'jFEXSysSimTool',jFEXSimTool=CompFactory.LVL1.jFEXSim(
227 'LVL1::jFEXSim',jFEXFPGATool=CompFactory.LVL1.jFEXFPGA(
228 'LVL1::jFEXFPGA',jFEXLargeRJetAlgoTool=
"",
229 IjFEXFormTOBsTool=CompFactory.LVL1.jFEXFormTOBs(
230 'LVL1::jFEXFormTOBs',IsMC=flags.Input.isMC)))))
231 acc.addEventAlgo(jFEXInputs)
232 acc.addEventAlgo(jFEX)
235 if flags.Trigger.L1.dogFex:
237 if flags.Input.Format
is not Format.POOL:
238 from L1CaloFEXByteStream.L1CaloFEXByteStreamConfig
import gFexInputByteStreamToolCfg
239 inputgFexTool = acc.popToolsAndMerge(gFexInputByteStreamToolCfg(flags,
'gFexInputBSDecoderTool'))
241 maybeMissingRobs = []
244 for module_id
in inputgFexTool.ROBIDs:
245 maybeMissingRobs.append(module_id)
247 decoderTools += [inputgFexTool]
248 decoderAlg = CompFactory.L1TriggerByteStreamDecoderAlg(name=
"L1TriggerByteStreamDecoder", DecoderTools=[inputgFexTool], MaybeMissingROBs=maybeMissingRobs)
249 acc.addEventAlgo(decoderAlg)
252 if not Format.POOL
or (
"L1_gFexEmulatedTowers" not in flags.Input.Collections
and sCellType
in flags.Input.Collections):
253 from L1CaloFEXAlgos.FexEmulatedTowersConfig
import gFexEmulatedTowersCfg
254 acc.merge(gFexEmulatedTowersCfg(flags,name=
"L1_gFexEmulatedTowers"))
256 gFEXTowerSummer = CompFactory.LVL1.gFexTowerSummer(
'gFexTowerSummer')
257 gFEXTowerSummer.gFexDataTowers =
"L1_gFexEmulatedTowers" if flags.Input.isMC
else "L1_gFexDataTowers"
258 gFEXTowerSummer.gTowers200WriteKey =
"L1_gFexEmulatedTowers200" if flags.Input.isMC
else "L1_gFexDataTowers200"
259 gFEXTowerSummer.gTowers50WriteKey =
"L1_gFexEmulatedTowers50" if flags.Input.isMC
else "L1_gFexDataTowers50"
260 gFEXTowerSummer.gTowersEMWriteKey =
""
261 gFEXTowerSummer.gTowersHADWriteKey =
""
262 acc.addEventAlgo(gFEXTowerSummer)
264 gFEXInputs = CompFactory.LVL1.gTowerMakerFromGfexTowers(
'gTowerMakerFromGfexTowers')
265 gFEXInputs.InputDataTowers =
"L1_gFexEmulatedTowers200" if flags.Input.isMC
else "L1_gFexDataTowers200"
266 gFEXInputs.MyGTowers =
"gTowerContainer"
268 gFEXInputs50 = CompFactory.LVL1.gTowerMakerFromGfexTowers(
'gTowerMakerFromGfexTowers50')
269 gFEXInputs50.InputDataTowers =
"L1_gFexEmulatedTowers50" if flags.Input.isMC
else "L1_gFexDataTowers50"
270 gFEXInputs50.MyGTowers =
"gTower50Container"
272 from L1CaloFEXCond.L1CaloFEXCondConfig
import gFexDBConfig
273 acc.merge(gFexDBConfig(flags))
275 gFEX = CompFactory.LVL1.gFEXDriver(
'gFEXDriver')
276 gFEX.gFEXSysSimTool = CompFactory.LVL1.gFEXSysSim(
'gFEXSysSimTool')
277 acc.addEventAlgo(gFEXInputs)
278 acc.addEventAlgo(gFEXInputs50)
279 acc.addEventAlgo(gFEX)
281 if flags.Trigger.doHLT:
285 from TrigEDMConfig.TriggerEDM
import recordable
287 assert key==recordable(key), f
'recordable() check failed for {key}'
288 if flags.Trigger.L1.doeFex:
289 check(eFEX.eFEXSysSimTool.Key_eFexEMOutputContainer)
290 check(eFEX.eFEXSysSimTool.Key_eFexTauOutputContainer)
292 check(eFEX.eFEXSysSimTool.Key_eFexAltTauOutputContainer)
293 if flags.Trigger.L1.dojFex:
294 check(jFEX.jFEXSysSimTool.Key_jFexSRJetOutputContainer)
295 check(jFEX.jFEXSysSimTool.Key_jFexLRJetOutputContainer)
296 check(jFEX.jFEXSysSimTool.Key_jFexTauOutputContainer)
297 check(jFEX.jFEXSysSimTool.Key_jFexSumETOutputContainer)
298 check(jFEX.jFEXSysSimTool.Key_jFexMETOutputContainer)
299 check(jFEX.jFEXSysSimTool.Key_jFexFwdElOutputContainer)
300 if flags.Trigger.L1.dogFex:
301 check(gFEX.gFEXSysSimTool.Key_gFexSRJetOutputContainer)
302 check(gFEX.gFEXSysSimTool.Key_gFexLRJetOutputContainer)
303 check(gFEX.gFEXSysSimTool.Key_gFexRhoOutputContainer)
304 check(gFEX.gFEXSysSimTool.Key_gScalarEJwojOutputContainer)
305 check(gFEX.gFEXSysSimTool.Key_gMETComponentsJwojOutputContainer)
306 check(gFEX.gFEXSysSimTool.Key_gMHTComponentsJwojOutputContainer)
307 check(gFEX.gFEXSysSimTool.Key_gMSTComponentsJwojOutputContainer)
308 check(gFEX.gFEXSysSimTool.Key_gMETComponentsNoiseCutOutputContainer)
309 check(gFEX.gFEXSysSimTool.Key_gMETComponentsRmsOutputContainer)
310 check(gFEX.gFEXSysSimTool.Key_gScalarENoiseCutOutputContainer)
311 check(gFEX.gFEXSysSimTool.Key_gScalarERmsOutputContainer)
314 def getSimHandle(key):
316 Add 'Sim' to the standard handle path and include user-specified suffix
319 if not key.endswith(
"Sim"): key +=
"Sim"
322 if flags.Trigger.L1.doeFex:
323 eFEX.eFEXSysSimTool.Key_eFexEMOutputContainer=getSimHandle(
"L1_eEMRoI")
324 eFEX.eFEXSysSimTool.Key_eFexTauOutputContainer=getSimHandle(
"L1_eTauRoI")
325 eFEX.eFEXSysSimTool.Key_eFexEMxTOBOutputContainer=getSimHandle(
"L1_eEMxRoI")
326 eFEX.eFEXSysSimTool.Key_eFexTauxTOBOutputContainer=getSimHandle(
"L1_eTauxRoI")
328 eFEX.eFEXSysSimTool.Key_eFexAltTauOutputContainer=getSimHandle(
"L1_eTauRoIAlt")
329 eFEX.eFEXSysSimTool.Key_eFexAltTauxTOBOutputContainer=getSimHandle(
"L1_eTauxRoIAlt")
331 if flags.Trigger.L1.dojFex:
332 jFEX.jFEXSysSimTool.Key_jFexSRJetOutputContainer=getSimHandle(
"L1_jFexSRJetRoI")
333 jFEX.jFEXSysSimTool.Key_jFexLRJetOutputContainer=getSimHandle(
"L1_jFexLRJetRoI")
334 jFEX.jFEXSysSimTool.Key_jFexTauOutputContainer=getSimHandle(
"L1_jFexTauRoI")
335 jFEX.jFEXSysSimTool.Key_jFexSumETOutputContainer=getSimHandle(
"L1_jFexSumETRoI")
336 jFEX.jFEXSysSimTool.Key_jFexMETOutputContainer=getSimHandle(
"L1_jFexMETRoI")
337 jFEX.jFEXSysSimTool.Key_jFexFwdElOutputContainer=getSimHandle(
"L1_jFexFwdElRoI")
338 jFEX.jFEXSysSimTool.Key_xTobOutKey_jJ=getSimHandle(
"L1_jFexSRJetxRoI")
339 jFEX.jFEXSysSimTool.Key_xTobOutKey_jLJ=getSimHandle(
"L1_jFexLRJetxRoI")
340 jFEX.jFEXSysSimTool.Key_xTobOutKey_jTau=getSimHandle(
"L1_jFexTauxRoI")
341 jFEX.jFEXSysSimTool.Key_xTobOutKey_jEM=getSimHandle(
"L1_jFexFwdElxRoI")
342 if flags.Trigger.L1.dogFex:
343 gFEX.gFEXSysSimTool.Key_gFexSRJetOutputContainer=getSimHandle(
"L1_gFexSRJetRoI")
344 gFEX.gFEXSysSimTool.Key_gFexLRJetOutputContainer=getSimHandle(
"L1_gFexLRJetRoI")
345 gFEX.gFEXSysSimTool.Key_gFexRhoOutputContainer=getSimHandle(
"L1_gFexRhoRoI")
346 gFEX.gFEXSysSimTool.Key_gScalarEJwojOutputContainer=getSimHandle(
"L1_gScalarEJwoj")
347 gFEX.gFEXSysSimTool.Key_gMETComponentsJwojOutputContainer=getSimHandle(
"L1_gMETComponentsJwoj")
348 gFEX.gFEXSysSimTool.Key_gMHTComponentsJwojOutputContainer=getSimHandle(
"L1_gMHTComponentsJwoj")
349 gFEX.gFEXSysSimTool.Key_gMSTComponentsJwojOutputContainer=getSimHandle(
"L1_gMSTComponentsJwoj")
350 gFEX.gFEXSysSimTool.Key_gMETComponentsNoiseCutOutputContainer=getSimHandle(
"L1_gMETComponentsNoiseCut")
351 gFEX.gFEXSysSimTool.Key_gMETComponentsRmsOutputContainer=getSimHandle(
"L1_gMETComponentsRms")
352 gFEX.gFEXSysSimTool.Key_gScalarENoiseCutOutputContainer=getSimHandle(
"L1_gScalarENoiseCut")
353 gFEX.gFEXSysSimTool.Key_gScalarERmsOutputContainer=getSimHandle(
"L1_gScalarERms")