CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Functions
util.getRunInfo Namespace Reference

Functions

def dasQuery
 
def dasRunQueryToDict
 
def day
 
def daysAgo
 
def getFilesForRun
 
def getRunsForDate
 
def getRunsNewer
 
def runGetDatasetsAvailable
 
def today
 

Function Documentation

def util.getRunInfo.dasQuery (   queryString,
  entryTitle 
)

Definition at line 74 of file getRunInfo.py.

Referenced by util.getRunInfo.dasRunQueryToDict(), util.getRunInfo.getFilesForRun(), and util.getRunInfo.runGetDatasetsAvailable().

74 
75 def dasQuery(queryString, entryTitle) :
76  dasinfo = das_client.get_data('https://cmsweb.cern.ch', queryString, 0, 0, False)
77  if dasinfo['status'] != 'ok' :
78  raise Exception('DAS query failed.\nQuery: %s\nDAS Status returned: %s' % (queryString, dasinfo['status']))
79 
80  if len(dasinfo['data']) > 0 :
81  for entry in dasinfo['data'] :
82  if entryTitle in entry and len(entry[entryTitle]) > 0 :
83  yield entry[entryTitle][0]
def util.getRunInfo.dasRunQueryToDict (   querystring)

Definition at line 66 of file getRunInfo.py.

References util.getRunInfo.dasQuery().

Referenced by util.getRunInfo.getRunsForDate(), and util.getRunInfo.getRunsNewer().

66 
67 def dasRunQueryToDict(querystring) :
68  runs = {}
69  for runDict in dasQuery(querystring, 'run') :
70  runNo = int(runDict['run_number'])
71  runDict['date'] = datestring
72  runs[runNo] = runDict
73  return runs
def dasRunQueryToDict
Definition: getRunInfo.py:66
def util.getRunInfo.day (   string)

Definition at line 11 of file getRunInfo.py.

Referenced by RunDCSHVDat.fillTheMapByTime(), RPCRunIOV.filterIMON(), LMFRunIOV.getParameters(), LMFLmrSubIOV.getParameters(), CSCTFConfigOnlineProd.newObject(), RunSummaryRead.readData(), L1TriggerScalerRead.readData(), SiStripDetVOffBuilder.readLastValueFromFile(), RPCRunIOV.toUNIX(), and RPCFw.UTtoT().

11 
12 def day(string) :
13  return datetime.datetime.strptime(string, "%Y%m%d").date()
def util.getRunInfo.daysAgo (   n)

Definition at line 7 of file getRunInfo.py.

References util.getRunInfo.today().

7 
8 def daysAgo(n) :
9  date = today()
10  return date - datetime.timedelta(days=n)
def util.getRunInfo.getFilesForRun (   run,
  dataset 
)
    run : int
    dataset : string dataset to find files in, e.g.
        /ExpressCosmics/Run2015A-Express-v1/FEVT
        /ExpressPhysics/Run2015A-Express-v1/FEVT

Definition at line 47 of file getRunInfo.py.

References util.getRunInfo.dasQuery(), and alcaDQMUpload.encode().

47 
48 def getFilesForRun(run, dataset) :
49  '''
50  run : int
51  dataset : string dataset to find files in, e.g.
52  /ExpressCosmics/Run2015A-Express-v1/FEVT
53  /ExpressPhysics/Run2015A-Express-v1/FEVT
54  '''
55  querystring = "file dataset={dataset} run={run}".format(dataset=dataset, run=run)
56 
57  files = []
58  for fileDict in dasQuery(querystring, 'file') :
59  # cmsRun will not like unicode
60  files.append(fileDict['name'].encode('ascii','replace'))
61 
62  return files
63 
64 
65 # -------------------- DAS convert tools
def util.getRunInfo.getRunsForDate (   date,
  minlumis = 10 
)
    date: expected to be datetime.datetime object

Definition at line 14 of file getRunInfo.py.

References util.getRunInfo.dasRunQueryToDict().

14 
15 def getRunsForDate(date, minlumis=10) :
16  '''
17  date: expected to be datetime.datetime object
18  '''
19  datestring = date.strftime('%Y%m%d')
20  querystring = "run date={date} | grep run.nlumis>{minlumis}".format(date=datestring, minlumis=minlumis)
21  return dasRunQueryToDict(querystring)
def dasRunQueryToDict
Definition: getRunInfo.py:66
def util.getRunInfo.getRunsNewer (   run,
  minlumis = 10,
  source = 'RunRegistry' 
)
    run: run number int
    source: Either RunRegistry or DAS

Definition at line 22 of file getRunInfo.py.

References util.getRunInfo.dasRunQueryToDict().

22 
23 def getRunsNewer(run, minlumis=10, source='RunRegistry') :
24  '''
25  run: run number int
26  source: Either RunRegistry or DAS
27  '''
28  if source == 'RunRegistry' :
29  return rrClient.getRunsNewer(run, minlumis)
30  elif source == 'DAS' :
31  querystring = "run | grep run.nlumis>{minlumis}, run.runnumber>{run}".format(run=run, minlumis=minlumis)
32  return dasRunQueryToDict(querystring)
def dasRunQueryToDict
Definition: getRunInfo.py:66
def util.getRunInfo.runGetDatasetsAvailable (   run)
    run : int
    Will return a list of datasets in DAS that have the run in them

Definition at line 33 of file getRunInfo.py.

References util.getRunInfo.dasQuery(), and alcaDQMUpload.encode().

33 
34 def runGetDatasetsAvailable(run) :
35  '''
36  run : int
37  Will return a list of datasets in DAS that have the run in them
38  '''
39  querystring = "dataset run={run}".format(run=run)
40 
41  datasets = []
42  for datasetDict in dasQuery(querystring, 'dataset') :
43  # cmsRun will not like unicode
44  datasets.append(datasetDict['name'].encode('ascii','replace'))
45 
46  return datasets
def runGetDatasetsAvailable
Definition: getRunInfo.py:33
def util.getRunInfo.today ( )

Definition at line 4 of file getRunInfo.py.

Referenced by util.getRunInfo.daysAgo().

4 
5 def today() :
6  return datetime.datetime.now().date()