From 5c30eb60c5da0060e5a0a6322b5f7e0d2f9dae03 Mon Sep 17 00:00:00 2001
From: Rafal Bielski <rafal.bielski@cern.ch>
Date: Thu, 10 Dec 2020 17:45:40 +0100
Subject: [PATCH] Make Trigger output config more robust against unset input
 file name

---
 .../share/RecExCommon_topOptions.py           | 36 ++++++++++---------
 1 file changed, 20 insertions(+), 16 deletions(-)

diff --git a/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py b/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py
index 1ec89204466..3812ce61174 100644
--- a/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py
+++ b/Reconstruction/RecExample/RecExCommon/share/RecExCommon_topOptions.py
@@ -567,22 +567,26 @@ if rec.doTrigger:
             treatException("Could not import TriggerJobOpts.TriggerGetter . Switched off !" )
             recAlgs.doTrigger=False
 
-# Run-3 Trigger Outputs
-from AthenaConfiguration.AllConfigFlags import ConfigFlags
-if ConfigFlags.Trigger.EDMVersion == 3 and rec.readESD() and rec.doAOD():
-    # Don't run any trigger - only pass the HLT contents from ESD to AOD
-    # Add HLT output
-    from TriggerJobOpts.HLTTriggerResultGetter import HLTTriggerResultGetter
-    hltOutput = HLTTriggerResultGetter()
-    # Add Trigger menu metadata
-    if rec.doFileMetaData():
-        from RecExConfig.ObjKeyStore import objKeyStore
-        metadataItems = [ "xAOD::TriggerMenuContainer#TriggerMenu",
-                          "xAOD::TriggerMenuAuxContainer#TriggerMenuAux." ]
-        objKeyStore.addManyTypesMetaData( metadataItems )
-    # Add L1 output (to be consistent with R2)
-    from TrigEDMConfig.TriggerEDM import getLvl1AODList
-    objKeyStore.addManyTypesStreamAOD(getLvl1AODList())        
+# Run-3 Trigger Outputs: Don't run any trigger - only pass the HLT contents from ESD to AOD
+if rec.readESD() and rec.doAOD():
+    from AthenaConfiguration.AllConfigFlags import ConfigFlags
+    # The simplest protection in case ConfigFlags.Input.Files is not set, doesn't cover all cases:
+    if ConfigFlags.Input.Files == ['_ATHENA_GENERIC_INPUTFILE_NAME_'] and athenaCommonFlags.FilesInput():
+        ConfigFlags.Input.Files = athenaCommonFlags.FilesInput()
+
+    if ConfigFlags.Trigger.EDMVersion == 3:
+        # Add HLT output
+        from TriggerJobOpts.HLTTriggerResultGetter import HLTTriggerResultGetter
+        hltOutput = HLTTriggerResultGetter()
+        # Add Trigger menu metadata
+        if rec.doFileMetaData():
+            from RecExConfig.ObjKeyStore import objKeyStore
+            metadataItems = [ "xAOD::TriggerMenuContainer#TriggerMenu",
+                              "xAOD::TriggerMenuAuxContainer#TriggerMenuAux." ]
+            objKeyStore.addManyTypesMetaData( metadataItems )
+        # Add L1 output (to be consistent with R2)
+        from TrigEDMConfig.TriggerEDM import getLvl1AODList
+        objKeyStore.addManyTypesStreamAOD(getLvl1AODList())
 
 AODFix_postTrigger()
 
-- 
GitLab