Skip to content

Commit

Permalink
python print migration Alignment/HIPAlignmentAlgorithm
Browse files Browse the repository at this point in the history
  • Loading branch information
davidlange6 committed Jul 25, 2018
1 parent e30b382 commit b256402
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 17 deletions.
@@ -1,3 +1,4 @@
from __future__ import print_function
from array import array
from copy import copy
from copy import deepcopy
Expand Down Expand Up @@ -174,7 +175,7 @@ def interpretOptions(self):
dtype=int(val)
self.datatype=dtype
except ValueError:
print "Data type is not an integer"
print("Data type is not an integer")
# Get lumi json file
elif key=="lumilist":
self.LumiJSON = LumiList.LumiList(filename = val).getVLuminosityBlockRange()
Expand All @@ -191,7 +192,7 @@ def interpretOptions(self):
fval=float(val)
self.overallweight=fval
except ValueError:
print "Overall weight is not a float"
print("Overall weight is not a float")
# Get uniform eta formula. Turns reweighting on
elif key=="uniformetaformula":
self.uniformetaformula=val
Expand Down
19 changes: 10 additions & 9 deletions Alignment/HIPAlignmentAlgorithm/scripts/batchHippy.py
@@ -1,5 +1,6 @@
#!/bin/env python

from __future__ import print_function
import sys
import imp
import copy
Expand Down Expand Up @@ -65,22 +66,22 @@ def __init__(self):
self.mkdir(self.opt.outputdir)

if self.opt.lstfile is None:
print "Unspecified lst file."
print("Unspecified lst file.")
sys.exit(1)
if self.opt.iovfile is None:
print "Unspecified IOV list."
print("Unspecified IOV list.")
sys.exit(1)

self.jobname = self.opt.outputdir.split('/')[-1]

if self.opt.redirectproxy:
print "Job {} is configured to redirect its Grid proxy.".format(self.jobname)
print("Job {} is configured to redirect its Grid proxy.".format(self.jobname))
self.redirectProxy()

if self.opt.sendto is not None:
self.opt.sendto.strip()
self.opt.sendto.replace(","," ")
print "Job {} is configured to notify {}.".format(self.jobname, self.opt.sendto)
print("Job {} is configured to notify {}.".format(self.jobname, self.opt.sendto))

# Set numerical flags for iterator_py
self.SDflag = 1 if self.opt.useSD else 0
Expand All @@ -91,11 +92,11 @@ def mkdir(self, dirname):
mkdir = 'mkdir -p %s' % dirname
ret = os.system( mkdir )
if( ret != 0 ):
print 'Please remove or rename directory: ', dirname
print('Please remove or rename directory: ', dirname)
sys.exit(4)

def notify(self, desc):
print desc
print(desc)
if self.opt.sendto is not None:
strcmd = "mail -s {1} {0} <<< \"{2}\"".format(self.opt.sendto, self.jobname, desc)
os.system(strcmd)
Expand Down Expand Up @@ -142,7 +143,7 @@ def submitJobs(self):
)
else:
if self.opt.dryRun > 0:
print 'Dry run option is enabled. Will not submit jobs to the queue'
print('Dry run option is enabled. Will not submit jobs to the queue')
jobcmd = 'scripts/iterator_py {} {} {} {} {} {} {} {} {} {}'.format(
self.opt.niter,
self.opt.outputdir,
Expand All @@ -162,13 +163,13 @@ def checkProxy(self):
try:
subprocess.check_call(["voms-proxy-info", "--exists"])
except subprocess.CalledProcessError:
print "Please initialize your proxy before submitting."
print("Please initialize your proxy before submitting.")
sys.exit(1)

def redirectProxy(self):
local_proxy = subprocess.check_output(["voms-proxy-info", "--path"]).strip()
new_proxy_path = os.path.join(self.opt.outputdir,".user_proxy")
print "Copying local proxy {} to the job directory as {}.".format(local_proxy,new_proxy_path)
print("Copying local proxy {} to the job directory as {}.".format(local_proxy,new_proxy_path))
shutil.copyfile(local_proxy, new_proxy_path)


Expand Down
13 changes: 7 additions & 6 deletions Alignment/HIPAlignmentAlgorithm/test/runTwoBodyDecayTest.py
@@ -1,3 +1,4 @@
from __future__ import print_function
import FWCore.ParameterSet.Config as cms

process = cms.Process("TBDtest")
Expand Down Expand Up @@ -131,7 +132,7 @@
strTBDConstrainer="TwoBodyDecayConstraint,trackParameters"

if strTBDConstrainer is not None:
print "strTBDConstrainer=",strTBDConstrainer
print("strTBDConstrainer=",strTBDConstrainer)

process.TrackRefitterSequence = TrackRefitterSequencer.getSequence(
process,
Expand Down Expand Up @@ -160,7 +161,7 @@
process.AlignmentTrackSelector.TwoBodyDecaySelector.maxXMass = 100.0


print process.TrackRefitterSequence
print(process.TrackRefitterSequence)
subproc=[
"offlineBeamSpot",
"HighPurityTrackSelector",
Expand All @@ -175,16 +176,16 @@
moduleSum=None
for sp in subproc:
if hasattr(process, sp):
print "\n\tAttributes for process.{}".format(sp)
print("\n\tAttributes for process.{}".format(sp))
if moduleSum is None:
moduleSum=getattr(process,sp)
else:
moduleSum+=getattr(process,sp)
for v in vars(getattr(process,sp)):
print v,":",getattr(getattr(process,sp),v)
print(v,":",getattr(getattr(process,sp),v))

process.TrackRefitterSequence = cms.Sequence(moduleSum)
print "Final process path:",process.TrackRefitterSequence
print("Final process path:",process.TrackRefitterSequence)
process.p = cms.Path(process.TrackRefitterSequence)


Expand All @@ -193,7 +194,7 @@
TAG = TAG + "_" + strflagopts
TAG = TAG.replace(':','_')
TAG = TAG.strip()
print "Output file:","analyzed_{0}.root".format(TAG)
print("Output file:","analyzed_{0}.root".format(TAG))
process.Analyzer = cms.EDAnalyzer(
"HIPTwoBodyDecayAnalyzer",
alcarecotracks = cms.InputTag(strtrackcollname),
Expand Down

0 comments on commit b256402

Please sign in to comment.