From d3f247a0c0801275931b22eb7e1d140a3384e34c Mon Sep 17 00:00:00 2001
From: Adrian Casais Vidal <adrian.casais.vidal@cern.ch>
Date: Tue, 18 Mar 2025 16:11:36 +0100
Subject: [PATCH 01/21] Change filtering

---
 .../Hlt2Conf/lines/qee/dielectron_persist_photons.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index 504bbefe238..2dc336ad8d5 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -141,7 +141,7 @@ def dielectron_sp_prompt_line(
         ],
         prescale=prescale,
         monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMass_massSlice.*_promptDecision"],
+        hlt1_filter_code=["Hlt1DiElectronLowMass_.*Decision"],
     )
 
 
@@ -185,7 +185,7 @@ def dielectron_sp_prompt_line_full(
         ],
         prescale=prescale,
         monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMass_massSlice.*_promptDecision"],
+        hlt1_filter_code=["Hlt1DiElectronLowMass_.*Decision"],
     )
 
 
@@ -226,7 +226,7 @@ def dielectron_sp_displaced_line(
         ],
         prescale=prescale,
         monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMass_massSlice.*_displacedDecision"],
+        hlt1_filter_code=["Hlt1DiElectronLowMass_.*Decision"],
     )
 
 
@@ -270,7 +270,7 @@ def dielectron_sp_displaced_line_full(
         ],
         prescale=prescale,
         monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMass_massSlice.*_displacedDecision"],
+        hlt1_filter_code=["Hlt1DiElectronLowMass_.*Decision"],
     )
 
 
@@ -310,7 +310,7 @@ def dielectron_sp_prompt_same_sign_line(
         ],
         prescale=prescale,
         monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMass_SS_massSlice.*_promptDecision"],
+        hlt1_filter_code=["Hlt1DiElectronLowMass_SS.*Decision"],
     )
 
 
@@ -349,5 +349,5 @@ def dielectron_sp_displaced_same_sign_line(
         ],
         prescale=prescale,
         monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMass_SS_massSlice.*_displacedDecision"],
+        hlt1_filter_code=["Hlt1DiElectronLowMass_SS.*Decision"],
     )
-- 
GitLab


From 067878d6b87b2771df2ef3015bdff25e1b00efaa Mon Sep 17 00:00:00 2001
From: Adrian Casais Vidal <adrian.casais.vidal@cern.ch>
Date: Tue, 18 Mar 2025 21:25:58 +0100
Subject: [PATCH 02/21] Add Norm line

---
 .../lines/qee/dielectron_persist_photons.py   | 131 +++++++++++++++++-
 1 file changed, 124 insertions(+), 7 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index 2dc336ad8d5..d832fc1a5c8 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -111,7 +111,7 @@ def dielectron_sp_prompt_line(
     name="Hlt2QEE_DiElectronPrompt_PersistPhotons",
     prescale=1,
     persistreco=False,
-    e_minpt=0.0,
+    e_minpt=00.,
     make_pvs=make_pvs,
 ):
     """Aiming for prompt pi0/eta -> gamma e+ e- decays. Label the dielectron
@@ -141,10 +141,46 @@ def dielectron_sp_prompt_line(
         ],
         prescale=prescale,
         monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMass_.*Decision"],
+        hlt1_filter_code=["Hlt1DiElectronLowMass_NoIPDecision"],
     )
 
 
+def dielectron_sp_prompt_norm_line(
+    name="Hlt2QEE_DiElectronPromptNorm_PersistPhotons",
+    prescale=1,
+    persistreco=False,
+    e_minpt=00.,
+    make_pvs=make_pvs,
+):
+    """Aiming for to normalize displaced pi0/eta -> gamma e+ e- decays. Label the dielectron
+    as J/psi(1S) [during brem-recovery-reconstruction of dielectron pair] and
+    save photons if Pi0/eta in mass range of [5, 700]MeV."""
+    pvs = make_pvs()
+
+    dielectrons_prompt = dielectron_maker_prompt(e_minpt, isOS=True)
+
+    photons_table = WeightedRelTableAlg(
+        InputCandidates=photon_filter(),
+        ReferenceParticles=dielectrons_prompt,
+        Cut=in_range(comb_mass_limits[0], F.COMB_MASS(), comb_mass_limits[1]),
+    )
+
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + [require_pvs(pvs), dielectrons_prompt],
+        persistreco=persistreco,
+        extra_outputs=[
+            (
+                "DiElectronPromptNorm_Photons",
+                SelectionFromRelationTable(
+                    InputRelations=photons_table.OutputRelations
+                ).OutputLocation,
+            )
+        ],
+        prescale=prescale,
+        monitoring_variables=_default_monitoring_variables,
+        hlt1_filter_code=["Hlt1DiElectronLowMass_NoIPNormDecision"],
+    )
 @register_line_builder(full_lines)
 @configurable
 def dielectron_sp_prompt_line_full(
@@ -185,9 +221,51 @@ def dielectron_sp_prompt_line_full(
         ],
         prescale=prescale,
         monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMass_.*Decision"],
+        hlt1_filter_code=["Hlt1DiElectronLowMass_NoIPDecision"],
+    )
+
+@register_line_builder(full_lines)
+@configurable
+def dielectron_sp_prompt_line_full(
+    name="Hlt2QEE_DiElectronPromptNorm_PersistPhotons_Full",
+    prescale=0.05,
+    persistreco=True,
+    e_minpt=0.0,
+    make_pvs=make_pvs,
+):
+    """Copy of turbo line, but strongly prescaled, which allows full-event
+    studies e.g. of brem correction and background template for e+e- pairs
+    combined with a random photon (4-vector deduced from e+e- in same event
+    and charged pion momentum)"""
+    pvs = make_pvs()
+
+    dielectrons_prompt = dielectron_maker_prompt(e_minpt, isOS=True)
+
+    photons_table = WeightedRelTableAlg(
+        InputCandidates=photon_filter(),
+        ReferenceParticles=dielectrons_prompt,
+        Cut=in_range(comb_mass_limits[0], F.COMB_MASS(), comb_mass_limits[1]),
     )
 
+    extra_pions = charged_pion_filter(pi_minpt=75.0 * MeV)
+
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + [require_pvs(pvs), dielectrons_prompt],
+        persistreco=persistreco,
+        extra_outputs=[
+            (
+                "DiElectronPrompt_Photons",
+                SelectionFromRelationTable(
+                    InputRelations=photons_table.OutputRelations
+                ).OutputLocation,
+            ),
+            ("ChargedPions", extra_pions),
+        ],
+        prescale=prescale,
+        monitoring_variables=_default_monitoring_variables,
+        hlt1_filter_code=["Hlt1DiElectronLowMassNoIPNormDecision"],
+    )
 
 # OS displaced lines (one to turbo, prescaled to full)
 @register_line_builder(turbo_lines)
@@ -270,7 +348,7 @@ def dielectron_sp_displaced_line_full(
         ],
         prescale=prescale,
         monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMass_.*Decision"],
+        hlt1_filter_code=["Hlt1DiElectronLowMass_NoIPDecision","Hlt1DiElectronLowMass_DisplacedDecision"],
     )
 
 
@@ -280,7 +358,46 @@ def dielectron_sp_prompt_same_sign_line(
     name="Hlt2QEE_DiElectronPrompt_PersistPhotonsSS",
     prescale=0.1,
     persistreco=False,
-    e_minpt=0.0,
+    e_minpt=00.,
+    make_pvs=make_pvs,
+):
+    """Aiming for prompt pi0/eta -> gamma e+ e+ or gamma e- e- decays. Label
+    the doubly-charged dielectron as J/psi(1S) and save photons if Pi0/eta in
+    mass range of [5, 700]MeV."""
+    pvs = make_pvs()
+
+    dielectrons_prompt = dielectron_maker_prompt(e_minpt, isOS=False)
+
+    photons_table = WeightedRelTableAlg(
+        InputCandidates=photon_filter(),
+        ReferenceParticles=dielectrons_prompt,
+        Cut=in_range(comb_mass_limits[0], F.COMB_MASS(), comb_mass_limits[1]),
+    )
+
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + [require_pvs(pvs), dielectrons_prompt],
+        persistreco=persistreco,
+        extra_outputs=[
+            (
+                "DiElectronPrompt_ss_Photons",
+                SelectionFromRelationTable(
+                    InputRelations=photons_table.OutputRelations
+                ).OutputLocation,
+            )
+        ],
+        prescale=prescale,
+        monitoring_variables=_default_monitoring_variables,
+        hlt1_filter_code=["Hlt1DiElectronLowMass_SS_NoIPDecision"],
+    )
+
+@register_line_builder(turbo_lines)
+@configurable
+def dielectron_sp_prompt_norm_same_sign_line(
+    name="Hlt2QEE_DiElectronPromptNorm_PersistPhotonsSS",
+    prescale=0.1,
+    persistreco=False,
+    e_minpt=00.,
     make_pvs=make_pvs,
 ):
     """Aiming for prompt pi0/eta -> gamma e+ e+ or gamma e- e- decays. Label
@@ -310,7 +427,7 @@ def dielectron_sp_prompt_same_sign_line(
         ],
         prescale=prescale,
         monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMass_SS.*Decision"],
+        hlt1_filter_code=["Hlt1DiElectronLowMass_SS_NoIPNormDecision"],
     )
 
 
@@ -349,5 +466,5 @@ def dielectron_sp_displaced_same_sign_line(
         ],
         prescale=prescale,
         monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMass_SS.*Decision"],
+        hlt1_filter_code=["Hlt1DiElectronLowMass_SS_NoIPDecision", "Hlt1DiElectronLowMass_SS_DisplacedDecision"],
     )
-- 
GitLab


From 923d3b54675b022f94728a582a18f9bb363508c7 Mon Sep 17 00:00:00 2001
From: Gitlab CI <noreply@cern.ch>
Date: Tue, 18 Mar 2025 20:26:37 +0000
Subject: [PATCH 03/21] pre-commit fixes

patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/52934401
---
 .../lines/qee/dielectron_persist_photons.py   | 23 ++++++++++++++-----
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index d832fc1a5c8..06ad9046202 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -111,7 +111,7 @@ def dielectron_sp_prompt_line(
     name="Hlt2QEE_DiElectronPrompt_PersistPhotons",
     prescale=1,
     persistreco=False,
-    e_minpt=00.,
+    e_minpt=00.0,
     make_pvs=make_pvs,
 ):
     """Aiming for prompt pi0/eta -> gamma e+ e- decays. Label the dielectron
@@ -149,7 +149,7 @@ def dielectron_sp_prompt_norm_line(
     name="Hlt2QEE_DiElectronPromptNorm_PersistPhotons",
     prescale=1,
     persistreco=False,
-    e_minpt=00.,
+    e_minpt=00.0,
     make_pvs=make_pvs,
 ):
     """Aiming for to normalize displaced pi0/eta -> gamma e+ e- decays. Label the dielectron
