File indexing completed on 2024-04-06 12:33:19
0001
0002
0003
0004
0005 from __future__ import print_function
0006 from builtins import range
0007 import time
0008 import random
0009 from Validation.RecoTau.ValidationOptions_cff import *
0010
0011 options.parseArguments()
0012 checkOptionsForBadInput()
0013
0014
0015 if not CMSSWEnvironmentIsCurrent():
0016 print("CMSSW_BASE points to a different directory, please rerun cmsenv!")
0017 sys.exit()
0018
0019 if options.nJobs == 0:
0020 print("Must specify nJobs > 0. Run 'python3 LXBatchValidation.py help' for options")
0021 sys.exit()
0022
0023 if options.maxEvents == -1 and options.nJobs > 1:
0024 print("Please use maxEvents to specify the number of events to process per job.")
0025 sys.exit()
0026
0027
0028 if options.writeEDMFile != "":
0029 if options.copyToCastorDir == "<home>":
0030 options.copyToCastorDir = "/castor/cern.ch/user/%s/%s/" % (os.environ["LOGNAME"][0], os.environ["LOGNAME"])
0031 print("Setting castor directory to your home @ %s" % options.copyToCastorDir)
0032
0033 if options.copyToCastorDir != "":
0034 checkCastor = os.system("nsls %s" % options.copyToCastorDir)
0035 if checkCastor:
0036 print("Error: castor reports an error when checking the supplied castor location: ", options.copyToCastorDir)
0037 sys.exit()
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057 print("")
0058 print("I'm going to submit %i %s jobs, each with %i events, for a total of %i events" % (options.nJobs, options.eventType, options.maxEvents, options.nJobs*options.maxEvents))
0059
0060 if options.writeEDMFile != "":
0061 print("EDM files with the prefix %s will be produced and stored in %s" % (options.writeEDMFile, castorLocation))
0062
0063 print("Hit Ctrl-c in the next 3 seconds to cancel...")
0064 try:
0065 time.sleep(2)
0066 except KeyboardInterrupt:
0067 print("Canceled, exiting.")
0068 sys.exit()
0069
0070
0071 setupCommands = "cd $PWD; scramv1 runtime -sh > tempEnvs_%i; source tempEnvs_%i; rm tempEnvs_%i; cd -;"
0072 cmsRunCommands = "cmsRun $PWD/RunValidation_cfg.py %s;" % returnOptionsString()
0073 cleanupCommands = ""
0074 if options.writeEDMFile != "":
0075 cleanupCommand += " rfcp *.root %s;" % options.copyToCastorDir
0076
0077 for iJob in range(0, options.nJobs):
0078 options.batchNumber = iJob
0079
0080
0081
0082 setupCommands = "export edmOutputDir=\$PWD; cd $PWD; scramv1 runtime -sh > tempEnvs_%s_%i; source tempEnvs_%s_%i; rm tempEnvs_%s_%i;" % (options.eventType, iJob, options.eventType, iJob, options.eventType, iJob)
0083 cmsRunCommand = "cmsRun RunValidation_cfg.py %s;" % returnOptionsString()
0084 cleanupCommand = ""
0085 if options.writeEDMFile != "":
0086 cleanupCommand += "cd -; rfcp *.root %s;" % options.copyToCastorDir
0087
0088 totalCommand = setupCommands + cmsRunCommand + cleanupCommand
0089 bsubCommand = "bsub -J %s_%i -q %s \"%s\"" % (options.eventType, iJob, options.lxbatchQueue, totalCommand)
0090
0091 os.system(bsubCommand)
0092