10 from __future__
import print_function
20 from optparse
import OptionParser
25 template = os.path.expandvars(
'$CMSSW_BASE/src/Alignment/CommonAlignmentProducer/data/AlCaHLTBitMon_cfg_template_py')
26 if os.path.exists(template):
28 template = os.path.expandvars(
'$CMSSW_RELEASE_BASE/src/Alignment/CommonAlignmentProducer/data/AlCaHLTBitMon_cfg_template_py')
29 if os.path.exists(template):
35 f = open(hltkeylistfile,
'r')
37 keylistlist.append(line.replace(
'\n',
''))
41 def parallelJobs(hltkeylistfile,jsonDir,globalTag,templateName,queue,cafsetup):
42 PWD = os.path.abspath(
'.')
44 if templateName ==
'default':
47 templateFile = os.path.abspath(os.path.expandvars(templateName))
49 tfile = open(templateFile,
'r')
50 template = tfile.read()
52 template = template.replace('%%%GLOBALTAG%%%', globalTag)
56 for keylist
in keylistlist:
58 configName =
'AlCaHLTBitMon_%d_cfg.py'%index
59 jobName =
'AlCaHLTBitMon_%d_job.csh'%index
60 jsonFile = os.path.abspath(
'%(dir)s/%(index)d.json' % {
'dir' : jsonDir,
'index' : index})
61 dataFile = os.path.abspath(
'%(dir)s/%(index)d.data' % {
'dir' : jsonDir,
'index' : index})
62 logFile =
'AlCaHLTBitMon_%d'%index
64 dfile = open(dataFile,
'r')
68 config = template.replace('%%%JSON%%%', jsonFile);
69 config = config.replace(
'%%%DATA%%%', data);
70 config = config.replace(
'%%%KEYNAME%%%', keylist);
71 config = config.replace(
'%%%LOGFILE%%%', logFile);
73 cfile = open(configName,
'w')
78 jfile = open(jobName,
'w')
79 jfile.write(
'#!/bin/tcsh\n\n')
81 jfile.write(
'source /afs/cern.ch/cms/caf/setup.csh\n\n')
83 jfile.write(
'cd $1\n\n')
84 jfile.write(
'eval `scramv1 run -csh`\n\n')
85 jfile.write(
'cmsRun %s\n\n'%configName)
86 jfile.write(
'cp %s.log $2'%logFile)
89 if os.path.exists(
'./%s'%keylist) ==
False:
90 os.system(
'mkdir ./%s'%keylist)
92 os.system(
'chmod u+x %s'%jobName)
94 os.system(
'bsub -q %(queue)s %(jobname)s %(pwd)s %(pwd)s/%(outdir)s' % {
'queue' : queue,
'jobname' : jobName,
'pwd' : PWD,
'outdir' : keylist})
99 parser = OptionParser()
101 parser.add_option(
"-k",
"--keylist",
102 dest=
"hltKeyListFile",
103 default=
"lista_key.txt",
104 help=
"text file with HLT keys")
106 parser.add_option(
"-j",
"--json",
108 help=
"directory with the corresponding json files")
110 parser.add_option(
"-g",
"--globalTag",
112 help=
"the global tag to use in the config files")
114 parser.add_option(
"-t",
"--template",
117 help=
"the template to use for the config files")
119 parser.add_option(
"-q",
"--queue",
122 help=
"the queue to use (default=cmscaf1nd)")
124 parser.add_option(
"-c",
"--cafsetup", action=
"store_true",
127 help=
"wether the caf setup is sourced in the scripts")
129 (options, args) = parser.parse_args()
131 if len(sys.argv) == 1:
132 print(
"\nUsage: %s --help"%sys.argv[0])
135 if str(options.hltKeyListFile) ==
'None':
136 print(
"Please provide a file with HLT keys")
139 if str(options.jsonDir) ==
'None':
140 print(
"Please provide a directory containing the json files")
143 if str(options.globalTag) ==
'None':
144 print(
"Please provide a global tag")
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def getConfigTemplateFilename