8 from optparse
import OptionParser
11 jobHash =
"%s_%s_%s" % (os.getuid(), os.getpid(),
int(time.time()))
13 usage =
'%prog [options]. \n\t-a and -k required, -h for help.' 14 parser = OptionParser(usage)
15 parser.add_option(
"-a",
"--analysis", dest=
"analysis",
16 help=
"analysis configuration file")
20 parser.add_option(
"-k",
"--hltkey", dest=
"hltkey",
21 help=
"ignore RunRegistry and force the use of HLT key KEY",
23 parser.add_option(
"-c",
"--hltcff", dest=
"hltcff",
24 help=
"use the config fragment CFF to define HLT configuration",
26 parser.add_option(
"-f",
"--frontier", dest=
"frontier",
27 help=
"frontier connection string to use, defaults to frontier://FrontierProd/CMS_COND_21X_GLOBALTAG",
28 default=
"frontier://FrontierProd/CMS_COND_31X_GLOBALTAG")
31 (options, args) = parser.parse_args()
33 if options.hltkey ==
None and options.hltcff ==
None:
34 parser.error(
"I don't have all the required options.")
36 "Please specify one of --hltkey (-k) or --hltcff (-s)")
37 if options.hltkey !=
None and options.hltcff !=
None:
38 raise SystemExit(
"Please only specify --hltkey (-k) or --hltcff (-c)")
43 if options.analysis ==
None:
45 "Please specify an analysis configuration: -a or --analysis")
52 raise SystemExit(
"Must run from a Module/Package/python directory")
57 onlineFrontier = re.search(
'"(frontier:.*)"', config)
58 if not onlineFrontier:
59 print "WARNING: Could not find Frontier string in HLT configuration. Will ignore." 61 config = config.replace(onlineFrontier.group(1), frontierString)
64 config = config.replace(
"H::All",
"P::All")
71 config =
RemovePSet(config,
"FUShmDQMOutputService")
76 startLoc = config.find(pset)
84 if config[curLoc] ==
"(":
91 if config[curLoc] ==
"(":
93 elif config[curLoc] ==
")":
99 config = config.replace(config[startLoc:endLoc + 1],
"")
112 config = os.popen2(
'wget "http://cms-project-confdb-hltdev.web.cern.ch/cms-project-confdb-hltdev/get.jsp?dbName=ORCOFF&configName=%s&cff=&nooutput=&format=Python" -O- -o /dev/null' % hltKey)[1].read()
114 configName =
"JobHLTConfig_%s_cff.py" % jobHash
120 f = open(configName,
"w")
124 return 'process.load("%s.%s.%s")' % (module, package, configName.split(
".")[0])
128 raise SystemExit(
"Not implemented yet")
132 pathParts = cffPath.split(
".")
133 if not re.match(
"^[_A-Za-z0-9]*\.[_A-Za-z0-9]*\.[_A-Za-z0-9]*$", cffPath):
134 raise SystemExit(
"Expected cff in form Package.Module.configName_cff")
135 return 'process.load("%s")' % cffPath
139 tmpCode = compileCode.replace(
"SUBSYSTEM", subsystem)
140 tmpCode = tmpCode.replace(
"PACKAGE", package)
141 tmpCode = tmpCode.replace(
"CONFIG", hltConfig +
"c")
146 anaName =
"JobAnalysisConfig_%s_cfg.py" % jobHash
148 g = open(anaName,
"w")
161 if options.hltkey !=
None:
163 elif options.hltcff !=
None:
173 print "Using HLT configuration: %s" % hltConfig
175 print "Created HLT configuration: %s" % hltConfig
176 print "Created analysis configuration: %s" % anaConfig
def FormatHltCff(cffPath)
def ConvertHltOnlineToOffline(config, frontierString)
def GetHltConfiguration(hltKey, frontierString)
def RemovePSet(config, pset)
def CreateAnalysisConfig(analysis, hltInclude)
def GetHltCompileCode(subsystem, package, hltConfig)