From 56b9b240577b2b1f0a1879c3068428566094fe56 Mon Sep 17 00:00:00 2001
From: Peter van Gemmeren <Peter.van.Gemmeren@cern.ch>
Date: Wed, 5 May 2021 09:03:50 -0500
Subject: [PATCH] Adding PersSvcPerInputType property to allow using multiple
 persistency services, one per input type.

---
 .../AthenaPoolCnvSvc/src/AthenaPoolCnvSvc.cxx          | 10 +++++++++-
 .../AthenaPOOL/AthenaPoolCnvSvc/src/AthenaPoolCnvSvc.h |  6 +++++-
 2 files changed, 14 insertions(+), 2 deletions(-)

diff --git a/Database/AthenaPOOL/AthenaPoolCnvSvc/src/AthenaPoolCnvSvc.cxx b/Database/AthenaPOOL/AthenaPoolCnvSvc/src/AthenaPoolCnvSvc.cxx
index 799078d7a6a1..f5995d0b08c1 100644
--- a/Database/AthenaPOOL/AthenaPoolCnvSvc/src/AthenaPoolCnvSvc.cxx
+++ b/Database/AthenaPOOL/AthenaPoolCnvSvc/src/AthenaPoolCnvSvc.cxx
@@ -188,6 +188,14 @@ StatusCode AthenaPoolCnvSvc::createObj(IOpaqueAddress* pAddress, DataObject*& re
    if (m_doChronoStat) {
       m_chronoStatSvc->chronoStart("cObj_" + objName);
    }
+   if (m_persSvcPerInputType) { // Use separate PersistencySvc for each input data type
+      TokenAddress* tokAddr = dynamic_cast<TokenAddress*>(pAddress);
+      if (tokAddr != nullptr && tokAddr->getToken() != nullptr) {
+         char text[32];
+         ::sprintf(text, "[CTXT=%08X]", m_poolSvc->getInputContext(tokAddr->getToken()->classID().toString()));
+         tokAddr->getToken()->setAuxString(text);
+      }
+   }
    // Forward to base class createObj
    StatusCode status = ::AthCnvSvc::createObj(pAddress, refpObject);
    if (m_doChronoStat) {
@@ -827,7 +835,7 @@ Token* AthenaPoolCnvSvc::registerForWrite(Placement* placement, const void* obj,
          if (!m_outputStreamingTool.empty() && m_outputStreamingTool[0]->isClient() && m_parallelCompression) {
             placement->setFileName(placement->fileName() + m_streamPortString.value());
          }
-         if (m_persSvcPerOutput) {
+         if (m_persSvcPerOutput) { // Use separate PersistencySvc for each output stream/file
             char text[32];
             ::sprintf(text, "[CTXT=%08X]", m_poolSvc->getOutputContext(placement->fileName()));
             placement->setAuxString(text);
diff --git a/Database/AthenaPOOL/AthenaPoolCnvSvc/src/AthenaPoolCnvSvc.h b/Database/AthenaPOOL/AthenaPoolCnvSvc/src/AthenaPoolCnvSvc.h
index 31241fbe6d89..276c2c755e60 100644
--- a/Database/AthenaPOOL/AthenaPoolCnvSvc/src/AthenaPoolCnvSvc.h
+++ b/Database/AthenaPOOL/AthenaPoolCnvSvc/src/AthenaPoolCnvSvc.h
@@ -233,9 +233,13 @@ private: // properties
    std::map<std::string, long long> m_databaseMaxFileSize;
 
    /// PersSvcPerOutput,boolean property to use multiple persistency services, one per output stream.
-   /// default = false.
+   /// default = true.
    BooleanProperty m_persSvcPerOutput{this,"PersSvcPerOutput",true};
    unsigned outputContextId(const std::string& outputConnection);
+
+   /// PersSvcPerInputType,boolean property to use multiple persistency services, one per input type.
+   /// default = false.
+   BooleanProperty m_persSvcPerInputType{this,"PersSvcPerInputType",false};
    std::mutex  m_mutex;
   
    /// SkipFirstChronoCommit, boolean property to skip the first commit in the chrono stats so the first
-- 
GitLab