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