CMS 3D CMS Logo

getHLTPrescaleColumns.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 from __future__ import print_function
3 from sys import stderr, exit
4 import commands
5 
6 from optparse import OptionParser
7 parser = OptionParser(usage="usage: %prog [options] Trigger_Path")
8 parser.add_option("--firstRun", dest="firstRun", help="first run", type="int", metavar="RUN", default="1")
9 parser.add_option("--lastRun", dest="lastRun", help="last run", type="int", metavar="RUN", default="9999999")
10 parser.add_option("--groupName", dest="groupName", help="select runs of name like NAME", metavar="NAME", default="Collisions%")
11 parser.add_option("--jsonOut", dest="jsonOut", help="dump prescales in JSON format on FILE", metavar="FILE")
12 (options, args) = parser.parse_args()
13 if len(args) != 1:
14  parser.print_usage()
15  exit(2)
16 path = args[0]
17 
18 
19 edmCfgFromDB = "edmConfigFromDB --orcoff --format summary.ascii --paths " + path;
20 ## my $pyPrintTable = "echo 'for X in process.PrescaleService.prescaleTable: print \"\%s \%s\" % (X.pathName.value(), X.prescales[0])'";
22  #stderr.write("\t%s ...\n" % key);
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()
26  psMap = {}
27  aa=""
28  if len(res)>0:
29  for uu in range(3,len(res_split)-1):
30  if uu % 2 == 1:
31  aa = aa + res_split[uu] + "\t"
32  psMap[path] = aa
33  else:
34  psMap[path] = 0
35  return psMap
36 
37 from queryRR import queryRR
38 
39 runKeys = queryRR(options.firstRun,options.lastRun,options.groupName)
40 prescaleTable = {}
41 runs = runKeys.keys(); runs.sort()
42 stderr.write("Querying ConfDB for prescales for path %s...\n" % (path));
43 jsout = {}
44 for run in runs:
45  key = runKeys[run]
46  if key not in prescaleTable:
47  prescaleTable[key] = getPrescalesFromKey(key)
48  psfactor = 1
49  if path in prescaleTable[key]: psfactor = prescaleTable[key][path]
50  print("%s\t%s" % (run, psfactor))
51  jsout[run] = psfactor
52 
53 if options.jsonOut:
54  stderr.write("Exporting to JSON file %s...\n" % (options.jsonOut))
55  import json
56  jsonFile = open(options.jsonOut, "w")
57  jsonFile.write(json.dumps(jsout))
58  jsonFile.close()
def getPrescalesFromKey(key)
my $pyPrintTable = "echo 'for X in process.PrescaleService.prescaleTable: print \"%s %s" % (X...
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:65