From d29cbdb4ef7d6040aeaf5783f3ae1ad03f17abae Mon Sep 17 00:00:00 2001
From: Alex Pearce <alex@alexpearce.me>
Date: Thu, 11 Jan 2018 09:43:17 +0100
Subject: [PATCH] Make CaloDigit cloning behaviour consistent, and also
 always-on for PersistReco.

---
 Phys/Tesla/python/Tesla/Configuration.py | 25 ++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/Phys/Tesla/python/Tesla/Configuration.py b/Phys/Tesla/python/Tesla/Configuration.py
index f7db0c2a7..1b86ccc0c 100644
--- a/Phys/Tesla/python/Tesla/Configuration.py
+++ b/Phys/Tesla/python/Tesla/Configuration.py
@@ -866,6 +866,7 @@ class Tesla(LHCbConfigurableUser):
         namer = lambda x: '{0}ForStream{1}'.format(x, output_prefix)
         pack = self.getProp('Pack')
         write_fsr = self.getProp('WriteFSR')
+        simulation = self.getProp('Simulation')
 
         stream_seq = GaudiSequencer(namer('TeslaStreamSequence'))
 
@@ -922,6 +923,30 @@ class Tesla(LHCbConfigurableUser):
             ppc.ICloneTrack = "TrackClonerWithClusters"
             tcwc.CloneAncestors = False
 
+            # We do two things here:
+            #   1. Configure the CaloCluster and CaloHypo cloners to have
+            #   consistent behaviour;
+            #   2. Force digits to always be cloned when running over simulated
+            #   data.
+            ccc = container_cloner.addTool(CaloClusterCloner, name='CaloClusterCloner')
+            chc = container_cloner.addTool(CaloHypoCloner, name='CaloHypoCloner')
+            ccc.CloneEntriesNeuP = True
+            ccc.CloneEntriesChP = False
+            ccc.CloneEntriesAlways = simulation
+            chc.CloneClustersNeuP = True
+            chc.CloneClustersChP = False
+            chc.CloneDigitsNeuP = True
+            chc.CloneDigitsChP = False
+            chc.CloneClustersAlways = simulation
+
+            # We *always* want associated digits to be cloned in PersistReco
+            ccc_pp = ccc.clone("CaloClusterClonerForTurboPP")
+            ccc_pp.CloneEntriesAlways = True
+            container_cloner.TurboPPICloneCaloCluster = container_cloner.addTool(ccc_pp).getFullName()
+            chc_pp = chc.clone("CaloHypoClonerForTurboPP")
+            chc_pp.CloneClustersAlways = True
+            container_cloner.TurboPPICloneCaloHypo = container_cloner.addTool(chc_pp).getFulName()
+
             # Look for input objects under /Event/Turbo
             def prepend_base(configurable, property):
                 """Prepend Tesla.base to the configurable's property value."""
-- 
GitLab