@@ -181,6 +181,8 @@ def dielectron_sp_prompt_norm_line(
         monitoring_variables=_default_monitoring_variables,
         hlt1_filter_code=["Hlt1DiElectronLowMass_NoIPNormDecision"],
     )
+
+
 @register_line_builder(full_lines)
 @configurable
 def dielectron_sp_prompt_line_full(
@@ -224,6 +226,7 @@ def dielectron_sp_prompt_line_full(
         hlt1_filter_code=["Hlt1DiElectronLowMass_NoIPDecision"],
     )
 
+
 @register_line_builder(full_lines)
 @configurable
 def dielectron_sp_prompt_line_full(
@@ -267,6 +270,7 @@ def dielectron_sp_prompt_line_full(
         hlt1_filter_code=["Hlt1DiElectronLowMassNoIPNormDecision"],
     )
 
+
 # OS displaced lines (one to turbo, prescaled to full)
 @register_line_builder(turbo_lines)
 @configurable
@@ -348,7 +352,10 @@ def dielectron_sp_displaced_line_full(
         ],
         prescale=prescale,
         monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMass_NoIPDecision","Hlt1DiElectronLowMass_DisplacedDecision"],
+        hlt1_filter_code=[
+            "Hlt1DiElectronLowMass_NoIPDecision",
+            "Hlt1DiElectronLowMass_DisplacedDecision",
+        ],
     )
 
 
@@ -358,7 +365,7 @@ def dielectron_sp_prompt_same_sign_line(
     name="Hlt2QEE_DiElectronPrompt_PersistPhotonsSS",
     prescale=0.1,
     persistreco=False,
-    e_minpt=00.,
+    e_minpt=00.0,
     make_pvs=make_pvs,
 ):
     """Aiming for prompt pi0/eta -> gamma e+ e+ or gamma e- e- decays. Label
@@ -391,13 +398,14 @@ def dielectron_sp_prompt_same_sign_line(
         hlt1_filter_code=["Hlt1DiElectronLowMass_SS_NoIPDecision"],
     )
 
+
 @register_line_builder(turbo_lines)
 @configurable
 def dielectron_sp_prompt_norm_same_sign_line(
     name="Hlt2QEE_DiElectronPromptNorm_PersistPhotonsSS",
     prescale=0.1,
     persistreco=False,
-    e_minpt=00.,
+    e_minpt=00.0,
     make_pvs=make_pvs,
 ):
     """Aiming for prompt pi0/eta -> gamma e+ e+ or gamma e- e- decays. Label
@@ -466,5 +474,8 @@ def dielectron_sp_displaced_same_sign_line(
         ],
         prescale=prescale,
         monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMass_SS_NoIPDecision", "Hlt1DiElectronLowMass_SS_DisplacedDecision"],
+        hlt1_filter_code=[
+            "Hlt1DiElectronLowMass_SS_NoIPDecision",
+            "Hlt1DiElectronLowMass_SS_DisplacedDecision",
+        ],
     )
-- 
GitLab


From 7e9b2bfd57560c7660b351c286c37bde37e6accd Mon Sep 17 00:00:00 2001
From: Adrian Casais Vidal <adrian.casais.vidal@cern.ch>
Date: Tue, 18 Mar 2025 21:41:45 +0100
Subject: [PATCH 04/21] typo

