Skip to content

Commit

Permalink
Merge pull request #23900 from davidlange6/printMig_180721T4_CalibCal…
Browse files Browse the repository at this point in the history
…orimetry_CaloMiscalibTools

Print function migration for CalibCalorimetry_CaloMiscalibTools
  • Loading branch information
cmsbuild committed Jul 22, 2018
2 parents 17e33e9 + 1048444 commit 0e35371
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 18 deletions.
@@ -1,4 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function
import commands,string,time,thread,random,math,sys

#global variables
Expand Down Expand Up @@ -75,16 +76,16 @@ def miscalib(lumi,endcap,z,etaindex,phiindex,randval):

#main
if len(sys.argv)==1:
print 'Usage: '+sys.argv[0]+' <barrel|endcap> <lumi> <filename> [MINRES=0.02] [SEED=random]'
print ' put lumi=0 for precalibration values (random at MINRES)'
print('Usage: '+sys.argv[0]+' <barrel|endcap> <lumi> <filename> [MINRES=0.02] [SEED=random]')
print(' put lumi=0 for precalibration values (random at MINRES)')
sys.exit(1)

if sys.argv[1]=='barrel':
endcap=0
elif sys.argv[1]=='endcap':
endcap=1
else:
print 'please specify one of <barrel|endcap>'
print('please specify one of <barrel|endcap>')
sys.exit(1)

if endcap==1:
Expand All @@ -109,19 +110,19 @@ def miscalib(lumi,endcap,z,etaindex,phiindex,randval):
lumi=string.atof(sys.argv[2])

if lumi<0:
print 'lumi = '+str(lumi)+' not valid'
print('lumi = '+str(lumi)+' not valid')
sys.exit(1)

fileout=sys.argv[3]

if len(sys.argv)>=5:
MINRES=string.atof(sys.argv[4])

print 'Using minimal resolution: '+str(MINRES)
print('Using minimal resolution: '+str(MINRES))

if len(sys.argv)>=6:
SEED=string.atoi(sys.argv[5])
print 'Using fixed seed for random generation: '+str(SEED)
print('Using fixed seed for random generation: '+str(SEED))
random.seed(SEED)

# now open file
Expand Down Expand Up @@ -188,7 +189,7 @@ def miscalib(lumi,endcap,z,etaindex,phiindex,randval):
xmlfile.write(' </EcalEndcap>\n')
xmlfile.write('</CalibrationConstants>\n')
xmlfile.close()
print 'File '+fileout+' written with '+str(count)+' lines'
print('File '+fileout+' written with '+str(count)+' lines')
#print miscalib(5,0,1,85,1,0)
#print miscalib(5,1,-1,10,1,0)
#print miscalib(5,1,-1,10,1,1)
Expand Down
23 changes: 12 additions & 11 deletions CalibCalorimetry/CaloMiscalibTools/test/make_miscalibration.py
@@ -1,4 +1,5 @@
#!/usr/bin/env python
from __future__ import print_function
import commands,string,time,thread,random,math,sys

#global variables
Expand Down Expand Up @@ -129,13 +130,13 @@ def miscalibhcal(lumi,det,etaindex,phiindex,depth,randval):
else:
return 0.02
else:
print 'lumi must be 0, 1 or 10'
print('lumi must be 0, 1 or 10')


#main
if len(sys.argv)==1:
print 'Usage: '+sys.argv[0]+' <ecalbarrel|ecalendcap|HCAL> <lumi> <filename> <validcell for hcal> [MINRES=0.02] [SEED=random]'
print ' put lumi=0 for precalibration values (CSA07)'
print('Usage: '+sys.argv[0]+' <ecalbarrel|ecalendcap|HCAL> <lumi> <filename> <validcell for hcal> [MINRES=0.02] [SEED=random]')
print(' put lumi=0 for precalibration values (CSA07)')
sys.exit(1)

ecalbarrel=0
Expand All @@ -151,13 +152,13 @@ def miscalibhcal(lumi,det,etaindex,phiindex,depth,randval):
elif sys.argv[1]=='HCAL':
hcal=1
else:
print 'please specify one of <barrel|endcap|HCAL>'
print('please specify one of <barrel|endcap|HCAL>')
sys.exit(1)

lumi=string.atof(sys.argv[2])

if lumi<0:
print 'lumi = '+str(lumi)+' not valid'
print('lumi = '+str(lumi)+' not valid')
sys.exit(1)

fileout=sys.argv[3]
Expand Down Expand Up @@ -193,7 +194,7 @@ def miscalibhcal(lumi,det,etaindex,phiindex,depth,randval):
hcalcells=hcalcells+1

hcalcell.close()
print 'Read ',hcalcells,' valid cells for hcal'
print('Read ',hcalcells,' valid cells for hcal')
# read non existing cells file, not needed anymore
# necell=open('non_existing_cell_endcap','r')

Expand All @@ -213,11 +214,11 @@ def miscalibhcal(lumi,det,etaindex,phiindex,depth,randval):
MINRES=string.atof(sys.argv[5])

if (hcal==0) or (lumi==0):
print 'Using minimal resolution: '+str(MINRES)
print('Using minimal resolution: '+str(MINRES))

if len(sys.argv)>=7:
SEED=string.atoi(sys.argv[6])
print 'Using fixed seed for random generation: '+str(SEED)
print('Using fixed seed for random generation: '+str(SEED))
random.seed(SEED)

# now open file
Expand Down Expand Up @@ -350,9 +351,9 @@ def miscalibhcal(lumi,det,etaindex,phiindex,depth,randval):
xmlfile.close()
xmlfileinv.close()
txtfile.close()
print 'File '+fileout+'.xml'+' written with '+str(count)+' lines'
print 'File inv_'+fileout+'.xml'+' written with '+str(count)+' lines'
print 'File '+fileout+'.txt'+' written with '+str(count)+' lines'
print('File '+fileout+'.xml'+' written with '+str(count)+' lines')
print('File inv_'+fileout+'.xml'+' written with '+str(count)+' lines')
print('File '+fileout+'.txt'+' written with '+str(count)+' lines')
#print miscalibecal(5,0,1,85,1,0)
#print miscalibecal(5,1,-1,10,1,0)
#print miscalibecal(5,1,-1,10,1,1)
Expand Down

0 comments on commit 0e35371

Please sign in to comment.