CMS 3D CMS Logo

getHLTkey.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 from __future__ import print_function
3 from __future__ import absolute_import
4 from sys import stderr, exit
5 import commands
6 
7 
8 #
9 # E.P., 27 July 2010
10 # query to the Run Reistry taken from a script by Giovanni Petrucianni
11 #
12 
13 
14 from optparse import OptionParser
15 parser = OptionParser(usage="usage: %prog [options] ")
16 parser.add_option("--firstRun", dest="firstRun", help="first run", type="int", metavar="RUN", default="1")
17 parser.add_option("--lastRun", dest="lastRun", help="last run", type="int", metavar="RUN", default="9999999")
18 parser.add_option("--groupName", dest="groupName", help="select runs of name like NAME", metavar="NAME", default="Collisions%")
19 parser.add_option("--HLTkey", dest="HLTkey", help="name of the HLTkey e.g. /cdaq/physics/Run2010/v3.1/HLT_1.6E30/V1",metavar="HLT")
20 parser.add_option("--perKey", action="store_true",default=False,dest="perKey",help="list the runs per HLT key",metavar="perKey")
21 (options, args) = parser.parse_args()
22 
23 from .queryRR import queryRR
24 
25 runKeys = queryRR(options.firstRun,options.lastRun,options.groupName)
26 runs = runKeys.keys(); runs.sort()
27 
28 if options.perKey:
29  runsPerKey={}
30  for run in runs:
31  key = runKeys[run]
32  if not key in runsPerKey.keys():
33  tmpruns=[]
34  tmpruns.append(run)
35  runsPerKey[key] = tmpruns
36  else:
37  runsPerKey[key].append(run)
38  theKeys = runsPerKey.keys()
39  for key in theKeys:
40  theruns = runsPerKey[key]
41  topr=""
42  for r in theruns:
43  topr=topr+"\t"+r
44  print(key,topr)
45  exit(1)
46 
47 if options.HLTkey:
48  HLTkey = options.HLTkey
49  print("List of runs taken with HLT key = ",HLTkey)
50 for run in runs:
51  key = runKeys[run]
52 
53  if not options.HLTkey:
54  print(run,key)
55  else:
56  if key == options.HLTkey:
57  print(run)
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66