From dfccc2040e9cee6bddc1d43ceee3f1bed9ccc7a2 Mon Sep 17 00:00:00 2001
From: John Chapman <jchapman@cern.ch>
Date: Fri, 22 May 2020 12:13:08 +0200
Subject: [PATCH] Add Bkg_TruthEvent to the list of known McEventCollection
 names in HepMcParticleLink.cxx

The pre-mixing jobs rename the output `McEventCollection` to `Bkg_TruthEvent` rather than `TruthEvent`.
`HepMcParticleLink` doesn't know that this is a possible collection name that it should check for so
all links are broken and the attempts to find the `McEventCollection` in the T->P converter methods
always return `nullptr`. This causes the above crash as there is currently no protection against
dereferencing a null `McEventCollection` pointer. Adding `Bkg_TruthEvent` to the list of known
`McEventCollection` names in `HepMcParticleLink.cxx` should fix ATLASSIM-4539.
---
 .../GeneratorObjects/src/HepMcParticleLink.cxx       | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Generators/GeneratorObjects/src/HepMcParticleLink.cxx b/Generators/GeneratorObjects/src/HepMcParticleLink.cxx
index 5a6aa6abfb9..a91473bdcc7 100644
--- a/Generators/GeneratorObjects/src/HepMcParticleLink.cxx
+++ b/Generators/GeneratorObjects/src/HepMcParticleLink.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 */
 
 
@@ -26,14 +26,14 @@ namespace {
 /**
  * @brief StoreGate keys to try for each EBC_EVCOLL enum.
  */
-constexpr static int NKEYS = 4;
+constexpr static int NKEYS = 5;
 const
 std::string s_keys[EBC_NCOLLKINDS][NKEYS] =
   {
-   {"TruthEvent","G4Truth","GEN_AOD","GEN_EVENT"},
-   {"TruthEvent_PU","G4Truth_PU","GEN_AOD_PU","GEN_EVENT_PU"},
-   {"TruthEvent_HighPtPU","G4Truth_HighPtPU","GEN_AOD_HighPtPU","GEN_EVENT_HighPtPU"},
-   {"TruthEvent_Cavern","G4Truth_Cavern","GEN_AOD_Cavern","GEN_EVENT_Cavern"},
+    {"TruthEvent","G4Truth","GEN_AOD","GEN_EVENT","Bkg_TruthEvent"},
+    {"TruthEvent_PU","G4Truth_PU","GEN_AOD_PU","GEN_EVENT_PU","Bkg_TruthEvent_PU"},
+    {"TruthEvent_HighPtPU","G4Truth_HighPtPU","GEN_AOD_HighPtPU","GEN_EVENT_HighPtPU","Bkg_TruthEvent_HighPtPU"},
+    {"TruthEvent_Cavern","G4Truth_Cavern","GEN_AOD_Cavern","GEN_EVENT_Cavern","Bkg_TruthEvent_Cavern"},
   };
 
 
-- 
GitLab