2 from sys
import stderr, exit
5 from optparse
import OptionParser
6 parser = OptionParser(usage=
"usage: %prog [options] Trigger_Path")
7 parser.add_option(
"--firstRun", dest=
"firstRun", help=
"first run", type=
"int", metavar=
"RUN", default=
"1")
8 parser.add_option(
"--lastRun", dest=
"lastRun", help=
"last run", type=
"int", metavar=
"RUN", default=
"9999999")
9 parser.add_option(
"--groupName", dest=
"groupName", help=
"select runs of name like NAME", metavar=
"NAME", default=
"Collisions%")
10 parser.add_option(
"--rrurl", dest=
"rrurl", help=
"run registry xmlrpc url", metavar=
"URL", default=
"http://cms-service-runregistry-api.web.cern.ch/cms-service-runregistry-api/xmlrpc")
11 parser.add_option(
"--jsonOut", dest=
"jsonOut", help=
"dump prescales in JSON format on FILE", metavar=
"FILE")
12 (options, args) = parser.parse_args()
19 edmCfgFromDB =
"edmConfigFromDB --orcoff --format summary.ascii --paths " + path;
23 cmd = ( edmCfgFromDB +
" --configName "+key +
" | grep -i "+ path +
" | tail -1 | awk ' $2 ==\"%s\" {print $NL}' " ) % path
24 res = commands.getoutput(cmd)
25 res_split = res.split()
28 for uu
in range(3,len(res_split)-1):
30 psCols.append(res_split[uu])
35 stderr.write(
"Querying run registry for range [%d, %d], group name like %s ...\n" % (options.firstRun, options.lastRun, options.groupName))
38 server = xmlrpclib.ServerProxy(options.rrurl)
39 run_data = server.DataExporter.export(
'RUN',
'GLOBAL',
'xml_datasets',
"{runNumber} >= %d AND {runNumber} <= %d AND {groupName} like '%s' AND {datasetName} = '/Global/Online/ALL'" % (options.firstRun, options.lastRun, options.groupName))
41 xml_data = xml.dom.minidom.parseString(run_data)
42 xml_runs = xml_data.documentElement.getElementsByTagName(
"RUN_DATASET")
43 for xml_run
in xml_runs:
44 ret[xml_run.getElementsByTagName(
"RUN_NUMBER")[0].firstChild.nodeValue] = xml_run.getElementsByTagName(
"RUN_HLTKEY")[0].firstChild.nodeValue
48 asciiFile=open(
"columns.txt",
"read")
52 fl=asciiFile.readline()
57 mapIndex[runnumber]=pindex
66 runs = runKeys.keys(); runs.sort()
67 stderr.write(
"Querying ConfDB for prescales for path %s...\n" % (path));
71 if not prescaleTable.has_key(key):
75 if len(prescaleTable[key]) == 0:
78 if MapIndex.has_key(run):
79 index = int(MapIndex[run])
80 psfactor = prescaleTable[key][index]
84 psfactor = prescaleTable[key][index]
88 psfactor = prescaleTable[key][index]
92 print "%s\t%s" % (run, psfactor)
94 print "%s\t%s\t (*)" % (run, psfactor)
99 print "(*) The following runs were not found in columns.txt (the run may be too recent, or the prescale index is not in OMDS)."
100 print "For these runs, the prescale_index was assumed to be zero. You need to check independently."
106 stderr.write(
"Exporting to JSON file %s...\n" % (options.jsonOut))
108 jsonFile = open(options.jsonOut,
"w")
109 jsonFile.write(json.dumps(jsout))
def getPrescalesFromKey
my $pyPrintTable = "echo 'for X in process.PrescaleService.prescaleTable: print \"%s %s" % (X...