ATLAS Offline Software
Functions | Variables
python.AtlRunQueryInterpretDataPeriods Namespace Reference

Functions

def getCurrentYear ()
 
def getRunsFromPeriods (list_of_periods)
 
def getSortedAvailablePeriods ()
 
def getListOfPeriodsFromOrdinateRange (begin, end, requiredProjectName, specialData=None)
 
def getDataPeriodsWithinRange (period_range)
 
def GetRuns (arg)
 

Variables

 pat_last = re.compile(r"(?:l|la|las|last) (\d*)$")
 
 pat_number = re.compile(r"\d{5,8}[+-]?$")
 
 pat_range = re.compile(r"\d{5,8}-\d{5,8}$")
 
 pat_short = re.compile(r"(?:(?:\d{2})(\d{2})\.)?([a-zA-Z]+\d*)$")
 
 pshort = re.compile(r"(?P<first>(data|20)?(?P<year>\d{2})(_.*)?\.)?(period)?(?P<period>[a-zA-Z])(?P<subperiod>\d+)?$",re.I)
 

Function Documentation

◆ getCurrentYear()

def python.AtlRunQueryInterpretDataPeriods.getCurrentYear ( )
returns the last two digits of current year 

Definition at line 21 of file AtlRunQueryInterpretDataPeriods.py.

21 def getCurrentYear():
22  """
23  returns the last two digits of current year
24  """
25  from time import gmtime
26  return gmtime().tm_year - 2000
27 
28 
29 

◆ getDataPeriodsWithinRange()

def python.AtlRunQueryInterpretDataPeriods.getDataPeriodsWithinRange (   period_range)

Definition at line 92 of file AtlRunQueryInterpretDataPeriods.py.

92 def getDataPeriodsWithinRange( period_range ):
93 
94  m1 = pshort.match(period_range[0])
95  m2 = pshort.match(period_range[1])
96 
97  if m1 is None or m2 is None:
98  if m1 is None:
99  print ("Invalid specification of begin of range",period_range[0])
100  if m2 is None:
101  print ("Invalid specification of end of range", period_range[1])
102  sys.exit(0)
103 
104  m1 = m1.groupdict()
105  m2 = m2.groupdict()
106 
107  # year
108  m1['year'] = int(m1['year']) if m1['year'] else getCurrentYear()
109  m2['year'] = int(m2['year']) if m2['year'] else m1['year']
110  # sub-period
111  m1['subperiod'] = int(m1['subperiod']) if m1['subperiod'] else 0
112  m2['subperiod'] = int(m2['subperiod']) if m2['subperiod'] else 99
113 
114  #print ("Interpret run range: %r - %r" % (m1,m2))
115 
116  # ordinate
117  p1c = 10000*m1['year'] + 100*(ord(m1['period'].upper())-65) + m1['subperiod']
118  p2c = 10000*m2['year'] + 100*(ord(m2['period'].upper())-65) + m2['subperiod']
119 
120  return getListOfPeriodsFromOrdinateRange( p1c, p2c, None )
121 
122 
123 

◆ getListOfPeriodsFromOrdinateRange()

def python.AtlRunQueryInterpretDataPeriods.getListOfPeriodsFromOrdinateRange (   begin,
  end,
  requiredProjectName,
  specialData = None 
)
requiredProjectName e.g. data15_13TeV, data15_cos, data15_hip, etc. . If None then it is required that the project name ends in TeV

Definition at line 54 of file AtlRunQueryInterpretDataPeriods.py.

54 def getListOfPeriodsFromOrdinateRange(begin, end, requiredProjectName, specialData=None ):
55  """
56  requiredProjectName e.g. data15_13TeV, data15_cos, data15_hip, etc. . If None then it is required that the project name ends in TeV
57  """
58  if begin>end:
59  sys.exit(0)
60  list_of_periods = []
61 
62  for p,full_name in getSortedAvailablePeriods():
63  (year, period, ordcode, projname) = p
64 
65  if requiredProjectName is None:
66  if not projname.endswith("TeV"):
67  continue
68  else:
69  if projname != requiredProjectName:
70  continue
71 
72  if ordcode == 0: # no special VdM or AllYear stuff periods
73  if specialData is not None:
74  (vdmyear, vdmperiod, vdmsubperiod) = specialData
75  if year==vdmyear and (vdmperiod+vdmsubperiod)==period:
76  list_of_periods += [ (year, period, full_name) ]
77  print (p,"--> include")
78  continue
79 
80  if ordcode % 100 == 0: # no full periods as they are already listed in the numbered periods
81  continue
82 
83  if ordcode < begin or ordcode>end:
84  continue
85 
86  list_of_periods += [ (year, period, full_name) ]
87  print (p,"--> include")
88  return list_of_periods
89 
90 
91 

