From f812503d6e2037c4652c7227e580a52c8b08b8e7 Mon Sep 17 00:00:00 2001
From: Gerhard Raven <gerhard.raven@nikhef.nl>
Date: Wed, 1 Nov 2023 11:32:14 +0100
Subject: [PATCH 1/2] use RawBank::View as input instead of RawEvent to
 VP{,Retina} clustering

- needed for LHCb!4010 which updates the VPRetina clustering, and
  Rec!3351 which updates the VP clustering
---
 .../options/FT_pseudo_hit_efficiency.py       |  1 -
 Hlt/RecoConf/python/RecoConf/hlt1_tracking.py | 63 ++++++++-----------
 Hlt/RecoConf/python/RecoConf/standalone.py    | 16 +++--
 3 files changed, 32 insertions(+), 48 deletions(-)

diff --git a/Hlt/RecoConf/options/FT_pseudo_hit_efficiency.py b/Hlt/RecoConf/options/FT_pseudo_hit_efficiency.py
index c149c943c1a..1e9d909fc07 100644
--- a/Hlt/RecoConf/options/FT_pseudo_hit_efficiency.py
+++ b/Hlt/RecoConf/options/FT_pseudo_hit_efficiency.py
@@ -18,7 +18,6 @@ from RecoConf.hlt1_tracking import make_FTRawBankDecoder_clusters
 from RecoConf.hlt2_tracking import (make_hlt2_tracks_without_UT,
                                     get_UpgradeGhostId_tool_no_UT)
 from PyConf.Algorithms import VeloRetinaClusterTrackingSIMD
-#from RecoConf.hlt1_tracking import make_VeloClusterTrackingSIMD, make_RetinaDecoder_raw_event
 from RecoConf.hlt1_tracking import make_VeloClusterTrackingSIMD, make_RetinaClusters
 from RecoConf.hlt1_muonid import make_muon_hits
 
diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py b/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py
index 23cd497f601..c554245e289 100644
--- a/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py
+++ b/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py
@@ -10,7 +10,7 @@
 ###############################################################################
 import logging
 from PyConf import configurable
-from PyConf.application import default_raw_event, default_raw_banks, make_odin
+from PyConf.application import default_raw_banks, make_odin
 from PyConf.utilities import DISABLE_TOOL
 from PyConf.packing import persistable_location
 
