From b4f5d309289bb97171bfa70bde6c37bc050d273f Mon Sep 17 00:00:00 2001
From: lugrazet <Luke.Grazette@CERN.CH>
Date: Thu, 6 Jul 2023 15:24:34 +0100
Subject: [PATCH 1/3] Adding require_pvs() prefilter to spruce_qee_jets

---
 .../python/Hlt2Conf/lines/qee/spruce_qee_jets.py      | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_jets.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_jets.py
index 70b62a36833..e127f52ca54 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_jets.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_jets.py
@@ -16,7 +16,8 @@ from PyConf import configurable
 
 from Moore.config import register_line_builder, SpruceLine
 
-from RecoConf.reconstruction_objects import upfront_reconstruction
+from RecoConf.reconstruction_objects import make_pvs, upfront_reconstruction
+from RecoConf.event_filters import require_pvs
 
 from Hlt2Conf.lines.qee.di_bjet import make_SVTagDijets_cand, make_Dijets_cand, make_Trijets_cand, make_TrijetsTwoSVTag_cand
 
@@ -31,7 +32,7 @@ def SVTagDijets_sprucing_line(name='SpruceQEE_SVTagDijets', prescale=1):
     line_alg = make_SVTagDijets_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
 
 
@@ -43,7 +44,7 @@ def Dijets_sprucing_line(name='SpruceQEE_Dijets', prescale=1):
     line_alg = make_Dijets_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
 
 
@@ -55,7 +56,7 @@ def Trijets_sprucing_line(name='SpruceQEE_Trijets', prescale=1):
     line_alg = make_Trijets_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
 
 
