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 CalibTracker_SiStripChannelGain #23902

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
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from __future__ import print_function
import os,sys
import getopt
import commands
Expand All @@ -18,8 +19,8 @@ def numberOfEvents(file,mode):
rootfile.GetObject("gainCalibrationTree%s/tree"%mode,tree)
NEntries = tree.GetEntries()
rootfile.Close()
print file +' --> '+str(NEntries)
print "gainCalibrationTree%s/tree"%mode
print(file +' --> '+str(NEntries))
print("gainCalibrationTree%s/tree"%mode)
return NEntries


Expand Down Expand Up @@ -64,16 +65,16 @@ def numberOfEvents(file,mode):

DQM_dir = "AlCaReco/SiStripGains" if "AagBunch" not in opt.calMode else "AlCaReco/SiStripGainsAAG"

print
print
print "Gain payload computing configuration"
print " firstRun = " +str(firstRun)
print " lastRun = " +str(lastRun)
print " publish = " +str(publish)
print " usePCL = " +str(usePCL)
print " calMode = " + calMode
print " DQM_dir = " + DQM_dir
print
print()
print()
print("Gain payload computing configuration")
print(" firstRun = " +str(firstRun))
print(" lastRun = " +str(lastRun))
print(" publish = " +str(publish))
print(" usePCL = " +str(usePCL))
print(" calMode = " + calMode)
print(" DQM_dir = " + DQM_dir)
print()


#go to parent directory = test directory
Expand All @@ -83,8 +84,8 @@ def numberOfEvents(file,mode):
if(firstRun<=0):
out = commands.getstatusoutput("ls /afs/cern.ch/cms/tracker/sistrvalidation/WWW/CalibrationValidation/ParticleGain/ | grep Run_ | tail -n 1");
firstRun = int(out[1].split('_')[3])+1
print "firstRun set to " +str(firstRun)
print
print("firstRun set to " +str(firstRun))
print()

initEnv='cd ' + os.getcwd() + ';'
initEnv+='source /afs/cern.ch/cms/cmsset_default.sh' + ';'
Expand All @@ -97,21 +98,21 @@ def numberOfEvents(file,mode):
FileList = ""

dataCertInfo = dataCert.get()
print "Loaded certification info. Last update : %s"%dataCertInfo["Last update"]
print("Loaded certification info. Last update : %s"%dataCertInfo["Last update"])

lastGoodRun = -1
if(usePCL==True):
print("Get the list of PCL output files from DAS")
print initEnv+"das_client.py --limit=9999 --query='dataset=%s'"%PCLDATASET
print(initEnv+"das_client.py --limit=9999 --query='dataset=%s'"%PCLDATASET)
dasOutput = commands.getstatusoutput(initEnv+"das_client.py --limit=9999 --query='dataset=%s'"%PCLDATASET)[1]
datasets = [ line for line in dasOutput.splitlines()
if not line.startswith('Showing') and 'SCRAM fatal' not in line and len(line)>0 ]
print datasets
print(datasets)
if len( datasets)==0 or 'Error' in " ".join(datasets):
print "Issues in gathering the dataset names, please check the command and the query"
print "***** DAS OUTPUT *****"
print dasOutput
print "**********************"
print("Issues in gathering the dataset names, please check the command and the query")
print("***** DAS OUTPUT *****")
print(dasOutput)
print("**********************")
exit (0)

runs = []
Expand All @@ -120,7 +121,7 @@ def numberOfEvents(file,mode):
"das_client.py --limit=9999 --query='run dataset=%s'"%dataset)[1].splitlines()
if not line.startswith('Showing') and 'SCRAM fatal' not in line and len(line)>0 ]
if len( runs )==0 or 'Error' in " ".join(datasets):
print "Issues in gathering the run numbers, please check the command and the query"
print("Issues in gathering the run numbers, please check the command and the query")
exit (0)
sorted( runs, key=lambda x: x[1])

