From 6afbe11f926a3794f6c6ea2bf27d05de3e52b88e Mon Sep 17 00:00:00 2001
From: Helder Lopes <lopes@lxplus741.cern.ch>
Date: Wed, 25 May 2022 19:05:27 +0200
Subject: [PATCH 1/2] Change standard_jets.py and Jets.py to include jet energy
 correction (JEC)

---
 Hlt/Hlt2Conf/python/Hlt2Conf/lines/Jets.py    | 38 ++++++++++++++++++-
 Hlt/Hlt2Conf/python/Hlt2Conf/standard_jets.py | 14 ++++++-
 2 files changed, 49 insertions(+), 3 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/Jets.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/Jets.py
index 343ef5771e7..09f75d10672 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/Jets.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/Jets.py
@@ -45,8 +45,10 @@ def make_jets(pflow,
               pt_min=10 * GeV,
               JetsByVtx=False,
               tags=None,
-              useflightdirectionfortag=False):
-    jets = build_jets(pflow, JetsByVtx)
+              applyJEC=False,  # Jet energy correction, JEC config in ..standard_jets.build_jets
+              useflightdirectionfortag=False,
+              name=""):
+    jets = build_jets(pflow, JetsByVtx, applyJEC,name = 'JetBuilder' + name)
 
     if tags is not None:
         taggedjets = tag_jets(
@@ -107,6 +109,38 @@ def jetpt10_func_line(name='Hlt2JetsPt10Line', prescale=1):
         prescale=prescale,
     )
 
