Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-11-26 02:34:21

0001 #!/usr/bin/env python3 
0002 from sys import stderr, exit
0003 
0004 
0005 #
0006 # E.P., 27 July 2010
0007 # query to the Run Reistry taken from a script by Giovanni Petrucianni
0008 #
0009 
0010 
0011 from optparse import OptionParser
0012 parser = OptionParser(usage="usage: %prog [options] ")
0013 parser.add_option("--firstRun",  dest="firstRun",  help="first run", type="int", metavar="RUN", default="1")
0014 parser.add_option("--lastRun",   dest="lastRun",   help="last run",  type="int", metavar="RUN", default="9999999")
0015 parser.add_option("--groupName", dest="groupName", help="select runs of name like NAME", metavar="NAME", default="Collisions%")
0016 parser.add_option("--HLTkey",    dest="HLTkey",    help="name of the HLTkey e.g. /cdaq/physics/Run2010/v3.1/HLT_1.6E30/V1",metavar="HLT")
0017 parser.add_option("--perKey",    action="store_true",default=False,dest="perKey",help="list the runs per HLT key",metavar="perKey")
0018 (options, args) = parser.parse_args()
0019 
0020 from .queryRR import queryRR
0021 
0022 runKeys = queryRR(options.firstRun,options.lastRun,options.groupName)
0023 runs = runKeys.keys(); runs.sort()
0024 
0025 if options.perKey:
0026     runsPerKey={}
0027     for run in runs:
0028         key = runKeys[run]
0029         if not key in runsPerKey.keys():
0030             tmpruns=[]
0031             tmpruns.append(run)
0032             runsPerKey[key] = tmpruns
0033         else:
0034             runsPerKey[key].append(run)
0035     theKeys = runsPerKey.keys()
0036     for key in theKeys:
0037         theruns = runsPerKey[key]
0038         topr=""
0039         for r in theruns:
0040             topr=topr+"\t"+r
0041         print(key,topr)
0042     exit(1)
0043 
0044 if options.HLTkey:
0045     HLTkey = options.HLTkey
0046     print("List of runs taken with HLT key = ",HLTkey) 
0047 for run in runs:
0048     key = runKeys[run]
0049 
0050     if not options.HLTkey:
0051         print(run,key)  
0052     else:
0053         if key == options.HLTkey:
0054             print(run)