From fc478430a2c0326341cc5b1bb7ab21e9b701821d Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <fwinkl@cern>
Date: Tue, 30 Jun 2020 16:08:21 +0200
Subject: [PATCH] TrigJetMonitoring: Package cleanup

- delete obsolete job options file
- enable flake8 and fix code
- cleanup cmake configuration
- move private header to src directory
---
 .../TrigJetMonitoring/CMakeLists.txt          |  29 +--
 .../python/JetChainRemapping.py               |   2 +
 .../python/JetCollRemapping.py                |   2 +
 .../python/TrigJetMonitoringConfig.py         |  14 +-
 .../python/TrigJetMonitoringConfig_cosmics.py |  11 +-
 .../python/TrigJetMonitoringConfig_physics.py |  13 +-
 .../share/HLTJetMon_jobOptions.py             | 172 ------------------
 .../TrigJetMonitoring/src/HLTJetMonTool.cxx   |   2 +-
 .../HLTJetMonTool.h                           |   0
 .../components/TrigJetMonitoring_entries.cxx  |   2 +-
 10 files changed, 28 insertions(+), 219 deletions(-)
 delete mode 100644 Trigger/TrigMonitoring/TrigJetMonitoring/share/HLTJetMon_jobOptions.py
 rename Trigger/TrigMonitoring/TrigJetMonitoring/{TrigJetMonitoring => src}/HLTJetMonTool.h (100%)
 mode change 100755 => 100644

diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/CMakeLists.txt b/Trigger/TrigMonitoring/TrigJetMonitoring/CMakeLists.txt
index 3847b635f2e..f4fd742ae34 100644
--- a/Trigger/TrigMonitoring/TrigJetMonitoring/CMakeLists.txt
+++ b/Trigger/TrigMonitoring/TrigJetMonitoring/CMakeLists.txt
@@ -1,38 +1,17 @@
-################################################################################
-# Package: TrigJetMonitoring
-################################################################################
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 # Declare the package name:
 atlas_subdir( TrigJetMonitoring )
 
-# Declare the package's dependencies:
-atlas_depends_on_subdirs( PUBLIC
-                          Event/xAOD/xAODEventInfo
-                          Event/xAOD/xAODJet
-                          Event/xAOD/xAODTrigger
-                          GaudiKernel
-                          PhysicsAnalysis/AnalysisTrigger/AnalysisTriggerEvent
-                          Trigger/TrigEvent/TrigCaloEvent
-                          Trigger/TrigMonitoring/TrigHLTMonitoring
-                          PRIVATE
-                          Control/StoreGate
-                          Trigger/TrigAnalysis/TrigDecisionTool
-                          Trigger/TrigEvent/TrigSteeringEvent
-                          Trigger/TrigSteer/DecisionHandling )
-
 # External dependencies:
 find_package( Boost )