+@register_line_builder(all_lines)
+@configurable
+def jetpt10JEC_func_line(name='Hlt2JetsPt10JECLine', prescale=1):
+    pflow = make_particleflow()
+    jets = make_jets(pflow=pflow, pt_min=10 * GeV, applyJEC=True, name="Pt10_JEC")
+    return HltLine(
+        name=name,
+        algs=upfront_reconstruction() + [jets],
+        prescale=prescale,
+    )
+
+@register_line_builder(all_lines)
+@configurable
+def jetpt10byPVs_func_line(name='Hlt2JetsPt10byPVsLine', prescale=1):
+    pflow = make_particleflow()
+    jets = make_jets(pflow=pflow, pt_min=10 * GeV, JetsByVtx=True, name="Pt10_byPVs")
+    return HltLine(
+        name=name,
+        algs=upfront_reconstruction() + [jets],
+        prescale=prescale,
+    )
+
+@register_line_builder(all_lines)
+@configurable
+def jetpt10byPVsJEC_func_line(name='Hlt2JetsPt10byPVsJECLine', prescale=1):
+    pflow = make_particleflow()
+    jets = make_jets(pflow=pflow, pt_min=10 * GeV, JetsByVtx=True, applyJEC=True, name="Pt10_byPVs_JEC")
+    return HltLine(
+        name=name,
+        algs=upfront_reconstruction() + [jets],
+        prescale=prescale,
+    )
 
 @register_line_builder(all_lines)
 @configurable
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/standard_jets.py b/Hlt/Hlt2Conf/python/Hlt2Conf/standard_jets.py
index f5267845152..9269f4aaca0 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/standard_jets.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/standard_jets.py
@@ -12,6 +12,8 @@
 """
 from __future__ import absolute_import, division, print_function
 
+from math import pi as M_PI
+
 from GaudiKernel.SystemOfUnits import GeV
 
 from PyConf.Algorithms import (ParticleMakerForParticleFlow, FastJetBuilder,
@@ -54,7 +56,10 @@ def tag_jets(jets, tags, useflightdirection=False, name="TagJets"):
 
 
 @configurable
-def build_jets(pflow, JetsByVtx=False, name='JetBuilder'):
+def build_jets(pflow, JetsByVtx=False, applyJEC=False, name='JetBuilder'):
+    jetEcFilePath = "" # Null jetEcFilePath: Don't apply JEC
+    if applyJEC:
+       jetEcFilePath = "paramfile://data/JetEnergyCorrections_R05_hlt_Run2.root"
     return FastJetBuilder(
         Input=pflow,
         PVLocation=_make_pvs(),
@@ -66,6 +71,13 @@ def build_jets(pflow, JetsByVtx=False, name='JetBuilder'):
         Recombination='E_scheme',  #  FastJet: RecombinationScheme
         JetID=98,  # LHCb: Jet PID number
         JetsByVtx=JetsByVtx,
+        jetEcFilePath=jetEcFilePath,
+        jecLimNPvs = [0,1],
+        jecLimEta = [2.0, 2.2, 2.3, 2.4, 2.6, 2.8, 3.0, 3.2, 3.6, 4.2, 4.5],
+        jecLimCpf = [0.06, 0.3, 0.4, 0.5, 0.6, 0.8, 1.0001],
+        jecLimPhi = [0, 1.0 / 6.0 * M_PI, 1.0 / 3.0 * M_PI, 0.5 * M_PI],
+        jecLimPt = [5, 298],
+        jetEcShift = 0.,
         name=name).Output
 
 
-- 
GitLab


From bbab4ab8523d73335c3bfe2c0eafce2f9adff711 Mon Sep 17 00:00:00 2001
From: Gitlab CI <noreply@cern.ch>
Date: Fri, 3 Jun 2022 16:45:23 +0000
Subject: [PATCH 2/2] Fixed formatting

patch generated by https://gitlab.cern.ch/lhcb/Moore/-/jobs/22287664
---
 Hlt/Hlt2Conf/python/Hlt2Conf/lines/Jets.py    | 34 +++++++++++++------
 Hlt/Hlt2Conf/python/Hlt2Conf/standard_jets.py | 16 ++++-----
 2 files changed, 31 insertions(+), 19 deletions(-)

diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/Jets.py b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/Jets.py
index 09f75d10672..31b0a1d5cea 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/lines/Jets.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/lines/Jets.py
@@ -41,14 +41,15 @@ all_lines = {}
 
 
 @configurable
-def make_jets(pflow,
-              pt_min=10 * GeV,
-              JetsByVtx=False,
-              tags=None,
-              applyJEC=False,  # Jet energy correction, JEC config in ..standard_jets.build_jets
-              useflightdirectionfortag=False,
-              name=""):
-    jets = build_jets(pflow, JetsByVtx, applyJEC,name = 'JetBuilder' + name)
+def make_jets(
+        pflow,
+        pt_min=10 * GeV,
+        JetsByVtx=False,
+        tags=None,
+        applyJEC=False,  # Jet energy correction, JEC config in ..standard_jets.build_jets
+        useflightdirectionfortag=False,
+        name=""):
+    jets = build_jets(pflow, JetsByVtx, applyJEC, name='JetBuilder' + name)
 
     if tags is not None:
         taggedjets = tag_jets(
@@ -109,39 +110,50 @@ def jetpt10_func_line(name='Hlt2JetsPt10Line', prescale=1):
         prescale=prescale,
     )
 
+
 @register_line_builder(all_lines)
 @configurable
 def jetpt10JEC_func_line(name='Hlt2JetsPt10JECLine', prescale=1):
     pflow = make_particleflow()
-    jets = make_jets(pflow=pflow, pt_min=10 * GeV, applyJEC=True, name="Pt10_JEC")
+    jets = make_jets(
+        pflow=pflow, pt_min=10 * GeV, applyJEC=True, name="Pt10_JEC")
     return HltLine(
         name=name,
         algs=upfront_reconstruction() + [jets],
         prescale=prescale,
     )
 
+
 @register_line_builder(all_lines)
 @configurable
 def jetpt10byPVs_func_line(name='Hlt2JetsPt10byPVsLine', prescale=1):
     pflow = make_particleflow()
-    jets = make_jets(pflow=pflow, pt_min=10 * GeV, JetsByVtx=True, name="Pt10_byPVs")
+    jets = make_jets(
+        pflow=pflow, pt_min=10 * GeV, JetsByVtx=True, name="Pt10_byPVs")
     return HltLine(
         name=name,
         algs=upfront_reconstruction() + [jets],
         prescale=prescale,
     )
 
+
 @register_line_builder(all_lines)
 @configurable
 def jetpt10byPVsJEC_func_line(name='Hlt2JetsPt10byPVsJECLine', prescale=1):
     pflow = make_particleflow()
-    jets = make_jets(pflow=pflow, pt_min=10 * GeV, JetsByVtx=True, applyJEC=True, name="Pt10_byPVs_JEC")
+    jets = make_jets(
+        pflow=pflow,
+        pt_min=10 * GeV,
+        JetsByVtx=True,
+        applyJEC=True,
+        name="Pt10_byPVs_JEC")
     return HltLine(
         name=name,
         algs=upfront_reconstruction() + [jets],
         prescale=prescale,
     )
 
+
 @register_line_builder(all_lines)
 @configurable
 def onlytrack_jetpt10_func_line(name='Hlt2TrackJetsPt10Line', prescale=1):
diff --git a/Hlt/Hlt2Conf/python/Hlt2Conf/standard_jets.py b/Hlt/Hlt2Conf/python/Hlt2Conf/standard_jets.py
index 9269f4aaca0..5f59a34bf47 100644
--- a/Hlt/Hlt2Conf/python/Hlt2Conf/standard_jets.py
+++ b/Hlt/Hlt2Conf/python/Hlt2Conf/standard_jets.py
@@ -57,9 +57,9 @@ def tag_jets(jets, tags, useflightdirection=False, name="TagJets"):
 
 @configurable
 def build_jets(pflow, JetsByVtx=False, applyJEC=False, name='JetBuilder'):
-    jetEcFilePath = "" # Null jetEcFilePath: Don't apply JEC
+    jetEcFilePath = ""  # Null jetEcFilePath: Don't apply JEC
     if applyJEC:
-       jetEcFilePath = "paramfile://data/JetEnergyCorrections_R05_hlt_Run2.root"
+        jetEcFilePath = "paramfile://data/JetEnergyCorrections_R05_hlt_Run2.root"
     return FastJetBuilder(
         Input=pflow,
         PVLocation=_make_pvs(),
@@ -72,12 +72,12 @@ def build_jets(pflow, JetsByVtx=False, applyJEC=False, name='JetBuilder'):
         JetID=98,  # LHCb: Jet PID number
         JetsByVtx=JetsByVtx,
         jetEcFilePath=jetEcFilePath,
-        jecLimNPvs = [0,1],
-        jecLimEta = [2.0, 2.2, 2.3, 2.4, 2.6, 2.8, 3.0, 3.2, 3.6, 4.2, 4.5],
-        jecLimCpf = [0.06, 0.3, 0.4, 0.5, 0.6, 0.8, 1.0001],
-        jecLimPhi = [0, 1.0 / 6.0 * M_PI, 1.0 / 3.0 * M_PI, 0.5 * M_PI],
-        jecLimPt = [5, 298],
-        jetEcShift = 0.,
+        jecLimNPvs=[0, 1],
+        jecLimEta=[2.0, 2.2, 2.3, 2.4, 2.6, 2.8, 3.0, 3.2, 3.6, 4.2, 4.5],
+        jecLimCpf=[0.06, 0.3, 0.4, 0.5, 0.6, 0.8, 1.0001],
+        jecLimPhi=[0, 1.0 / 6.0 * M_PI, 1.0 / 3.0 * M_PI, 0.5 * M_PI],
+        jecLimPt=[5, 298],
+        jetEcShift=0.,
         name=name).Output
 
 
-- 
GitLab