From 0e422228aac0ece21cc0062c3faee74292e24ca9 Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Mon, 27 Dec 2021 17:31:57 +0100
Subject: [PATCH 01/26] first attempt

---
 .../lines/rd/builders/rdbuilder_thor.py       |   6 +-
 .../python/Hlt2Conf/lines/rd/qqbar_to_emu.py  | 148 ++++++++++++++++++
 2 files changed, 151 insertions(+), 3 deletions(-)
 create mode 100644 Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/rdbuilder_thor.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/rdbuilder_thor.py
index cfc3294a05e..68e34eb0ea9 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/rdbuilder_thor.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/rdbuilder_thor.py
@@ -804,7 +804,7 @@ def make_rd_detached_dielectron(name="rd_detached_dielectron",
 
 
 @configurable
-def make_rd_detached_mue(name="rd_detached_mue",
+def make_rd_detached_mue(min_dilepton_mass=100. * MeV,
                          max_dilepton_mass=6000. * MeV,
                          parent_id='J/psi(1S)',
                          min_probnn_mu=0.,
@@ -830,8 +830,8 @@ def make_rd_detached_mue(name="rd_detached_mue",
         min_pt_mu=min_pt_mu,
         min_bpvvdchi2=min_bpvvdchi2,
         max_vchi2ndof=max_vchi2ndof)
-    code = require_all(F.MASS < max_dilepton_mass)
-    return ParticleFilter(dileptons, F.FILTER(code), name=name)
+    code = require_all(in_range(min_dilepton_mass, F.MASS, max_dilepton_mass))
+    return ParticleFilter(dileptons, F.FILTER(code))
 
 
 ####################################
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
new file mode 100644
index 00000000000..e06dd44d6e9
--- /dev/null
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
@@ -0,0 +1,148 @@
+##############################################################################
+# (c) Copyright 2021 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.                                       #
+###############################################################################
+"""
+Definiton of LFV lines of qqbar -> emu
+- Phi(1020) -> E Mu + SS
+- J/Psi(1S) -> E Mu + SS
+- Upsilon(1S) -> E Mu + SS
+
+author: Miroslav Saur
+date: 27.12.2021
+
+"""
+
+import Functors as F
+from GaudiKernel.SystemOfUnits import MeV, GeV, ps
+from PyConf import configurable
+from Moore.config import register_line_builder
+from Moore.lines import Hlt2Line
+from RecoConf.reconstruction_objects import upfront_reconstruction
+from .builders.rdbuilder_thor import make_rd_detached_mue
+
+all_lines = {}
+
+
+@register_line_builder(all_lines)
+@configurable
+def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Line", prescale=1,
+                    persistreco=False):
+
+    descriptor = "[phi(1020) -> mu- e+]CC"
+    emu = make_rd_detached_mue(
+        name="Hlt2RD_PhiToMuE_Builder",
+        min_dilepton_mass=800. * MeV,
+        max_dilepton_mass=1570. * MeV)
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + [emu],
+        prescale=prescale,
+        persistreco=persistreco)
+
+
+@register_line_builder(all_lines)
+@configurable
+def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
+                       prescale=1,
+                       persistreco=False):
+
+    descriptor = "[phi(1020) -> mu+ e+]CC"
+    emu = make_rd_detached_mue(
+        name="Hlt2RD_PhiToMuE_SS_Builder",
+        min_dilepton_mass=800. * MeV,
+        max_dilepton_mass=1570. * MeV,
+        same_sign=True)
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + [emu],
+        prescale=prescale,
+        persistreco=persistreco)
+
+
+@register_line_builder(all_lines)
+@configurable
+def jpsi_to_mue_line(name="Hlt2RD_PhiToMuE_Line",
+                     prescale=1,
+                     persistreco=False):
+
+    descriptor = "[J/psi(1S) -> mu- e+]CC"
+    emu = make_rd_detached_mue(
+        name="Hlt2RD_JpsiToMuE_Builder",
+        min_dilepton_mass=2600. * MeV,
+        max_dilepton_mass=4200. * MeV,
+        min_pt_e=0.5 * GeV,
+        min_pt_mu=0.5 * GeV)
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + [emu],
+        prescale=prescale,
+        persistreco=persistreco)
+
+
+@register_line_builder(all_lines)
+@configurable
+def jpsi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
+                        prescale=1,
+                        persistreco=False):
+
+    descriptor = "[phi(J/psi(1S) -> mu+ e+]CC"
+    emu = make_rd_detached_mue(
+        name="Hlt2RD_JpsiToMuE_SS_Builder",
+        min_dilepton_mass=2600. * MeV,
+        max_dilepton_mass=4200. * MeV,
+        min_pt_e=0.5 * GeV,
+        min_pt_mu=0.5 * GeV,
+        same_sign=True)
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + [emu],
+        prescale=prescale,
+        persistreco=persistreco)
+
+
+@register_line_builder(all_lines)
+@configurable
+def upsilon_to_mue_line(name="Hlt2RD_UpsilonToMuE_Line",
+                        prescale=1,
+                        persistreco=False):
+
+    descriptor = "[Upsilon(1S) -> mu- e+]CC"
+    emu = make_rd_detached_mue(
+        name="Hlt2RD_UpsilonToMuE_Builder",
+        min_dilepton_mass=7000. * MeV,
+        max_dilepton_mass=13000. * MeV,
+        min_pt_e=0.5 * GeV,
+        min_pt_mu=1.0 * GeV)
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + [emu],
+        prescale=prescale,
+        persistreco=persistreco)
+
+
+@register_line_builder(all_lines)
+@configurable
+def upsilon_to_mue_ss_line(name="Hlt2RD_UpsilonToMuE_SS_Line",
+                           prescale=1,
+                           persistreco=False):
+
+    descriptor = "[Upsilon(1S) -> mu+ e+]CC"
+    emu = make_rd_detached_mue(
+        name="Hlt2RD_UpsilonToMuE_SS_Builder",
+        min_dilepton_mass=7000. * MeV,
+        max_dilepton_mass=13000. * MeV,
+        min_pt_e=0.5 * GeV,
+        min_pt_mu=1.0 * GeV,
+        same_sign=True)
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + [emu],
+        prescale=prescale,
+        persistreco=persistreco)
-- 
GitLab


From 24e6c9ed07d1fda292916b3dd870a94d3dad95b4 Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Mon, 27 Dec 2021 18:07:09 +0100
Subject: [PATCH 02/26] working version

---
 .../lines/rd/builders/rdbuilder_thor.py       |  3 +-
 .../python/Hlt2Conf/lines/rd/qqbar_to_emu.py  | 43 ++++++++++++-------
 2 files changed, 29 insertions(+), 17 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/rdbuilder_thor.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/rdbuilder_thor.py
