From f0f5a6f4568ff5115753c6a8911151be391e42ac Mon Sep 17 00:00:00 2001
From: Anil Sonay <anil.sonay@cern.ch>
Date: Tue, 16 Mar 2021 17:37:34 +0100
Subject: [PATCH 1/4] L1Topo kinematics phase1 upgrade-I

---
 .../Root/DeltaRApproxBoxCutIncl1.cxx          |  18 ---
 .../Root/DeltaRApproxBoxCutIncl2.cxx          |  19 ---
 .../Root/DisambiguationInvmIncl2.cxx          |  42 ------
 .../Root/InvariantMassDeltaPhiInclusive2.cxx  |   8 +-
 .../L1Topo/L1TopoAlgorithms/Root/NotMatch.cxx |  30 ----
 .../L1Topo/L1TopoEvent/Root/ClusterTOB.cxx    |   2 +-
 .../L1Topo/L1TopoInterfaces/CMakeLists.txt    |   2 +-
 .../L1TopoInterfaces/ConfigurableAlg.h        |  15 +-
 .../L1TopoInterfaces/Root/ConfigurableAlg.cxx |  81 ++++++++++-
 .../src/EMTauInputProviderFEX.cxx             |   7 +-
 .../L1TopoSimulationUtils/Kinematics.h        |   2 +-
 .../L1TopoSimulationUtils/LegacyKinematics.h  |  45 ++++++
 .../L1TopoSimulationUtils/Root/Kinematics.cxx |   2 +-
 .../Root/LegacyKinematics.cxx                 | 131 ++++++++++++++++++
 14 files changed, 282 insertions(+), 122 deletions(-)
 create mode 100644 Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/LegacyKinematics.h
 create mode 100644 Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/LegacyKinematics.cxx

diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRApproxBoxCutIncl1.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRApproxBoxCutIncl1.cxx
index ce755cd5a873..e2cf410a650d 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRApproxBoxCutIncl1.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRApproxBoxCutIncl1.cxx
@@ -21,24 +21,6 @@
 
 REGISTER_ALG_TCS(DeltaRApproxBoxCutIncl1)
 
-namespace {
-   unsigned int
-   calcDeltaPhi(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
-      if(dphi>M_PI)
-         dphi = 2*M_PI - dphi;
-      
-      return round( 10 * dphi );
-   }
-
-   unsigned int
-   calcDeltaEta(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      double deta = std::abs( tob1->eta() - tob2->eta() );
-      return deta;
-   }
-}
-
-
 TCS::DeltaRApproxBoxCutIncl1::DeltaRApproxBoxCutIncl1(const std::string & name) : DecisionAlg(name)
 {
    defineParameter("InputWidth", 3);
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRApproxBoxCutIncl2.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRApproxBoxCutIncl2.cxx
index a9ee935a7fa3..75ab6e330219 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRApproxBoxCutIncl2.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRApproxBoxCutIncl2.cxx
@@ -20,25 +20,6 @@
 
 REGISTER_ALG_TCS(DeltaRApproxBoxCutIncl2)
 
-
-namespace {
-   unsigned int
-   calcDeltaPhi(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
-      if(dphi>M_PI)
-         dphi = 2*M_PI - dphi;
-      
-      return round( 10 * dphi );
-   }
-
-   unsigned int
-   calcDeltaEta(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      double deta = std::abs( tob1->eta() - tob2->eta() );
-      return deta;
-   }
-}
-
-
 TCS::DeltaRApproxBoxCutIncl2::DeltaRApproxBoxCutIncl2(const std::string & name) : DecisionAlg(name)
 {
    defineParameter("InputWidth1", 5);
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationInvmIncl2.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationInvmIncl2.cxx
index 3b575685bb66..12fcaf940b19 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationInvmIncl2.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationInvmIncl2.cxx
@@ -28,48 +28,6 @@ REGISTER_ALG_TCS(DisambiguationInvmIncl2)
 // not the best solution but we will move to athena where this comes for free
 #define LOG std::cout << "TCS::DisambiguationInvmIncl2:     "
 
-namespace {
-unsigned int
-calcInvMass(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-    double deta = fabs( tob1->etaDouble() - tob2->etaDouble() );
-    double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
-    if(dphi>M_PI)
-        dphi = 2*M_PI - dphi;
-    double cosheta = cosh (deta);
-    double cosphi = cos (dphi);
-    double invmass2 = 2*tob1->Et()*tob2->Et()*(cosheta - cosphi);
-    return round( invmass2 );
-}
-
-unsigned int
-calcInvMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-    auto bit_cosheta = TSU::L1TopoDataTypes<19,7>(TSU::Hyperbolic::Cosh.at(abs(tob1->eta() - tob2->eta())));
-    auto bit_cosphi = TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Cos.at(abs(tob1->phi() - tob2->phi())));
-    TSU::L1TopoDataTypes<11,0> bit_Et1(tob1->Et());
-    TSU::L1TopoDataTypes<11,0> bit_Et2(tob2->Et());
-    auto bit_invmass2 = 2*bit_Et1*bit_Et2*(bit_cosheta - bit_cosphi);
-    return int(bit_invmass2) ;
-}
-
-unsigned int
-calcDeltaR2(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-    double deta = ( tob1->etaDouble() - tob2->etaDouble() );
-    double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
-    if(dphi>M_PI)
-        dphi = 2*M_PI - dphi;
-    return round ( 100 * ((dphi)*(dphi) + (deta)*(deta) )) ;
-}
-
-unsigned int
-calcDeltaR2BW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-    int detaB = abs( tob1->eta() - tob2->eta() );
-    int dphiB = abs( tob1->phi() - tob2->phi() );
-    if(dphiB>32)
-        dphiB = 64 - dphiB;
-    unsigned int bit_dr2 = dphiB*dphiB + detaB*detaB;
-    return bit_dr2;
-}
-} // namespace
 
 TCS::DisambiguationInvmIncl2::DisambiguationInvmIncl2(const std::string & name) : DecisionAlg(name)
 {
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassDeltaPhiInclusive2.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassDeltaPhiInclusive2.cxx
index f0583b2801a1..6487c6e33210 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassDeltaPhiInclusive2.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassDeltaPhiInclusive2.cxx
@@ -156,9 +156,9 @@ TCS::InvariantMassDeltaPhiInclusive2::processBitCorrect( const std::vector<TCS::
                  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
                  ++tob2) {
                 // Inv Mass calculation
-                unsigned int invmass2 = TSU::Kinematics::calcInvMassBW( *tob1, *tob2 );
+                unsigned int invmass2 = calcInvMassBW( *tob1, *tob2 );
 		// test DeltaPhiMin, DeltaPhiMax                                       
-		unsigned int deltaPhi = TSU::Kinematics::calcDeltaPhiBW( *tob1, *tob2 );
+		unsigned int deltaPhi = calcDeltaPhiBW( *tob1, *tob2 );
                 const int eta1 = (*tob1)->eta();
                 const int eta2 = (*tob2)->eta();
                 const unsigned int aeta1 = std::abs(eta1);
@@ -214,9 +214,9 @@ TCS::InvariantMassDeltaPhiInclusive2::process( const std::vector<TCS::TOBArray c
                  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
                  ++tob2) {
                 // Inv Mass calculation
-                unsigned int invmass2 = TSU::Kinematics::calcInvMass( *tob1, *tob2 );
+                unsigned int invmass2 = calcInvMass( *tob1, *tob2 );
 		// test DeltaPhiMin, DeltaPhiMax                                     
-		unsigned int deltaPhi = TSU::Kinematics::calcDeltaPhi( *tob1, *tob2 );
+		unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
                 const int eta1 = (*tob1)->eta();
                 const int eta2 = (*tob2)->eta();
                 const unsigned int aeta1 = std::abs(eta1);
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/NotMatch.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/NotMatch.cxx
index caf98facaf53..4ed8c2fc6b2f 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/NotMatch.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/NotMatch.cxx
@@ -23,36 +23,6 @@ REGISTER_ALG_TCS(NotMatch)
 #define LOG cout << "TCS::NotMatch:     "
 
 
-
-
-namespace {
-   unsigned int
-   calcDeltaR2(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      double deta = ( tob1->etaDouble() - tob2->etaDouble() );
-      double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
-      if(dphi>M_PI)
-         dphi = 2*M_PI - dphi;
-
-      return round ( 100 * ((dphi)*(dphi) + (deta)*(deta) )) ;
-
-   }
-
-   unsigned int
-   calcDeltaR2BW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-
-      int detaB = abs( tob1->eta() - tob2->eta() );
-      int dphiB = abs( tob1->phi() - tob2->phi() );
-      if(dphiB>32)
-         dphiB = 64 - dphiB;
-
-      unsigned int bit_dr2 = dphiB*dphiB + detaB*detaB;
-      return bit_dr2;
-
-   }
-
-}
-
-
 TCS::NotMatch::NotMatch(const std::string & name) : DecisionAlg(name)
 {
    defineParameter("InputWidth1", 9);
diff --git a/Trigger/TrigT1/L1Topo/L1TopoEvent/Root/ClusterTOB.cxx b/Trigger/TrigT1/L1Topo/L1TopoEvent/Root/ClusterTOB.cxx
index fe0101c9cd43..59ba12a51b5d 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoEvent/Root/ClusterTOB.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoEvent/Root/ClusterTOB.cxx
@@ -17,7 +17,7 @@ TCS::ClusterTOB::ClusterTOB(uint32_t roiWord) :
 // constructor with initial values
 TCS::ClusterTOB::ClusterTOB(unsigned int et, unsigned int isolation, int eta, int phi, inputTOBType_t tobType, uint32_t roiWord) :
    BaseTOB( roiWord )
-   , m_Et( sizeCheck(et, nBitsEt()) )
+   , m_Et( et )
    , m_isolation( sizeCheck( isolation, nBitsIsolation()) )
    , m_eta( sizeCheck(eta, nBitsEta()) )
    , m_phi( sizeCheck(phi, nBitsPhi()) )
diff --git a/Trigger/TrigT1/L1Topo/L1TopoInterfaces/CMakeLists.txt b/Trigger/TrigT1/L1Topo/L1TopoInterfaces/CMakeLists.txt
index 44fb55373803..8cb95ca3b40f 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoInterfaces/CMakeLists.txt
+++ b/Trigger/TrigT1/L1Topo/L1TopoInterfaces/CMakeLists.txt
@@ -12,4 +12,4 @@ atlas_add_library( L1TopoInterfaces
                    PUBLIC_HEADERS L1TopoInterfaces
                    INCLUDE_DIRS ${ROOT_INCLUDE_DIRS}
                    PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES}
-                   LINK_LIBRARIES L1TopoCommon L1TopoEvent TrigConfBase TrigConfIO TrigConfData)
+                   LINK_LIBRARIES L1TopoCommon L1TopoEvent L1TopoSimulationUtils TrigConfBase TrigConfIO TrigConfData)
diff --git a/Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/ConfigurableAlg.h b/Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/ConfigurableAlg.h
index c87841a98fb3..507a7fa36e5e 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/ConfigurableAlg.h
+++ b/Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/ConfigurableAlg.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  BaseTOBoAlg.h
 //  TopoCore
@@ -14,6 +14,7 @@
 #include "L1TopoInterfaces/ParameterSpace.h"
 #include "L1TopoInterfaces/AlgFactory.h"
 #include "L1TopoCommon/StatusCode.h"
+#include "L1TopoEvent/GenericTOB.h"
 
 #include <vector>
 #include <string>
@@ -63,6 +64,18 @@ namespace TCS {
 
       bool isLegacyTopo() const { return m_isLegacyTopo; }
 
+      // Kinematic calculation
+      unsigned int calcDeltaPhiBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+      unsigned int calcDeltaEtaBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+      unsigned int calcInvMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+      unsigned int calcDeltaR2BW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+      unsigned long quadraticSumBW(int i1, int i2);
+      unsigned int calcDeltaPhi(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+      unsigned int calcDeltaEta(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+      unsigned int calcInvMass(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+      unsigned int calcDeltaR2(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+
+
       // const access to parameter
       const Parameter & parameter(const std::string & parameterName) const;
 
diff --git a/Trigger/TrigT1/L1Topo/L1TopoInterfaces/Root/ConfigurableAlg.cxx b/Trigger/TrigT1/L1Topo/L1TopoInterfaces/Root/ConfigurableAlg.cxx
index 93a2cdf567db..f98d4f1ee162 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoInterfaces/Root/ConfigurableAlg.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoInterfaces/Root/ConfigurableAlg.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  BaseTOBoAlg.cpp
 //  TopoCore
@@ -8,6 +8,12 @@
 #include "L1TopoInterfaces/ConfigurableAlg.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/IL1TopoHistSvc.h"
+// Bitwise implementation utils
+#include "L1TopoSimulationUtils/L1TopoDataTypes.h"
+#include "L1TopoSimulationUtils/Trigo.h"
+#include "L1TopoSimulationUtils/Hyperbolic.h"
+#include "L1TopoSimulationUtils/Kinematics.h"
+#include "L1TopoSimulationUtils/LegacyKinematics.h"
 
 #include "TH1.h"
 #include "TH2.h"
@@ -110,6 +116,79 @@ ConfigurableAlg::ConfigurableAlg(const  std::string & name, AlgType algType) :
 ConfigurableAlg::~ConfigurableAlg()
 {}
 
+// Kinematic Calculation
+unsigned int
+ConfigurableAlg::calcDeltaPhiBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+  if (m_isLegacyTopo)
+    {return TSU::LegacyKinematics::calcDeltaPhiBW(tob1,tob2);}
+  else
+    {return TSU::Kinematics::calcDeltaPhiBW(tob1,tob2);}
+}
+
+unsigned int
+ConfigurableAlg::calcDeltaEtaBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+  if (m_isLegacyTopo)
+    {return TSU::LegacyKinematics::calcDeltaEtaBW(tob1,tob2);}
+  else
+    {return TSU::Kinematics::calcDeltaEtaBW(tob1,tob2);}
+}
+
+unsigned int
+ConfigurableAlg::calcInvMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+  if (m_isLegacyTopo)
+    {return TSU::LegacyKinematics::calcInvMassBW(tob1,tob2);}
+  else
+    {return TSU::Kinematics::calcInvMassBW(tob1,tob2);}
+}
+
+unsigned int
+ConfigurableAlg::calcDeltaR2BW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+  if (m_isLegacyTopo)
+    {return TSU::LegacyKinematics::calcDeltaR2BW(tob1,tob2);}
+  else
+    {return TSU::Kinematics::calcDeltaR2BW(tob1,tob2);}
+}
+
+unsigned long
+ConfigurableAlg::quadraticSumBW(int i1, int i2) {
+  if (m_isLegacyTopo)
+    {return TSU::LegacyKinematics::quadraticSumBW(i1, i2);}
+  else
+    {return TSU::Kinematics::quadraticSumBW(i1, i2);}
+}
+
+unsigned int
+ConfigurableAlg::calcDeltaPhi(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+  if (m_isLegacyTopo)
+    {return TSU::LegacyKinematics::calcDeltaPhi(tob1,tob2);}
+  else
+    {return TSU::Kinematics::calcDeltaPhi(tob1,tob2);}
+}
+
+unsigned int
+ConfigurableAlg::calcDeltaEta(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+  if (m_isLegacyTopo)
+    {return TSU::LegacyKinematics::calcDeltaEta(tob1,tob2);}
+  else
+    {return TSU::Kinematics::calcDeltaEta(tob1,tob2);}
+}
+
+unsigned int
+ConfigurableAlg::calcInvMass(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+  if (m_isLegacyTopo)
+    {return TSU::LegacyKinematics::calcInvMass(tob1,tob2);}
+  else
+    {return TSU::Kinematics::calcInvMass(tob1,tob2);}
+}
+
+unsigned int
+ConfigurableAlg::calcDeltaR2(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+  if (m_isLegacyTopo)
+    {return TSU::LegacyKinematics::calcDeltaR2(tob1,tob2);}
+  else
+    {return TSU::Kinematics::calcDeltaR2(tob1,tob2);}
+}
+
 
 // define parameters to be called by developer
 void
diff --git a/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/EMTauInputProviderFEX.cxx b/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/EMTauInputProviderFEX.cxx
index 61f543fd7836..a281d2c1106a 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/EMTauInputProviderFEX.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoSimulation/src/EMTauInputProviderFEX.cxx
@@ -56,13 +56,13 @@ EMTauInputProviderFEX::handle(const Incident& incident) {
    string histPath = "/EXPERT/" + name() + "/";
    replace( histPath.begin(), histPath.end(), '.', '/'); 
 
-   auto hEMEt = std::make_unique<TH1I>( "EMTOBEt", "EM TOB Et", 40, 0, 200);
+   auto hEMEt = std::make_unique<TH1I>( "EMTOBEt", "EM TOB Et", 400, 0, 400);
    hEMEt->SetXTitle("E_{T}");
    auto hEMEtaPhi = std::make_unique<TH2I>( "EMTOBPhiEta", "EM TOB Location", 100, -50, 50, 64, 0, 64);
    hEMEtaPhi->SetXTitle("#eta");
    hEMEtaPhi->SetYTitle("#phi");
 
-   auto hTauEt = std::make_unique<TH1I>( "TauTOBEt", "Tau TOB Et", 40, 0, 200);
+   auto hTauEt = std::make_unique<TH1I>( "TauTOBEt", "Tau TOB Et", 400, 0, 400);
    hTauEt->SetXTitle("E_{T}");
    auto hTauEtaPhi = std::make_unique<TH2I>( "TauTOBPhiEta", "Tau TOB Location", 100, -50, 50, 64, 0, 64);
    hTauEtaPhi->SetXTitle("#eta");
@@ -126,9 +126,10 @@ EMTauInputProviderFEX::fillTopoInputEvent(TCS::TopoInputEvent& inputEvent) const
 
     int ieta = ConvertEta((int)eFexRoI->iEta());
     int iphi = eFexRoI->iPhi();
+    unsigned int iet = static_cast<unsigned int>(eFexRoI->et()/Gaudi::Units::GeV);
 
     //EM TOB
-    TCS::ClusterTOB cluster( static_cast<unsigned int>(eFexRoI->tobEt()/Gaudi::Units::GeV), static_cast<unsigned int>(0), ieta, iphi, TCS::CLUSTER , static_cast<long int>(eFexRoI->Word0()) );
+    TCS::ClusterTOB cluster( iet, static_cast<unsigned int>(0), ieta, iphi, TCS::CLUSTER , static_cast<long int>(eFexRoI->Word0()) );
     cluster.setEtaDouble( eFexRoI->eta() );
     cluster.setPhiDouble( eFexRoI->phi() );
     
diff --git a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/Kinematics.h b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/Kinematics.h
index ab37fe682d05..5d924375fd5f 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/Kinematics.h
+++ b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/Kinematics.h
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 // Kinematics.h
diff --git a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/LegacyKinematics.h b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/LegacyKinematics.h
new file mode 100644
index 000000000000..c14da015f021
--- /dev/null
+++ b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/LegacyKinematics.h
@@ -0,0 +1,45 @@
+/*
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
+*/
+
+// LegacyKinematics.h
+
+
+#ifndef TSU_LegacyKinematics
+#define TSU_LegacyKinematics
+
+//the file 'requirements' in cmt can get you this L1TopoEvent
+#include "L1TopoEvent/GenericTOB.h"
+#include <iostream>
+#include <vector>
+
+namespace TSU { 
+   struct LegacyKinematics {
+	static unsigned int calcDeltaPhiBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);		
+	static unsigned int calcDeltaEtaBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+
+	static unsigned int calcInvMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+	static unsigned int calcDeltaR2BW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+     /**
+        @brief compute the sum in quadrature of two ints
+
+        This function includes an integer square root implementation using a bitwise iterative approach.
+        Square root is computed bit-by-bit (highest significance bits first) and the result is
+        adjusted up- or downwards in each iteration based on whether or not the current result
+        under- or overestimates the value of the sum of squares.
+
+        That is the same way in which the sqrt int is implemented in firmware:
+            processor/sources/common/libraries/L1TopoFunctions.vhd
+            --> function sqrt(d : UNSIGNED) return UNSIGNED
+      */
+	static unsigned long quadraticSumBW(int i1, int i2);
+
+	static unsigned int calcDeltaPhi(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+	static unsigned int calcDeltaEta(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+	static unsigned int calcInvMass(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+	static unsigned int calcDeltaR2(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+   };
+
+} // end of namespace TSU
+
+#endif
diff --git a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Kinematics.cxx b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Kinematics.cxx
index dc34eca3708d..75b5d37f5446 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Kinematics.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Kinematics.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 #include <cmath>
diff --git a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/LegacyKinematics.cxx b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/LegacyKinematics.cxx
new file mode 100644
index 000000000000..dfca7cdcb80b
--- /dev/null
+++ b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/LegacyKinematics.cxx
@@ -0,0 +1,131 @@
+/*
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
+*/
+
+#include <cmath>
+#include <string>
+#include <iostream>
+#include <sstream>
+#include <vector>
+
+#include "L1TopoSimulationUtils/LegacyKinematics.h"
+#include "L1TopoSimulationUtils/Hyperbolic.h"
+#include "L1TopoSimulationUtils/L1TopoDataTypes.h"
+#include "L1TopoSimulationUtils/Trigo.h"
+#include "L1TopoEvent/GenericTOB.h"
+
+//
+
+using namespace std; 
+
+unsigned int TSU::LegacyKinematics::calcDeltaPhiBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2){
+      int dphiB = abs( tob1->phi() - tob2->phi() );
+      if(dphiB>64)
+         dphiB = dphiB - 64;
+      if(dphiB>32)
+         dphiB = 64 - dphiB;
+
+      return dphiB ;
+}
+
+unsigned int TSU::LegacyKinematics::calcDeltaEtaBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+      double deta = abs( tob1->eta() - tob2->eta() );
+	return deta;
+}
+
+unsigned int TSU::LegacyKinematics::calcInvMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2){
+
+  auto bit_cosheta = TSU::L1TopoDataTypes<19,7>(TSU::Hyperbolic::Cosh.at(abs(tob1->eta() - tob2->eta())));
+  //In case of EM objects / jets / taus the phi angle goes between 0 and 64 while muons are between -32 and 32, applying a shift to keep delta-phi in the allowed range. 
+  int phi_tob1 = tob1->phi();
+  int phi_tob2 = tob2->phi();
+  //those cases should happen only in mixed EM/jets/tau plus mu triggers, if both phi's are in [0,2pi] will not get in
+  if ( abs(phi_tob1-phi_tob2)>=64 )
+    {
+      if(phi_tob1 >= 32) phi_tob1 = phi_tob1-64;
+      if(phi_tob2 >= 32) phi_tob2 = phi_tob2-64;
+    }
+  auto bit_cosphi = TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Cos.at(abs( phi_tob1 - phi_tob2 )));
+  TSU::L1TopoDataTypes<11,0> bit_Et1(tob1->Et());
+  TSU::L1TopoDataTypes<11,0> bit_Et2(tob2->Et());
+  auto bit_invmass2 = bit_Et1*bit_Et2*(bit_cosheta - bit_cosphi)*2;
+  return int(bit_invmass2) ;
+}
+
+unsigned int TSU::LegacyKinematics::calcDeltaR2BW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+      int detaB = abs( tob1->eta() - tob2->eta() );
+      int dphiB = abs( tob1->phi() - tob2->phi() );
+      if(dphiB>64) //Probably same error here as in DeltaPhiBW. Check
+         dphiB = dphiB - 64;
+      if(dphiB>32)
+         dphiB = 64 - dphiB;
+
+      unsigned int bit_dr2 = dphiB*dphiB + detaB*detaB;
+      return bit_dr2;
+}
+
+unsigned long TSU::LegacyKinematics::quadraticSumBW(int i1, int i2){
+    unsigned int ui1 = i1, ui2=i2;
+    unsigned int a = ui1*ui1 + ui2*ui2; 
+
+    unsigned int result=0;
+    int left=0, right=0; 
+    unsigned int r=0;
+    int sign=0;
+  
+    //The values for halflength and bitmask enforce the
+    //bitwise overflow limit, not the precision of the chosen C++ parameters
+    int halflength = 16; //max 16
+    unsigned int bitmask = 0b11111111111111111111111111111111; //32 bits
+    bitmask >>= (32 - halflength*2); //does nothing unless halflength changes
+  
+    for(int i = 0; i < halflength; i++){ //16-->4
+        right = 1 + (sign<<1) + (result<<2);
+        left = (r<<2) + (a >> (2*halflength-2));
+        a <<= 2;
+        a = a & bitmask;
+        r = sign ? (left + right) : (left - right);
+        sign = ((r & (1 << (halflength+1) ))  > 0) ? 1 : 0;
+        result <<= 1;
+        if(sign==0) result += 1;
+    }
+    return result;
+}
+
+/*------------------------------------------ NON-BITWISE --------------------------------------------------*/
+
+unsigned int TSU::LegacyKinematics::calcDeltaPhi(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+      double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
+      if(dphi>M_PI)
+         dphi = 2*M_PI - dphi;
+
+      return round( 10 * dphi );
+}
+
+unsigned int TSU::LegacyKinematics::calcDeltaEta(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+      double deta = fabs( tob1->eta() - tob2->eta() );
+	return deta;
+}
+
+unsigned int TSU::LegacyKinematics::calcInvMass(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+      double deta = fabs( tob1->etaDouble() - tob2->etaDouble() );
+      double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
+      if(dphi>M_PI)
+         dphi = 2*M_PI - dphi;
+
+      double cosheta = cosh ( deta);
+      double cosphi = cos ( dphi);
+      double invmass2 = 2*tob1->Et()*tob2->Et()*(cosheta - cosphi);
+      return round( invmass2 );
+}
+
+unsigned int TSU::LegacyKinematics::calcDeltaR2(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+      double deta = ( tob1->etaDouble() - tob2->etaDouble() );
+      double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
+      if(dphi>M_PI)
+         dphi = 2*M_PI - dphi;
+
+
+      return round ( 100 * ((dphi)*(dphi) + (deta)*(deta) )) ;
+}
+
-- 
GitLab


From b8985abf7094c8472409889b3c3d6a9f88f7017b Mon Sep 17 00:00:00 2001
From: Anil Sonay <anil.sonay@cern.ch>
Date: Thu, 18 Mar 2021 09:13:17 +0100
Subject: [PATCH 2/4] Moving legacy kinematics into main

---
 .../L1Topo/L1TopoEvent/Root/ClusterTOB.cxx    |   2 +-
 .../L1TopoInterfaces/Root/ConfigurableAlg.cxx |  34 ++---
 .../L1TopoSimulationUtils/Kinematics.h        |   5 +
 .../L1TopoSimulationUtils/LegacyKinematics.h  |  45 ------
 .../L1TopoSimulationUtils/Root/Kinematics.cxx |  46 ++++++
 .../Root/LegacyKinematics.cxx                 | 131 ------------------
 6 files changed, 61 insertions(+), 202 deletions(-)
 delete mode 100644 Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/LegacyKinematics.h
 delete mode 100644 Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/LegacyKinematics.cxx

diff --git a/Trigger/TrigT1/L1Topo/L1TopoEvent/Root/ClusterTOB.cxx b/Trigger/TrigT1/L1Topo/L1TopoEvent/Root/ClusterTOB.cxx
index 59ba12a51b5d..fe0101c9cd43 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoEvent/Root/ClusterTOB.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoEvent/Root/ClusterTOB.cxx
@@ -17,7 +17,7 @@ TCS::ClusterTOB::ClusterTOB(uint32_t roiWord) :
 // constructor with initial values
 TCS::ClusterTOB::ClusterTOB(unsigned int et, unsigned int isolation, int eta, int phi, inputTOBType_t tobType, uint32_t roiWord) :
    BaseTOB( roiWord )
-   , m_Et( et )
+   , m_Et( sizeCheck(et, nBitsEt()) )
    , m_isolation( sizeCheck( isolation, nBitsIsolation()) )
    , m_eta( sizeCheck(eta, nBitsEta()) )
    , m_phi( sizeCheck(phi, nBitsPhi()) )
diff --git a/Trigger/TrigT1/L1Topo/L1TopoInterfaces/Root/ConfigurableAlg.cxx b/Trigger/TrigT1/L1Topo/L1TopoInterfaces/Root/ConfigurableAlg.cxx
index f98d4f1ee162..ad30126644b7 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoInterfaces/Root/ConfigurableAlg.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoInterfaces/Root/ConfigurableAlg.cxx
@@ -13,7 +13,6 @@
 #include "L1TopoSimulationUtils/Trigo.h"
 #include "L1TopoSimulationUtils/Hyperbolic.h"
 #include "L1TopoSimulationUtils/Kinematics.h"
-#include "L1TopoSimulationUtils/LegacyKinematics.h"
 
 #include "TH1.h"
 #include "TH2.h"
@@ -120,7 +119,7 @@ ConfigurableAlg::~ConfigurableAlg()
 unsigned int
 ConfigurableAlg::calcDeltaPhiBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
   if (m_isLegacyTopo)
-    {return TSU::LegacyKinematics::calcDeltaPhiBW(tob1,tob2);}
+    {return TSU::Kinematics::calcDeltaPhiBWLegacy(tob1,tob2);}
   else
     {return TSU::Kinematics::calcDeltaPhiBW(tob1,tob2);}
 }