---
 .../python/Hlt2Conf/lines/qee/dielectron_persist_photons.py     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index 06ad9046202..55c8bb68c78 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -229,7 +229,7 @@ def dielectron_sp_prompt_line_full(
 
 @register_line_builder(full_lines)
 @configurable
-def dielectron_sp_prompt_line_full(
+def dielectron_sp_prompt_norm_line_full(
     name="Hlt2QEE_DiElectronPromptNorm_PersistPhotons_Full",
     prescale=0.05,
     persistreco=True,
-- 
GitLab


From 6154521d8d596ea48bcb222799cedd12dacd386f Mon Sep 17 00:00:00 2001
From: Adrian Casais Vidal <adrian.casais.vidal@cern.ch>
Date: Tue, 18 Mar 2025 21:45:21 +0100
Subject: [PATCH 05/21] typooo

---
 .../python/Hlt2Conf/lines/qee/dielectron_persist_photons.py  | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index 55c8bb68c78..a8c49508e1c 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -308,7 +308,10 @@ def dielectron_sp_displaced_line(
         ],
         prescale=prescale,
         monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMass_.*Decision"],
+        hlt1_filter_code=[
+            "Hlt1DiElectronLowMass_NoIPDecision",
+            "Hlt1DiElectronLowMass_DisplacedDecision",
+        ],
     )
 
 
-- 
GitLab


From 6477929b4a566e95115f35d131e6e8abc18fa3c2 Mon Sep 17 00:00:00 2001
From: Adrian Casais Vidal <adrian.casais.vidal@cern.ch>
Date: Wed, 19 Mar 2025 14:28:32 +0100
Subject: [PATCH 06/21] fix typo

---
 .../python/Hlt2Conf/lines/qee/dielectron_persist_photons.py   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index a8c49508e1c..08addfdc236 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -111,7 +111,7 @@ def dielectron_sp_prompt_line(
     name="Hlt2QEE_DiElectronPrompt_PersistPhotons",
     prescale=1,
     persistreco=False,
-    e_minpt=00.0,
+    e_minpt=0.0,
     make_pvs=make_pvs,
 ):
     """Aiming for prompt pi0/eta -> gamma e+ e- decays. Label the dielectron
@@ -149,7 +149,7 @@ def dielectron_sp_prompt_norm_line(
     name="Hlt2QEE_DiElectronPromptNorm_PersistPhotons",
     prescale=1,
     persistreco=False,
-    e_minpt=00.0,
+    e_minpt=0.0,
     make_pvs=make_pvs,
 ):
     """Aiming for to normalize displaced pi0/eta -> gamma e+ e- decays. Label the dielectron
-- 
GitLab


From 163ef4cce209c2891b3ef6b6fc09f3665c8ff0dc Mon Sep 17 00:00:00 2001
From: Adrian Casais Vidal <adrian.casais.vidal@cern.ch>
Date: Wed, 19 Mar 2025 14:32:12 +0100
Subject: [PATCH 07/21] correct typos further

---
 .../Hlt2Conf/lines/qee/dielectron_persist_photons.py | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index 08addfdc236..c793891f10f 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -152,7 +152,7 @@ def dielectron_sp_prompt_norm_line(
     e_minpt=0.0,
     make_pvs=make_pvs,
 ):
-    """Aiming for to normalize displaced pi0/eta -> gamma e+ e- decays. Label the dielectron
+    """Aiming for to normalize displaced to prompt pi0/eta -> gamma e+ e- decays. Label the dielectron
     as J/psi(1S) [during brem-recovery-reconstruction of dielectron pair] and
     save photons if Pi0/eta in mass range of [5, 700]MeV."""
     pvs = make_pvs()
@@ -239,7 +239,7 @@ def dielectron_sp_prompt_norm_line_full(
     """Copy of turbo line, but strongly prescaled, which allows full-event
     studies e.g. of brem correction and background template for e+e- pairs
     combined with a random photon (4-vector deduced from e+e- in same event
-    and charged pion momentum)"""
+    and charged pion momentum). This one is to normalize displaced to prompt candidates."""
     pvs = make_pvs()
 
     dielectrons_prompt = dielectron_maker_prompt(e_minpt, isOS=True)
@@ -368,10 +368,10 @@ def dielectron_sp_prompt_same_sign_line(
     name="Hlt2QEE_DiElectronPrompt_PersistPhotonsSS",
     prescale=0.1,
     persistreco=False,
-    e_minpt=00.0,
+    e_minpt=0.0,
     make_pvs=make_pvs,
 ):
-    """Aiming for prompt pi0/eta -> gamma e+ e+ or gamma e- e- decays. Label
+    """Aiming to normalize prompt pi0/eta -> gamma e+ e+ or gamma e- e- decays. Label
     the doubly-charged dielectron as J/psi(1S) and save photons if Pi0/eta in
     mass range of [5, 700]MeV."""
     pvs = make_pvs()
@@ -408,10 +408,10 @@ def dielectron_sp_prompt_norm_same_sign_line(
     name="Hlt2QEE_DiElectronPromptNorm_PersistPhotonsSS",
     prescale=0.1,
     persistreco=False,
-    e_minpt=00.0,
+    e_minpt=0.0,
     make_pvs=make_pvs,
 ):
-    """Aiming for prompt pi0/eta -> gamma e+ e+ or gamma e- e- decays. Label
+    """Aiming to normalize displaced to prompt pi0/eta -> gamma e+ e+ or gamma e- e- decays. Label
     the doubly-charged dielectron as J/psi(1S) and save photons if Pi0/eta in
     mass range of [5, 700]MeV."""
     pvs = make_pvs()
-- 
GitLab


From 370fcd2399e7f4b792361931d426f3deda1d9841 Mon Sep 17 00:00:00 2001
From: Adrian Casais Vidal <adrian.casais.vidal@cern.ch>
Date: Thu, 20 Mar 2025 18:02:41 +0100
Subject: [PATCH 08/21] Address Ross comments and loop prompt lines

---
 .../lines/qee/dielectron_persist_photons.py   | 368 ++++++------------
 1 file changed, 124 insertions(+), 244 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index c793891f10f..f74e2bdd94c 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -103,172 +103,132 @@ def dielectron_maker_displaced(e_minpt, isOS):
         vfaspfchi2ndof=10,
     )
 
-
-# OS Prompt lines (one to turbo, prescaled to full)
-@register_line_builder(turbo_lines)
-@configurable
-def dielectron_sp_prompt_line(
-    name="Hlt2QEE_DiElectronPrompt_PersistPhotons",
-    prescale=1,
-    persistreco=False,
-    e_minpt=0.0,
-    make_pvs=make_pvs,
-):
-    """Aiming for prompt pi0/eta -> gamma e+ e- decays. Label the dielectron
-    as J/psi(1S) [during brem-recovery-reconstruction of dielectron pair] and
-    save photons if Pi0/eta in mass range of [5, 700]MeV."""
-    pvs = make_pvs()
-
-    dielectrons_prompt = dielectron_maker_prompt(e_minpt, isOS=True)
-
-    photons_table = WeightedRelTableAlg(
-        InputCandidates=photon_filter(),
-        ReferenceParticles=dielectrons_prompt,
-        Cut=in_range(comb_mass_limits[0], F.COMB_MASS(), comb_mass_limits[1]),
-    )
-
-    return Hlt2Line(
-        name=name,
-        algs=upfront_reconstruction() + [require_pvs(pvs), dielectrons_prompt],
-        persistreco=persistreco,
-        extra_outputs=[
-            (
-                "DiElectronPrompt_Photons",
-                SelectionFromRelationTable(
-                    InputRelations=photons_table.OutputRelations
-                ).OutputLocation,
-            )
-        ],
-        prescale=prescale,
-        monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMass_NoIPDecision"],
-    )
-
-
-def dielectron_sp_prompt_norm_line(
-    name="Hlt2QEE_DiElectronPromptNorm_PersistPhotons",
-    prescale=1,
-    persistreco=False,
-    e_minpt=0.0,
-    make_pvs=make_pvs,
-):
-    """Aiming for to normalize displaced to prompt pi0/eta -> gamma e+ e- decays. Label the dielectron
-    as J/psi(1S) [during brem-recovery-reconstruction of dielectron pair] and
-    save photons if Pi0/eta in mass range of [5, 700]MeV."""
-    pvs = make_pvs()
-
-    dielectrons_prompt = dielectron_maker_prompt(e_minpt, isOS=True)
-
-    photons_table = WeightedRelTableAlg(
-        InputCandidates=photon_filter(),
-        ReferenceParticles=dielectrons_prompt,
-        Cut=in_range(comb_mass_limits[0], F.COMB_MASS(), comb_mass_limits[1]),
-    )
-
-    return Hlt2Line(
-        name=name,
-        algs=upfront_reconstruction() + [require_pvs(pvs), dielectrons_prompt],
-        persistreco=persistreco,
-        extra_outputs=[
-            (
-                "DiElectronPromptNorm_Photons",
-                SelectionFromRelationTable(
-                    InputRelations=photons_table.OutputRelations
-                ).OutputLocation,
-            )
-        ],
-        prescale=prescale,
-        monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMass_NoIPNormDecision"],
-    )
-
-
-@register_line_builder(full_lines)
-@configurable
-def dielectron_sp_prompt_line_full(
-    name="Hlt2QEE_DiElectronPrompt_PersistPhotons_Full",
-    prescale=0.05,
-    persistreco=True,
-    e_minpt=0.0,
-    make_pvs=make_pvs,
-):
-    """Copy of turbo line, but strongly prescaled, which allows full-event
-    studies e.g. of brem correction and background template for e+e- pairs
-    combined with a random photon (4-vector deduced from e+e- in same event
-    and charged pion momentum)"""
-    pvs = make_pvs()
-
-    dielectrons_prompt = dielectron_maker_prompt(e_minpt, isOS=True)
-
-    photons_table = WeightedRelTableAlg(
-        InputCandidates=photon_filter(),
-        ReferenceParticles=dielectrons_prompt,
-        Cut=in_range(comb_mass_limits[0], F.COMB_MASS(), comb_mass_limits[1]),
-    )
-
-    extra_pions = charged_pion_filter(pi_minpt=75.0 * MeV)
-
-    return Hlt2Line(
-        name=name,
-        algs=upfront_reconstruction() + [require_pvs(pvs), dielectrons_prompt],
-        persistreco=persistreco,
-        extra_outputs=[
-            (
-                "DiElectronPrompt_Photons",
-                SelectionFromRelationTable(
-                    InputRelations=photons_table.OutputRelations
-                ).OutputLocation,
-            ),
-            ("ChargedPions", extra_pions),
-        ],
-        prescale=prescale,
-        monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMass_NoIPDecision"],
-    )
+# Add regular and Normalization line to. The Norm line is intended to normalize the displace yield to the prompt 
+# because of the different PID cuts in HLT1. 
+for kind in "","Norm":
+    # OS Prompt lines (one to turbo, prescaled to full)
+    @register_line_builder(turbo_lines)
+    @configurable
+    def dielectron_sp_prompt_line(
+        name=f"Hlt2QEE_DiElectronPrompt{kind}_PersistPhotons",
+        prescale=1 if kind =='' else 0.1,
+        persistreco=False,
+        e_minpt=0.0,
+        make_pvs=make_pvs,
+    ):
+        """Aiming for prompt pi0/eta -> gamma e+ e- decays. Label the dielectron
+        as J/psi(1S) [during brem-recovery-reconstruction of dielectron pair] and
+        save photons if Pi0/eta in mass range of [5, 700]MeV."""
+        pvs = make_pvs()
+
+        dielectrons_prompt = dielectron_maker_prompt(e_minpt, isOS=True)
+
+        photons_table = WeightedRelTableAlg(
+            InputCandidates=photon_filter(),
+            ReferenceParticles=dielectrons_prompt,
+            Cut=in_range(comb_mass_limits[0], F.COMB_MASS(), comb_mass_limits[1]),
+        )
+
+        return Hlt2Line(
+            name=name,
+            algs=upfront_reconstruction() + [require_pvs(pvs), dielectrons_prompt],
+            persistreco=persistreco,
+            extra_outputs=[
+                (
+                    "DiElectronPrompt_Photons",
+                    SelectionFromRelationTable(
+                        InputRelations=photons_table.OutputRelations
+                    ).OutputLocation,
+                )
+            ],
+            prescale=prescale,
+            monitoring_variables=_default_monitoring_variables,
+            hlt1_filter_code=[f"Hlt1DiElectronLowMass_NoIP{kind}Decision"],
+        )
+
+    @register_line_builder(full_lines)
+    @configurable
+    def dielectron_sp_prompt_line_full(
+        name=f"Hlt2QEE_DiElectronPrompt{kind}_PersistPhotons_Full",
+        prescale=0.05,
+        persistreco=True,
+        e_minpt=0.0,
+        make_pvs=make_pvs,
+    ):
+        """Copy of turbo line, but strongly prescaled, which allows full-event
+        studies e.g. of brem correction and background template for e+e- pairs
+        combined with a random photon (4-vector deduced from e+e- in same event
+        and charged pion momentum)"""
+        pvs = make_pvs()
+
+        dielectrons_prompt = dielectron_maker_prompt(e_minpt, isOS=True)
+
+        photons_table = WeightedRelTableAlg(
+            InputCandidates=photon_filter(),
+            ReferenceParticles=dielectrons_prompt,
+            Cut=in_range(comb_mass_limits[0], F.COMB_MASS(), comb_mass_limits[1]),
+        )
+
+        extra_pions = charged_pion_filter(pi_minpt=75.0 * MeV)
+
+        return Hlt2Line(
+            name=name,
+            algs=upfront_reconstruction() + [require_pvs(pvs), dielectrons_prompt],
+            persistreco=persistreco,
+            extra_outputs=[
+                (
+                    "DiElectronPrompt_Photons",
+                    SelectionFromRelationTable(
+                        InputRelations=photons_table.OutputRelations
+                    ).OutputLocation,
+                ),
+                ("ChargedPions", extra_pions),
+            ],
+            prescale=prescale,
+            monitoring_variables=_default_monitoring_variables,
+            hlt1_filter_code=[f"Hlt1DiElectronLowMass_NoIP{kind}Decision"],
+        )
+
+    @register_line_builder(turbo_lines)
+    @configurable
+    def dielectron_sp_prompt_same_sign_line(
+        name=f"Hlt2QEE_DiElectronPrompt{kind}_PersistPhotonsSS",
+        prescale=0.1,
+        persistreco=False,
+        e_minpt=0.0,
+        make_pvs=make_pvs,
+    ):
+        """Aiming to normalize prompt pi0/eta -> gamma e+ e+ or gamma e- e- decays. Label
+        the doubly-charged dielectron as J/psi(1S) and save photons if Pi0/eta in
+        mass range of [5, 700]MeV."""
+        pvs = make_pvs()
+
+        dielectrons_prompt = dielectron_maker_prompt(e_minpt, isOS=False)
+
+        photons_table = WeightedRelTableAlg(
+            InputCandidates=photon_filter(),
+            ReferenceParticles=dielectrons_prompt,
+            Cut=in_range(comb_mass_limits[0], F.COMB_MASS(), comb_mass_limits[1]),
+        )
+
+        return Hlt2Line(
+            name=name,
+            algs=upfront_reconstruction() + [require_pvs(pvs), dielectrons_prompt],
+            persistreco=persistreco,
+            extra_outputs=[
+                (
+                    "DiElectronPrompt_ss_Photons",
+                    SelectionFromRelationTable(
+                        InputRelations=photons_table.OutputRelations
+                    ).OutputLocation,
+                )
+            ],
+            prescale=prescale,
+            monitoring_variables=_default_monitoring_variables,
+            hlt1_filter_code=[f"Hlt1DiElectronLowMass_SS_NoIP{kind}Decision"],
+        )
 
 
-@register_line_builder(full_lines)
-@configurable
-def dielectron_sp_prompt_norm_line_full(
-    name="Hlt2QEE_DiElectronPromptNorm_PersistPhotons_Full",
-    prescale=0.05,
-    persistreco=True,
-    e_minpt=0.0,
-    make_pvs=make_pvs,
-):
-    """Copy of turbo line, but strongly prescaled, which allows full-event
-    studies e.g. of brem correction and background template for e+e- pairs
-    combined with a random photon (4-vector deduced from e+e- in same event
-    and charged pion momentum). This one is to normalize displaced to prompt candidates."""
-    pvs = make_pvs()
-
-    dielectrons_prompt = dielectron_maker_prompt(e_minpt, isOS=True)
-
-    photons_table = WeightedRelTableAlg(
-        InputCandidates=photon_filter(),
-        ReferenceParticles=dielectrons_prompt,
-        Cut=in_range(comb_mass_limits[0], F.COMB_MASS(), comb_mass_limits[1]),
-    )
-
-    extra_pions = charged_pion_filter(pi_minpt=75.0 * MeV)
-
-    return Hlt2Line(
-        name=name,
-        algs=upfront_reconstruction() + [require_pvs(pvs), dielectrons_prompt],
-        persistreco=persistreco,
-        extra_outputs=[
-            (
-                "DiElectronPrompt_Photons",
-                SelectionFromRelationTable(
-                    InputRelations=photons_table.OutputRelations
-                ).OutputLocation,
-            ),
-            ("ChargedPions", extra_pions),
-        ],
-        prescale=prescale,
-        monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMassNoIPNormDecision"],
-    )
 
 
 # OS displaced lines (one to turbo, prescaled to full)
@@ -362,86 +322,6 @@ def dielectron_sp_displaced_line_full(
     )
 
 
-@register_line_builder(turbo_lines)
-@configurable
-def dielectron_sp_prompt_same_sign_line(
-    name="Hlt2QEE_DiElectronPrompt_PersistPhotonsSS",
-    prescale=0.1,
-    persistreco=False,
-    e_minpt=0.0,
-    make_pvs=make_pvs,
-):
-    """Aiming to normalize prompt pi0/eta -> gamma e+ e+ or gamma e- e- decays. Label
-    the doubly-charged dielectron as J/psi(1S) and save photons if Pi0/eta in
-    mass range of [5, 700]MeV."""
-    pvs = make_pvs()
-
-    dielectrons_prompt = dielectron_maker_prompt(e_minpt, isOS=False)
-
-    photons_table = WeightedRelTableAlg(
-        InputCandidates=photon_filter(),
-        ReferenceParticles=dielectrons_prompt,
-        Cut=in_range(comb_mass_limits[0], F.COMB_MASS(), comb_mass_limits[1]),
-    )
-
-    return Hlt2Line(
-        name=name,
-        algs=upfront_reconstruction() + [require_pvs(pvs), dielectrons_prompt],
-        persistreco=persistreco,
-        extra_outputs=[
-            (
-                "DiElectronPrompt_ss_Photons",
-                SelectionFromRelationTable(
-                    InputRelations=photons_table.OutputRelations
-                ).OutputLocation,
-            )
-        ],
-        prescale=prescale,
-        monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMass_SS_NoIPDecision"],
-    )
-
-
-@register_line_builder(turbo_lines)
-@configurable
-def dielectron_sp_prompt_norm_same_sign_line(
-    name="Hlt2QEE_DiElectronPromptNorm_PersistPhotonsSS",
-    prescale=0.1,
-    persistreco=False,
-    e_minpt=0.0,
-    make_pvs=make_pvs,
-):
-    """Aiming to normalize displaced to prompt pi0/eta -> gamma e+ e+ or gamma e- e- decays. Label
-    the doubly-charged dielectron as J/psi(1S) and save photons if Pi0/eta in
-    mass range of [5, 700]MeV."""
-    pvs = make_pvs()
-
-    dielectrons_prompt = dielectron_maker_prompt(e_minpt, isOS=False)
-
-    photons_table = WeightedRelTableAlg(
-        InputCandidates=photon_filter(),
-        ReferenceParticles=dielectrons_prompt,
-        Cut=in_range(comb_mass_limits[0], F.COMB_MASS(), comb_mass_limits[1]),
-    )
-
-    return Hlt2Line(
-        name=name,
-        algs=upfront_reconstruction() + [require_pvs(pvs), dielectrons_prompt],
-        persistreco=persistreco,
-        extra_outputs=[
-            (
-                "DiElectronPrompt_ss_Photons",
-                SelectionFromRelationTable(
-                    InputRelations=photons_table.OutputRelations
-                ).OutputLocation,
-            )
-        ],
-        prescale=prescale,
-        monitoring_variables=_default_monitoring_variables,
-        hlt1_filter_code=["Hlt1DiElectronLowMass_SS_NoIPNormDecision"],
-    )
-
-
 @register_line_builder(turbo_lines)
 @configurable
 def dielectron_sp_displaced_same_sign_line(
-- 
GitLab


From 0dbd3b031ba5a278a803ed8d124d93ad4a373cae Mon Sep 17 00:00:00 2001
From: Gitlab CI <noreply@cern.ch>
Date: Thu, 20 Mar 2025 17:03:30 +0000
Subject: [PATCH 09/21] pre-commit fixes

patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/53072683
---
 .../Hlt2Conf/lines/qee/dielectron_persist_photons.py  | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index f74e2bdd94c..5eb39f580bb 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -103,15 +103,16 @@ def dielectron_maker_displaced(e_minpt, isOS):
         vfaspfchi2ndof=10,
     )
 
-# Add regular and Normalization line to. The Norm line is intended to normalize the displace yield to the prompt 
-# because of the different PID cuts in HLT1. 
-for kind in "","Norm":
+
+# Add regular and Normalization line to. The Norm line is intended to normalize the displace yield to the prompt
+# because of the different PID cuts in HLT1.
+for kind in "", "Norm":
     # OS Prompt lines (one to turbo, prescaled to full)
     @register_line_builder(turbo_lines)
     @configurable
     def dielectron_sp_prompt_line(
         name=f"Hlt2QEE_DiElectronPrompt{kind}_PersistPhotons",
-        prescale=1 if kind =='' else 0.1,
+        prescale=1 if kind == "" else 0.1,
         persistreco=False,
         e_minpt=0.0,
         make_pvs=make_pvs,
@@ -229,8 +230,6 @@ for kind in "","Norm":
         )
 
 
-
-
 # OS displaced lines (one to turbo, prescaled to full)
 @register_line_builder(turbo_lines)
 @configurable
-- 
GitLab


From a1a97e5ade7b7c294b927b32039cdcec733b7218 Mon Sep 17 00:00:00 2001
From: Adrian Casais Vidal <adrian.casais.vidal@cern.ch>
Date: Fri, 21 Mar 2025 15:53:34 +0100
Subject: [PATCH 10/21] add string param to prevent error

---
 .../Hlt2Conf/lines/qee/dielectron_persist_photons.py      | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index 5eb39f580bb..27e87cef7ed 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -106,7 +106,7 @@ def dielectron_maker_displaced(e_minpt, isOS):
 
 # Add regular and Normalization line to. The Norm line is intended to normalize the displace yield to the prompt
 # because of the different PID cuts in HLT1.
-for kind in "", "Norm":
+for kind in "Norm":
     # OS Prompt lines (one to turbo, prescaled to full)
     @register_line_builder(turbo_lines)
     @configurable
@@ -136,7 +136,7 @@ for kind in "", "Norm":
             persistreco=persistreco,
             extra_outputs=[
                 (
-                    "DiElectronPrompt_Photons",
+                    f"DiElectronPrompt{kind}_Photons",
                     SelectionFromRelationTable(
                         InputRelations=photons_table.OutputRelations
                     ).OutputLocation,
@@ -178,7 +178,7 @@ for kind in "", "Norm":
             persistreco=persistreco,
             extra_outputs=[
                 (
-                    "DiElectronPrompt_Photons",
+                    f"DiElectronPrompt{kind}_Photons",
                     SelectionFromRelationTable(
                         InputRelations=photons_table.OutputRelations
                     ).OutputLocation,
@@ -218,7 +218,7 @@ for kind in "", "Norm":
             persistreco=persistreco,
             extra_outputs=[
                 (
-                    "DiElectronPrompt_ss_Photons",
+                    f"DiElectronPrompt{kind}_ss_Photons",
                     SelectionFromRelationTable(
                         InputRelations=photons_table.OutputRelations
                     ).OutputLocation,
-- 
GitLab


From 20c042c63407c430151a6547d79c922bc17bf78b Mon Sep 17 00:00:00 2001
From: Adrian Casais Vidal <adrian.casais.vidal@cern.ch>
Date: Fri, 21 Mar 2025 16:08:42 +0100
Subject: [PATCH 11/21] typo

---
 .../python/Hlt2Conf/lines/qee/dielectron_persist_photons.py     | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index 27e87cef7ed..046f8ce1e83 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -106,7 +106,7 @@ def dielectron_maker_displaced(e_minpt, isOS):
 
 # Add regular and Normalization line to. The Norm line is intended to normalize the displace yield to the prompt
 # because of the different PID cuts in HLT1.
-for kind in "Norm":
+for kind in "", "Norm":
     # OS Prompt lines (one to turbo, prescaled to full)
     @register_line_builder(turbo_lines)
     @configurable
-- 
GitLab


From 6ccd582b05045f38dfd7a1eaf34c410b3faeb035 Mon Sep 17 00:00:00 2001
From: Adrian Casais Vidal <adrian.casais.vidal@cern.ch>
Date: Fri, 21 Mar 2025 23:02:38 +0100
Subject: [PATCH 12/21] put cuts on dielectron aligning with hlt1

---
 .../lines/qee/dielectron_persist_photons.py        | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index 046f8ce1e83..4a9a73435ae 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -73,10 +73,10 @@ def dielectron_maker_prompt(e_minpt, isOS):
         opposite_sign=isOS,
         PIDe_min=0.0,
         pt_e=e_minpt,
-        maxipchi2=2.0,
+        maxipchi2=64.0,
         trghostprob=0.25,
         dielectron_ID="J/psi(1S)",
-        pt_diE=0 * MeV,
+        pt_diE=500 * MeV, #HLT1 cuts on the SumPT > 1000 
         m_diE_min=5 * MeV,
         m_diE_max=300 * MeV,
         adocachi2cut=30,
@@ -92,10 +92,10 @@ def dielectron_maker_displaced(e_minpt, isOS):
         opposite_sign=isOS,
         PIDe_min=0.0,
         pt_e=e_minpt,
-        minipchi2=2.0,
+        minipchi2=4.0,
         trghostprob=0.25,
         dielectron_ID="J/psi(1S)",
-        pt_diE=0 * MeV,
+        pt_diE=500 * MeV, #HLT1 cuts on the SumPT > 1000 
         m_diE_min=5 * MeV,
         m_diE_max=300 * MeV,
         adocachi2cut=30,
@@ -114,7 +114,7 @@ for kind in "", "Norm":
         name=f"Hlt2QEE_DiElectronPrompt{kind}_PersistPhotons",
         prescale=1 if kind == "" else 0.1,
         persistreco=False,
-        e_minpt=0.0,
+        e_minpt=300., #HLT1 cuts on the PT
         make_pvs=make_pvs,
     ):
         """Aiming for prompt pi0/eta -> gamma e+ e- decays. Label the dielectron
@@ -153,7 +153,7 @@ for kind in "", "Norm":
         name=f"Hlt2QEE_DiElectronPrompt{kind}_PersistPhotons_Full",
         prescale=0.05,
         persistreco=True,
-        e_minpt=0.0,
+        e_minpt=300,
         make_pvs=make_pvs,
     ):
         """Copy of turbo line, but strongly prescaled, which allows full-event
@@ -196,7 +196,7 @@ for kind in "", "Norm":
         name=f"Hlt2QEE_DiElectronPrompt{kind}_PersistPhotonsSS",
         prescale=0.1,
         persistreco=False,
-        e_minpt=0.0,
+        e_minpt=300,
         make_pvs=make_pvs,
     ):
         """Aiming to normalize prompt pi0/eta -> gamma e+ e+ or gamma e- e- decays. Label
-- 
GitLab


From 96e82cc41521f0c928f8c14016e7d083fda1b115 Mon Sep 17 00:00:00 2001
From: Gitlab CI <noreply@cern.ch>
Date: Fri, 21 Mar 2025 22:03:16 +0000
Subject: [PATCH 13/21] pre-commit fixes

patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/53142239
---
 .../python/Hlt2Conf/lines/qee/dielectron_persist_photons.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index 4a9a73435ae..f533c215602 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -76,7 +76,7 @@ def dielectron_maker_prompt(e_minpt, isOS):
         maxipchi2=64.0,
         trghostprob=0.25,
         dielectron_ID="J/psi(1S)",
-        pt_diE=500 * MeV, #HLT1 cuts on the SumPT > 1000 
+        pt_diE=500 * MeV,  # HLT1 cuts on the SumPT > 1000
         m_diE_min=5 * MeV,
         m_diE_max=300 * MeV,
         adocachi2cut=30,
@@ -95,7 +95,7 @@ def dielectron_maker_displaced(e_minpt, isOS):
         minipchi2=4.0,
         trghostprob=0.25,
         dielectron_ID="J/psi(1S)",
-        pt_diE=500 * MeV, #HLT1 cuts on the SumPT > 1000 
+        pt_diE=500 * MeV,  # HLT1 cuts on the SumPT > 1000
         m_diE_min=5 * MeV,
         m_diE_max=300 * MeV,
         adocachi2cut=30,
@@ -114,7 +114,7 @@ for kind in "", "Norm":
         name=f"Hlt2QEE_DiElectronPrompt{kind}_PersistPhotons",
         prescale=1 if kind == "" else 0.1,
         persistreco=False,
-        e_minpt=300., #HLT1 cuts on the PT
+        e_minpt=300.0,  # HLT1 cuts on the PT
         make_pvs=make_pvs,
     ):
         """Aiming for prompt pi0/eta -> gamma e+ e- decays. Label the dielectron
-- 
GitLab


From d1b0955473aae0432d13c9a11a66f045a99eea17 Mon Sep 17 00:00:00 2001
From: Adrian Casais Vidal <adrian.casais.vidal@cern.ch>
Date: Mon, 24 Mar 2025 17:06:32 +0100
Subject: [PATCH 14/21] cuts were not properly aligned

---
 .../Hlt2Conf/lines/qee/dielectron_persist_photons.py       | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index f533c215602..5824a37cbbc 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -107,6 +107,7 @@ def dielectron_maker_displaced(e_minpt, isOS):
 # Add regular and Normalization line to. The Norm line is intended to normalize the displace yield to the prompt
 # because of the different PID cuts in HLT1.
 for kind in "", "Norm":
+    e_pt_cut = 0 if kind == "Norm" else 300
     # OS Prompt lines (one to turbo, prescaled to full)
     @register_line_builder(turbo_lines)
     @configurable
@@ -114,7 +115,7 @@ for kind in "", "Norm":
         name=f"Hlt2QEE_DiElectronPrompt{kind}_PersistPhotons",
         prescale=1 if kind == "" else 0.1,
         persistreco=False,
-        e_minpt=300.0,  # HLT1 cuts on the PT
+        e_minpt=e_pt_cut,  # HLT1 cuts on the PT
         make_pvs=make_pvs,
     ):
         """Aiming for prompt pi0/eta -> gamma e+ e- decays. Label the dielectron
@@ -153,7 +154,7 @@ for kind in "", "Norm":
         name=f"Hlt2QEE_DiElectronPrompt{kind}_PersistPhotons_Full",
         prescale=0.05,
         persistreco=True,
-        e_minpt=300,
+        e_minpt=e_pt_cut,
         make_pvs=make_pvs,
     ):
         """Copy of turbo line, but strongly prescaled, which allows full-event
@@ -196,7 +197,7 @@ for kind in "", "Norm":
         name=f"Hlt2QEE_DiElectronPrompt{kind}_PersistPhotonsSS",
         prescale=0.1,
         persistreco=False,
-        e_minpt=300,
+        e_minpt=e_pt_cut,
         make_pvs=make_pvs,
     ):
         """Aiming to normalize prompt pi0/eta -> gamma e+ e+ or gamma e- e- decays. Label
-- 
GitLab


From 96f08af0505c2ce8dd1d23605a3439db1d74a30d Mon Sep 17 00:00:00 2001
From: Gitlab CI <noreply@cern.ch>
Date: Mon, 24 Mar 2025 16:07:18 +0000
Subject: [PATCH 15/21] pre-commit fixes

patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/53229662
---
 .../python/Hlt2Conf/lines/qee/dielectron_persist_photons.py      | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index 5824a37cbbc..44b621c8698 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -108,6 +108,7 @@ def dielectron_maker_displaced(e_minpt, isOS):
 # because of the different PID cuts in HLT1.
 for kind in "", "Norm":
     e_pt_cut = 0 if kind == "Norm" else 300
+
     # OS Prompt lines (one to turbo, prescaled to full)
     @register_line_builder(turbo_lines)
     @configurable
-- 
GitLab


From 6c71aa3971dc562f1c7441aafc8e0ab8b085863d Mon Sep 17 00:00:00 2001
From: Adrian Casais Vidal <adrian.casais.vidal@cern.ch>
Date: Tue, 25 Mar 2025 17:31:17 +0100
Subject: [PATCH 16/21] Actually use NoIPLine very sizeable reductions in rate

---
 .../lines/qee/dielectron_persist_photons.py   | 30 +++++++++---
 .../python/RecoConf/standard_particles.py     | 49 +++++++++++++++++++
 2 files changed, 73 insertions(+), 6 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index 44b621c8698..b8dbd5da7ab 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -29,6 +29,7 @@ from RecoConf.standard_particles import (
     make_long_electrons_no_brem,
     make_photons,
     make_prompt_dielectron_with_brem,
+    make_noip_dielectron_with_brem,
 )
 
 full_lines = {}
@@ -84,6 +85,23 @@ def dielectron_maker_prompt(e_minpt, isOS):
         vfaspfchi2ndof=10,
     )
 
+@configurable
+def dielectron_maker_noip(e_minpt, isOS):
+    return make_noip_dielectron_with_brem(
+        electron_maker=make_long_electrons_no_brem,
+        opposite_sign=isOS,
+        PIDe_min=0.0,
+        pt_e=e_minpt,
+        trghostprob=0.25,
+        dielectron_ID="J/psi(1S)",
+        pt_diE=500 * MeV,  # HLT1 cuts on the SumPT > 1000
+        m_diE_min=5 * MeV,
+        m_diE_max=300 * MeV,
+        adocachi2cut=30,
+        bpvvdchi2=None,
+        vfaspfchi2ndof=10,
+    )
+
 
 @configurable
 def dielectron_maker_displaced(e_minpt, isOS):
@@ -113,8 +131,8 @@ for kind in "", "Norm":
     @register_line_builder(turbo_lines)
     @configurable
     def dielectron_sp_prompt_line(
-        name=f"Hlt2QEE_DiElectronPrompt{kind}_PersistPhotons",
-        prescale=1 if kind == "" else 0.1,
+        name=f"Hlt2QEE_DiElectronNoIP{kind}_PersistPhotons",
+        prescale=0.1 if kind == "Norm" else 1,
         persistreco=False,
         e_minpt=e_pt_cut,  # HLT1 cuts on the PT
         make_pvs=make_pvs,
@@ -124,7 +142,7 @@ for kind in "", "Norm":
         save photons if Pi0/eta in mass range of [5, 700]MeV."""
         pvs = make_pvs()
 
-        dielectrons_prompt = dielectron_maker_prompt(e_minpt, isOS=True)
+        dielectrons_prompt = dielectron_maker_noip(e_minpt, isOS=True)
 
         photons_table = WeightedRelTableAlg(
             InputCandidates=photon_filter(),
@@ -152,7 +170,7 @@ for kind in "", "Norm":
     @register_line_builder(full_lines)
     @configurable
     def dielectron_sp_prompt_line_full(
-        name=f"Hlt2QEE_DiElectronPrompt{kind}_PersistPhotons_Full",
+        name=f"Hlt2QEE_DiElectronNoIP{kind}_PersistPhotons_Full",
         prescale=0.05,
         persistreco=True,
         e_minpt=e_pt_cut,
@@ -164,7 +182,7 @@ for kind in "", "Norm":
         and charged pion momentum)"""
         pvs = make_pvs()
 
-        dielectrons_prompt = dielectron_maker_prompt(e_minpt, isOS=True)
+        dielectrons_prompt = dielectron_maker_noip(e_minpt, isOS=True)
 
         photons_table = WeightedRelTableAlg(
             InputCandidates=photon_filter(),
@@ -195,7 +213,7 @@ for kind in "", "Norm":
     @register_line_builder(turbo_lines)
     @configurable
     def dielectron_sp_prompt_same_sign_line(
-        name=f"Hlt2QEE_DiElectronPrompt{kind}_PersistPhotonsSS",
+        name=f"Hlt2QEE_DiElectronNoIP{kind}_PersistPhotonsSS",
         prescale=0.1,
         persistreco=False,
         e_minpt=e_pt_cut,
diff --git a/Hlt/RecoConf/python/RecoConf/standard_particles.py b/Hlt/RecoConf/python/RecoConf/standard_particles.py
index ea61516f18a..540a48a244f 100644
--- a/Hlt/RecoConf/python/RecoConf/standard_particles.py
+++ b/Hlt/RecoConf/python/RecoConf/standard_particles.py
@@ -906,6 +906,55 @@ def _make_dielectron_with_brem(
     ).Particles
 
 
+@configurable
+def make_noip_dielectron_with_brem(
+    electron_maker=make_long_electrons_no_brem,
+    opposite_sign=True,
+    pv_maker=_make_pvs,
+    PIDe_min=2.0,
+    probnn_e=None,
+    pt_e=0.25 * GeV,
+    p_e=0.0 * GeV,
+    trghostprob=0.25,
+    dielectron_ID="J/psi(1S)",
+    pt_diE=0 * MeV,
+    m_diE_min=0 * MeV,
+    m_diE_max=6000 * MeV,
+    adocachi2cut=30,
+    bpvvdchi2=30,
+    vfaspfchi2ndof=10,
+):
+    """Make prompt Jpsi -> e+ e- or [Jpsi -> e+ e+ ]cc candidates adding bremsstrahlung correction to the
+    electrons. The selection follows make_detached_dielectron_with_brem but the dielectron
+    combination is built through _make_dielectron_with_brem, providing an example
+    of the usage of this private method.
+    """
+    pvs = pv_maker()
+    particles = electron_maker()
+    code_e = F.require_all(
+        F.PT > pt_e, F.P > p_e, F.GHOSTPROB < trghostprob
+    )
+    if PIDe_min is not None:
+        code_e = code_e & (F.PID_E > PIDe_min)
+    if probnn_e is not None:
+        code_e = code_e & (F.PROBNN_E > probnn_e)
+
+    prompt_e = ParticleFilter(particles, F.FILTER(code_e))
+    prompt_dielectron_with_brem = _make_dielectron_with_brem(
+        prompt_e,
+        pt_diE=pt_diE,
+        m_diE_min=m_diE_min,
+        m_diE_max=m_diE_max,
+        m_diE_ID=dielectron_ID,
+        opposite_sign=opposite_sign,
+    )
+    code_dielectron = F.require_all(
+        F.MAXSDOCACHI2CUT(float(adocachi2cut)), F.CHI2DOF < vfaspfchi2ndof
+    )
+    if bpvvdchi2 is not None:
+        code_dielectron = code_dielectron & (F.OWNPVFDCHI2 < bpvvdchi2)
+
+    return ParticleFilter(prompt_dielectron_with_brem, F.FILTER(code_dielectron))
 @configurable
 def make_prompt_dielectron_with_brem(
     electron_maker=make_long_electrons_no_brem,
-- 
GitLab


From b5046418297a6fe3ca370e267f48d53d559edfe8 Mon Sep 17 00:00:00 2001
From: Adrian Casais Vidal <adrian.casais.vidal@cern.ch>
Date: Tue, 25 Mar 2025 17:49:26 +0100
Subject: [PATCH 17/21] go full no_ip

---
 .../lines/qee/dielectron_persist_photons.py   | 27 ++--------
 .../python/Hlt2Conf/lines/qee/spruce_qee.py   | 20 ++++----
 .../lines/qee/spruce_qee_pp_ref_2024.py       | 12 ++---
 .../python/RecoConf/standard_particles.py     | 51 -------------------
 4 files changed, 20 insertions(+), 90 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index b8dbd5da7ab..4a365ce8845 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -28,7 +28,6 @@ from RecoConf.standard_particles import (
     make_has_rich_long_pions,
     make_long_electrons_no_brem,
     make_photons,
-    make_prompt_dielectron_with_brem,
     make_noip_dielectron_with_brem,
 )
 
@@ -67,24 +66,6 @@ def charged_pion_filter(pi_minpt):
     return ParticleFilter(make_has_rich_long_pions(), F.FILTER(code))
 
 
-@configurable
-def dielectron_maker_prompt(e_minpt, isOS):
-    return make_prompt_dielectron_with_brem(
-        electron_maker=make_long_electrons_no_brem,
-        opposite_sign=isOS,
-        PIDe_min=0.0,
-        pt_e=e_minpt,
-        maxipchi2=64.0,
-        trghostprob=0.25,
-        dielectron_ID="J/psi(1S)",
-        pt_diE=500 * MeV,  # HLT1 cuts on the SumPT > 1000
-        m_diE_min=5 * MeV,
-        m_diE_max=300 * MeV,
-        adocachi2cut=30,
-        bpvvdchi2=None,
-        vfaspfchi2ndof=10,
-    )
-
 @configurable
 def dielectron_maker_noip(e_minpt, isOS):
     return make_noip_dielectron_with_brem(
@@ -130,7 +111,7 @@ for kind in "", "Norm":
     # OS Prompt lines (one to turbo, prescaled to full)
     @register_line_builder(turbo_lines)
     @configurable
-    def dielectron_sp_prompt_line(
+    def dielectron_sp_noip_line(
         name=f"Hlt2QEE_DiElectronNoIP{kind}_PersistPhotons",
         prescale=0.1 if kind == "Norm" else 1,
         persistreco=False,
@@ -169,7 +150,7 @@ for kind in "", "Norm":
 
     @register_line_builder(full_lines)
     @configurable
-    def dielectron_sp_prompt_line_full(
+    def dielectron_sp_noip_line_full(
         name=f"Hlt2QEE_DiElectronNoIP{kind}_PersistPhotons_Full",
         prescale=0.05,
         persistreco=True,
@@ -212,7 +193,7 @@ for kind in "", "Norm":
 
     @register_line_builder(turbo_lines)
     @configurable
-    def dielectron_sp_prompt_same_sign_line(
+    def dielectron_sp_noip_same_sign_line(
         name=f"Hlt2QEE_DiElectronNoIP{kind}_PersistPhotonsSS",
         prescale=0.1,
         persistreco=False,
@@ -224,7 +205,7 @@ for kind in "", "Norm":
         mass range of [5, 700]MeV."""
         pvs = make_pvs()
 
-        dielectrons_prompt = dielectron_maker_prompt(e_minpt, isOS=False)
+        dielectrons_prompt = dielectron_maker_noip(e_minpt, isOS=False)
 
         photons_table = WeightedRelTableAlg(
             InputCandidates=photon_filter(),
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee.py
index 1de20e0414b..c69dfb2f7c3 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee.py
@@ -36,9 +36,9 @@ from Hlt2Conf.lines.qee.diboson import (
 from Hlt2Conf.lines.qee.dielectron_persist_photons import (
     charged_pion_filter,
     dielectron_maker_displaced,
-    dielectron_maker_prompt,
+    dielectron_maker_noip,
     dielectron_sp_displaced_line_full,
-    dielectron_sp_prompt_line_full,
+    dielectron_sp_noip_line_full,
     photon_filter,
 )
 from Hlt2Conf.lines.qee.high_mass_dielec import (
@@ -1000,7 +1000,7 @@ def TrijetsTwoSVTag_sprucing_line(name="SpruceQEE_TrijetsTwoSVTag", prescale=1):
 
 @register_line_builder(sprucing_lines)
 @configurable
-def dielectron_sp_prompt_sprucing_line(
+def dielectron_sp_noip_sprucing_line(
     name="SpruceQEE_DiElectronPrompt_PersistPhotons", prescale=0.1
 ):
     """Sprucing of full stream lines selecting prompt pi0/eta -> e+e-gamma
@@ -1010,22 +1010,22 @@ def dielectron_sp_prompt_sprucing_line(
 
     pvs = make_pvs()
 
-    dielectrons_prompt = dielectron_maker_prompt(e_minpt=0.0, isOS=True)
+    dielectrons_noip = dielectron_maker_noip(e_minpt=0.0, isOS=True)
 
     photons_table = WeightedRelTableAlg(
         InputCandidates=photon_filter(),
-        ReferenceParticles=dielectrons_prompt,
-        Cut=in_range(5.0 * MeV, F.COMB_MASS(), 600.0 * MeV),
+        ReferenceParticles=dielectrons_noip,
+        Cut=in_range(5.0 * MeV, F.COMB_MASS(), 700.0 * MeV),
     )
 
     charged_pions = charged_pion_filter(pi_minpt=75.0 * MeV)
 
     return SpruceLine(
         name=name,
-        algs=upfront_reconstruction() + [require_pvs(pvs), dielectrons_prompt],
+        algs=upfront_reconstruction() + [require_pvs(pvs), dielectrons_noip],
         extra_outputs=[
             (
-                "DiElectronPrompt_Photons",
+                "DiElectronNoIP_Photons",
                 SelectionFromRelationTable(
                     InputRelations=photons_table.OutputRelations
                 ).OutputLocation,
@@ -1033,7 +1033,7 @@ def dielectron_sp_prompt_sprucing_line(
             ("ChargedPions", charged_pions),
         ],
         prescale=prescale,
-        hlt2_filter_code=_hlt2_decision_regex(dielectron_sp_prompt_line_full),
+        hlt2_filter_code=_hlt2_decision_regex(dielectron_sp_noip_line_full),
     )
 
 
@@ -1054,7 +1054,7 @@ def dielectron_sp_displaced_sprucing_line(
     photons_table = WeightedRelTableAlg(
         InputCandidates=photon_filter(),
         ReferenceParticles=dielectrons_displaced,
-        Cut=in_range(5.0 * MeV, F.COMB_MASS(), 600.0 * MeV),
+        Cut=in_range(5.0 * MeV, F.COMB_MASS(), 700.0 * MeV),
     )
 
     charged_pions = charged_pion_filter(pi_minpt=75.0 * MeV)
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_pp_ref_2024.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_pp_ref_2024.py
index 14dfe963536..0994c239717 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_pp_ref_2024.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_pp_ref_2024.py
@@ -35,9 +35,9 @@ from Hlt2Conf.lines.qee.diboson import (
 from Hlt2Conf.lines.qee.dielectron_persist_photons import (
     charged_pion_filter,
     dielectron_maker_displaced,
-    dielectron_maker_prompt,
+    dielectron_maker_noip,
     dielectron_sp_displaced_line_full,
-    dielectron_sp_prompt_line_full,
+    dielectron_sp_noip_line_full,
     photon_filter,
 )
 from Hlt2Conf.lines.qee.high_mass_dielec import (
@@ -995,12 +995,12 @@ def dielectron_sp_prompt_sprucing_line(
 
     pvs = make_pvs()
 
-    dielectrons_prompt = dielectron_maker_prompt(e_minpt=0.0, isOS=True)
+    dielectrons_prompt = dielectron_maker_noip(e_minpt=0.0, isOS=True)
 
     photons_table = WeightedRelTableAlg(
         InputCandidates=photon_filter(),
         ReferenceParticles=dielectrons_prompt,
-        Cut=in_range(5.0 * MeV, F.COMB_MASS(), 600.0 * MeV),
+        Cut=in_range(5.0 * MeV, F.COMB_MASS(), 700.0 * MeV),
     )
 
     charged_pions = charged_pion_filter(pi_minpt=75.0 * MeV)
@@ -1018,7 +1018,7 @@ def dielectron_sp_prompt_sprucing_line(
             ("ChargedPions", charged_pions),
         ],
         prescale=prescale,
-        hlt2_filter_code=_hlt2_decision_regex(dielectron_sp_prompt_line_full),
+        hlt2_filter_code=_hlt2_decision_regex(dielectron_sp_noip_line_full),
     )
 
 
@@ -1039,7 +1039,7 @@ def dielectron_sp_displaced_sprucing_line(
     photons_table = WeightedRelTableAlg(
         InputCandidates=photon_filter(),
         ReferenceParticles=dielectrons_displaced,
-        Cut=in_range(5.0 * MeV, F.COMB_MASS(), 600.0 * MeV),
+        Cut=in_range(5.0 * MeV, F.COMB_MASS(), 700.0 * MeV),
     )
 
     charged_pions = charged_pion_filter(pi_minpt=75.0 * MeV)
diff --git a/Hlt/RecoConf/python/RecoConf/standard_particles.py b/Hlt/RecoConf/python/RecoConf/standard_particles.py
index 540a48a244f..d84ed299c81 100644
--- a/Hlt/RecoConf/python/RecoConf/standard_particles.py
+++ b/Hlt/RecoConf/python/RecoConf/standard_particles.py
@@ -955,57 +955,6 @@ def make_noip_dielectron_with_brem(
         code_dielectron = code_dielectron & (F.OWNPVFDCHI2 < bpvvdchi2)
 
     return ParticleFilter(prompt_dielectron_with_brem, F.FILTER(code_dielectron))
-@configurable
-def make_prompt_dielectron_with_brem(
-    electron_maker=make_long_electrons_no_brem,
-    opposite_sign=True,
-    pv_maker=_make_pvs,
-    PIDe_min=2.0,
-    probnn_e=None,
-    pt_e=0.25 * GeV,
-    p_e=0.0 * GeV,
-    maxipchi2=9.0,
-    trghostprob=0.25,
-    dielectron_ID="J/psi(1S)",
-    pt_diE=0 * MeV,
-    m_diE_min=0 * MeV,
-    m_diE_max=6000 * MeV,
-    adocachi2cut=30,
-    bpvvdchi2=30,
-    vfaspfchi2ndof=10,
-):
-    """Make prompt Jpsi -> e+ e- or [Jpsi -> e+ e+ ]cc candidates adding bremsstrahlung correction to the
-    electrons. The selection follows make_detached_dielectron_with_brem but the dielectron
-    combination is built through _make_dielectron_with_brem, providing an example
-    of the usage of this private method.
-    """
-    pvs = pv_maker()
-    particles = electron_maker()
-    code_e = F.require_all(
-        F.PT > pt_e, F.P > p_e, F.MINIPCHI2(pvs) < maxipchi2, F.GHOSTPROB < trghostprob
-    )
-    if PIDe_min is not None:
-        code_e = code_e & (F.PID_E > PIDe_min)
-    if probnn_e is not None:
-        code_e = code_e & (F.PROBNN_E > probnn_e)
-
-    prompt_e = ParticleFilter(particles, F.FILTER(code_e))
-    prompt_dielectron_with_brem = _make_dielectron_with_brem(
-        prompt_e,
-        pt_diE=pt_diE,
-        m_diE_min=m_diE_min,
-        m_diE_max=m_diE_max,
-        m_diE_ID=dielectron_ID,
-        opposite_sign=opposite_sign,
-    )
-    code_dielectron = F.require_all(
-        F.MAXSDOCACHI2CUT(float(adocachi2cut)), F.CHI2DOF < vfaspfchi2ndof
-    )
-    if bpvvdchi2 is not None:
-        code_dielectron = code_dielectron & (F.OWNPVFDCHI2 < bpvvdchi2)
-
-    return ParticleFilter(prompt_dielectron_with_brem, F.FILTER(code_dielectron))
-
 
 @configurable
 def make_detached_dielectron_with_brem(
-- 
GitLab


From f5f59ac5305d706e874a0cc92a11be90eeae711c Mon Sep 17 00:00:00 2001
From: Gitlab CI <noreply@cern.ch>
Date: Tue, 25 Mar 2025 16:50:05 +0000
Subject: [PATCH 18/21] pre-commit fixes

patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/53284813
---
 .../python/Hlt2Conf/lines/qee/dielectron_persist_photons.py  | 2 +-
 Hlt/RecoConf/python/RecoConf/standard_particles.py           | 5 ++---
 2 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index 4a365ce8845..96512966f5b 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -27,8 +27,8 @@ from RecoConf.standard_particles import (
     make_detached_dielectron_with_brem,
     make_has_rich_long_pions,
     make_long_electrons_no_brem,
-    make_photons,
     make_noip_dielectron_with_brem,
+    make_photons,
 )
 
 full_lines = {}
diff --git a/Hlt/RecoConf/python/RecoConf/standard_particles.py b/Hlt/RecoConf/python/RecoConf/standard_particles.py
index d84ed299c81..ec6f81ea5c4 100644
--- a/Hlt/RecoConf/python/RecoConf/standard_particles.py
+++ b/Hlt/RecoConf/python/RecoConf/standard_particles.py
@@ -931,9 +931,7 @@ def make_noip_dielectron_with_brem(
     """
     pvs = pv_maker()
     particles = electron_maker()
-    code_e = F.require_all(
-        F.PT > pt_e, F.P > p_e, F.GHOSTPROB < trghostprob
-    )
+    code_e = F.require_all(F.PT > pt_e, F.P > p_e, F.GHOSTPROB < trghostprob)
     if PIDe_min is not None:
         code_e = code_e & (F.PID_E > PIDe_min)
     if probnn_e is not None:
@@ -956,6 +954,7 @@ def make_noip_dielectron_with_brem(
 
     return ParticleFilter(prompt_dielectron_with_brem, F.FILTER(code_dielectron))
 
+
 @configurable
 def make_detached_dielectron_with_brem(
     electron_maker=make_long_electrons_no_brem,
-- 
GitLab


From 5339b9088c593b35ac5315e7e4441d5b3fc93edc Mon Sep 17 00:00:00 2001
From: Adrian Casais Vidal <adrian.casais.vidal@cern.ch>
Date: Tue, 25 Mar 2025 18:12:51 +0100
Subject: [PATCH 19/21] don't remove builder add new one

---
 .../python/RecoConf/standard_particles.py     | 55 ++++++++++++++++++-
 1 file changed, 54 insertions(+), 1 deletion(-)

diff --git a/Hlt/RecoConf/python/RecoConf/standard_particles.py b/Hlt/RecoConf/python/RecoConf/standard_particles.py
index ec6f81ea5c4..9fb276425d7 100644
--- a/Hlt/RecoConf/python/RecoConf/standard_particles.py
+++ b/Hlt/RecoConf/python/RecoConf/standard_particles.py
@@ -931,7 +931,60 @@ def make_noip_dielectron_with_brem(
     """
     pvs = pv_maker()
     particles = electron_maker()
-    code_e = F.require_all(F.PT > pt_e, F.P > p_e, F.GHOSTPROB < trghostprob)
+    code_e = F.require_all(
+        F.PT > pt_e, F.P > p_e, F.GHOSTPROB < trghostprob
+    )
+    if PIDe_min is not None:
+        code_e = code_e & (F.PID_E > PIDe_min)
+    if probnn_e is not None:
+        code_e = code_e & (F.PROBNN_E > probnn_e)
+
+    prompt_e = ParticleFilter(particles, F.FILTER(code_e))
+    prompt_dielectron_with_brem = _make_dielectron_with_brem(
+        prompt_e,
+        pt_diE=pt_diE,
+        m_diE_min=m_diE_min,
+        m_diE_max=m_diE_max,
+        m_diE_ID=dielectron_ID,
+        opposite_sign=opposite_sign,
+    )
+    code_dielectron = F.require_all(
+        F.MAXSDOCACHI2CUT(float(adocachi2cut)), F.CHI2DOF < vfaspfchi2ndof
+    )
+    if bpvvdchi2 is not None:
+        code_dielectron = code_dielectron & (F.OWNPVFDCHI2 < bpvvdchi2)
+
+    return ParticleFilter(prompt_dielectron_with_brem, F.FILTER(code_dielectron))
+    
+@configurable
+def make_prompt_dielectron_with_brem(
+    electron_maker=make_long_electrons_no_brem,
+    opposite_sign=True,
+    pv_maker=_make_pvs,
+    PIDe_min=2.0,
+    probnn_e=None,
+    pt_e=0.25 * GeV,
+    p_e=0.0 * GeV,
+    maxipchi2=9.0,
+    trghostprob=0.25,
+    dielectron_ID="J/psi(1S)",
+    pt_diE=0 * MeV,
+    m_diE_min=0 * MeV,
+    m_diE_max=6000 * MeV,
+    adocachi2cut=30,
+    bpvvdchi2=30,
+    vfaspfchi2ndof=10,
+):
+    """Make prompt Jpsi -> e+ e- or [Jpsi -> e+ e+ ]cc candidates adding bremsstrahlung correction to the
+    electrons. The selection follows make_detached_dielectron_with_brem but the dielectron
+    combination is built through _make_dielectron_with_brem, providing an example
+    of the usage of this private method.
+    """
+    pvs = pv_maker()
+    particles = electron_maker()
+    code_e = F.require_all(
+        F.PT > pt_e, F.P > p_e, F.MINIPCHI2(pvs) < maxipchi2, F.GHOSTPROB < trghostprob
+    )
     if PIDe_min is not None:
         code_e = code_e & (F.PID_E > PIDe_min)
     if probnn_e is not None:
-- 
GitLab


From fc8b312b3a4563c727dbb2db9a4c47c526ad344a Mon Sep 17 00:00:00 2001
From: Adrian Casais Vidal <adrian.casais.vidal@cern.ch>
Date: Tue, 25 Mar 2025 18:44:41 +0100
Subject: [PATCH 20/21] Actually no need a new builder just used the displaced
 with no IPChi2 cut

---
 .../lines/qee/dielectron_persist_photons.py   | 28 ++---------
 .../python/Hlt2Conf/lines/qee/spruce_qee.py   |  3 +-
 .../lines/qee/spruce_qee_pp_ref_2024.py       |  3 +-
 .../python/RecoConf/standard_particles.py     | 50 -------------------
 4 files changed, 7 insertions(+), 77 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index 96512966f5b..26e89405f57 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -27,7 +27,6 @@ from RecoConf.standard_particles import (
     make_detached_dielectron_with_brem,
     make_has_rich_long_pions,
     make_long_electrons_no_brem,
-    make_noip_dielectron_with_brem,
     make_photons,
 )
 
@@ -66,32 +65,15 @@ def charged_pion_filter(pi_minpt):
     return ParticleFilter(make_has_rich_long_pions(), F.FILTER(code))
 
 
-@configurable
-def dielectron_maker_noip(e_minpt, isOS):
-    return make_noip_dielectron_with_brem(
-        electron_maker=make_long_electrons_no_brem,
-        opposite_sign=isOS,
-        PIDe_min=0.0,
-        pt_e=e_minpt,
-        trghostprob=0.25,
-        dielectron_ID="J/psi(1S)",
-        pt_diE=500 * MeV,  # HLT1 cuts on the SumPT > 1000
-        m_diE_min=5 * MeV,
-        m_diE_max=300 * MeV,
-        adocachi2cut=30,
-        bpvvdchi2=None,
-        vfaspfchi2ndof=10,
-    )
-
 
 @configurable
-def dielectron_maker_displaced(e_minpt, isOS):
+def dielectron_maker_displaced(e_minpt, isOS,minipchi2=4.0):
     return make_detached_dielectron_with_brem(
         electron_maker=make_long_electrons_no_brem,
         opposite_sign=isOS,
         PIDe_min=0.0,
         pt_e=e_minpt,
-        minipchi2=4.0,
+        minipchi2=minipchi2,
         trghostprob=0.25,
         dielectron_ID="J/psi(1S)",
         pt_diE=500 * MeV,  # HLT1 cuts on the SumPT > 1000
@@ -123,7 +105,7 @@ for kind in "", "Norm":
         save photons if Pi0/eta in mass range of [5, 700]MeV."""
         pvs = make_pvs()
 
-        dielectrons_prompt = dielectron_maker_noip(e_minpt, isOS=True)
+        dielectrons_prompt = dielectron_maker_displaced(e_minpt, isOS=True, minipchi2=-1)
 
         photons_table = WeightedRelTableAlg(
             InputCandidates=photon_filter(),
@@ -163,7 +145,7 @@ for kind in "", "Norm":
         and charged pion momentum)"""
         pvs = make_pvs()
 
-        dielectrons_prompt = dielectron_maker_noip(e_minpt, isOS=True)
+        dielectrons_prompt = dielectron_maker_displaced(e_minpt, isOS=True, minipchi2=-1)
 
         photons_table = WeightedRelTableAlg(
             InputCandidates=photon_filter(),
@@ -205,7 +187,7 @@ for kind in "", "Norm":
         mass range of [5, 700]MeV."""
         pvs = make_pvs()
 
-        dielectrons_prompt = dielectron_maker_noip(e_minpt, isOS=False)
+        dielectrons_prompt = dielectron_maker_displaced(e_minpt, isOS=True, minipchi2=-1)
 
         photons_table = WeightedRelTableAlg(
             InputCandidates=photon_filter(),
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee.py
index c69dfb2f7c3..049afb007c1 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee.py
@@ -36,7 +36,6 @@ from Hlt2Conf.lines.qee.diboson import (
 from Hlt2Conf.lines.qee.dielectron_persist_photons import (
     charged_pion_filter,
     dielectron_maker_displaced,
-    dielectron_maker_noip,
     dielectron_sp_displaced_line_full,
     dielectron_sp_noip_line_full,
     photon_filter,
@@ -1010,7 +1009,7 @@ def dielectron_sp_noip_sprucing_line(
 
     pvs = make_pvs()
 
-    dielectrons_noip = dielectron_maker_noip(e_minpt=0.0, isOS=True)
+    dielectrons_noip = dielectron_maker_displaced(e_minpt=300, isOS=True, minipchi2=-1)
 
     photons_table = WeightedRelTableAlg(
         InputCandidates=photon_filter(),
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_pp_ref_2024.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_pp_ref_2024.py
index 0994c239717..1e2de82753d 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_pp_ref_2024.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_pp_ref_2024.py
@@ -35,7 +35,6 @@ from Hlt2Conf.lines.qee.diboson import (
 from Hlt2Conf.lines.qee.dielectron_persist_photons import (
     charged_pion_filter,
     dielectron_maker_displaced,
-    dielectron_maker_noip,
     dielectron_sp_displaced_line_full,
     dielectron_sp_noip_line_full,
     photon_filter,
@@ -995,7 +994,7 @@ def dielectron_sp_prompt_sprucing_line(
 
     pvs = make_pvs()
 
-    dielectrons_prompt = dielectron_maker_noip(e_minpt=0.0, isOS=True)
+    dielectrons_prompt = dielectron_maker_displaced(e_minpt=300., isOS=True, minipchi2=-1)
 
     photons_table = WeightedRelTableAlg(
         InputCandidates=photon_filter(),
diff --git a/Hlt/RecoConf/python/RecoConf/standard_particles.py b/Hlt/RecoConf/python/RecoConf/standard_particles.py
index 9fb276425d7..6845626cc9d 100644
--- a/Hlt/RecoConf/python/RecoConf/standard_particles.py
+++ b/Hlt/RecoConf/python/RecoConf/standard_particles.py
@@ -905,56 +905,6 @@ def _make_dielectron_with_brem(
         BremAdder=bremadder,
     ).Particles
 
-
-@configurable
-def make_noip_dielectron_with_brem(
-    electron_maker=make_long_electrons_no_brem,
-    opposite_sign=True,
-    pv_maker=_make_pvs,
-    PIDe_min=2.0,
-    probnn_e=None,
-    pt_e=0.25 * GeV,
-    p_e=0.0 * GeV,
-    trghostprob=0.25,
-    dielectron_ID="J/psi(1S)",
-    pt_diE=0 * MeV,
-    m_diE_min=0 * MeV,
-    m_diE_max=6000 * MeV,
-    adocachi2cut=30,
-    bpvvdchi2=30,
-    vfaspfchi2ndof=10,
-):
-    """Make prompt Jpsi -> e+ e- or [Jpsi -> e+ e+ ]cc candidates adding bremsstrahlung correction to the
-    electrons. The selection follows make_detached_dielectron_with_brem but the dielectron
-    combination is built through _make_dielectron_with_brem, providing an example
-    of the usage of this private method.
-    """
-    pvs = pv_maker()
-    particles = electron_maker()
-    code_e = F.require_all(
-        F.PT > pt_e, F.P > p_e, F.GHOSTPROB < trghostprob
-    )
-    if PIDe_min is not None:
-        code_e = code_e & (F.PID_E > PIDe_min)
-    if probnn_e is not None:
-        code_e = code_e & (F.PROBNN_E > probnn_e)
-
-    prompt_e = ParticleFilter(particles, F.FILTER(code_e))
-    prompt_dielectron_with_brem = _make_dielectron_with_brem(
-        prompt_e,
-        pt_diE=pt_diE,
-        m_diE_min=m_diE_min,
-        m_diE_max=m_diE_max,
-        m_diE_ID=dielectron_ID,
-        opposite_sign=opposite_sign,
-    )
-    code_dielectron = F.require_all(
-        F.MAXSDOCACHI2CUT(float(adocachi2cut)), F.CHI2DOF < vfaspfchi2ndof
-    )
-    if bpvvdchi2 is not None:
-        code_dielectron = code_dielectron & (F.OWNPVFDCHI2 < bpvvdchi2)
-
-    return ParticleFilter(prompt_dielectron_with_brem, F.FILTER(code_dielectron))
     
 @configurable
 def make_prompt_dielectron_with_brem(
-- 
GitLab


From 020cfa2f3588475cbd4724957618e10acf0cc2d6 Mon Sep 17 00:00:00 2001
From: Gitlab CI <noreply@cern.ch>
Date: Tue, 25 Mar 2025 17:45:21 +0000
Subject: [PATCH 21/21] pre-commit fixes

patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/53287445
---
 .../lines/qee/dielectron_persist_photons.py       | 15 ++++++++++-----
 .../Hlt2Conf/lines/qee/spruce_qee_pp_ref_2024.py  |  4 +++-
 .../python/RecoConf/standard_particles.py         |  2 +-
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
index 26e89405f57..4b44210fd23 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/dielectron_persist_photons.py
@@ -65,9 +65,8 @@ def charged_pion_filter(pi_minpt):
     return ParticleFilter(make_has_rich_long_pions(), F.FILTER(code))
 
 
-
 @configurable
-def dielectron_maker_displaced(e_minpt, isOS,minipchi2=4.0):
+def dielectron_maker_displaced(e_minpt, isOS, minipchi2=4.0):
     return make_detached_dielectron_with_brem(
         electron_maker=make_long_electrons_no_brem,
         opposite_sign=isOS,
@@ -105,7 +104,9 @@ for kind in "", "Norm":
         save photons if Pi0/eta in mass range of [5, 700]MeV."""
         pvs = make_pvs()
 
-        dielectrons_prompt = dielectron_maker_displaced(e_minpt, isOS=True, minipchi2=-1)
+        dielectrons_prompt = dielectron_maker_displaced(
+            e_minpt, isOS=True, minipchi2=-1
+        )
 
         photons_table = WeightedRelTableAlg(
             InputCandidates=photon_filter(),
@@ -145,7 +146,9 @@ for kind in "", "Norm":
         and charged pion momentum)"""
         pvs = make_pvs()
 
-        dielectrons_prompt = dielectron_maker_displaced(e_minpt, isOS=True, minipchi2=-1)
+        dielectrons_prompt = dielectron_maker_displaced(
+            e_minpt, isOS=True, minipchi2=-1
+        )
 
         photons_table = WeightedRelTableAlg(
             InputCandidates=photon_filter(),
@@ -187,7 +190,9 @@ for kind in "", "Norm":
         mass range of [5, 700]MeV."""
         pvs = make_pvs()
 
-        dielectrons_prompt = dielectron_maker_displaced(e_minpt, isOS=True, minipchi2=-1)
+        dielectrons_prompt = dielectron_maker_displaced(
+            e_minpt, isOS=True, minipchi2=-1
+        )
 
         photons_table = WeightedRelTableAlg(
             InputCandidates=photon_filter(),
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_pp_ref_2024.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_pp_ref_2024.py
index 1e2de82753d..d834a6b7594 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_pp_ref_2024.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/qee/spruce_qee_pp_ref_2024.py
@@ -994,7 +994,9 @@ def dielectron_sp_prompt_sprucing_line(
 
     pvs = make_pvs()
 
-    dielectrons_prompt = dielectron_maker_displaced(e_minpt=300., isOS=True, minipchi2=-1)
+    dielectrons_prompt = dielectron_maker_displaced(
+        e_minpt=300.0, isOS=True, minipchi2=-1
+    )
 
     photons_table = WeightedRelTableAlg(
         InputCandidates=photon_filter(),
diff --git a/Hlt/RecoConf/python/RecoConf/standard_particles.py b/Hlt/RecoConf/python/RecoConf/standard_particles.py
index 6845626cc9d..ea61516f18a 100644
--- a/Hlt/RecoConf/python/RecoConf/standard_particles.py
+++ b/Hlt/RecoConf/python/RecoConf/standard_particles.py
@@ -905,7 +905,7 @@ def _make_dielectron_with_brem(
         BremAdder=bremadder,
     ).Particles
 
-    
+
 @configurable
 def make_prompt_dielectron_with_brem(
     electron_maker=make_long_electrons_no_brem,
-- 
GitLab