8 from __future__
import print_function
9 from optparse
import OptionParser
12 jobHash =
"%s_%s_%s" % (os.getuid(), os.getpid(), int(time.time()))
14 usage =
'%prog [options]. \n\t-a and -k required, -h for help.'
15 parser = OptionParser(usage)
16 parser.add_option(
"-a",
"--analysis", dest=
"analysis",
17 help=
"analysis configuration file")
21 parser.add_option(
"-k",
"--hltkey", dest=
"hltkey",
22 help=
"ignore RunRegistry and force the use of HLT key KEY",
24 parser.add_option(
"-c",
"--hltcff", dest=
"hltcff",
25 help=
"use the config fragment CFF to define HLT configuration",
27 parser.add_option(
"-f",
"--frontier", dest=
"frontier",
28 help=
"frontier connection string to use, defaults to frontier://FrontierProd/CMS_COND_21X_GLOBALTAG",
29 default=
"frontier://FrontierProd/CMS_COND_31X_GLOBALTAG")
32 (options, args) = parser.parse_args()
34 if options.hltkey ==
None and options.hltcff ==
None:
35 parser.error(
"I don't have all the required options.")
37 "Please specify one of --hltkey (-k) or --hltcff (-s)")
38 if options.hltkey !=
None and options.hltcff !=
None:
39 raise SystemExit(
"Please only specify --hltkey (-k) or --hltcff (-c)")
44 if options.analysis ==
None:
46 "Please specify an analysis configuration: -a or --analysis")
53 raise SystemExit(
"Must run from a Module/Package/python directory")
58 onlineFrontier = re.search(
'"(frontier:.*)"', config)
59 if not onlineFrontier:
60 print(
"WARNING: Could not find Frontier string in HLT configuration. Will ignore.")
62 config = config.replace(onlineFrontier.group(1), frontierString)
65 config = config.replace(
"H::All",
"P::All")
72 config =
RemovePSet(config,
"FUShmDQMOutputService")
77 startLoc = config.find(pset)
85 if config[curLoc] ==
"(":
92 if config[curLoc] ==
"(":
94 elif config[curLoc] ==
")":
100 config = config.replace(config[startLoc:endLoc + 1],
"")
113 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()
115 configName =
"JobHLTConfig_%s_cff.py" % jobHash
121 f = open(configName,
"w")
125 return 'process.load("%s.%s.%s")' % (module, package, configName.split(
".")[0])
129 raise SystemExit(
"Not implemented yet")
133 pathParts = cffPath.split(
".")
134 if not re.match(
"^[_A-Za-z0-9]*\.[_A-Za-z0-9]*\.[_A-Za-z0-9]*$", cffPath):
135 raise SystemExit(
"Expected cff in form Package.Module.configName_cff")
136 return 'process.load("%s")' % cffPath
140 tmpCode = compileCode.replace(
"SUBSYSTEM", subsystem)
141 tmpCode = tmpCode.replace(
"PACKAGE", package)
142 tmpCode = tmpCode.replace(
"CONFIG", hltConfig +
"c")
147 anaName =
"JobAnalysisConfig_%s_cfg.py" % jobHash
149 g = open(anaName,
"w")
162 if options.hltkey !=
None:
164 elif options.hltcff !=
None:
174 print(
"Using HLT configuration: %s" % hltConfig)
176 print(
"Created HLT configuration: %s" % hltConfig)
177 print(
"Created analysis configuration: %s" % anaConfig)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
def ConvertHltOnlineToOffline