From 637e3fb8b82a01ca4d80a0618a99df16a1ceeef9 Mon Sep 17 00:00:00 2001
From: Frank Berghaus <frank.berghaus@cern.ch>
Date: Fri, 26 Mar 2021 20:04:46 +0100
Subject: [PATCH] Add output ByteStream to output sequence ATLASRECTS-6130

The multiple stream manager was adding configured ByteStream output
streams in the old Gaudi style to "theApp". In multithreaded transforms
this means they no longer appear in the AthOutSeq, and thus no output is
written. This commit fixes that.
---
 .../python/MultipleStreamManager.py                    | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/Database/AthenaPOOL/OutputStreamAthenaPool/python/MultipleStreamManager.py b/Database/AthenaPOOL/OutputStreamAthenaPool/python/MultipleStreamManager.py
index 3554264b329a..a3eb13675a75 100644
--- a/Database/AthenaPOOL/OutputStreamAthenaPool/python/MultipleStreamManager.py
+++ b/Database/AthenaPOOL/OutputStreamAthenaPool/python/MultipleStreamManager.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 
 ########################################################
 ##  AugmentedStreams & MultipleStreamManager classes  ##
@@ -284,12 +284,14 @@ class AugmentedByteStream( AugmentedStreamBase ):
         self.bsCopyTool.ByteStreamOutputSvc=self.bsOutputSvc
         self.bsCopyTool.ByteStreamInputSvc=svcMgr.ByteStreamInputSvc
 
-        # create AthenaOutputStream for BS Copy and add it to topSequence
+        # create AthenaOutputStream for BS Copy
         from AthenaServices.AthenaServicesConf import AthenaOutputStream
         self.Stream = AthenaOutputStream( StreamName, WritingTool=self.bsCopyTool )
 
-        #topSequence += self.Stream #<-- coherent with asAlg=False in OutputStreamAthenaPool.py
-        theApp.addOutputStream( self.Stream )
+        # add the stream to the output sequence
+        from AthenaCommon.AlgSequence import AthSequencer
+        outSequence = AthSequencer("AthOutSeq")
+        outSequence += self.Stream
         return
 
     def SetOutputFileName(self, name):
-- 
GitLab