@@ -128,7 +127,7 @@ ConfigurableAlg::calcDeltaPhiBW(const TCS::GenericTOB* tob1, const TCS::GenericT
 unsigned int
 ConfigurableAlg::calcDeltaEtaBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
   if (m_isLegacyTopo)
-    {return TSU::LegacyKinematics::calcDeltaEtaBW(tob1,tob2);}
+    {return TSU::Kinematics::calcDeltaEtaBWLegacy(tob1,tob2);}
   else
     {return TSU::Kinematics::calcDeltaEtaBW(tob1,tob2);}
 }
@@ -136,7 +135,7 @@ ConfigurableAlg::calcDeltaEtaBW(const TCS::GenericTOB* tob1, const TCS::GenericT
 unsigned int
 ConfigurableAlg::calcInvMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
   if (m_isLegacyTopo)
-    {return TSU::LegacyKinematics::calcInvMassBW(tob1,tob2);}
+    {return TSU::Kinematics::calcInvMassBWLegacy(tob1,tob2);}
   else
     {return TSU::Kinematics::calcInvMassBW(tob1,tob2);}
 }
@@ -144,49 +143,34 @@ ConfigurableAlg::calcInvMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTO
 unsigned int
 ConfigurableAlg::calcDeltaR2BW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
   if (m_isLegacyTopo)
-    {return TSU::LegacyKinematics::calcDeltaR2BW(tob1,tob2);}
+    {return TSU::Kinematics::calcDeltaR2BWLegacy(tob1,tob2);}
   else
     {return TSU::Kinematics::calcDeltaR2BW(tob1,tob2);}
 }
 
 unsigned long
 ConfigurableAlg::quadraticSumBW(int i1, int i2) {
-  if (m_isLegacyTopo)
-    {return TSU::LegacyKinematics::quadraticSumBW(i1, i2);}
-  else
-    {return TSU::Kinematics::quadraticSumBW(i1, i2);}
+  return TSU::Kinematics::quadraticSumBW(i1, i2);
 }
 
 unsigned int
 ConfigurableAlg::calcDeltaPhi(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-  if (m_isLegacyTopo)
-    {return TSU::LegacyKinematics::calcDeltaPhi(tob1,tob2);}
-  else
-    {return TSU::Kinematics::calcDeltaPhi(tob1,tob2);}
+  return TSU::Kinematics::calcDeltaPhi(tob1,tob2);
 }
 
 unsigned int
 ConfigurableAlg::calcDeltaEta(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-  if (m_isLegacyTopo)
-    {return TSU::LegacyKinematics::calcDeltaEta(tob1,tob2);}
-  else
-    {return TSU::Kinematics::calcDeltaEta(tob1,tob2);}
+  return TSU::Kinematics::calcDeltaEta(tob1,tob2);
 }
 
 unsigned int
 ConfigurableAlg::calcInvMass(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-  if (m_isLegacyTopo)
-    {return TSU::LegacyKinematics::calcInvMass(tob1,tob2);}
-  else
-    {return TSU::Kinematics::calcInvMass(tob1,tob2);}
+  return TSU::Kinematics::calcInvMass(tob1,tob2);
 }
 
 unsigned int
 ConfigurableAlg::calcDeltaR2(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-  if (m_isLegacyTopo)
-    {return TSU::LegacyKinematics::calcDeltaR2(tob1,tob2);}
-  else
-    {return TSU::Kinematics::calcDeltaR2(tob1,tob2);}
+  return TSU::Kinematics::calcDeltaR2(tob1,tob2);
 }
 
 
diff --git a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/Kinematics.h b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/Kinematics.h
index 5d924375fd5f..7032ff425502 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/Kinematics.h
+++ b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/Kinematics.h
@@ -16,6 +16,11 @@
 
 namespace TSU { 
    struct Kinematics {
+	static unsigned int calcDeltaPhiBWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);		
+	static unsigned int calcDeltaEtaBWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+
+	static unsigned int calcInvMassBWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+	static unsigned int calcDeltaR2BWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
 	static unsigned int calcDeltaPhiBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);		
 	static unsigned int calcDeltaEtaBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
 
