From c351c743ee0acbcebbdebaf0d96d2a6ad8108be0 Mon Sep 17 00:00:00 2001 From: scott snyder <snyder@bnl.gov> Date: Fri, 6 Mar 2020 14:49:40 +0100 Subject: [PATCH] PhysicsD3PDMaker: Python 3 fixes Updates for python 3 compatibility. --- .../PhysicsD3PDMaker/python/JSD3PD.py | 6 ++-- .../python/METRefGetter_newplup.py | 34 ++++++++++--------- .../PhysicsD3PDMaker/share/MyJetMake.py | 2 -- 3 files changed, 22 insertions(+), 20 deletions(-) diff --git a/PhysicsAnalysis/D3PDMaker/PhysicsD3PDMaker/python/JSD3PD.py b/PhysicsAnalysis/D3PDMaker/PhysicsD3PDMaker/python/JSD3PD.py index 292bbe42691..bc16fe8fc71 100644 --- a/PhysicsAnalysis/D3PDMaker/PhysicsD3PDMaker/python/JSD3PD.py +++ b/PhysicsAnalysis/D3PDMaker/PhysicsD3PDMaker/python/JSD3PD.py @@ -1,4 +1,6 @@ -# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration +# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration + +from __future__ import print_function from JetD3PDMaker.JetD3PDObject import getJetD3PDObject from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags @@ -100,7 +102,7 @@ def JSD3PD(jetsToWrite, alg): jsD3PD=None for val in myJSD3PD: if val[0]==jetsToWrite: - print "using existing JSD3PD" + print ("using existing JSD3PD") jsD3PD=val[1] break diff --git a/PhysicsAnalysis/D3PDMaker/PhysicsD3PDMaker/python/METRefGetter_newplup.py b/PhysicsAnalysis/D3PDMaker/PhysicsD3PDMaker/python/METRefGetter_newplup.py index e1f53fa2c0b..b664d47afbf 100644 --- a/PhysicsAnalysis/D3PDMaker/PhysicsD3PDMaker/python/METRefGetter_newplup.py +++ b/PhysicsAnalysis/D3PDMaker/PhysicsD3PDMaker/python/METRefGetter_newplup.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 ############################################################################################## # @@ -9,6 +9,8 @@ # ############################################################################################## +from __future__ import print_function + from AthenaCommon.SystemOfUnits import * # loads MeV etc... from AthenaCommon.Constants import * # Loads DEBUG INFO etc.. from AthenaCommon.Logging import logging # loads logger @@ -173,7 +175,7 @@ class METRefGetter_newplup ( Configured ): theMETRefAlgMu.UseCells = True except: mlog.error("could not import MissingET.METRefAlg") - print traceback.format_exc() + mlog.error (traceback.format_exc()) return False #------------------------------------------------------------------------------------------------ # configure the tools: METRefinedEleTool => calibrator Tool for ATLFASTII @@ -199,8 +201,8 @@ class METRefGetter_newplup ( Configured ): theMETRefinedEleTool.CalibToolName = 'H1WeightToolCSC12Generic/'+ calibtool_name theMETRefinedEleTool.BackNavigationTo = "Cell" # to "Cell" theMETRefinedEleTool.MissingETOutKey = "MET_RefEle"+self.suffix - print "******************* key = "+theMETRefinedEleTool.MissingETOutKey - print "******************* key2 = "+theMETRefinedEleTool.MissingETOutKey + print ("******************* key = "+theMETRefinedEleTool.MissingETOutKey) + print ("******************* key2 = "+theMETRefinedEleTool.MissingETOutKey) #----------------- from MissingET.MissingETConf import METClusterResolverTool theMETEleResolver = METClusterResolverTool("EleResolve"+self.suffix) @@ -236,7 +238,7 @@ class METRefGetter_newplup ( Configured ): except: mlog.error("could not get handle to METRefinedEleTool Quit") - print traceback.format_exc() + mlog.error (traceback.format_exc()) return False # add cellcalibtool @@ -289,7 +291,7 @@ class METRefGetter_newplup ( Configured ): except: mlog.error("could not get handle to METRefinedTauTool Quit") - print traceback.format_exc() + mlog.error (traceback.format_exc()) return False # add cellcalibtool @@ -353,7 +355,7 @@ class METRefGetter_newplup ( Configured ): theMETRefinedJetTool.CalibToolName = 'H1WeightToolCSC12Generic/'+ calibtool_name except: mlog.error("could not get handle to METRefinedJetTool Quit") - print traceback.format_exc() + mlog.error (traceback.format_exc()) return False # add cellcalibtool @@ -409,7 +411,7 @@ class METRefGetter_newplup ( Configured ): theMETSoftJetsTool.CalibToolName = 'H1WeightToolCSC12Generic/'+ calibtool_name except: mlog.error("could not get handle to METSoftJetsTool Quit") - print traceback.format_exc() + mlog.error (traceback.format_exc()) return False # add cellcalibtool @@ -462,7 +464,7 @@ class METRefGetter_newplup ( Configured ): theMETRefAlg += theMETRefMuonSpectroTool except: mlog.error("could not get handle to METRefinedMuonTool Quit") - print traceback.format_exc() + mlog.error (traceback.format_exc()) return False except: mlog.error("could not import DetFlags") @@ -498,7 +500,7 @@ class METRefGetter_newplup ( Configured ): except: mlog.error("could not get handle to METRefinedClusterTool Quit") - print traceback.format_exc() + mlog.error (traceback.format_exc()) return False # add cellcalibtool @@ -531,7 +533,7 @@ class METRefGetter_newplup ( Configured ): except: mlog.error("could not get handle to METRefinedClusterTool Quit") - print traceback.format_exc() + mlog.error (traceback.format_exc()) return False # add cellcalibtool @@ -563,7 +565,7 @@ class METRefGetter_newplup ( Configured ): except: mlog.error("could not get handle to METRefinedClusterTool Quit") - print traceback.format_exc() + mlog.error (traceback.format_exc()) return False # add cellcalibtool @@ -624,7 +626,7 @@ class METRefGetter_newplup ( Configured ): except: mlog.error("could not get handle to METMuonTool Quit") - print traceback.format_exc() + mlog.error (traceback.format_exc()) return False # add the METMuonTool to list of tools @@ -658,7 +660,7 @@ class METRefGetter_newplup ( Configured ): theMETAlg=METAlg("METAlg"+self.suffix) except: mlog.error("could not import MissingET.METAlg") - print traceback.format_exc() + mlog.error(traceback.format_exc()) return False #------------------------------------------------------------------------------------------------ try: @@ -690,7 +692,7 @@ class METRefGetter_newplup ( Configured ): theMETAlg += theMETCryoTopoTool except: mlog.error("could not get handle to METCryoTopoTool Quit") - print traceback.format_exc() + mlog.error(traceback.format_exc()) return False #------------------------------------------------------------------------------------------------ @@ -778,7 +780,7 @@ class METRefGetter_newplup ( Configured ): except: mlog.error("could not get handle to METRefFinal Quit") - print traceback.format_exc() + mlog.error(traceback.format_exc()) return False # add METFinalTool to list of tools diff --git a/PhysicsAnalysis/D3PDMaker/PhysicsD3PDMaker/share/MyJetMake.py b/PhysicsAnalysis/D3PDMaker/PhysicsD3PDMaker/share/MyJetMake.py index a7a1c910375..82216e505f8 100644 --- a/PhysicsAnalysis/D3PDMaker/PhysicsD3PDMaker/share/MyJetMake.py +++ b/PhysicsAnalysis/D3PDMaker/PhysicsD3PDMaker/share/MyJetMake.py @@ -13,10 +13,8 @@ seq = AlgSequence() if rec.doTruth(): # Needed for release 15 AntiKt6 truth jets # make_StandardJetGetter('AntiKt', 0.6, 'Truth') - print "jason" import D3PDMakerCoreComps from D3PDMakerCoreComps.resolveSGKey import testSGKey - print testSGKey ('JetCollection', 'AntiKt6TruthJets') if not testSGKey ('JetCollection', 'AntiKt6TruthJets'): make_StandardJetGetter('AntiKt', 0.6, 'Truth') -- GitLab