From 5d0d89ce5afe4c0887f21a137c277988d82b0608 Mon Sep 17 00:00:00 2001
From: Scott Snyder <scott.snyder@cern.ch>
Date: Thu, 18 Jun 2020 12:02:11 +0000
Subject: [PATCH] EventSelectorAthenaPool: Add new configuration fragment for
 CondProxyProvider.

Add a new-style configuration fragment for CondProxyProvider.
Need to set the semantics of the InputCollections property to allow
for proper merging.
---
 .../EventSelectorAthenaPool/CMakeLists.txt    |  5 +++
 .../python/CondProxyProviderConfig.py         | 44 +++++++++++++++++++
 .../share/CondProxyProviderConfig_test.ref    | 16 +++++++
 .../src/CondProxyProvider.cxx                 |  3 +-
 .../src/CondProxyProvider.h                   |  5 ++-
 5 files changed, 69 insertions(+), 4 deletions(-)
 create mode 100644 Database/AthenaPOOL/EventSelectorAthenaPool/python/CondProxyProviderConfig.py
 create mode 100644 Database/AthenaPOOL/EventSelectorAthenaPool/share/CondProxyProviderConfig_test.ref

diff --git a/Database/AthenaPOOL/EventSelectorAthenaPool/CMakeLists.txt b/Database/AthenaPOOL/EventSelectorAthenaPool/CMakeLists.txt
index a929c62272a..5d9257e6ba3 100644
--- a/Database/AthenaPOOL/EventSelectorAthenaPool/CMakeLists.txt
+++ b/Database/AthenaPOOL/EventSelectorAthenaPool/CMakeLists.txt
@@ -39,3 +39,8 @@ atlas_add_component( EventSelectorAthenaPool
 atlas_install_python_modules( python/*.py )
 atlas_install_joboptions( share/*.py )
 
+
+atlas_add_test( CondProxyProviderConfig_test
+                SCRIPT python -m EventSelectorAthenaPool.CondProxyProviderConfig
+                LOG_SELECT_PATTERN "ComponentAccumulator|^---|^CondProxyProvider" )
+
diff --git a/Database/AthenaPOOL/EventSelectorAthenaPool/python/CondProxyProviderConfig.py b/Database/AthenaPOOL/EventSelectorAthenaPool/python/CondProxyProviderConfig.py
new file mode 100644
index 00000000000..02ecf31fe60
--- /dev/null
+++ b/Database/AthenaPOOL/EventSelectorAthenaPool/python/CondProxyProviderConfig.py
@@ -0,0 +1,44 @@
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+
+# File: EventSelectorAthenaPool/python/CondProxyProviderConfig.py
+# Created: Jun 2020, sss
+# Purpose: Configure CondProxyProvider.
+
+from __future__ import print_function
+
+from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
+from AthenaConfiguration.ComponentFactory import CompFactory
+
+
+def CondProxyProviderCfg (flags, poolFiles):
+    if not isinstance (poolFiles, list):
+        poolFiles = [poolFiles]
+
+    result = ComponentAccumulator()
+
+    ProxyProviderSvc = CompFactory.ProxyProviderSvc # SGComps
+    pps = ProxyProviderSvc (ProviderNames = ['CondProxyProvider'])
+    result.addService (pps)
+    
+    CondProxyProvider = CompFactory.CondProxyProvider # EventSelectorAthenaPool
+    cpp = CondProxyProvider (InputCollections = poolFiles)
+    result.addService (cpp)
+
+    return result
+    
+
+if __name__ == "__main__":
+    from AthenaCommon.Configurable import Configurable
+    Configurable.configurableRun3Behavior=1
+    from AthenaConfiguration.AllConfigFlags import ConfigFlags
+    ConfigFlags.loadAllDynamicFlags()
+
+    flags1 = ConfigFlags.clone()
+    flags1.lock()
+    acc1 = ComponentAccumulator()
+    acc1.merge (CondProxyProviderCfg (flags1, 'file1'))
+    acc1.merge (CondProxyProviderCfg (flags1, ['file2', 'file3']))
+    acc1.printConfig (summariseProps=True)
+    print ('CondProxyProvider:', acc1.getService('CondProxyProvider'))
+    acc1.wasMerged()
+
diff --git a/Database/AthenaPOOL/EventSelectorAthenaPool/share/CondProxyProviderConfig_test.ref b/Database/AthenaPOOL/EventSelectorAthenaPool/share/CondProxyProviderConfig_test.ref
new file mode 100644
index 00000000000..494822f7cad
--- /dev/null
+++ b/Database/AthenaPOOL/EventSelectorAthenaPool/share/CondProxyProviderConfig_test.ref
@@ -0,0 +1,16 @@
+Py:Athena            INFO using release [WorkDir-22.0.15] [x86_64-centos7-gcc8-opt] [config.EventSelectorAthenaPool-20200617/24fa4eb1a41] -- built on [2020-06-17T2014]
+Py:ComponentAccumulator    INFO Event Inputs
+Py:ComponentAccumulator    INFO Event Algorithm Sequences
+Py:ComponentAccumulator    INFO Top sequence 0
+Py:ComponentAccumulator    INFO \__ AthAlgSeq (seq: SEQ AND)
+Py:ComponentAccumulator    INFO Condition Algorithms
+Py:ComponentAccumulator    INFO Services
+Py:ComponentAccumulator    INFO ['ProxyProviderSvc', 'CondProxyProvider']
+Py:ComponentAccumulator    INFO Public Tools
+Py:ComponentAccumulator    INFO [
+Py:ComponentAccumulator    INFO ]
+Py:ComponentAccumulator    INFO Private Tools
+Py:ComponentAccumulator    INFO [
+Py:ComponentAccumulator    INFO ]
+Py:ComponentAccumulator    INFO TheApp properties
+CondProxyProvider: CondProxyProvider('CondProxyProvider', InputCollections=['file1', 'file2', 'file3'])
diff --git a/Database/AthenaPOOL/EventSelectorAthenaPool/src/CondProxyProvider.cxx b/Database/AthenaPOOL/EventSelectorAthenaPool/src/CondProxyProvider.cxx
index 9e3b2859b48..7d761658725 100755
--- a/Database/AthenaPOOL/EventSelectorAthenaPool/src/CondProxyProvider.cxx
+++ b/Database/AthenaPOOL/EventSelectorAthenaPool/src/CondProxyProvider.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 */
 
 /** @file CondProxyProvider.cxx
@@ -33,7 +33,6 @@ CondProxyProvider::CondProxyProvider(const std::string& name, ISvcLocator* pSvcL
 	m_athenaPoolCnvSvc("AthenaPoolCnvSvc", name),
 	m_poolCollectionConverter(0),
 	m_headerIterator(0) {
-   declareProperty("InputCollections", m_inputCollectionsProp);
 }
 //________________________________________________________________________________
 CondProxyProvider::~CondProxyProvider() {
diff --git a/Database/AthenaPOOL/EventSelectorAthenaPool/src/CondProxyProvider.h b/Database/AthenaPOOL/EventSelectorAthenaPool/src/CondProxyProvider.h
index 761bee1d20c..6f8d5c0726f 100755
--- a/Database/AthenaPOOL/EventSelectorAthenaPool/src/CondProxyProvider.h
+++ b/Database/AthenaPOOL/EventSelectorAthenaPool/src/CondProxyProvider.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 */
 
 #ifndef CONDPROXYPROVIDER_H
@@ -63,7 +63,8 @@ private: // data
 
 private: // properties
    /// InputCollections, vector with names of the input collections.
-   StringArrayProperty m_inputCollectionsProp;
+   StringArrayProperty m_inputCollectionsProp
+   { this, "InputCollections", {}, "Files to read", "OrderedSet<std::string>" };
    mutable std::vector<std::string>::const_iterator m_inputCollectionsIterator;
 
 private: // internal helper functions
-- 
GitLab