Expand All @@ -129,7 +130,7 @@ def numberOfEvents(file,mode):
if(run<firstRun or run in runsToVeto):continue
if(lastRun>0 and run>lastRun):continue
if not dataCert.checkRun(run,dataCertInfo):
print "Skipping..."
print("Skipping...")
continue
lastGoodRun = run
sys.stdout.write( 'Gathering infos for RUN %i: ' % run )
Expand Down Expand Up @@ -168,7 +169,7 @@ def numberOfEvents(file,mode):
else:
print("Get the list of calibTree from castor (eos ls " + CALIBTREEPATH + ")")
calibTreeInfo = commands.getstatusoutput("eos ls -l "+CALIBTREEPATH)[1].split('\n');
print calibTreeInfo
print(calibTreeInfo)
# collect the list of runs and file size
# calibTreeInfo.split()[8] - file name
# calibTreeInfo.split()[4] - file size
Expand All @@ -186,10 +187,10 @@ def numberOfEvents(file,mode):
if(run<firstRun or run in runsToVeto):continue
if(lastRun>0 and run>lastRun):continue
if not dataCert.checkRun(run,dataCertInfo):
print "Skipping..."
print("Skipping...")
continue
if run<295310:
print "Skipping..."
print("Skipping...")
continue
lastGoodRun = run
NEvents = numberOfEvents("root://eoscms//eos/cms"+CALIBTREEPATH+'/'+info[0],calMode);
Expand All @@ -201,22 +202,22 @@ def numberOfEvents(file,mode):
if(automatic==True and NTotalEvents >= maxNEvents):break;

if lastGoodRun < 0:
print "No good run to process."
print("No good run to process.")
sys.exit()
if(lastRun<=0):lastRun = lastGoodRun

print "RunRange=[" + str(firstRun) + "," + str(lastRun) + "] --> NEvents=" + str(NTotalEvents/1000)+"K"
print("RunRange=[" + str(firstRun) + "," + str(lastRun) + "] --> NEvents=" + str(NTotalEvents/1000)+"K")

if(automatic==True and NTotalEvents<2e6): #ask at least 2M events to perform the calibration
print 'Not Enough events to run the calibration'
print('Not Enough events to run the calibration')
os.system('echo "Gain calibration postponed" | mail -s "Gain calibration postponed ('+str(firstRun)+' to '+str(lastRun)+') NEvents=' + str(NTotalEvents/1000)+'K" ' + mail)
exit(0);

name = "Run_"+str(firstRun)+"_to_"+str(lastRun)
if len(calMode)>0: name = name+"_"+calMode
if(usePCL==True): name = name+"_PCL"
else: name = name+"_CalibTree"
print name
print(name)

oldDirectory = "7TeVData"
newDirectory = "Data_"+name;
Expand All @@ -241,14 +242,14 @@ def numberOfEvents(file,mode):
job+= "\ncd %s; \npwd; \nls; \npython submitJob.py -f %s -l %s -p %s -P %s"%(os.getcwd(),firstRun,lastRun,usePCL,publish)
job+= " -m %s -s %s -a %s"%(calMode,scriptDir,automatic)

print "*** JOB : ***"
print job
print "cwd = %s"%(os.getcwd())
print("*** JOB : ***")
print(job)
print("cwd = %s"%(os.getcwd()))
with open("job.sh","w") as f:
f.write(job)
os.system("chmod +x job.sh")
submitCMD = 'bsub -q 2nd -J G2prod -R "type == SLC6_64 && pool > 30000" "job.sh"'
print submitCMD
print(submitCMD)
os.system(submitCMD)

#if(os.system("sh sequence.sh \"" + name + "\" \"" + calMode + "\" \"CMS Preliminary - Run " + str(firstRun) + " to " + str(lastRun) + "\"")!=0):
Expand Down
19 changes: 10 additions & 9 deletions CalibTracker/SiStripChannelGain/test/7TeVData/dataCert.py
@@ -1,3 +1,4 @@
from __future__ import print_function
import os,json,sys


Expand Down Expand Up @@ -58,17 +59,17 @@ def generateJSON():
os.system("wget http://vocms061.cern.ch/event_display/RunList/status.Collisions17.html -O .certif_temp.html > /dev/null 2>&1")

if not os.path.isfile(".certif_temp.html"):
print "Unable to download file"
print("Unable to download file")
return(1)

runQuality = getRunQuality()

if runQuality == {}:
print "Warning, no %s found. Creating new list."%JSON_NAME
print("Warning, no %s found. Creating new list."%JSON_NAME)

(title,table)=getHTMLtable()
if table==0:
print "Error, Unable to download run table."
print("Error, Unable to download run table.")
return(1)
runQuality["Last update"] = title[title.find("(")+1:title.find(")")]

Expand All @@ -92,7 +93,7 @@ def generateJSON():
comment=getComment(entry[colNumber])
runQuality[entry[0]]={"qual":entry[colNumber][:4],"comment":comment}
elif len(entry)>0:
print "Error, unrecognized line !"
print("Error, unrecognized line !")
return 1


Expand All @@ -105,22 +106,22 @@ def generateJSON():

def get():
if generateJSON()!=0:
print "ERROR, JSON file not updated... Loading old file."
print("ERROR, JSON file not updated... Loading old file.")

