From da53058f7d41149e96b10fac97e4d6f529de53de Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <fwinkl@cern>
Date: Thu, 26 Nov 2020 11:57:52 +0100
Subject: [PATCH] egammaTools: cmake fixes, enable flake8

Remove CLHEP dependency by using Gaudi's `SystemOfUnits.h`. Update cmake
configuration and enable flake8.
---
 .../egamma/egammaTools/CMakeLists.txt          | 18 ++++++------------
 .../egammaTools/python/egammaToolsFactories.py | 14 ++++----------
 .../egammaTools/src/egammaOQFlagsBuilder.cxx   |  6 ++----
 3 files changed, 12 insertions(+), 26 deletions(-)

diff --git a/Reconstruction/egamma/egammaTools/CMakeLists.txt b/Reconstruction/egamma/egammaTools/CMakeLists.txt
index 12849074ea0..b45acb932c0 100644
--- a/Reconstruction/egamma/egammaTools/CMakeLists.txt
+++ b/Reconstruction/egamma/egammaTools/CMakeLists.txt
@@ -1,19 +1,13 @@
-################################################################################
-# Package: egammaTools
-################################################################################
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 # Declare the package name:
 atlas_subdir( egammaTools )
 
-
+# Component(s) in the package:
 atlas_add_component( egammaTools
-	src/*.cxx
-	src/components/*.cxx
-	INCLUDE_DIRS
-	LINK_LIBRARIES CaloConditions CaloEvent  CaloIdentifier CaloRecLib CaloUtilsLib AthenaBaseComps AthenaKernel
-	AthContainers StoreGateLib  Identifier EventKernel EventPrimitives FourMom FourMomUtils  xAODCaloEvent
-	xAODEgamma xAODTracking xAODTruth GaudiKernel LArRecConditions LArCablingLib LumiBlockCompsLib PATCoreLib
-	EgammaAnalysisInterfacesLib egammaRecEvent egammaUtils TrkEventPrimitives egammaInterfacesLib )
+   src/*.cxx
+   src/components/*.cxx
+   LINK_LIBRARIES AthenaBaseComps AthenaKernel CaloConditions CaloDetDescrLib CaloEvent CaloIdentifier CaloInterfaceLib CaloRecLib CaloUtilsLib EgammaAnalysisInterfacesLib EventPrimitives FourMom FourMomUtils GaudiKernel GeoPrimitives Identifier LArCablingLib LArRecConditions LumiBlockCompsLib PATCoreAcceptLib SGTools StoreGateLib TrkEventPrimitives egammaInterfacesLib egammaRecEvent egammaUtils xAODCaloEvent xAODEgamma xAODTracking )
 
 # Install files from the package:
-atlas_install_python_modules( python/*.py )
+atlas_install_python_modules( python/*.py POST_BUILD_CMD ${ATLAS_FLAKE8} )
diff --git a/Reconstruction/egamma/egammaTools/python/egammaToolsFactories.py b/Reconstruction/egamma/egammaTools/python/egammaToolsFactories.py
index 42024a9528d..17caae683d5 100644
--- a/Reconstruction/egamma/egammaTools/python/egammaToolsFactories.py
+++ b/Reconstruction/egamma/egammaTools/python/egammaToolsFactories.py
@@ -6,7 +6,6 @@ __author__ = "Bruno Lenzi"
 
 
 from ROOT import egammaPID
-import cppyy
 from ElectronPhotonSelectorTools.ConfiguredAsgForwardElectronIsEMSelectors \
     import ConfiguredAsgForwardElectronIsEMSelector
 from .EMPIDBuilderBase import EMPIDBuilderPhotonBase
@@ -22,8 +21,6 @@ from egammaRec import egammaKeys
 # to set jobproperties.egammaRecFlags
 from egammaRec.egammaRecFlags import jobproperties
 
-import six
-
 
 _clusterTypes = dict(
     Ele35='ele35', Ele55='ele55', Ele37='ele37',
@@ -35,10 +32,7 @@ _clusterTypes = dict(
 # Configure fixed-size (non-supercell) corrections
 def configureFixedSizeClusterCorrections(swTool):
     "Add attributes ClusterCorrectionToolsXX to egammaSwTool object for fixed-size cluster corrections."
-    from CaloClusterCorrection.CaloSwCorrections import (
-        make_CaloSwCorrections, rfac, etaoff_b1, etaoff_e1,
-        etaoff_b2, etaoff_e2, phioff_b2, phioff_e2, update,
-        time, listBadChannel)
+    from CaloClusterCorrection.CaloSwCorrections import make_CaloSwCorrections
     from CaloRec.CaloRecMakers import _process_tools
 
     for attrName, clName in _clusterTypes.items():
@@ -161,6 +155,6 @@ TightForwardElectronSelector = ToolFactory(
 # -------------------------
 
 # Import the factories that are not defined here
-from .EMTrackMatchBuilder import EMTrackMatchBuilder
-from .egammaOQFlagsBuilder import egammaOQFlagsBuilder
-from .EMShowerBuilder import EMShowerBuilder
+from .EMTrackMatchBuilder import EMTrackMatchBuilder    # noqa: F401
+from .egammaOQFlagsBuilder import egammaOQFlagsBuilder  # noqa: F401
+from .EMShowerBuilder import EMShowerBuilder            # noqa: F401
diff --git a/Reconstruction/egamma/egammaTools/src/egammaOQFlagsBuilder.cxx b/Reconstruction/egamma/egammaTools/src/egammaOQFlagsBuilder.cxx
index 9afe98cfe36..efb6bb9174d 100644
--- a/Reconstruction/egamma/egammaTools/src/egammaOQFlagsBuilder.cxx
+++ b/Reconstruction/egamma/egammaTools/src/egammaOQFlagsBuilder.cxx
@@ -11,7 +11,7 @@
 #include <cmath>
 #include <vector>
 
-#include "CLHEP/Units/SystemOfUnits.h"
+#include "GaudiKernel/SystemOfUnits.h"
 #include "CaloConditions/CaloAffectedRegionInfoVec.h"
 #include "CaloIdentifier/CaloCell_ID.h"
 #include "CaloIdentifier/LArEM_ID.h"
@@ -20,8 +20,6 @@
 #include "StoreGate/ReadHandle.h"
 #include "StoreGate/StoreGateSvc.h"
 
-using CLHEP::GeV;
-
 namespace {
 bool
 isbadtilecell(CaloCellList& ccl,
@@ -194,7 +192,7 @@ egammaOQFlagsBuilder::execute(const EventContext& ctx,
     egammaOQFlagsBuilder::findCentralCell(cluster, cellCentrId);
 
   // Set timing bit
-  const double absEnergyGeV = fabs(cluster->e() * (1. / GeV));
+  const double absEnergyGeV = fabs(cluster->e() * (1. / Gaudi::Units::GeV));
   if (absEnergyGeV != 0 &&
       fabs(cluster->time()) > m_TCut + m_TCutVsE / absEnergyGeV) {
     iflag |= (0x1 << xAOD::EgammaParameters::OutTime);
-- 
GitLab