-find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread MathMore Minuit Minuit2 Matrix Physics HistPainter Rint Graf Graf3d Gpad Html Postscript Gui GX11TTF GX11 )
-find_package( cx_Oracle )
+find_package( ROOT COMPONENTS Core Hist )
 
 # Component(s) in the package:
 atlas_add_component( TrigJetMonitoring
                      src/*.cxx src/components/*.cxx
                      INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${ROOT_INCLUDE_DIRS}
-                     LINK_LIBRARIES ${Boost_LIBRARIES} ${ROOT_LIBRARIES} TrigSteeringEvent 
-                     xAODEventInfo xAODJet xAODTrigger GaudiKernel AnalysisTriggerEvent TrigCaloEvent 
-                     TrigHLTMonitoringLib StoreGateLib SGtests TrigDecisionToolLib DecisionHandlingLib )
+                     LINK_LIBRARIES ${ROOT_LIBRARIES} AnalysisTriggerEvent AthenaMonitoringKernelLib AthenaMonitoringLib GaudiKernel StoreGateLib TrigDecisionToolLib TrigHLTMonitoringLib TrigSteeringEvent xAODEventInfo xAODJet xAODTrigger )
 
 # 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/Trigger/TrigMonitoring/TrigJetMonitoring/python/JetChainRemapping.py b/Trigger/TrigMonitoring/TrigJetMonitoring/python/JetChainRemapping.py
index cde8d7e9155..4a3cb1739ad 100644
--- a/Trigger/TrigMonitoring/TrigJetMonitoring/python/JetChainRemapping.py
+++ b/Trigger/TrigMonitoring/TrigJetMonitoring/python/JetChainRemapping.py
@@ -1,3 +1,5 @@
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+
 # Corresponding Run 3 jet chain name for each Run 2 jet chain
 JetChainRun2ToRun3 = {
   'HLT_j420'           : 'HLT_j420_L1J100',
diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/python/JetCollRemapping.py b/Trigger/TrigMonitoring/TrigJetMonitoring/python/JetCollRemapping.py
index cd67696182a..31a4414b7eb 100644
--- a/Trigger/TrigMonitoring/TrigJetMonitoring/python/JetCollRemapping.py
+++ b/Trigger/TrigMonitoring/TrigJetMonitoring/python/JetCollRemapping.py
@@ -1,3 +1,5 @@
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
+
 # Corresponding Run 3 jet collection name for each Run 2 jet collection
 JetCollRun2ToRun3 = {
   'HLT_xAOD__JetContainer_a4tcemsubjesISFS'   : 'HLT_AntiKt4EMTopoJets_subjesIS',                   # default small-R
diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitoringConfig.py b/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitoringConfig.py
index 8aac676048d..734b26138b8 100644
--- a/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitoringConfig.py
+++ b/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitoringConfig.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 #################################################################################################
 #  file: TrigJetMonitoring_physics.py
@@ -137,8 +137,8 @@ if (pp) or (mc):
                   "a4tcemsubjesISFS"  : "HLT_xAOD__JetContainer_a4tcemsubjesISFS",
                   "a4tclcwjesFS"    : "HLT_xAOD__JetContainer_a4tclcwjesFS",
                   "a4GSC" : "HLT_xAOD__JetContainer_GSCJet",
-		  "a10r_tcemsubjesISFS": "HLT_xAOD__JetContainer_a10r_tcemsubjesISFS",
-		  "a4tcemnojcalibFS": "HLT_xAOD__JetContainer_a4tcemnojcalibFS",
+                  "a10r_tcemsubjesISFS": "HLT_xAOD__JetContainer_a10r_tcemsubjesISFS",
+                  "a4tcemnojcalibFS": "HLT_xAOD__JetContainer_a4tcemnojcalibFS",
                   "a10tclcwsubjesFS"   : "HLT_xAOD__JetContainer_a10tclcwsubjesFS",
                   "a10ttclcwjesFS"   : "HLT_xAOD__JetContainer_a10ttclcwjesFS",
                   "a4tcemsubjesISFSftk"  : "HLT_xAOD__JetContainer_a4tcemsubjesISFSftk",
@@ -799,7 +799,7 @@ def TrigJetMonitoringTool():
             histoPathBase        = "/Trigger/HLT",
             JetMonBase           = "/HLT/JetMon",
             DoL1Efficiency       = True,         # w.r.t offline
-	    DoOfflineJets        = True,         # fill offline jet plots
+            DoOfflineJets        = True,         # fill offline jet plots
             DoHLTEfficiency      = True,         # w.r.t offline (HLT eff = L1 & HLT)
  #           EnableLumi           = True,        # Enable Luminosity Tool
  #           DoLumiWeight         = True,        # Decide to apply luminosity weights                       
@@ -967,8 +967,8 @@ def TrigJetMonitoringTool():
             ## Out-of-time Calo Jet Energy (not to exceed X ns)
             #DoOFMaxJetTimeCut = True,
             #OFMaxTimens = 50.
-        );
-  from AthenaCommon.AppMgr import ToolSvc
+        )
+  #from AthenaCommon.AppMgr import ToolSvc
   #from AthenaCommon import CfgMgr
 
  # from TrigHLTMonitoring.HLTMonFlags import HLTMonFlags
@@ -984,7 +984,7 @@ def TrigJetMonitoringTool():
                                           #ConfigTool = ToolSvc.xAODConfigTool,
                                           #TrigDecisionKey = "xTrigDecision" )
 
-  list = [ HLTJetMon ];
+  list = [ HLTJetMon ]
   return list
 
 
diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitoringConfig_cosmics.py b/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitoringConfig_cosmics.py
index 427013420a4..b71f54e66d9 100644
--- a/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitoringConfig_cosmics.py
+++ b/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitoringConfig_cosmics.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 #################################################################################################
 #  file: TrigJetMonitoring_cosmics.py
@@ -103,7 +103,7 @@ def TrigJetMonitoringTool():
             histoPathBase        = "/Trigger/HLT",
             JetMonBase           = "/HLT/JetMon",
             DoL1Efficiency       = False,         # w.r.t offline
-	    DoOfflineJets        = False,         # fill offline jet plots
+            DoOfflineJets        = False,         # fill offline jet plots
             DoHLTEfficiency      = False,         # w.r.t offline (EF eff = L1 & L2 & EF)
 
             # Select events based on any of these passing EvtSelTriggers 
@@ -244,8 +244,7 @@ def TrigJetMonitoringTool():
             ## Out-of-time Calo Jet Energy (not to exceed X ns)
             #DoOFMaxJetTimeCut = True,
             #OFMaxTimens = 50.
-        );
-  #from AthenaCommon.AppMgr import ToolSvc
-  #ToolSvc += HLTJetMon;
-  list = [ HLTJetMon ];
+        )
+
+  list = [ HLTJetMon ]
   return list
diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitoringConfig_physics.py b/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitoringConfig_physics.py
index 879cf76f2fb..a584567a1db 100644
--- a/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitoringConfig_physics.py
+++ b/Trigger/TrigMonitoring/TrigJetMonitoring/python/TrigJetMonitoringConfig_physics.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
+# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 
 #################################################################################################
 #  file: TrigJetMonitoring_physics.py
@@ -21,7 +21,7 @@ hlt_JetKeys = { "a10tcemsubFS" : "HLT_xAOD__JetContainer_a10tcemsubFS",
                 "a4tcemsubFS" : "HLT_xAOD__JetContainer_a4tcemsubFS", 
                 "a4tcemjesFS" : "HLT_xAOD__JetContainer_a4tcemjesFS", 
                 "a4tcemsubjesFS" : "HLT_xAOD__JetContainer_a4tcemsubjesFS",
-		"a4tclcwjesFS" : "HLT_xAOD__JetContainer_a4tclcwjesFS" }
+                "a4tclcwjesFS" : "HLT_xAOD__JetContainer_a4tclcwjesFS" }
 
 hlt_offlineJetKeys = { "AntiKt4LCTopoJets" : "AntiKt4LCTopoJets", 
                        "AntiKt4EMTopoJets" : "AntiKt4EMTopoJets", 
@@ -103,7 +103,7 @@ def TrigJetMonitoringTool():
             histoPathBase        = "/Trigger/HLT",
             JetMonBase           = "/HLT/JetMon",
             DoL1Efficiency       = True,         # w.r.t offline
-	    DoOfflineJets        = True,         # fill offline jet plots
+            DoOfflineJets        = True,         # fill offline jet plots
             DoHLTEfficiency      = True,         # w.r.t offline (HLT eff = L1 & HLT)
                                    
             # SG Keys for L1, EF, OF Jets
@@ -239,8 +239,7 @@ def TrigJetMonitoringTool():
             ## Out-of-time Calo Jet Energy (not to exceed X ns)
             #DoOFMaxJetTimeCut = True,
             #OFMaxTimens = 50.
-        );
-  #from AthenaCommon.AppMgr import ToolSvc
-  #ToolSvc += HLTJetMon;
-  list = [ HLTJetMon ];
+        )
+
+  list = [ HLTJetMon ]
   return list
diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/share/HLTJetMon_jobOptions.py b/Trigger/TrigMonitoring/TrigJetMonitoring/share/HLTJetMon_jobOptions.py
deleted file mode 100644
index cd93a4d9e2d..00000000000
--- a/Trigger/TrigMonitoring/TrigJetMonitoring/share/HLTJetMon_jobOptions.py
+++ /dev/null
@@ -1,172 +0,0 @@
-
-###################################################
-# File   : Job Options to run monitoring in stand-alone mode 
-# Author : Venkat.Kaushik@cern.ch
-# Date   : Jan 2010
-###################################################
-doLocal = True
-
-import sys
-
-######################################################################################
-# helper gets input collection
-##############################
-def getInputFiles(dir, AODHLTP):
-
-  import fnmatch, os, glob
-  if len(AODHLTP) > 0:
-    del AODHLTP[:]
-
-  if len(dir) == 2:
-    all_dirs = glob.glob(dir[0])
-    for thedir in all_dirs:
-      print 'i am in', thedir
-      for fileName in os.listdir(thedir):
-        if fnmatch.fnmatch(fileName, dir[1] ):
-          fullpath = os.path.join(thedir,fileName)
-          print 'file ', fullpath
-          AODHLTP.append(fullpath)
-
-
-
-######################################################################################
-# Input files
-##############################
-
-AODir2011 = ['/raid01/venkat/dataset/data/csc/2011/mcpskim/data10_7TeV.*.phys*', 'data10_7TeV*DESD_ZMUMU*']
-AODir2012 = ['/raid01/venkat/dataset/hlt-met/2012', 'AOD*pool*']
-AODir2014 = ['/afs/cern.ch/work/s/sawyer/data','data12_8TeV*.pool.root']
-TestDir   = ['/afs/cern.ch/atlas/offline/ReleaseData/v3/testfile/','valid1.005200.T1_McAtNlo_Jimmy.digit.RDO.e322_s488_d151_tid039414_RDO.039414._00001_extract_10evt.pool.root']
-
-HLTJetInputFiles = []
-if doLocal:
-  getInputFiles(TestDir, HLTJetInputFiles)
-  print HLTJetInputFiles
-  if len(HLTJetInputFiles) < 1:
-    print "No input files specified yet! Cannot do anything."
-    sys.exit(0)
-  else:
-    for file in HLTJetInputFiles:
-      print file
-
-
-
-#################################
-# Auto configure everything
-#################################
-import AthenaPoolCnvSvc.ReadAthenaPool
-ServiceMgr.EventSelector.InputCollections=HLTJetInputFiles
-ServiceMgr.PoolSvc.AttemptCatalogPatch = True;
-ServiceMgr.OutputLevel=ERROR
-
-if 1:
-  #
-  from AthenaCommon.AthenaCommonFlags import athenaCommonFlags
-
-  if len(athenaCommonFlags.FilesInput()) == 0:
-    athenaCommonFlags.FilesInput = ServiceMgr.EventSelector.InputCollections
-    
-  #
-  import AthenaPoolCnvSvc.ReadAthenaPool
-    
-  import AthenaPoolCnvSvc.WriteAthenaPool
-    
-  #
-  from RecExConfig.RecFlags import rec
-
-  rec.AutoConfiguration          .set_Value_and_Lock(["everything"])
-    
-  rec.doCBNT                     .set_Value_and_Lock(False)
-  rec.doESD                      .set_Value_and_Lock(False)
-  rec.doHist                     .set_Value_and_Lock(False)
-  rec.doPerfMon                  .set_Value_and_Lock(False)
-    
-  rec.doWriteAOD                 .set_Value_and_Lock(False)
-  rec.doWriteESD                 .set_Value_and_Lock(False)
-  rec.doWriteTAG                 .set_Value_and_Lock(False)
-  rec.doWriteTAGCOM              .set_Value_and_Lock(False)
-
-  #
-  from AthenaCommon.Include import include
-    
-  include ("RecExCommon/RecExCommon_topOptions.py")
-
-#
-for i in ServiceMgr:  i.OutputLevel=INFO
-
-##############################
-# Output file
-##############################
-OutputFile = 'Monitoring.HLTjet.root'
-
-from GaudiSvc.GaudiSvcConf import THistSvc
-svcMgr += THistSvc()
-svcMgr.THistSvc.Output += ["MonitorHLTjet DATAFILE='" + OutputFile + "' OPT='RECREATE'"]
-
-############################################################
-
-##############################
-# Add the Toplevel Alg
-##############################
-
-from AthenaCommon.AlgSequence import AlgSequence
-topSequence = AlgSequence()
-
-###############################
-# Configure the job
-###############################
-
-from AthenaCommon.GlobalFlags import globalflags
-globalflags.DetGeo = 'atlas'
-
-from RecExConfig.RecFlags import rec
-rec.readRDO=False
-rec.readAOD=True
-rec.doWriteESD=False
-rec.doWriteAOD=False
-rec.doWriteTAG=False
-
-###############################
-# Setup Athena Monitoring
-###############################
-from AthenaMonitoring.AthenaMonitoringConf import AthenaMonManager
-
-if not 'DQMonFlags' in dir():
-  from AthenaMonitoring.DQMonFlags import DQMonFlags
-
-HLTjetOutputLevel=INFO
-myTrigDecisionTool = ""
-if(DQMonFlags.useTrigger() and hasattr(ToolSvc, DQMonFlags.nameTrigDecTool())):
-  myTrigDecisionTool = getattr(ToolSvc, DQMonFlags.nameTrigDecTool())
-else:
-  from TrigDecisionTool.TrigDecisionToolConf import Trig__TrigDecisionTool
-  ToolSvc += Trig__TrigDecisionTool( "TrigDecisionTool" )
-  ToolSvc.TrigDecisionTool.OutputLevel=ERROR
-  ToolSvc.TrigDecisionTool.Navigation.OutputLevel = FATAL
-
-HLTjetMonMan = AthenaMonManager(name="HLTMonManager",
-                                   FileKey             = DQMonFlags.monManFileKey(),
-                                   Environment         = DQMonFlags.monManEnvironment(),
-                                   OutputLevel         = HLTjetOutputLevel)
-
-topSequence += HLTjetMonMan
-
-# in order to check available detectors
-from RecExConfig.RecFlags  import rec
-
-try:
-  from TrigJetMonitoring.TrigJetMonitoringConfig import TrigJetMonitoringTool
-  HLTjetMonMan.AthenaMonTools += TrigJetMonitoringTool()
-
-except:
-  print "Problems with HLTJetTool, tool not enabled"
-
-HLTjetMonMan.FileKey = "MonitorHLTjet"
-
-print HLTjetMonMan;
-
-##########################
-# Events to run over
-##########################
-theApp.EvtMax = 10
-
diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/HLTJetMonTool.cxx b/Trigger/TrigMonitoring/TrigJetMonitoring/src/HLTJetMonTool.cxx
index 466b607aa62..38c6761f09e 100755
--- a/Trigger/TrigMonitoring/TrigJetMonitoring/src/HLTJetMonTool.cxx
+++ b/Trigger/TrigMonitoring/TrigJetMonitoring/src/HLTJetMonTool.cxx
@@ -5,7 +5,7 @@
 
 #include "StoreGate/StoreGateSvc.h"
 
-#include "TrigJetMonitoring/HLTJetMonTool.h"
+#include "HLTJetMonTool.h"
 
 #include "TrigDecisionTool/ChainGroup.h"
 #include "TrigDecisionTool/Feature.h"
diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/TrigJetMonitoring/HLTJetMonTool.h b/Trigger/TrigMonitoring/TrigJetMonitoring/src/HLTJetMonTool.h
old mode 100755
new mode 100644
similarity index 100%
rename from Trigger/TrigMonitoring/TrigJetMonitoring/TrigJetMonitoring/HLTJetMonTool.h
rename to Trigger/TrigMonitoring/TrigJetMonitoring/src/HLTJetMonTool.h
diff --git a/Trigger/TrigMonitoring/TrigJetMonitoring/src/components/TrigJetMonitoring_entries.cxx b/Trigger/TrigMonitoring/TrigJetMonitoring/src/components/TrigJetMonitoring_entries.cxx
index 6758d84971f..1baafe907da 100644
--- a/Trigger/TrigMonitoring/TrigJetMonitoring/src/components/TrigJetMonitoring_entries.cxx
+++ b/Trigger/TrigMonitoring/TrigJetMonitoring/src/components/TrigJetMonitoring_entries.cxx
@@ -2,7 +2,7 @@
   Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
 */
 
-#include "TrigJetMonitoring/HLTJetMonTool.h"
+#include "../HLTJetMonTool.h"
 #include "../TrigL1JetMonitorAlgorithm.h"
 
 DECLARE_COMPONENT( HLTJetMonTool )
-- 
GitLab