@@ -142,9 +142,6 @@ def make_VeloClusterTrackingSIMD_hits(
 def make_VPClus_location_and_offsets():
     """Makes velo clusters with VPClus
 
-       Args:
-           make_raw (DataHandle): RawEventLocation for VeloClusterTrackingSIMD, defaults to `default_raw_event <PyConf.application.default_raw_event>`.
-
        Returns:
            A dict mapping VPClus' ClusterLocation and ClusterOffsets DataHandles to ``'Location'`` and ``'Offsets'`` respectively.
     """
@@ -161,11 +158,20 @@ def make_VPClus_hits():
 
 
 @configurable
-def make_velo_full_clusters(make_raw=default_raw_event,
+def make_velo_full_clusters(make_raw=default_raw_banks,
                             make_full_cluster=VPClusFull,
-                            detector=["VP"]):
-    return make_full_cluster(
-        RawEventLocation=make_raw(detector)).ClusterLocation
+                            detector=None):
+    expected_detector = {
+        'VPClusFull': 'VP',
+        'VPRetinaFullClusterDecoder': 'VPRetinaCluster',
+        'VPRetinaFullClustering': 'VP'
+    }.get(make_full_cluster.type.getType(), None)
+    if expected_detector:
+        assert not detector or detector == expected_detector, f"explicitly specified detector will not work: {detector} vs {expected_detector} for {make_full_cluster.type.getType()}"
+        if not detector: detector = expected_detector
+
+    assert detector, "do not know which rawbank type {make_full_cluster.type.getType()} needs -- and it is not explicitly specified"
+    return make_full_cluster(RawBanks=make_raw(detector)).ClusterLocation
 
 
 @configurable
@@ -173,30 +179,13 @@ def make_SPmixed_raw_banks(detector=None, make_raw=default_raw_banks):
     """Mix SP.
 
        Args:
-           make_raw (DataHandle): RawEventLocation for VPRetinaSPmixer, defaults to `default_raw_event <PyConf.application.default_raw_event>`.
+           make_raw (DataHandle): RawBanks for VPRetinaSPmixer, defaults to `default_raw_banks <PyConf.application.default_raw_banks>`.
 
        Returns:
     """
-    # Can detector ever be something else
-    assert not detector or detector == "VP" or detector == ['VP'], detector
-    return VPRetinaSPmixer(RawBanks=make_raw("VP")).RawEventLocationMixed
-
-
-@configurable
-def make_RetinaCluster_raw_event(detector=None, make_raw=default_raw_banks):
-    """Makes velo clusters with VPRetinaClusterCreator.
-
-       Args:
-           make_raw (DataHandle): RawEventLocation for VPRetinaClusterCreator, defaults to `default_raw_event <PyConf.application.default_raw_event>`.
-
-       Returns:
-    """
-    assert not detector or detector == [
-        "VPRetinaCluster"
-    ] or detector == "VPRetinaCluster", detector
-    clustering = VPRetinaClusterCreator(
-        RawBanks=_rawevent_to_rawbank(make_raw("VP"), "VP"))
-    return clustering.RetinaRawBanks  # this is a RawBank::View
+    # Can detector ever be something else?
+    assert not detector or detector == "VP", detector
+    return VPRetinaSPmixer(RawBanks=make_raw("VP")).MixedRawBanks
 
 
 @configurable
@@ -204,16 +193,14 @@ def make_RetinaCluster_raw_bank(detector=None, make_raw=default_raw_banks):
     """Makes velo clusters with VPRetinaClusterCreator.
 
        Args:
-           make_raw (DataHandle): RawEventLocation for VPRetinaClusterCreator, defaults to `default_raw_event <PyConf.application.default_raw_event>`.
+           make_raw (DataHandle): RawEventLocation for VPRetinaClusterCreator, defaults to `default_raw_vent <PyConf.application.default_raw_banks>`.
 
        Returns:
     """
     assert not detector or detector == [
         "VPRetinaCluster"
     ] or detector == "VPRetinaCluster", detector
-    clustering = VPRetinaClusterCreator(
-        RawBanks=_rawevent_to_rawbank(make_raw("VP"), "VP"))
-    return clustering.RetinaRawBanks  # this is a RawBank::View
+    return VPRetinaClusterCreator(RawBanks=make_raw("VP")).RetinaRawBanks
 
 
 @configurable
@@ -227,8 +214,8 @@ def make_RetinaClusters(detector=None, make_raw=default_raw_banks):
            vector<LHCb::VPLightCluster>
     """
     assert not detector or detector == 'VPRetinaCluster', detector
-    decoding = VPRetinaClusterDecoder(RawBanks=make_raw('VPRetinaCluster'))
-    return decoding.ClusterLocation
+    return VPRetinaClusterDecoder(
+        RawBanks=make_raw('VPRetinaCluster')).ClusterLocation
 
 
 @configurable
@@ -443,7 +430,7 @@ def make_PrStoreUTHit_hits(make_raw=default_raw_banks,
     """Decodes UT hits from raw data.
 
        Args:
-            make_raw (DataHandle): RawEventLocation for VeloClusterTrackingSIMD, defaults to `default_raw_event <PyConf.application.default_raw_event>`.
+            make_raw (DataHandle): RawEventLocation for VeloClusterTrackingSIMD, defaults to `default_raw_banks <PyConf.application.default_raw_banks>`.
 
        Returns:
             DataHandle: PrStoreUTHit's UTHitsLocation.
@@ -472,7 +459,7 @@ def make_PrStorePrUTHits_hits(make_raw=default_raw_banks,
     """Decodes UT hits from raw data, fills an SOA container.
 
        Args:
-            make_raw (DataHandle): RawEventLocation for VeloClusterTrackingSIMD, defaults to `default_raw_event <PyConf.application.default_raw_event>`.
+            make_raw (DataHandle): RawEventLocation for VeloClusterTrackingSIMD, defaults to `default_raw_banks <PyConf.application.default_raw_banks>`.
 
        Returns:
             DataHandle: PrStorePrUTHits' UTHitsLocation.
@@ -535,7 +522,7 @@ def make_FTRawBankDecoder_clusters(make_raw=default_raw_banks):
     """Decodes the FT raw bank into FTLiteClusters. DecodingVersion set by `default_ft_decoding_version`.
 
        Args:
-           make_raw (DataHandle): RawEventLocation for VeloClusterTrackingSIMD, defaults to `default_raw_event <PyConf.application.default_raw_event>`.
+           make_raw (DataHandle): RawEventLocation for VeloClusterTrackingSIMD, defaults to `default_raw_banks <PyConf.application.default_raw_banks>`.
 
        Returns:
            DataHandle: FTRawBankDecoder's OutputLocation.
diff --git a/Hlt/RecoConf/python/RecoConf/standalone.py b/Hlt/RecoConf/python/RecoConf/standalone.py
index 7a0b90416a3..830751cbbac 100644
--- a/Hlt/RecoConf/python/RecoConf/standalone.py
+++ b/Hlt/RecoConf/python/RecoConf/standalone.py
@@ -14,11 +14,10 @@ from .event_filters import require_gec
 from .hlt1_tracking import (
     make_reco_pvs, make_pvs, make_all_pvs, make_hlt1_tracks,
     make_SPmixed_raw_banks, make_RetinaCluster_raw_bank,
-    make_RetinaCluster_raw_event, make_VeloClusterTrackingSIMD,
-    make_VeloClusterTrackingSIMD_hits, make_VeloKalman_fitted_tracks,
-    make_PatPV3DFuture_pvs, all_hlt1_forward_track_types,
-    make_TrackEventFitter_fitted_tracks, make_hlt1_fitted_tracks,
-    make_velo_full_clusters, make_RetinaClusters,
+    make_VeloClusterTrackingSIMD, make_VeloClusterTrackingSIMD_hits,
+    make_VeloKalman_fitted_tracks, make_PatPV3DFuture_pvs,
+    all_hlt1_forward_track_types, make_TrackEventFitter_fitted_tracks,
+    make_hlt1_fitted_tracks, make_velo_full_clusters, make_RetinaClusters,
     get_global_measurement_provider)
 
 from RecoConf.hlt1_muonmatch import make_tracks_with_muonmatch_ipcut
@@ -345,10 +344,9 @@ def standalone_hlt2_full_track_reco_retinacluster(light_reco=False,
             Reconstruction: Data and control flow of Hlt2 track reconstruction.
     """
 
-    with make_RetinaCluster_raw_event.bind(make_raw=make_SPmixed_raw_banks), \
-         make_RetinaCluster_raw_bank.bind(make_raw=make_SPmixed_raw_banks), \
-         make_velo_full_clusters.bind(make_raw=make_SPmixed_raw_banks, make_full_cluster=VPRetinaFullClustering), \
-         make_RetinaClusters.bind(make_raw=make_RetinaCluster_raw_event,detector='VPRetinaCluster'),\
+    with make_RetinaCluster_raw_bank.bind(make_raw=make_SPmixed_raw_banks), \
+         make_velo_full_clusters.bind(make_full_cluster=VPRetinaFullClustering,make_raw=make_SPmixed_raw_banks), \
+         make_RetinaClusters.bind(make_raw=make_RetinaCluster_raw_bank),\
          get_UpgradeGhostId_tool.bind(velo_hits=make_RetinaClusters),\
          get_global_measurement_provider.bind(velo_hits=make_RetinaClusters),\
          make_VeloClusterTrackingSIMD.bind(make_raw=make_RetinaCluster_raw_bank, algorithm=VeloRetinaClusterTrackingSIMD):
-- 
GitLab


From 61cf41a7a3433455c7424f0637b99a36bb632be5 Mon Sep 17 00:00:00 2001
From: Gerhard Raven <gerhard.raven@nikhef.nl>
Date: Thu, 2 Nov 2023 10:02:42 +0100
Subject: [PATCH 2/2] cleanup deprecated code

---
 Hlt/RecoConf/options/VP_tracking_monitors.py  |  5 +--
 .../options/examples/VP_hit_efficiency.py     |  4 +--
 Hlt/RecoConf/python/RecoConf/hlt1_tracking.py | 31 +------------------
 3 files changed, 3 insertions(+), 37 deletions(-)

diff --git a/Hlt/RecoConf/options/VP_tracking_monitors.py b/Hlt/RecoConf/options/VP_tracking_monitors.py
index 1f7b2c65840..011b73758da 100644
--- a/Hlt/RecoConf/options/VP_tracking_monitors.py
+++ b/Hlt/RecoConf/options/VP_tracking_monitors.py
@@ -29,7 +29,6 @@ from RecoConf.hlt1_tracking import (
     make_reco_pvs,
     make_PatPV3DFuture_pvs,
     make_RetinaClusters,
-    _rawevent_to_rawbank,
     get_global_measurement_provider,
 )
 
@@ -72,10 +71,8 @@ def make_my_sequence():
         my_mask = [sensor in [99]
                    for sensor in range(208)]  # sensor 99 is chosen arbitrarily
 
-        bankType = "VPRetinaCluster"
         vpClustering = VeloRetinaClusterTrackingSIMDFull(
-            RawBanks=_rawevent_to_rawbank(
-                default_raw_banks(bankType), bankType),
+            RawBanks=default_raw_banks("VPRetinaCluster"),
             SensorMasks=tuple(my_mask),
             MaxScatterSeeding=0.1,
             MaxScatterForwarding=0.1,
diff --git a/Hlt/RecoConf/options/examples/VP_hit_efficiency.py b/Hlt/RecoConf/options/examples/VP_hit_efficiency.py
index 929b0aaa2f0..604f131b151 100644
--- a/Hlt/RecoConf/options/examples/VP_hit_efficiency.py
+++ b/Hlt/RecoConf/options/examples/VP_hit_efficiency.py
@@ -17,7 +17,6 @@ from RecoConf.hlt1_tracking import (
     make_PatPV3DFuture_pvs,
     make_RetinaClusters,
     get_global_measurement_provider,
-    _rawevent_to_rawbank,
 )
 
 from PyConf.application import default_raw_banks
@@ -71,8 +70,7 @@ def make_my_sequence():
             ]
 
             vpClustering = VeloRetinaClusterTrackingSIMDFull(
-                RawBanks=_rawevent_to_rawbank(
-                    default_raw_banks("VPRetinaCluster"), "VPRetinaCluster"),
+                RawBanks=default_raw_banks("VPRetinaCluster"),
                 SensorMasks=tuple(my_SensorMask),
                 MaxScatterSeeding=0.1,
                 MaxScatterForwarding=0.1,
diff --git a/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py b/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py
index c554245e289..aa395b4cf7d 100644
--- a/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py
+++ b/Hlt/RecoConf/python/RecoConf/hlt1_tracking.py
@@ -40,7 +40,6 @@ from PyConf.Algorithms import (
     PatPV3DFuture,
     PrStorePrUTHitsEmptyProducer,
     PrStoreUTHitEmptyProducer,
-    LHCb__UnpackRawEvent,
 )
 
 from PyConf.Tools import (
@@ -60,34 +59,6 @@ log = logging.getLogger(__name__)
 from RecoConf.core_algorithms import make_unique_id_generator
 
 
-def _rawevent_to_rawbank(dh, tp):
-    if dh.type == "LHCb::RawEvent":
-        print("FIXME: fix input to return RawBanks instead of RawEvent")
-
-        def output_transform(Output):
-            return {"RawBankLocations": [Output]}
-
-        dh = LHCb__UnpackRawEvent(
-            RawEventLocation=dh,
-            output_transform=output_transform,
-            BankTypes=[tp]).Output
-    return dh
-
-
-@configurable
-def default_ft_decoding_version(value=4):
-    raise DeprecationWarning(
-        "Function default_ft_decoding_version has to be imported from the RecoConf.decoders module."
-    )
-
-
-@configurable
-def require_gec(make_raw=default_raw_banks, cut=-1, **kwargs):
-    raise DeprecationWarning(
-        "Function require_gec has to be imported from the RecoConf.event_filters module."
-    )
-
-
 @configurable
 def make_VeloClusterTrackingSIMD(algorithm=VeloClusterTrackingSIMD,
                                  make_raw=default_raw_banks,
@@ -117,7 +88,7 @@ def make_VeloClusterTrackingSIMD(algorithm=VeloClusterTrackingSIMD,
     my_SensorMasks = [j in masked_sensors for j in range(208)
                       ]  # 208 = LHCb::Pr::Velo::VPInfos::NSensors
     return algorithm(
-        RawBanks=_rawevent_to_rawbank(make_raw(bank_type), bank_type),
+        RawBanks=make_raw(bank_type),
         SensorMasks=tuple(my_SensorMasks),
         MaxScatterSeeding=MaxScatterSeeding,
         MaxScatterForwarding=MaxScatterForwarding,
-- 
GitLab