◆ GetRuns()

def python.AtlRunQueryInterpretDataPeriods.GetRuns (   arg)
arg:     'run data10_7TeV.periodA' or 'run periodA' (where 'data11_7TeV' is assumed)
#               or 'data10_7TeV.periodA-periodC' or 'data10_7TeV.periodA,data10_7TeV.periodB,...'
# This is case sensitive !!

Definition at line 124 of file AtlRunQueryInterpretDataPeriods.py.

124 def GetRuns( arg ):
125  """
126  arg: 'run data10_7TeV.periodA' or 'run periodA' (where 'data11_7TeV' is assumed)
127  # or 'data10_7TeV.periodA-periodC' or 'data10_7TeV.periodA,data10_7TeV.periodB,...'
128  # This is case sensitive !!
129  """
130 
131  # final result in here
132  list_of_runs = []
133 
134  # are their any commas?
135  for tag in arg.split(','):
136 
137  # last X runs pattern
138  m = pat_last.match(arg)
139  if m:
140  #print ("Pattern 'Last N'")
141  list_of_runs += [ "last%s" % m.group(1) ]
142  continue
143 
144  # run numbers
145  if pat_number.match(tag):
146  #print ("Pattern 'List of runs'")
147  list_of_runs += [tag]
148  continue
149 
150  # run number range
151  if pat_range.match(tag):
152  #print ("Pattern 'Range of runs'")
153  list_of_runs += [tag]
154  continue
155 
156 
157  if '-' in tag: # range
158  #print ("Pattern 'Range of periods'")
159  list_of_periods = getDataPeriodsWithinRange( tag.split('-') )
160  list_of_runs += getRunsFromPeriods(list_of_periods)
161  continue
162 
163 
164  # various AllYear versions
165  if '.' not in tag or tag.endswith(".All") or tag.endswith(".AllYear") or tag.endswith(".periodAllYear"):
166  #print ("Pattern 'AllYear'")
167  allyear = 0
168  projectName = None
169  # no tag means AllYear
170  m = re.match(r"20(?P<year>\d{2})(.All|.AllYear|.periodAllYear)?$", tag, re.I)
171  if m:
172  allyear = int(m.groupdict()['year'])
173  else:
174  m = re.match(r"(?P<proj>data(?P<year>\d{2})_.*?)(.All|.AllYear|.periodAllYear)?$", tag, re.I)
175  if m:
176  allyear = int(m.groupdict()['year'])
177  projectName = m.groupdict()['proj']
178 
179  if allyear==0:
180  raise RuntimeError("Can't interpret run period %s" % tag)
181 
182  print ("Interpret period: AllYear for %i" % (2000+allyear))
183 
184  # ordinate
185  p1c = 10000*allyear
186  p2c = 10000*(allyear+1) - 1
187 
188  list_of_periods = getListOfPeriodsFromOrdinateRange(p1c, p2c, projectName)
189 
190  print (list_of_periods)
191 
192  list_of_runs += getRunsFromPeriods(list_of_periods)
193  continue
194 
195 
196 
197  m = re.match( r"(?P<first>(data|20)?(?P<year>\d{2})(_.*)?\.)?(period)?(?P<period>[a-zA-Z])(?P<subperiod>\d+)?$", tag, re.I )
198 
199  #projPeriod = re.compile(r"(?P<first>(data|20)?(?P<year>\d{2})(_.*)?\.)?(period)?(?P<period>[a-zA-Z])(?P<subperiod>\d+)?$",re.I) # 2015_periodA5
200 
201 
202  d = { 'projname' : None }
203  m = re.match( r"20(?P<year>\d{2})\.(period)?(?P<period>[a-zA-Z]|VdM)(?P<subperiod>\d+)?$", tag, re.I )
204  if m:
205  #print ("Pattern '2015.(period)A1'")
206  d.update( m.groupdict() )
207  else:
208  m = re.match( r"(?P<projname>data(?P<year>\d{2})_.*?)\.(period)?(?P<period>[a-zA-Z]|VdM)(?P<subperiod>\d+)?$", tag, re.I )
209  if m:
210  #print ("Pattern 'dataYY_TTT.(period)A1'")
211  d.update( m.groupdict() )
212  else:
213  d = None
214 
215  if d:
216  d['subperiod'] = int(d['subperiod']) if d['subperiod'] else 0
217 
218  print ("Interpret period: %r" % d)
219  if len(d['period'])==1:
220  # ordinate
221  p1c = 10000*int(d['year']) + 100*(ord(d['period'].upper())-65) + d['subperiod']
222  if d['subperiod'] != 0:
223  p2c = p1c
224  else:
225  p2c = p1c+99
226  list_of_periods = getListOfPeriodsFromOrdinateRange(p1c, p2c, d['projname'])
227  else:
228  # VdM
229  sp = '' if d['subperiod']==0 else str(d['subperiod'])
230  list_of_periods = getListOfPeriodsFromOrdinateRange( 0, 0, d['projname'], (int(d['year']), d['period'],sp) )
231 
232  list_of_runs += getRunsFromPeriods(list_of_periods)
233  continue
234 
235  if len(list_of_runs)==0:
236  print ("No runs matching pattern")
237 
238  return list_of_runs
239 
240 
241 
242 
243 
244 # command line driver for convenience

