From b2c947f5b227417610cc09ffb74ba99adbd57794 Mon Sep 17 00:00:00 2001
From: Alex Pearce <alex.pearce@cern.ch>
Date: Wed, 31 May 2017 10:25:48 +0200
Subject: [PATCH] More general configuration of persistence service.

---
 Phys/Tesla/python/Tesla/Configuration.py | 52 +++++++++++++-----------
 1 file changed, 29 insertions(+), 23 deletions(-)

diff --git a/Phys/Tesla/python/Tesla/Configuration.py b/Phys/Tesla/python/Tesla/Configuration.py
index 622835a0f..fe9bd0d9e 100644
--- a/Phys/Tesla/python/Tesla/Configuration.py
+++ b/Phys/Tesla/python/Tesla/Configuration.py
@@ -18,7 +18,6 @@ from Configurables import (
     DstConf,
     EventSelector,
     GaudiSequencer,
-    HltLinePersistenceSvc,
     HltPackedDataDecoder,
     HltRoutingBitsFilter,
     InputCopyStream,
@@ -39,6 +38,7 @@ from Configurables import (
     RecSummaryFromSelReports,
     RecombineRawEvent,
     RecordStream,
+    TCKLinePersistenceSvc,
     TeslaLineChecker,
     TeslaReportAlgo,
     TrackAssociator,
@@ -103,6 +103,7 @@ class Tesla(LHCbConfigurableUser):
           , 'EnableLineChecker' : True          # Enable the comparison of lines in the DecReports and the input to TeslaReportsAlgo
           , 'IgnoredLines'      : [ ]   # Regexes for lines excluded from the comparison of DecReports and input to TeslaReportsAlgo
           , 'FilterMC' : False # Save a subset of the input MC particles and vertices under `Tesla.base, mimicking a microDST writer`
+          , 'ILinePersistenceSvc' : "TCKLinePersistenceSvc"   # Implementation of the ILinePersistenceSvc to use (for >= 2017 data types)
           }
     _propertyDocDct ={
             "EvtMax"		: "Maximum number of events to process, default all"
@@ -147,6 +148,7 @@ class Tesla(LHCbConfigurableUser):
             , 'EnableLineChecker' : 'Enable the comparison of lines in the DecReports and the input to TeslaReportsAlgo'
             , 'IgnoredLines'      : 'Regexes for lines excluded from the comparison of DecReports and input to TeslaReportsAlgo'
             , 'FilterMC' : "Save a subset of the input MC particles and vertices under `Tesla.base`, mimicking a microDST writer"
+            , 'ILinePersistenceSvc' : "Implementation of the ILinePersistenceSvc to use (for >= 2017 data types)"
             
             }
 
@@ -813,29 +815,33 @@ class Tesla(LHCbConfigurableUser):
 
         # No need to clone if the output prefix is empty (everything stays
         # under /Event/Turbo)
-        # XXX change this to the TCK svc once finished debugging
-        persistence_svc = HltLinePersistenceSvc()
-        container_cloner = CopyLinePersistenceLocations(
-            namer('CopyLinePersistenceLocations'),
-            OutputPrefix=output_prefix,
-            LinesToCopy=decisions,
-            ILinePersistenceSvc=persistence_svc.getFullName()
-        )
-        p2pv_cloner = CopyParticle2PVRelationsFromLinePersistenceLocations(
-            namer('CopyP2PVRelationsFromLinePersistenceLocations'),
-            OutputPrefix=output_prefix,
-            LinesToCopy=decisions,
-            ILinePersistenceSvc=persistence_svc.getFullName()
-        )
-        copy_line_outputs_seq = GaudiSequencer(
-            namer('TeslaCopyLineOutputsSequence'),
-            Members=[
-                container_cloner,
-                p2pv_cloner
-            ],
-            IgnoreFilterPassed=True
-        )
         if output_prefix:
+            persistence_svc = self.getProp('ILinePersistenceSvc')
+            ApplicationMgr().ExtSvc.append(persistence_svc)
+            # Tell the persistence service to map any packed locations it knows
+            # about to unpacked locations, as it is the unpacked locations we
+            # want to copy to stream-specific locations
+            TCKLinePersistenceSvc().ContainerMap = packing.packedToOutputLocationMap()
+            container_cloner = CopyLinePersistenceLocations(
+                namer('CopyLinePersistenceLocations'),
+                OutputPrefix=output_prefix,
+                LinesToCopy=decisions,
+                ILinePersistenceSvc=persistence_svc
+            )
+            p2pv_cloner = CopyParticle2PVRelationsFromLinePersistenceLocations(
+                namer('CopyP2PVRelationsFromLinePersistenceLocations'),
+                OutputPrefix=output_prefix,
+                LinesToCopy=decisions,
+                ILinePersistenceSvc=persistence_svc
+            )
+            copy_line_outputs_seq = GaudiSequencer(
+                namer('TeslaCopyLineOutputsSequence'),
+                Members=[
+                    container_cloner,
+                    p2pv_cloner
+                ],
+                IgnoreFilterPassed=True
+            )
             stream_seq.Members.append(copy_line_outputs_seq)
 
         tes_root = '/Event'
-- 
GitLab