index 68e34eb0ea9..8f53fa27b36 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/rdbuilder_thor.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/rdbuilder_thor.py
@@ -804,7 +804,8 @@ def make_rd_detached_dielectron(name="rd_detached_dielectron",
 
 
 @configurable
-def make_rd_detached_mue(min_dilepton_mass=100. * MeV,
+def make_rd_detached_mue(name="rd_detached_mue",
+                         min_dilepton_mass=0. * MeV,
                          max_dilepton_mass=6000. * MeV,
                          parent_id='J/psi(1S)',
                          min_probnn_mu=0.,
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
index e06dd44d6e9..859e5d8bad1 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
@@ -34,12 +34,15 @@ all_lines = {}
 @configurable
 def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Line", prescale=1,
                     persistreco=False):
-
-    descriptor = "[phi(1020) -> mu- e+]CC"
+    """
+    Definiton of [phi(1020) -> mu- e+]CC
+    """
     emu = make_rd_detached_mue(
         name="Hlt2RD_PhiToMuE_Builder",
         min_dilepton_mass=800. * MeV,
-        max_dilepton_mass=1570. * MeV)
+        max_dilepton_mass=1570. * MeV,
+        min_pt_e=0.25 * GeV,
+        min_pt_mu=0.25 * GeV)
     return Hlt2Line(
         name=name,
         algs=upfront_reconstruction() + [emu],
@@ -52,12 +55,16 @@ def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Line", prescale=1,
 def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
                        prescale=1,
                        persistreco=False):
-
+    """
+    Definiton of [phi(1020) -> mu+ e+]CC
+    """
     descriptor = "[phi(1020) -> mu+ e+]CC"
     emu = make_rd_detached_mue(
         name="Hlt2RD_PhiToMuE_SS_Builder",
         min_dilepton_mass=800. * MeV,
         max_dilepton_mass=1570. * MeV,
+        min_pt_e=0.25 * GeV,
+        min_pt_mu=0.25 * GeV,
         same_sign=True)
     return Hlt2Line(
         name=name,
@@ -68,11 +75,12 @@ def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
 
 @register_line_builder(all_lines)
 @configurable
-def jpsi_to_mue_line(name="Hlt2RD_PhiToMuE_Line",
+def jpsi_to_mue_line(name="Hlt2RD_JpsiToMuE_Line",
                      prescale=1,
                      persistreco=False):
-
-    descriptor = "[J/psi(1S) -> mu- e+]CC"
+    """
+    Definiton of [Jpsi(1S) -> mu- e+]CC
+    """
     emu = make_rd_detached_mue(
         name="Hlt2RD_JpsiToMuE_Builder",
         min_dilepton_mass=2600. * MeV,
@@ -88,11 +96,12 @@ def jpsi_to_mue_line(name="Hlt2RD_PhiToMuE_Line",
 
 @register_line_builder(all_lines)
 @configurable
-def jpsi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
+def jpsi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Line",
                         prescale=1,
                         persistreco=False):
-
-    descriptor = "[phi(J/psi(1S) -> mu+ e+]CC"
+    """
+    Definiton of [Jpsi(1S) -> mu+ e+]CC
+    """
     emu = make_rd_detached_mue(
         name="Hlt2RD_JpsiToMuE_SS_Builder",
         min_dilepton_mass=2600. * MeV,
@@ -112,14 +121,15 @@ def jpsi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
 def upsilon_to_mue_line(name="Hlt2RD_UpsilonToMuE_Line",
                         prescale=1,
                         persistreco=False):
-
-    descriptor = "[Upsilon(1S) -> mu- e+]CC"
+    """
+    Definiton of [Upsilon -> mu- e+]CC
+    """
     emu = make_rd_detached_mue(
         name="Hlt2RD_UpsilonToMuE_Builder",
         min_dilepton_mass=7000. * MeV,
         max_dilepton_mass=13000. * MeV,
         min_pt_e=0.5 * GeV,
-        min_pt_mu=1.0 * GeV)
+        min_pt_mu=0.5 * GeV)
     return Hlt2Line(
         name=name,
         algs=upfront_reconstruction() + [emu],
@@ -132,14 +142,15 @@ def upsilon_to_mue_line(name="Hlt2RD_UpsilonToMuE_Line",
 def upsilon_to_mue_ss_line(name="Hlt2RD_UpsilonToMuE_SS_Line",
                            prescale=1,
                            persistreco=False):
-
-    descriptor = "[Upsilon(1S) -> mu+ e+]CC"
+    """
+    Definiton of [Upsilon -> mu+ e+]CC
+    """
     emu = make_rd_detached_mue(
         name="Hlt2RD_UpsilonToMuE_SS_Builder",
         min_dilepton_mass=7000. * MeV,
         max_dilepton_mass=13000. * MeV,
         min_pt_e=0.5 * GeV,
-        min_pt_mu=1.0 * GeV,
+        min_pt_mu=0.5 * GeV,
         same_sign=True)
     return Hlt2Line(
         name=name,
-- 
GitLab


From fe6c43f25073fb9db0b0b314ce1501c289754f5a Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Mon, 27 Dec 2021 18:09:35 +0100
Subject: [PATCH 03/26] formatting

---
 Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
index 859e5d8bad1..a567e1b10c1 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
@@ -19,8 +19,7 @@ date: 27.12.2021
 
 """
 
-import Functors as F
-from GaudiKernel.SystemOfUnits import MeV, GeV, ps
+from GaudiKernel.SystemOfUnits import MeV, GeV
 from PyConf import configurable
 from Moore.config import register_line_builder
 from Moore.lines import Hlt2Line
@@ -58,7 +57,6 @@ def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
     """
     Definiton of [phi(1020) -> mu+ e+]CC
     """
-    descriptor = "[phi(1020) -> mu+ e+]CC"
     emu = make_rd_detached_mue(
         name="Hlt2RD_PhiToMuE_SS_Builder",
         min_dilepton_mass=800. * MeV,
-- 
GitLab


From 3bb13ed567512263f5052ecc5e1f996bf90b2973 Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Tue, 28 Dec 2021 10:55:57 +0100
Subject: [PATCH 04/26] adding parent_id

---
 .../python/Hlt2Conf/lines/rd/qqbar_to_emu.py       | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
index a567e1b10c1..ba77fe81db8 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
@@ -38,6 +38,7 @@ def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Line", prescale=1,
     """
     emu = make_rd_detached_mue(
         name="Hlt2RD_PhiToMuE_Builder",
+        parent_id='phi(1020)',
         min_dilepton_mass=800. * MeV,
         max_dilepton_mass=1570. * MeV,
         min_pt_e=0.25 * GeV,
@@ -59,6 +60,7 @@ def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
     """
     emu = make_rd_detached_mue(
         name="Hlt2RD_PhiToMuE_SS_Builder",
+        parent_id='phi(1020)',
         min_dilepton_mass=800. * MeV,
         max_dilepton_mass=1570. * MeV,
         min_pt_e=0.25 * GeV,
@@ -77,10 +79,11 @@ def jpsi_to_mue_line(name="Hlt2RD_JpsiToMuE_Line",
                      prescale=1,
                      persistreco=False):
     """
-    Definiton of [Jpsi(1S) -> mu- e+]CC
+    Definiton of [J/psi(1S) -> mu- e+]CC
     """
     emu = make_rd_detached_mue(
         name="Hlt2RD_JpsiToMuE_Builder",
+        parent_id='J/psi(1S)',
         min_dilepton_mass=2600. * MeV,
         max_dilepton_mass=4200. * MeV,
         min_pt_e=0.5 * GeV,
@@ -98,10 +101,11 @@ def jpsi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Line",
                         prescale=1,
                         persistreco=False):
     """
-    Definiton of [Jpsi(1S) -> mu+ e+]CC
+    Definiton of [J/psi(1S) -> mu+ e+]CC
     """
     emu = make_rd_detached_mue(
         name="Hlt2RD_JpsiToMuE_SS_Builder",
+        parent_id='J/psi(1S)',
         min_dilepton_mass=2600. * MeV,
         max_dilepton_mass=4200. * MeV,
         min_pt_e=0.5 * GeV,
@@ -120,10 +124,11 @@ def upsilon_to_mue_line(name="Hlt2RD_UpsilonToMuE_Line",
                         prescale=1,
                         persistreco=False):
     """
-    Definiton of [Upsilon -> mu- e+]CC
+    Definiton of [Upsilon(1S) -> mu- e+]CC
     """
     emu = make_rd_detached_mue(
         name="Hlt2RD_UpsilonToMuE_Builder",
+        parent_id='Upsilon(1S)',
         min_dilepton_mass=7000. * MeV,
         max_dilepton_mass=13000. * MeV,
         min_pt_e=0.5 * GeV,
@@ -141,10 +146,11 @@ def upsilon_to_mue_ss_line(name="Hlt2RD_UpsilonToMuE_SS_Line",
                            prescale=1,
                            persistreco=False):
     """
-    Definiton of [Upsilon -> mu+ e+]CC
+    Definiton of [Upsilon(1S) -> mu+ e+]CC
     """
     emu = make_rd_detached_mue(
         name="Hlt2RD_UpsilonToMuE_SS_Builder",
+        parent_id='Upsilon(1S)',
         min_dilepton_mass=7000. * MeV,
         max_dilepton_mass=13000. * MeV,
         min_pt_e=0.5 * GeV,
-- 
GitLab


From c3d30ef29bb8e6fc0319dc59fcaf24ce05ab86a5 Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Tue, 28 Dec 2021 11:02:57 +0100
Subject: [PATCH 05/26] __init__ update

---
 Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py
index 9d62208085f..3160a1b53ff 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py
@@ -26,3 +26,4 @@ all_lines.update(b_to_hhhgamma.all_lines)
 all_lines.update(b_to_hhhgamma_gamma_to_ee.all_lines)
 all_lines.update(B2ll_lines.all_lines)
 all_lines.update(strange_lines)
+all_lines.update(qqbar_to_emu)
\ No newline at end of file
-- 
GitLab


From fb74c0ed9c9692d19596b9b2f3374dfa1cb596a3 Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Tue, 28 Dec 2021 11:48:16 +0100
Subject: [PATCH 06/26] fix

---
 Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py
index 3160a1b53ff..ca7743d87ce 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py
@@ -15,7 +15,7 @@ from . import b_to_hhgamma
 from . import b_to_hhgamma_gamma_to_ee
 from . import b_to_hhhgamma
 from . import b_to_hhhgamma_gamma_to_ee
-from . import B2ll_lines
+from . import qqbar_to_emu
 from .strange import all_lines as strange_lines
 
 # provide "all_lines" for correct registration by the overall HLT2 lines module
@@ -24,6 +24,5 @@ all_lines.update(b_to_hhgamma.all_lines)
 all_lines.update(b_to_hhgamma_gamma_to_ee.all_lines)
 all_lines.update(b_to_hhhgamma.all_lines)
 all_lines.update(b_to_hhhgamma_gamma_to_ee.all_lines)
-all_lines.update(B2ll_lines.all_lines)
-all_lines.update(strange_lines)
-all_lines.update(qqbar_to_emu)
\ No newline at end of file
+all_lines.update(qqbar_to_emu.all_lines)
+all_lines.update(strange_lines)
\ No newline at end of file
-- 
GitLab


From d5ba291374dee5d9d32d64f63f8e13711e2776fc Mon Sep 17 00:00:00 2001
From: Gitlab CI <noreply@cern.ch>
Date: Tue, 28 Dec 2021 10:48:57 +0000
Subject: [PATCH 07/26] Fixed formatting

patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/18533986
---
 Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py
index ca7743d87ce..242c0d9d4d2 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py
@@ -25,4 +25,4 @@ all_lines.update(b_to_hhgamma_gamma_to_ee.all_lines)
 all_lines.update(b_to_hhhgamma.all_lines)
 all_lines.update(b_to_hhhgamma_gamma_to_ee.all_lines)
 all_lines.update(qqbar_to_emu.all_lines)
-all_lines.update(strange_lines)
\ No newline at end of file
+all_lines.update(strange_lines)
-- 
GitLab


From 6c5f65d63bb1a943fc580a9733107ce82736947f Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Sat, 8 Jan 2022 16:00:26 +0100
Subject: [PATCH 08/26] additional cuts

---
 .../python/Hlt2Conf/lines/rd/qqbar_to_emu.py  | 45 ++++++++++++++++---
 1 file changed, 38 insertions(+), 7 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
index ba77fe81db8..604ce52c426 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
@@ -40,9 +40,14 @@ def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Line", prescale=1,
         name="Hlt2RD_PhiToMuE_Builder",
         parent_id='phi(1020)',
         min_dilepton_mass=800. * MeV,
-        max_dilepton_mass=1570. * MeV,
+        max_dilepton_mass=1220. * MeV,
+        min_probnn_mu=0.2,
+        min_PIDe=3.,
         min_pt_e=0.25 * GeV,
-        min_pt_mu=0.25 * GeV)
+        min_pt_mu=0.25 * GeV,
+        min_bpvvdchi2=30.,
+        max_vchi2ndof=5.,
+    )
     return Hlt2Line(
         name=name,
         algs=upfront_reconstruction() + [emu],
@@ -62,9 +67,13 @@ def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
         name="Hlt2RD_PhiToMuE_SS_Builder",
         parent_id='phi(1020)',
         min_dilepton_mass=800. * MeV,
-        max_dilepton_mass=1570. * MeV,
+        max_dilepton_mass=1220. * MeV,
+        min_probnn_mu=0.2,
+        min_PIDe=3.,
         min_pt_e=0.25 * GeV,
         min_pt_mu=0.25 * GeV,
+        min_bpvvdchi2=30.,
+        max_vchi2ndof=5.,
         same_sign=True)
     return Hlt2Line(
         name=name,
@@ -85,9 +94,14 @@ def jpsi_to_mue_line(name="Hlt2RD_JpsiToMuE_Line",
         name="Hlt2RD_JpsiToMuE_Builder",
         parent_id='J/psi(1S)',
         min_dilepton_mass=2600. * MeV,
-        max_dilepton_mass=4200. * MeV,
+        max_dilepton_mass=3700. * MeV,
+        min_probnn_mu=0.2,
+        min_PIDe=2.,
         min_pt_e=0.5 * GeV,
-        min_pt_mu=0.5 * GeV)
+        min_pt_mu=0.5 * GeV,
+        min_bpvvdchi2=30.,
+        max_vchi2ndof=5.,
+    )
     return Hlt2Line(
         name=name,
         algs=upfront_reconstruction() + [emu],
@@ -107,9 +121,13 @@ def jpsi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Line",
         name="Hlt2RD_JpsiToMuE_SS_Builder",
         parent_id='J/psi(1S)',
         min_dilepton_mass=2600. * MeV,
-        max_dilepton_mass=4200. * MeV,
+        max_dilepton_mass=3700. * MeV,
+        min_probnn_mu=0.2,
+        min_PIDe=2.,
         min_pt_e=0.5 * GeV,
         min_pt_mu=0.5 * GeV,
+        min_bpvvdchi2=30.,
+        max_vchi2ndof=5.,
         same_sign=True)
     return Hlt2Line(
         name=name,
@@ -131,8 +149,13 @@ def upsilon_to_mue_line(name="Hlt2RD_UpsilonToMuE_Line",
         parent_id='Upsilon(1S)',
         min_dilepton_mass=7000. * MeV,
         max_dilepton_mass=13000. * MeV,
+        min_probnn_mu=0.2,
+        min_PIDe=2.,
         min_pt_e=0.5 * GeV,
-        min_pt_mu=0.5 * GeV)
+        min_pt_mu=0.5 * GeV,
+        min_bpvvdchi2=30.,
+        max_vchi2ndof=5.,
+    )
     return Hlt2Line(
         name=name,
         algs=upfront_reconstruction() + [emu],
@@ -153,11 +176,19 @@ def upsilon_to_mue_ss_line(name="Hlt2RD_UpsilonToMuE_SS_Line",
         parent_id='Upsilon(1S)',
         min_dilepton_mass=7000. * MeV,
         max_dilepton_mass=13000. * MeV,
+        min_probnn_mu=0.2,
+        min_PIDe=2.,
         min_pt_e=0.5 * GeV,
         min_pt_mu=0.5 * GeV,
+        min_bpvvdchi2=30.,
+        max_vchi2ndof=5.,
         same_sign=True)
     return Hlt2Line(
         name=name,
         algs=upfront_reconstruction() + [emu],
         prescale=prescale,
         persistreco=persistreco)
+
+#################
+## END OF FILE ##
+#################
\ No newline at end of file
-- 
GitLab


From be37671b7a7eb875f120afb71b616ac38862c369 Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Fri, 14 Jan 2022 15:05:29 +0100
Subject: [PATCH 09/26] extending list of cuts

---
 .../python/Hlt2Conf/lines/rd/qqbar_to_emu.py  | 62 +++++++++++++------
 1 file changed, 42 insertions(+), 20 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
index 604ce52c426..54dc3b86125 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
@@ -10,8 +10,10 @@
 ###############################################################################
 """
 Definiton of LFV lines of qqbar -> emu
-- Phi(1020) -> E Mu + SS
-- J/Psi(1S) -> E Mu + SS
+- Phi(1020) -> E Mu + SS prompt
+- Phi(1020) -> E Mu + SS detached
+- J/Psi(1S) -> E Mu + SS prompt
+- J/Psi(1S) -> E Mu + SS detached
 - Upsilon(1S) -> E Mu + SS
 
 author: Miroslav Saur
@@ -31,7 +33,7 @@ all_lines = {}
 
 @register_line_builder(all_lines)
 @configurable
-def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Line", prescale=1,
+def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Detached_Line", prescale=1,
                     persistreco=False):
     """
     Definiton of [phi(1020) -> mu- e+]CC
@@ -40,13 +42,13 @@ def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Line", prescale=1,
         name="Hlt2RD_PhiToMuE_Builder",
         parent_id='phi(1020)',
         min_dilepton_mass=800. * MeV,
-        max_dilepton_mass=1220. * MeV,
-        min_probnn_mu=0.2,
+        max_dilepton_mass=1570. * MeV,
+        min_probnn_mu=0.,
         min_PIDe=3.,
         min_pt_e=0.25 * GeV,
         min_pt_mu=0.25 * GeV,
         min_bpvvdchi2=30.,
-        max_vchi2ndof=5.,
+        max_vchi2ndof=8.,
     )
     return Hlt2Line(
         name=name,
@@ -57,7 +59,7 @@ def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Line", prescale=1,
 
 @register_line_builder(all_lines)
 @configurable
-def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
+def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Detached_Line",
                        prescale=1,
                        persistreco=False):
     """
@@ -67,13 +69,13 @@ def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
         name="Hlt2RD_PhiToMuE_SS_Builder",
         parent_id='phi(1020)',
         min_dilepton_mass=800. * MeV,
-        max_dilepton_mass=1220. * MeV,
-        min_probnn_mu=0.2,
+        max_dilepton_mass=1570. * MeV,
+        min_probnn_mu=0.,
         min_PIDe=3.,
         min_pt_e=0.25 * GeV,
         min_pt_mu=0.25 * GeV,
         min_bpvvdchi2=30.,
-        max_vchi2ndof=5.,
+        max_vchi2ndof=8.,
         same_sign=True)
     return Hlt2Line(
         name=name,
@@ -84,7 +86,7 @@ def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
 
 @register_line_builder(all_lines)
 @configurable
-def jpsi_to_mue_line(name="Hlt2RD_JpsiToMuE_Line",
+def jpsi_to_mue_line(name="Hlt2RD_JpsiToMuE_Detached_Line",
                      prescale=1,
                      persistreco=False):
     """
@@ -95,12 +97,12 @@ def jpsi_to_mue_line(name="Hlt2RD_JpsiToMuE_Line",
         parent_id='J/psi(1S)',
         min_dilepton_mass=2600. * MeV,
         max_dilepton_mass=3700. * MeV,
-        min_probnn_mu=0.2,
+        min_probnn_mu=0.,
         min_PIDe=2.,
         min_pt_e=0.5 * GeV,
         min_pt_mu=0.5 * GeV,
         min_bpvvdchi2=30.,
-        max_vchi2ndof=5.,
+        max_vchi2ndof=8.,
     )
     return Hlt2Line(
         name=name,
@@ -111,7 +113,7 @@ def jpsi_to_mue_line(name="Hlt2RD_JpsiToMuE_Line",
 
 @register_line_builder(all_lines)
 @configurable
-def jpsi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Line",
+def jpsi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Detached_Line",
                         prescale=1,
                         persistreco=False):
     """
@@ -122,12 +124,12 @@ def jpsi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Line",
         parent_id='J/psi(1S)',
         min_dilepton_mass=2600. * MeV,
         max_dilepton_mass=3700. * MeV,
-        min_probnn_mu=0.2,
+        min_probnn_mu=0.,
         min_PIDe=2.,
         min_pt_e=0.5 * GeV,
         min_pt_mu=0.5 * GeV,
         min_bpvvdchi2=30.,
-        max_vchi2ndof=5.,
+        max_vchi2ndof=8.,
         same_sign=True)
     return Hlt2Line(
         name=name,
@@ -135,6 +137,26 @@ def jpsi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Line",
         prescale=prescale,
         persistreco=persistreco)
 
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
 
 @register_line_builder(all_lines)
 @configurable
@@ -149,12 +171,12 @@ def upsilon_to_mue_line(name="Hlt2RD_UpsilonToMuE_Line",
         parent_id='Upsilon(1S)',
         min_dilepton_mass=7000. * MeV,
         max_dilepton_mass=13000. * MeV,
-        min_probnn_mu=0.2,
+        min_probnn_mu=0.,
         min_PIDe=2.,
         min_pt_e=0.5 * GeV,
         min_pt_mu=0.5 * GeV,
         min_bpvvdchi2=30.,
-        max_vchi2ndof=5.,
+        max_vchi2ndof=8.,
     )
     return Hlt2Line(
         name=name,
@@ -176,12 +198,12 @@ def upsilon_to_mue_ss_line(name="Hlt2RD_UpsilonToMuE_SS_Line",
         parent_id='Upsilon(1S)',
         min_dilepton_mass=7000. * MeV,
         max_dilepton_mass=13000. * MeV,
-        min_probnn_mu=0.2,
+        min_probnn_mu=0.,
         min_PIDe=2.,
         min_pt_e=0.5 * GeV,
         min_pt_mu=0.5 * GeV,
         min_bpvvdchi2=30.,
-        max_vchi2ndof=5.,
+        max_vchi2ndof=8.,
         same_sign=True)
     return Hlt2Line(
         name=name,
-- 
GitLab


From cee56abe949c88753e2b452b789caebaacc86fd8 Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Sat, 15 Jan 2022 14:01:02 +0100
Subject: [PATCH 10/26] fixing messed up rebase

---
 Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py               | 2 ++
 .../python/Hlt2Conf/lines/rd/builders/rdbuilder_thor.py         | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py
index 242c0d9d4d2..0b082eb9211 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py
@@ -15,6 +15,7 @@ from . import b_to_hhgamma
 from . import b_to_hhgamma_gamma_to_ee
 from . import b_to_hhhgamma
 from . import b_to_hhhgamma_gamma_to_ee
+from . import B2ll_lines
 from . import qqbar_to_emu
 from .strange import all_lines as strange_lines
 
@@ -25,4 +26,5 @@ all_lines.update(b_to_hhgamma_gamma_to_ee.all_lines)
 all_lines.update(b_to_hhhgamma.all_lines)
 all_lines.update(b_to_hhhgamma_gamma_to_ee.all_lines)
 all_lines.update(qqbar_to_emu.all_lines)
+all_lines.update(B2ll_lines.all_lines)
 all_lines.update(strange_lines)
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/rdbuilder_thor.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/rdbuilder_thor.py
index 8f53fa27b36..23ffc3ee8af 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/rdbuilder_thor.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/rdbuilder_thor.py
@@ -832,7 +832,7 @@ def make_rd_detached_mue(name="rd_detached_mue",
         min_bpvvdchi2=min_bpvvdchi2,
         max_vchi2ndof=max_vchi2ndof)
     code = require_all(in_range(min_dilepton_mass, F.MASS, max_dilepton_mass))
-    return ParticleFilter(dileptons, F.FILTER(code))
+    return ParticleFilter(dileptons, F.FILTER(code), name=name)
 
 
 ####################################
-- 
GitLab


From 5ea7f4189fa93771cadd5ac03034c5504310af1a Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Sat, 15 Jan 2022 17:23:22 +0100
Subject: [PATCH 11/26] builders for prompt lines

---
 .../lines/rd/builders/qqbar_builder.py        | 150 ++++++++++++++++++
 .../python/Hlt2Conf/lines/rd/qqbar_to_emu.py  |  26 +--
 2 files changed, 154 insertions(+), 22 deletions(-)
 create mode 100644 Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
new file mode 100644
index 00000000000..1c72779f9a2
--- /dev/null
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
@@ -0,0 +1,150 @@
+##############################################################################
+# (c) Copyright 2022 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.                                       #
+###############################################################################
+"""
+Definiton of dedicated prompt builders for LFV lines of qqbar -> emu (detached lines are using standard make_rd_detached_mue)
+- Phi(1020) -> E Mu + SS prompt
+- J/Psi(1S) -> E Mu + SS prompt
+- Upsilon(1S) -> E Mu + SS
+
+author: Miroslav Saur
+date: 27.12.2021
+
+"""
+
+import Functors as F
+from Functors.math import in_range
+
+from GaudiKernel.SystemOfUnits import MeV, GeV, mm
+
+from RecoConf.reconstruction_objects import make_pvs_v2 as make_pvs
+
+from Hlt2Conf.algorithms_thor import require_all, ParticleFilter, ParticleCombiner
+from PyConf import configurable
+
+from Hlt2Conf.standard_particles import make_long_electrons_with_brem, make_ismuon_long_muon
+
+
+@configurable
+def make_prompt_long_electrons(make_particles=make_long_electrons_with_brem,
+                               name="prompt_long_electrons",
+                               min_pt_e=0. * MeV,
+                               min_p_e=0. * GeV,
+                               min_ipchi2_electron=0,
+                               min_ip_electron=0,
+                               min_pid_electron=-5,
+                               max_ghostprob_electron=0.7,
+                               max_trackchi2_electron=None,
+                               max_ipchi2_electron=None):
+
+    pvs = make_pvs()
+
+    code = require_all(F.PT > min_pt_e, F.P > min_p_e,
+                       F.MINIPCHI2(pvs) > min_ipchi2_electron,
+                       F.MINIP(pvs) > min_ip_electron,
+                       F.PID_MU > min_pid_electron,
+                       F.GHOSTPROB < max_ghostprob_electron)
+
+    if max_trackchi2_electron is not None:
+        code &= (F.CHI2 < max_trackchi2_electron)
+    if max_ipchi2_electron is not None:
+        code &= (F.MINIPCHI2(pvs) < max_ipchi2_electron)
+
+    return ParticleFilter(make_particles(), name=name, Cut=F.FILTER(code))
+
+
+@configurable
+def make_prompt_long_muons(make_particles=make_ismuon_long_muon,
+                           name="prompt_long_muons",
+                           min_pt_mu=0. * MeV,
+                           min_p_mu=0. * GeV,
+                           min_ipchi2_muon=0,
+                           min_ip_muon=0,
+                           min_pid_muon=-5,
+                           max_ghostprob_muon=0.7,
+                           max_trackchi2_muon=None,
+                           max_ipchi2_muon=None):
+
+    pvs = make_pvs()
+
+    code = require_all(F.PT > min_pt_mu, F.ISMUON, F.P > min_p_mu,
+                       F.MINIPCHI2(pvs) > min_ipchi2_muon,
+                       F.MINIP(pvs) > min_ip_muon, F.PID_MU > min_pid_muon,
+                       F.GHOSTPROB < max_ghostprob_muon)
+
+    if max_trackchi2_muon is not None:
+        code &= (F.CHI2 < max_trackchi2_muon)
+    if max_ipchi2_muon is not None:
+        code &= (F.MINIPCHI2(pvs) < max_ipchi2_muon)
+
+    return ParticleFilter(make_particles(), name=name, Cut=F.FILTER(code))
+
+
+# the new dimuon base for bandq lines
+@configurable
+def make_prompt_mue(
+        name='prompt_mue_builder',
+        same_sign=False,
+        dilepton_ID='J/psi(1S)',
+        max_vertexchi2_mue=25,
+        min_pt_mu=0. * MeV,
+        min_p_mu=0. * GeV,
+        min_ipchi2_muon=0,
+        min_ip_muon=0,
+        max_ghostprob_muon=0.7,
+        min_pid_muon=-5,
+        min_pt_e=0. * MeV,
+        min_p_e=0. * GeV,
+        min_ipchi2_electron=0,
+        min_ip_electron=0,
+        max_ghostprob_electron=0.7,
+        min_pid_electron=-5,
+        min_dilepton_mass=0. * MeV,
+        max_dilepton_mass=100000. * MeV,
+        max_trackchi2_muon=None,
+):
+
+    DecayDescriptor = [f"[{dilepton_ID} -> mu+ e-]cc"]
+    if same_sign: DecayDescriptor = [f"[{dilepton_ID} -> mu+ e+]cc"]
+
+    muons = make_prompt_long_muons(
+        min_pt_mu=min_pt_mu,
+        min_p_mu=min_p_mu,
+        min_ipchi2_muon=min_ipchi2_muon,
+        min_ip_muon=min_ip_muon,
+        max_ghostprob_muon=max_ghostprob_muon,
+        max_trackchi2_muon=max_trackchi2_muon,
+        min_pid_muon=min_pid_muon)
+
+    electrons = make_prompt_long_electrons(
+        min_pt_e=min_pt_e,
+        min_p_e=min_p_e,
+        min_ipchi2_electron=min_ipchi2_electron,
+        min_ip_electron=min_ip_electron,
+        max_ghostprob_electron=max_ghostprob_electron,
+        max_trackchi2_electron=max_trackchi2_electron,
+        min_pid_electron=min_pid_electron)
+
+    combination_code = in_range(minMass_dimuon, F.MASS, maxMass_dimuon)
+
+    # require that the muons come from the same vertex
+    vertex_code = (F.CHI2DOF < max_vertexchi2_mue)
+
+    return ParticleCombiner(
+        name=name,
+        Inputs=[muons, electrons],
+        DecayDescriptor=DecayDescriptor,
+        CombinationCut=combination_code,
+        CompositeCut=vertex_code)
+
+
+#################
+## END OF FILE ##
+#################
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
index 54dc3b86125..e709bc6d108 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
@@ -33,7 +33,8 @@ all_lines = {}
 
 @register_line_builder(all_lines)
 @configurable
-def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Detached_Line", prescale=1,
+def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Detached_Line",
+                    prescale=1,
                     persistreco=False):
     """
     Definiton of [phi(1020) -> mu- e+]CC
@@ -137,26 +138,6 @@ def jpsi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Detached_Line",
         prescale=prescale,
         persistreco=persistreco)
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 
 @register_line_builder(all_lines)
 @configurable
@@ -211,6 +192,7 @@ def upsilon_to_mue_ss_line(name="Hlt2RD_UpsilonToMuE_SS_Line",
         prescale=prescale,
         persistreco=persistreco)
 
+
 #################
 ## END OF FILE ##
-#################
\ No newline at end of file
+#################
-- 
GitLab


From 6876160ff63611b024b2fb0272ae152e198534ba Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Sat, 15 Jan 2022 18:12:19 +0100
Subject: [PATCH 12/26] added new prompt lines, to be tuned

---
 .../lines/rd/builders/qqbar_builder.py        |  55 +++--
 .../python/Hlt2Conf/lines/rd/qqbar_to_emu.py  | 230 +++++++++++++-----
 2 files changed, 195 insertions(+), 90 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
index 1c72779f9a2..ecebf2e0855 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
@@ -22,7 +22,7 @@ date: 27.12.2021
 import Functors as F
 from Functors.math import in_range
 
-from GaudiKernel.SystemOfUnits import MeV, GeV, mm
+from GaudiKernel.SystemOfUnits import MeV, GeV
 
 from RecoConf.reconstruction_objects import make_pvs_v2 as make_pvs
 
@@ -89,30 +89,30 @@ def make_prompt_long_muons(make_particles=make_ismuon_long_muon,
 
 # the new dimuon base for bandq lines
 @configurable
-def make_prompt_mue(
-        name='prompt_mue_builder',
-        same_sign=False,
-        dilepton_ID='J/psi(1S)',
-        max_vertexchi2_mue=25,
-        min_pt_mu=0. * MeV,
-        min_p_mu=0. * GeV,
-        min_ipchi2_muon=0,
-        min_ip_muon=0,
-        max_ghostprob_muon=0.7,
-        min_pid_muon=-5,
-        min_pt_e=0. * MeV,
-        min_p_e=0. * GeV,
-        min_ipchi2_electron=0,
-        min_ip_electron=0,
-        max_ghostprob_electron=0.7,
-        min_pid_electron=-5,
-        min_dilepton_mass=0. * MeV,
-        max_dilepton_mass=100000. * MeV,
-        max_trackchi2_muon=None,
-):
-
-    DecayDescriptor = [f"[{dilepton_ID} -> mu+ e-]cc"]
-    if same_sign: DecayDescriptor = [f"[{dilepton_ID} -> mu+ e+]cc"]
+def make_prompt_mue(name='prompt_mue_builder',
+                    same_sign=False,
+                    parent_id='J/psi(1S)',
+                    min_dilepton_mass=0. * MeV,
+                    max_dilepton_mass=100000. * MeV,
+                    max_vertexchi2_mue=25,
+                    max_vchi2ndof=10,
+                    min_pt_mu=0.25 * GeV,
+                    min_p_mu=2. * GeV,
+                    min_ipchi2_muon=0,
+                    min_ip_muon=0,
+                    max_ghostprob_muon=0.5,
+                    min_pid_muon=-0,
+                    min_pt_e=0.25 * GeV,
+                    min_p_e=1. * GeV,
+                    min_ipchi2_electron=0,
+                    min_ip_electron=0,
+                    max_ghostprob_electron=0.5,
+                    min_pid_electron=3,
+                    max_trackchi2_muon=None,
+                    max_trackchi2_electron=None):
+
+    DecayDescriptor = [f"[{parent_id} -> mu+ e-]cc"]
+    if same_sign: DecayDescriptor = [f"[{parent_id} -> mu+ e+]cc"]
 
     muons = make_prompt_long_muons(
         min_pt_mu=min_pt_mu,
@@ -132,10 +132,11 @@ def make_prompt_mue(
         max_trackchi2_electron=max_trackchi2_electron,
         min_pid_electron=min_pid_electron)
 
-    combination_code = in_range(minMass_dimuon, F.MASS, maxMass_dimuon)
+    combination_code = in_range(min_dilepton_mass, F.MASS, max_dilepton_mass)
 
     # require that the muons come from the same vertex
-    vertex_code = (F.CHI2DOF < max_vertexchi2_mue)
+    vertex_code = require_all((F.CHI2DOF < max_vertexchi2_mue),
+                              F.CHI2 / F.NDOF < max_vchi2ndof)
 
     return ParticleCombiner(
         name=name,
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
index e709bc6d108..4b218cc5773 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
@@ -27,81 +27,185 @@ from Moore.config import register_line_builder
 from Moore.lines import Hlt2Line
 from RecoConf.reconstruction_objects import upfront_reconstruction
 from .builders.rdbuilder_thor import make_rd_detached_mue
+from .builders.qqbar_builders import make_prompt_mue
 
 all_lines = {}
 
 
+def prefilters():
+    return [require_gec(), require_pvs(make_pvs())]
+
+
+###### PROMPT LINES #####
+
+
 @register_line_builder(all_lines)
 @configurable
-def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Detached_Line",
-                    prescale=1,
+def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Line", prescale=1,
                     persistreco=False):
-    """
-    Definiton of [phi(1020) -> mu- e+]CC
-    """
-    emu = make_rd_detached_mue(
+
+    emu = make_prompt_mue(
         name="Hlt2RD_PhiToMuE_Builder",
         parent_id='phi(1020)',
         min_dilepton_mass=800. * MeV,
         max_dilepton_mass=1570. * MeV,
-        min_probnn_mu=0.,
-        min_PIDe=3.,
-        min_pt_e=0.25 * GeV,
-        min_pt_mu=0.25 * GeV,
-        min_bpvvdchi2=30.,
-        max_vchi2ndof=8.,
-    )
+        max_vertexchi2_mue=25,
+        min_pt_mu=0.25 * MeV,
+        min_pid_muon=-5,
+        min_pt_e=0.25 * MeV,
+        min_pid_electron=-5,
+        max_vchi2ndof=5)
     return Hlt2Line(
         name=name,
-        algs=upfront_reconstruction() + [emu],
+        algs=upfront_reconstruction() + prefilters() + [emu],
         prescale=prescale,
         persistreco=persistreco)
 
 
 @register_line_builder(all_lines)
 @configurable
-def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Detached_Line",
+def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
                        prescale=1,
                        persistreco=False):
-    """
-    Definiton of [phi(1020) -> mu+ e+]CC
-    """
-    emu = make_rd_detached_mue(
+
+    emu = make_prompt_mue(
         name="Hlt2RD_PhiToMuE_SS_Builder",
         parent_id='phi(1020)',
         min_dilepton_mass=800. * MeV,
         max_dilepton_mass=1570. * MeV,
-        min_probnn_mu=0.,
-        min_PIDe=3.,
-        min_pt_e=0.25 * GeV,
-        min_pt_mu=0.25 * GeV,
-        min_bpvvdchi2=30.,
-        max_vchi2ndof=8.,
+        max_vertexchi2_mue=25,
+        min_pt_mu=0.25 * MeV,
+        min_pid_muon=-5,
+        min_pt_e=0.25 * MeV,
+        min_pid_electron=-5,
+        max_vchi2ndof=5,
         same_sign=True)
     return Hlt2Line(
         name=name,
-        algs=upfront_reconstruction() + [emu],
+        algs=upfront_reconstruction() + prefilters() + [emu],
         prescale=prescale,
         persistreco=persistreco)
 
 
 @register_line_builder(all_lines)
 @configurable
-def jpsi_to_mue_line(name="Hlt2RD_JpsiToMuE_Detached_Line",
-                     prescale=1,
-                     persistreco=False):
-    """
-    Definiton of [J/psi(1S) -> mu- e+]CC
-    """
-    emu = make_rd_detached_mue(
+def phi_to_mue_line(name="Hlt2RD_JpsiToMuE_Line",
+                    prescale=1,
+                    persistreco=False):
+
+    emu = make_prompt_mue(
         name="Hlt2RD_JpsiToMuE_Builder",
         parent_id='J/psi(1S)',
         min_dilepton_mass=2600. * MeV,
         max_dilepton_mass=3700. * MeV,
+        max_vertexchi2_mue=25,
+        min_pt_mu=0.75 * MeV,
+        min_pid_muon=-5,
+        min_pt_e=0.5 * MeV,
+        min_pid_electron=-5,
+        max_vchi2ndof=5)
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + prefilters() + [emu],
+        prescale=prescale,
+        persistreco=persistreco)
+
+
+@register_line_builder(all_lines)
+@configurable
+def phi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Line",
+                       prescale=1,
+                       persistreco=False):
+
+    emu = make_prompt_mue(
+        name="Hlt2RD_JpsiToMuE_SS_Builder",
+        parent_id='J/psi(1S)',
+        min_dilepton_mass=2600. * MeV,
+        max_dilepton_mass=3700. * MeV,
+        max_vertexchi2_mue=25,
+        min_pt_mu=0.75 * MeV,
+        min_pid_muon=-5,
+        min_pt_e=0.5 * MeV,
+        min_pid_electron=-5,
+        max_vchi2ndof=5,
+        same_sign=True)
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + prefilters() + [emu],
+        prescale=prescale,
+        persistreco=persistreco)
+
+
+@register_line_builder(all_lines)
+@configurable
+def phi_to_mue_line(name="Hlt2RD_UpsilonToMuE_Line",
+                    prescale=1,
+                    persistreco=False):
+
+    emu = make_prompt_mue(
+        name="Hlt2RD_UpsilonToMuE_Builder",
+        parent_id='Upsilon(1S)',
+        min_dilepton_mass=7000. * MeV,
+        max_dilepton_mass=13000. * MeV,
+        max_vertexchi2_mue=25,
+        min_pt_mu=2 * MeV,
+        min_pid_muon=-5,
+        min_pt_e=1.5 * MeV,
+        min_pid_electron=-5,
+        max_vchi2ndof=5,
+    )
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + prefilters() + [emu],
+        prescale=prescale,
+        persistreco=persistreco)
+
+
+@register_line_builder(all_lines)
+@configurable
+def phi_to_mue_ss_line(name="Hlt2RD_UpsilonToMuE_SS_Line",
+                       prescale=1,
+                       persistreco=False):
+
+    emu = make_prompt_mue(
+        name="Hlt2RD_UpsilonToMuE_SS_Builder",
+        parent_id='Upsilon(1S)',
+        min_dilepton_mass=7000. * MeV,
+        max_dilepton_mass=13000. * MeV,
+        max_vertexchi2_mue=25,
+        min_pt_mu=2 * MeV,
+        min_pid_muon=-5,
+        min_pt_e=1.5 * MeV,
+        min_pid_electron=-5,
+        max_vchi2ndof=5,
+        same_sign=True)
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + prefilters() + [emu],
+        prescale=prescale,
+        persistreco=persistreco)
+
+
+##### DETACHED LINES #####
+
+
+@register_line_builder(all_lines)
+@configurable
+def phi_to_mue_detached_line(name="Hlt2RD_PhiToMuE_Detached_Line",
+                             prescale=1,
+                             persistreco=False):
+    """
+    Definiton of [phi(1020) -> mu- e+]CC
+    """
+    emu = make_rd_detached_mue(
+        name="Hlt2RD_PhiToMuE_Builder",
+        parent_id='phi(1020)',
+        min_dilepton_mass=800. * MeV,
+        max_dilepton_mass=1570. * MeV,
         min_probnn_mu=0.,
-        min_PIDe=2.,
-        min_pt_e=0.5 * GeV,
-        min_pt_mu=0.5 * GeV,
+        min_PIDe=3.,
+        min_pt_e=0.25 * GeV,
+        min_pt_mu=0.25 * GeV,
         min_bpvvdchi2=30.,
         max_vchi2ndof=8.,
     )
@@ -114,21 +218,21 @@ def jpsi_to_mue_line(name="Hlt2RD_JpsiToMuE_Detached_Line",
 
 @register_line_builder(all_lines)
 @configurable
-def jpsi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Detached_Line",
-                        prescale=1,
-                        persistreco=False):
+def phi_to_mue_ss_detached_line(name="Hlt2RD_PhiToMuE_SS_Detached_Line",
+                                prescale=1,
+                                persistreco=False):
     """
-    Definiton of [J/psi(1S) -> mu+ e+]CC
+    Definiton of [phi(1020) -> mu+ e+]CC
     """
     emu = make_rd_detached_mue(
-        name="Hlt2RD_JpsiToMuE_SS_Builder",
-        parent_id='J/psi(1S)',
-        min_dilepton_mass=2600. * MeV,
-        max_dilepton_mass=3700. * MeV,
+        name="Hlt2RD_PhiToMuE_SS_Builder",
+        parent_id='phi(1020)',
+        min_dilepton_mass=800. * MeV,
+        max_dilepton_mass=1570. * MeV,
         min_probnn_mu=0.,
-        min_PIDe=2.,
-        min_pt_e=0.5 * GeV,
-        min_pt_mu=0.5 * GeV,
+        min_PIDe=3.,
+        min_pt_e=0.25 * GeV,
+        min_pt_mu=0.25 * GeV,
         min_bpvvdchi2=30.,
         max_vchi2ndof=8.,
         same_sign=True)
@@ -141,17 +245,17 @@ def jpsi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Detached_Line",
 
 @register_line_builder(all_lines)
 @configurable
-def upsilon_to_mue_line(name="Hlt2RD_UpsilonToMuE_Line",
-                        prescale=1,
-                        persistreco=False):
+def jpsi_to_mue_detached_line(name="Hlt2RD_JpsiToMuE_Detached_Line",
+                              prescale=1,
+                              persistreco=False):
     """
-    Definiton of [Upsilon(1S) -> mu- e+]CC
+    Definiton of [J/psi(1S) -> mu- e+]CC
     """
     emu = make_rd_detached_mue(
-        name="Hlt2RD_UpsilonToMuE_Builder",
-        parent_id='Upsilon(1S)',
-        min_dilepton_mass=7000. * MeV,
-        max_dilepton_mass=13000. * MeV,
+        name="Hlt2RD_JpsiToMuE_Builder",
+        parent_id='J/psi(1S)',
+        min_dilepton_mass=2600. * MeV,
+        max_dilepton_mass=3700. * MeV,
         min_probnn_mu=0.,
         min_PIDe=2.,
         min_pt_e=0.5 * GeV,
@@ -168,17 +272,17 @@ def upsilon_to_mue_line(name="Hlt2RD_UpsilonToMuE_Line",
 
 @register_line_builder(all_lines)
 @configurable
-def upsilon_to_mue_ss_line(name="Hlt2RD_UpsilonToMuE_SS_Line",
-                           prescale=1,
-                           persistreco=False):
+def jpsi_to_mue_ss_detached_line(name="Hlt2RD_JpsiToMuE_SS_Detached_Line",
+                                 prescale=1,
+                                 persistreco=False):
     """
-    Definiton of [Upsilon(1S) -> mu+ e+]CC
+    Definiton of [J/psi(1S) -> mu+ e+]CC
     """
     emu = make_rd_detached_mue(
-        name="Hlt2RD_UpsilonToMuE_SS_Builder",
-        parent_id='Upsilon(1S)',
-        min_dilepton_mass=7000. * MeV,
-        max_dilepton_mass=13000. * MeV,
+        name="Hlt2RD_JpsiToMuE_SS_Builder",
+        parent_id='J/psi(1S)',
+        min_dilepton_mass=2600. * MeV,
+        max_dilepton_mass=3700. * MeV,
         min_probnn_mu=0.,
         min_PIDe=2.,
         min_pt_e=0.5 * GeV,
-- 
GitLab


From db2ab04116b74a6474769724dd3f1221c1b3cac6 Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Sat, 15 Jan 2022 18:15:38 +0100
Subject: [PATCH 13/26] fixing gitlab ci-test

---
 Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
index 4b218cc5773..6a700bb27df 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
@@ -23,6 +23,9 @@ date: 27.12.2021
 
 from GaudiKernel.SystemOfUnits import MeV, GeV
 from PyConf import configurable
+from RecoConf.hlt1_tracking import require_pvs, require_gec
+from RecoConf.reconstruction_objects import (make_pvs_v2 as make_pvs,
+                                             upfront_reconstruction)
 from Moore.config import register_line_builder
 from Moore.lines import Hlt2Line
 from RecoConf.reconstruction_objects import upfront_reconstruction
@@ -89,7 +92,7 @@ def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
 
 @register_line_builder(all_lines)
 @configurable
-def phi_to_mue_line(name="Hlt2RD_JpsiToMuE_Line",
+def jpsi_to_mue_line(name="Hlt2RD_JpsiToMuE_Line",
                     prescale=1,
                     persistreco=False):
 
@@ -113,7 +116,7 @@ def phi_to_mue_line(name="Hlt2RD_JpsiToMuE_Line",
 
 @register_line_builder(all_lines)
 @configurable
-def phi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Line",
+def jpsi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Line",
                        prescale=1,
                        persistreco=False):
 
@@ -138,7 +141,7 @@ def phi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Line",
 
 @register_line_builder(all_lines)
 @configurable
-def phi_to_mue_line(name="Hlt2RD_UpsilonToMuE_Line",
+def upsilon_to_mue_line(name="Hlt2RD_UpsilonToMuE_Line",
                     prescale=1,
                     persistreco=False):
 
@@ -163,7 +166,7 @@ def phi_to_mue_line(name="Hlt2RD_UpsilonToMuE_Line",
 
 @register_line_builder(all_lines)
 @configurable
-def phi_to_mue_ss_line(name="Hlt2RD_UpsilonToMuE_SS_Line",
+def upsilon_to_mue_ss_line(name="Hlt2RD_UpsilonToMuE_SS_Line",
                        prescale=1,
                        persistreco=False):
 
-- 
GitLab


From b149cbcddd2d86b299ad67dcdc0158d2a9b37fa2 Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Sat, 15 Jan 2022 18:17:43 +0100
Subject: [PATCH 14/26] fix

---
 .../python/Hlt2Conf/lines/rd/qqbar_to_emu.py    | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
index 6a700bb27df..70f7da7d21d 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
@@ -28,7 +28,6 @@ from RecoConf.reconstruction_objects import (make_pvs_v2 as make_pvs,
                                              upfront_reconstruction)
 from Moore.config import register_line_builder
 from Moore.lines import Hlt2Line
-from RecoConf.reconstruction_objects import upfront_reconstruction
 from .builders.rdbuilder_thor import make_rd_detached_mue
 from .builders.qqbar_builders import make_prompt_mue
 
@@ -93,8 +92,8 @@ def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
 @register_line_builder(all_lines)
 @configurable
 def jpsi_to_mue_line(name="Hlt2RD_JpsiToMuE_Line",
-                    prescale=1,
-                    persistreco=False):
+                     prescale=1,
+                     persistreco=False):
 
     emu = make_prompt_mue(
         name="Hlt2RD_JpsiToMuE_Builder",
@@ -117,8 +116,8 @@ def jpsi_to_mue_line(name="Hlt2RD_JpsiToMuE_Line",
 @register_line_builder(all_lines)
 @configurable
 def jpsi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Line",
-                       prescale=1,
-                       persistreco=False):
+                        prescale=1,
+                        persistreco=False):
 
     emu = make_prompt_mue(
         name="Hlt2RD_JpsiToMuE_SS_Builder",
@@ -142,8 +141,8 @@ def jpsi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Line",
 @register_line_builder(all_lines)
 @configurable
 def upsilon_to_mue_line(name="Hlt2RD_UpsilonToMuE_Line",
-                    prescale=1,
-                    persistreco=False):
+                        prescale=1,
+                        persistreco=False):
 
     emu = make_prompt_mue(
         name="Hlt2RD_UpsilonToMuE_Builder",
@@ -167,8 +166,8 @@ def upsilon_to_mue_line(name="Hlt2RD_UpsilonToMuE_Line",
 @register_line_builder(all_lines)
 @configurable
 def upsilon_to_mue_ss_line(name="Hlt2RD_UpsilonToMuE_SS_Line",
-                       prescale=1,
-                       persistreco=False):
+                           prescale=1,
+                           persistreco=False):
 
     emu = make_prompt_mue(
         name="Hlt2RD_UpsilonToMuE_SS_Builder",
-- 
GitLab


From 3287348395a737ee205610ba618d41fb484b427f Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Mon, 17 Jan 2022 10:29:11 +0100
Subject: [PATCH 15/26] tuning cuts

---
 .../python/Hlt2Conf/lines/rd/qqbar_to_emu.py  | 28 +++++++++----------
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
index 70f7da7d21d..b91e057d4cf 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
@@ -51,10 +51,10 @@ def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Line", prescale=1,
         parent_id='phi(1020)',
         min_dilepton_mass=800. * MeV,
         max_dilepton_mass=1570. * MeV,
-        max_vertexchi2_mue=25,
-        min_pt_mu=0.25 * MeV,
+        max_vertexchi2_mue=20,
+        min_pt_mu=0.75 * MeV,
         min_pid_muon=-5,
-        min_pt_e=0.25 * MeV,
+        min_pt_e=0.75 * MeV,
         min_pid_electron=-5,
         max_vchi2ndof=5)
     return Hlt2Line(
@@ -75,10 +75,10 @@ def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
         parent_id='phi(1020)',
         min_dilepton_mass=800. * MeV,
         max_dilepton_mass=1570. * MeV,
-        max_vertexchi2_mue=25,
-        min_pt_mu=0.25 * MeV,
+        max_vertexchi2_mue=20,
+        min_pt_mu=0.75 * MeV,
         min_pid_muon=-5,
-        min_pt_e=0.25 * MeV,
+        min_pt_e=0.75 * MeV,
         min_pid_electron=-5,
         max_vchi2ndof=5,
         same_sign=True)
@@ -100,10 +100,10 @@ def jpsi_to_mue_line(name="Hlt2RD_JpsiToMuE_Line",
         parent_id='J/psi(1S)',
         min_dilepton_mass=2600. * MeV,
         max_dilepton_mass=3700. * MeV,
-        max_vertexchi2_mue=25,
-        min_pt_mu=0.75 * MeV,
+        max_vertexchi2_mue=20,
+        min_pt_mu=1. * MeV,
         min_pid_muon=-5,
-        min_pt_e=0.5 * MeV,
+        min_pt_e=1. * MeV,
         min_pid_electron=-5,
         max_vchi2ndof=5)
     return Hlt2Line(
@@ -124,10 +124,10 @@ def jpsi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Line",
         parent_id='J/psi(1S)',
         min_dilepton_mass=2600. * MeV,
         max_dilepton_mass=3700. * MeV,
-        max_vertexchi2_mue=25,
-        min_pt_mu=0.75 * MeV,
+        max_vertexchi2_mue=20,
+        min_pt_mu=1. * MeV,
         min_pid_muon=-5,
-        min_pt_e=0.5 * MeV,
+        min_pt_e=1. * MeV,
         min_pid_electron=-5,
         max_vchi2ndof=5,
         same_sign=True)
@@ -149,7 +149,7 @@ def upsilon_to_mue_line(name="Hlt2RD_UpsilonToMuE_Line",
         parent_id='Upsilon(1S)',
         min_dilepton_mass=7000. * MeV,
         max_dilepton_mass=13000. * MeV,
-        max_vertexchi2_mue=25,
+        max_vertexchi2_mue=20,
         min_pt_mu=2 * MeV,
         min_pid_muon=-5,
         min_pt_e=1.5 * MeV,
@@ -174,7 +174,7 @@ def upsilon_to_mue_ss_line(name="Hlt2RD_UpsilonToMuE_SS_Line",
         parent_id='Upsilon(1S)',
         min_dilepton_mass=7000. * MeV,
         max_dilepton_mass=13000. * MeV,
-        max_vertexchi2_mue=25,
+        max_vertexchi2_mue=20,
         min_pt_mu=2 * MeV,
         min_pid_muon=-5,
         min_pt_e=1.5 * MeV,
-- 
GitLab


From 4191ee7aebd1917688cc05e35b0b479e510fa122 Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Mon, 17 Jan 2022 16:43:05 +0100
Subject: [PATCH 16/26] working new builders and lines

---
 .../lines/rd/builders/qqbar_builder.py        | 46 +++++++++++++------
 .../python/Hlt2Conf/lines/rd/qqbar_to_emu.py  | 33 ++++++-------
 MooreCache/CMakeLists.txt                     |  2 +-
 3 files changed, 49 insertions(+), 32 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
index ecebf2e0855..f7434db28d7 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
@@ -33,7 +33,8 @@ from Hlt2Conf.standard_particles import make_long_electrons_with_brem, make_ismu
 
 
 @configurable
-def make_prompt_long_electrons(make_particles=make_long_electrons_with_brem,
+def make_prompt_long_electrons(pvs,
+                               make_particles=make_long_electrons_with_brem,
                                name="prompt_long_electrons",
                                min_pt_e=0. * MeV,
                                min_p_e=0. * GeV,
@@ -44,7 +45,7 @@ def make_prompt_long_electrons(make_particles=make_long_electrons_with_brem,
                                max_trackchi2_electron=None,
                                max_ipchi2_electron=None):
 
-    pvs = make_pvs()
+    #pvs = make_pvs()
 
     code = require_all(F.PT > min_pt_e, F.P > min_p_e,
                        F.MINIPCHI2(pvs) > min_ipchi2_electron,
@@ -61,7 +62,8 @@ def make_prompt_long_electrons(make_particles=make_long_electrons_with_brem,
 
 
 @configurable
-def make_prompt_long_muons(make_particles=make_ismuon_long_muon,
+def make_prompt_long_muons(pvs,
+                           make_particles=make_ismuon_long_muon,
                            name="prompt_long_muons",
                            min_pt_mu=0. * MeV,
                            min_p_mu=0. * GeV,
@@ -72,9 +74,9 @@ def make_prompt_long_muons(make_particles=make_ismuon_long_muon,
                            max_trackchi2_muon=None,
                            max_ipchi2_muon=None):
 
-    pvs = make_pvs()
+    #pvs = make_pvs()
 
-    code = require_all(F.PT > min_pt_mu, F.ISMUON, F.P > min_p_mu,
+    code = require_all(F.PT > min_pt_mu, F.P > min_p_mu,
                        F.MINIPCHI2(pvs) > min_ipchi2_muon,
                        F.MINIP(pvs) > min_ip_muon, F.PID_MU > min_pid_muon,
                        F.GHOSTPROB < max_ghostprob_muon)
@@ -89,12 +91,16 @@ def make_prompt_long_muons(make_particles=make_ismuon_long_muon,
 
 # the new dimuon base for bandq lines
 @configurable
-def make_prompt_mue(name='prompt_mue_builder',
-                    same_sign=False,
+def make_prompt_mue(pvs,
+                    name='prompt_mue_builder',
                     parent_id='J/psi(1S)',
                     min_dilepton_mass=0. * MeV,
                     max_dilepton_mass=100000. * MeV,
-                    max_vertexchi2_mue=25,
+                    min_pt_mue=1. * GeV,
+                    min_DIRA_mue=0.99,
+                    min_bpvvdchi2_mue=196.,
+                    max_ipchi2_mue=20,
+                    max_vertexchi2_mue=10,
                     max_vchi2ndof=10,
                     min_pt_mu=0.25 * GeV,
                     min_p_mu=2. * GeV,
@@ -107,14 +113,19 @@ def make_prompt_mue(name='prompt_mue_builder',
                     min_ipchi2_electron=0,
                     min_ip_electron=0,
                     max_ghostprob_electron=0.5,
-                    min_pid_electron=3,
+                    min_pid_electron=2,
                     max_trackchi2_muon=None,
-                    max_trackchi2_electron=None):
+                    max_trackchi2_electron=None,
+                    same_sign=False):
 
-    DecayDescriptor = [f"[{parent_id} -> mu+ e-]cc"]
-    if same_sign: DecayDescriptor = [f"[{parent_id} -> mu+ e+]cc"]
+    #DecayDescriptor = [f'[{parent_id} -> mu+ e-]CC']
+    DecayDescriptor = '[{} -> mu+ e-]CC'.format(parent_id)
+    if same_sign: DecayDescriptor = ['[{} -> mu+ e+]CC'.format(parent_id)]
+
+    #pvs = make_pvs()
 
     muons = make_prompt_long_muons(
+        pvs,
         min_pt_mu=min_pt_mu,
         min_p_mu=min_p_mu,
         min_ipchi2_muon=min_ipchi2_muon,
@@ -124,6 +135,7 @@ def make_prompt_mue(name='prompt_mue_builder',
         min_pid_muon=min_pid_muon)
 
     electrons = make_prompt_long_electrons(
+        pvs,
         min_pt_e=min_pt_e,
         min_p_e=min_p_e,
         min_ipchi2_electron=min_ipchi2_electron,
@@ -132,11 +144,15 @@ def make_prompt_mue(name='prompt_mue_builder',
         max_trackchi2_electron=max_trackchi2_electron,
         min_pid_electron=min_pid_electron)
 
-    combination_code = in_range(min_dilepton_mass, F.MASS, max_dilepton_mass)
+    combination_code = require_all(in_range(min_dilepton_mass, F.MASS, max_dilepton_mass))
 
     # require that the muons come from the same vertex
-    vertex_code = require_all((F.CHI2DOF < max_vertexchi2_mue),
-                              F.CHI2 / F.NDOF < max_vchi2ndof)
+    vertex_code = require_all(F.CHI2DOF < max_vertexchi2_mue,
+                              #F.CHI2 / F.NDOF < max_vchi2ndof, <- doesn't work?
+                              F.PT > min_pt_mue,
+                              F.BPVFDCHI2(pvs) > min_bpvvdchi2_mue,
+                              F.BPVIPCHI2(pvs) < max_ipchi2_mue,
+                              F.BPVDIRA(pvs) > min_DIRA_mue)
 
     return ParticleCombiner(
         name=name,
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
index b91e057d4cf..d19212c25d6 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
@@ -28,8 +28,10 @@ from RecoConf.reconstruction_objects import (make_pvs_v2 as make_pvs,
                                              upfront_reconstruction)
 from Moore.config import register_line_builder
 from Moore.lines import Hlt2Line
-from .builders.rdbuilder_thor import make_rd_detached_mue
-from .builders.qqbar_builders import make_prompt_mue
+from Hlt2Conf.lines.rd.builders.rdbuilder_thor import make_rd_detached_mue
+from Hlt2Conf.lines.rd.builders.qqbar_builder import make_prompt_mue
+
+from Hlt2Conf.standard_particles import (make_detached_mue_with_brem)
 
 all_lines = {}
 
@@ -45,8 +47,12 @@ def prefilters():
 @configurable
 def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Line", prescale=1,
                     persistreco=False):
-
+    """
+    Definiton of [phi(1020) -> mu- e+]CC
+    """
+    pvs = make_pvs()
     emu = make_prompt_mue(
+        pvs,
         name="Hlt2RD_PhiToMuE_Builder",
         parent_id='phi(1020)',
         min_dilepton_mass=800. * MeV,
@@ -55,7 +61,6 @@ def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Line", prescale=1,
         min_pt_mu=0.75 * MeV,
         min_pid_muon=-5,
         min_pt_e=0.75 * MeV,
-        min_pid_electron=-5,
         max_vchi2ndof=5)
     return Hlt2Line(
         name=name,
@@ -64,12 +69,13 @@ def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Line", prescale=1,
         persistreco=persistreco)
 
 
+
+
 @register_line_builder(all_lines)
 @configurable
 def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
                        prescale=1,
                        persistreco=False):
-
     emu = make_prompt_mue(
         name="Hlt2RD_PhiToMuE_SS_Builder",
         parent_id='phi(1020)',
@@ -79,7 +85,6 @@ def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
         min_pt_mu=0.75 * MeV,
         min_pid_muon=-5,
         min_pt_e=0.75 * MeV,
-        min_pid_electron=-5,
         max_vchi2ndof=5,
         same_sign=True)
     return Hlt2Line(
@@ -104,7 +109,6 @@ def jpsi_to_mue_line(name="Hlt2RD_JpsiToMuE_Line",
         min_pt_mu=1. * MeV,
         min_pid_muon=-5,
         min_pt_e=1. * MeV,
-        min_pid_electron=-5,
         max_vchi2ndof=5)
     return Hlt2Line(
         name=name,
@@ -128,7 +132,6 @@ def jpsi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Line",
         min_pt_mu=1. * MeV,
         min_pid_muon=-5,
         min_pt_e=1. * MeV,
-        min_pid_electron=-5,
         max_vchi2ndof=5,
         same_sign=True)
     return Hlt2Line(
@@ -153,7 +156,6 @@ def upsilon_to_mue_line(name="Hlt2RD_UpsilonToMuE_Line",
         min_pt_mu=2 * MeV,
         min_pid_muon=-5,
         min_pt_e=1.5 * MeV,
-        min_pid_electron=-5,
         max_vchi2ndof=5,
     )
     return Hlt2Line(
@@ -178,7 +180,6 @@ def upsilon_to_mue_ss_line(name="Hlt2RD_UpsilonToMuE_SS_Line",
         min_pt_mu=2 * MeV,
         min_pid_muon=-5,
         min_pt_e=1.5 * MeV,
-        min_pid_electron=-5,
         max_vchi2ndof=5,
         same_sign=True)
     return Hlt2Line(
@@ -205,7 +206,7 @@ def phi_to_mue_detached_line(name="Hlt2RD_PhiToMuE_Detached_Line",
         min_dilepton_mass=800. * MeV,
         max_dilepton_mass=1570. * MeV,
         min_probnn_mu=0.,
-        min_PIDe=3.,
+        min_PIDe=2.,
         min_pt_e=0.25 * GeV,
         min_pt_mu=0.25 * GeV,
         min_bpvvdchi2=30.,
@@ -213,7 +214,7 @@ def phi_to_mue_detached_line(name="Hlt2RD_PhiToMuE_Detached_Line",
     )
     return Hlt2Line(
         name=name,
-        algs=upfront_reconstruction() + [emu],
+        algs=upfront_reconstruction() + prefilters() + [emu],
         prescale=prescale,
         persistreco=persistreco)
 
@@ -232,7 +233,7 @@ def phi_to_mue_ss_detached_line(name="Hlt2RD_PhiToMuE_SS_Detached_Line",
         min_dilepton_mass=800. * MeV,
         max_dilepton_mass=1570. * MeV,
         min_probnn_mu=0.,
-        min_PIDe=3.,
+        min_PIDe=2.,
         min_pt_e=0.25 * GeV,
         min_pt_mu=0.25 * GeV,
         min_bpvvdchi2=30.,
@@ -240,7 +241,7 @@ def phi_to_mue_ss_detached_line(name="Hlt2RD_PhiToMuE_SS_Detached_Line",
         same_sign=True)
     return Hlt2Line(
         name=name,
-        algs=upfront_reconstruction() + [emu],
+        algs=upfront_reconstruction() + prefilters() + [emu],
         prescale=prescale,
         persistreco=persistreco)
 
@@ -267,7 +268,7 @@ def jpsi_to_mue_detached_line(name="Hlt2RD_JpsiToMuE_Detached_Line",
     )
     return Hlt2Line(
         name=name,
-        algs=upfront_reconstruction() + [emu],
+        algs=upfront_reconstruction() + prefilters() + [emu],
         prescale=prescale,
         persistreco=persistreco)
 
@@ -294,7 +295,7 @@ def jpsi_to_mue_ss_detached_line(name="Hlt2RD_JpsiToMuE_SS_Detached_Line",
         same_sign=True)
     return Hlt2Line(
         name=name,
-        algs=upfront_reconstruction() + [emu],
+        algs=upfront_reconstruction() + prefilters() + [emu],
         prescale=prescale,
         persistreco=persistreco)
 
diff --git a/MooreCache/CMakeLists.txt b/MooreCache/CMakeLists.txt
index 42e4fddd5fc..a72f52ca665 100644
--- a/MooreCache/CMakeLists.txt
+++ b/MooreCache/CMakeLists.txt
@@ -53,7 +53,7 @@ foreach(name IN LISTS hlt1_settings)
             Gaudi::GaudiKernel
             Rec::FunctorCoreLib
         DEPENDS ${cache_deps}
-        SPLIT 15
+        SPLIT 30
     )
 endforeach()
 
-- 
GitLab


From e9b0653fac7543b16c5fa39dd0a80dfc235629c1 Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Mon, 17 Jan 2022 17:22:45 +0100
Subject: [PATCH 17/26] cleaning of code, tighter cuts for prompt lines

---
 .../lines/rd/builders/qqbar_builder.py        | 22 +++++++-------
 .../python/Hlt2Conf/lines/rd/qqbar_to_emu.py  | 30 ++++---------------
 MooreCache/CMakeLists.txt                     |  4 +--
 3 files changed, 19 insertions(+), 37 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
index f7434db28d7..9d5bae4680b 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
@@ -91,8 +91,7 @@ def make_prompt_long_muons(pvs,
 
 # the new dimuon base for bandq lines
 @configurable
-def make_prompt_mue(pvs,
-                    name='prompt_mue_builder',
+def make_prompt_mue(name='prompt_mue_builder',
                     parent_id='J/psi(1S)',
                     min_dilepton_mass=0. * MeV,
                     max_dilepton_mass=100000. * MeV,
@@ -118,11 +117,10 @@ def make_prompt_mue(pvs,
                     max_trackchi2_electron=None,
                     same_sign=False):
 
-    #DecayDescriptor = [f'[{parent_id} -> mu+ e-]CC']
     DecayDescriptor = '[{} -> mu+ e-]CC'.format(parent_id)
     if same_sign: DecayDescriptor = ['[{} -> mu+ e+]CC'.format(parent_id)]
 
-    #pvs = make_pvs()
+    pvs = make_pvs()
 
     muons = make_prompt_long_muons(
         pvs,
@@ -144,15 +142,17 @@ def make_prompt_mue(pvs,
         max_trackchi2_electron=max_trackchi2_electron,
         min_pid_electron=min_pid_electron)
 
-    combination_code = require_all(in_range(min_dilepton_mass, F.MASS, max_dilepton_mass))
+    combination_code = require_all(
+        in_range(min_dilepton_mass, F.MASS, max_dilepton_mass))
 
     # require that the muons come from the same vertex
-    vertex_code = require_all(F.CHI2DOF < max_vertexchi2_mue,
-                              #F.CHI2 / F.NDOF < max_vchi2ndof, <- doesn't work?
-                              F.PT > min_pt_mue,
-                              F.BPVFDCHI2(pvs) > min_bpvvdchi2_mue,
-                              F.BPVIPCHI2(pvs) < max_ipchi2_mue,
-                              F.BPVDIRA(pvs) > min_DIRA_mue)
+    vertex_code = require_all(
+        F.CHI2DOF < max_vertexchi2_mue,
+        #F.CHI2 / F.NDOF < max_vchi2ndof, <- doesn't work?
+        F.PT > min_pt_mue,
+        F.BPVFDCHI2(pvs) > min_bpvvdchi2_mue,
+        F.BPVIPCHI2(pvs) < max_ipchi2_mue,
+        F.BPVDIRA(pvs) > min_DIRA_mue)
 
     return ParticleCombiner(
         name=name,
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
index d19212c25d6..e2f87ee52a4 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
@@ -31,8 +31,6 @@ from Moore.lines import Hlt2Line
 from Hlt2Conf.lines.rd.builders.rdbuilder_thor import make_rd_detached_mue
 from Hlt2Conf.lines.rd.builders.qqbar_builder import make_prompt_mue
 
-from Hlt2Conf.standard_particles import (make_detached_mue_with_brem)
-
 all_lines = {}
 
 
@@ -50,17 +48,13 @@ def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Line", prescale=1,
     """
     Definiton of [phi(1020) -> mu- e+]CC
     """
-    pvs = make_pvs()
     emu = make_prompt_mue(
-        pvs,
         name="Hlt2RD_PhiToMuE_Builder",
         parent_id='phi(1020)',
         min_dilepton_mass=800. * MeV,
         max_dilepton_mass=1570. * MeV,
-        max_vertexchi2_mue=20,
-        min_pt_mu=0.75 * MeV,
-        min_pid_muon=-5,
-        min_pt_e=0.75 * MeV,
+        min_pt_mu=0.5 * MeV,
+        min_pt_e=0.5 * MeV,
         max_vchi2ndof=5)
     return Hlt2Line(
         name=name,
@@ -69,8 +63,6 @@ def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Line", prescale=1,
         persistreco=persistreco)
 
 
-
-
 @register_line_builder(all_lines)
 @configurable
 def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
@@ -81,9 +73,7 @@ def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
         parent_id='phi(1020)',
         min_dilepton_mass=800. * MeV,
         max_dilepton_mass=1570. * MeV,
-        max_vertexchi2_mue=20,
         min_pt_mu=0.75 * MeV,
-        min_pid_muon=-5,
         min_pt_e=0.75 * MeV,
         max_vchi2ndof=5,
         same_sign=True)
@@ -105,9 +95,7 @@ def jpsi_to_mue_line(name="Hlt2RD_JpsiToMuE_Line",
         parent_id='J/psi(1S)',
         min_dilepton_mass=2600. * MeV,
         max_dilepton_mass=3700. * MeV,
-        max_vertexchi2_mue=20,
         min_pt_mu=1. * MeV,
-        min_pid_muon=-5,
         min_pt_e=1. * MeV,
         max_vchi2ndof=5)
     return Hlt2Line(
@@ -128,9 +116,7 @@ def jpsi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Line",
         parent_id='J/psi(1S)',
         min_dilepton_mass=2600. * MeV,
         max_dilepton_mass=3700. * MeV,
-        max_vertexchi2_mue=20,
         min_pt_mu=1. * MeV,
-        min_pid_muon=-5,
         min_pt_e=1. * MeV,
         max_vchi2ndof=5,
         same_sign=True)
@@ -152,10 +138,8 @@ def upsilon_to_mue_line(name="Hlt2RD_UpsilonToMuE_Line",
         parent_id='Upsilon(1S)',
         min_dilepton_mass=7000. * MeV,
         max_dilepton_mass=13000. * MeV,
-        max_vertexchi2_mue=20,
-        min_pt_mu=2 * MeV,
-        min_pid_muon=-5,
-        min_pt_e=1.5 * MeV,
+        min_pt_mu=1. * MeV,
+        min_pt_e=1. * MeV,
         max_vchi2ndof=5,
     )
     return Hlt2Line(
@@ -176,10 +160,8 @@ def upsilon_to_mue_ss_line(name="Hlt2RD_UpsilonToMuE_SS_Line",
         parent_id='Upsilon(1S)',
         min_dilepton_mass=7000. * MeV,
         max_dilepton_mass=13000. * MeV,
-        max_vertexchi2_mue=20,
-        min_pt_mu=2 * MeV,
-        min_pid_muon=-5,
-        min_pt_e=1.5 * MeV,
+        min_pt_mu=1. * MeV,
+        min_pt_e=1. * MeV,
         max_vchi2ndof=5,
         same_sign=True)
     return Hlt2Line(
diff --git a/MooreCache/CMakeLists.txt b/MooreCache/CMakeLists.txt
index a72f52ca665..69d8b8f26c4 100644
--- a/MooreCache/CMakeLists.txt
+++ b/MooreCache/CMakeLists.txt
@@ -53,7 +53,7 @@ foreach(name IN LISTS hlt1_settings)
             Gaudi::GaudiKernel
             Rec::FunctorCoreLib
         DEPENDS ${cache_deps}
-        SPLIT 30
+        SPLIT 15
     )
 endforeach()
 
@@ -82,6 +82,6 @@ foreach(options_path IN LISTS hlt2_settings)
             Rec::FunctorCoreLib
             Rec::LoKiTrackLib
         DEPENDS ${cache_deps}
-        SPLIT 50
+        SPLIT 30
     )
 endforeach()
-- 
GitLab


From 924bf13a6a7b429c0dfbe9d3297f6166035bfee2 Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Tue, 18 Jan 2022 16:04:38 +0100
Subject: [PATCH 18/26] new builders and revisited lines, all prompt and
 detached signal + SS included

---
 .../lines/rd/builders/qqbar_builder.py        | 131 ++++++++++++---
 .../python/Hlt2Conf/lines/rd/qqbar_to_emu.py  | 156 ++++++++++++++----
 2 files changed, 238 insertions(+), 49 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
index 9d5bae4680b..4391df1628a 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
@@ -29,9 +29,99 @@ from RecoConf.reconstruction_objects import make_pvs_v2 as make_pvs
 from Hlt2Conf.algorithms_thor import require_all, ParticleFilter, ParticleCombiner
 from PyConf import configurable
 
-from Hlt2Conf.standard_particles import make_long_electrons_with_brem, make_ismuon_long_muon
+from Hlt2Conf.standard_particles import make_long_electrons_with_brem, make_long_muons, make_detached_mue_with_brem, make_detached_dielectron_with_brem, make_detached_dielectron_with_brem
 
 
+#filter based on the rd_detached_mue / make_detached_mue_with_brem with zero cuts on IP and added combination cuts
+@configurable
+def make_prompt_mue(
+        name="prompt_mue_builder",
+        min_dilepton_mass=0. * MeV,
+        max_dilepton_mass=6000. * MeV,
+        min_dilepton_pt=1.0 * GeV,
+        min_DIRA_mue=0.99,
+        max_ipchi2_mue=50,
+        parent_id='J/psi(1S)',
+        min_probnn_mu=0.,
+        min_PIDmu=0.,
+        IsMuon=True,
+        min_PIDe=2.,
+        min_pt_e=0.5 * GeV,
+        min_pt_mu=0.5 * GeV,
+        minipchi2=0,  #must be 0 for a prompt builder
+        min_bpvvdchi2=0.,  #must be 0 for a prompt builder
+        max_vchi2ndof=10.,
+        max_trghostprob=0.25,
+        same_sign=False):
+    """
+    Make the detached muon-electron pair, opposite-sign or same-sign.
+    """
+    pvs = make_pvs()
+    dileptons = make_detached_mue_with_brem(
+        dilepton_ID=parent_id,
+        min_probnn_mu=min_probnn_mu,
+        min_PIDmu=0.,
+        IsMuon=IsMuon,
+        min_PIDe=min_PIDe,
+        same_sign=same_sign,
+        min_pt_e=min_pt_e,
+        min_pt_mu=min_pt_mu,
+        minipchi2_track=minipchi2,
+        min_bpvvdchi2=min_bpvvdchi2,
+        max_vchi2ndof=max_vchi2ndof,
+        max_trghostprob=max_trghostprob)
+    code = require_all(
+        in_range(min_dilepton_mass, F.MASS, max_dilepton_mass),
+        F.PT > min_dilepton_pt,
+        F.BPVDIRA(pvs) > min_DIRA_mue,
+        F.BPVIPCHI2(pvs) < max_ipchi2_mue)
+    return ParticleFilter(dileptons, F.FILTER(code), name=name)
+
+
+@configurable
+def make_prompt_ee(
+        name="prompt_ee_builder",
+        opposite_sign=True,
+        PIDe_min=2.,
+        pt_e=0.5 * GeV,
+        minipchi2=0,  #must be 0 for a prompt builder
+        min_DIRA_ee=0.99,
+        max_ipchi2_ee=50,
+        trghostprob=0.25,
+        parent_id="J/psi(1S)",
+        min_dilepton_pt=0 * MeV,
+        min_dilepton_mass=0 * MeV,
+        max_dilepton_mass=6000 * MeV,
+        adocachi2cut=30,
+        bpvvdchi2=30,
+        max_vchi2ndof=7.5):
+    """
+    Make the detached muon-electron pair, opposite-sign or same-sign.
+    """
+    pvs = make_pvs()
+    dileptons = make_detached_dielectron_with_brem(
+        opposite_sign=opposite_sign,
+        PIDe_min=PIDe_min,
+        pt_e=pt_e,
+        minipchi2=minipchi2,
+        trghostprob=trghostprob,
+        dielectron_ID=parent_id,
+        pt_diE=min_dilepton_pt,
+        m_diE_min=min_dilepton_mass,
+        m_diE_max=max_dilepton_mass,
+        adocachi2cut=adocachi2cut,
+        bpvvdchi2=bpvvdchi2,
+        vfaspfchi2ndof=max_vchi2ndof)
+    code = require_all(
+        in_range(min_dilepton_mass, F.MASS, max_dilepton_mass),
+        F.PT > min_dilepton_pt,
+        F.BPVDIRA(pvs) > min_DIRA_ee,
+        F.BPVIPCHI2(pvs) < max_ipchi2_ee)
+    return ParticleFilter(dileptons, F.FILTER(code), name=name)
+
+
+"""
+### dedicated filters and builders for making up everything from the basic particles; keeping it now for posible revison but to be removed before merging into master
 @configurable
 def make_prompt_long_electrons(pvs,
                                make_particles=make_long_electrons_with_brem,
@@ -52,18 +142,18 @@ def make_prompt_long_electrons(pvs,
                        F.MINIP(pvs) > min_ip_electron,
                        F.PID_MU > min_pid_electron,
                        F.GHOSTPROB < max_ghostprob_electron)
-
+    
     if max_trackchi2_electron is not None:
         code &= (F.CHI2 < max_trackchi2_electron)
     if max_ipchi2_electron is not None:
         code &= (F.MINIPCHI2(pvs) < max_ipchi2_electron)
 
-    return ParticleFilter(make_particles(), name=name, Cut=F.FILTER(code))
+    return ParticleFilter(make_particles(), name=name, Cut=F.FILTER())
 
 
 @configurable
 def make_prompt_long_muons(pvs,
-                           make_particles=make_ismuon_long_muon,
+                           make_particles=make_long_muons,
                            name="prompt_long_muons",
                            min_pt_mu=0. * MeV,
                            min_p_mu=0. * GeV,
@@ -76,11 +166,11 @@ def make_prompt_long_muons(pvs,
 
     #pvs = make_pvs()
 
-    code = require_all(F.PT > min_pt_mu, F.P > min_p_mu,
+    code = require_all(F.PT > min_pt_mu, F.ISMUON, F.P > min_p_mu,
                        F.MINIPCHI2(pvs) > min_ipchi2_muon,
                        F.MINIP(pvs) > min_ip_muon, F.PID_MU > min_pid_muon,
                        F.GHOSTPROB < max_ghostprob_muon)
-
+    
     if max_trackchi2_muon is not None:
         code &= (F.CHI2 < max_trackchi2_muon)
     if max_ipchi2_muon is not None:
@@ -89,17 +179,18 @@ def make_prompt_long_muons(pvs,
     return ParticleFilter(make_particles(), name=name, Cut=F.FILTER(code))
 
 
-# the new dimuon base for bandq lines
-@configurable
+"""
+"""
+@configurable #currenctly does not work, no events selected even after removing all the requirements
 def make_prompt_mue(name='prompt_mue_builder',
-                    parent_id='J/psi(1S)',
+                    DecayDescriptor='[J/psi(1S) -> mu+ e-]CC',
                     min_dilepton_mass=0. * MeV,
                     max_dilepton_mass=100000. * MeV,
                     min_pt_mue=1. * GeV,
-                    min_DIRA_mue=0.99,
-                    min_bpvvdchi2_mue=196.,
+                    min_DIRA_mue=0.95,
+                    min_bpvvdchi2_mue=100.,
                     max_ipchi2_mue=20,
-                    max_vertexchi2_mue=10,
+                    max_vertexchi2_mue=20,
                     max_vchi2ndof=10,
                     min_pt_mu=0.25 * GeV,
                     min_p_mu=2. * GeV,
@@ -112,13 +203,12 @@ def make_prompt_mue(name='prompt_mue_builder',
                     min_ipchi2_electron=0,
                     min_ip_electron=0,
                     max_ghostprob_electron=0.5,
-                    min_pid_electron=2,
+                    min_pid_electron=-5,
                     max_trackchi2_muon=None,
-                    max_trackchi2_electron=None,
-                    same_sign=False):
+                    max_trackchi2_electron=None):
 
-    DecayDescriptor = '[{} -> mu+ e-]CC'.format(parent_id)
-    if same_sign: DecayDescriptor = ['[{} -> mu+ e+]CC'.format(parent_id)]
+    #DecayDescriptor = '{} -> mu+ e-'.format(parent_id) # <- giving a weird error: ValueError: received an instance of <class 'list'>, but <class 'str'> expected
+    #if same_sign: DecayDescriptor = ['[{} -> mu+ e+]CC'.format(parent_id)]
 
     pvs = make_pvs()
 
@@ -158,9 +248,10 @@ def make_prompt_mue(name='prompt_mue_builder',
         name=name,
         Inputs=[muons, electrons],
         DecayDescriptor=DecayDescriptor,
-        CombinationCut=combination_code,
-        CompositeCut=vertex_code)
-
+        #CombinationCut=combination_code,
+        #CompositeCut=vertex_code
+        )
+"""
 
 #################
 ## END OF FILE ##
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
index e2f87ee52a4..b0259e55594 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
@@ -14,7 +14,9 @@ Definiton of LFV lines of qqbar -> emu
 - Phi(1020) -> E Mu + SS detached
 - J/Psi(1S) -> E Mu + SS prompt
 - J/Psi(1S) -> E Mu + SS detached
-- Upsilon(1S) -> E Mu + SS
+- Upsilon(1S) -> E Mu + SS prompt only
+
+add control channels e+e- / mu+mu-
 
 author: Miroslav Saur
 date: 27.12.2021
@@ -29,7 +31,7 @@ from RecoConf.reconstruction_objects import (make_pvs_v2 as make_pvs,
 from Moore.config import register_line_builder
 from Moore.lines import Hlt2Line
 from Hlt2Conf.lines.rd.builders.rdbuilder_thor import make_rd_detached_mue
-from Hlt2Conf.lines.rd.builders.qqbar_builder import make_prompt_mue
+from Hlt2Conf.lines.rd.builders.qqbar_builder import make_prompt_mue, make_prompt_ee
 
 all_lines = {}
 
@@ -51,11 +53,15 @@ def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Line", prescale=1,
     emu = make_prompt_mue(
         name="Hlt2RD_PhiToMuE_Builder",
         parent_id='phi(1020)',
-        min_dilepton_mass=800. * MeV,
-        max_dilepton_mass=1570. * MeV,
-        min_pt_mu=0.5 * MeV,
-        min_pt_e=0.5 * MeV,
-        max_vchi2ndof=5)
+        min_dilepton_mass=850. * MeV,
+        max_dilepton_mass=1520. * MeV,
+        min_dilepton_pt=2.0 * GeV,
+        min_probnn_mu=0.,
+        min_PIDmu=0.,
+        IsMuon=True,
+        min_PIDe=2.,
+        min_pt_e=0.5 * GeV,
+        min_pt_mu=0.5 * GeV)
     return Hlt2Line(
         name=name,
         algs=upfront_reconstruction() + prefilters() + [emu],
@@ -71,11 +77,15 @@ def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
     emu = make_prompt_mue(
         name="Hlt2RD_PhiToMuE_SS_Builder",
         parent_id='phi(1020)',
-        min_dilepton_mass=800. * MeV,
-        max_dilepton_mass=1570. * MeV,
-        min_pt_mu=0.75 * MeV,
-        min_pt_e=0.75 * MeV,
-        max_vchi2ndof=5,
+        min_dilepton_mass=850. * MeV,
+        max_dilepton_mass=1520. * MeV,
+        min_dilepton_pt=2.0 * GeV,
+        min_probnn_mu=0.,
+        min_PIDmu=0.,
+        IsMuon=True,
+        min_PIDe=2.,
+        min_pt_e=0.5 * GeV,
+        min_pt_mu=0.5 * GeV,
         same_sign=True)
     return Hlt2Line(
         name=name,
@@ -95,9 +105,13 @@ def jpsi_to_mue_line(name="Hlt2RD_JpsiToMuE_Line",
         parent_id='J/psi(1S)',
         min_dilepton_mass=2600. * MeV,
         max_dilepton_mass=3700. * MeV,
-        min_pt_mu=1. * MeV,
-        min_pt_e=1. * MeV,
-        max_vchi2ndof=5)
+        min_dilepton_pt=2.0 * GeV,
+        min_probnn_mu=0.,
+        min_PIDmu=0.,
+        IsMuon=True,
+        min_PIDe=2.,
+        min_pt_e=0.5 * GeV,
+        min_pt_mu=0.5 * GeV)
     return Hlt2Line(
         name=name,
         algs=upfront_reconstruction() + prefilters() + [emu],
@@ -116,9 +130,13 @@ def jpsi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Line",
         parent_id='J/psi(1S)',
         min_dilepton_mass=2600. * MeV,
         max_dilepton_mass=3700. * MeV,
-        min_pt_mu=1. * MeV,
-        min_pt_e=1. * MeV,
-        max_vchi2ndof=5,
+        min_dilepton_pt=2.0 * GeV,
+        min_probnn_mu=0.,
+        min_PIDmu=0.,
+        IsMuon=True,
+        min_PIDe=2.,
+        min_pt_e=0.5 * GeV,
+        min_pt_mu=0.5 * GeV,
         same_sign=True)
     return Hlt2Line(
         name=name,
@@ -138,10 +156,14 @@ def upsilon_to_mue_line(name="Hlt2RD_UpsilonToMuE_Line",
         parent_id='Upsilon(1S)',
         min_dilepton_mass=7000. * MeV,
         max_dilepton_mass=13000. * MeV,
-        min_pt_mu=1. * MeV,
-        min_pt_e=1. * MeV,
-        max_vchi2ndof=5,
-    )
+        min_dilepton_pt=1.0 * GeV,
+        min_probnn_mu=0.,
+        min_PIDmu=0.,
+        IsMuon=True,
+        min_PIDe=2.,
+        min_pt_e=1.0 * GeV,
+        min_pt_mu=1.0 * GeV,
+        same_sign=False)
     return Hlt2Line(
         name=name,
         algs=upfront_reconstruction() + prefilters() + [emu],
@@ -160,9 +182,13 @@ def upsilon_to_mue_ss_line(name="Hlt2RD_UpsilonToMuE_SS_Line",
         parent_id='Upsilon(1S)',
         min_dilepton_mass=7000. * MeV,
         max_dilepton_mass=13000. * MeV,
-        min_pt_mu=1. * MeV,
-        min_pt_e=1. * MeV,
-        max_vchi2ndof=5,
+        min_dilepton_pt=1.0 * GeV,
+        min_probnn_mu=0.,
+        min_PIDmu=0.,
+        IsMuon=True,
+        min_PIDe=2.,
+        min_pt_e=1.0 * GeV,
+        min_pt_mu=1.0 * GeV,
         same_sign=True)
     return Hlt2Line(
         name=name,
@@ -183,7 +209,7 @@ def phi_to_mue_detached_line(name="Hlt2RD_PhiToMuE_Detached_Line",
     Definiton of [phi(1020) -> mu- e+]CC
     """
     emu = make_rd_detached_mue(
-        name="Hlt2RD_PhiToMuE_Builder",
+        name="Hlt2RD_PhiToMuE_detached_Builder",
         parent_id='phi(1020)',
         min_dilepton_mass=800. * MeV,
         max_dilepton_mass=1570. * MeV,
@@ -210,7 +236,7 @@ def phi_to_mue_ss_detached_line(name="Hlt2RD_PhiToMuE_SS_Detached_Line",
     Definiton of [phi(1020) -> mu+ e+]CC
     """
     emu = make_rd_detached_mue(
-        name="Hlt2RD_PhiToMuE_SS_Builder",
+        name="Hlt2RD_PhiToMuE_SS_detached_Builder",
         parent_id='phi(1020)',
         min_dilepton_mass=800. * MeV,
         max_dilepton_mass=1570. * MeV,
@@ -237,7 +263,7 @@ def jpsi_to_mue_detached_line(name="Hlt2RD_JpsiToMuE_Detached_Line",
     Definiton of [J/psi(1S) -> mu- e+]CC
     """
     emu = make_rd_detached_mue(
-        name="Hlt2RD_JpsiToMuE_Builder",
+        name="Hlt2RD_JpsiToMuE_detached_Builder",
         parent_id='J/psi(1S)',
         min_dilepton_mass=2600. * MeV,
         max_dilepton_mass=3700. * MeV,
@@ -264,7 +290,7 @@ def jpsi_to_mue_ss_detached_line(name="Hlt2RD_JpsiToMuE_SS_Detached_Line",
     Definiton of [J/psi(1S) -> mu+ e+]CC
     """
     emu = make_rd_detached_mue(
-        name="Hlt2RD_JpsiToMuE_SS_Builder",
+        name="Hlt2RD_JpsiToMuE_SS_deached_Builder",
         parent_id='J/psi(1S)',
         min_dilepton_mass=2600. * MeV,
         max_dilepton_mass=3700. * MeV,
@@ -282,6 +308,78 @@ def jpsi_to_mue_ss_detached_line(name="Hlt2RD_JpsiToMuE_SS_Detached_Line",
         persistreco=persistreco)
 
 
+##### CONTROL ee/mumu LINES #####
+
+
+@register_line_builder(all_lines)
+@configurable
+def phi_to_ee_line(name="Hlt2RD_PhiToEE_Line", prescale=1, persistreco=False):
+    emu = make_prompt_ee(
+        name="Hlt2RD_PhiToMuE_SS_Builder",
+        parent_id='phi(1020)',
+        opposite_sign=True,
+        PIDe_min=2.,
+        pt_e=0.25 * GeV,
+        minipchi2=0,  #must be 0 for a prompt builder
+        min_DIRA_ee=0.99,
+        max_ipchi2_ee=50,
+        min_dilepton_pt=2.0 * GeV,
+        min_dilepton_mass=850 * MeV,
+        max_dilepton_mass=1520 * MeV)
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + prefilters() + [emu],
+        prescale=prescale,
+        persistreco=persistreco)
+
+
+@register_line_builder(all_lines)
+@configurable
+def jpsi_to_ee_line(name="Hlt2RD_JpsiToEE_Line", prescale=1,
+                    persistreco=False):
+    emu = make_prompt_ee(
+        name="Hlt2RD_PhiToMuE_SS_Builder",
+        parent_id='J/psi(1S)',
+        opposite_sign=True,
+        PIDe_min=2.,
+        pt_e=0.5 * GeV,
+        minipchi2=0,  #must be 0 for a prompt builder
+        min_DIRA_ee=0.99,
+        max_ipchi2_ee=50,
+        min_dilepton_pt=2.0 * GeV,
+        min_dilepton_mass=2600 * MeV,
+        max_dilepton_mass=3700 * MeV)
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + prefilters() + [emu],
+        prescale=prescale,
+        persistreco=persistreco)
+
+
+@register_line_builder(all_lines)
+@configurable
+def upsilon_to_ee_line(name="Hlt2RD_UpsilonToEE_Line",
+                       prescale=1,
+                       persistreco=False):
+    emu = make_prompt_ee(
+        name="Hlt2RD_UpsilonToMuE_SS_Builder",
+        parent_id='Upsilon(1S)',
+        opposite_sign=True,
+        PIDe_min=2.,
+        pt_e=1. * GeV,
+        minipchi2=0,  #must be 0 for a prompt builder
+        min_DIRA_ee=0.99,
+        max_ipchi2_ee=50,
+        min_dilepton_pt=2.0 * GeV,
+        min_dilepton_mass=7000 * MeV,
+        max_dilepton_mass=13000 * MeV)
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + prefilters() + [emu],
+        prescale=prescale,
+        persistreco=persistreco)
+
+
 #################
 ## END OF FILE ##
 #################
-- 
GitLab


From 02284e4b7cb0e11db3393d90557bd2e8fd52f27e Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Tue, 25 Jan 2022 18:04:28 +0100
Subject: [PATCH 19/26] applying comments, removig DIRA cuts, pushing ipchi2 to
 0

---
 .../lines/rd/builders/qqbar_builder.py        | 10 ++--
 .../python/Hlt2Conf/lines/rd/qqbar_to_emu.py  | 53 +++----------------
 2 files changed, 12 insertions(+), 51 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
index 4391df1628a..5eda46b7cbf 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
@@ -29,7 +29,7 @@ from RecoConf.reconstruction_objects import make_pvs_v2 as make_pvs
 from Hlt2Conf.algorithms_thor import require_all, ParticleFilter, ParticleCombiner
 from PyConf import configurable
 
-from Hlt2Conf.standard_particles import make_long_electrons_with_brem, make_long_muons, make_detached_mue_with_brem, make_detached_dielectron_with_brem, make_detached_dielectron_with_brem
+from Hlt2Conf.standard_particles import make_detached_mue_with_brem, make_detached_dielectron_with_brem
 
 
 #filter based on the rd_detached_mue / make_detached_mue_with_brem with zero cuts on IP and added combination cuts
@@ -39,7 +39,6 @@ def make_prompt_mue(
         min_dilepton_mass=0. * MeV,
         max_dilepton_mass=6000. * MeV,
         min_dilepton_pt=1.0 * GeV,
-        min_DIRA_mue=0.99,
         max_ipchi2_mue=50,
         parent_id='J/psi(1S)',
         min_probnn_mu=0.,
@@ -51,7 +50,7 @@ def make_prompt_mue(
         minipchi2=0,  #must be 0 for a prompt builder
         min_bpvvdchi2=0.,  #must be 0 for a prompt builder
         max_vchi2ndof=10.,
-        max_trghostprob=0.25,
+        max_trghostprob=0.2,
         same_sign=False):
     """
     Make the detached muon-electron pair, opposite-sign or same-sign.
@@ -87,13 +86,12 @@ def make_prompt_ee(
         minipchi2=0,  #must be 0 for a prompt builder
         min_DIRA_ee=0.99,
         max_ipchi2_ee=50,
-        trghostprob=0.25,
+        trghostprob=0.2,
         parent_id="J/psi(1S)",
-        min_dilepton_pt=0 * MeV,
+        min_dilepton_pt=0 * GeV,
         min_dilepton_mass=0 * MeV,
         max_dilepton_mass=6000 * MeV,
         adocachi2cut=30,
-        bpvvdchi2=30,
         max_vchi2ndof=7.5):
     """
     Make the detached muon-electron pair, opposite-sign or same-sign.
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
index b0259e55594..11f2d4a6e3f 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/qqbar_to_emu.py
@@ -56,10 +56,6 @@ def phi_to_mue_line(name="Hlt2RD_PhiToMuE_Line", prescale=1,
         min_dilepton_mass=850. * MeV,
         max_dilepton_mass=1520. * MeV,
         min_dilepton_pt=2.0 * GeV,
-        min_probnn_mu=0.,
-        min_PIDmu=0.,
-        IsMuon=True,
-        min_PIDe=2.,
         min_pt_e=0.5 * GeV,
         min_pt_mu=0.5 * GeV)
     return Hlt2Line(
@@ -80,10 +76,6 @@ def phi_to_mue_ss_line(name="Hlt2RD_PhiToMuE_SS_Line",
         min_dilepton_mass=850. * MeV,
         max_dilepton_mass=1520. * MeV,
         min_dilepton_pt=2.0 * GeV,
-        min_probnn_mu=0.,
-        min_PIDmu=0.,
-        IsMuon=True,
-        min_PIDe=2.,
         min_pt_e=0.5 * GeV,
         min_pt_mu=0.5 * GeV,
         same_sign=True)
@@ -106,12 +98,8 @@ def jpsi_to_mue_line(name="Hlt2RD_JpsiToMuE_Line",
         min_dilepton_mass=2600. * MeV,
         max_dilepton_mass=3700. * MeV,
         min_dilepton_pt=2.0 * GeV,
-        min_probnn_mu=0.,
-        min_PIDmu=0.,
-        IsMuon=True,
-        min_PIDe=2.,
-        min_pt_e=0.5 * GeV,
-        min_pt_mu=0.5 * GeV)
+        min_pt_e=1.0 * GeV,
+        min_pt_mu=1.0 * GeV)
     return Hlt2Line(
         name=name,
         algs=upfront_reconstruction() + prefilters() + [emu],
@@ -131,12 +119,8 @@ def jpsi_to_mue_ss_line(name="Hlt2RD_JpsiToMuE_SS_Line",
         min_dilepton_mass=2600. * MeV,
         max_dilepton_mass=3700. * MeV,
         min_dilepton_pt=2.0 * GeV,
-        min_probnn_mu=0.,
-        min_PIDmu=0.,
-        IsMuon=True,
-        min_PIDe=2.,
-        min_pt_e=0.5 * GeV,
-        min_pt_mu=0.5 * GeV,
+        min_pt_e=1.0 * GeV,
+        min_pt_mu=1.0 * GeV,
         same_sign=True)
     return Hlt2Line(
         name=name,
@@ -157,10 +141,6 @@ def upsilon_to_mue_line(name="Hlt2RD_UpsilonToMuE_Line",
         min_dilepton_mass=7000. * MeV,
         max_dilepton_mass=13000. * MeV,
         min_dilepton_pt=1.0 * GeV,
-        min_probnn_mu=0.,
-        min_PIDmu=0.,
-        IsMuon=True,
-        min_PIDe=2.,
         min_pt_e=1.0 * GeV,
         min_pt_mu=1.0 * GeV,
         same_sign=False)
@@ -183,10 +163,6 @@ def upsilon_to_mue_ss_line(name="Hlt2RD_UpsilonToMuE_SS_Line",
         min_dilepton_mass=7000. * MeV,
         max_dilepton_mass=13000. * MeV,
         min_dilepton_pt=1.0 * GeV,
-        min_probnn_mu=0.,
-        min_PIDmu=0.,
-        IsMuon=True,
-        min_PIDe=2.,
         min_pt_e=1.0 * GeV,
         min_pt_mu=1.0 * GeV,
         same_sign=True)
@@ -214,7 +190,6 @@ def phi_to_mue_detached_line(name="Hlt2RD_PhiToMuE_Detached_Line",
         min_dilepton_mass=800. * MeV,
         max_dilepton_mass=1570. * MeV,
         min_probnn_mu=0.,
-        min_PIDe=2.,
         min_pt_e=0.25 * GeV,
         min_pt_mu=0.25 * GeV,
         min_bpvvdchi2=30.,
@@ -241,7 +216,6 @@ def phi_to_mue_ss_detached_line(name="Hlt2RD_PhiToMuE_SS_Detached_Line",
         min_dilepton_mass=800. * MeV,
         max_dilepton_mass=1570. * MeV,
         min_probnn_mu=0.,
-        min_PIDe=2.,
         min_pt_e=0.25 * GeV,
         min_pt_mu=0.25 * GeV,
         min_bpvvdchi2=30.,
@@ -268,7 +242,6 @@ def jpsi_to_mue_detached_line(name="Hlt2RD_JpsiToMuE_Detached_Line",
         min_dilepton_mass=2600. * MeV,
         max_dilepton_mass=3700. * MeV,
         min_probnn_mu=0.,
-        min_PIDe=2.,
         min_pt_e=0.5 * GeV,
         min_pt_mu=0.5 * GeV,
         min_bpvvdchi2=30.,
@@ -295,7 +268,6 @@ def jpsi_to_mue_ss_detached_line(name="Hlt2RD_JpsiToMuE_SS_Detached_Line",
         min_dilepton_mass=2600. * MeV,
         max_dilepton_mass=3700. * MeV,
         min_probnn_mu=0.,
-        min_PIDe=2.,
         min_pt_e=0.5 * GeV,
         min_pt_mu=0.5 * GeV,
         min_bpvvdchi2=30.,
@@ -319,10 +291,7 @@ def phi_to_ee_line(name="Hlt2RD_PhiToEE_Line", prescale=1, persistreco=False):
         parent_id='phi(1020)',
         opposite_sign=True,
         PIDe_min=2.,
-        pt_e=0.25 * GeV,
-        minipchi2=0,  #must be 0 for a prompt builder
-        min_DIRA_ee=0.99,
-        max_ipchi2_ee=50,
+        pt_e=1.5 * GeV,
         min_dilepton_pt=2.0 * GeV,
         min_dilepton_mass=850 * MeV,
         max_dilepton_mass=1520 * MeV)
@@ -343,10 +312,7 @@ def jpsi_to_ee_line(name="Hlt2RD_JpsiToEE_Line", prescale=1,
         opposite_sign=True,
         PIDe_min=2.,
         pt_e=0.5 * GeV,
-        minipchi2=0,  #must be 0 for a prompt builder
-        min_DIRA_ee=0.99,
-        max_ipchi2_ee=50,
-        min_dilepton_pt=2.0 * GeV,
+        min_dilepton_pt=1.0 * GeV,
         min_dilepton_mass=2600 * MeV,
         max_dilepton_mass=3700 * MeV)
     return Hlt2Line(
@@ -362,15 +328,12 @@ def upsilon_to_ee_line(name="Hlt2RD_UpsilonToEE_Line",
                        prescale=1,
                        persistreco=False):
     emu = make_prompt_ee(
-        name="Hlt2RD_UpsilonToMuE_SS_Builder",
+        name="Hlt2RD_UpsilonToMuE_Builder",
         parent_id='Upsilon(1S)',
         opposite_sign=True,
         PIDe_min=2.,
         pt_e=1. * GeV,
-        minipchi2=0,  #must be 0 for a prompt builder
-        min_DIRA_ee=0.99,
-        max_ipchi2_ee=50,
-        min_dilepton_pt=2.0 * GeV,
+        min_dilepton_pt=0.5 * GeV,
         min_dilepton_mass=7000 * MeV,
         max_dilepton_mass=13000 * MeV)
     return Hlt2Line(
-- 
GitLab


From 8c8ced8f5e085a86ffb4bec798ab0530f4f947c2 Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Tue, 25 Jan 2022 18:06:03 +0100
Subject: [PATCH 20/26] applying comments, removig all DIRA cuts

---
 .../python/Hlt2Conf/lines/rd/builders/qqbar_builder.py         | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
index 5eda46b7cbf..0208d5259a5 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
@@ -72,7 +72,6 @@ def make_prompt_mue(
     code = require_all(
         in_range(min_dilepton_mass, F.MASS, max_dilepton_mass),
         F.PT > min_dilepton_pt,
-        F.BPVDIRA(pvs) > min_DIRA_mue,
         F.BPVIPCHI2(pvs) < max_ipchi2_mue)
     return ParticleFilter(dileptons, F.FILTER(code), name=name)
 
@@ -84,7 +83,6 @@ def make_prompt_ee(
         PIDe_min=2.,
         pt_e=0.5 * GeV,
         minipchi2=0,  #must be 0 for a prompt builder
-        min_DIRA_ee=0.99,
         max_ipchi2_ee=50,
         trghostprob=0.2,
         parent_id="J/psi(1S)",
@@ -113,7 +111,6 @@ def make_prompt_ee(
     code = require_all(
         in_range(min_dilepton_mass, F.MASS, max_dilepton_mass),
         F.PT > min_dilepton_pt,
-        F.BPVDIRA(pvs) > min_DIRA_ee,
         F.BPVIPCHI2(pvs) < max_ipchi2_ee)
     return ParticleFilter(dileptons, F.FILTER(code), name=name)
 
-- 
GitLab


From 6deb6376added40131f479a62cae14ae3db2f0c8 Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Tue, 25 Jan 2022 18:07:48 +0100
Subject: [PATCH 21/26] makelist

---
 MooreCache/CMakeLists.txt | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MooreCache/CMakeLists.txt b/MooreCache/CMakeLists.txt
index 69d8b8f26c4..42e4fddd5fc 100644
--- a/MooreCache/CMakeLists.txt
+++ b/MooreCache/CMakeLists.txt
@@ -82,6 +82,6 @@ foreach(options_path IN LISTS hlt2_settings)
             Rec::FunctorCoreLib
             Rec::LoKiTrackLib
         DEPENDS ${cache_deps}
-        SPLIT 30
+        SPLIT 50
     )
 endforeach()
-- 
GitLab


From ae9c2c38d00e9eadd388f90d108f39f1db744f48 Mon Sep 17 00:00:00 2001
From: Miroslav Saur <miroslav.saur@cern.ch>
Date: Tue, 25 Jan 2022 18:09:12 +0100
Subject: [PATCH 22/26] fixing builders

---
 .../python/Hlt2Conf/lines/rd/builders/qqbar_builder.py         | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
index 0208d5259a5..8091faeb018 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
@@ -26,7 +26,7 @@ from GaudiKernel.SystemOfUnits import MeV, GeV
 
 from RecoConf.reconstruction_objects import make_pvs_v2 as make_pvs
 
-from Hlt2Conf.algorithms_thor import require_all, ParticleFilter, ParticleCombiner
+from Hlt2Conf.algorithms_thor import require_all, ParticleFilter
 from PyConf import configurable
 
 from Hlt2Conf.standard_particles import make_detached_mue_with_brem, make_detached_dielectron_with_brem
@@ -106,7 +106,6 @@ def make_prompt_ee(
         m_diE_min=min_dilepton_mass,
         m_diE_max=max_dilepton_mass,
         adocachi2cut=adocachi2cut,
-        bpvvdchi2=bpvvdchi2,
         vfaspfchi2ndof=max_vchi2ndof)
     code = require_all(
         in_range(min_dilepton_mass, F.MASS, max_dilepton_mass),
-- 
GitLab


From ae655a25b5871625adac059aee4da295cd8f6abd Mon Sep 17 00:00:00 2001
From: Raja Nandakumar <raja.nandakumar@cern.ch>
Date: Sun, 13 Feb 2022 10:00:59 +0000
Subject: [PATCH 23/26] New lines for Upsilon -> ll analysis

---
 .../python/Hlt2Conf/lines/rd/__init__.py      |   1 +
 .../lines/rd/builders/qqbar_builder.py        | 270 +++++++++++++++---
 .../python/Hlt2Conf/lines/rd/upsilon_to_ll.py | 133 +++++++++
 3 files changed, 364 insertions(+), 40 deletions(-)
 create mode 100644 Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/upsilon_to_ll.py

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py
index 0b082eb9211..f1354bdbbe8 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py
@@ -28,3 +28,4 @@ all_lines.update(b_to_hhhgamma_gamma_to_ee.all_lines)
 all_lines.update(qqbar_to_emu.all_lines)
 all_lines.update(B2ll_lines.all_lines)
 all_lines.update(strange_lines)
+all_lines.update(upsilon_to_ll.all_lines)
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
index 8091faeb018..cf48dfda1a3 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
@@ -26,32 +26,39 @@ from GaudiKernel.SystemOfUnits import MeV, GeV
 
 from RecoConf.reconstruction_objects import make_pvs_v2 as make_pvs
 
-from Hlt2Conf.algorithms_thor import require_all, ParticleFilter
+from Hlt2Conf.algorithms_thor import require_all, ParticleFilter, ParticleCombiner
 from PyConf import configurable
+from Hlt2Conf.algorithms import ParticleCombinerWithPVs
+from Hlt2Conf.lines.rd.builders.rdbuilder_thor import make_rd_tauons_hadronic_decay
 
-from Hlt2Conf.standard_particles import make_detached_mue_with_brem, make_detached_dielectron_with_brem
+from Hlt2Conf.standard_particles import (
+    make_detached_mue_with_brem, make_detached_dielectron_with_brem, make_detached_mumu,
+    make_long_electrons_with_brem, make_ismuon_long_muon
+)
 
 
-#filter based on the rd_detached_mue / make_detached_mue_with_brem with zero cuts on IP and added combination cuts
+
+# filter based on the rd_detached_mue / make_detached_mue_with_brem with zero cuts on IP and added combination cuts
 @configurable
 def make_prompt_mue(
-        name="prompt_mue_builder",
-        min_dilepton_mass=0. * MeV,
-        max_dilepton_mass=6000. * MeV,
-        min_dilepton_pt=1.0 * GeV,
-        max_ipchi2_mue=50,
-        parent_id='J/psi(1S)',
-        min_probnn_mu=0.,
-        min_PIDmu=0.,
-        IsMuon=True,
-        min_PIDe=2.,
-        min_pt_e=0.5 * GeV,
-        min_pt_mu=0.5 * GeV,
-        minipchi2=0,  #must be 0 for a prompt builder
-        min_bpvvdchi2=0.,  #must be 0 for a prompt builder
-        max_vchi2ndof=10.,
-        max_trghostprob=0.2,
-        same_sign=False):
+    name="prompt_mue_builder",
+    min_dilepton_mass=0.0 * MeV,
+    max_dilepton_mass=6000.0 * MeV,
+    min_dilepton_pt=1.0 * GeV,
+    max_ipchi2_mue=50,
+    parent_id="J/psi(1S)",
+    min_probnn_mu=0.0,
+    min_PIDmu=0.0,
+    IsMuon=True,
+    min_PIDe=2.0,
+    min_pt_e=0.5 * GeV,
+    min_pt_mu=0.5 * GeV,
+    minipchi2=0,  # must be 0 for a prompt builder
+    min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
+    max_vchi2ndof=10.0,
+    max_trghostprob=0.2,
+    same_sign=False,
+):
     """
     Make the detached muon-electron pair, opposite-sign or same-sign.
     """
@@ -59,7 +66,7 @@ def make_prompt_mue(
     dileptons = make_detached_mue_with_brem(
         dilepton_ID=parent_id,
         min_probnn_mu=min_probnn_mu,
-        min_PIDmu=0.,
+        min_PIDmu=0.0,
         IsMuon=IsMuon,
         min_PIDe=min_PIDe,
         same_sign=same_sign,
@@ -68,29 +75,210 @@ def make_prompt_mue(
         minipchi2_track=minipchi2,
         min_bpvvdchi2=min_bpvvdchi2,
         max_vchi2ndof=max_vchi2ndof,
-        max_trghostprob=max_trghostprob)
+        max_trghostprob=max_trghostprob,
+    )
     code = require_all(
         in_range(min_dilepton_mass, F.MASS, max_dilepton_mass),
         F.PT > min_dilepton_pt,
-        F.BPVIPCHI2(pvs) < max_ipchi2_mue)
+        F.BPVIPCHI2(pvs) < max_ipchi2_mue,
+    )
     return ParticleFilter(dileptons, F.FILTER(code), name=name)
 
+@configurable
+def make_prompt_etau(
+    name="prompt_mue_builder",
+    min_dilepton_mass=7000.0 * MeV,
+    max_dilepton_mass=13000.0 * MeV,
+    min_dilepton_pt=1.0 * GeV,
+    max_ipchi2_etau=50,
+    parent_id="Upsilon(1S)",
+    min_PIDe=2.0,
+    max_adocachi2=30.,
+    min_pt_e=0.5 * GeV,
+    min_pt_tau=0.3*GeV,
+    minipchi2=0,  # must be 0 for a prompt builder
+    min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
+    max_vchi2ndof=10.0,
+):
+    """
+    Make the detached electron-tau pair, opposite-sign for now.
+    """
+    pvs = make_pvs()
+    descriptor = "[{} -> e+ tau-]cc".format(parent_id)
+    taus = make_rd_tauons_hadronic_decay(best_pi_ipchi2_min=minipchi2) # Make them prompt(?)
+    electrons = make_long_electrons_with_brem()
+    daughters_code = {
+        'tau+': f'(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})', # Do we need to add a minipchi2 to the taus also for promptness?
+        'tau-': f'(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
+        'e+': f'(PIDe > {min_PIDe}) & (PT > {min_pt_e}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
+        'e-': f'(PIDe > {min_PIDe}) & (PT > {min_pt_e}) & (MIPCHI2DV(PRIMARY) > {minipchi2})'
+    }
+    combination_code = f"ADOCACHI2CUT({max_adocachi2}, '')"
+    vertex_code = f"(VFASPF(VCHI2/VDOF) < {max_vchi2ndof}) & (BPVVDCHI2() > {min_bpvvdchi2})"
+    etau = ParticleCombinerWithPVs(
+        particles=[electrons, taus],
+        pvs=pvs,
+        DaughtersCuts=daughters_code,
+        DecayDescriptor=descriptor,
+        CombinationCut = combination_code,
+        MotherCut = vertex_code
+    )
+    code = require_all(
+        in_range(min_dilepton_mass, F.MASS, max_dilepton_mass),
+        F.PT > min_dilepton_pt,
+        F.BPVIPCHI2(pvs) < max_ipchi2_etau,
+    )
+    return ParticleFilter(etau, F.FILTER(code), name=name)
 
 @configurable
-def make_prompt_ee(
-        name="prompt_ee_builder",
-        opposite_sign=True,
-        PIDe_min=2.,
-        pt_e=0.5 * GeV,
-        minipchi2=0,  #must be 0 for a prompt builder
-        max_ipchi2_ee=50,
-        trghostprob=0.2,
-        parent_id="J/psi(1S)",
-        min_dilepton_pt=0 * GeV,
-        min_dilepton_mass=0 * MeV,
-        max_dilepton_mass=6000 * MeV,
+def make_prompt_mutau(
+    name="prompt_mue_builder",
+    min_dilepton_mass=7000.0 * MeV,
+    max_dilepton_mass=13000.0 * MeV,
+    min_dilepton_pt=1.0 * GeV,
+    max_ipchi2_mutau=50,
+    parent_id="Upsilon(1S)",
+        min_probnn_mu=0.2,
+        min_PIDmu=0.,
+        IsMuon=False,
+        min_pt_mu=0. * GeV,
+    max_adocachi2=30.,
+    min_pt_tau=0.3*GeV,
+    minipchi2=0,  # must be 0 for a prompt builder
+    min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
+    max_vchi2ndof=10.0,
+):
+    """
+    Make the detached electron-tau pair, opposite-sign for now.
+    """
+    pvs = make_pvs()
+    descriptor = "[{} -> mu+ tau-]cc".format(parent_id)
+    taus = make_rd_tauons_hadronic_decay(best_pi_ipchi2_min=minipchi2) # Make them prompt(?)
+    muons = make_ismuon_long_muon()
+    daughters_code = {
+        'tau+': f'(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})', # Do we need to add a minipchi2 to the taus also for promptness?
+        'tau-': f'(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
+        'mu+':
+            f'(PROBNNmu > {min_probnn_mu}) & (PIDmu > {min_PIDmu}) & (PT > {min_pt_mu}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
+        'mu-':
+            f'(PROBNNmu > {min_probnn_mu}) & (PIDmu > {min_PIDmu}) & (PT > {min_pt_mu}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
+    }
+    if IsMuon:
+        daughters_code["mu+"] = daughters_code["mu+"] + " & ISMUON"
+        daughters_code["mu-"] = daughters_code["mu-"] + " & ISMUON"
+    combination_code = f"ADOCACHI2CUT({max_adocachi2}, '')"
+    vertex_code = f"(VFASPF(VCHI2/VDOF) < {max_vchi2ndof}) & (BPVVDCHI2() > {min_bpvvdchi2})"
+    mutau = ParticleCombinerWithPVs(
+        particles=[muons, taus],
+        pvs=pvs,
+        DaughtersCuts=daughters_code,
+        DecayDescriptor=descriptor,
+        CombinationCut = combination_code,
+        MotherCut = vertex_code
+    )
+    code = require_all(
+        in_range(min_dilepton_mass, F.MASS, max_dilepton_mass),
+        F.PT > min_dilepton_pt,
+        F.BPVIPCHI2(pvs) < max_ipchi2_mutau,
+    )
+    return ParticleFilter(mutau, F.FILTER(code), name=name)
+
+@configurable
+def make_prompt_tautau(
+    name="prompt_tautau_builder",
+    min_dilepton_mass=7000.0 * MeV,
+    max_dilepton_mass=13000.0 * MeV,
+    min_dilepton_pt=1.0 * GeV,
+    max_ipchi2_tautau=50,
+    max_adocachi2=30.,
+    parent_id="Upsilon(1S)",
+    min_pt_tau=0.3*GeV,
+    minipchi2=0,  # must be 0 for a prompt builder
+    min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
+    max_vchi2ndof=10.0,
+):
+    """
+    Make the detached muon-electron pair, opposite-sign or same-sign.
+    """
+    pvs = make_pvs()
+    taus = make_rd_tauons_hadronic_decay(best_pi_ipchi2_min=minipchi2) # Make them prompt(?)
+    descriptor = "{} -> tau+ tau-".format(parent_id)
+    combination_code = f"ADOCACHI2CUT({max_adocachi2}, '')"
+    vertex_code = f"(VFASPF(VCHI2/VDOF) < {max_vchi2ndof}) & (BPVVDCHI2() > {min_bpvvdchi2})"
+    daughters_code = {
+        'tau+': f'(PT > {min_pt_tau})', # Do we need to add a minipchi2 to the taus also for promptness?
+        'tau-': f'(PT > {min_pt_tau})'
+    }
+    tautau = ParticleCombinerWithPVs(
+        particles=[taus, taus],
+        pvs=pvs,
+        DaughtersCuts=daughters_code,
+        DecayDescriptor=descriptor,
+        CombinationCut = combination_code,
+        MotherCut = vertex_code
+    )
+
+    code = require_all(
+        in_range(min_dilepton_mass, F.MASS, max_dilepton_mass),
+        F.PT > min_dilepton_pt,
+        F.BPVIPCHI2(pvs) < max_ipchi2_tautau,
+    )
+    return ParticleFilter(tautau, F.FILTER(code), name=name)
+
+
+# filter based on the rd_detached_mue / make_detached_mue_with_brem with zero cuts on IP and added combination cuts
+@configurable
+def make_prompt_mumu(
+    name="prompt_mumu_builder",
+    min_dilepton_mass=0.0 * MeV,
+    max_dilepton_mass=6000.0 * MeV,
+    min_dilepton_pt=1.0 * GeV,
+    max_ipchi2_mumu=50,
+    parent_id="J/psi(1S)",
+    min_probnn_mu=0.0,
+    IsMuon=True,
+    min_pt_mu=0.5 * GeV,
+    minipchi2=0,  # must be 0 for a prompt builder
+    min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
+    max_trghostprob=0.2,
+):
+    """
+    Make the detached muon-electron pair, opposite-sign or same-sign.
+    """
+    pvs = make_pvs()
+    dileptons = make_detached_mumu(
         adocachi2cut=30,
-        max_vchi2ndof=7.5):
+        vfaspfchi2ndof=10,
+        probnn_mu=min_probnn_mu,
+        pt_mu=min_pt_mu,
+        minipchi2=minipchi2,
+        bpvvdchi2=min_bpvvdchi2,
+        trghostprob=max_trghostprob,
+    )
+    code = require_all(
+        in_range(min_dilepton_mass, F.MASS, max_dilepton_mass),
+        F.PT > min_dilepton_pt,
+        F.BPVIPCHI2(pvs) < max_ipchi2_mumu,
+    )
+    return ParticleFilter(dileptons, F.FILTER(code), name=name)
+
+
+@configurable
+def make_prompt_ee(
+    name="prompt_ee_builder",
+    opposite_sign=True,
+    PIDe_min=2.0,
+    pt_e=0.5 * GeV,
+    minipchi2=0,  # must be 0 for a prompt builder
+    max_ipchi2_ee=50,
+    trghostprob=0.2,
+    parent_id="J/psi(1S)",
+    min_dilepton_pt=0 * GeV,
+    min_dilepton_mass=0 * MeV,
+    max_dilepton_mass=6000 * MeV,
+    adocachi2cut=30,
+    max_vchi2ndof=7.5,
+):
     """
     Make the detached muon-electron pair, opposite-sign or same-sign.
     """
@@ -106,11 +294,13 @@ def make_prompt_ee(
         m_diE_min=min_dilepton_mass,
         m_diE_max=max_dilepton_mass,
         adocachi2cut=adocachi2cut,
-        vfaspfchi2ndof=max_vchi2ndof)
+        vfaspfchi2ndof=max_vchi2ndof,
+    )
     code = require_all(
         in_range(min_dilepton_mass, F.MASS, max_dilepton_mass),
         F.PT > min_dilepton_pt,
-        F.BPVIPCHI2(pvs) < max_ipchi2_ee)
+        F.BPVIPCHI2(pvs) < max_ipchi2_ee,
+    )
     return ParticleFilter(dileptons, F.FILTER(code), name=name)
 
 
@@ -136,7 +326,7 @@ def make_prompt_long_electrons(pvs,
                        F.MINIP(pvs) > min_ip_electron,
                        F.PID_MU > min_pid_electron,
                        F.GHOSTPROB < max_ghostprob_electron)
-    
+
     if max_trackchi2_electron is not None:
         code &= (F.CHI2 < max_trackchi2_electron)
     if max_ipchi2_electron is not None:
@@ -164,7 +354,7 @@ def make_prompt_long_muons(pvs,
                        F.MINIPCHI2(pvs) > min_ipchi2_muon,
                        F.MINIP(pvs) > min_ip_muon, F.PID_MU > min_pid_muon,
                        F.GHOSTPROB < max_ghostprob_muon)
-    
+
     if max_trackchi2_muon is not None:
         code &= (F.CHI2 < max_trackchi2_muon)
     if max_ipchi2_muon is not None:
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/upsilon_to_ll.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/upsilon_to_ll.py
new file mode 100644
index 00000000000..b8e1f45db7f
--- /dev/null
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/upsilon_to_ll.py
@@ -0,0 +1,133 @@
+###############################################################################
+# (c) Copyright 2021 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.                                       #
+###############################################################################
+"""
+Registration of B2ll(')(gamma) lines for the RD working group.
+It contains also B2HH as this is an important normalisation.
+- Upsilon -> e e
+- Upsilon -> mumu
+
+author: Raja Nandakumar, Fergus Wilson
+date: 31.01.2022
+"""
+
+from Moore.config import HltLine, register_line_builder
+from Moore.lines import Hlt2Line
+from GaudiKernel.SystemOfUnits import MeV, GeV
+from PyConf import configurable
+
+from RecoConf.reconstruction_objects import upfront_reconstruction
+
+from Hlt2Conf.algorithms_thor import require_all, ParticleCombiner, ParticleFilter
+from Hlt2Conf.standard_particles import make_has_rich_long_pions, make_has_rich_up_pions
+from Hlt2Conf.lines.rd.builders.qqbar_builder import make_prompt_mumu, make_prompt_ee, make_prompt_tautau
+from Hlt2Conf.lines.rd.builders.qqbar_builder import make_prompt_etau, make_prompt_mutau
+
+all_lines = {}
+
+
+@register_line_builder(all_lines)
+@configurable
+def Hlt2RD_UpsilonToEE_Line( name="Hlt2RD_UpsilonToEE_Line", prescale=1, persistreco=False ):
+
+    ee = make_prompt_ee(
+        name="Hlt2RD_UpsilonToEE_Builder",
+        parent_id="Upsilon(1S)",
+        opposite_sign=True,
+        min_dilepton_mass=7000.0 * MeV,
+        max_dilepton_mass=13000.0 * MeV,
+        min_dilepton_pt=1.0 * GeV,
+        pt_e=1.0 * GeV,  # The minimum Pt
+    )
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + [ee],
+        prescale=prescale,
+        persistreco=persistreco,
+    )
+
+
+@register_line_builder(all_lines)
+@configurable
+def Hlt2RD_UpsilonToMuMu_Line( name="Hlt2RD_UpsilonToMuMu_Line", prescale=1, persistreco=False ):
+
+    mumu = make_prompt_mumu(
+        name="Hlt2RD_UpsilonToMuMu_Builder",
+        parent_id="Upsilon(1S)",
+        min_dilepton_mass=7000.0 * MeV,
+        max_dilepton_mass=13000.0 * MeV,
+        min_dilepton_pt=1.0 * GeV,
+        min_pt_mu=1.0 * GeV,
+    )
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + [mumu],
+        prescale=prescale,
+        persistreco=persistreco,
+    )
+
+@register_line_builder(all_lines)
+@configurable
+def Hlt2RD_UpsilonToTauTau_Line( name="Hlt2RD_UpsilonToTauTau_Line", prescale=1, persistreco=False ):
+
+    tautau = make_prompt_tautau(
+        name="Hlt2RD_UpsilonToTauTau_Builder",
+        parent_id="Upsilon(1S)",
+        min_dilepton_mass=7000.0 * MeV,
+        max_dilepton_mass=13000.0 * MeV,
+        min_dilepton_pt=1.0 * GeV,
+    )
+
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + [tautau],
+        prescale=prescale,
+        persistreco=persistreco,
+    )
+
+@register_line_builder(all_lines)
+@configurable
+def Hlt2RD_UpsilonToeTau_Line( name="Hlt2RD_UpsilonToeTau_Line", prescale=1, persistreco=False ):
+
+    etau = make_prompt_etau(
+        name="Hlt2RD_UpsilonToeTau_Builder",
+        parent_id="Upsilon(1S)",
+        min_dilepton_mass=7000.0 * MeV,
+        max_dilepton_mass=13000.0 * MeV,
+        min_dilepton_pt=1.0 * GeV,
+        min_pt_e=1.0 * GeV,
+    )
+
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + [etau],
+        prescale=prescale,
+        persistreco=persistreco,
+    )
+
+@register_line_builder(all_lines)
+@configurable
+def Hlt2RD_UpsilonTomuTau_Line( name="Hlt2RD_UpsilonTomuTau_Line", prescale=1, persistreco=False ):
+
+    mutau = make_prompt_mutau(
+        name="Hlt2RD_UpsilonTomuTau_Builder",
+        parent_id="Upsilon(1S)",
+        min_dilepton_mass=7000.0 * MeV,
+        max_dilepton_mass=13000.0 * MeV,
+        min_dilepton_pt=1.0 * GeV,
+        min_pt_mu=1.0 * GeV,
+    )
+
+    return Hlt2Line(
+        name=name,
+        algs=upfront_reconstruction() + [mutau],
+        prescale=prescale,
+        persistreco=persistreco,
+    )
-- 
GitLab


From b64018bd131af6b504e14c3c512e28c1640a9ec8 Mon Sep 17 00:00:00 2001
From: Raja Nandakumar <raja.nandakumar@cern.ch>
Date: Sun, 13 Feb 2022 10:02:25 +0000
Subject: [PATCH 24/26] New lines for Upsilon -> ll analysis - update comment

---
 Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/upsilon_to_ll.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/upsilon_to_ll.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/upsilon_to_ll.py
index b8e1f45db7f..3445dd23349 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/upsilon_to_ll.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/upsilon_to_ll.py
@@ -9,10 +9,13 @@
 # or submit itself to any jurisdiction.                                       #
 ###############################################################################
 """
-Registration of B2ll(')(gamma) lines for the RD working group.
+Registration of Upsilon to ll(')(gamma) lines for the RD working group.
 It contains also B2HH as this is an important normalisation.
 - Upsilon -> e e
 - Upsilon -> mumu
+- Upsilon -> tautau
+- Upsilon -> etau
+- Upsilon -> mutau
 
 author: Raja Nandakumar, Fergus Wilson
 date: 31.01.2022
-- 
GitLab


From 22344d1686c00487c3b6ced21a5596ef16557156 Mon Sep 17 00:00:00 2001
From: Gitlab CI <noreply@cern.ch>
Date: Sun, 13 Feb 2022 10:21:00 +0000
Subject: [PATCH 25/26] Fixed formatting

patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/19487836
---
 .../lines/rd/builders/qqbar_builder.py        | 212 +++++++++---------
 .../python/Hlt2Conf/lines/rd/upsilon_to_ll.py |  23 +-
 2 files changed, 128 insertions(+), 107 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
index cf48dfda1a3..d13f3c59fc4 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
@@ -32,32 +32,30 @@ from Hlt2Conf.algorithms import ParticleCombinerWithPVs
 from Hlt2Conf.lines.rd.builders.rdbuilder_thor import make_rd_tauons_hadronic_decay
 
 from Hlt2Conf.standard_particles import (
-    make_detached_mue_with_brem, make_detached_dielectron_with_brem, make_detached_mumu,
-    make_long_electrons_with_brem, make_ismuon_long_muon
-)
-
+    make_detached_mue_with_brem, make_detached_dielectron_with_brem,
+    make_detached_mumu, make_long_electrons_with_brem, make_ismuon_long_muon)
 
 
 # filter based on the rd_detached_mue / make_detached_mue_with_brem with zero cuts on IP and added combination cuts
 @configurable
 def make_prompt_mue(
-    name="prompt_mue_builder",
-    min_dilepton_mass=0.0 * MeV,
-    max_dilepton_mass=6000.0 * MeV,
-    min_dilepton_pt=1.0 * GeV,
-    max_ipchi2_mue=50,
-    parent_id="J/psi(1S)",
-    min_probnn_mu=0.0,
-    min_PIDmu=0.0,
-    IsMuon=True,
-    min_PIDe=2.0,
-    min_pt_e=0.5 * GeV,
-    min_pt_mu=0.5 * GeV,
-    minipchi2=0,  # must be 0 for a prompt builder
-    min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
-    max_vchi2ndof=10.0,
-    max_trghostprob=0.2,
-    same_sign=False,
+        name="prompt_mue_builder",
+        min_dilepton_mass=0.0 * MeV,
+        max_dilepton_mass=6000.0 * MeV,
+        min_dilepton_pt=1.0 * GeV,
+        max_ipchi2_mue=50,
+        parent_id="J/psi(1S)",
+        min_probnn_mu=0.0,
+        min_PIDmu=0.0,
+        IsMuon=True,
+        min_PIDe=2.0,
+        min_pt_e=0.5 * GeV,
+        min_pt_mu=0.5 * GeV,
+        minipchi2=0,  # must be 0 for a prompt builder
+        min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
+        max_vchi2ndof=10.0,
+        max_trghostprob=0.2,
+        same_sign=False,
 ):
     """
     Make the detached muon-electron pair, opposite-sign or same-sign.
@@ -84,34 +82,40 @@ def make_prompt_mue(
     )
     return ParticleFilter(dileptons, F.FILTER(code), name=name)
 
+
 @configurable
 def make_prompt_etau(
-    name="prompt_mue_builder",
-    min_dilepton_mass=7000.0 * MeV,
-    max_dilepton_mass=13000.0 * MeV,
-    min_dilepton_pt=1.0 * GeV,
-    max_ipchi2_etau=50,
-    parent_id="Upsilon(1S)",
-    min_PIDe=2.0,
-    max_adocachi2=30.,
-    min_pt_e=0.5 * GeV,
-    min_pt_tau=0.3*GeV,
-    minipchi2=0,  # must be 0 for a prompt builder
-    min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
-    max_vchi2ndof=10.0,
+        name="prompt_mue_builder",
+        min_dilepton_mass=7000.0 * MeV,
+        max_dilepton_mass=13000.0 * MeV,
+        min_dilepton_pt=1.0 * GeV,
+        max_ipchi2_etau=50,
+        parent_id="Upsilon(1S)",
+        min_PIDe=2.0,
+        max_adocachi2=30.,
+        min_pt_e=0.5 * GeV,
+        min_pt_tau=0.3 * GeV,
+        minipchi2=0,  # must be 0 for a prompt builder
+        min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
+        max_vchi2ndof=10.0,
 ):
     """
     Make the detached electron-tau pair, opposite-sign for now.
     """
     pvs = make_pvs()
     descriptor = "[{} -> e+ tau-]cc".format(parent_id)
-    taus = make_rd_tauons_hadronic_decay(best_pi_ipchi2_min=minipchi2) # Make them prompt(?)
+    taus = make_rd_tauons_hadronic_decay(
+        best_pi_ipchi2_min=minipchi2)  # Make them prompt(?)
     electrons = make_long_electrons_with_brem()
     daughters_code = {
-        'tau+': f'(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})', # Do we need to add a minipchi2 to the taus also for promptness?
-        'tau-': f'(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
-        'e+': f'(PIDe > {min_PIDe}) & (PT > {min_pt_e}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
-        'e-': f'(PIDe > {min_PIDe}) & (PT > {min_pt_e}) & (MIPCHI2DV(PRIMARY) > {minipchi2})'
+        'tau+':
+        f'(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',  # Do we need to add a minipchi2 to the taus also for promptness?
+        'tau-':
+        f'(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
+        'e+':
+        f'(PIDe > {min_PIDe}) & (PT > {min_pt_e}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
+        'e-':
+        f'(PIDe > {min_PIDe}) & (PT > {min_pt_e}) & (MIPCHI2DV(PRIMARY) > {minipchi2})'
     }
     combination_code = f"ADOCACHI2CUT({max_adocachi2}, '')"
     vertex_code = f"(VFASPF(VCHI2/VDOF) < {max_vchi2ndof}) & (BPVVDCHI2() > {min_bpvvdchi2})"
@@ -120,9 +124,8 @@ def make_prompt_etau(
         pvs=pvs,
         DaughtersCuts=daughters_code,
         DecayDescriptor=descriptor,
-        CombinationCut = combination_code,
-        MotherCut = vertex_code
-    )
+        CombinationCut=combination_code,
+        MotherCut=vertex_code)
     code = require_all(
         in_range(min_dilepton_mass, F.MASS, max_dilepton_mass),
         F.PT > min_dilepton_pt,
@@ -130,38 +133,42 @@ def make_prompt_etau(
     )
     return ParticleFilter(etau, F.FILTER(code), name=name)
 
+
 @configurable
 def make_prompt_mutau(
-    name="prompt_mue_builder",
-    min_dilepton_mass=7000.0 * MeV,
-    max_dilepton_mass=13000.0 * MeV,
-    min_dilepton_pt=1.0 * GeV,
-    max_ipchi2_mutau=50,
-    parent_id="Upsilon(1S)",
+        name="prompt_mue_builder",
+        min_dilepton_mass=7000.0 * MeV,
+        max_dilepton_mass=13000.0 * MeV,
+        min_dilepton_pt=1.0 * GeV,
+        max_ipchi2_mutau=50,
+        parent_id="Upsilon(1S)",
         min_probnn_mu=0.2,
         min_PIDmu=0.,
         IsMuon=False,
         min_pt_mu=0. * GeV,
-    max_adocachi2=30.,
-    min_pt_tau=0.3*GeV,
-    minipchi2=0,  # must be 0 for a prompt builder
-    min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
-    max_vchi2ndof=10.0,
+        max_adocachi2=30.,
+        min_pt_tau=0.3 * GeV,
+        minipchi2=0,  # must be 0 for a prompt builder
+        min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
+        max_vchi2ndof=10.0,
 ):
     """
     Make the detached electron-tau pair, opposite-sign for now.
     """
     pvs = make_pvs()
     descriptor = "[{} -> mu+ tau-]cc".format(parent_id)
-    taus = make_rd_tauons_hadronic_decay(best_pi_ipchi2_min=minipchi2) # Make them prompt(?)
+    taus = make_rd_tauons_hadronic_decay(
+        best_pi_ipchi2_min=minipchi2)  # Make them prompt(?)
     muons = make_ismuon_long_muon()
     daughters_code = {
-        'tau+': f'(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})', # Do we need to add a minipchi2 to the taus also for promptness?
-        'tau-': f'(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
+        'tau+':
+        f'(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',  # Do we need to add a minipchi2 to the taus also for promptness?
+        'tau-':
+        f'(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
         'mu+':
-            f'(PROBNNmu > {min_probnn_mu}) & (PIDmu > {min_PIDmu}) & (PT > {min_pt_mu}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
+        f'(PROBNNmu > {min_probnn_mu}) & (PIDmu > {min_PIDmu}) & (PT > {min_pt_mu}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
         'mu-':
-            f'(PROBNNmu > {min_probnn_mu}) & (PIDmu > {min_PIDmu}) & (PT > {min_pt_mu}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
+        f'(PROBNNmu > {min_probnn_mu}) & (PIDmu > {min_PIDmu}) & (PT > {min_pt_mu}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
     }
     if IsMuon:
         daughters_code["mu+"] = daughters_code["mu+"] + " & ISMUON"
@@ -173,9 +180,8 @@ def make_prompt_mutau(
         pvs=pvs,
         DaughtersCuts=daughters_code,
         DecayDescriptor=descriptor,
-        CombinationCut = combination_code,
-        MotherCut = vertex_code
-    )
+        CombinationCut=combination_code,
+        MotherCut=vertex_code)
     code = require_all(
         in_range(min_dilepton_mass, F.MASS, max_dilepton_mass),
         F.PT > min_dilepton_pt,
@@ -183,30 +189,33 @@ def make_prompt_mutau(
     )
     return ParticleFilter(mutau, F.FILTER(code), name=name)
 
+
 @configurable
 def make_prompt_tautau(
-    name="prompt_tautau_builder",
-    min_dilepton_mass=7000.0 * MeV,
-    max_dilepton_mass=13000.0 * MeV,
-    min_dilepton_pt=1.0 * GeV,
-    max_ipchi2_tautau=50,
-    max_adocachi2=30.,
-    parent_id="Upsilon(1S)",
-    min_pt_tau=0.3*GeV,
-    minipchi2=0,  # must be 0 for a prompt builder
-    min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
-    max_vchi2ndof=10.0,
+        name="prompt_tautau_builder",
+        min_dilepton_mass=7000.0 * MeV,
+        max_dilepton_mass=13000.0 * MeV,
+        min_dilepton_pt=1.0 * GeV,
+        max_ipchi2_tautau=50,
+        max_adocachi2=30.,
+        parent_id="Upsilon(1S)",
+        min_pt_tau=0.3 * GeV,
+        minipchi2=0,  # must be 0 for a prompt builder
+        min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
+        max_vchi2ndof=10.0,
 ):
     """
     Make the detached muon-electron pair, opposite-sign or same-sign.
     """
     pvs = make_pvs()
-    taus = make_rd_tauons_hadronic_decay(best_pi_ipchi2_min=minipchi2) # Make them prompt(?)
+    taus = make_rd_tauons_hadronic_decay(
+        best_pi_ipchi2_min=minipchi2)  # Make them prompt(?)
     descriptor = "{} -> tau+ tau-".format(parent_id)
     combination_code = f"ADOCACHI2CUT({max_adocachi2}, '')"
     vertex_code = f"(VFASPF(VCHI2/VDOF) < {max_vchi2ndof}) & (BPVVDCHI2() > {min_bpvvdchi2})"
     daughters_code = {
-        'tau+': f'(PT > {min_pt_tau})', # Do we need to add a minipchi2 to the taus also for promptness?
+        'tau+':
+        f'(PT > {min_pt_tau})',  # Do we need to add a minipchi2 to the taus also for promptness?
         'tau-': f'(PT > {min_pt_tau})'
     }
     tautau = ParticleCombinerWithPVs(
@@ -214,9 +223,8 @@ def make_prompt_tautau(
         pvs=pvs,
         DaughtersCuts=daughters_code,
         DecayDescriptor=descriptor,
-        CombinationCut = combination_code,
-        MotherCut = vertex_code
-    )
+        CombinationCut=combination_code,
+        MotherCut=vertex_code)
 
     code = require_all(
         in_range(min_dilepton_mass, F.MASS, max_dilepton_mass),
@@ -229,18 +237,18 @@ def make_prompt_tautau(
 # filter based on the rd_detached_mue / make_detached_mue_with_brem with zero cuts on IP and added combination cuts
 @configurable
 def make_prompt_mumu(
-    name="prompt_mumu_builder",
-    min_dilepton_mass=0.0 * MeV,
-    max_dilepton_mass=6000.0 * MeV,
-    min_dilepton_pt=1.0 * GeV,
-    max_ipchi2_mumu=50,
-    parent_id="J/psi(1S)",
-    min_probnn_mu=0.0,
-    IsMuon=True,
-    min_pt_mu=0.5 * GeV,
-    minipchi2=0,  # must be 0 for a prompt builder
-    min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
-    max_trghostprob=0.2,
+        name="prompt_mumu_builder",
+        min_dilepton_mass=0.0 * MeV,
+        max_dilepton_mass=6000.0 * MeV,
+        min_dilepton_pt=1.0 * GeV,
+        max_ipchi2_mumu=50,
+        parent_id="J/psi(1S)",
+        min_probnn_mu=0.0,
+        IsMuon=True,
+        min_pt_mu=0.5 * GeV,
+        minipchi2=0,  # must be 0 for a prompt builder
+        min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
+        max_trghostprob=0.2,
 ):
     """
     Make the detached muon-electron pair, opposite-sign or same-sign.
@@ -265,19 +273,19 @@ def make_prompt_mumu(
 
 @configurable
 def make_prompt_ee(
-    name="prompt_ee_builder",
-    opposite_sign=True,
-    PIDe_min=2.0,
-    pt_e=0.5 * GeV,
-    minipchi2=0,  # must be 0 for a prompt builder
-    max_ipchi2_ee=50,
-    trghostprob=0.2,
-    parent_id="J/psi(1S)",
-    min_dilepton_pt=0 * GeV,
-    min_dilepton_mass=0 * MeV,
-    max_dilepton_mass=6000 * MeV,
-    adocachi2cut=30,
-    max_vchi2ndof=7.5,
+        name="prompt_ee_builder",
+        opposite_sign=True,
+        PIDe_min=2.0,
+        pt_e=0.5 * GeV,
+        minipchi2=0,  # must be 0 for a prompt builder
+        max_ipchi2_ee=50,
+        trghostprob=0.2,
+        parent_id="J/psi(1S)",
+        min_dilepton_pt=0 * GeV,
+        min_dilepton_mass=0 * MeV,
+        max_dilepton_mass=6000 * MeV,
+        adocachi2cut=30,
+        max_vchi2ndof=7.5,
 ):
     """
     Make the detached muon-electron pair, opposite-sign or same-sign.
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/upsilon_to_ll.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/upsilon_to_ll.py
index 3445dd23349..bbd7313d059 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/upsilon_to_ll.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/upsilon_to_ll.py
@@ -38,7 +38,9 @@ all_lines = {}
 
 @register_line_builder(all_lines)
 @configurable
-def Hlt2RD_UpsilonToEE_Line( name="Hlt2RD_UpsilonToEE_Line", prescale=1, persistreco=False ):
+def Hlt2RD_UpsilonToEE_Line(name="Hlt2RD_UpsilonToEE_Line",
+                            prescale=1,
+                            persistreco=False):
 
     ee = make_prompt_ee(
         name="Hlt2RD_UpsilonToEE_Builder",
@@ -59,7 +61,9 @@ def Hlt2RD_UpsilonToEE_Line( name="Hlt2RD_UpsilonToEE_Line", prescale=1, persist
 
 @register_line_builder(all_lines)
 @configurable
-def Hlt2RD_UpsilonToMuMu_Line( name="Hlt2RD_UpsilonToMuMu_Line", prescale=1, persistreco=False ):
+def Hlt2RD_UpsilonToMuMu_Line(name="Hlt2RD_UpsilonToMuMu_Line",
+                              prescale=1,
+                              persistreco=False):
 
     mumu = make_prompt_mumu(
         name="Hlt2RD_UpsilonToMuMu_Builder",
@@ -76,9 +80,12 @@ def Hlt2RD_UpsilonToMuMu_Line( name="Hlt2RD_UpsilonToMuMu_Line", prescale=1, per
         persistreco=persistreco,
     )
 
+
 @register_line_builder(all_lines)
 @configurable
-def Hlt2RD_UpsilonToTauTau_Line( name="Hlt2RD_UpsilonToTauTau_Line", prescale=1, persistreco=False ):
+def Hlt2RD_UpsilonToTauTau_Line(name="Hlt2RD_UpsilonToTauTau_Line",
+                                prescale=1,
+                                persistreco=False):
 
     tautau = make_prompt_tautau(
         name="Hlt2RD_UpsilonToTauTau_Builder",
@@ -95,9 +102,12 @@ def Hlt2RD_UpsilonToTauTau_Line( name="Hlt2RD_UpsilonToTauTau_Line", prescale=1,
         persistreco=persistreco,
     )
 
+
 @register_line_builder(all_lines)
 @configurable
-def Hlt2RD_UpsilonToeTau_Line( name="Hlt2RD_UpsilonToeTau_Line", prescale=1, persistreco=False ):
+def Hlt2RD_UpsilonToeTau_Line(name="Hlt2RD_UpsilonToeTau_Line",
+                              prescale=1,
+                              persistreco=False):
 
     etau = make_prompt_etau(
         name="Hlt2RD_UpsilonToeTau_Builder",
@@ -115,9 +125,12 @@ def Hlt2RD_UpsilonToeTau_Line( name="Hlt2RD_UpsilonToeTau_Line", prescale=1, per
         persistreco=persistreco,
     )
 
+
 @register_line_builder(all_lines)
 @configurable
-def Hlt2RD_UpsilonTomuTau_Line( name="Hlt2RD_UpsilonTomuTau_Line", prescale=1, persistreco=False ):
+def Hlt2RD_UpsilonTomuTau_Line(name="Hlt2RD_UpsilonTomuTau_Line",
+                               prescale=1,
+                               persistreco=False):
 
     mutau = make_prompt_mutau(
         name="Hlt2RD_UpsilonTomuTau_Builder",
-- 
GitLab


From 78ca26f635639bf786a03941eb05eae9fc42aa64 Mon Sep 17 00:00:00 2001
From: Raja Nandakumar <raja.nandakumar@cern.ch>
Date: Sun, 13 Feb 2022 10:35:13 +0000
Subject: [PATCH 26/26] Formatting fixes and import in lines/rd/__init__

---
 .../python/Hlt2Conf/lines/rd/__init__.py      |   1 +
 .../lines/rd/builders/qqbar_builder.py        | 231 +++++++++---------
 .../python/Hlt2Conf/lines/rd/upsilon_to_ll.py |  40 +--
 3 files changed, 141 insertions(+), 131 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py
index f1354bdbbe8..a6bd8e46693 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/__init__.py
@@ -17,6 +17,7 @@ from . import b_to_hhhgamma
 from . import b_to_hhhgamma_gamma_to_ee
 from . import B2ll_lines
 from . import qqbar_to_emu
+from . import upsilon_to_ll
 from .strange import all_lines as strange_lines
 
 # provide "all_lines" for correct registration by the overall HLT2 lines module
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
index d13f3c59fc4..4b104337f03 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/builders/qqbar_builder.py
@@ -26,36 +26,40 @@ from GaudiKernel.SystemOfUnits import MeV, GeV
 
 from RecoConf.reconstruction_objects import make_pvs_v2 as make_pvs
 
-from Hlt2Conf.algorithms_thor import require_all, ParticleFilter, ParticleCombiner
+from Hlt2Conf.algorithms_thor import require_all, ParticleFilter
 from PyConf import configurable
 from Hlt2Conf.algorithms import ParticleCombinerWithPVs
 from Hlt2Conf.lines.rd.builders.rdbuilder_thor import make_rd_tauons_hadronic_decay
 
 from Hlt2Conf.standard_particles import (
-    make_detached_mue_with_brem, make_detached_dielectron_with_brem,
-    make_detached_mumu, make_long_electrons_with_brem, make_ismuon_long_muon)
+    make_detached_mue_with_brem,
+    make_detached_dielectron_with_brem,
+    make_detached_mumu,
+    make_long_electrons_with_brem,
+    make_ismuon_long_muon,
+)
 
 
 # filter based on the rd_detached_mue / make_detached_mue_with_brem with zero cuts on IP and added combination cuts
 @configurable
 def make_prompt_mue(
-        name="prompt_mue_builder",
-        min_dilepton_mass=0.0 * MeV,
-        max_dilepton_mass=6000.0 * MeV,
-        min_dilepton_pt=1.0 * GeV,
-        max_ipchi2_mue=50,
-        parent_id="J/psi(1S)",
-        min_probnn_mu=0.0,
-        min_PIDmu=0.0,
-        IsMuon=True,
-        min_PIDe=2.0,
-        min_pt_e=0.5 * GeV,
-        min_pt_mu=0.5 * GeV,
-        minipchi2=0,  # must be 0 for a prompt builder
-        min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
-        max_vchi2ndof=10.0,
-        max_trghostprob=0.2,
-        same_sign=False,
+    name="prompt_mue_builder",
+    min_dilepton_mass=0.0 * MeV,
+    max_dilepton_mass=6000.0 * MeV,
+    min_dilepton_pt=1.0 * GeV,
+    max_ipchi2_mue=50,
+    parent_id="J/psi(1S)",
+    min_probnn_mu=0.0,
+    min_PIDmu=0.0,
+    IsMuon=True,
+    min_PIDe=2.0,
+    min_pt_e=0.5 * GeV,
+    min_pt_mu=0.5 * GeV,
+    minipchi2=0,  # must be 0 for a prompt builder
+    min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
+    max_vchi2ndof=10.0,
+    max_trghostprob=0.2,
+    same_sign=False,
 ):
     """
     Make the detached muon-electron pair, opposite-sign or same-sign.
@@ -85,19 +89,19 @@ def make_prompt_mue(
 
 @configurable
 def make_prompt_etau(
-        name="prompt_mue_builder",
-        min_dilepton_mass=7000.0 * MeV,
-        max_dilepton_mass=13000.0 * MeV,
-        min_dilepton_pt=1.0 * GeV,
-        max_ipchi2_etau=50,
-        parent_id="Upsilon(1S)",
-        min_PIDe=2.0,
-        max_adocachi2=30.,
-        min_pt_e=0.5 * GeV,
-        min_pt_tau=0.3 * GeV,
-        minipchi2=0,  # must be 0 for a prompt builder
-        min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
-        max_vchi2ndof=10.0,
+    name="prompt_mue_builder",
+    min_dilepton_mass=7000.0 * MeV,
+    max_dilepton_mass=13000.0 * MeV,
+    min_dilepton_pt=1.0 * GeV,
+    max_ipchi2_etau=50,
+    parent_id="Upsilon(1S)",
+    min_PIDe=2.0,
+    max_adocachi2=30.0,
+    min_pt_e=0.5 * GeV,
+    min_pt_tau=0.3 * GeV,
+    minipchi2=0,  # must be 0 for a prompt builder
+    min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
+    max_vchi2ndof=10.0,
 ):
     """
     Make the detached electron-tau pair, opposite-sign for now.
@@ -105,27 +109,27 @@ def make_prompt_etau(
     pvs = make_pvs()
     descriptor = "[{} -> e+ tau-]cc".format(parent_id)
     taus = make_rd_tauons_hadronic_decay(
-        best_pi_ipchi2_min=minipchi2)  # Make them prompt(?)
+        best_pi_ipchi2_min=minipchi2
+    )  # Make them prompt(?)
     electrons = make_long_electrons_with_brem()
     daughters_code = {
-        'tau+':
-        f'(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',  # Do we need to add a minipchi2 to the taus also for promptness?
-        'tau-':
-        f'(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
-        'e+':
-        f'(PIDe > {min_PIDe}) & (PT > {min_pt_e}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
-        'e-':
-        f'(PIDe > {min_PIDe}) & (PT > {min_pt_e}) & (MIPCHI2DV(PRIMARY) > {minipchi2})'
+        "tau+": f"(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})",  # Do we need to add a minipchi2 to the taus also for promptness?
+        "tau-": f"(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})",
+        "e+": f"(PIDe > {min_PIDe}) & (PT > {min_pt_e}) & (MIPCHI2DV(PRIMARY) > {minipchi2})",
+        "e-": f"(PIDe > {min_PIDe}) & (PT > {min_pt_e}) & (MIPCHI2DV(PRIMARY) > {minipchi2})",
     }
     combination_code = f"ADOCACHI2CUT({max_adocachi2}, '')"
-    vertex_code = f"(VFASPF(VCHI2/VDOF) < {max_vchi2ndof}) & (BPVVDCHI2() > {min_bpvvdchi2})"
+    vertex_code = (
+        f"(VFASPF(VCHI2/VDOF) < {max_vchi2ndof}) & (BPVVDCHI2() > {min_bpvvdchi2})"
+    )
     etau = ParticleCombinerWithPVs(
         particles=[electrons, taus],
         pvs=pvs,
         DaughtersCuts=daughters_code,
         DecayDescriptor=descriptor,
         CombinationCut=combination_code,
-        MotherCut=vertex_code)
+        MotherCut=vertex_code,
+    )
     code = require_all(
         in_range(min_dilepton_mass, F.MASS, max_dilepton_mass),
         F.PT > min_dilepton_pt,
@@ -136,21 +140,21 @@ def make_prompt_etau(
 
 @configurable
 def make_prompt_mutau(
-        name="prompt_mue_builder",
-        min_dilepton_mass=7000.0 * MeV,
-        max_dilepton_mass=13000.0 * MeV,
-        min_dilepton_pt=1.0 * GeV,
-        max_ipchi2_mutau=50,
-        parent_id="Upsilon(1S)",
-        min_probnn_mu=0.2,
-        min_PIDmu=0.,
-        IsMuon=False,
-        min_pt_mu=0. * GeV,
-        max_adocachi2=30.,
-        min_pt_tau=0.3 * GeV,
-        minipchi2=0,  # must be 0 for a prompt builder
-        min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
-        max_vchi2ndof=10.0,
+    name="prompt_mue_builder",
+    min_dilepton_mass=7000.0 * MeV,
+    max_dilepton_mass=13000.0 * MeV,
+    min_dilepton_pt=1.0 * GeV,
+    max_ipchi2_mutau=50,
+    parent_id="Upsilon(1S)",
+    min_probnn_mu=0.2,
+    min_PIDmu=0.0,
+    IsMuon=False,
+    min_pt_mu=0.0 * GeV,
+    max_adocachi2=30.0,
+    min_pt_tau=0.3 * GeV,
+    minipchi2=0,  # must be 0 for a prompt builder
+    min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
+    max_vchi2ndof=10.0,
 ):
     """
     Make the detached electron-tau pair, opposite-sign for now.
@@ -158,30 +162,30 @@ def make_prompt_mutau(
     pvs = make_pvs()
     descriptor = "[{} -> mu+ tau-]cc".format(parent_id)
     taus = make_rd_tauons_hadronic_decay(
-        best_pi_ipchi2_min=minipchi2)  # Make them prompt(?)
+        best_pi_ipchi2_min=minipchi2
+    )  # Make them prompt(?)
     muons = make_ismuon_long_muon()
     daughters_code = {
-        'tau+':
-        f'(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',  # Do we need to add a minipchi2 to the taus also for promptness?
-        'tau-':
-        f'(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
-        'mu+':
-        f'(PROBNNmu > {min_probnn_mu}) & (PIDmu > {min_PIDmu}) & (PT > {min_pt_mu}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
-        'mu-':
-        f'(PROBNNmu > {min_probnn_mu}) & (PIDmu > {min_PIDmu}) & (PT > {min_pt_mu}) & (MIPCHI2DV(PRIMARY) > {minipchi2})',
+        "tau+": f"(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})",  # Do we need to add a minipchi2 to the taus also for promptness?
+        "tau-": f"(PT > {min_pt_tau}) & (MIPCHI2DV(PRIMARY) > {minipchi2})",
+        "mu+": f"(PROBNNmu > {min_probnn_mu}) & (PIDmu > {min_PIDmu}) & (PT > {min_pt_mu}) & (MIPCHI2DV(PRIMARY) > {minipchi2})",
+        "mu-": f"(PROBNNmu > {min_probnn_mu}) & (PIDmu > {min_PIDmu}) & (PT > {min_pt_mu}) & (MIPCHI2DV(PRIMARY) > {minipchi2})",
     }
     if IsMuon:
         daughters_code["mu+"] = daughters_code["mu+"] + " & ISMUON"
         daughters_code["mu-"] = daughters_code["mu-"] + " & ISMUON"
     combination_code = f"ADOCACHI2CUT({max_adocachi2}, '')"
-    vertex_code = f"(VFASPF(VCHI2/VDOF) < {max_vchi2ndof}) & (BPVVDCHI2() > {min_bpvvdchi2})"
+    vertex_code = (
+        f"(VFASPF(VCHI2/VDOF) < {max_vchi2ndof}) & (BPVVDCHI2() > {min_bpvvdchi2})"
+    )
     mutau = ParticleCombinerWithPVs(
         particles=[muons, taus],
         pvs=pvs,
         DaughtersCuts=daughters_code,
         DecayDescriptor=descriptor,
         CombinationCut=combination_code,
-        MotherCut=vertex_code)
+        MotherCut=vertex_code,
+    )
     code = require_all(
         in_range(min_dilepton_mass, F.MASS, max_dilepton_mass),
         F.PT > min_dilepton_pt,
@@ -192,31 +196,33 @@ def make_prompt_mutau(
 
 @configurable
 def make_prompt_tautau(
-        name="prompt_tautau_builder",
-        min_dilepton_mass=7000.0 * MeV,
-        max_dilepton_mass=13000.0 * MeV,
-        min_dilepton_pt=1.0 * GeV,
-        max_ipchi2_tautau=50,
-        max_adocachi2=30.,
-        parent_id="Upsilon(1S)",
-        min_pt_tau=0.3 * GeV,
-        minipchi2=0,  # must be 0 for a prompt builder
-        min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
-        max_vchi2ndof=10.0,
+    name="prompt_tautau_builder",
+    min_dilepton_mass=7000.0 * MeV,
+    max_dilepton_mass=13000.0 * MeV,
+    min_dilepton_pt=1.0 * GeV,
+    max_ipchi2_tautau=50,
+    max_adocachi2=30.0,
+    parent_id="Upsilon(1S)",
+    min_pt_tau=0.3 * GeV,
+    minipchi2=0,  # must be 0 for a prompt builder
+    min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
+    max_vchi2ndof=10.0,
 ):
     """
     Make the detached muon-electron pair, opposite-sign or same-sign.
     """
     pvs = make_pvs()
     taus = make_rd_tauons_hadronic_decay(
-        best_pi_ipchi2_min=minipchi2)  # Make them prompt(?)
+        best_pi_ipchi2_min=minipchi2
+    )  # Make them prompt(?)
     descriptor = "{} -> tau+ tau-".format(parent_id)
     combination_code = f"ADOCACHI2CUT({max_adocachi2}, '')"
-    vertex_code = f"(VFASPF(VCHI2/VDOF) < {max_vchi2ndof}) & (BPVVDCHI2() > {min_bpvvdchi2})"
+    vertex_code = (
+        f"(VFASPF(VCHI2/VDOF) < {max_vchi2ndof}) & (BPVVDCHI2() > {min_bpvvdchi2})"
+    )
     daughters_code = {
-        'tau+':
-        f'(PT > {min_pt_tau})',  # Do we need to add a minipchi2 to the taus also for promptness?
-        'tau-': f'(PT > {min_pt_tau})'
+        "tau+": f"(PT > {min_pt_tau})",  # Do we need to add a minipchi2 to the taus also for promptness?
+        "tau-": f"(PT > {min_pt_tau})",
     }
     tautau = ParticleCombinerWithPVs(
         particles=[taus, taus],
@@ -224,7 +230,8 @@ def make_prompt_tautau(
         DaughtersCuts=daughters_code,
         DecayDescriptor=descriptor,
         CombinationCut=combination_code,
-        MotherCut=vertex_code)
+        MotherCut=vertex_code,
+    )
 
     code = require_all(
         in_range(min_dilepton_mass, F.MASS, max_dilepton_mass),
@@ -237,18 +244,18 @@ def make_prompt_tautau(
 # filter based on the rd_detached_mue / make_detached_mue_with_brem with zero cuts on IP and added combination cuts
 @configurable
 def make_prompt_mumu(
-        name="prompt_mumu_builder",
-        min_dilepton_mass=0.0 * MeV,
-        max_dilepton_mass=6000.0 * MeV,
-        min_dilepton_pt=1.0 * GeV,
-        max_ipchi2_mumu=50,
-        parent_id="J/psi(1S)",
-        min_probnn_mu=0.0,
-        IsMuon=True,
-        min_pt_mu=0.5 * GeV,
-        minipchi2=0,  # must be 0 for a prompt builder
-        min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
-        max_trghostprob=0.2,
+    name="prompt_mumu_builder",
+    min_dilepton_mass=0.0 * MeV,
+    max_dilepton_mass=6000.0 * MeV,
+    min_dilepton_pt=1.0 * GeV,
+    max_ipchi2_mumu=50,
+    parent_id="J/psi(1S)",
+    min_probnn_mu=0.0,
+    IsMuon=True,
+    min_pt_mu=0.5 * GeV,
+    minipchi2=0,  # must be 0 for a prompt builder
+    min_bpvvdchi2=0.0,  # must be 0 for a prompt builder
+    max_trghostprob=0.2,
 ):
     """
     Make the detached muon-electron pair, opposite-sign or same-sign.
@@ -273,19 +280,19 @@ def make_prompt_mumu(
 
 @configurable
 def make_prompt_ee(
-        name="prompt_ee_builder",
-        opposite_sign=True,
-        PIDe_min=2.0,
-        pt_e=0.5 * GeV,
-        minipchi2=0,  # must be 0 for a prompt builder
-        max_ipchi2_ee=50,
-        trghostprob=0.2,
-        parent_id="J/psi(1S)",
-        min_dilepton_pt=0 * GeV,
-        min_dilepton_mass=0 * MeV,
-        max_dilepton_mass=6000 * MeV,
-        adocachi2cut=30,
-        max_vchi2ndof=7.5,
+    name="prompt_ee_builder",
+    opposite_sign=True,
+    PIDe_min=2.0,
+    pt_e=0.5 * GeV,
+    minipchi2=0,  # must be 0 for a prompt builder
+    max_ipchi2_ee=50,
+    trghostprob=0.2,
+    parent_id="J/psi(1S)",
+    min_dilepton_pt=0 * GeV,
+    min_dilepton_mass=0 * MeV,
+    max_dilepton_mass=6000 * MeV,
+    adocachi2cut=30,
+    max_vchi2ndof=7.5,
 ):
     """
     Make the detached muon-electron pair, opposite-sign or same-sign.
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/upsilon_to_ll.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/upsilon_to_ll.py
index bbd7313d059..e6bd6e258cc 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/upsilon_to_ll.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/rd/upsilon_to_ll.py
@@ -21,16 +21,18 @@ author: Raja Nandakumar, Fergus Wilson
 date: 31.01.2022
 """
 
-from Moore.config import HltLine, register_line_builder
+from Moore.config import register_line_builder
 from Moore.lines import Hlt2Line
 from GaudiKernel.SystemOfUnits import MeV, GeV
 from PyConf import configurable
 
 from RecoConf.reconstruction_objects import upfront_reconstruction
 
-from Hlt2Conf.algorithms_thor import require_all, ParticleCombiner, ParticleFilter
-from Hlt2Conf.standard_particles import make_has_rich_long_pions, make_has_rich_up_pions
-from Hlt2Conf.lines.rd.builders.qqbar_builder import make_prompt_mumu, make_prompt_ee, make_prompt_tautau
+from Hlt2Conf.lines.rd.builders.qqbar_builder import (
+    make_prompt_mumu,
+    make_prompt_ee,
+    make_prompt_tautau,
+)
 from Hlt2Conf.lines.rd.builders.qqbar_builder import make_prompt_etau, make_prompt_mutau
 
 all_lines = {}
@@ -38,9 +40,9 @@ all_lines = {}
 
 @register_line_builder(all_lines)
 @configurable
-def Hlt2RD_UpsilonToEE_Line(name="Hlt2RD_UpsilonToEE_Line",
-                            prescale=1,
-                            persistreco=False):
+def Hlt2RD_UpsilonToEE_Line(
+    name="Hlt2RD_UpsilonToEE_Line", prescale=1, persistreco=False
+):
 
     ee = make_prompt_ee(
         name="Hlt2RD_UpsilonToEE_Builder",
@@ -61,9 +63,9 @@ def Hlt2RD_UpsilonToEE_Line(name="Hlt2RD_UpsilonToEE_Line",
 
 @register_line_builder(all_lines)
 @configurable
-def Hlt2RD_UpsilonToMuMu_Line(name="Hlt2RD_UpsilonToMuMu_Line",
-                              prescale=1,
-                              persistreco=False):
+def Hlt2RD_UpsilonToMuMu_Line(
+    name="Hlt2RD_UpsilonToMuMu_Line", prescale=1, persistreco=False
+):
 
     mumu = make_prompt_mumu(
         name="Hlt2RD_UpsilonToMuMu_Builder",
@@ -83,9 +85,9 @@ def Hlt2RD_UpsilonToMuMu_Line(name="Hlt2RD_UpsilonToMuMu_Line",
 
 @register_line_builder(all_lines)
 @configurable
-def Hlt2RD_UpsilonToTauTau_Line(name="Hlt2RD_UpsilonToTauTau_Line",
-                                prescale=1,
-                                persistreco=False):
+def Hlt2RD_UpsilonToTauTau_Line(
+    name="Hlt2RD_UpsilonToTauTau_Line", prescale=1, persistreco=False
+):
 
     tautau = make_prompt_tautau(
         name="Hlt2RD_UpsilonToTauTau_Builder",
@@ -105,9 +107,9 @@ def Hlt2RD_UpsilonToTauTau_Line(name="Hlt2RD_UpsilonToTauTau_Line",
 
 @register_line_builder(all_lines)
 @configurable
-def Hlt2RD_UpsilonToeTau_Line(name="Hlt2RD_UpsilonToeTau_Line",
-                              prescale=1,
-                              persistreco=False):
+def Hlt2RD_UpsilonToeTau_Line(
+    name="Hlt2RD_UpsilonToeTau_Line", prescale=1, persistreco=False
+):
 
     etau = make_prompt_etau(
         name="Hlt2RD_UpsilonToeTau_Builder",
@@ -128,9 +130,9 @@ def Hlt2RD_UpsilonToeTau_Line(name="Hlt2RD_UpsilonToeTau_Line",
 
 @register_line_builder(all_lines)
 @configurable
-def Hlt2RD_UpsilonTomuTau_Line(name="Hlt2RD_UpsilonTomuTau_Line",
-                               prescale=1,
-                               persistreco=False):
+def Hlt2RD_UpsilonTomuTau_Line(
+    name="Hlt2RD_UpsilonTomuTau_Line", prescale=1, persistreco=False
+):
 
     mutau = make_prompt_mutau(
         name="Hlt2RD_UpsilonTomuTau_Builder",
-- 
GitLab