◆ getRunsFromPeriods()

def python.AtlRunQueryInterpretDataPeriods.getRunsFromPeriods (   list_of_periods)
find the run numbers for given period(s)

list_of_periods   periods in format  [('10','B1'),('11','A'),...]

Definition at line 30 of file AtlRunQueryInterpretDataPeriods.py.

30 def getRunsFromPeriods(list_of_periods):
31  """
32  find the run numbers for given period(s)
33 
34  list_of_periods periods in format [('10','B1'),('11','A'),...]
35  """
36  runlist = []
37  from CoolRunQuery.AtlRunQueryCOMA import ARQ_COMA
38  for year, period, fname in list_of_periods:
39  runlist += ARQ_COMA.get_runs(period, 2000+int(year))
40  return runlist
41 
42 
43 @cache

◆ getSortedAvailablePeriods()

def python.AtlRunQueryInterpretDataPeriods.getSortedAvailablePeriods ( )

Definition at line 44 of file AtlRunQueryInterpretDataPeriods.py.

45  from CoolRunQuery.AtlRunQueryCOMA import ARQ_COMA
46  available_periods = ARQ_COMA.get_all_periods()
47  available_periods.sort()
48  #print ('\nAvailable periods:\n')
49  #for i,p in enumerate(available_periods):
50  # print (p)
51  return available_periods
52 
53 

Variable Documentation

◆ pat_last

python.AtlRunQueryInterpretDataPeriods.pat_last = re.compile(r"(?:l|la|las|last) (\d*)$")

Definition at line 12 of file AtlRunQueryInterpretDataPeriods.py.

◆ pat_number

python.AtlRunQueryInterpretDataPeriods.pat_number = re.compile(r"\d{5,8}[+-]?$")

Definition at line 13 of file AtlRunQueryInterpretDataPeriods.py.

◆ pat_range

python.AtlRunQueryInterpretDataPeriods.pat_range = re.compile(r"\d{5,8}-\d{5,8}$")

Definition at line 14 of file AtlRunQueryInterpretDataPeriods.py.

◆ pat_short

python.AtlRunQueryInterpretDataPeriods.pat_short = re.compile(r"(?:(?:\d{2})(\d{2})\.)?([a-zA-Z]+\d*)$")

Definition at line 15 of file AtlRunQueryInterpretDataPeriods.py.

◆ pshort

python.AtlRunQueryInterpretDataPeriods.pshort = re.compile(r"(?P<first>(data|20)?(?P<year>\d{2})(_.*)?\.)?(period)?(?P<period>[a-zA-Z])(?P<subperiod>\d+)?$",re.I)

Definition at line 16 of file AtlRunQueryInterpretDataPeriods.py.

python.AtlRunQueryInterpretDataPeriods.getDataPeriodsWithinRange
def getDataPeriodsWithinRange(period_range)
Definition: AtlRunQueryInterpretDataPeriods.py:92
python.AtlRunQueryInterpretDataPeriods.getSortedAvailablePeriods
def getSortedAvailablePeriods()
Definition: AtlRunQueryInterpretDataPeriods.py:44
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
upper
int upper(int c)
Definition: LArBadChannelParser.cxx:49
python.AtlRunQueryInterpretDataPeriods.getCurrentYear
def getCurrentYear()
Definition: AtlRunQueryInterpretDataPeriods.py:21
python.AtlRunQueryInterpretDataPeriods.getListOfPeriodsFromOrdinateRange
def getListOfPeriodsFromOrdinateRange(begin, end, requiredProjectName, specialData=None)
Definition: AtlRunQueryInterpretDataPeriods.py:54
python.AtlRunQueryInterpretDataPeriods.getRunsFromPeriods
def getRunsFromPeriods(list_of_periods)
Definition: AtlRunQueryInterpretDataPeriods.py:30
python.AtlRunQueryInterpretDataPeriods.GetRuns
def GetRuns(arg)
Definition: AtlRunQueryInterpretDataPeriods.py:124
str
Definition: BTagTrackIpAccessor.cxx:11