From c1389f7586ed3a736a1d808c3884101e18bdb618 Mon Sep 17 00:00:00 2001
From: Innes Mackay <innes.mackay@cern.ch>
Date: Fri, 7 Jul 2023 15:04:57 +0100
Subject: [PATCH 1/5] Resolve merge conflicts

---
 .../python/Hlt2Conf/lines/pid/L0ToPPi.py      | 52 +++++++++++++++++--
 1 file changed, 48 insertions(+), 4 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py
index d758df832b9..163be9703bf 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py
@@ -108,7 +108,7 @@ def make_l0dds(
 
 
 @register_line_builder(all_lines)
-def L0ToPPi_LL(name="Hlt2PID_L0ToPPi_LL", prescale=0.03):
+def L0ToPPi_LL_LowPT(name="Hlt2PID_L0ToPPi_LL_LowPT", prescale=0.002):
     pvs = make_pvs()
     protons = flt.filter_long_particles(
         filter_protons(make_long_protons()), pvs, trchi2_max=4, mipchi2_min=36)
@@ -123,9 +123,28 @@ def L0ToPPi_LL(name="Hlt2PID_L0ToPPi_LL", prescale=0.03):
         persistreco=True,
     )
 
+@register_line_builder(all_lines)
+def L0ToPPi_LL_MidPT(name="Hlt2PID_L0ToPPi_LL_MidPT", prescale=0.01):
+    pvs = make_pvs()
+    protons = flt.filter_long_particles(
+        filter_protons(make_long_protons(), pt_min=1.5 * GeV),
+        pvs,
+        trchi2_max=99999,
+        mipchi2_min=36)
+    pions = flt.filter_long_particles(
+        make_long_pions(), pvs, trchi2_max=99999, mipchi2_min=36)
+    l0lls = make_l0lls(protons, pions, pvs)
+
+    return HltLine(
+        name=name,
+        algs=flt.pid_prefilters() + [l0lls],
+        prescale=prescale,
+        persistreco=True,
+    )
+
 
 @register_line_builder(all_lines)