@@ -68,5 +69,5 @@ def TrijetsTwoSVTag_sprucing_line(name='SpruceQEE_TrijetsTwoSVTag',
     line_alg = make_TrijetsTwoSVTag_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
-- 
GitLab


From c45d16556b37513438937b1d1404b7711710e062 Mon Sep 17 00:00:00 2001
From: lugrazet <Luke.Grazette@CERN.CH>
Date: Thu, 6 Jul 2023 22:03:43 +0100
Subject: [PATCH 2/3] jet-lines in spruce_qee also needed require_pvs()

---
 .../python/Hlt2Conf/lines/qee/spruce_qee.py   | 32 +++++++++----------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee.py
index 4c672e52083..dc85afc7f1b 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee.py
@@ -175,7 +175,7 @@ def z_svjet_sprucing_line(name='SpruceQEE_ZSVJet', prescale=1):
     line_alg = make_Z0SVjet_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
 
 
@@ -187,7 +187,7 @@ def z_jetjet_sprucing_line(name='SpruceQEE_ZJetJet', prescale=1):
     line_alg = make_Z0jetjet_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
 
 
@@ -199,7 +199,7 @@ def z_svjetsvjet_sprucing_line(name='SpruceQEE_ZSVJetSVJet', prescale=1):
     line_alg = make_Z0SVjetSVjet_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
 
 
@@ -211,7 +211,7 @@ def w_jet_sprucing_line(name='SpruceQEE_WJet', prescale=1):
     line_alg = make_Wjet_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
 
 
@@ -223,7 +223,7 @@ def w_svjet_sprucing_line(name='SpruceQEE_WSVJet', prescale=1):
     line_alg = make_WSVjet_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
 
 
@@ -235,7 +235,7 @@ def w_jetjet_sprucing_line(name='SpruceQEE_WJetJet', prescale=1):
     line_alg = make_Wjetjet_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
 
 
@@ -247,7 +247,7 @@ def w_svjetsvjet_sprucing_line(name='SpruceQEE_WSVJetSVJet', prescale=1):
     line_alg = make_WSVjetSVjet_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
 
 
@@ -259,7 +259,7 @@ def zee_jet_sprucing_line(name='SpruceQEE_ZEEJet', prescale=1):
     line_alg = make_Z0_elec_jet_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
 
 
@@ -271,7 +271,7 @@ def zee_svjet_sprucing_line(name='SpruceQEE_ZEESVJet', prescale=1):
     line_alg = make_Z0_elec_SVjet_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
 
 
@@ -283,7 +283,7 @@ def zee_jetjet_sprucing_line(name='SpruceQEE_ZEEJetJet', prescale=1):
     line_alg = make_Z0_elec_jetjet_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
 
 
@@ -295,7 +295,7 @@ def zee_svjetsvjet_sprucing_line(name='SpruceQEE_ZEESVJetSVJet', prescale=1):
     line_alg = make_Z0_elec_SVjetSVjet_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
 
 
@@ -307,7 +307,7 @@ def we_jet_sprucing_line(name='SpruceQEE_WEJet', prescale=1):
     line_alg = make_W_elec_jet_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
 
 
@@ -319,7 +319,7 @@ def we_svjet_sprucing_line(name='SpruceQEE_WESVJet', prescale=1):
     line_alg = make_W_elec_SVjet_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
 
 
@@ -331,7 +331,7 @@ def we_jetjet_sprucing_line(name='SpruceQEE_WEJetJet', prescale=1):
     line_alg = make_W_elec_jetjet_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
 
 
@@ -343,7 +343,7 @@ def we_svjetsvjet_sprucing_line(name='SpruceQEE_WESVJetSVJet', prescale=1):
     line_alg = make_W_elec_SVjetSVjet_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
 
 
@@ -368,7 +368,7 @@ def ttbar_to_mu_e_bjet_sprucing_line(name='SpruceQEE_TTbarToMuEBjet',
     line_alg = make_ttbar_MuEBjet_cand()
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [line_alg],
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
         prescale=prescale)
 
 
-- 
GitLab


From 681c74be82b519ead63e5836639ff97d4e8b1425 Mon Sep 17 00:00:00 2001
From: lugrazet <Luke.Grazette@CERN.CH>
Date: Fri, 7 Jul 2023 15:31:35 +0100
Subject: [PATCH 3/3] absorb spruce_qee_jets into spruce_qee with some
 organisation comments

---
 .../python/Hlt2Conf/lines/qee/__init__.py     |  2 -
 .../python/Hlt2Conf/lines/qee/spruce_qee.py   | 60 +++++++++++++++
 .../Hlt2Conf/lines/qee/spruce_qee_jets.py     | 73 -------------------
 3 files changed, 60 insertions(+), 75 deletions(-)
 delete mode 100644 Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_jets.py

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/__init__.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/__init__.py
index 3d6e9f24715..556037c98de 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/__init__.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/__init__.py
@@ -14,7 +14,6 @@ Submodule that defines all the QEE selection lines
 
 from . import hlt2_qee
 from . import spruce_qee
-from . import spruce_qee_jets
 
 hlt2_turbo_lines = {}
 hlt2_turbo_lines.update(hlt2_qee.turbo_lines)
@@ -28,4 +27,3 @@ all_lines.update(hlt2_full_lines)
 
 sprucing_lines = {}
 sprucing_lines.update(spruce_qee.sprucing_lines)
-sprucing_lines.update(spruce_qee_jets.sprucing_jet_lines)
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee.py
index dc85afc7f1b..f4915fceace 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee.py
@@ -29,6 +29,7 @@ from Hlt2Conf.lines.qee.diboson import make_WW_emu_cand, make_WZ_Zll_Wlnu_cand,
 from Hlt2Conf.lines.qee.wz_boson_rare_decays import make_WZRareDecay_HadronGamma_cand, make_WZRareDecay_DiMuonMeson_cand, make_WRareDecay_DiMuonPhiDsp_cand
 from Hlt2Conf.lines.qee.qee_builders import muon_filter
 from Hlt2Conf.lines.qee.single_high_pt_muon import make_isolated_muons
+from Hlt2Conf.lines.qee.di_bjet import make_SVTagDijets_cand, make_Dijets_cand, make_Trijets_cand, make_TrijetsTwoSVTag_cand
 
 # Necessary imports to hlt2_filter robustly;
 from inspect import signature
@@ -45,6 +46,7 @@ def _hlt2_decision_name(line_defn):
     return f"{line_name}Decision"
 
 
+################ Z -> ll lines ################
 @register_line_builder(sprucing_lines)
 @configurable
 def z_to_mu_mu_sprucing_line(name='SpruceQEE_ZToMuMu', prescale=1):
@@ -127,6 +129,7 @@ def same_sign_dielec_sprucing_line(name='SpruceQEE_DiElectronSameSign',
         prescale=prescale)
 
 
+################ Z + Jet lines ################
 @register_line_builder(sprucing_lines)
 @configurable
 def z_jet_sprucing_line(name='SpruceQEE_ZJet', prescale=1):
@@ -203,6 +206,7 @@ def z_svjetsvjet_sprucing_line(name='SpruceQEE_ZSVJetSVJet', prescale=1):
         prescale=prescale)
 
 
