diff --git a/DaVinciTests/tests/options/CommonParticles/DVTestStandardIntermediate.py b/DaVinciTests/tests/options/CommonParticles/DVTestStandardIntermediate.py index 4c217b8c4efe5e317d6c90315c801287263f704f..c67f93873e5d8742e57263e226f9553f0d69ae48 100644 --- a/DaVinciTests/tests/options/CommonParticles/DVTestStandardIntermediate.py +++ b/DaVinciTests/tests/options/CommonParticles/DVTestStandardIntermediate.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2000-2020 CERN for the benefit of the LHCb Collaboration # # # # This software is distributed under the terms of the GNU General Public # # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # @@ -16,6 +16,7 @@ # Author: Patrick Koppenburg <patrick.koppenburg@cern.ch> # ############################################################################## +from __future__ import print_function from DaVinci.Configuration import DaVinci from Gaudi.Configuration import * ############################################################################## @@ -24,8 +25,8 @@ from CommonParticles import StandardBasic from CommonParticles import StandardIntermediate Locations = [] -for a,b in StandardIntermediate.locations.iteritems(): - print "DVTestCommonParticles adding location", a +for a,b in StandardIntermediate.locations.items(): + print("DVTestCommonParticles adding location", a) Locations.append(a) from Configurables import CountParticles diff --git a/DaVinciTests/tests/options/CommonParticles/TestStandardIntermediateCuts.py b/DaVinciTests/tests/options/CommonParticles/TestStandardIntermediateCuts.py index d2dcc9abc2e9076e12da5dcb5da6f68fbe304cc0..79975acc70617ab3e59daba148b4e9e61f27c48e 100644 --- a/DaVinciTests/tests/options/CommonParticles/TestStandardIntermediateCuts.py +++ b/DaVinciTests/tests/options/CommonParticles/TestStandardIntermediateCuts.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2000-2020 CERN for the benefit of the LHCb Collaboration # # # # This software is distributed under the terms of the GNU General Public # # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # @@ -15,6 +15,7 @@ Author: Juan Palacios <palacios@physik.uzh.ch> """ ############################################################################## +from __future__ import print_function from DaVinci.Configuration import DaVinci from Gaudi.Configuration import * # @@ -23,8 +24,8 @@ from CommonParticles import StandardIntermediate List = [] -for a,b in StandardIntermediate.locations.iteritems(): - print "DVTestCommonParticles adding location", a +for a,b in StandardIntermediate.locations.items(): + print("DVTestCommonParticles adding location", a) List.append(b) # list of algorithms DaVinci( UserAlgorithms = List, diff --git a/DaVinciTests/tests/options/dtfdict.py b/DaVinciTests/tests/options/dtfdict.py index 8dbc713b9392abc16cb4a3724a096538477f7b79..00e8c8c343da371da7ffe89d4287853216cd5f94 100644 --- a/DaVinciTests/tests/options/dtfdict.py +++ b/DaVinciTests/tests/options/dtfdict.py @@ -1,6 +1,6 @@ #!/usr/bin/env python ############################################################################### -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2000-2020 CERN for the benefit of the LHCb Collaboration # # # # This software is distributed under the terms of the GNU General Public # # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # @@ -14,6 +14,7 @@ Test of the DFTDict module """ +from __future__ import print_function __author__ = "Davide Fazzini davide.fazzini@cern.ch" from Configurables import DaVinci @@ -70,7 +71,7 @@ sel = get_selection_sequence('Bd2JpsiKstarSel') seq.Members += [sel.sequence()] tuple_input = sel.outputLocation() -print "sequence test: passed" +print("sequence test: passed") # make a tuple tpl = DecayTreeTuple("Bd2JpsiKstar") @@ -99,7 +100,7 @@ DictTuple.Cons.Substitutions = { 'J/psi(1S) -> mu+ ^mu-' : 'e-', } -print "LoKi__Hybrid__Dict2Tuple test: passed" +print("LoKi__Hybrid__Dict2Tuple test: passed") # Add LoKiFunctors to the tool chain, # these functors will be applied to the refitted decay tree @@ -114,7 +115,7 @@ DictTuple.Cons.dict.Variables = { "Cons_PZ" : "PZ", } -print "LoKi__Hybrid__DictOfFunctors test: passed" +print("LoKi__Hybrid__DictOfFunctors test: passed") # add the tuple to the main sequence seq.Members += [tpl] diff --git a/DaVinciTests/tests/options/gpython_algs.py b/DaVinciTests/tests/options/gpython_algs.py index 57044c99da0ba6d590ee8d76bc8f5c21fa9341d8..e148019248eb77320e71d91a3eac4f01f1f2ce38 100755 --- a/DaVinciTests/tests/options/gpython_algs.py +++ b/DaVinciTests/tests/options/gpython_algs.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- ############################################################################### -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2000-2020 CERN for the benefit of the LHCb Collaboration # # # # This software is distributed under the terms of the GNU General Public # # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # @@ -23,6 +23,7 @@ ## ## Configurables: ## +from __future__ import print_function from Configurables import DaVinci, MessageSvc dv = DaVinci( DataType = "Upgrade", @@ -78,18 +79,18 @@ for i in range(10) : gaudi.run(1) alg = gaudi.algorithm('KAONS') - print ' [%d] KAONS initialized? %s [counterintuitive]' % ( i , alg._ialg.isInitialized () ) - print ' [%d] KAONS executed? %s ' % ( i , isExecuted(alg) ) + print(' [%d] KAONS initialized? %s [counterintuitive]' % ( i , alg._ialg.isInitialized () )) + print(' [%d] KAONS executed? %s ' % ( i , isExecuted(alg) )) - print ' without fix in $LOKICORE/src/AlgFunctors.cpp following lines produce segmentation violation' + print(' without fix in $LOKICORE/src/AlgFunctors.cpp following lines produce segmentation violation') fun1 = ALG_EXECUTED ( mainseq ) fun2 = ALG_PASSED ( mainseq ) fun3 = ALG_ENABLED ( mainseq ) - print ' [%d] main sequence executed? %s ' % ( i , fun1() ) - print ' [%d] main sequence passed? %s ' % ( i , fun2() ) - print ' [%d] main sequence enabled? %s ' % ( i , fun3() ) + print(' [%d] main sequence executed? %s ' % ( i , fun1() )) + print(' [%d] main sequence passed? %s ' % ( i , fun2() )) + print(' [%d] main sequence enabled? %s ' % ( i , fun3() )) exit() diff --git a/Phys/DaVinci/python/DaVinci/Configuration.py b/Phys/DaVinci/python/DaVinci/Configuration.py index cdbf8e1ab40a8a95deb88f9a9f3b5f2a97bbd4f2..70150a3fd008861f0f0aaed2db16ad4fb2ab85a6 100644 --- a/Phys/DaVinci/python/DaVinci/Configuration.py +++ b/Phys/DaVinci/python/DaVinci/Configuration.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2000-2019 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2000-2020 CERN for the benefit of the LHCb Collaboration # # # # This software is distributed under the terms of the GNU General Public # # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # @@ -650,7 +650,7 @@ class DaVinci(LHCbConfigurableUser) : def _set_root_in_tes_ ( s , root ) : # if isinstance ( s , str ) : return - prps = s.getProperties().keys() + prps = set(s.getProperties()) if 'RootInTES' in prps : if not s.isPropertySet ( 'RootInTES' ) : log.info ( "Set RootInTES=%s for %s" % ( root , s.getName() ) ) diff --git a/Phys/Tesla/python/Tesla/Configuration.py b/Phys/Tesla/python/Tesla/Configuration.py index dcf677f53be677fac61e8fc92c031194cf6976c9..98efb0b66ea1d8203a669a6fef2f52ea6b6d3b78 100644 --- a/Phys/Tesla/python/Tesla/Configuration.py +++ b/Phys/Tesla/python/Tesla/Configuration.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2000-2019 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2000-2020 CERN for the benefit of the LHCb Collaboration # # # # This software is distributed under the terms of the GNU General Public # # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # @@ -8,6 +8,7 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### +from __future__ import print_function import logging as log import os import re @@ -518,14 +519,14 @@ class Tesla(LHCbConfigurableUser): raise ValueError("Multiple instances of type "+PRtype+" have been detected") trackTruthSeq = self._configureTrackTruth(assocpp,matchedTracks[0]) - print("Adding additional PR protoparticles for truth matching: "+matchedProtos[0]) + print(("Adding additional PR protoparticles for truth matching: "+matchedProtos[0])) assocpp.InputData += [ matchedProtos[0] ] ChargedProtoSeq.Members+=[trackTruthSeq] # Add container of merged long and downstream PersistReco PPs # TODO this should be in the list in the configuration file assocpp.InputData += ['Hlt2/Protos/Charged'] - print("Adding additional PR protoparticles for truth matching: "+assocpp.InputData[-1]) + print(("Adding additional PR protoparticles for truth matching: "+assocpp.InputData[-1])) trackTruthSeq = self._configureTrackTruth(assocpp, '/Event/Hlt2/TrackFitted/Charged') ChargedProtoSeq.Members += [trackTruthSeq] @@ -812,12 +813,12 @@ class Tesla(LHCbConfigurableUser): prescale = lines_dict.get('prescale', None) turboRepLoc="Turbo/DecReports"+stream if prescale: - print "Requested to prescale stream: "+stream + print("Requested to prescale stream: "+stream) # if line not in dictionary, give it a prescale of 1 for line in lines: if line not in prescale: prescale[line]=1.0 - print prescale + print(prescale) prescaleVersion = lines_dict.get('prescaleVersion', None) pscaler = TurboPrescaler("TurboPrescaler"+stream) pscaler.FilterOutput=True @@ -1209,7 +1210,7 @@ class Tesla(LHCbConfigurableUser): psandvs_packer = PackParticlesAndVertices( namer('TurboPacker'), InputStream=turbo_base, - VetoedContainers=prpacking_stream.inputs.values() + VetoedContainers=list(prpacking_stream.inputs.values()) ) packers.append(psandvs_packer) @@ -1380,7 +1381,7 @@ class Tesla(LHCbConfigurableUser): # Load the raw event format dictionaries RawEventFormatConf().loadIfRequired() - locs = RawEventLocationsToBanks(output_format).keys() + locs = list(RawEventLocationsToBanks(output_format)) return [os.path.join('/Event', l) + '#1' for l in locs] def __apply_configuration__(self): diff --git a/Phys/Tesla/tests/options/DV_Upgrade_PVs.py b/Phys/Tesla/tests/options/DV_Upgrade_PVs.py index aa887d28c1376bf11de41c9a4fdc8ead3459216f..f4e3197010e1b88ac92d7d8a9fa56576aafea002 100644 --- a/Phys/Tesla/tests/options/DV_Upgrade_PVs.py +++ b/Phys/Tesla/tests/options/DV_Upgrade_PVs.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2000-2020 CERN for the benefit of the LHCb Collaboration # # # # This software is distributed under the terms of the GNU General Public # # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # @@ -8,6 +8,7 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### +from __future__ import print_function from Gaudi.Configuration import * from LHCbKernel.Configuration import * from Configurables import GaudiSequencer,RawEventJuggler @@ -57,7 +58,7 @@ while True: gaudi.run(1) # if not tes['/Event/DAQ/RawEvent']: - print "End of file" + print("End of file") break # n=0 @@ -69,6 +70,6 @@ while True: continue if not tes[vertLoc]: - print tes["Hlt2/SelReports"] - print "ERROR: PVs have not been created" + print(tes["Hlt2/SelReports"]) + print("ERROR: PVs have not been created") break diff --git a/Phys/Tesla/tests/options/analyseAll.py b/Phys/Tesla/tests/options/analyseAll.py index 36c9416f03a8be46bb7422f901167451d944ff95..82aa0b342a67dccfdd56bb6d88df878a65b24a04 100644 --- a/Phys/Tesla/tests/options/analyseAll.py +++ b/Phys/Tesla/tests/options/analyseAll.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2000-2020 CERN for the benefit of the LHCb Collaboration # # # # This software is distributed under the terms of the GNU General Public # # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # @@ -10,12 +10,12 @@ ############################################################################### from subprocess import call import os -execfile(os.path.expandvars("$TESLAROOT/tests/options/streams.py")) +exec(compile(open(os.path.expandvars("$TESLAROOT/tests/options/streams.py"), "rb").read(), os.path.expandvars("$TESLAROOT/tests/options/streams.py"), 'exec')) exit_code = call(["python",os.path.expandvars("$TESLAROOT/tests/options/analyseInput.py")]) if exit_code: exit( exit_code ) -for stream,lines in turbo_streams.iteritems(): +for stream,lines in turbo_streams.items(): exit_code = call(["python",os.path.expandvars("$TESLAROOT/tests/options/analyseOutput.py"),stream]) if exit_code: exit( exit_code ) diff --git a/Phys/Tesla/tests/options/analyseInput.py b/Phys/Tesla/tests/options/analyseInput.py index f5d5c430b8d31dbe6664d1fe6548abf6b9593ed9..48fae6365e4859a3f93b09f8e302a5447410cb31 100644 --- a/Phys/Tesla/tests/options/analyseInput.py +++ b/Phys/Tesla/tests/options/analyseInput.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2000-2020 CERN for the benefit of the LHCb Collaboration # # # # This software is distributed under the terms of the GNU General Public # # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # @@ -8,6 +8,7 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### +from __future__ import print_function import sys import GaudiPython as GP @@ -46,11 +47,11 @@ appMgr = GP.AppMgr() evt = appMgr.evtsvc() import os -execfile(os.path.expandvars("$TESLAROOT/tests/options/streams.py")) +exec(compile(open(os.path.expandvars("$TESLAROOT/tests/options/streams.py"), "rb").read(), os.path.expandvars("$TESLAROOT/tests/options/streams.py"), 'exec')) decsPerStream = {} evtsPerStream = {} -for stream, lines in turbo_streams.iteritems(): +for stream, lines in turbo_streams.items(): decsPerStream[stream] = 0 evtsPerStream[stream] = 0 @@ -61,7 +62,7 @@ def routing_bits(rawevent): assert rbbanks.size() == 1 # stop if we have multiple rb banks d = rbbanks[rbbanks.size() - 1].data() # get last bank bits = "{:032b}{:032b}{:032b}".format(d[2], d[1], d[0]) - return map(int, reversed(bits)) + return [int(b) for b in reversed(bits)] # Number of events has to be the same as in TeslaStepsStreams.py for i in range(0,500): @@ -77,28 +78,28 @@ for i in range(0,500): if not evt["DAQ/ODIN"]: break if not evt["Hlt2/DecReports"]: - print "ERROR: Hlt2 dec report missing" + print("ERROR: Hlt2 dec report missing") continue else: found = {} - for stream, lines in turbo_streams.iteritems(): + for stream, lines in turbo_streams.items(): found[stream] = False - for name,dec in evt["Hlt2/DecReports"].decReports().iteritems(): + for name,dec in evt["Hlt2/DecReports"].decReports().items(): if name == 'Hlt2Global': continue if dec.decision()==1: - for stream, lines in turbo_streams.iteritems(): + for stream, lines in turbo_streams.items(): if name[:-8] in lines["lines"]: decsPerStream[stream] = decsPerStream[stream] + 1 found[stream] = True - for stream, lines in turbo_streams.iteritems(): + for stream, lines in turbo_streams.items(): if found[stream]: evtsPerStream[stream] = evtsPerStream[stream] + 1 -print decsPerStream -print evtsPerStream +print(decsPerStream) +print(evtsPerStream) import pickle pickle.dump( decsPerStream, open( "decsPerStream.p", "wb" ) ) pickle.dump( evtsPerStream, open( "evtsPerStream.p", "wb" ) ) diff --git a/Phys/Tesla/tests/options/analyseOutput.py b/Phys/Tesla/tests/options/analyseOutput.py index da8a9a5054b8a4bd91a6144deccab4681123af8d..151ed575af3b58a72d7242d22dd150e4c76bb771 100644 --- a/Phys/Tesla/tests/options/analyseOutput.py +++ b/Phys/Tesla/tests/options/analyseOutput.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2000-2020 CERN for the benefit of the LHCb Collaboration # # # # This software is distributed under the terms of the GNU General Public # # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # @@ -8,6 +8,7 @@ # granted to it by virtue of its status as an Intergovernmental Organization # # or submit itself to any jurisdiction. # ############################################################################### +from __future__ import print_function import sys import GaudiPython as GP @@ -54,14 +55,14 @@ appMgr = GP.AppMgr() evt = appMgr.evtsvc() import os import sys -execfile(os.path.expandvars("$TESLAROOT/tests/options/streams.py")) +exec(compile(open(os.path.expandvars("$TESLAROOT/tests/options/streams.py"), "rb").read(), os.path.expandvars("$TESLAROOT/tests/options/streams.py"), 'exec')) lines = turbo_streams[stream]["lines"] lines = [line+"Decision" for line in lines] -print lines +print(lines) decLocation = "Hlt2/DecReports" if turbo_streams[stream]["prescale"] != None: - print "Prescaled stream" + print("Prescaled stream") decLocation = turboReports @@ -77,11 +78,11 @@ for i in range(0,10000): if not evt["DAQ/ODIN"]: break if not evt[decLocation]: - print "ERROR: Hlt2 dec report missing. Location ", decLocation + print("ERROR: Hlt2 dec report missing. Location ", decLocation) continue else: allEvents = allEvents + 1 - for name,dec in evt[decLocation].decReports().iteritems(): + for name,dec in evt[decLocation].decReports().items(): if name == 'Hlt2Global': continue if dec.decision()==1: @@ -99,36 +100,36 @@ for i in range(0,10000): assert (inStream or not offStream), "ERROR: Should not contain events of other streams" -print "##### SUMMARY #####" -print "All Events ",allEvents, ", events in stream", streamEvents, ", postive line decisions ", streamDecs +print("##### SUMMARY #####") +print("All Events ",allEvents, ", events in stream", streamEvents, ", postive line decisions ", streamDecs) if allEvents != streamEvents: - print "ERROR: More events than should be in stream" + print("ERROR: More events than should be in stream") import pickle decsPerStream = pickle.load( open( "decsPerStream.p", "rb" ) ) evtsPerStream = pickle.load( open( "evtsPerStream.p", "rb" ) ) if turbo_streams[stream]["prescale"] == None: if decsPerStream[stream] != streamDecs: - print "ERROR : Number of input decision different to output" - print "Should be ", decsPerStream[stream] + print("ERROR : Number of input decision different to output") + print("Should be ", decsPerStream[stream]) assert False if evtsPerStream[stream] != streamEvents: - print "ERROR : Number of input events different to output" - print "Should be ", evntsPerStream[stream] + print("ERROR : Number of input events different to output") + print("Should be ", evntsPerStream[stream]) assert False else: - print "INFO : Stream contains prescaled lines" - print "Input decsions were ", decsPerStream[stream] - print "Effective prescaling : ", float(streamDecs)/decsPerStream[stream] + print("INFO : Stream contains prescaled lines") + print("Input decsions were ", decsPerStream[stream]) + print("Effective prescaling : ", float(streamDecs)/decsPerStream[stream]) if streamDecs >= decsPerStream[stream] : - print "ERROR : No prescaling applied" + print("ERROR : No prescaling applied") assert False - print "Input events were ", evtsPerStream[stream] - print "Effective prescaling : ", float(streamEvents)/evtsPerStream[stream] + print("Input events were ", evtsPerStream[stream]) + print("Effective prescaling : ", float(streamEvents)/evtsPerStream[stream]) if streamEvents >= evtsPerStream[stream] : - print "ERROR : No prescaling applied" + print("ERROR : No prescaling applied") assert False diff --git a/Phys/Tesla/tests/options/containers.py b/Phys/Tesla/tests/options/containers.py index cb711f7610bc9247332b6d25c05b82df10023de2..c825ba2f26c26ebe9d4c3411d2d4c21c4a4732f7 100644 --- a/Phys/Tesla/tests/options/containers.py +++ b/Phys/Tesla/tests/options/containers.py @@ -1,5 +1,5 @@ ############################################################################### -# (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration # +# (c) Copyright 2000-2020 CERN for the benefit of the LHCb Collaboration # # # # This software is distributed under the terms of the GNU General Public # # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". # @@ -11,6 +11,7 @@ # Options file for the QMTest to check that the containers have not # changed, either in values or in size. +from __future__ import print_function from Configurables import Tesla from Gaudi.Configuration import * @@ -99,7 +100,7 @@ while n<1000: # gaudi.run(1) if not tes['/Event/DAQ/RawEvent']: - print "End of file" + print("End of file") break # gaudi.executeEvent() @@ -136,15 +137,15 @@ meanSizeProto = i_protoTot / n_pop meanDLLK = meanDLLK / ( i_protoTot ) # print container sizes and mean of interested quantities -print "Particle Check ***********************************" -print "Average mass = "+str(round(meanMass,1)) -print "Average container size = "+str(round(meanSizePart,1)) -print "Track Check **************************************" -print "Average chi2 = "+str(round(meanTrackChi2,2)) -print "Average container size = "+str(round(meanSizeTrack,1)) -print "Vertex Check *************************************" -print "Average chi2 = "+str(round(meanVertexChi2,3)) -print "Average container size = "+str(round(meanSizeVert,1)) -print "Proto Check **************************************" -print "Average DLLK = "+str(round(meanDLLK,3)) -print "Average container size = "+str(round(meanSizeProto,1)) +print("Particle Check ***********************************") +print("Average mass = "+str(round(meanMass,1))) +print("Average container size = "+str(round(meanSizePart,1))) +print("Track Check **************************************") +print("Average chi2 = "+str(round(meanTrackChi2,2))) +print("Average container size = "+str(round(meanSizeTrack,1))) +print("Vertex Check *************************************") +print("Average chi2 = "+str(round(meanVertexChi2,3))) +print("Average container size = "+str(round(meanSizeVert,1))) +print("Proto Check **************************************") +print("Average DLLK = "+str(round(meanDLLK,3))) +print("Average container size = "+str(round(meanSizeProto,1)))