diff --git a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/LegacyKinematics.h b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/LegacyKinematics.h
deleted file mode 100644
index c14da015f021..000000000000
--- a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/LegacyKinematics.h
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
-  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
-*/
-
-// LegacyKinematics.h
-
-
-#ifndef TSU_LegacyKinematics
-#define TSU_LegacyKinematics
-
-//the file 'requirements' in cmt can get you this L1TopoEvent
-#include "L1TopoEvent/GenericTOB.h"
-#include <iostream>
-#include <vector>
-
-namespace TSU { 
-   struct LegacyKinematics {
-	static unsigned int calcDeltaPhiBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);		
-	static unsigned int calcDeltaEtaBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
-
-	static unsigned int calcInvMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
-	static unsigned int calcDeltaR2BW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
-     /**
-        @brief compute the sum in quadrature of two ints
-
-        This function includes an integer square root implementation using a bitwise iterative approach.
-        Square root is computed bit-by-bit (highest significance bits first) and the result is
-        adjusted up- or downwards in each iteration based on whether or not the current result
-        under- or overestimates the value of the sum of squares.
-
-        That is the same way in which the sqrt int is implemented in firmware:
-            processor/sources/common/libraries/L1TopoFunctions.vhd
-            --> function sqrt(d : UNSIGNED) return UNSIGNED
-      */
-	static unsigned long quadraticSumBW(int i1, int i2);
-
-	static unsigned int calcDeltaPhi(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
-	static unsigned int calcDeltaEta(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
-	static unsigned int calcInvMass(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
-	static unsigned int calcDeltaR2(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
-   };
-
-} // end of namespace TSU
-
-#endif
diff --git a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Kinematics.cxx b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Kinematics.cxx
index 75b5d37f5446..044494f998e8 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Kinematics.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Kinematics.cxx
@@ -18,6 +18,52 @@
 
 using namespace std; 
 
+unsigned int TSU::Kinematics::calcDeltaPhiBWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2){
+      int dphiB = abs( tob1->phi() - tob2->phi() );
+      if(dphiB>64)
+         dphiB = dphiB - 64;
+      if(dphiB>32)
+         dphiB = 64 - dphiB;
+
+      return dphiB ;
+}
+
+unsigned int TSU::Kinematics::calcDeltaEtaBWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+      double deta = abs( tob1->eta() - tob2->eta() );
+	return deta;
+}
+
+unsigned int TSU::Kinematics::calcInvMassBWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2){
+
+  auto bit_cosheta = TSU::L1TopoDataTypes<19,7>(TSU::Hyperbolic::Cosh.at(abs(tob1->eta() - tob2->eta())));
+  //In case of EM objects / jets / taus the phi angle goes between 0 and 64 while muons are between -32 and 32, applying a shift to keep delta-phi in the allowed range. 
+  int phi_tob1 = tob1->phi();
+  int phi_tob2 = tob2->phi();
+  //those cases should happen only in mixed EM/jets/tau plus mu triggers, if both phi's are in [0,2pi] will not get in
+  if ( abs(phi_tob1-phi_tob2)>=64 )
+    {
+      if(phi_tob1 >= 32) phi_tob1 = phi_tob1-64;
+      if(phi_tob2 >= 32) phi_tob2 = phi_tob2-64;
+    }
+  auto bit_cosphi = TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Cos.at(abs( phi_tob1 - phi_tob2 )));
+  TSU::L1TopoDataTypes<11,0> bit_Et1(tob1->Et());
+  TSU::L1TopoDataTypes<11,0> bit_Et2(tob2->Et());
+  auto bit_invmass2 = bit_Et1*bit_Et2*(bit_cosheta - bit_cosphi)*2;
+  return int(bit_invmass2) ;
+}
+
+unsigned int TSU::Kinematics::calcDeltaR2BWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+      int detaB = abs( tob1->eta() - tob2->eta() );
+      int dphiB = abs( tob1->phi() - tob2->phi() );
+      if(dphiB>64) //Probably same error here as in DeltaPhiBW. Check
+         dphiB = dphiB - 64;
+      if(dphiB>32)
+         dphiB = 64 - dphiB;
+
+      unsigned int bit_dr2 = dphiB*dphiB + detaB*detaB;
+      return bit_dr2;
+}
+
 unsigned int TSU::Kinematics::calcDeltaPhiBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2){
       int dphiB = abs( tob1->phi() - tob2->phi() );
       if(dphiB>64)
diff --git a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/LegacyKinematics.cxx b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/LegacyKinematics.cxx
deleted file mode 100644
index dfca7cdcb80b..000000000000
--- a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/LegacyKinematics.cxx
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
-  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
-*/
-
-#include <cmath>
-#include <string>
-#include <iostream>
-#include <sstream>
-#include <vector>
-
-#include "L1TopoSimulationUtils/LegacyKinematics.h"
-#include "L1TopoSimulationUtils/Hyperbolic.h"
-#include "L1TopoSimulationUtils/L1TopoDataTypes.h"
-#include "L1TopoSimulationUtils/Trigo.h"
-#include "L1TopoEvent/GenericTOB.h"
-
-//
-
-using namespace std; 
-
-unsigned int TSU::LegacyKinematics::calcDeltaPhiBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2){
-      int dphiB = abs( tob1->phi() - tob2->phi() );
-      if(dphiB>64)
-         dphiB = dphiB - 64;
-      if(dphiB>32)
-         dphiB = 64 - dphiB;
-
-      return dphiB ;
-}
-
-unsigned int TSU::LegacyKinematics::calcDeltaEtaBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      double deta = abs( tob1->eta() - tob2->eta() );
-	return deta;
-}
-
-unsigned int TSU::LegacyKinematics::calcInvMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2){
-
-  auto bit_cosheta = TSU::L1TopoDataTypes<19,7>(TSU::Hyperbolic::Cosh.at(abs(tob1->eta() - tob2->eta())));
-  //In case of EM objects / jets / taus the phi angle goes between 0 and 64 while muons are between -32 and 32, applying a shift to keep delta-phi in the allowed range. 
-  int phi_tob1 = tob1->phi();
-  int phi_tob2 = tob2->phi();
-  //those cases should happen only in mixed EM/jets/tau plus mu triggers, if both phi's are in [0,2pi] will not get in
-  if ( abs(phi_tob1-phi_tob2)>=64 )
-    {
-      if(phi_tob1 >= 32) phi_tob1 = phi_tob1-64;
-      if(phi_tob2 >= 32) phi_tob2 = phi_tob2-64;
-    }
-  auto bit_cosphi = TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Cos.at(abs( phi_tob1 - phi_tob2 )));
-  TSU::L1TopoDataTypes<11,0> bit_Et1(tob1->Et());
-  TSU::L1TopoDataTypes<11,0> bit_Et2(tob2->Et());
-  auto bit_invmass2 = bit_Et1*bit_Et2*(bit_cosheta - bit_cosphi)*2;
-  return int(bit_invmass2) ;
-}
-
-unsigned int TSU::LegacyKinematics::calcDeltaR2BW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      int detaB = abs( tob1->eta() - tob2->eta() );
-      int dphiB = abs( tob1->phi() - tob2->phi() );
-      if(dphiB>64) //Probably same error here as in DeltaPhiBW. Check
-         dphiB = dphiB - 64;
-      if(dphiB>32)
-         dphiB = 64 - dphiB;
-
-      unsigned int bit_dr2 = dphiB*dphiB + detaB*detaB;
-      return bit_dr2;
-}
-
-unsigned long TSU::LegacyKinematics::quadraticSumBW(int i1, int i2){
-    unsigned int ui1 = i1, ui2=i2;
-    unsigned int a = ui1*ui1 + ui2*ui2; 
-
-    unsigned int result=0;
-    int left=0, right=0; 
-    unsigned int r=0;
-    int sign=0;
-  
-    //The values for halflength and bitmask enforce the
-    //bitwise overflow limit, not the precision of the chosen C++ parameters
-    int halflength = 16; //max 16
-    unsigned int bitmask = 0b11111111111111111111111111111111; //32 bits
-    bitmask >>= (32 - halflength*2); //does nothing unless halflength changes
-  
-    for(int i = 0; i < halflength; i++){ //16-->4
-        right = 1 + (sign<<1) + (result<<2);
-        left = (r<<2) + (a >> (2*halflength-2));
-        a <<= 2;
-        a = a & bitmask;
-        r = sign ? (left + right) : (left - right);
-        sign = ((r & (1 << (halflength+1) ))  > 0) ? 1 : 0;
-        result <<= 1;
-        if(sign==0) result += 1;
-    }
-    return result;
-}
-
-/*------------------------------------------ NON-BITWISE --------------------------------------------------*/
-
-unsigned int TSU::LegacyKinematics::calcDeltaPhi(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
-      if(dphi>M_PI)
-         dphi = 2*M_PI - dphi;
-
-      return round( 10 * dphi );
-}
-
-unsigned int TSU::LegacyKinematics::calcDeltaEta(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      double deta = fabs( tob1->eta() - tob2->eta() );
-	return deta;
-}
-
-unsigned int TSU::LegacyKinematics::calcInvMass(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      double deta = fabs( tob1->etaDouble() - tob2->etaDouble() );
-      double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
-      if(dphi>M_PI)
-         dphi = 2*M_PI - dphi;
-
-      double cosheta = cosh ( deta);
-      double cosphi = cos ( dphi);
-      double invmass2 = 2*tob1->Et()*tob2->Et()*(cosheta - cosphi);
-      return round( invmass2 );
-}
-
-unsigned int TSU::LegacyKinematics::calcDeltaR2(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      double deta = ( tob1->etaDouble() - tob2->etaDouble() );
-      double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
-      if(dphi>M_PI)
-         dphi = 2*M_PI - dphi;
-
-
-      return round ( 100 * ((dphi)*(dphi) + (deta)*(deta) )) ;
-}
-
-- 
GitLab


From 0d8c2f3da58285c700870e9afa9a4629d63261f4 Mon Sep 17 00:00:00 2001
From: Anil Sonay <anil.sonay@cern.ch>
Date: Thu, 18 Mar 2021 13:36:28 +0100
Subject: [PATCH 3/4] Propogate to all algos

---
 .../Root/ClusterAbbreviated.cxx               |   2 +-
 .../L1TopoAlgorithms/Root/ClusterNoSort.cxx   |   2 +-
 .../L1TopoAlgorithms/Root/ClusterSelect.cxx   |   2 +-
 .../L1TopoAlgorithms/Root/ClusterSort.cxx     |   2 +-
 .../Root/ClusterSortingAlg.cxx                |   2 +-
 .../L1TopoAlgorithms/Root/DeltaEtaIncl1.cxx   |   8 +-
 .../L1TopoAlgorithms/Root/DeltaEtaIncl2.cxx   |   8 +-
 .../Root/DeltaEtaPhiIncl1.cxx                 |  13 +-
 .../Root/DeltaEtaPhiIncl2.cxx                 |  13 +-
 .../L1TopoAlgorithms/Root/DeltaPhiIncl1.cxx   |   8 +-
 .../L1TopoAlgorithms/Root/DeltaPhiIncl2.cxx   |   8 +-
 .../Root/DeltaRApproxBoxCutIncl1.cxx          |   4 +-
 .../Root/DeltaRApproxBoxCutIncl2.cxx          |   4 +-
 .../L1TopoAlgorithms/Root/DeltaRSqrIncl1.cxx  |   9 +-
 .../L1TopoAlgorithms/Root/DeltaRSqrIncl2.cxx  |   7 +-
 .../Root/DisambiguationDRIncl2.cxx            |   7 +-
 .../Root/DisambiguationDRIncl3.cxx            |  15 +-
 .../Root/DisambiguationDetaDPhiIncl3.cxx      |  19 +-
 .../Root/DisambiguationIncl2.cxx              |   7 +-
 .../Root/DisambiguationIncl3.cxx              |  11 +-
 .../Root/DisambiguationInvmIncl2.cxx          |   6 +-
 .../L1TopoAlgorithms/Root/EMMultiplicity.cxx  |   5 +-
 .../L1Topo/L1TopoAlgorithms/Root/EtCut.cxx    |   2 +-
 .../L1TopoAlgorithms/Root/EtaPhiWindow.cxx    |   6 +-
 .../L1TopoAlgorithms/Root/ExclusiveJets.cxx   |  12 +-
 .../Root/GenericArrayCreator.cxx              |   2 +-
 .../Root/GenericListGenerator.cxx             |   2 +-
 .../Root/InvariantMassDeltaPhiInclusive2.cxx  |  10 +-
 .../InvariantMassDeltaPhiInclusive2Charge.cxx |  16 +-
 .../Root/InvariantMassInclusive1.cxx          |  13 +-
 .../Root/InvariantMassInclusive2.cxx          |  14 +-
 .../InvariantMassInclusiveDeltaRSqrIncl1.cxx  |  18 +-
 .../InvariantMassInclusiveDeltaRSqrIncl2.cxx  |  18 +-
 .../Root/InvariantMassThreeTOBsIncl.cxx       |  23 +--
 .../Root/InvariantMassThreeTOBsInclCharge.cxx |  20 +-
 .../L1TopoAlgorithms/Root/JetAbbreviated.cxx  |   2 +-
 .../L1Topo/L1TopoAlgorithms/Root/JetHT.cxx    |   3 +-
 .../L1Topo/L1TopoAlgorithms/Root/JetMatch.cxx |   2 +-
 .../L1TopoAlgorithms/Root/JetNoSort.cxx       |   2 +-
 .../L1TopoAlgorithms/Root/JetNoSortMatch.cxx  |   2 +-
 .../L1TopoAlgorithms/Root/JetSelect.cxx       |   2 +-
 .../L1Topo/L1TopoAlgorithms/Root/JetSort.cxx  |   2 +-
 .../L1TopoAlgorithms/Root/JetSortingAlg.cxx   |   2 +-
 .../Root/JetSortingAlgSize1.cxx               |   2 +-
 .../Root/JetSortingAlgSize2.cxx               |   2 +-
 .../Root/KalmanMETCorrection.cxx              |   5 +-
 .../L1Topo/L1TopoAlgorithms/Root/LAr.cxx      |   2 +-
 .../L1Topo/L1TopoAlgorithms/Root/METCut.cxx   |   2 +-
 .../L1TopoAlgorithms/Root/METNoSort.cxx       |   2 +-
 .../L1TopoAlgorithms/Root/METSortingAlg.cxx   |   2 +-
 .../L1Topo/L1TopoAlgorithms/Root/MetSort.cxx  |   7 +-
 .../Root/MinDeltaPhiIncl2.cxx                 |   9 +-
 .../L1TopoAlgorithms/Root/Multiplicity.cxx    |   2 +-
 .../Root/MultiplicityCustom.cxx               |   2 +-
 .../L1TopoAlgorithms/Root/MuonAbbreviated.cxx |   2 +-
 .../L1TopoAlgorithms/Root/MuonNoSort.cxx      |   2 +-
 .../L1TopoAlgorithms/Root/MuonSelect.cxx      |   2 +-
 .../L1Topo/L1TopoAlgorithms/Root/MuonSort.cxx |   2 +-
 .../L1TopoAlgorithms/Root/MuonSort_1BC.cxx    |   2 +-
 .../L1Topo/L1TopoAlgorithms/Root/NotMatch.cxx |   2 +-
 .../L1Topo/L1TopoAlgorithms/Root/Ratio.cxx    |   2 +-
 .../L1Topo/L1TopoAlgorithms/Root/Ratio2.cxx   |   2 +-
 .../L1TopoAlgorithms/Root/RatioMatch.cxx      |   2 +-
 .../L1Topo/L1TopoAlgorithms/Root/RatioSum.cxx |   2 +-
 .../L1TopoAlgorithms/Root/SimpleCone.cxx      |   3 +-
 .../Root/TransverseMassInclusive1.cxx         |  36 +---
 .../L1TopoInterfaces/ConfigurableAlg.h        |   2 +
 .../L1TopoInterfaces/Root/ConfigurableAlg.cxx |  13 ++
 .../L1TopoSimulationUtils/Kinematics.h        |   3 +
 .../L1TopoSimulationUtils/Root/Kinematics.cxx | 179 ++++++++++--------
 70 files changed, 262 insertions(+), 366 deletions(-)

diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterAbbreviated.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterAbbreviated.cxx
index 0d8554754973..9776db58acea 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterAbbreviated.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterAbbreviated.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  ClusterAbbreviated.cxx
 //  TopoCore
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterNoSort.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterNoSort.cxx
index 34f6085a8ddf..d2b3241b6b4c 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterNoSort.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterNoSort.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  ClusterNoSort.cxx
 //  TopoCore
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterSelect.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterSelect.cxx
index 619535b3320e..5945adb170f5 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterSelect.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterSelect.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  ClusterSelect.cxx
 //  TopoCore
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterSort.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterSort.cxx
index f9992a961247..2861daff18c7 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterSort.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterSort.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  ClusterSort.cxx
 //  TopoCore
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterSortingAlg.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterSortingAlg.cxx
index 969be0fa953a..ee3e2ed38a8b 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterSortingAlg.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ClusterSortingAlg.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  ClusterSortingAlg.cxx
 //  TopoCore
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaEtaIncl1.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaEtaIncl1.cxx
index df377622a24c..b13c14b24743 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaEtaIncl1.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaEtaIncl1.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * DeltaEtaIncl1.cpp
@@ -16,12 +16,10 @@
 #include <iostream>
 #include <sstream>
 #include <vector>
-#include "TH1F.h"
 
 #include "L1TopoAlgorithms/DeltaEtaIncl1.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
 
 REGISTER_ALG_TCS(DeltaEtaIncl1)
 