+################ W + Jet lines ################
 @register_line_builder(sprucing_lines)
 @configurable
 def w_jet_sprucing_line(name='SpruceQEE_WJet', prescale=1):
@@ -263,6 +267,7 @@ def zee_jet_sprucing_line(name='SpruceQEE_ZEEJet', prescale=1):
         prescale=prescale)
 
 
+################ Z -> ll + Jet lines ################
 @register_line_builder(sprucing_lines)
 @configurable
 def zee_svjet_sprucing_line(name='SpruceQEE_ZEESVJet', prescale=1):
@@ -299,6 +304,7 @@ def zee_svjetsvjet_sprucing_line(name='SpruceQEE_ZEESVJetSVJet', prescale=1):
         prescale=prescale)
 
 
+################ W -> l + Jet lines ################
 @register_line_builder(sprucing_lines)
 @configurable
 def we_jet_sprucing_line(name='SpruceQEE_WEJet', prescale=1):
@@ -347,6 +353,7 @@ def we_svjetsvjet_sprucing_line(name='SpruceQEE_WESVJetSVJet', prescale=1):
         prescale=prescale)
 
 
+################ ttbar Jet lines ################
 @register_line_builder(sprucing_lines)
 @configurable
 def ttbar_to_mu_e_sprucing_line(name='SpruceQEE_TTbarToMuE', prescale=1):
@@ -372,6 +379,7 @@ def ttbar_to_mu_e_bjet_sprucing_line(name='SpruceQEE_TTbarToMuEBjet',
         prescale=prescale)
 
 
+################ DiBoson lines ################
 @register_line_builder(sprucing_lines)
 @configurable
 def WW_to_e_mu_sprucing_line(name='SpruceQEE_WWToMuE', prescale=1):
@@ -462,6 +470,7 @@ for lepton_type, lepton_suffix in zip(["mu", "e"], ["Mu", "E"]):
                 prescale=prescale)
 
 
+################ W/Z RareDecay Hadron lines ################
 @register_line_builder(sprucing_lines)
 @configurable
 def W_to_JPsi_Phi_Dsp_sprucing_line(name='SpruceQEE_DiMuonPhiDsp', prescale=1):
@@ -521,6 +530,7 @@ for decay_type in ["JPsiDsp", "DiMuonDsp", "DiMuonPion"]:
             prescale=prescale)
 
 