-def L0ToPPi_LL_HighPT(name="Hlt2PID_L0ToPPi_LL_HighPT", prescale=1):
+def L0ToPPi_LL_HighPT(name="Hlt2PID_L0ToPPi_LL_HighPT", prescale=0.1):
     pvs = make_pvs()
     protons = flt.filter_long_particles(
         filter_protons(make_long_protons(), pt_min=3 * GeV),
@@ -165,7 +184,7 @@ def L0ToPPi_LL_VeryHighPT(name="Hlt2PID_L0ToPPi_LL_VeryHighPT", prescale=1):
 
 
 @register_line_builder(all_lines)
-def L0ToPPi_DD(name="Hlt2PID_L0ToPPi_DD", prescale=0.03):
+def L0ToPPi_DD_LowPT(name="Hlt2PID_L0ToPPi_DD_LowPT", prescale=0.002):
     pvs = make_pvs()
     protons = flt.filter_down_particles(
         filter_protons(make_down_protons()),
@@ -190,7 +209,32 @@ def L0ToPPi_DD(name="Hlt2PID_L0ToPPi_DD", prescale=0.03):
 
 
 @register_line_builder(all_lines)
-def L0ToPPi_DD_HighPT(name="Hlt2PID_L0ToPPi_DD_HighPT", prescale=1):
+def L0ToPPi_DD_MidPT(name="Hlt2PID_L0ToPPi_DD_MidPT", prescale=0.01):
+    pvs = make_pvs()
+    protons = flt.filter_down_particles(
+        filter_protons(make_down_protons()),
+        p_min=3.0 * GeV,
+        pt_min=1.5 * GeV,
+        trchi2_max=99999,
+    )
+    pions = flt.filter_down_particles(
+        make_down_pions(),
+        p_min=3.0 * GeV,
+        pt_min=0.175 * GeV,
+        trchi2_max=99999,
+    )
+    l0dds = make_l0dds(protons, pions, pvs)
+
+    return HltLine(
+        name=name,
+        algs=flt.pid_prefilters() + [l0dds],
+        prescale=prescale,
+        persistreco=True,
+    )
+
+
+@register_line_builder(all_lines)
+def L0ToPPi_DD_HighPT(name="Hlt2PID_L0ToPPi_DD_HighPT", prescale=0.1):
     pvs = make_pvs()
     protons = flt.filter_down_particles(
         filter_protons(make_down_protons()),
-- 
GitLab


From c516d5285235e1925b4f0e31e3247b1442829070 Mon Sep 17 00:00:00 2001
From: Gitlab CI <noreply@cern.ch>
Date: Mon, 15 May 2023 08:57:41 +0000
Subject: [PATCH 2/5] Fixed formatting

patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/29567090
---
 Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py
index 163be9703bf..392655dce76 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py
@@ -123,6 +123,7 @@ def L0ToPPi_LL_LowPT(name="Hlt2PID_L0ToPPi_LL_LowPT", prescale=0.002):
         persistreco=True,
     )
 
+
 @register_line_builder(all_lines)
 def L0ToPPi_LL_MidPT(name="Hlt2PID_L0ToPPi_LL_MidPT", prescale=0.01):
     pvs = make_pvs()
-- 
GitLab


From ed1ee05f502b8d8ff07cb8fbbf9a7cfe9ca58995 Mon Sep 17 00:00:00 2001
From: Innes Mackay <innes.mackay@cern.ch>
Date: Wed, 17 May 2023 11:01:35 +0100
Subject: [PATCH 3/5] Add upper pt limits to stop double counting; Change pt
 filter for downstream lines

---
 .../python/Hlt2Conf/lines/pid/L0ToPPi.py      | 22 ++++++++++---------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py
index 392655dce76..b740908436b 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py
@@ -34,8 +34,8 @@ from Hlt2Conf.lines.pid.utils import constants, filters as flt
 all_lines = {}
 
 
-def filter_protons(particles, p_min=2.0 * GeV, pt_min=0 * GeV):
-    code = F.require_all(F.P > p_min, F.PT > pt_min)
+def filter_protons(particles, p_min=2.0 * GeV, pt_min=0 * GeV, pt_max=1000 * GeV):
+    code = F.require_all(F.P > p_min, F.PT > pt_min, F.PT < pt_max)
     return ParticleFilter(particles, F.FILTER(code))
 
 
@@ -111,7 +111,10 @@ def make_l0dds(
 def L0ToPPi_LL_LowPT(name="Hlt2PID_L0ToPPi_LL_LowPT", prescale=0.002):
     pvs = make_pvs()
     protons = flt.filter_long_particles(
-        filter_protons(make_long_protons()), pvs, trchi2_max=4, mipchi2_min=36)
+        filter_protons(make_long_protons(), pt_max=1.5 * GeV),
+        pvs,
+        trchi2_max=4,
+        mipchi2_min=36)
     pions = flt.filter_long_particles(
         make_long_pions(), pvs, trchi2_max=4, mipchi2_min=36)
     l0lls = make_l0lls(protons, pions, pvs)
@@ -128,7 +131,7 @@ def L0ToPPi_LL_LowPT(name="Hlt2PID_L0ToPPi_LL_LowPT", prescale=0.002):
 def L0ToPPi_LL_MidPT(name="Hlt2PID_L0ToPPi_LL_MidPT", prescale=0.01):
     pvs = make_pvs()
     protons = flt.filter_long_particles(
-        filter_protons(make_long_protons(), pt_min=1.5 * GeV),
+        filter_protons(make_long_protons(), pt_min=1.5 * GeV, pt_max=3 * GeV),
         pvs,
         trchi2_max=99999,
         mipchi2_min=36)
@@ -148,7 +151,7 @@ def L0ToPPi_LL_MidPT(name="Hlt2PID_L0ToPPi_LL_MidPT", prescale=0.01):
 def L0ToPPi_LL_HighPT(name="Hlt2PID_L0ToPPi_LL_HighPT", prescale=0.1):
     pvs = make_pvs()
     protons = flt.filter_long_particles(
-        filter_protons(make_long_protons(), pt_min=3 * GeV),
+        filter_protons(make_long_protons(), pt_min=3 * GeV, pt_max=6 * GeV),
         pvs,
         trchi2_max=4,
         mipchi2_min=36)
@@ -188,7 +191,7 @@ def L0ToPPi_LL_VeryHighPT(name="Hlt2PID_L0ToPPi_LL_VeryHighPT", prescale=1):
 def L0ToPPi_DD_LowPT(name="Hlt2PID_L0ToPPi_DD_LowPT", prescale=0.002):
     pvs = make_pvs()
     protons = flt.filter_down_particles(
-        filter_protons(make_down_protons()),
+        filter_protons(make_down_protons(), pt_min=0.175 * GeV, pt_max=1.5 * GeV),
         p_min=3.0 * GeV,
         pt_min=0.175 * GeV,
         trchi2_max=4,
@@ -213,9 +216,8 @@ def L0ToPPi_DD_LowPT(name="Hlt2PID_L0ToPPi_DD_LowPT", prescale=0.002):
 def L0ToPPi_DD_MidPT(name="Hlt2PID_L0ToPPi_DD_MidPT", prescale=0.01):
     pvs = make_pvs()
     protons = flt.filter_down_particles(
-        filter_protons(make_down_protons()),
+        filter_protons(make_down_protons(), pt_min=1.5 * GeV, pt_max=3 * GeV),
         p_min=3.0 * GeV,
-        pt_min=1.5 * GeV,
         trchi2_max=99999,
     )
     pions = flt.filter_down_particles(
@@ -238,7 +240,7 @@ def L0ToPPi_DD_MidPT(name="Hlt2PID_L0ToPPi_DD_MidPT", prescale=0.01):
 def L0ToPPi_DD_HighPT(name="Hlt2PID_L0ToPPi_DD_HighPT", prescale=0.1):
     pvs = make_pvs()
     protons = flt.filter_down_particles(
-        filter_protons(make_down_protons()),
+        filter_protons(make_down_protons(), pt_min=3.0 * GeV, pt_max=6 * GeV),
         p_min=3.0 * GeV,
         pt_min=3.0 * GeV,
         trchi2_max=4,
@@ -263,7 +265,7 @@ def L0ToPPi_DD_HighPT(name="Hlt2PID_L0ToPPi_DD_HighPT", prescale=0.1):
 def L0ToPPi_DD_VeryHighPT(name="Hlt2PID_L0ToPPi_DD_VeryHighPT", prescale=1):
     pvs = make_pvs()
     protons = flt.filter_down_particles(
-        filter_protons(make_down_protons()),
+        filter_protons(make_down_protons(), pt_min=6.0 * GeV),
         p_min=3.0 * GeV,
         pt_min=6.0 * GeV,
         trchi2_max=4,
-- 
GitLab


From d204d0b3be25429938605136da0a4e0db76ddcf8 Mon Sep 17 00:00:00 2001
From: Gitlab CI <noreply@cern.ch>
Date: Wed, 17 May 2023 10:02:15 +0000
Subject: [PATCH 4/5] Fixed formatting

patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/29628487
---
 Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py
index b740908436b..101e145c69a 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py
@@ -34,7 +34,10 @@ from Hlt2Conf.lines.pid.utils import constants, filters as flt
 all_lines = {}
 
 
-def filter_protons(particles, p_min=2.0 * GeV, pt_min=0 * GeV, pt_max=1000 * GeV):
+def filter_protons(particles,
+                   p_min=2.0 * GeV,
+                   pt_min=0 * GeV,
+                   pt_max=1000 * GeV):
     code = F.require_all(F.P > p_min, F.PT > pt_min, F.PT < pt_max)
     return ParticleFilter(particles, F.FILTER(code))
 
@@ -191,7 +194,8 @@ def L0ToPPi_LL_VeryHighPT(name="Hlt2PID_L0ToPPi_LL_VeryHighPT", prescale=1):
 def L0ToPPi_DD_LowPT(name="Hlt2PID_L0ToPPi_DD_LowPT", prescale=0.002):
     pvs = make_pvs()
     protons = flt.filter_down_particles(
-        filter_protons(make_down_protons(), pt_min=0.175 * GeV, pt_max=1.5 * GeV),
+        filter_protons(
+            make_down_protons(), pt_min=0.175 * GeV, pt_max=1.5 * GeV),
         p_min=3.0 * GeV,
         pt_min=0.175 * GeV,
         trchi2_max=4,
-- 
GitLab


From 3b7584972b121eb7a836929011055efcf319bf60 Mon Sep 17 00:00:00 2001
From: Innes Mackay <innes.mackay@cern.ch>
Date: Fri, 7 Jul 2023 15:22:35 +0100
Subject: [PATCH 5/5] Tighten TRCHI2 cut on MidPT lines

---
 Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py
index 101e145c69a..864326dddad 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/pid/L0ToPPi.py
@@ -136,10 +136,10 @@ def L0ToPPi_LL_MidPT(name="Hlt2PID_L0ToPPi_LL_MidPT", prescale=0.01):
     protons = flt.filter_long_particles(
         filter_protons(make_long_protons(), pt_min=1.5 * GeV, pt_max=3 * GeV),
         pvs,
-        trchi2_max=99999,
+        trchi2_max=4,
         mipchi2_min=36)
     pions = flt.filter_long_particles(
-        make_long_pions(), pvs, trchi2_max=99999, mipchi2_min=36)
+        make_long_pions(), pvs, trchi2_max=4, mipchi2_min=36)
     l0lls = make_l0lls(protons, pions, pvs)
 
     return HltLine(
@@ -222,13 +222,13 @@ def L0ToPPi_DD_MidPT(name="Hlt2PID_L0ToPPi_DD_MidPT", prescale=0.01):
     protons = flt.filter_down_particles(
         filter_protons(make_down_protons(), pt_min=1.5 * GeV, pt_max=3 * GeV),
         p_min=3.0 * GeV,
-        trchi2_max=99999,
+        trchi2_max=4,
     )
     pions = flt.filter_down_particles(
         make_down_pions(),
         p_min=3.0 * GeV,
         pt_min=0.175 * GeV,
-        trchi2_max=99999,
+        trchi2_max=4,
     )
     l0dds = make_l0dds(protons, pions, pvs)
 
-- 
GitLab