19 from optparse
import OptionParser
24 template = os.path.expandvars(
'$CMSSW_BASE/src/Alignment/CommonAlignmentProducer/data/AlCaHLTBitMon_cfg_template_py')
25 if os.path.exists(template):
27 template = os.path.expandvars(
'$CMSSW_RELEASE_BASE/src/Alignment/CommonAlignmentProducer/data/AlCaHLTBitMon_cfg_template_py')
28 if os.path.exists(template):
34 f = open(hltkeylistfile,
'r')
36 keylistlist.append(line.replace(
'\n',
''))
40 def parallelJobs(hltkeylistfile,jsonDir,globalTag,templateName,queue,cafsetup):
41 PWD = os.path.abspath(
'.')
43 if templateName ==
'default':
46 templateFile = os.path.abspath(os.path.expandvars(templateName))
48 tfile = open(templateFile,
'r')
49 template = tfile.read()
51 template = template.replace('%%%GLOBALTAG%%%', globalTag)
55 for keylist
in keylistlist:
57 configName =
'AlCaHLTBitMon_%d_cfg.py'%index
58 jobName =
'AlCaHLTBitMon_%d_job.csh'%index
59 jsonFile = os.path.abspath(
'%(dir)s/%(index)d.json' % {
'dir' : jsonDir,
'index' : index})
60 dataFile = os.path.abspath(
'%(dir)s/%(index)d.data' % {
'dir' : jsonDir,
'index' : index})
61 logFile =
'AlCaHLTBitMon_%d'%index
63 dfile = open(dataFile,
'r')
67 config = template.replace('%%%JSON%%%', jsonFile);
68 config = config.replace(
'%%%DATA%%%', data);
69 config = config.replace(
'%%%KEYNAME%%%', keylist);
70 config = config.replace(
'%%%LOGFILE%%%', logFile);
72 cfile = open(configName,
'w')
77 jfile = open(jobName,
'w')
78 jfile.write(
'#!/bin/tcsh\n\n')
80 jfile.write(
'source /afs/cern.ch/cms/caf/setup.csh\n\n')
82 jfile.write(
'cd $1\n\n')
83 jfile.write(
'eval `scramv1 run -csh`\n\n')
84 jfile.write(
'cmsRun %s\n\n'%configName)
85 jfile.write(
'cp %s.log $2'%logFile)
88 if os.path.exists(
'./%s'%keylist) ==
False:
89 os.system(
'mkdir ./%s'%keylist)
91 os.system(
'chmod u+x %s'%jobName)
93 os.system(
'bsub -q %(queue)s %(jobname)s %(pwd)s %(pwd)s/%(outdir)s' % {
'queue' : queue,
'jobname' : jobName,
'pwd' : PWD,
'outdir' : keylist})
98 parser = OptionParser()
100 parser.add_option(
"-k",
"--keylist",
101 dest=
"hltKeyListFile",
102 default=
"lista_key.txt",
103 help=
"text file with HLT keys")
105 parser.add_option(
"-j",
"--json",
107 help=
"directory with the corresponding json files")
109 parser.add_option(
"-g",
"--globalTag",
111 help=
"the global tag to use in the config files")
113 parser.add_option(
"-t",
"--template",
116 help=
"the template to use for the config files")
118 parser.add_option(
"-q",
"--queue",
121 help=
"the queue to use (default=cmscaf1nd)")
123 parser.add_option(
"-c",
"--cafsetup", action=
"store_true",
126 help=
"wether the caf setup is sourced in the scripts")
128 (options, args) = parser.parse_args()
130 if len(sys.argv) == 1:
131 print(
"\nUsage: %s --help"%sys.argv[0])
134 if str(options.hltKeyListFile) ==
'None':
135 print(
"Please provide a file with HLT keys")
138 if str(options.jsonDir) ==
'None':
139 print(
"Please provide a directory containing the json files")
142 if str(options.globalTag) ==
'None':
143 print(
"Please provide a global tag")
std::string print(const Track &, edm::Verbosity=edm::Concise)
Track print utility.
def getConfigTemplateFilename