+################ Single muon lines ################
 @register_line_builder(sprucing_lines)
 @configurable
 def single_muon_highpt_sprucing_line(name='SpruceQEE_SingleHighPtMuon',
@@ -578,3 +588,53 @@ def single_muon_highpt_nomuid_sprucing_line(
         algs=upfront_reconstruction() + [line_alg],
         hlt2_filter_code=_hlt2_decision_name(single_muon_highpt_nomuid_line),
         prescale=prescale)
+
+
+################ SV Di/Tri-Jet lines ################
+@register_line_builder(sprucing_lines)
+@configurable
+def SVTagDijets_sprucing_line(name='SpruceQEE_SVTagDijets', prescale=1):
+    """SV Tag Dijets sprucing line"""
+
+    line_alg = make_SVTagDijets_cand()
+    return SpruceLine(
+        name=name,
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
+        prescale=prescale)
+
+
+@register_line_builder(sprucing_lines)
+@configurable
+def Dijets_sprucing_line(name='SpruceQEE_Dijets', prescale=1):
+    """Dijets sprucing line"""
+
+    line_alg = make_Dijets_cand()
+    return SpruceLine(
+        name=name,
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
+        prescale=prescale)
+
+
+@register_line_builder(sprucing_lines)
+@configurable
+def Trijets_sprucing_line(name='SpruceQEE_Trijets', prescale=1):
+    """Trijets sprucing line"""
+
+    line_alg = make_Trijets_cand()
+    return SpruceLine(
+        name=name,
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
+        prescale=prescale)
+
+
+@register_line_builder(sprucing_lines)
+@configurable
+def TrijetsTwoSVTag_sprucing_line(name='SpruceQEE_TrijetsTwoSVTag',
+                                  prescale=1):
+    """Trijets sprucing line"""
+
+    line_alg = make_TrijetsTwoSVTag_cand()
+    return SpruceLine(
+        name=name,
+        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
+        prescale=prescale)
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_jets.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_jets.py
deleted file mode 100644
index e127f52ca54..00000000000
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_jets.py
+++ /dev/null
@@ -1,73 +0,0 @@
-###############################################################################
-# (c) Copyright 2019-2023 CERN for the benefit of the LHCb Collaboration      #
-#                                                                             #
-# This software is distributed under the terms of the GNU General Public      #
-# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING".   #
-#                                                                             #
-# In applying this licence, CERN does not waive the privileges and immunities #
-# granted to it by virtue of its status as an Intergovernmental Organization  #
-# or submit itself to any jurisdiction.                                       #
-###############################################################################
-"""
-Definitions of the jets QEE sprucing lines.
-"""
-
-from PyConf import configurable
-
-from Moore.config import register_line_builder, SpruceLine
-
-from RecoConf.reconstruction_objects import make_pvs, upfront_reconstruction
-from RecoConf.event_filters import require_pvs
-
-from Hlt2Conf.lines.qee.di_bjet import make_SVTagDijets_cand, make_Dijets_cand, make_Trijets_cand, make_TrijetsTwoSVTag_cand
-
-sprucing_jet_lines = {}
-
-
-@register_line_builder(sprucing_jet_lines)
-@configurable
-def SVTagDijets_sprucing_line(name='SpruceQEE_SVTagDijets', prescale=1):
-    """SV Tag Dijets sprucing line"""
-
-    line_alg = make_SVTagDijets_cand()
-    return SpruceLine(
-        name=name,
-        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
-        prescale=prescale)
-
-
-@register_line_builder(sprucing_jet_lines)
-@configurable
-def Dijets_sprucing_line(name='SpruceQEE_Dijets', prescale=1):
-    """Dijets sprucing line"""
-
-    line_alg = make_Dijets_cand()
-    return SpruceLine(
-        name=name,
-        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
-        prescale=prescale)
-
-
-@register_line_builder(sprucing_jet_lines)
-@configurable
-def Trijets_sprucing_line(name='SpruceQEE_Trijets', prescale=1):
-    """Trijets sprucing line"""
-
-    line_alg = make_Trijets_cand()
-    return SpruceLine(
-        name=name,
-        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
-        prescale=prescale)
-
-
-@register_line_builder(sprucing_jet_lines)
-@configurable
-def TrijetsTwoSVTag_sprucing_line(name='SpruceQEE_TrijetsTwoSVTag',
-                                  prescale=1):
-    """Trijets sprucing line"""
-
-    line_alg = make_TrijetsTwoSVTag_cand()
-    return SpruceLine(
-        name=name,
-        algs=upfront_reconstruction() + [require_pvs(make_pvs()), line_alg],
-        prescale=prescale)
-- 
GitLab