@@ -124,7 +122,7 @@ TCS::DeltaEtaIncl1::processBitCorrect( const std::vector<TCS::TOBArray const *>
                    if( parType_t((*tob2)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
                    if( (parType_t((*tob1)->Et()) <= std::max(p_MinET1[i],p_MinET2[i])) && (parType_t((*tob2)->Et()) <= std::max(p_MinET1[i],p_MinET2[i]))) continue;
                    // DeltaEta cuts
-                   unsigned int deltaEta = TSU::Kinematics::calcDeltaEtaBW( *tob1, *tob2 );
+                   unsigned int deltaEta = calcDeltaEtaBW( *tob1, *tob2 );
                    std::stringstream msgss;
                    msgss << "Combination : " << distance( input[0]->begin(), tob1)
                          << " x " << distance( input[0]->begin(), tob2)
@@ -178,7 +176,7 @@ TCS::DeltaEtaIncl1::process( const std::vector<TCS::TOBArray const *> & input,
                    if( parType_t((*tob2)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
                    if( (parType_t((*tob1)->Et()) <= std::max(p_MinET1[i],p_MinET2[i])) && (parType_t((*tob2)->Et()) <= std::max(p_MinET1[i],p_MinET2[i]))) continue;
                    // DeltaEta cuts
-                   unsigned int deltaEta = TSU::Kinematics::calcDeltaEta( *tob1, *tob2 );
+                   unsigned int deltaEta = calcDeltaEta( *tob1, *tob2 );
                    std::stringstream msgss;
                    msgss << "Combination : " << distance( input[0]->begin(), tob1)
                          << " x " << distance( input[0]->begin(), tob2)
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaEtaIncl2.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaEtaIncl2.cxx
index 4ec3f32b1c81..4838f0693e4c 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaEtaIncl2.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaEtaIncl2.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * DeltaEtaIncl2.cpp
@@ -16,12 +16,10 @@
 #include <iostream>
 #include <sstream>
 #include <vector>
-#include "TH1F.h"
 
 #include "L1TopoAlgorithms/DeltaEtaIncl2.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
 
 REGISTER_ALG_TCS(DeltaEtaIncl2)
 
@@ -115,7 +113,7 @@ TCS::DeltaEtaIncl2::processBitCorrect( const std::vector<TCS::TOBArray const *>
                      tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
                      ++tob2) {
                     // test DeltaEtaMin, DeltaEtaMax
-                    unsigned int deltaEta = TSU::Kinematics::calcDeltaEtaBW( *tob1, *tob2 );
+                    unsigned int deltaEta = calcDeltaEtaBW( *tob1, *tob2 );
                     for(unsigned int i=0; i<numberOutputBits(); ++i) {
                         bool accept = false;
                         if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
@@ -158,7 +156,7 @@ TCS::DeltaEtaIncl2::process( const std::vector<TCS::TOBArray const *> & input,
                      tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
                      ++tob2) {
                     // test DeltaEtaMin, DeltaEtaMax
-                    unsigned int deltaEta = TSU::Kinematics::calcDeltaEta( *tob1, *tob2 );
+                    unsigned int deltaEta = calcDeltaEta( *tob1, *tob2 );
                     for(unsigned int i=0; i<numberOutputBits(); ++i) {
                         bool accept = false;
                         if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaEtaPhiIncl1.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaEtaPhiIncl1.cxx
index f367d26cd34d..959b10635205 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaEtaPhiIncl1.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaEtaPhiIncl1.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * DeltaEtaPhiIncl1.cpp
@@ -12,13 +12,10 @@
 **********************************/
 
 #include <cmath>
-#include "TH1F.h"
-#include "TH2F.h"
 
 #include "L1TopoAlgorithms/DeltaEtaPhiIncl1.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
 
 REGISTER_ALG_TCS(DeltaEtaPhiIncl1)
 
@@ -114,9 +111,9 @@ TCS::DeltaEtaPhiIncl1::processBitCorrect( const std::vector<TCS::TOBArray const
                     tob2 != input[0]->end() && distance( input[0]->begin(), tob2) < p_NumberLeading2;
                     ++tob2) {
                    // DeltaPhi cuts
-                   unsigned int deltaPhi = TSU::Kinematics::calcDeltaPhiBW( *tob1, *tob2 );
+                   unsigned int deltaPhi = calcDeltaPhiBW( *tob1, *tob2 );
                    // DeltaEta cuts
-                   unsigned int deltaEta = TSU::Kinematics::calcDeltaEtaBW( *tob1, *tob2 );
+                   unsigned int deltaEta = calcDeltaEtaBW( *tob1, *tob2 );
                    //
                    // to-do change message output
                    std::stringstream msgss;
@@ -168,9 +165,9 @@ TCS::DeltaEtaPhiIncl1::process( const std::vector<TCS::TOBArray const *> & input
                      tob2 != input[0]->end() && distance( input[0]->begin(), tob2) < p_NumberLeading2;
                      ++tob2) {
                     // DeltaPhi cuts
-                    unsigned int deltaPhi = TSU::Kinematics::calcDeltaPhi( *tob1, *tob2 );
+                    unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
                     // DeltaEta cuts
-                    unsigned int deltaEta = TSU::Kinematics::calcDeltaEta( *tob1, *tob2 );
+                    unsigned int deltaEta = calcDeltaEta( *tob1, *tob2 );
                     //
                     // to-do change message output
                     std::stringstream msgss;
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaEtaPhiIncl2.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaEtaPhiIncl2.cxx
index acb8953eb78b..f0dbc75a2bc8 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaEtaPhiIncl2.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaEtaPhiIncl2.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * DeltaEtaPhiIncl2.cpp
@@ -11,13 +11,10 @@
 **********************************/
 
 #include <cmath>
-#include "TH1F.h"
-#include "TH2F.h"
 
 #include "L1TopoAlgorithms/DeltaEtaPhiIncl2.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
 
 
 REGISTER_ALG_TCS(DeltaEtaPhiIncl2)
@@ -114,9 +111,9 @@ TCS::DeltaEtaPhiIncl2::processBitCorrect( const std::vector<TCS::TOBArray const
                      tob2 != input[1]->end() && distance( input[1]->begin(), tob2) < p_NumberLeading2;
                      ++tob2) {
                     // DeltaPhi cuts
-                    unsigned int deltaPhi = TSU::Kinematics::calcDeltaPhiBW( *tob1, *tob2 );
+                    unsigned int deltaPhi = calcDeltaPhiBW( *tob1, *tob2 );
                     // DeltaEta cuts
-                    unsigned int deltaEta = TSU::Kinematics::calcDeltaEtaBW( *tob1, *tob2 );
+                    unsigned int deltaEta = calcDeltaEtaBW( *tob1, *tob2 );
                     //
                     // to-do change message output
                     std::stringstream msgss;
@@ -167,9 +164,9 @@ TCS::DeltaEtaPhiIncl2::process( const std::vector<TCS::TOBArray const *> & input
                      tob2 != input[1]->end() && distance( input[1]->begin(), tob2) < p_NumberLeading2;
                      ++tob2) {
                     // DeltaPhi cuts
-                    unsigned int deltaPhi = TSU::Kinematics::calcDeltaPhi( *tob1, *tob2 );
+                    unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
                     // DeltaEta cuts
-                    unsigned int deltaEta = TSU::Kinematics::calcDeltaEta( *tob1, *tob2 );
+                    unsigned int deltaEta = calcDeltaEta( *tob1, *tob2 );
                     //
                     // to-do change message output
                     std::stringstream msgss;
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaPhiIncl1.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaPhiIncl1.cxx
index 115e4b6df41e..993182c087b8 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaPhiIncl1.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaPhiIncl1.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * DeltaPhiIncl1.cpp
@@ -12,12 +12,10 @@
 **********************************/
 
 #include <cmath>
-#include "TH1F.h"
 
 #include "L1TopoAlgorithms/DeltaPhiIncl1.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
 
 REGISTER_ALG_TCS(DeltaPhiIncl1)
 
@@ -103,7 +101,7 @@ TCS::DeltaPhiIncl1::processBitCorrect( const std::vector<TCS::TOBArray const *>
                      tob2 != input[0]->end() && distance( input[0]->begin(), tob2) < nLeading2;
                      ++tob2) {
                     // DeltaPhi cuts
-                    unsigned int deltaPhi = TSU::Kinematics::calcDeltaPhiBW( *tob1, *tob2 );
+                    unsigned int deltaPhi = calcDeltaPhiBW( *tob1, *tob2 );
                     std::stringstream msgss;
                     msgss << "  phi1=" << (*tob1)->phi() << " , phi2=" << (*tob2)->phi()
                           << ", DeltaPhi = " << deltaPhi << " -> ";
@@ -154,7 +152,7 @@ TCS::DeltaPhiIncl1::process( const std::vector<TCS::TOBArray const *> & input,
                      tob2 != input[0]->end() && distance( input[0]->begin(), tob2) < nLeading2;
                      ++tob2) {
                     // DeltaPhi cuts
-                    unsigned int deltaPhi = TSU::Kinematics::calcDeltaPhi( *tob1, *tob2 );
+                    unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
                     std::stringstream msgss;
                     msgss << "    Combination : " << distance( input[0]->begin(), tob1) 
                           << " x " << distance( input[0]->begin(), tob2)
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaPhiIncl2.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaPhiIncl2.cxx
index cd782796a491..cc5c111a0114 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaPhiIncl2.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaPhiIncl2.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * DeltaPhiIncl2.cpp
@@ -16,12 +16,10 @@
 #include <iostream>
 #include <sstream>
 #include <vector>
-#include "TH1F.h"
 
 #include "L1TopoAlgorithms/DeltaPhiIncl2.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
 
 REGISTER_ALG_TCS(DeltaPhiIncl2)
 
@@ -101,7 +99,7 @@ TCS::DeltaPhiIncl2::processBitCorrect( const std::vector<TCS::TOBArray const *>
                      tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
                      ++tob2) {
                     // test DeltaPhiMin, DeltaPhiMax
-                    unsigned int deltaPhi = TSU::Kinematics::calcDeltaPhiBW( *tob1, *tob2 );
+                    unsigned int deltaPhi = calcDeltaPhiBW( *tob1, *tob2 );
                     for(unsigned int i=0; i<numberOutputBits(); ++i) {
                         bool accept = false;
                         if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
@@ -146,7 +144,7 @@ TCS::DeltaPhiIncl2::process( const std::vector<TCS::TOBArray const *> & input,
                      tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
                      ++tob2) {
                     // test DeltaPhiMin, DeltaPhiMax
-                    unsigned int deltaPhi = TSU::Kinematics::calcDeltaPhi( *tob1, *tob2 );
+                    unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
                     for(unsigned int i=0; i<numberOutputBits(); ++i) {
                         bool accept = false;
                         if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRApproxBoxCutIncl1.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRApproxBoxCutIncl1.cxx
index e2cf410a650d..163adf00e552 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRApproxBoxCutIncl1.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRApproxBoxCutIncl1.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * DeltaRApproxBoxCutIncl1.cpp
@@ -12,8 +12,6 @@
 **********************************/
 
 #include <cmath>
-#include "TH1F.h"
-#include "TH2F.h"
 
 #include "L1TopoAlgorithms/DeltaRApproxBoxCutIncl1.h"
 #include "L1TopoCommon/Exception.h"
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRApproxBoxCutIncl2.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRApproxBoxCutIncl2.cxx
index 75ab6e330219..ae79e57d695a 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRApproxBoxCutIncl2.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRApproxBoxCutIncl2.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * DeltaRApproxBoxCutIncl2.cpp
@@ -11,8 +11,6 @@
 **********************************/
 
 #include <cmath>
-#include "TH1F.h"
-#include "TH2F.h"
 
 #include "L1TopoAlgorithms/DeltaRApproxBoxCutIncl2.h"
 #include "L1TopoCommon/Exception.h"
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRSqrIncl1.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRSqrIncl1.cxx
index 693ed0743733..f21a7a69ea9b 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRSqrIncl1.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRSqrIncl1.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * DeltaRSqrIncl1.cpp
@@ -11,13 +11,10 @@
 **********************************/
 
 #include <cmath>
-#include "TH1F.h"
-#include "TH2F.h"
 
 #include "L1TopoAlgorithms/DeltaRSqrIncl1.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
 
 REGISTER_ALG_TCS(DeltaRSqrIncl1)
 
@@ -111,7 +108,7 @@ TCS::DeltaRSqrIncl1::processBitCorrect( const std::vector<TCS::TOBArray const *>
                   // OneBarrel
                   if (p_OneBarrel && parType_t(abs((*tob1)->eta())) > 10 && parType_t(abs((*tob2)->eta())) > 10 ) continue;
                   // DeltaR2 cuts
-                  unsigned int deltaR2 = TSU::Kinematics::calcDeltaR2BW( *tob1, *tob2 );
+                  unsigned int deltaR2 = calcDeltaR2BW( *tob1, *tob2 );
                   for(unsigned int i=0; i<numberOutputBits(); ++i) {
 		    bool accept = false;
 		    accept = deltaR2 >= p_DeltaRMin[i] && deltaR2 <= p_DeltaRMax[i];
@@ -157,7 +154,7 @@ TCS::DeltaRSqrIncl1::process( const std::vector<TCS::TOBArray const *> & input,
                     // OneBarrel
                     if (p_OneBarrel && parType_t(abs((*tob1)->eta())) > 10 && parType_t(abs((*tob2)->eta())) > 10 ) continue;
                     // DeltaR2 cuts
-                    unsigned int deltaR2 = TSU::Kinematics::calcDeltaR2( *tob1, *tob2 );
+                    unsigned int deltaR2 = calcDeltaR2( *tob1, *tob2 );
                     for(unsigned int i=0; i<numberOutputBits(); ++i) {
 		      bool accept = false;
 		      accept = deltaR2 >= p_DeltaRMin[i] && deltaR2 <= p_DeltaRMax[i];
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRSqrIncl2.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRSqrIncl2.cxx
index e6213716dbb1..f81203196f5b 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRSqrIncl2.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DeltaRSqrIncl2.cxx
@@ -11,13 +11,10 @@
 **********************************/
 
 #include <cmath>
-#include "TH1F.h"
-#include "TH2F.h"
 
 #include "L1TopoAlgorithms/DeltaRSqrIncl2.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
 
 REGISTER_ALG_TCS(DeltaRSqrIncl2)
 
@@ -105,7 +102,7 @@ TCS::DeltaRSqrIncl2::processBitCorrect( const std::vector<TCS::TOBArray const *>
                   tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
                   ++tob2) {
                  // test DeltaR2Min, DeltaR2Max
-                 unsigned int deltaR2 = TSU::Kinematics::calcDeltaR2BW( *tob1, *tob2 );
+                 unsigned int deltaR2 = calcDeltaR2BW( *tob1, *tob2 );
                  TRG_MSG_DEBUG("Jet1 = " << **tob1 << ", Jet2 = " << **tob2 << ", deltaR2 = " << deltaR2);
                  for(unsigned int i=0; i<numberOutputBits(); ++i) {
                    bool accept = false;
@@ -152,7 +149,7 @@ TCS::DeltaRSqrIncl2::process( const std::vector<TCS::TOBArray const *> & input,
                  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
                  ++tob2) {
                // test DeltaR2Min, DeltaR2Max
-               unsigned int deltaR2 = TSU::Kinematics::calcDeltaR2( *tob1, *tob2 );
+               unsigned int deltaR2 = calcDeltaR2( *tob1, *tob2 );
 
                TRG_MSG_DEBUG("Jet1 = " << **tob1 << ", Jet2 = " << **tob2 << ", deltaR2 = " << deltaR2);
                for(unsigned int i=0; i<numberOutputBits(); ++i) {
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationDRIncl2.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationDRIncl2.cxx
index 5e19282c2005..b8ac8058638e 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationDRIncl2.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationDRIncl2.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * DisambiguationDRIncl2.cpp
@@ -16,7 +16,6 @@
 #include "L1TopoAlgorithms/DisambiguationDRIncl2.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
 
 REGISTER_ALG_TCS(DisambiguationDRIncl2)
 
@@ -102,7 +101,7 @@ TCS::DisambiguationDRIncl2::processBitCorrect( const std::vector<TCS::TOBArray c
                  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
                  ++tob2) {
                 // test DeltaR2Min, DeltaR2Max
-                unsigned int deltaR2Cut = TSU::Kinematics::calcDeltaR2BW( *tob1, *tob2 );
+                unsigned int deltaR2Cut = calcDeltaR2BW( *tob1, *tob2 );
                 for(unsigned int i=0; i<numberOutputBits(); ++i) {
                     bool accept = false;
                     if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
@@ -151,7 +150,7 @@ TCS::DisambiguationDRIncl2::process( const std::vector<TCS::TOBArray const *> &
                   tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
                   ++tob2) {
                  // test DeltaR2Min, DeltaR2Max
-                 unsigned int deltaR2Cut = TSU::Kinematics::calcDeltaR2( *tob1, *tob2 );
+                 unsigned int deltaR2Cut = calcDeltaR2( *tob1, *tob2 );
                  for(unsigned int i=0; i<numberOutputBits(); ++i) {
                      bool accept = false;
                      if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationDRIncl3.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationDRIncl3.cxx
index 66281666584f..1e7ac1203e83 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationDRIncl3.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationDRIncl3.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * DisambiguationDRIncl3.cpp
@@ -16,7 +16,6 @@
 #include "L1TopoAlgorithms/DisambiguationDRIncl3.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
 
 REGISTER_ALG_TCS(DisambiguationDRIncl3)
 
@@ -116,13 +115,13 @@ TCS::DisambiguationDRIncl3::processBitCorrect( const std::vector<TCS::TOBArray c
 
 
                // test DeltaR2Min, DeltaR2Max
-               unsigned int deltaR2Cut = TSU::Kinematics::calcDeltaR2BW( *tob1, *tob2 );
+               unsigned int deltaR2Cut = calcDeltaR2BW( *tob1, *tob2 );
                
                for( TCS::TOBArray::const_iterator tob3 = input[2]->begin();
                     tob3 != input[2]->end() ;
                     ++tob3) {
-                   unsigned int deltaR13 = TSU::Kinematics::calcDeltaR2BW( *tob1, *tob3 );
-                   unsigned int deltaR23 = TSU::Kinematics::calcDeltaR2BW( *tob2, *tob3 );
+                   unsigned int deltaR13 = calcDeltaR2BW( *tob1, *tob3 );
+                   unsigned int deltaR23 = calcDeltaR2BW( *tob2, *tob3 );
                    for(unsigned int i=0; i<numberOutputBits(); ++i) {
                        bool accept = false;
                        if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
@@ -170,13 +169,13 @@ TCS::DisambiguationDRIncl3::process( const std::vector<TCS::TOBArray const *> &
 
 
                // test DeltaR2Min, DeltaR2Max
-               unsigned int deltaR2Cut = TSU::Kinematics::calcDeltaR2( *tob1, *tob2 );
+               unsigned int deltaR2Cut = calcDeltaR2( *tob1, *tob2 );
                
                for( TCS::TOBArray::const_iterator tob3 = input[2]->begin();
                     tob3 != input[2]->end() ;
                     ++tob3) {
-                   unsigned int deltaR13 = TSU::Kinematics::calcDeltaR2( *tob1, *tob3 );
-                   unsigned int deltaR23 = TSU::Kinematics::calcDeltaR2( *tob2, *tob3 );
+                   unsigned int deltaR13 = calcDeltaR2( *tob1, *tob3 );
+                   unsigned int deltaR23 = calcDeltaR2( *tob2, *tob3 );
                    for(unsigned int i=0; i<numberOutputBits(); ++i) {
                        bool accept = false;
                        if( parType_t((*tob1)->Et()) <= p_MinET1[i]) continue; // ET cut
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationDetaDPhiIncl3.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationDetaDPhiIncl3.cxx
index d16a33b25cbe..0f4a7979d9e4 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationDetaDPhiIncl3.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationDetaDPhiIncl3.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * DisambiguationDetaDPhiIncl3.cpp
@@ -16,7 +16,6 @@
 #include "L1TopoAlgorithms/DisambiguationDetaDPhiIncl3.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
 
 REGISTER_ALG_TCS(DisambiguationDetaDPhiIncl3)
 
@@ -140,9 +139,9 @@ TCS::DisambiguationDetaDPhiIncl3::processBitCorrect( const std::vector<TCS::TOBA
                if( parType_t(std::abs((*tob2)->eta())) < p_EtaMin2 ) continue; // Eta cut
 
                // DeltaPhi cuts
-               unsigned int deltaPhi = TSU::Kinematics::calcDeltaPhiBW( *tob1, *tob2 );
+               unsigned int deltaPhi = calcDeltaPhiBW( *tob1, *tob2 );
                // DeltaEta cuts
-               unsigned int deltaEta = TSU::Kinematics::calcDeltaEtaBW( *tob1, *tob2 );
+               unsigned int deltaEta = calcDeltaEtaBW( *tob1, *tob2 );
 
                if(deltaPhi > p_DeltaPhiMax || deltaEta > p_DeltaEtaMax) continue;
                if (deltaEta < p_DeltaEtaMin &&  deltaPhi < p_DeltaPhiMin ) continue;
@@ -153,8 +152,8 @@ TCS::DisambiguationDetaDPhiIncl3::processBitCorrect( const std::vector<TCS::TOBA
                    if( parType_t((*tob3)->Et()) <= p_MinET3) continue; // ET cut
                    if( parType_t(std::abs((*tob3)->eta())) > p_EtaMax3 ) continue; // Eta cut
                    if( parType_t(std::abs((*tob3)->eta())) < p_EtaMin3 ) continue; // Eta cut
-                   unsigned int deltaR13 = TSU::Kinematics::calcDeltaR2BW( *tob1, *tob3 );
-                   unsigned int deltaR23 = TSU::Kinematics::calcDeltaR2BW( *tob2, *tob3 );
+                   unsigned int deltaR13 = calcDeltaR2BW( *tob1, *tob3 );
+                   unsigned int deltaR23 = calcDeltaR2BW( *tob2, *tob3 );
                    for(unsigned int i=0; i<numberOutputBits(); ++i) {
                        bool accept = false;
                        accept = deltaR13 > p_DisambDR[i] && deltaR23 > p_DisambDR[i] ;
@@ -202,9 +201,9 @@ TCS::DisambiguationDetaDPhiIncl3::process( const std::vector<TCS::TOBArray const
                if( parType_t(std::abs((*tob2)->eta())) < p_EtaMin2 ) continue; // Eta cut
 
                // DeltaPhi cuts
-               unsigned int deltaPhi = TSU::Kinematics::calcDeltaPhi( *tob1, *tob2 );
+               unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
                // DeltaEta cuts
-               unsigned int deltaEta = TSU::Kinematics::calcDeltaEta( *tob1, *tob2 );
+               unsigned int deltaEta = calcDeltaEta( *tob1, *tob2 );
 
                if(deltaPhi > p_DeltaPhiMax || deltaEta > p_DeltaEtaMax) continue;
                if (deltaEta < p_DeltaEtaMin &&  deltaPhi < p_DeltaPhiMin ) continue;
@@ -215,8 +214,8 @@ TCS::DisambiguationDetaDPhiIncl3::process( const std::vector<TCS::TOBArray const
                    if( parType_t((*tob3)->Et()) <= p_MinET3) continue; // ET cut
                    if( parType_t(std::abs((*tob3)->eta())) > p_EtaMax3 ) continue; // Eta cut
                    if( parType_t(std::abs((*tob3)->eta())) < p_EtaMin3 ) continue; // Eta cut
-                   unsigned int deltaR13 = TSU::Kinematics::calcDeltaR2( *tob1, *tob3 );
-                   unsigned int deltaR23 = TSU::Kinematics::calcDeltaR2( *tob2, *tob3 );
+                   unsigned int deltaR13 = calcDeltaR2( *tob1, *tob3 );
+                   unsigned int deltaR23 = calcDeltaR2( *tob2, *tob3 );
                    for(unsigned int i=0; i<numberOutputBits(); ++i) {
                        bool accept = false;
                        accept = deltaR13 > p_DisambDR[i] && deltaR23 > p_DisambDR[i] ;
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationIncl2.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationIncl2.cxx
index 66e7e66fa8fa..a1fec9d708f8 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationIncl2.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationIncl2.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * DisambiguationIncl2.cpp
@@ -15,7 +15,6 @@
 #include "L1TopoAlgorithms/DisambiguationIncl2.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
 
 REGISTER_ALG_TCS(DisambiguationIncl2)
 
@@ -95,7 +94,7 @@ TCS::DisambiguationIncl2::processBitCorrect( const std::vector<TCS::TOBArray con
 
 
                // test DeltaR2Min, DeltaR2Max
-               unsigned int deltaR2 = TSU::Kinematics::calcDeltaR2BW( *tob1, *tob2 );
+               unsigned int deltaR2 = calcDeltaR2BW( *tob1, *tob2 );
                
                for(unsigned int i=0; i<numberOutputBits(); ++i) {
                    bool accept = false;
@@ -141,7 +140,7 @@ TCS::DisambiguationIncl2::process( const std::vector<TCS::TOBArray const *> & in
 
 
                // test DeltaR2Min, DeltaR2Max
-               unsigned int deltaR2 = TSU::Kinematics::calcDeltaR2( *tob1, *tob2 );
+               unsigned int deltaR2 = calcDeltaR2( *tob1, *tob2 );
                
                for(unsigned int i=0; i<numberOutputBits(); ++i) {
                    bool accept = false;
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationIncl3.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationIncl3.cxx
index 871f282dc911..453c91cd068f 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationIncl3.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationIncl3.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * DisambiguationIncl3.cpp
@@ -15,7 +15,6 @@
 #include "L1TopoAlgorithms/DisambiguationIncl3.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
 
 REGISTER_ALG_TCS(DisambiguationIncl3)
 
@@ -115,8 +114,8 @@ TCS::DisambiguationIncl3::processBitCorrect( const std::vector<TCS::TOBArray con
                     ++tob3) {
 
                
-                  unsigned int deltaR13 = TSU::Kinematics::calcDeltaR2BW( *tob1, *tob3 );
-                  unsigned int deltaR23 = TSU::Kinematics::calcDeltaR2BW( *tob2, *tob3 );
+                  unsigned int deltaR13 = calcDeltaR2BW( *tob1, *tob3 );
+                  unsigned int deltaR23 = calcDeltaR2BW( *tob2, *tob3 );
 
                   for(unsigned int i=0; i<numberOutputBits(); ++i) {
                       bool accept = false;
@@ -180,8 +179,8 @@ TCS::DisambiguationIncl3::process( const std::vector<TCS::TOBArray const *> & in
                     ++tob3) {
 
                
-                  unsigned int deltaR13 = TSU::Kinematics::calcDeltaR2( *tob1, *tob3 );
-                  unsigned int deltaR23 = TSU::Kinematics::calcDeltaR2( *tob2, *tob3 );
+                  unsigned int deltaR13 = calcDeltaR2( *tob1, *tob3 );
+                  unsigned int deltaR23 = calcDeltaR2( *tob2, *tob3 );
 
                   for(unsigned int i=0; i<numberOutputBits(); ++i) {
                       bool accept = false;
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationInvmIncl2.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationInvmIncl2.cxx
index 12fcaf940b19..519a52a086c7 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationInvmIncl2.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/DisambiguationInvmIncl2.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * DisambiguationInvmIncl2.cpp
@@ -17,10 +17,6 @@
 #include "L1TopoAlgorithms/DisambiguationInvmIncl2.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-// Bitwise implementation utils
-#include "L1TopoSimulationUtils/L1TopoDataTypes.h"
-#include "L1TopoSimulationUtils/Trigo.h"
-#include "L1TopoSimulationUtils/Hyperbolic.h"
 
 REGISTER_ALG_TCS(DisambiguationInvmIncl2)
 
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/EMMultiplicity.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/EMMultiplicity.cxx
index 46c70b582947..2f979b784223 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/EMMultiplicity.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/EMMultiplicity.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * EMMultiplicity.cpp
@@ -22,9 +22,6 @@
 #include "L1TopoEvent/ClusterTOBArray.h"
 #include "L1TopoEvent/GenericTOB.h"
 
-#include "TH1F.h"
-#include "TH2F.h"
-
 REGISTER_ALG_TCS(EMMultiplicity)
 
 using namespace std;
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/EtCut.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/EtCut.cxx
index 58bdcd3528db..5726ac50b599 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/EtCut.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/EtCut.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * LAr.cpp
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/EtaPhiWindow.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/EtaPhiWindow.cxx
index 16653c8f83ef..b92fdafab415 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/EtaPhiWindow.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/EtaPhiWindow.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 
 
@@ -11,9 +11,7 @@
 
 #include <cmath>
 #include <iterator>
-//
-#include "TH1F.h"
-#include "TH2F.h"
+
 
 REGISTER_ALG_TCS(EtaPhiWindow)
 
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ExclusiveJets.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ExclusiveJets.cxx
index 7d55c20175d6..f58d5d7486e5 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ExclusiveJets.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/ExclusiveJets.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * ExclusiveJets.cxx
@@ -16,17 +16,11 @@
 #include <iostream>
 #include <sstream>
 #include <vector>
-#include "TH1F.h"
-#include "TH2F.h"
+
 #include "L1TopoAlgorithms/ExclusiveJets.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-// Bitwise implementation utils
-#include "L1TopoSimulationUtils/L1TopoDataTypes.h"
-#include "L1TopoSimulationUtils/Trigo.h"
-#include "L1TopoSimulationUtils/Hyperbolic.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
-//
+
 REGISTER_ALG_TCS(ExclusiveJets)
 
 TCS::ExclusiveJets::ExclusiveJets(const std::string & name) : DecisionAlg(name)
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/GenericArrayCreator.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/GenericArrayCreator.cxx
index e85d9285970e..b30e53e7be9a 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/GenericArrayCreator.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/GenericArrayCreator.cxx
@@ -1,4 +1,4 @@
-// Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+// Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 
 #include "L1TopoAlgorithms/GenericArrayCreator.h"
 #include "L1TopoEvent/ClusterTOBArray.h"
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/GenericListGenerator.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/GenericListGenerator.cxx
index ee4a9466b7d3..97f5929798c9 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/GenericListGenerator.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/GenericListGenerator.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  GenericListGenerator.cxx
 //  TopoCore
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassDeltaPhiInclusive2.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassDeltaPhiInclusive2.cxx
index 6487c6e33210..eac8d99e9f5f 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassDeltaPhiInclusive2.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassDeltaPhiInclusive2.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * InvariantMassDeltaPhiInclusive2.cxx
@@ -14,14 +14,6 @@
 #include "L1TopoAlgorithms/InvariantMassDeltaPhiInclusive2.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-// Bitwise implementation utils
-#include "L1TopoSimulationUtils/L1TopoDataTypes.h"
-#include "L1TopoSimulationUtils/Trigo.h"
-#include "L1TopoSimulationUtils/Hyperbolic.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
-//
-#include "TH1F.h"
-#include "TH2F.h"
 
 #include <cmath>
 
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassDeltaPhiInclusive2Charge.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassDeltaPhiInclusive2Charge.cxx
index b8ad6e87a01e..35b77e2ac321 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassDeltaPhiInclusive2Charge.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassDeltaPhiInclusive2Charge.cxx
@@ -14,14 +14,6 @@
 #include "L1TopoAlgorithms/InvariantMassDeltaPhiInclusive2Charge.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-// Bitwise implementation utils
-#include "L1TopoSimulationUtils/L1TopoDataTypes.h"
-#include "L1TopoSimulationUtils/Trigo.h"
-#include "L1TopoSimulationUtils/Hyperbolic.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
-//
-#include "TH1F.h"
-#include "TH2F.h"
 
 #include <cmath>
 
@@ -164,9 +156,9 @@ TCS::InvariantMassDeltaPhiInclusive2Charge::processBitCorrect( const std::vector
                  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
                  ++tob2) {
                 // Inv Mass calculation
-                unsigned int invmass2 = TSU::Kinematics::calcInvMassBW( *tob1, *tob2 );
+                unsigned int invmass2 = calcInvMassBW( *tob1, *tob2 );
 		// test DeltaPhiMin, DeltaPhiMax                                       
-		unsigned int deltaPhi = TSU::Kinematics::calcDeltaPhiBW( *tob1, *tob2 );
+		unsigned int deltaPhi = calcDeltaPhiBW( *tob1, *tob2 );
                 const int eta1 = (*tob1)->eta();
                 const int eta2 = (*tob2)->eta();
                 const unsigned int aeta1 = std::abs(eta1);
@@ -239,9 +231,9 @@ TCS::InvariantMassDeltaPhiInclusive2Charge::process( const std::vector<TCS::TOBA
                  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
                  ++tob2) {
                 // Inv Mass calculation
-                unsigned int invmass2 = TSU::Kinematics::calcInvMass( *tob1, *tob2 );
+                unsigned int invmass2 = calcInvMass( *tob1, *tob2 );
 		// test DeltaPhiMin, DeltaPhiMax                                     
-		unsigned int deltaPhi = TSU::Kinematics::calcDeltaPhi( *tob1, *tob2 );
+		unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
                 const int eta1 = (*tob1)->eta();
                 const int eta2 = (*tob2)->eta();
                 const unsigned int aeta1 = std::abs(eta1);
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassInclusive1.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassInclusive1.cxx
index 1ebdf15ae715..9c8389f2d947 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassInclusive1.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassInclusive1.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * InvariantMassInclusive1.cpp
@@ -15,18 +15,11 @@
 #include <iostream>
 #include <sstream>
 #include <vector>
-#include "TH1F.h"
 
 #include "L1TopoAlgorithms/InvariantMassInclusive1.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-// Bitwise implementation utils
-#include "L1TopoSimulationUtils/L1TopoDataTypes.h"
-#include "L1TopoSimulationUtils/Trigo.h"
-#include "L1TopoSimulationUtils/Hyperbolic.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
 
-//
 
 REGISTER_ALG_TCS(InvariantMassInclusive1)
 
@@ -142,7 +135,7 @@ TCS::InvariantMassInclusive1::processBitCorrect( const std::vector<TCS::TOBArray
                if (p_OneBarrel && parType_t(abs((*tob1)->eta())) > 10 && parType_t(abs((*tob2)->eta())) > 10 ) continue;
                
                // Inv Mass calculation
-               unsigned int invmass2 = TSU::Kinematics::calcInvMassBW( *tob1, *tob2 );
+               unsigned int invmass2 = calcInvMassBW( *tob1, *tob2 );
                for(unsigned int i=0; i<numberOutputBits(); ++i) {
                    bool accept = false;
                    if( parType_t((*tob1)->Et()) <= std::min(p_MinET1[i],p_MinET2[i])) continue; // ET cut
@@ -199,7 +192,7 @@ TCS::InvariantMassInclusive1::process( const std::vector<TCS::TOBArray const *>
                
                // Inv Mass calculation
              
-	       unsigned int invmass2 = TSU::Kinematics::calcInvMass( *tob1, *tob2 );
+	       unsigned int invmass2 = calcInvMass( *tob1, *tob2 );
 
 
                for(unsigned int i=0; i<numberOutputBits(); ++i) {
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassInclusive2.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassInclusive2.cxx
index 9291d1cb3a3b..142fb8381b9d 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassInclusive2.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassInclusive2.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * InvariantMassInclusive2.cpp
@@ -14,14 +14,6 @@
 #include "L1TopoAlgorithms/InvariantMassInclusive2.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-// Bitwise implementation utils
-#include "L1TopoSimulationUtils/L1TopoDataTypes.h"
-#include "L1TopoSimulationUtils/Trigo.h"
-#include "L1TopoSimulationUtils/Hyperbolic.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
-//
-#include "TH1F.h"
-#include "TH2F.h"
 
 #include <cmath>
 #include <iostream>
@@ -146,7 +138,7 @@ TCS::InvariantMassInclusive2::processBitCorrect( const std::vector<TCS::TOBArray
                  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
                  ++tob2) {
                 // Inv Mass calculation
-                unsigned int invmass2 = TSU::Kinematics::calcInvMassBW( *tob1, *tob2 );
+                unsigned int invmass2 = calcInvMassBW( *tob1, *tob2 );
                 const int eta1 = (*tob1)->eta();
                 const int eta2 = (*tob2)->eta();
                 const unsigned int aeta1 = std::abs(eta1);
@@ -202,7 +194,7 @@ TCS::InvariantMassInclusive2::process( const std::vector<TCS::TOBArray const *>
                  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
                  ++tob2) {
                 // Inv Mass calculation
-                unsigned int invmass2 = TSU::Kinematics::calcInvMass( *tob1, *tob2 );
+                unsigned int invmass2 = calcInvMass( *tob1, *tob2 );
                 const int eta1 = (*tob1)->eta();
                 const int eta2 = (*tob2)->eta();
                 const unsigned int aeta1 = std::abs(eta1);
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassInclusiveDeltaRSqrIncl1.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassInclusiveDeltaRSqrIncl1.cxx
index df634f59ae70..c35649c0e548 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassInclusiveDeltaRSqrIncl1.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassInclusiveDeltaRSqrIncl1.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * Based on InvariantMassInclusive1 and DeltaRSqrIncl1. 01/03/2019.
@@ -16,19 +16,11 @@
 #include <string>
 #include <sstream>
 #include <vector>
-#include "TH1F.h"
-#include "TH2F.h"
 
 #include "L1TopoAlgorithms/InvariantMassInclusiveDeltaRSqrIncl1.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-// Bitwise implementation utils
-#include "L1TopoSimulationUtils/L1TopoDataTypes.h"
-#include "L1TopoSimulationUtils/Trigo.h"
-#include "L1TopoSimulationUtils/Hyperbolic.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
 
-//
 
 REGISTER_ALG_TCS(InvariantMassInclusiveDeltaRSqrIncl1)
 
@@ -156,9 +148,9 @@ TCS::InvariantMassInclusiveDeltaRSqrIncl1::processBitCorrect( const std::vector<
                if (p_OneBarrel && parType_t(abs((*tob1)->eta())) > 10 && parType_t(abs((*tob2)->eta())) > 10 ) continue;
                
                // Inv Mass calculation
-               unsigned int invmass2 = TSU::Kinematics::calcInvMassBW( *tob1, *tob2 );
+               unsigned int invmass2 = calcInvMassBW( *tob1, *tob2 );
 	       // test DeltaR2Min, DeltaR2Max                                                                                                
-	       unsigned int deltaR2 = TSU::Kinematics::calcDeltaR2BW( *tob1, *tob2 );
+	       unsigned int deltaR2 = calcDeltaR2BW( *tob1, *tob2 );
 	       TRG_MSG_DEBUG("Jet1 = " << **tob1 << ", Jet2 = " << **tob2 << ", invmass2 = " << invmass2 << ", deltaR2 = " << deltaR2);
                for(unsigned int i=0; i<numberOutputBits(); ++i) {
                    bool accept = false;
@@ -215,9 +207,9 @@ TCS::InvariantMassInclusiveDeltaRSqrIncl1::process( const std::vector<TCS::TOBAr
                if (p_OneBarrel && parType_t(abs((*tob1)->eta())) > 10 && parType_t(abs((*tob2)->eta())) > 10 ) continue;
                
                // Inv Mass calculation
-	       unsigned int invmass2 = TSU::Kinematics::calcInvMass( *tob1, *tob2 );
+	       unsigned int invmass2 = calcInvMass( *tob1, *tob2 );
 	       // test DeltaR2Min, DeltaR2Max                                                                                                  
-	       unsigned int deltaR2 = TSU::Kinematics::calcDeltaR2( *tob1, *tob2 );
+	       unsigned int deltaR2 = calcDeltaR2( *tob1, *tob2 );
 	       TRG_MSG_DEBUG("Jet1 = " << **tob1 << ", Jet2 = " << **tob2 << ", invmass2 = " << invmass2 << ", deltaR2 = " << deltaR2);
 	       
                for(unsigned int i=0; i<numberOutputBits(); ++i) {
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassInclusiveDeltaRSqrIncl2.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassInclusiveDeltaRSqrIncl2.cxx
index f7cf29606e55..90e684481541 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassInclusiveDeltaRSqrIncl2.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassInclusiveDeltaRSqrIncl2.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * Based on InvariantMassInclusive2 and DeltaRSqrIncl2. 01/03/2019.
@@ -16,14 +16,6 @@
 #include "L1TopoAlgorithms/InvariantMassInclusiveDeltaRSqrIncl2.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-// Bitwise implementation utils
-#include "L1TopoSimulationUtils/L1TopoDataTypes.h"
-#include "L1TopoSimulationUtils/Trigo.h"
-#include "L1TopoSimulationUtils/Hyperbolic.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
-//
-#include "TH1F.h"
-#include "TH2F.h"
 
 #include <cmath>
 
@@ -159,9 +151,9 @@ TCS::InvariantMassInclusiveDeltaRSqrIncl2::processBitCorrect( const std::vector<
                  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
                  ++tob2) {
                 // Inv Mass calculation
-                unsigned int invmass2 = TSU::Kinematics::calcInvMassBW( *tob1, *tob2 );
+                unsigned int invmass2 = calcInvMassBW( *tob1, *tob2 );
 		// test DeltaR2Min, DeltaR2Max                                                                                                
-		unsigned int deltaR2 = TSU::Kinematics::calcDeltaR2BW( *tob1, *tob2 );
+		unsigned int deltaR2 = calcDeltaR2BW( *tob1, *tob2 );
 		TRG_MSG_DEBUG("Jet1 = " << **tob1 << ", Jet2 = " << **tob2 << ", invmass2 = " << invmass2 << ", deltaR2 = " << deltaR2);
                 const int eta1 = (*tob1)->eta();
                 const int eta2 = (*tob2)->eta();
@@ -216,9 +208,9 @@ TCS::InvariantMassInclusiveDeltaRSqrIncl2::process( const std::vector<TCS::TOBAr
                  tob2 != input[1]->end() && distance(input[1]->begin(), tob2) < p_NumberLeading2;
                  ++tob2) {
 	      // Inv Mass calculation
-	      unsigned int invmass2 = TSU::Kinematics::calcInvMass( *tob1, *tob2 );
+	      unsigned int invmass2 = calcInvMass( *tob1, *tob2 );
 	      // test DeltaR2Min, DeltaR2Max                                                                                                  
-	      unsigned int deltaR2 = TSU::Kinematics::calcDeltaR2( *tob1, *tob2 );
+	      unsigned int deltaR2 = calcDeltaR2( *tob1, *tob2 );
 	      TRG_MSG_DEBUG("Jet1 = " << **tob1 << ", Jet2 = " << **tob2 << ", invmass2 = " << invmass2 << ", deltaR2 = " << deltaR2);
 	      const int eta1 = (*tob1)->eta();
 	      const int eta2 = (*tob2)->eta();
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassThreeTOBsIncl.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassThreeTOBsIncl.cxx
index 2803a8db97cc..5c748f18000d 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassThreeTOBsIncl.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassThreeTOBsIncl.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * InvariantMassThreeTOBsIncl.cxx
@@ -23,19 +23,10 @@
 #include <iostream>
 #include <sstream>
 #include <vector>
-#include "TH1F.h"
-#include "TH2F.h"
 
 #include "L1TopoAlgorithms/InvariantMassThreeTOBsIncl.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-// Bitwise implementation utils
-#include "L1TopoSimulationUtils/L1TopoDataTypes.h"
-#include "L1TopoSimulationUtils/Trigo.h"
-#include "L1TopoSimulationUtils/Hyperbolic.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
-
-//
 
 REGISTER_ALG_TCS(InvariantMassThreeTOBsIncl)
 
@@ -140,9 +131,9 @@ TCS::InvariantMassThreeTOBsIncl::processBitCorrect( const std::vector<TCS::TOBAr
 		if (p_OneBarrel && parType_t(abs((*tob1)->eta())) > 10 && parType_t(abs((*tob2)->eta())) > 10 && parType_t(abs((*tob3)->eta())) > 10 ) continue;
                
 		// Inv Mass calculation
-		unsigned int invmass2_12 = TSU::Kinematics::calcInvMassBW( *tob1, *tob2 );
-		unsigned int invmass2_13 = TSU::Kinematics::calcInvMassBW( *tob1, *tob3 );
-		unsigned int invmass2_23 = TSU::Kinematics::calcInvMassBW( *tob2, *tob3 );
+		unsigned int invmass2_12 = calcInvMassBW( *tob1, *tob2 );
+		unsigned int invmass2_13 = calcInvMassBW( *tob1, *tob3 );
+		unsigned int invmass2_23 = calcInvMassBW( *tob2, *tob3 );
 		unsigned int invmass2 = invmass2_12 + invmass2_13 + invmass2_23;
 		for(unsigned int i=0; i<numberOutputBits(); ++i) {
 		  bool accept = false;
@@ -212,9 +203,9 @@ TCS::InvariantMassThreeTOBsIncl::process( const std::vector<TCS::TOBArray const
 		
 		// Inv Mass calculation
              
-		unsigned int invmass2_12 = TSU::Kinematics::calcInvMass( *tob1, *tob2 );
-		unsigned int invmass2_13 = TSU::Kinematics::calcInvMass( *tob1, *tob3 );
-		unsigned int invmass2_23 = TSU::Kinematics::calcInvMass( *tob2, *tob3 );
+		unsigned int invmass2_12 = calcInvMass( *tob1, *tob2 );
+		unsigned int invmass2_13 = calcInvMass( *tob1, *tob3 );
+		unsigned int invmass2_23 = calcInvMass( *tob2, *tob3 );
 		unsigned int invmass2 = invmass2_12 + invmass2_13 + invmass2_23;
 		for(unsigned int i=0; i<numberOutputBits(); ++i) {
 		  bool accept = false;
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassThreeTOBsInclCharge.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassThreeTOBsInclCharge.cxx
index 9b122c72a917..b624925f6f08 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassThreeTOBsInclCharge.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/InvariantMassThreeTOBsInclCharge.cxx
@@ -21,19 +21,11 @@
 #include <iostream>
 #include <sstream>
 #include <vector>
-#include "TH1F.h"
-#include "TH2F.h"
 
 #include "L1TopoAlgorithms/InvariantMassThreeTOBsInclCharge.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-// Bitwise implementation utils
-#include "L1TopoSimulationUtils/L1TopoDataTypes.h"
-#include "L1TopoSimulationUtils/Trigo.h"
-#include "L1TopoSimulationUtils/Hyperbolic.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
 
-//
 
 REGISTER_ALG_TCS(InvariantMassThreeTOBsInclCharge)
 
@@ -150,9 +142,9 @@ TCS::InvariantMassThreeTOBsInclCharge::processBitCorrect( const std::vector<TCS:
 		if (p_OneBarrel && static_cast<parType_t>(std::abs((*tob1)->eta())) > 10 && static_cast<parType_t>(std::abs((*tob2)->eta())) > 10 && static_cast<parType_t>(std::abs((*tob3)->eta())) > 10 ) continue;
                
 		// Inv Mass calculation
-		unsigned int invmass2_12 = TSU::Kinematics::calcInvMassBW( *tob1, *tob2 );
-		unsigned int invmass2_13 = TSU::Kinematics::calcInvMassBW( *tob1, *tob3 );
-		unsigned int invmass2_23 = TSU::Kinematics::calcInvMassBW( *tob2, *tob3 );
+		unsigned int invmass2_12 = calcInvMassBW( *tob1, *tob2 );
+		unsigned int invmass2_13 = calcInvMassBW( *tob1, *tob3 );
+		unsigned int invmass2_23 = calcInvMassBW( *tob2, *tob3 );
 		unsigned int invmass2 = invmass2_12 + invmass2_13 + invmass2_23;
                 // Muon sector and charge
                 std::string sector1 = (*tob1)->sectorName();
@@ -240,9 +232,9 @@ TCS::InvariantMassThreeTOBsInclCharge::process( const std::vector<TCS::TOBArray
 		if (p_OneBarrel && static_cast<parType_t>(std::abs((*tob1)->eta())) > 10 && static_cast<parType_t>(std::abs((*tob2)->eta())) > 10 && static_cast<parType_t>(std::abs((*tob3)->eta())) > 10 ) continue;
 		
 		// Inv Mass calculation            
-		unsigned int invmass2_12 = TSU::Kinematics::calcInvMass( *tob1, *tob2 );
-		unsigned int invmass2_13 = TSU::Kinematics::calcInvMass( *tob1, *tob3 );
-		unsigned int invmass2_23 = TSU::Kinematics::calcInvMass( *tob2, *tob3 );
+		unsigned int invmass2_12 = calcInvMass( *tob1, *tob2 );
+		unsigned int invmass2_13 = calcInvMass( *tob1, *tob3 );
+		unsigned int invmass2_23 = calcInvMass( *tob2, *tob3 );
 		unsigned int invmass2 = invmass2_12 + invmass2_13 + invmass2_23;
                 // Muon sector and charge
                 std::string sector1 = (*tob1)->sectorName();
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetAbbreviated.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetAbbreviated.cxx
index 487ce46ed3fd..3aaf48cd0508 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetAbbreviated.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetAbbreviated.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  JetAbbreviated.cxx
 //  TopoCore
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetHT.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetHT.cxx
index 9f75ca7a417f..c3bf92a968a5 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetHT.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetHT.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * JetHT.cpp
@@ -15,7 +15,6 @@
 #include <iostream>
 #include <sstream>
 #include <vector>
-#include "TH1F.h"
 
 #include "L1TopoAlgorithms/JetHT.h"
 #include "L1TopoCommon/Exception.h"
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetMatch.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetMatch.cxx
index 6cf7999707f8..01f73aa920f7 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetMatch.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetMatch.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * JetMatch.cpp
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetNoSort.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetNoSort.cxx
index 0477925c8d4f..8b33f252afa5 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetNoSort.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetNoSort.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  JetNoSort.cxx
 //  TopoCore
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetNoSortMatch.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetNoSortMatch.cxx
index 36e58e05ab68..bd180c2fcb07 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetNoSortMatch.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetNoSortMatch.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  JetNoSortMatch.cxx
 //  TopoCore
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSelect.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSelect.cxx
index af05f78acc3d..2a5d85835996 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSelect.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSelect.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  JetSelect.cxx
 //  TopoCore
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSort.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSort.cxx
index d942e91e25fc..0c521f188f3b 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSort.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSort.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  JetSort.cxx
 //  TopoCore
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSortingAlg.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSortingAlg.cxx
index 030df94201e9..5559ffd3d4bc 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSortingAlg.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSortingAlg.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  JetSortingAlg.cxx
 //  TopoCore
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSortingAlgSize1.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSortingAlgSize1.cxx
index 1f4208df7ee5..6c05dc9c1c86 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSortingAlgSize1.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSortingAlgSize1.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  JetSortingAlgSize1.cxx
 //  TopoCore
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSortingAlgSize2.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSortingAlgSize2.cxx
index c3d39e19ea89..d471599a8dbe 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSortingAlgSize2.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/JetSortingAlgSize2.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  JetSortingAlgSize1.cxx
 //  TopoCore
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/KalmanMETCorrection.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/KalmanMETCorrection.cxx
index ec70506c4d63..8e45d09f06f0 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/KalmanMETCorrection.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/KalmanMETCorrection.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * KalmanMETCorrection.cpp
@@ -106,6 +106,7 @@ TCS::KalmanMETCorrection::processBitCorrect( const std::vector<TCS::TOBArray con
 
        corrfactor = LUTobj.getcorrKF(ipt,jeta);   
 
+       // This part of the code has to be reviewed again for phase1 BW simulation
        auto cosphi = TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Cos.at(/*abs*/(parType_t((*tob)->phi()))));
        auto sinphi = TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Sin.at(/*abs*/(parType_t((*tob)->phi()))));
 
@@ -114,7 +115,7 @@ TCS::KalmanMETCorrection::processBitCorrect( const std::vector<TCS::TOBArray con
             
 
         TRG_MSG_DEBUG("corr  " << corrfactor);
-         TRG_MSG_DEBUG("metsumx " << summetx << "metsumy " << summety );
+	TRG_MSG_DEBUG("metsumx " << summetx << "metsumy " << summety );
 
        corrfactor = 0;
   }
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/LAr.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/LAr.cxx
index 2b9908f1355c..05576c3109f8 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/LAr.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/LAr.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * LAr.cpp
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/METCut.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/METCut.cxx
index e9638d1eafa6..7f02ed10c512 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/METCut.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/METCut.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * METCut.cpp
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/METNoSort.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/METNoSort.cxx
index a48f1a22a3c5..0b61035cbd69 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/METNoSort.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/METNoSort.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  METNoSort.cxx
 //  author: Joerg Stelzer
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/METSortingAlg.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/METSortingAlg.cxx
index 4ef04d26f405..03d5d3a4e26a 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/METSortingAlg.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/METSortingAlg.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  file: METSortingAlg.cxx
 //  author: Joerg Stelzer
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MetSort.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MetSort.cxx
index 7edecf894d73..b1cf1c6774ee 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MetSort.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MetSort.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  MetSort.cxx
 //  author: Joerg Stelzer
@@ -14,10 +14,7 @@
 #include <cmath>
 
 // Bitwise implementation utils
-#include "L1TopoSimulationUtils/L1TopoDataTypes.h"
 #include "L1TopoSimulationUtils/Trigo.h"
-#include "L1TopoSimulationUtils/Hyperbolic.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
 
 using std::sqrt;
 using std::round;
@@ -51,7 +48,7 @@ TCS::MetSort::sortBitCorrect(const InputTOBArray & input, TOBArray & output) {
    }
 
    const MetTOBArray & mets = dynamic_cast<const MetTOBArray&>(input);
-   int missingET = TSU::Kinematics::quadraticSumBW(mets[0].Ex(), mets[0].Ey());
+   int missingET = quadraticSumBW(mets[0].Ex(), mets[0].Ey());
    int metphi = TSU::Trigo::atan2(mets[0].Ex(),mets[0].Ey());
 
    TRG_MSG_DEBUG("MET phi values " << metphi << " " );
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MinDeltaPhiIncl2.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MinDeltaPhiIncl2.cxx
index 9844bfbf9d41..ff0c0d5ffd51 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MinDeltaPhiIncl2.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MinDeltaPhiIncl2.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * MinDeltaPhiIncl2.cpp
@@ -16,13 +16,10 @@
 #include <sstream>
 #include <vector>
 #include <algorithm>
-#include "TH1F.h"
-
 
 #include "L1TopoAlgorithms/MinDeltaPhiIncl2.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
 
 REGISTER_ALG_TCS(MinDeltaPhiIncl2)
 
@@ -111,7 +108,7 @@ TCS::MinDeltaPhiIncl2::processBitCorrect( const std::vector<TCS::TOBArray const
                if( parType_t((*tob2)->Et()) <= p_MinET2) continue; // ET cut
 
                // test DeltaPhiMin, DeltaPhiMax
-               unsigned int deltaPhi = TSU::Kinematics::calcDeltaPhiBW( *tob1, *tob2 );
+               unsigned int deltaPhi = calcDeltaPhiBW( *tob1, *tob2 );
 
                if (firstphi) {
                   mindphi = deltaPhi;
@@ -183,7 +180,7 @@ TCS::MinDeltaPhiIncl2::process( const std::vector<TCS::TOBArray const *> & input
                if( parType_t((*tob2)->Et()) <= p_MinET2) continue; // ET cut
 
                // test DeltaPhiMin, DeltaPhiMax
-               unsigned int deltaPhi = TSU::Kinematics::calcDeltaPhi( *tob1, *tob2 );
+               unsigned int deltaPhi = calcDeltaPhi( *tob1, *tob2 );
 
                if (firstphi) {
                   mindphi = deltaPhi;
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/Multiplicity.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/Multiplicity.cxx
index 56f0d5e9ffd2..2f358f415f34 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/Multiplicity.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/Multiplicity.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * Multiplicity.cpp
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MultiplicityCustom.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MultiplicityCustom.cxx
index 93f57b9b3ead..d3d33591977a 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MultiplicityCustom.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MultiplicityCustom.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * MultiplicityCustom.cpp
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonAbbreviated.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonAbbreviated.cxx
index 3cf02404ff69..23798948e361 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonAbbreviated.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonAbbreviated.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  MuonAbbreviated.cxx
 //  TopoCore
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonNoSort.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonNoSort.cxx
index db978d54abc9..2eb9a33e18b6 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonNoSort.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonNoSort.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  MuonNoSort.cxx
 //  TopoCore
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonSelect.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonSelect.cxx
index d12949bed15b..e024086e5493 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonSelect.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonSelect.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  MuonSelect.cxx
 //  TopoCore
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonSort.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonSort.cxx
index 010ae7a04984..1e7d589676d4 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonSort.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonSort.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  MuonSort.cxx
 //  TopoCore
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonSort_1BC.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonSort_1BC.cxx
index a1f6321b4dce..95da70716ce2 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonSort_1BC.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/MuonSort_1BC.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 //  MuonSort_1BC.cxx
 //  TopoCore
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/NotMatch.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/NotMatch.cxx
index 4ed8c2fc6b2f..a73b9688dc32 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/NotMatch.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/NotMatch.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * NotMatch.cpp
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/Ratio.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/Ratio.cxx
index 5a9dfcad8ebf..f2ed99d93b83 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/Ratio.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/Ratio.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * Ratio.cpp
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/Ratio2.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/Ratio2.cxx
index 200156b1e2a6..3248c9cdf818 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/Ratio2.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/Ratio2.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * Ratio2.cpp
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/RatioMatch.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/RatioMatch.cxx
index 90e8ae3ed8e4..dc1b44e8a527 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/RatioMatch.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/RatioMatch.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * RatioMatch.cpp
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/RatioSum.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/RatioSum.cxx
index 0900ad4a3a77..e9dd27e552bb 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/RatioSum.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/RatioSum.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * RatioSum.cpp
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/SimpleCone.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/SimpleCone.cxx
index 2be36ed6ca8a..c88f85a4233a 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/SimpleCone.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/SimpleCone.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * SimpleCone.cpp
@@ -15,7 +15,6 @@
 #include <sstream>
 #include <vector>
 #include <algorithm>
-#include "TH1F.h"
 
 #include "L1TopoAlgorithms/SimpleCone.h"
 #include "L1TopoCommon/Exception.h"
diff --git a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/TransverseMassInclusive1.cxx b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/TransverseMassInclusive1.cxx
index 13194780a8ab..8141c4af192d 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/TransverseMassInclusive1.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoAlgorithms/Root/TransverseMassInclusive1.cxx
@@ -1,5 +1,5 @@
 /*
-  Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
+  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
 */
 /*********************************
  * TransverseMassInclusive1.cpp
@@ -14,16 +14,10 @@
 #include <string>
 #include <sstream>
 #include <vector>
-#include "TH1F.h"
 
 #include "L1TopoAlgorithms/TransverseMassInclusive1.h"
 #include "L1TopoCommon/Exception.h"
 #include "L1TopoInterfaces/Decision.h"
-// Bitwise implementation utils
-#include "L1TopoSimulationUtils/L1TopoDataTypes.h"
-#include "L1TopoSimulationUtils/Trigo.h"
-#include "L1TopoSimulationUtils/Hyperbolic.h"
-#include "L1TopoSimulationUtils/Kinematics.h"
 
 //
 REGISTER_ALG_TCS(TransverseMassInclusive1)
@@ -32,34 +26,6 @@ REGISTER_ALG_TCS(TransverseMassInclusive1)
 #define LOG std::cout << "TCS::TransverseMassInclusive1:     "
 
 
-
-
-namespace {
-   unsigned int
-   calcTMass(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
-      if(dphi>M_PI)
-         dphi = 2*M_PI - dphi;
-      
-      double cosphi = cos ( dphi);
-      double tmass2 = 2*tob1->Et()*tob2->Et()*(1 - cosphi);
-      return round( tmass2 );
-   }
-
-   unsigned int
-   calcTMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      auto bit_cosphi = TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Cos.at(abs(tob1->phi() - tob2->phi())));
-      TSU::L1TopoDataTypes<11,0> bit_Et1(tob1->Et());
-      TSU::L1TopoDataTypes<11,0> bit_Et2(tob2->Et());
-      TSU::L1TopoDataTypes<22,0> bit_tmass2 = 2*bit_Et1*bit_Et2*(1.  - bit_cosphi);
-      return int(bit_tmass2) ;
-     // end bitwise implementation
-   }
-                                                                        
-      
-}
-
-
 TCS::TransverseMassInclusive1::TransverseMassInclusive1(const std::string & name) : DecisionAlg(name)
 {
    defineParameter("InputWidth", 3);
diff --git a/Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/ConfigurableAlg.h b/Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/ConfigurableAlg.h
index 507a7fa36e5e..b75511a152c5 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/ConfigurableAlg.h
+++ b/Trigger/TrigT1/L1Topo/L1TopoInterfaces/L1TopoInterfaces/ConfigurableAlg.h
@@ -68,11 +68,13 @@ namespace TCS {
       unsigned int calcDeltaPhiBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
       unsigned int calcDeltaEtaBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
       unsigned int calcInvMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+      unsigned int calcTMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
       unsigned int calcDeltaR2BW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
       unsigned long quadraticSumBW(int i1, int i2);
       unsigned int calcDeltaPhi(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
       unsigned int calcDeltaEta(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
       unsigned int calcInvMass(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+      unsigned int calcTMass(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
       unsigned int calcDeltaR2(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
 
 
diff --git a/Trigger/TrigT1/L1Topo/L1TopoInterfaces/Root/ConfigurableAlg.cxx b/Trigger/TrigT1/L1Topo/L1TopoInterfaces/Root/ConfigurableAlg.cxx
index ad30126644b7..cec3de09caeb 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoInterfaces/Root/ConfigurableAlg.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoInterfaces/Root/ConfigurableAlg.cxx
@@ -140,6 +140,14 @@ ConfigurableAlg::calcInvMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTO
     {return TSU::Kinematics::calcInvMassBW(tob1,tob2);}
 }
 
+unsigned int
+ConfigurableAlg::calcTMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+  if (m_isLegacyTopo)
+    {return TSU::Kinematics::calcTMassBWLegacy(tob1,tob2);}
+  else
+    {return TSU::Kinematics::calcTMassBW(tob1,tob2);}
+}
+
 unsigned int
 ConfigurableAlg::calcDeltaR2BW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
   if (m_isLegacyTopo)
@@ -168,6 +176,11 @@ ConfigurableAlg::calcInvMass(const TCS::GenericTOB* tob1, const TCS::GenericTOB*
   return TSU::Kinematics::calcInvMass(tob1,tob2);
 }
 
+unsigned int
+ConfigurableAlg::calcTMass(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+  return TSU::Kinematics::calcTMass(tob1,tob2);
+}
+
 unsigned int
 ConfigurableAlg::calcDeltaR2(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
   return TSU::Kinematics::calcDeltaR2(tob1,tob2);
diff --git a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/Kinematics.h b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/Kinematics.h
index 7032ff425502..39d99a165fc7 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/Kinematics.h
+++ b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/L1TopoSimulationUtils/Kinematics.h
@@ -20,11 +20,13 @@ namespace TSU {
 	static unsigned int calcDeltaEtaBWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
 
 	static unsigned int calcInvMassBWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+	static unsigned int calcTMassBWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
 	static unsigned int calcDeltaR2BWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
 	static unsigned int calcDeltaPhiBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);		
 	static unsigned int calcDeltaEtaBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
 
 	static unsigned int calcInvMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+	static unsigned int calcTMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
 	static unsigned int calcDeltaR2BW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
      /**
         @brief compute the sum in quadrature of two ints
@@ -43,6 +45,7 @@ namespace TSU {
 	static unsigned int calcDeltaPhi(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
 	static unsigned int calcDeltaEta(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
 	static unsigned int calcInvMass(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
+	static unsigned int calcTMass(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
 	static unsigned int calcDeltaR2(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2);
    };
 
diff --git a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Kinematics.cxx b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Kinematics.cxx
index 044494f998e8..791f197f9ae0 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Kinematics.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Kinematics.cxx
@@ -19,18 +19,18 @@
 using namespace std; 
 
 unsigned int TSU::Kinematics::calcDeltaPhiBWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2){
-      int dphiB = abs( tob1->phi() - tob2->phi() );
-      if(dphiB>64)
-         dphiB = dphiB - 64;
-      if(dphiB>32)
-         dphiB = 64 - dphiB;
+  int dphiB = abs( tob1->phi() - tob2->phi() );
+  if(dphiB>64)
+    dphiB = dphiB - 64;
+  if(dphiB>32)
+    dphiB = 64 - dphiB;
 
-      return dphiB ;
+  return dphiB ;
 }
 
 unsigned int TSU::Kinematics::calcDeltaEtaBWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      double deta = abs( tob1->eta() - tob2->eta() );
-	return deta;
+  double deta = abs( tob1->eta() - tob2->eta() );
+  return deta;
 }
 
 unsigned int TSU::Kinematics::calcInvMassBWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2){
@@ -52,31 +52,40 @@ unsigned int TSU::Kinematics::calcInvMassBWLegacy(const TCS::GenericTOB* tob1, c
   return int(bit_invmass2) ;
 }
 
-unsigned int TSU::Kinematics::calcDeltaR2BWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      int detaB = abs( tob1->eta() - tob2->eta() );
-      int dphiB = abs( tob1->phi() - tob2->phi() );
-      if(dphiB>64) //Probably same error here as in DeltaPhiBW. Check
-         dphiB = dphiB - 64;
-      if(dphiB>32)
-         dphiB = 64 - dphiB;
+unsigned int TSU::Kinematics::calcTMassBWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+  auto bit_cosphi = TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Cos.at(abs(tob1->phi() - tob2->phi())));
+  TSU::L1TopoDataTypes<11,0> bit_Et1(tob1->Et());
+  TSU::L1TopoDataTypes<11,0> bit_Et2(tob2->Et());
+  TSU::L1TopoDataTypes<22,0> bit_tmass2 = 2*bit_Et1*bit_Et2*(1.  - bit_cosphi);
+  return int(bit_tmass2) ;
+  // end bitwise implementation
+}
 
-      unsigned int bit_dr2 = dphiB*dphiB + detaB*detaB;
-      return bit_dr2;
+unsigned int TSU::Kinematics::calcDeltaR2BWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+  int detaB = abs( tob1->eta() - tob2->eta() );
+  int dphiB = abs( tob1->phi() - tob2->phi() );
+  if(dphiB>64) //Probably same error here as in DeltaPhiBW. Check
+    dphiB = dphiB - 64;
+  if(dphiB>32)
+    dphiB = 64 - dphiB;
+
+  unsigned int bit_dr2 = dphiB*dphiB + detaB*detaB;
+  return bit_dr2;
 }
 
 unsigned int TSU::Kinematics::calcDeltaPhiBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2){
-      int dphiB = abs( tob1->phi() - tob2->phi() );
-      if(dphiB>64)
-         dphiB = dphiB - 64;
-      if(dphiB>32)
-         dphiB = 64 - dphiB;
+  int dphiB = abs( tob1->phi() - tob2->phi() );
+  if(dphiB>64)
+    dphiB = dphiB - 64;
+  if(dphiB>32)
+    dphiB = 64 - dphiB;
 
-      return dphiB ;
+  return dphiB ;
 }
 
 unsigned int TSU::Kinematics::calcDeltaEtaBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      double deta = abs( tob1->eta() - tob2->eta() );
-	return deta;
+  double deta = abs( tob1->eta() - tob2->eta() );
+  return deta;
 }
 
 unsigned int TSU::Kinematics::calcInvMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2){
@@ -98,80 +107,98 @@ unsigned int TSU::Kinematics::calcInvMassBW(const TCS::GenericTOB* tob1, const T
   return int(bit_invmass2) ;
 }
 
-unsigned int TSU::Kinematics::calcDeltaR2BW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      int detaB = abs( tob1->eta() - tob2->eta() );
-      int dphiB = abs( tob1->phi() - tob2->phi() );
-      if(dphiB>64) //Probably same error here as in DeltaPhiBW. Check
-         dphiB = dphiB - 64;
-      if(dphiB>32)
-         dphiB = 64 - dphiB;
+unsigned int TSU::Kinematics::calcTMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+  auto bit_cosphi = TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Cos.at(abs(tob1->phi() - tob2->phi())));
+  TSU::L1TopoDataTypes<11,0> bit_Et1(tob1->Et());
+  TSU::L1TopoDataTypes<11,0> bit_Et2(tob2->Et());
+  TSU::L1TopoDataTypes<22,0> bit_tmass2 = 2*bit_Et1*bit_Et2*(1.  - bit_cosphi);
+  return int(bit_tmass2) ;
+  // end bitwise implementation
+}
 
-      unsigned int bit_dr2 = dphiB*dphiB + detaB*detaB;
-      return bit_dr2;
+unsigned int TSU::Kinematics::calcDeltaR2BW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+  int detaB = abs( tob1->eta() - tob2->eta() );
+  int dphiB = abs( tob1->phi() - tob2->phi() );
+  if(dphiB>64) //Probably same error here as in DeltaPhiBW. Check
+    dphiB = dphiB - 64;
+  if(dphiB>32)
+    dphiB = 64 - dphiB;
+
+  unsigned int bit_dr2 = dphiB*dphiB + detaB*detaB;
+  return bit_dr2;
 }
 
 unsigned long TSU::Kinematics::quadraticSumBW(int i1, int i2){
-    unsigned int ui1 = i1, ui2=i2;
-    unsigned int a = ui1*ui1 + ui2*ui2; 
+  unsigned int ui1 = i1, ui2=i2;
+  unsigned int a = ui1*ui1 + ui2*ui2; 
 
-    unsigned int result=0;
-    int left=0, right=0; 
-    unsigned int r=0;
-    int sign=0;
+  unsigned int result=0;
+  int left=0, right=0; 
+  unsigned int r=0;
+  int sign=0;
   
-    //The values for halflength and bitmask enforce the
-    //bitwise overflow limit, not the precision of the chosen C++ parameters
-    int halflength = 16; //max 16
-    unsigned int bitmask = 0b11111111111111111111111111111111; //32 bits
-    bitmask >>= (32 - halflength*2); //does nothing unless halflength changes
+  //The values for halflength and bitmask enforce the
+  //bitwise overflow limit, not the precision of the chosen C++ parameters
+  int halflength = 16; //max 16
+  unsigned int bitmask = 0b11111111111111111111111111111111; //32 bits
+  bitmask >>= (32 - halflength*2); //does nothing unless halflength changes
   
-    for(int i = 0; i < halflength; i++){ //16-->4
-        right = 1 + (sign<<1) + (result<<2);
-        left = (r<<2) + (a >> (2*halflength-2));
-        a <<= 2;
-        a = a & bitmask;
-        r = sign ? (left + right) : (left - right);
-        sign = ((r & (1 << (halflength+1) ))  > 0) ? 1 : 0;
-        result <<= 1;
-        if(sign==0) result += 1;
-    }
-    return result;
+  for(int i = 0; i < halflength; i++){ //16-->4
+    right = 1 + (sign<<1) + (result<<2);
+    left = (r<<2) + (a >> (2*halflength-2));
+    a <<= 2;
+    a = a & bitmask;
+    r = sign ? (left + right) : (left - right);
+    sign = ((r & (1 << (halflength+1) ))  > 0) ? 1 : 0;
+    result <<= 1;
+    if(sign==0) result += 1;
+  }
+  return result;
 }
 
 /*------------------------------------------ NON-BITWISE --------------------------------------------------*/
 
 unsigned int TSU::Kinematics::calcDeltaPhi(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
-      if(dphi>M_PI)
-         dphi = 2*M_PI - dphi;
+  double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
+  if(dphi>M_PI)
+    dphi = 2*M_PI - dphi;
 
-      return round( 10 * dphi );
+  return round( 10 * dphi );
 }
 
 unsigned int TSU::Kinematics::calcDeltaEta(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      double deta = fabs( tob1->eta() - tob2->eta() );
-	return deta;
+  double deta = fabs( tob1->eta() - tob2->eta() );
+  return deta;
 }
 
 unsigned int TSU::Kinematics::calcInvMass(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      double deta = fabs( tob1->etaDouble() - tob2->etaDouble() );
-      double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
-      if(dphi>M_PI)
-         dphi = 2*M_PI - dphi;
+  double deta = fabs( tob1->etaDouble() - tob2->etaDouble() );
+  double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
+  if(dphi>M_PI)
+    dphi = 2*M_PI - dphi;
+
+  double cosheta = cosh ( deta);
+  double cosphi = cos ( dphi);
+  double invmass2 = 2*tob1->Et()*tob2->Et()*(cosheta - cosphi);
+  return round( invmass2 );
+}
 
-      double cosheta = cosh ( deta);
-      double cosphi = cos ( dphi);
-      double invmass2 = 2*tob1->Et()*tob2->Et()*(cosheta - cosphi);
-      return round( invmass2 );
+unsigned int TSU::Kinematics::calcTMass(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
+  double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
+  if(dphi>M_PI)
+    dphi = 2*M_PI - dphi;
+      
+  double cosphi = cos ( dphi);
+  double tmass2 = 2*tob1->Et()*tob2->Et()*(1 - cosphi);
+  return round( tmass2 );
 }
 
 unsigned int TSU::Kinematics::calcDeltaR2(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-      double deta = ( tob1->etaDouble() - tob2->etaDouble() );
-      double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
-      if(dphi>M_PI)
-         dphi = 2*M_PI - dphi;
+  double deta = ( tob1->etaDouble() - tob2->etaDouble() );
+  double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
+  if(dphi>M_PI)
+    dphi = 2*M_PI - dphi;
 
 
-      return round ( 100 * ((dphi)*(dphi) + (deta)*(deta) )) ;
+  return round ( 100 * ((dphi)*(dphi) + (deta)*(deta) )) ;
 }
-
-- 
GitLab


From 7cd6474360dee926171a81985a8b1a4718bd98c3 Mon Sep 17 00:00:00 2001
From: Anil Sonay <anil.sonay@cern.ch>
Date: Thu, 18 Mar 2021 21:12:22 +0100
Subject: [PATCH 4/4] Remove using namespace std

---
 .../L1TopoSimulationUtils/Root/Kinematics.cxx | 47 +++++++++----------
 1 file changed, 22 insertions(+), 25 deletions(-)

diff --git a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Kinematics.cxx b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Kinematics.cxx
index 791f197f9ae0..e9cf4ed6292c 100644
--- a/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Kinematics.cxx
+++ b/Trigger/TrigT1/L1Topo/L1TopoSimulationUtils/Root/Kinematics.cxx
@@ -14,12 +14,9 @@
 #include "L1TopoSimulationUtils/Trigo.h"
 #include "L1TopoEvent/GenericTOB.h"
 
-//
-
-using namespace std; 
 
 unsigned int TSU::Kinematics::calcDeltaPhiBWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2){
-  int dphiB = abs( tob1->phi() - tob2->phi() );
+  int dphiB = std::abs( tob1->phi() - tob2->phi() );
   if(dphiB>64)
     dphiB = dphiB - 64;
   if(dphiB>32)
@@ -29,23 +26,23 @@ unsigned int TSU::Kinematics::calcDeltaPhiBWLegacy(const TCS::GenericTOB* tob1,
 }
 
 unsigned int TSU::Kinematics::calcDeltaEtaBWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-  double deta = abs( tob1->eta() - tob2->eta() );
+  double deta = std::abs( tob1->eta() - tob2->eta() );
   return deta;
 }
 
 unsigned int TSU::Kinematics::calcInvMassBWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2){
 
-  auto bit_cosheta = TSU::L1TopoDataTypes<19,7>(TSU::Hyperbolic::Cosh.at(abs(tob1->eta() - tob2->eta())));
+  auto bit_cosheta = TSU::L1TopoDataTypes<19,7>(TSU::Hyperbolic::Cosh.at(std::abs(tob1->eta() - tob2->eta())));
   //In case of EM objects / jets / taus the phi angle goes between 0 and 64 while muons are between -32 and 32, applying a shift to keep delta-phi in the allowed range. 
   int phi_tob1 = tob1->phi();
   int phi_tob2 = tob2->phi();
   //those cases should happen only in mixed EM/jets/tau plus mu triggers, if both phi's are in [0,2pi] will not get in
-  if ( abs(phi_tob1-phi_tob2)>=64 )
+  if ( std::abs(phi_tob1-phi_tob2)>=64 )
     {
       if(phi_tob1 >= 32) phi_tob1 = phi_tob1-64;
       if(phi_tob2 >= 32) phi_tob2 = phi_tob2-64;
     }
-  auto bit_cosphi = TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Cos.at(abs( phi_tob1 - phi_tob2 )));
+  auto bit_cosphi = TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Cos.at(std::abs( phi_tob1 - phi_tob2 )));
   TSU::L1TopoDataTypes<11,0> bit_Et1(tob1->Et());
   TSU::L1TopoDataTypes<11,0> bit_Et2(tob2->Et());
   auto bit_invmass2 = bit_Et1*bit_Et2*(bit_cosheta - bit_cosphi)*2;
@@ -53,7 +50,7 @@ unsigned int TSU::Kinematics::calcInvMassBWLegacy(const TCS::GenericTOB* tob1, c
 }
 
 unsigned int TSU::Kinematics::calcTMassBWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-  auto bit_cosphi = TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Cos.at(abs(tob1->phi() - tob2->phi())));
+  auto bit_cosphi = TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Cos.at(std::abs(tob1->phi() - tob2->phi())));
   TSU::L1TopoDataTypes<11,0> bit_Et1(tob1->Et());
   TSU::L1TopoDataTypes<11,0> bit_Et2(tob2->Et());
   TSU::L1TopoDataTypes<22,0> bit_tmass2 = 2*bit_Et1*bit_Et2*(1.  - bit_cosphi);
@@ -62,8 +59,8 @@ unsigned int TSU::Kinematics::calcTMassBWLegacy(const TCS::GenericTOB* tob1, con
 }
 
 unsigned int TSU::Kinematics::calcDeltaR2BWLegacy(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-  int detaB = abs( tob1->eta() - tob2->eta() );
-  int dphiB = abs( tob1->phi() - tob2->phi() );
+  int detaB = std::abs( tob1->eta() - tob2->eta() );
+  int dphiB = std::abs( tob1->phi() - tob2->phi() );
   if(dphiB>64) //Probably same error here as in DeltaPhiBW. Check
     dphiB = dphiB - 64;
   if(dphiB>32)
@@ -74,7 +71,7 @@ unsigned int TSU::Kinematics::calcDeltaR2BWLegacy(const TCS::GenericTOB* tob1, c
 }
 
 unsigned int TSU::Kinematics::calcDeltaPhiBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2){
-  int dphiB = abs( tob1->phi() - tob2->phi() );
+  int dphiB = std::abs( tob1->phi() - tob2->phi() );
   if(dphiB>64)
     dphiB = dphiB - 64;
   if(dphiB>32)
@@ -84,23 +81,23 @@ unsigned int TSU::Kinematics::calcDeltaPhiBW(const TCS::GenericTOB* tob1, const
 }
 
 unsigned int TSU::Kinematics::calcDeltaEtaBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-  double deta = abs( tob1->eta() - tob2->eta() );
+  double deta = std::abs( tob1->eta() - tob2->eta() );
   return deta;
 }
 
 unsigned int TSU::Kinematics::calcInvMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2){
 
-  auto bit_cosheta = TSU::L1TopoDataTypes<19,7>(TSU::Hyperbolic::Cosh.at(abs(tob1->eta() - tob2->eta())));
+  auto bit_cosheta = TSU::L1TopoDataTypes<19,7>(TSU::Hyperbolic::Cosh.at(std::abs(tob1->eta() - tob2->eta())));
   //In case of EM objects / jets / taus the phi angle goes between 0 and 64 while muons are between -32 and 32, applying a shift to keep delta-phi in the allowed range. 
   int phi_tob1 = tob1->phi();
   int phi_tob2 = tob2->phi();
   //those cases should happen only in mixed EM/jets/tau plus mu triggers, if both phi's are in [0,2pi] will not get in
-  if ( abs(phi_tob1-phi_tob2)>=64 )
+  if ( std::abs(phi_tob1-phi_tob2)>=64 )
     {
       if(phi_tob1 >= 32) phi_tob1 = phi_tob1-64;
       if(phi_tob2 >= 32) phi_tob2 = phi_tob2-64;
     }
-  auto bit_cosphi = TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Cos.at(abs( phi_tob1 - phi_tob2 )));
+  auto bit_cosphi = TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Cos.at(std::abs( phi_tob1 - phi_tob2 )));
   TSU::L1TopoDataTypes<11,0> bit_Et1(tob1->Et());
   TSU::L1TopoDataTypes<11,0> bit_Et2(tob2->Et());
   auto bit_invmass2 = bit_Et1*bit_Et2*(bit_cosheta - bit_cosphi)*2;
@@ -108,7 +105,7 @@ unsigned int TSU::Kinematics::calcInvMassBW(const TCS::GenericTOB* tob1, const T
 }
 
 unsigned int TSU::Kinematics::calcTMassBW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-  auto bit_cosphi = TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Cos.at(abs(tob1->phi() - tob2->phi())));
+  auto bit_cosphi = TSU::L1TopoDataTypes<9,7>(TSU::Trigo::Cos.at(std::abs(tob1->phi() - tob2->phi())));
   TSU::L1TopoDataTypes<11,0> bit_Et1(tob1->Et());
   TSU::L1TopoDataTypes<11,0> bit_Et2(tob2->Et());
   TSU::L1TopoDataTypes<22,0> bit_tmass2 = 2*bit_Et1*bit_Et2*(1.  - bit_cosphi);
@@ -117,8 +114,8 @@ unsigned int TSU::Kinematics::calcTMassBW(const TCS::GenericTOB* tob1, const TCS
 }
 
 unsigned int TSU::Kinematics::calcDeltaR2BW(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-  int detaB = abs( tob1->eta() - tob2->eta() );
-  int dphiB = abs( tob1->phi() - tob2->phi() );
+  int detaB = std::abs( tob1->eta() - tob2->eta() );
+  int dphiB = std::abs( tob1->phi() - tob2->phi() );
   if(dphiB>64) //Probably same error here as in DeltaPhiBW. Check
     dphiB = dphiB - 64;
   if(dphiB>32)
@@ -159,7 +156,7 @@ unsigned long TSU::Kinematics::quadraticSumBW(int i1, int i2){
 /*------------------------------------------ NON-BITWISE --------------------------------------------------*/
 
 unsigned int TSU::Kinematics::calcDeltaPhi(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-  double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
+  double dphi = std::fabs( tob1->phiDouble() - tob2->phiDouble() );
   if(dphi>M_PI)
     dphi = 2*M_PI - dphi;
 
@@ -167,13 +164,13 @@ unsigned int TSU::Kinematics::calcDeltaPhi(const TCS::GenericTOB* tob1, const TC
 }
 
 unsigned int TSU::Kinematics::calcDeltaEta(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-  double deta = fabs( tob1->eta() - tob2->eta() );
+  double deta = std::fabs( tob1->eta() - tob2->eta() );
   return deta;
 }
 
 unsigned int TSU::Kinematics::calcInvMass(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-  double deta = fabs( tob1->etaDouble() - tob2->etaDouble() );
-  double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
+  double deta = std::fabs( tob1->etaDouble() - tob2->etaDouble() );
+  double dphi = std::fabs( tob1->phiDouble() - tob2->phiDouble() );
   if(dphi>M_PI)
     dphi = 2*M_PI - dphi;
 
@@ -184,7 +181,7 @@ unsigned int TSU::Kinematics::calcInvMass(const TCS::GenericTOB* tob1, const TCS
 }
 
 unsigned int TSU::Kinematics::calcTMass(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
-  double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
+  double dphi = std::fabs( tob1->phiDouble() - tob2->phiDouble() );
   if(dphi>M_PI)
     dphi = 2*M_PI - dphi;
       
@@ -195,7 +192,7 @@ unsigned int TSU::Kinematics::calcTMass(const TCS::GenericTOB* tob1, const TCS::
 
 unsigned int TSU::Kinematics::calcDeltaR2(const TCS::GenericTOB* tob1, const TCS::GenericTOB* tob2) {
   double deta = ( tob1->etaDouble() - tob2->etaDouble() );
-  double dphi = fabs( tob1->phiDouble() - tob2->phiDouble() );
+  double dphi = std::fabs( tob1->phiDouble() - tob2->phiDouble() );
   if(dphi>M_PI)
     dphi = 2*M_PI - dphi;
 
-- 
GitLab