Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print function migration for DQMOffline_JetMET #23892

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 7 additions & 6 deletions DQMOffline/JetMET/test/DDSearchCLI.py
Expand Up @@ -7,6 +7,7 @@
"""
DBS data discovery command line interface
"""
from __future__ import print_function

import httplib, urllib, urllib2, types, string, os, sys
from optparse import OptionParser
Expand Down Expand Up @@ -55,7 +56,7 @@ def sendMessage(host,port,dbsInst,userInput,page,limit,xml=0,case='on',iface='db
input=urllib.quote(userInput)
if debug:
httplib.HTTPConnection.debuglevel = 1
print "Contact",host,port
print("Contact",host,port)
_port=443
if host.find("http://")!=-1:
_port=80
Expand Down Expand Up @@ -87,16 +88,16 @@ def sendMessage(host,port,dbsInst,userInput,page,limit,xml=0,case='on',iface='db
headers = { 'User-Agent':agent, 'Accept':ctypes}
data = urllib.urlencode(params,doseq=True)
if debug:
print url,data,headers
print(url,data,headers)
req = urllib2.Request(url, data, headers)
data = ""
try:
response = urllib2.urlopen(req)
data = response.read()
except urllib2.HTTPError as e:
if e.code==201:
print e.headers
print e.msg
print(e.headers)
print(e.msg)
pass
else:
raise e
Expand Down Expand Up @@ -127,7 +128,7 @@ def sendMessage(host,port,dbsInst,userInput,page,limit,xml=0,case='on',iface='db
else:
input=opts.input
else:
print "\nUsage: %s --help"%sys.argv[0]
print("\nUsage: %s --help"%sys.argv[0])
sys.exit(0)
result = sendMessage(host,port,dbsInst,input,opts.page,opts.limit,opts.xml,opts.case,opts.iface,opts.details,opts.cff,opts.verbose)
print result
print(result)
33 changes: 17 additions & 16 deletions DQMOffline/JetMET/test/publish/make_html_output.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from __future__ import print_function
import ROOT
import sys,os,string,errno,shutil
import code
Expand All @@ -15,11 +16,11 @@
inputdir=sys.argv[1]
outputdir=sys.argv[2]

print str(inputdir)
print str(outputdir)
print(str(inputdir))
print(str(outputdir))

files = os.listdir(inputdir)
print files
print(files)

ROOT.gROOT.ProcessLine(".L ./plot_METDQM.C")
ROOT.gROOT.ProcessLine(".L ./plot_jets_data_vs_MC.C")
Expand Down Expand Up @@ -76,10 +77,10 @@
destination = os.path.join(outputdir)
try: shutil.copy2(source,destination)
except IOError as err:
print "cannot copy:\n%s\n to\n%s"%(source,destination)
print "I/O error(%d): %s"%(err.errno,err.strerror)
print("cannot copy:\n%s\n to\n%s"%(source,destination))
print("I/O error(%d): %s"%(err.errno,err.strerror))
else:
print "will not copy refernce root files to afs due to space restrictions"
print("will not copy refernce root files to afs due to space restrictions")
files.remove(file)


Expand Down Expand Up @@ -161,43 +162,43 @@
plotdirectory = "DQMData/Run %s/JetMET/Run summary/MET/%s"%(run,test)
if (rootfile.GetDirectory(plotdirectory)):
metcmd = "plot_METDQM(\"%s\",\"%s\",%d,\"%s\",\"%s\")"%(infilename,reference,int(float(run)),outputdir,test)
print metcmd
print(metcmd)
ROOT.gROOT.ProcessLine(metcmd)
else :
print "Directory "+plotdirectory+" does not exist, not running creating plots."
print("Directory "+plotdirectory+" does not exist, not running creating plots.")

# run the jet comparison plots
try: os.makedirs(os.path.join(outputdir,run,"JetDQM","CaloJetAntiKt"))
except OSError as err:
if err.errno != errno.EEXIST: raise

jetcmd = "plot_jets_data_vs_MC(\"%s\",\"%s\",%d,\"%s\")"%(infilename,reference,int(float(run)),outputdir)
print jetcmd
print(jetcmd)
ROOT.gROOT.ProcessLine(jetcmd)
source = os.path.join(os.getcwd(),"result.root")
destination = os.path.join(outputdir,run,"JetDQM")
try: shutil.copy2(source,destination)
except IOError as err:
print "cannot copy:\n%s\n to\n%s"%(source,destination)
print "I/O error(%d): %s"%(err.errno,err.strerror)
print("cannot copy:\n%s\n to\n%s"%(source,destination))
print("I/O error(%d): %s"%(err.errno,err.strerror))


if (outputdir.find("afs")!=1):
source = os.path.join(inputdir,file)
destination = os.path.join(outputdir,run)
try: shutil.copy2(source,destination)
except IOError as err:
print "cannot copy:\n%s\n to\n%s"%(source,destination)
print "I/O error(%d): %s"%(err.errno,err.strerror)
print("cannot copy:\n%s\n to\n%s"%(source,destination))
print("I/O error(%d): %s"%(err.errno,err.strerror))
else:
print "will not copy source root files to afs due to space restrictions"
print("will not copy source root files to afs due to space restrictions")

source = os.path.join(os.getcwd(),"UFAV.html")
destination = os.path.join(outputdir,run)
try: shutil.copy2(source,destination)
except IOError as err:
print "cannot copy:\n%s\n to\n%s"%(source,destination)
print "I/O error(%d): %s"%(err.errno,err.strerror)
print("cannot copy:\n%s\n to\n%s"%(source,destination))
print("I/O error(%d): %s"%(err.errno,err.strerror))

rmscanvas.cd(1)
h_SumEt_rms.Draw("p")
Expand Down
19 changes: 10 additions & 9 deletions DQMOffline/JetMET/test/run_PromptAna33X.py
@@ -1,3 +1,4 @@
from __future__ import print_function
##-----
# Set job-specific inputs based on shell
# the following enviromental variables
Expand All @@ -16,35 +17,35 @@
#
# --- [cosmic sequence (default=True)?]
iscosmics = (os.environ.get('COSMIC_MODE','True'))
print 'iscosmics (default=True) = '+str(iscosmics)
print('iscosmics (default=True) = '+str(iscosmics))
#
# --- [name of job & output file (default=test)?]
jobname = (os.environ.get('JOB_NAME','test'))
print 'jobname (default=test) = '+str(jobname)
print('jobname (default=test) = '+str(jobname))
#
# --- [number of events (default=1000)]
nevents = int(os.environ.get('NEVENTS','1000'))
print 'nevents (default=1000) = '+str(nevents)
print('nevents (default=1000) = '+str(nevents))
#
# --- [turn on all histograms (default=True)?]
allhist = (os.environ.get('ALL_HISTS','True'))
print 'allhist (default=True) = '+str(allhist)
print('allhist (default=True) = '+str(allhist))
#
#--- [read list of input files from a text file? or not (default=False)]
read_from_file = (os.environ.get('READ_LIST_FROM_FILE','False'))
print 'read list of input files from a text file (default=False) = '+str(read_from_file)
print('read list of input files from a text file (default=False) = '+str(read_from_file))
#
#--- [trigger set (default=HLT)]
trigger_set = (os.environ.get('TRIGGER_SET','HLT'))
print 'trigger set name (default=HLT) = '+str(trigger_set)
print('trigger set name (default=HLT) = '+str(trigger_set))
#
#--- [define list of input files]
inputfiles = []
if read_from_file=="True":
#--- [name of the text file (default=inputfile_list_default.txt)]
filename = (os.environ.get('INPUTFILES_LIST','inputfile_list_default.txt'))
file=open(filename)
print file.read()
print(file.read())
f = open(filename)
try:
for line in f:
Expand All @@ -57,8 +58,8 @@
#'/store/data/Commissioning09/MinimumBias/RECO/v4/000/102/347/F85D1BC6-A06A-DE11-BDF8-0019B9F581C9.root').split(",")
#'/store/data/CRAFT09/Calo/RECO/v1/000/112/220/F0B768A4-5E93-DE11-B222-000423D94524.root').split(",")

print 'List of input files'
print inputfiles
print('List of input files')
print(inputfiles)
#-----

#
Expand Down
19 changes: 10 additions & 9 deletions DQMOffline/JetMET/test/run_PromptAnaHI.py
@@ -1,3 +1,4 @@
from __future__ import print_function
##-----
# Set job-specific inputs based on shell
# the following enviromental variables
Expand All @@ -16,35 +17,35 @@
#
# --- [cosmic sequence (default=True)?]
iscosmics = (os.environ.get('COSMIC_MODE','False'))
print 'iscosmics (default=True) = '+str(iscosmics)
print('iscosmics (default=True) = '+str(iscosmics))
#
# --- [name of job & output file (default=test)?]
jobname = (os.environ.get('JOB_NAME','test'))
print 'jobname (default=test) = '+str(jobname)
print('jobname (default=test) = '+str(jobname))
#
# --- [number of events (default=1000)]
nevents = int(os.environ.get('NEVENTS','1000'))
print 'nevents (default=1000) = '+str(nevents)
print('nevents (default=1000) = '+str(nevents))
#
# --- [turn on all histograms (default=True)?]
allhist = (os.environ.get('ALL_HISTS','True'))
print 'allhist (default=True) = '+str(allhist)
print('allhist (default=True) = '+str(allhist))
#
#--- [read list of input files from a text file? or not (default=False)]
read_from_file = (os.environ.get('READ_LIST_FROM_FILE','True'))
print 'read list of input files from a text file (default=False) = '+str(read_from_file)
print('read list of input files from a text file (default=False) = '+str(read_from_file))
#
#--- [trigger set (default=HLT)]
trigger_set = (os.environ.get('TRIGGER_SET','HLT'))
print 'trigger set name (default=HLT) = '+str(trigger_set)
print('trigger set name (default=HLT) = '+str(trigger_set))
#
#--- [define list of input files]
inputfiles = []
if read_from_file=="True":
#--- [name of the text file (default=inputfile_list_default.txt)]
filename = (os.environ.get('INPUTFILES_LIST','inputfile_list_default.txt'))
file=open(filename)
print file.read()
print(file.read())
f = open(filename)
try:
for line in f:
Expand All @@ -57,8 +58,8 @@
#'/store/data/Commissioning09/MinimumBias/RECO/v4/000/102/347/F85D1BC6-A06A-DE11-BDF8-0019B9F581C9.root').split(",")
#'/store/data/CRAFT09/Calo/RECO/v1/000/112/220/F0B768A4-5E93-DE11-B222-000423D94524.root').split(",")

print 'List of input files'
print inputfiles
print('List of input files')
print(inputfiles)
#-----

#
Expand Down
11 changes: 6 additions & 5 deletions DQMOffline/JetMET/test/run_PromptAna_CAF.py
@@ -1,25 +1,26 @@
from __future__ import print_function
import os
import FWCore.ParameterSet.Config as cms

#
# --- [cosmic sequence (default=True)?]
iscosmics = 'False'
print 'iscosmics (default=True) = '+str(iscosmics)
print('iscosmics (default=True) = '+str(iscosmics))
# --- [name of job & output file (default=test)?]
jobname = 'test'
print 'jobname (default=test) = '+str(jobname)
print('jobname (default=test) = '+str(jobname))
#
# --- [number of events (default=1000)]
nevents = 1000
print 'nevents (default=1000) = '+str(nevents)
print('nevents (default=1000) = '+str(nevents))
#
# --- [turn on all histograms (default=True)?]
allhist = 'True'
print 'allhist (default=True) = '+str(allhist)
print('allhist (default=True) = '+str(allhist))
#
#--- [trigger set (default=HLT)]
trigger_set = 'HLT'
print 'trigger set name (default=HLT) = '+str(trigger_set)
print('trigger set name (default=HLT) = '+str(trigger_set))

#-----
process = cms.Process("test")
Expand Down
11 changes: 6 additions & 5 deletions DQMOffline/JetMET/test/run_PromptAna_CAF33x.py
@@ -1,25 +1,26 @@
from __future__ import print_function
import os
import FWCore.ParameterSet.Config as cms

#
# --- [cosmic sequence (default=True)?]
iscosmics = 'True'
print 'iscosmics (default=True) = '+str(iscosmics)
print('iscosmics (default=True) = '+str(iscosmics))
# --- [name of job & output file (default=test)?]
jobname = 'test'
print 'jobname (default=test) = '+str(jobname)
print('jobname (default=test) = '+str(jobname))
#
# --- [number of events (default=1000)]
nevents = 1000
print 'nevents (default=1000) = '+str(nevents)
print('nevents (default=1000) = '+str(nevents))
#
# --- [turn on all histograms (default=True)?]
allhist = 'True'
print 'allhist (default=True) = '+str(allhist)
print('allhist (default=True) = '+str(allhist))
#
#--- [trigger set (default=HLT)]
trigger_set = 'HLT'
print 'trigger set name (default=HLT) = '+str(trigger_set)
print('trigger set name (default=HLT) = '+str(trigger_set))

#-----
process = cms.Process("test")
Expand Down
19 changes: 10 additions & 9 deletions DQMOffline/JetMET/test/run_PromptAna_CRT.py
@@ -1,3 +1,4 @@
from __future__ import print_function

import os
import FWCore.ParameterSet.Config as cms
Expand All @@ -6,24 +7,24 @@

#--- [read list of input files from a text file? or not (default=False)]
read_from_file = (os.environ.get('READ_LIST_FROM_FILE','False'))
print 'read list of input files from a text file (default=False) = '+str(read_from_file)
print('read list of input files from a text file (default=False) = '+str(read_from_file))
#
#
# --- [do harvesting (default=True)? or read in histogram files]
harvesting = (os.environ.get('HARVESTING',True))
print 'harvesting (default=True) = '+str(harvesting)
print('harvesting (default=True) = '+str(harvesting))
#
# --- [reference histogram (default=jetMETMonitoring_test.root)]
reference_histogram_file = (os.environ.get('REFERENCE_HISTOGRAM_FILE','jetMETMonitoring_test.root'))
print 'reference_histogram_file = '+str(reference_histogram_file)
print('reference_histogram_file = '+str(reference_histogram_file))
#
# --- [input file(s) for harvesting/certification (default=reco_DQM_test.root)]
input_files = []
if read_from_file=="True":
#--- [name of the text file (default=inputfile_list_default.txt)]
filename = (os.environ.get('INPUTFILES_LIST','inputfile_list_default.txt'))
file=open(filename)
print file.read()
print(file.read())
f = open(filename)
try:
for line in f:
Expand All @@ -32,16 +33,16 @@
f.close()
else:
input_root_files = os.environ.get('INPUTEDMFILES','file:reco_DQM_test.root').split(",")
print 'input_root_files = '+str(input_root_files)
print
print('input_root_files = '+str(input_root_files))
print()

if harvesting:
for file in input_root_files: # Second Example
input_files.append(str(file))
else:
test_histogram_file = os.environ.get('TEST_HISTOGRAM_FILE','jetMETMonitoring_test.root')
print 'test_histogram_file = '+str(test_histogram_file)
print
print('test_histogram_file = '+str(test_histogram_file))
print()



Expand Down Expand Up @@ -91,7 +92,7 @@
process.load("DQMOffline.JetMET.dataCertificationJetMET_cff")

if harvesting:
print
print()
else:
process.dataCertificationJetMET.fileName = cms.untracked.string(test_histogram_file)

Expand Down