From 4acab110ba86eaa14046657448c26cec9070c61e Mon Sep 17 00:00:00 2001
From: amorley <anthony.morley@cern.ch>
Date: Thu, 21 Oct 2021 13:00:28 +0200
Subject: [PATCH 1/2] Add flag to read in instead of calculate fJVT in fJVT
 tool

---
 .../JetMomentTools/JetMomentTools/JetForwardJvtTool.h  |  1 +
 .../Jet/JetMomentTools/Root/JetForwardJvtTool.cxx      | 10 ++++++++--
 2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetForwardJvtTool.h b/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetForwardJvtTool.h
index d66554f8d7a2..7c47ae4992df 100644
--- a/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetForwardJvtTool.h
+++ b/Reconstruction/Jet/JetMomentTools/JetMomentTools/JetForwardJvtTool.h
@@ -81,6 +81,7 @@
     Gaudi::Property<double> m_jetScaleFactor{this, "JetScaleFactor", 0.4, "Jet scale factor"};
     Gaudi::Property<double> m_fjvtThresh{this, "FjvtThresh", 15e3, "FJVT threshold"}; //15GeV->92%,11GeV->85%
     Gaudi::Property<bool> m_tightOP{this, "UseTightOP", false, "Use tight (true) or loose (false)"};
+    Gaudi::Property<bool> m_recalculateFjvt{this, "RecalculateFjvt", true, "Recalculate Fjvt or use stored value"}; 
     mutable std::vector<TVector2> m_pileupMomenta;
     mutable size_t m_pvind = 0UL;
     void getPV() const;
diff --git a/Reconstruction/Jet/JetMomentTools/Root/JetForwardJvtTool.cxx b/Reconstruction/Jet/JetMomentTools/Root/JetForwardJvtTool.cxx
index f2015c7e57ee..7fec4b593835 100644
--- a/Reconstruction/Jet/JetMomentTools/Root/JetForwardJvtTool.cxx
+++ b/Reconstruction/Jet/JetMomentTools/Root/JetForwardJvtTool.cxx
@@ -74,10 +74,11 @@
     SG::WriteDecorHandle<xAOD::JetContainer, float> fjvtDecHandle(m_fjvtDecKey);
 
     getPV();
-    if (jetCont.size() > 0) calculateVertexMomenta(&jetCont);
+    if (m_recalculateFjvt && jetCont.size() > 0) calculateVertexMomenta(&jetCont);
     for(const auto jetF : jetCont) {
       outHandle(*jetF) = 1;
-      fjvtDecHandle(*jetF) = 0;
+      if(m_recalculateFjvt)
+        fjvtDecHandle(*jetF) = 0;
       if (!forwardJet(jetF)) continue;
       double fjvt = getFJVT(jetF)/jetF->pt();
       if (fjvt>m_fjvtThresh) outHandle(*jetF) = 0;
@@ -87,6 +88,11 @@
   }
 
   float JetForwardJvtTool::getFJVT(const xAOD::Jet *jet) const {
+    SG::WriteDecorHandle<xAOD::JetContainer, float> fjvtDecHandle(m_fjvtDecKey);
+
+    if(!m_recalculateFjvt)
+      return fjvtDecHandle(*jet);
+
     TVector2 fjet(-jet->pt()*cos(jet->phi()),-jet->pt()*sin(jet->phi()));
     double fjvt = 0;
     for (size_t pui = 0; pui < m_pileupMomenta.size(); pui++) {
-- 
GitLab


From c64b512dc3a18ef2d129997050ef734273e2ab10 Mon Sep 17 00:00:00 2001
From: amorley <anthony.morley@cern.ch>
Date: Thu, 21 Oct 2021 15:48:35 +0200
Subject: [PATCH 2/2] minor cleanup

---
 .../Jet/JetMomentTools/Root/JetForwardJvtTool.cxx        | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/Reconstruction/Jet/JetMomentTools/Root/JetForwardJvtTool.cxx b/Reconstruction/Jet/JetMomentTools/Root/JetForwardJvtTool.cxx
index 7fec4b593835..0e86ea3fd421 100644
--- a/Reconstruction/Jet/JetMomentTools/Root/JetForwardJvtTool.cxx
+++ b/Reconstruction/Jet/JetMomentTools/Root/JetForwardJvtTool.cxx
@@ -77,8 +77,7 @@
     if (m_recalculateFjvt && jetCont.size() > 0) calculateVertexMomenta(&jetCont);
     for(const auto jetF : jetCont) {
       outHandle(*jetF) = 1;
-      if(m_recalculateFjvt)
-        fjvtDecHandle(*jetF) = 0;
+      if(m_recalculateFjvt) fjvtDecHandle(*jetF) = 0;
       if (!forwardJet(jetF)) continue;
       double fjvt = getFJVT(jetF)/jetF->pt();
       if (fjvt>m_fjvtThresh) outHandle(*jetF) = 0;
@@ -88,10 +87,10 @@
   }
 
   float JetForwardJvtTool::getFJVT(const xAOD::Jet *jet) const {
-    SG::WriteDecorHandle<xAOD::JetContainer, float> fjvtDecHandle(m_fjvtDecKey);
-
-    if(!m_recalculateFjvt)
+    if(!m_recalculateFjvt){
+      SG::WriteDecorHandle<xAOD::JetContainer, float> fjvtDecHandle(m_fjvtDecKey);
       return fjvtDecHandle(*jet);
+    } 
 
     TVector2 fjet(-jet->pt()*cos(jet->phi()),-jet->pt()*sin(jet->phi()));
     double fjvt = 0;
-- 
GitLab