From fb53c3869bcd51004bae9ca198a33dd6308ffa89 Mon Sep 17 00:00:00 2001
From: Rafal Bielski <rafal.bielski@cern.ch>
Date: Thu, 17 Jan 2019 18:54:25 +0100
Subject: [PATCH] Make TrigByteStreamCnvSvc inherit from ByteStreamCnvSvc
 instead of ByteStreamCnvSvcBase

This way there can be only one instance of the service and it provides all functionality
needed by the offline code, while still implementing the HLT-specific output handling.
---
 .../src/TrigByteStreamCnvSvc.cxx               |  6 ++++--
 .../src/TrigByteStreamCnvSvc.h                 | 10 ++++++++--
 .../python/TriggerUnixStandardSetup.py         | 18 +++++-------------
 3 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/HLT/Event/TrigByteStreamCnvSvc/src/TrigByteStreamCnvSvc.cxx b/HLT/Event/TrigByteStreamCnvSvc/src/TrigByteStreamCnvSvc.cxx
index f400a2ba6f25..cc847ae24ba8 100644
--- a/HLT/Event/TrigByteStreamCnvSvc/src/TrigByteStreamCnvSvc.cxx
+++ b/HLT/Event/TrigByteStreamCnvSvc/src/TrigByteStreamCnvSvc.cxx
@@ -53,7 +53,7 @@ namespace {
 // Standard constructor
 // =============================================================================
 TrigByteStreamCnvSvc::TrigByteStreamCnvSvc(const std::string& name, ISvcLocator* svcLoc)
-: ByteStreamCnvSvcBase(name, svcLoc),
+: ByteStreamCnvSvc(name, svcLoc),
   m_evtStore("StoreGateSvc", name),
   m_robDataProviderSvc("ROBDataProviderSvc", name) {}
 
@@ -67,6 +67,7 @@ TrigByteStreamCnvSvc::~TrigByteStreamCnvSvc() {}
 // =============================================================================
 StatusCode TrigByteStreamCnvSvc::initialize() {
   ATH_MSG_VERBOSE("start of " << __FUNCTION__);
+  ATH_CHECK(ByteStreamCnvSvc::initialize());
   ATH_CHECK(m_evtStore.retrieve());
   ATH_CHECK(m_robDataProviderSvc.retrieve());
   ATH_MSG_VERBOSE("end of " << __FUNCTION__);
@@ -83,6 +84,7 @@ StatusCode TrigByteStreamCnvSvc::finalize() {
   if (m_evtStore.release().isFailure())
     ATH_MSG_WARNING("Failed to release service " << m_evtStore.typeAndName());
   ATH_MSG_VERBOSE("end of " << __FUNCTION__);
+  ATH_CHECK(ByteStreamCnvSvc::finalize());
   return StatusCode::SUCCESS;
 }
 
@@ -134,7 +136,7 @@ StatusCode TrigByteStreamCnvSvc::connectOutput(const std::string& outputFile, co
 StatusCode TrigByteStreamCnvSvc::commitOutput(const std::string& /*outputFile*/, bool /*do_commit*/) {
   ATH_MSG_VERBOSE("start of " << __FUNCTION__);
 
-  printRawEvent();
+  if (msgLvl(MSG::DEBUG)) printRawEvent();
 
   // Serialise the output FullEventFragment
   std::unique_ptr<uint32_t[]> rawEventPtr;
diff --git a/HLT/Event/TrigByteStreamCnvSvc/src/TrigByteStreamCnvSvc.h b/HLT/Event/TrigByteStreamCnvSvc/src/TrigByteStreamCnvSvc.h
index 419011203148..9ad63b849a94 100644
--- a/HLT/Event/TrigByteStreamCnvSvc/src/TrigByteStreamCnvSvc.h
+++ b/HLT/Event/TrigByteStreamCnvSvc/src/TrigByteStreamCnvSvc.h
@@ -5,7 +5,7 @@
 #ifndef TRIGBYTESTREAMCNVSVC_H
 #define TRIGBYTESTREAMCNVSVC_H
 
-#include "ByteStreamCnvSvcBase/ByteStreamCnvSvcBase.h"
+#include "ByteStreamCnvSvc/ByteStreamCnvSvc.h"
 
 // Forward declarations
 class StoreGateSvc;
@@ -13,8 +13,14 @@ class IROBDataProviderSvc;
 
 /** @class TrigByteStreamCnvSvc
  *  @brief A ByteStreamCnvSvc implementation for online use
+ *
+ *  It overrides the connectOutput and commitOutput methods of the base class. In this implementation, they create
+ *  the specific online HLT output and send it out directly to the TDAQ infrastructure without using an output service.
+ *
+ *  It needs to inherit from ByteStreamCnvSvc rather than ByteStreamCnvSvcBase, because some elements of the athena
+ *  framework (particularly converters) rely on the properties or functionality of the offline ByteStreamCnvSvc.
  **/
-class TrigByteStreamCnvSvc : public ByteStreamCnvSvcBase {
+class TrigByteStreamCnvSvc : public ByteStreamCnvSvc {
 public:
   /// Standard constructor
   TrigByteStreamCnvSvc(const std::string& name, ISvcLocator* svcLoc);
diff --git a/HLT/Trigger/TrigControl/TrigServices/python/TriggerUnixStandardSetup.py b/HLT/Trigger/TrigControl/TrigServices/python/TriggerUnixStandardSetup.py
index 1fa2dd419a77..6b48f061ccce 100644
--- a/HLT/Trigger/TrigControl/TrigServices/python/TriggerUnixStandardSetup.py
+++ b/HLT/Trigger/TrigControl/TrigServices/python/TriggerUnixStandardSetup.py
@@ -84,28 +84,20 @@ def setupCommonServices():
     theApp.CreateSvc += [ svcMgr.DetDescrCnvSvc.getFullName() ]
     svcMgr.EventPersistencySvc.CnvServices += [ "DetDescrCnvSvc" ]
 
-    # ByteStreamCnvSvc configuration
-    from ByteStreamCnvSvc.ByteStreamCnvSvcConf import ByteStreamCnvSvc
-    svcMgr += ByteStreamCnvSvc("ByteStreamCnvSvc")
+    # Online services for ByteStream input/output
+    from TrigByteStreamCnvSvc.TrigByteStreamCnvSvcConf import TrigByteStreamCnvSvc, TrigByteStreamInputSvc, TrigEventSelectorByteStream
+    svcMgr += TrigByteStreamCnvSvc("ByteStreamCnvSvc") # this name is hard-coded in some converters
     svcMgr.EventPersistencySvc.CnvServices += [ "ByteStreamCnvSvc" ]
-
-    from TrigByteStreamCnvSvc.TrigByteStreamCnvSvcConf import TrigByteStreamInputSvc
     svcMgr += TrigByteStreamInputSvc("ByteStreamInputSvc")
-
-    from TrigByteStreamCnvSvc.TrigByteStreamCnvSvcConf import TrigEventSelectorByteStream
-    svcMgr += TrigEventSelectorByteStream("EventSelector",
-                                          ByteStreamInputSvc = svcMgr.ByteStreamInputSvc)
+    svcMgr += TrigEventSelectorByteStream("EventSelector", ByteStreamInputSvc = svcMgr.ByteStreamInputSvc)
     theApp.EvtSel = "EventSelector"
 
-    from TrigByteStreamCnvSvc.TrigByteStreamCnvSvcConf import TrigByteStreamCnvSvc
-    svcMgr += TrigByteStreamCnvSvc("ByteStreamCnvSvc")
-
     # make the HltEventLoopMgr service available
     svcMgr.HltEventLoopMgr = theApp.service( "HltEventLoopMgr" )     # already instantiated
     svcMgr.HltEventLoopMgr.WhiteboardSvc = "EventDataSvc"
     svcMgr.HltEventLoopMgr.SchedulerSvc = AlgScheduler.getScheduler().getName()
     svcMgr.HltEventLoopMgr.EvtSel = svcMgr.EventSelector
-    svcMgr.HltEventLoopMgr.OutputCnvSvc = svcMgr.TrigByteStreamCnvSvc
+    svcMgr.HltEventLoopMgr.OutputCnvSvc = svcMgr.ByteStreamCnvSvc
 
     from TrigOutputHandling.TrigOutputHandlingConfig import HLTResultMTMakerCfg
     svcMgr.HltEventLoopMgr.ResultMaker = HLTResultMTMakerCfg()
-- 
GitLab