options.register('unitTest', True,
                 VarParsing.VarParsing.multiplicity.singleton,
                 VarParsing.VarParsing.varType.bool,
                 "Required to avoid the error.")

options.parseArguments()

print("Querying DAS for files...")
readFiles = cms.untracked.vstring()
secFiles = cms.untracked.vstring()
eventsToProcess = []

# Query DAS for a ROOT file for every lumisection
for ls in range(options.minLumi, options.maxLumi + 1):
    if fnmatch.fnmatch(str(ls), options.lumiPattern):
        read, sec = filesFromDASQuery("file run=%d dataset=%s lumi=%s" %
                                      (options.runNumber, options.dataset, ls))
        readFiles.extend(read)
        secFiles.extend(sec)

        # Get last eventsPerLumi of events in this file
        command = "edmFileUtil --catalog file:/cvmfs/cms-ib.cern.ch/SITECONF/local/PhEDEx/storage.xml?protocol=xrootd --events %s | tail -n +9 | head -n -5 | awk '{ print $3 }'" % read[
            0]
        print(command)
        events = subprocess.check_output(command, shell=True)
        events = events.split(b'\n')
        events = filter(lambda x: x != b"", events)
        events = map(int, events)
        events = sorted(events)
        events = events[-options.eventsPerLumi:]
        eventsToProcess.append("%s:%s:%s-%s:%s:%s" %
                               (options.runNumber, ls, events[0],
예제 #2
0
  print "Using filenames from dataset_cfi.py."
except:
  if options.dataset == 'auto':
    print "Querying DAS for a dataset..."
    import subprocess
    out = subprocess.check_output("das_client --query 'dataset run=%d dataset=/*Express*/*/*FEVT*'" % options.runNumber, shell=True)
    dataset = out.splitlines()[-1]
    print "Using dataset=%s." % dataset
  else:
    dataset = options.dataset

  print "Querying DAS for files..."
  readFiles = cms.untracked.vstring()
  secFiles = cms.untracked.vstring()
  # this outputs all results, which can be a lot...
  read, sec = filesFromDASQuery("file run=%d dataset=%s" % (options.runNumber, dataset), option=" --limit 10000 ")
  readFiles.extend(read)
  secFiles.extend(sec)

print "Got %d files." % len(readFiles)

runstr = str(options.runNumber)
runpattern = "*" + runstr[0:3] + "/" + runstr[3:] + "*"
readFiles = cms.untracked.vstring([f for f in readFiles if fnmatch.fnmatch(f, runpattern)])
secFiles = cms.untracked.vstring([f for f in secFiles if fnmatch.fnmatch(f, runpattern)])
lumirange =  cms.untracked.VLuminosityBlockRange(
  [ str(options.runNumber) + ":" + str(ls) 
      for ls in range(options.minLumi, options.maxLumi+1)
      if fnmatch.fnmatch(str(ls), options.lumiPattern)
  ]
)
예제 #3
0
        print "Querying DAS for a dataset..."
        import subprocess
        out = subprocess.check_output(
            "das_client --query 'dataset run=%d dataset=/*Express*/*/*FEVT*'" %
            options.runNumber,
            shell=True)
        dataset = out.splitlines()[-1]
        print "Using dataset=%s." % dataset
    else:
        dataset = options.dataset

    print "Querying DAS for files..."
    readFiles = cms.untracked.vstring()
    secFiles = cms.untracked.vstring()
    # this outputs all results, which can be a lot...
    read, sec = filesFromDASQuery("file dataset=%s" % dataset,
                                  option=" --limit 10000 ")
    readFiles.extend(read)
    secFiles.extend(sec)

print "Got %d files." % len(readFiles)

runstr = str(options.runNumber)
runpattern = "*" + runstr[0:3] + "/" + runstr[3:] + "*"
readFiles = cms.untracked.vstring(
    [f for f in readFiles if fnmatch.fnmatch(f, runpattern)])
lumirange = cms.untracked.VLuminosityBlockRange([
    str(options.runNumber) + ":" + str(ls)
    for ls in range(options.minLumi, options.maxLumi + 1)
    if fnmatch.fnmatch(str(ls), options.lumiPattern)
])