if not JSON_NAME in os.listdir("."):
print "ERROR, no JSON file available..."
print("ERROR, no JSON file available...")
return({})
else:
return getRunQuality()

def checkRun(runNumber, runQuality):
if not str(runNumber) in runQuality.keys():
print "WARNING : no certification info for run %s"%runNumber
print("WARNING : no certification info for run %s"%runNumber)
return(0)
else:
print "Data certification for run %s is %s"%(runNumber,runQuality[str(runNumber)]["qual"])
print("Data certification for run %s is %s"%(runNumber,runQuality[str(runNumber)]["qual"]))
if not "GOOD" in runQuality[str(runNumber)]["qual"]:
print "Reason : %s"%runQuality[str(runNumber)]["comment"]
print("Reason : %s"%runQuality[str(runNumber)]["comment"])
return("GOOD" in runQuality[str(runNumber)]["qual"])

if __name__ == "__main__":
Expand Down
3 changes: 2 additions & 1 deletion CalibTracker/SiStripChannelGain/test/7TeVData/submitJob.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from __future__ import print_function
import os,sys
import getopt
import commands
Expand Down Expand Up @@ -42,7 +43,7 @@
if len(calMode)>0: name = name+"_"+calMode
if(usePCL==True): name = name+"_PCL"
else: name = name+"_CalibTree"
print name
print(name)

automatic = opt.automatic
scriptDir = opt.scriptDir
Expand Down
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from __future__ import print_function
import urllib
import string
import os
Expand Down
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from __future__ import print_function
import urllib
import string
import os
Expand Down
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from __future__ import print_function
import urllib
import string
import os
Expand Down
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from __future__ import print_function
import urllib
import string
import os
Expand Down
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from __future__ import print_function
import urllib
import string
import os
Expand Down
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from __future__ import print_function
import urllib
import string
import os
Expand Down
3 changes: 2 additions & 1 deletion CalibTracker/SiStripChannelGain/test/PCL/Launch.py
@@ -1,5 +1,6 @@
#!/usr/bin/env python

from __future__ import print_function
import urllib
import string
import os
Expand Down Expand Up @@ -27,7 +28,7 @@
initEnv+='source /afs/cern.ch/cms/cmsset_default.sh' + ';'
initEnv+='eval `scramv1 runtime -sh`;'
commands.getstatusoutput('mkdir -p runs/'+str(r))
print "submitting jobs for run " + str(r)
print("submitting jobs for run " + str(r))
config_file=open('runs/'+str(r)+'/cmsDriver.sh','w')
config_file.write( initEnv + 'cmsDriver.py run'+str(r)+' --datatier ALCARECO --conditions auto:com10 -s ALCA:PromptCalibProdSiStripGains --eventcontent ALCARECO -n -1 --dasquery=\'file dataset=/MinimumBias/Run2012C-SiStripCalMinBias-v2/ALCARECO run='+str(r)+'\' --fileout file:run'+str(r)+'_out.root')
config_file.close()
Expand Down
@@ -1,3 +1,4 @@
from __future__ import print_function
# Auto generated configuration file
# with command line options: stepALCA --datatier ALCARECO --conditions auto:run2_data -s ALCA:PromptCalibProdSiStripGains --eventcontent ALCARECO -n 1000 --dasquery=file dataset=/ZeroBias/Run2016C-SiStripCalMinBias-18Apr2017-v1/ALCARECO run=276243 --no_exec
import FWCore.ParameterSet.Config as cms
Expand All @@ -16,21 +17,21 @@ def getFileNames_das_client():
jsondict = das_client.get_data(query)
status = jsondict['status']
if status != 'ok':
print "DAS query status: %s"%(status)
print("DAS query status: %s"%(status))
return files

data = jsondict['data']
viableDS = []
for element in data:
viableDS.append(element['dataset'][0]['name'])

print "Using Dataset:",viableDS[-1]
print("Using Dataset:",viableDS[-1])

query = "file dataset=%s site=T2_CH_CERN | grep file.name" % viableDS[-1]
jsondict = das_client.get_data(query)
status = jsondict['status']
if status != 'ok':
print "DAS query status: %s"%(status)
print("DAS query status: %s"%(status))
return files

mongo_query = jsondict['mongo_query']
Expand Down Expand Up @@ -82,7 +83,7 @@ def getFileNames_das_client():
INPUTFILES=getFileNames_das_client()

if len(INPUTFILES)==0:
print "** WARNING: ** According to a DAS query no suitable data for test is available. Skipping test"
print("** WARNING: ** According to a DAS query no suitable data for test is available. Skipping test")
os._exit(0)

myFiles = cms.untracked.vstring()
Expand Down