ATLAS Offline Software
Classes | Functions | Variables
python.utils.AtlRunQueryUtils Namespace Reference

Classes

class  DBConnectionController
 
class  Enumerate
 
class  Matrix
 
class  RunPeriods
 
class  XMLReader
 

Functions

def checkURL (url)
 
def runsOnServer ()
 
def importroot (batch=True)
 
def prettyNumber (n, width=-1, delim=',', decimal='.')
 
def durationInSeconds (duration_string)
 
def addKommaToNumber (no)
 
def filesize (no)
 
def MergeRanges (listOfRanges)
 
def MergeLBRanges (listOfRanges)
 
def stringToIntOrTime (s)
 
def timeStringToSecondsUTC (t)
 
def timeStringToSecondsLocalTime (t)
 
def secondsToTimeStringUTC (s)
 
def secondsToTimeStringLocaltime (s)
 
def GetRanges (rangestr, intRepFnc=stringToIntOrTime, maxval=1<< 30)
 
def full_time_string (s, startofday)
 
def GetTimeRanges (timeranges, intRepFnc=timeStringToSecondsUTC, maxval=1<< 30)
 
def SmartRangeCalulator (runlist, singleRuns=True)
 
def bConvertList (b, nbyte=1, nval=1)
 
def unpackRun1BCIDMask (blob, nb1, nb2, nbc)
 
def unpackRun2BCIDMask (blob)
 
def Poisson (n, mu)
 
def ComputePileup (lumi_mb, sigma, nbunch, fOrbit)
 
def Pileup (args)
 
def get_run_range (start, end=None)
 
def get_runs_last_dt (last)
 
def get_runs (start, end=None)
 
def get_run_range2 (start, end=None)
 

Variables

 coolDbConn = DBConnectionController()
 

Function Documentation

◆ addKommaToNumber()

def python.utils.AtlRunQueryUtils.addKommaToNumber (   no)

Definition at line 190 of file AtlRunQueryUtils.py.

190 def addKommaToNumber(no):
191  gr = [str(no)]
192  if not gr[0].isdigit():
193  return gr[0]
194  while gr[0]:
195  gr[0:1]=[gr[0][:-3],gr[0][-3:]]
196  return ','.join(gr[1:])
197 

◆ bConvertList()

def python.utils.AtlRunQueryUtils.bConvertList (   b,
  nbyte = 1,
  nval = 1 
)

Definition at line 419 of file AtlRunQueryUtils.py.

419 def bConvertList(b, nbyte=1, nval=1):
420  # routine to store an unsigned int (1, 2, 4 or 8 byte) in a blob
421  packopt=dict([[1,'B'],[2,'H'],[4,'f'],[8,'d']])
422  if nbyte in packopt:
423  # print ('bConvert - b:[', b[0:nbyte], '] nbyte:', nbyte, ' fmt:', packopt[nbyte], type(b))
424  fmt = '%d%s' % (nval, packopt[nbyte])
425  ival=struct.unpack(fmt, b[0:nval*nbyte])
426  else:
427  print ('bConvertList: Unrecognized pack option')
428  sys.exit()
429  return list(ival)
430 
431 

◆ checkURL()

def python.utils.AtlRunQueryUtils.checkURL (   url)

Definition at line 28 of file AtlRunQueryUtils.py.

28 def checkURL(url):
29  p = urllib.parse(url)
30  h = http.client.HTTP(p[1])
31  h.putrequest('HEAD', p[2])
32  h.endheaders()
33  if h.getreply()[0] == 200:
34  return 1
35  return 0
36 

◆ ComputePileup()

def python.utils.AtlRunQueryUtils.ComputePileup (   lumi_mb,
  sigma,
  nbunch,
  fOrbit 
)

Definition at line 477 of file AtlRunQueryUtils.py.

477 def ComputePileup( lumi_mb, sigma, nbunch, fOrbit ):
478  print("Calling compute pileup with")
479  print(" lumi_mb :", lumi_mb)
480  print(" sigma :", sigma)
481  print(" # bunches:", nbunch)
482  print(" # fOrbit :", fOrbit)
483  p = []
484  # sanity
485  if nbunch <= 0:
486  return 0, None
487 
488  # compute first probability of interaction
489  nint = lumi_mb * sigma / fOrbit / nbunch
490 
491  # large
492  if nint > 100:
493  return nint, None
494 
495  # small 'nint', compute poisson probabilities
496  for n in range(40):
497  p.append(Poisson(n,nint))
498  if n > 20 and p[-1] < 1e40:
499  break
500  return nint, p
501 

◆ durationInSeconds()

def python.utils.AtlRunQueryUtils.durationInSeconds (   duration_string)

Definition at line 88 of file AtlRunQueryUtils.py.

88 def durationInSeconds( duration_string ):
89  lst = duration_string.split()
90  sec = 0
91  for entry in lst:
92  if 's' in entry:
93  sec += int(entry.replace('s',''))
94  elif 'm' in entry:
95  sec += int(entry.replace('m',''))*60
96  elif 'h' in entry:
97  sec += int(entry.replace('h',''))*3600
98  elif 'd' in entry:
99  sec += int(entry.replace('d',''))*3600*24
100  elif 'w' in entry:
101  sec += int(entry.replace('w',''))*3600*24*7
102  elif 'y' in entry:
103  sec += int(entry.replace('y',''))*3600*24*365
104  else:
105  print ('Big troubles... in function "AtlRunQueryUtils::durationInSeconds": cannot decode string "%s"' % entry)
106  sys.exit(1)
107  return sec
108 

◆ filesize()

def python.utils.AtlRunQueryUtils.filesize (   no)

Definition at line 198 of file AtlRunQueryUtils.py.

198 def filesize(no):
199  if no is None:
200  return "n.a."
201  if no > 0x4000000000000:
202  return "%1.1f&nbsp;PB" % (no*1.0/0x4000000000000)
203  if no > 0x10000000000:
204  return "%1.1f&nbsp;TB" % (no*1.0/0x10000000000)
205  if no > 0x40000000:
206  return "%1.1f&nbsp;GB" % (no*1.0/0x40000000)
207  if no > 0x100000:
208  return "%1.1f&nbsp;MB" % (no*1.0/0x100000)
209  if no > 0x400:
210  return "%1.1f&nbsp;kB" % (no*1.0/0x400)
211 
212  return "%i&nbsp;B" % no
213 
214 
215 # a helper function to decode range lists and merge the intervals
216 # par: listOfRanges: [(b1,e1),(b2,e2),....,(bn,en)] -> [(b1,e2),....,(bn,en)] if b2-1<=e1

◆ full_time_string()

def python.utils.AtlRunQueryUtils.full_time_string (   s,
  startofday 
)

Definition at line 357 of file AtlRunQueryUtils.py.

357 def full_time_string(s,startofday):
358  try:
359  time.strptime(s,"%d.%m.")
360  year=str(time.gmtime().tm_year)
361  return s+year+"_00:00:00" if startofday else s+year+"_23:59:59"
362  except ValueError:
363  try:
364  time.strptime(s,"%d.%m.%Y")
365  return s+"_00:00:00" if startofday else s+"_23:59:59"
366  except ValueError:
367  return s
368 

◆ get_run_range()

def python.utils.AtlRunQueryUtils.get_run_range (   start,
  end = None 
)

Definition at line 582 of file AtlRunQueryUtils.py.

582 def get_run_range(start,end=None):
583  runs = get_runs(start,end)
584  if len(runs) == 0:
585  return None
586  if len(runs) == 1:
587  return (runs[0],runs[0])
588  return (runs[0],runs[-1])
589 

◆ get_run_range2()

def python.utils.AtlRunQueryUtils.get_run_range2 (   start,
  end = None 
)
find all runs between two timestamps
start and end are given in the format '1.5.2010_14:23:10', '1.5.2010 14:23:10', or '1.5.2010'

Definition at line 623 of file AtlRunQueryUtils.py.

623 def get_run_range2(start,end=None):
624  """
625  find all runs between two timestamps
626  start and end are given in the format '1.5.2010_14:23:10', '1.5.2010 14:23:10', or '1.5.2010'
627  """
628 
629  # first we find the last run before the specified start time
630  # second we check if it spans over the specified start time
631  # - if it does then we use this run number
632  # - if it does not we find the first run after the specified start time and use this run number
633  # if an end is given we search for the last run that starts before the specified end time
634 
635  co = coolDbConn.GetAtlasRunDBConnection()
636  cu = co.cursor()
637 
638  #available:
639  # NAME,RUNNUMBER,STARTAT,DURATION,CREATEDBY,HOST,PARTITIONNAME,CONFIGSCHEMA,CONFIGDATA,COMMENTS
640 
641  start_seconds_utc = timeStringToSecondsUTC(start)
642  start_gmtime = time.gmtime( start_seconds_utc )
643  start_fstring = time.strftime("%Y%m%dT%H%M%S", start_gmtime)
644 
645  # last run that started before the begin of the range
646  subq = "SELECT MAX(RUNNUMBER) FROM ATLAS_RUN_NUMBER.RUNNUMBER WHERE STARTAT<'%s' AND PARTITIONNAME='ATLAS'" % start_fstring
647  q = "select RUNNUMBER,STARTAT,DURATION from ATLAS_RUN_NUMBER.RUNNUMBER where RUNNUMBER=(%s)" % subq
648  cu.execute(q)
649  try:
650  run1,startat,duration = cu.fetchone()
651 
652  startAtGmtime = time.strptime( startat, "%Y%m%dT%H%M%S" ) # parse the format from the RunNumber DB
653  startAtUtcSecond = calendar.timegm( startAtGmtime )
654  # startAtHuman = time.strftime("%Y%m%dT%H%M%S", startAtGmtime)
655 
656  endAtUtcSecond = startAtUtcSecond + duration
657  # endAtGmtime = time.gmtime( endAtUtcSecond )
658  # endAtHuman = time.strftime("%Y%m%dT%H%M%S", endAtGmtime)
659 
660  # print("start: ", start)
661  # print("Last run before start: ",run1)
662  # print(" starts at: ",startat)
663  # print(" lasts for: ", duration)
664  # print("start sec", startAtUtcSecond)
665  # print("start gmt", startAtGmtime)
666  # print("start hr ", startAtHuman)
667  # print("end sec", endAtUtcSecond)
668  # print("end gmt", endAtGmtime)
669  # print("end hr ", endAtHuman)
670 
671  # note that duration is not exact, but always a bit larger than the length of the run
672 
673  if endAtUtcSecond < start_seconds_utc:
674  print("Run started and ended before the specified start time, so need to take the first one that started of the specified start time")
675  q = "SELECT MIN(RUNNUMBER) FROM ATLAS_RUN_NUMBER.RUNNUMBER WHERE STARTAT>'%s' AND PARTITIONNAME='ATLAS'" % start_fstring
676  cu.execute(q)
677  try:
678  run1 = cu.fetchone()[0]
679  except cx_Oracle.Error:
680  run1 = None
681  except cx_Oracle.Error:
682  run1 = None
683 
684  run2 = None
685  if end is not None:
686  # last run that started before the end of the range
687  start_gmtime = time.gmtime( timeStringToSecondsUTC(end) )
688  endtime = time.strftime("%Y%m%dT%H%M%S",start_gmtime)
689  q = "SELECT MAX(RUNNUMBER) FROM ATLAS_RUN_NUMBER.RUNNUMBER WHERE STARTAT<'%s'" % endtime
690  cu.execute(q)
691  run2 = cu.fetchone()[0]
692 
693  return (run1,run2)
694 
695 
696 

◆ get_runs()

def python.utils.AtlRunQueryUtils.get_runs (   start,
  end = None 
)
start and end are given in the format '1.5.2010_14:23:10', '1.5.2010 14:23:10', or '1.5.2010'

Definition at line 596 of file AtlRunQueryUtils.py.

596 def get_runs(start,end=None):
597  """start and end are given in the format '1.5.2010_14:23:10', '1.5.2010 14:23:10', or '1.5.2010'"""
598 
599  co = coolDbConn.GetAtlasRunDBConnection()
600  cu = co.cursor()
601 
602  #available:
603  # NAME,RUNNUMBER,STARTAT,DURATION,CREATEDBY,HOST,PARTITIONNAME,CONFIGSCHEMA,CONFIGDATA,COMMENTS
604  records = 'RUNNUMBER'
605 
606  t = time.gmtime( timeStringToSecondsUTC(start) )
607  starttime = time.strftime("%Y%m%dT%H%M%S",t)
608 
609  if not end:
610  q = "SELECT %s FROM ATLAS_RUN_NUMBER.RUNNUMBER WHERE STARTAT>'%s' ORDER BY RUNNUMBER desc" % (records,starttime)
611  else:
612  t = time.gmtime( timeStringToSecondsUTC(end) )
613  endtime = time.strftime("%Y%m%dT%H%M%S",t)
614  q = "SELECT %s FROM ATLAS_RUN_NUMBER.RUNNUMBER WHERE STARTAT>'%s' and STARTAT<'%s' ORDER BY RUNNUMBER" % (records,starttime,endtime)
615 
616  cu.arraysize=100
617  cu.execute(q)
618 
619  res = cu.fetchall()
620  return [r[0] for r in res]
621 
622 

◆ get_runs_last_dt()

def python.utils.AtlRunQueryUtils.get_runs_last_dt (   last)

Definition at line 590 of file AtlRunQueryUtils.py.

590 def get_runs_last_dt(last):
591  lt = last.replace('last','').strip()
592  nsec = durationInSeconds( lt )
593  start = time.gmtime( time.mktime(time.gmtime()) - nsec )
594  return get_runs(time.strftime("%d.%m.%Y_%H:%M:%S",start))
595 

◆ GetRanges()

def python.utils.AtlRunQueryUtils.GetRanges (   rangestr,
  intRepFnc = stringToIntOrTime,
  maxval = 1<<30 
)

Definition at line 328 of file AtlRunQueryUtils.py.

328 def GetRanges(rangestr, intRepFnc=stringToIntOrTime, maxval=1<<30):
329  if type(rangestr)==list:
330  ranges = rangestr
331  else:
332  if rangestr[:4]=='STR:':
333  return [ [rangestr[4:], rangestr[4:]] ]
334  ranges = rangestr.split(',')
335  listOfRanges = []
336  for r in ranges:
337  if r == '-':
338  listOfRanges += [[0,maxval]]
339  elif not ('-' in r or '+' in r):
340  # single value
341  x = intRepFnc(r)
342  listOfRanges += [[x,x]]
343  elif r[-1] == '+':
344  listOfRanges += [[intRepFnc(r[:-1]),maxval]]
345  elif r[-1] == '-':
346  listOfRanges += [[0,intRepFnc(r[:-1])]]
347  else:
348  startend = r.split('-')
349  if len(startend)!=2:
350  raise RuntimeError ("Range format error '%s'" % r)
351  listOfRanges += [[intRepFnc(x) for x in startend]]
352  return MergeRanges(listOfRanges)
353 
354 
355 
356 

◆ GetTimeRanges()

def python.utils.AtlRunQueryUtils.GetTimeRanges (   timeranges,
  intRepFnc = timeStringToSecondsUTC,
  maxval = 1<<30 
)

Definition at line 369 of file AtlRunQueryUtils.py.

369 def GetTimeRanges(timeranges, intRepFnc=timeStringToSecondsUTC, maxval=1<<30):
370  if type(timeranges)==list:
371  timeranges = ','.join(timeranges)
372 
373  timeranges = timeranges.split(',')
374  listOfRanges = []
375  listOfRangesHR = []
376 
377  for r in timeranges:
378  start = 0
379  end = 'inf'
380  if r == '-':
381  listOfRangesHR += [['0','inf']]
382  elif not ('-' in r or '+' in r):
383  # single value
384  start = full_time_string( r, startofday=True )
385  end = full_time_string( r, startofday=False )
386  elif r[-1] == '+':
387  start = full_time_string( r[:-1], startofday=True )
388  elif r[-1] == '-':
389  end = full_time_string( r[:-1], startofday=False )
390  else:
391  try:
392  start,end = r.split('-')
393  except ValueError:
394  raise RuntimeError ("Time format '%s' wrong, should be 'from-until'" % r)
395  start = full_time_string( start, startofday=True )
396  end = full_time_string( end, startofday=False )
397 
398  listOfRangesHR += [[start,end]]
399  start = 0 if start==0 else intRepFnc(start)
400  end = maxval if end=='inf' else intRepFnc(end)
401  listOfRanges += [[start,end]]
402 
403  return MergeRanges(listOfRanges),listOfRangesHR
404 
405 

◆ importroot()

def python.utils.AtlRunQueryUtils.importroot (   batch = True)

Definition at line 58 of file AtlRunQueryUtils.py.

58 def importroot(batch=True):
59  import sys
60  cmdline_args = sys.argv
61  sys.argv[1:]=[]
62  if batch:
63  sys.argv += ['-b']
64  import ROOT
65  ROOT.gROOT.SetBatch(batch)
66  if batch:
67  del sys.argv[1]
68  ROOT.gErrorIgnoreLevel = 2000 # to avoid printout when creating images
69  sys.argv=cmdline_args
70  return ROOT
71 
72 

◆ MergeLBRanges()

def python.utils.AtlRunQueryUtils.MergeLBRanges (   listOfRanges)

Definition at line 229 of file AtlRunQueryUtils.py.

229 def MergeLBRanges(listOfRanges):
230  listOfRanges.sort()
231  newRR=[]
232  for rr in listOfRanges:
233  if len(newRR)==0 or rr[0]>newRR[-1][1]:
234  newRR.append(copy(rr))
235  else:
236  newRR[-1] = (newRR[-1][0], max(rr[1],newRR[-1][1]) )
237  return newRR
238 

◆ MergeRanges()

def python.utils.AtlRunQueryUtils.MergeRanges (   listOfRanges)

Definition at line 217 of file AtlRunQueryUtils.py.

217 def MergeRanges(listOfRanges):
218  listOfRanges.sort()
219  newRR=[]
220  for rr in listOfRanges:
221  if len(newRR)==0 or rr[0]-1>newRR[-1][1]:
222  newRR.append(copy(rr))
223  else:
224  newRR[-1] = [newRR[-1][0], max(rr[1],newRR[-1][1]) ]
225  return newRR
226 
227 # a helper function to decode range lists and merge the intervals (like above)
228 # par: listOfRanges: [(b1,e1],(b2,e2],....,(bn,en]] -> [(b1,e2],....,(bn,en]] if b2<=e1

◆ Pileup()

def python.utils.AtlRunQueryUtils.Pileup (   args)

Definition at line 502 of file AtlRunQueryUtils.py.

502 def Pileup( args ):
503  # orbit revolution frequency
504  fOrbit = 11245.511 # [Hz] given by: 40.0790e6 Hz (bunch frequency) / 3564 (nbunches)
505 
506  if len(args) < 3:
507  return '<font color="red">ERROR: need at least 3 arguments for pileup calculation: inst.-lumi cross-section-in-mb nbunch [nevents]</font>'
508  try:
509  fstarg = float(args[0])
510  if fstarg < 1e20:
511  # input expects first two arguments to be number of protons and transverse beam size
512  nprotons = fstarg
513  sigtrans = float(args[1]) # given in microns
514  sigtrans *= 1e-4 # transform to cm
515 
516  sigma = float(args[2])
517  nbunch = float(args[3])
518  lumi = nprotons**2 * fOrbit * nbunch / (4.0 * pi * sigtrans**2)
519  nevents = 1
520  if len(args) == 5:
521  nevents = float(args[4])
522  else:
523  # input expects first argument to be luminosity in cm-2s-1
524  lumi = float(args[0])
525  sigma = float(args[1])
526  nbunch = int(args[2])
527  nevents = 1
528  if len(args) == 4:
529  nevents = int(args[3])
530 
531  # compute pileup
532  lumi_mb = lumi/1.e27 # luminosity in mb-1s-1
533  nint, plist = ComputePileup( lumi_mb, sigma, nbunch, fOrbit )
534  print("Resultat:")
535  print(" nint ",nint)
536  print(" plist ",plist)
537  referenceInfo = '7TeV: 60.3&pm;2.1 mb'
538  referenceInfo += ' [<a href="https://arxiv.org/abs/1104.0326" target="_blank" title="Measurement of the Inelastic Proton-Proton Cross Section at &sqrt;s=7 TeV with the ATLAS Detector at the LHC">arXiv:1104.0326</a>], '
539  referenceInfo += '13TeV: 78.1&pm;2.9mb'
540  referenceInfo += ' [<a href="https://arxiv.org/abs/1606.02625" target="_blank" title="Measurement of the Inelastic Proton-Proton Cross Section at &sqrt;s=13 TeV with the ATLAS Detector at the LHC">arXiv:1606.02625</a>]'
541  # create output string
542  s = ' '
543  s += '<table class="datasettable" style="font-size: 140%">'
544  s += '<tr><td>Instantaneous luminosity :</td><td> %g cm&minus;2s&minus;1 (= %g mb&minus;1s&minus;1)</td></tr>' % (lumi, lumi_mb)
545  s += '<tr><td>Inelastic cross section :</td><td> %g mb &nbsp;(%s)</td></tr>' % (sigma, referenceInfo)
546  s += '<tr><td>Number of colliding bunches :</td><td> %g</td></tr>' % nbunch
547  s += '<tr><td colspan="2"><hr style="width:100%; #999999; background-color: #999999; height:1px; margin-left:0px; border:0"></td></tr>'
548  s += '<tr><td>Inelastic interaction rate:</td><td>%g Hz</td></tr>' % (lumi_mb*sigma)
549  s += '<tr><td>Average number of interactions per crossing:&nbsp;&nbsp;</td><td> %g</td></tr>' % nint
550  s += '</table>'
551  s += '<hr style="width:100%; #999999; background-color: #999999; height:0px; border:0">\n<p>\n'
552  if nint > 100:
553  s += 'Very large pileup probability (assume Gaussian distribution): %g +- %g' % (nint, sqrt(nint))
554  else:
555  s += '<table class="pileuptable">'
556  s += '<tr><th>Num. of interactions per filled bunch crossing</th><th>Probability per filled bunch crossing</th><th>Probability per triggered minimum bias event*</th>'
557  if nevents>1:
558  s += '<th>Expected number of events in sample*</th>'
559  s += '</tr>'
560 
561  pref = 1.0-plist[0] # probability for a zero bias trigger to have triggered an event
562  psum = 0
563  for i,p in enumerate(plist):
564  if i>=1:
565  s += '<tr><td>&gt;= %i</td><td>%g</td><td>%g</td>' % (i,1.0-psum,(1.0-psum)/pref)
566  if nevents > 1:
567  nevexp = (1.0-psum)/pref*nevents
568  s += '<td> %g</td>' % (nevexp)
569  s += '</tr>'
570  if p < 1e-15:
571  break
572  psum += p
573  s += '</table><p></p>'
574  s += '<font size=-2>*assuming 100% trigger efficiency for inelastic events</font><br>'
575 
576  return s
577 
578  except ValueError:
579  return '<font color="red">ERROR: only numerical arguments allowed</font>'
580 
581 

◆ Poisson()

def python.utils.AtlRunQueryUtils.Poisson (   n,
  mu 
)

Definition at line 466 of file AtlRunQueryUtils.py.

466 def Poisson( n, mu ):
467  # only valid for small mu and integer n
468  if n < 0:
469  return 0
470  else:
471  p = exp(-mu)
472  for i in range(n):
473  p *= mu
474  p /= float(i+1)
475  return p
476 

◆ prettyNumber()

def python.utils.AtlRunQueryUtils.prettyNumber (   n,
  width = -1,
  delim = ',',
  decimal = '.' 
)
Converts a float to a string with appropriately placed commas

Definition at line 73 of file AtlRunQueryUtils.py.

73 def prettyNumber( n, width=-1, delim=',',decimal='.' ):
74  """Converts a float to a string with appropriately placed commas"""
75  if width >= 0:
76  s = "%.*f" % (width, n)
77  else:
78  s = str(n)
79  dec = s.find(decimal)
80  if dec == -1:
81  dec = len(s)
82  threes = int((dec-1)/3)
83  for i in range(threes):
84  loc = dec-3*(i+1)
85  s = s[:loc] + delim + s[loc:]
86  return s
87 

◆ runsOnServer()

def python.utils.AtlRunQueryUtils.runsOnServer ( )

Definition at line 48 of file AtlRunQueryUtils.py.

48 def runsOnServer():
49  hostname = os.getenv('HOSTNAME')
50  print ("Execution on host: %r" % hostname )
51  if not hostname:
52  onserver = False
53  else:
54  onserver = ( re.match(r'aiatlas.*\.cern\.ch',hostname) is not None )
55  print ("Execution on server: %r" % onserver)
56  return onserver
57 

◆ secondsToTimeStringLocaltime()

def python.utils.AtlRunQueryUtils.secondsToTimeStringLocaltime (   s)

Definition at line 322 of file AtlRunQueryUtils.py.

323  # convert seconds since epoch into localtime
324  return time.strftime("%d.%m.%Y %H:%M:%S",time.localtime(s))
325 
326 
327 

◆ secondsToTimeStringUTC()

def python.utils.AtlRunQueryUtils.secondsToTimeStringUTC (   s)

Definition at line 317 of file AtlRunQueryUtils.py.

318  # convert seconds since epoch into utc
319  return time.strftime("%d.%m.%Y %H:%M:%S",time.gmtime(s))
320 
321 

◆ SmartRangeCalulator()

def python.utils.AtlRunQueryUtils.SmartRangeCalulator (   runlist,
  singleRuns = True 
)

Definition at line 406 of file AtlRunQueryUtils.py.

406 def SmartRangeCalulator(runlist,singleRuns=True):
407  if len(runlist) == 0:
408  return []
409  if isinstance(runlist[0], list):
410  return runlist
411  if singleRuns:
412  rr = [[r.runNr,r.runNr] for r in runlist]
413  else:
414  rr = [[runlist[0].runNr,runlist[-1].runNr]]
415  return rr
416 
417 # code from Eric Torrence
418 # Optional argument to nval to specify number of values to read

◆ stringToIntOrTime()

def python.utils.AtlRunQueryUtils.stringToIntOrTime (   s)

Definition at line 269 of file AtlRunQueryUtils.py.

269 def stringToIntOrTime(s):
270  if re.match(r"^\d+$",s):
271  return int(s)
272  # convert the string into seconds since epoch
273 
274  # string is meant to be UTC time (hence we need calendar.timegm
275  # and not time.mktime to convert the tuple into seconds)
276  t = int(1E9*calendar.timegm(time.strptime(s,"%d.%m.%Y")))
277  #print ("turning",s,"into time",t)
278  #print ("cross-check:",time.strftime("%d.%m.%Y %H:%M:%S",time.gmtime(t/1E9)))
279  return t
280 

◆ timeStringToSecondsLocalTime()

def python.utils.AtlRunQueryUtils.timeStringToSecondsLocalTime (   t)
convert string into seconds since epoch

string is meant to be in local time (hence we use time.mktime
and not calender.timegm to convert the tuple into seconds)

format can be '1.5.2010_14:23:10', '1.5.2010 14:23:10', or '1.5.2010'

Definition at line 299 of file AtlRunQueryUtils.py.

300  """ convert string into seconds since epoch
301 
302  string is meant to be in local time (hence we use time.mktime
303  and not calender.timegm to convert the tuple into seconds)
304 
305  format can be '1.5.2010_14:23:10', '1.5.2010 14:23:10', or '1.5.2010'
306  """
307  try:
308  t = time.strptime(t,"%d.%m.%Y")
309  except ValueError:
310  try:
311  t = time.strptime(t,"%d.%m.%Y %H:%M:%S")
312  except ValueError:
313  t = time.strptime(t,"%d.%m.%Y_%H:%M:%S")
314 
315  return int(time.mktime(t))
316 

◆ timeStringToSecondsUTC()

def python.utils.AtlRunQueryUtils.timeStringToSecondsUTC (   t)
convert string into seconds since epoch

string is meant to be UTC time (hence we need calendar.timegm
and not time.mktime to convert the tuple into seconds)

format can be '1.5.2010_14:23:10', '1.5.2010 14:23:10', or '1.5.2010'

Definition at line 281 of file AtlRunQueryUtils.py.

282  """ convert string into seconds since epoch
283 
284  string is meant to be UTC time (hence we need calendar.timegm
285  and not time.mktime to convert the tuple into seconds)
286 
287  format can be '1.5.2010_14:23:10', '1.5.2010 14:23:10', or '1.5.2010'
288  """
289  try:
290  t = time.strptime(t,"%d.%m.%Y")
291  except ValueError:
292  try:
293  t = time.strptime(t,"%d.%m.%Y %H:%M:%S")
294  except ValueError:
295  t = time.strptime(t,"%d.%m.%Y_%H:%M:%S")
296 
297  return int(calendar.timegm(t))
298 

◆ unpackRun1BCIDMask()

def python.utils.AtlRunQueryUtils.unpackRun1BCIDMask (   blob,
  nb1,
  nb2,
  nbc 
)

Definition at line 432 of file AtlRunQueryUtils.py.

432 def unpackRun1BCIDMask(blob, nb1, nb2, nbc):
433  size = nb1+nb2+nbc
434  a = bConvertList(blob, 2, size)
435  beam1 = a[0:nb1]
436  beam2 = a[nb1:nb1+nb2]
437  coll = a[nb1+nb2:]
438  #print ('unpackRun1BCIDMask found:')
439  #print (' Beam1:', beam1)
440  #print (' Beam2:', beam2)
441  #print (' Coll: ', coll)
442  return beam1, beam2, coll
443 
444 

◆ unpackRun2BCIDMask()

def python.utils.AtlRunQueryUtils.unpackRun2BCIDMask (   blob)

Definition at line 445 of file AtlRunQueryUtils.py.

445 def unpackRun2BCIDMask(blob):
446  beam1=[]
447  beam2=[]
448  coll=[]
449  rawData = bConvertList(blob, 1, 3564)
450  for i in range(3564):
451  val = rawData[i]
452  if val & 0x01:
453  beam1.append(i)
454  if val & 0x02:
455  beam2.append(i)
456  if (val & 0x03) == 0x03:
457  coll.append(i)
458  #print ('unpackRun2BCIDMask found:')
459  #print (' Beam1:', beam1)
460  #print (' Beam2:', beam2)
461  #print (' Coll: ', coll)
462  return beam1, beam2, coll
463 
464 
465 

Variable Documentation

◆ coolDbConn

python.utils.AtlRunQueryUtils.coolDbConn = DBConnectionController()

Definition at line 188 of file AtlRunQueryUtils.py.

python.utils.AtlRunQueryUtils.unpackRun2BCIDMask
def unpackRun2BCIDMask(blob)
Definition: AtlRunQueryUtils.py:445
python.utils.AtlRunQueryUtils.unpackRun1BCIDMask
def unpackRun1BCIDMask(blob, nb1, nb2, nbc)
Definition: AtlRunQueryUtils.py:432
python.utils.AtlRunQueryUtils.get_runs_last_dt
def get_runs_last_dt(last)
Definition: AtlRunQueryUtils.py:590
python.utils.AtlRunQueryUtils.prettyNumber
def prettyNumber(n, width=-1, delim=',', decimal='.')
Definition: AtlRunQueryUtils.py:73
python.utils.AtlRunQueryUtils.filesize
def filesize(no)
Definition: AtlRunQueryUtils.py:198
max
#define max(a, b)
Definition: cfImp.cxx:41
python.utils.AtlRunQueryUtils.get_run_range
def get_run_range(start, end=None)
Definition: AtlRunQueryUtils.py:582
python.utils.AtlRunQueryUtils.importroot
def importroot(batch=True)
Definition: AtlRunQueryUtils.py:58
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.utils.AtlRunQueryUtils.addKommaToNumber
def addKommaToNumber(no)
Definition: AtlRunQueryUtils.py:190
python.utils.AtlRunQueryUtils.stringToIntOrTime
def stringToIntOrTime(s)
Definition: AtlRunQueryUtils.py:269
python.utils.AtlRunQueryUtils.GetTimeRanges
def GetTimeRanges(timeranges, intRepFnc=timeStringToSecondsUTC, maxval=1<< 30)
Definition: AtlRunQueryUtils.py:369
drawFromPickle.exp
exp
Definition: drawFromPickle.py:36
python.utils.AtlRunQueryUtils.runsOnServer
def runsOnServer()
Definition: AtlRunQueryUtils.py:48
python.utils.AtlRunQueryUtils.get_run_range2
def get_run_range2(start, end=None)
Definition: AtlRunQueryUtils.py:623
python.utils.AtlRunQueryUtils.durationInSeconds
def durationInSeconds(duration_string)
Definition: AtlRunQueryUtils.py:88
python.utils.AtlRunQueryUtils.bConvertList
def bConvertList(b, nbyte=1, nval=1)
Definition: AtlRunQueryUtils.py:419
python.utils.AtlRunQueryUtils.MergeRanges
def MergeRanges(listOfRanges)
Definition: AtlRunQueryUtils.py:217
python.utils.AtlRunQueryUtils.MergeLBRanges
def MergeLBRanges(listOfRanges)
Definition: AtlRunQueryUtils.py:229
python.utils.AtlRunQueryUtils.secondsToTimeStringLocaltime
def secondsToTimeStringLocaltime(s)
Definition: AtlRunQueryUtils.py:322
python.utils.AtlRunQueryUtils.checkURL
def checkURL(url)
Definition: AtlRunQueryUtils.py:28
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
python.utils.AtlRunQueryUtils.get_runs
def get_runs(start, end=None)
Definition: AtlRunQueryUtils.py:596
python.utils.AtlRunQueryUtils.secondsToTimeStringUTC
def secondsToTimeStringUTC(s)
Definition: AtlRunQueryUtils.py:317
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.utils.AtlRunQueryUtils.GetRanges
def GetRanges(rangestr, intRepFnc=stringToIntOrTime, maxval=1<< 30)
Definition: AtlRunQueryUtils.py:328
python.utils.AtlRunQueryUtils.ComputePileup
def ComputePileup(lumi_mb, sigma, nbunch, fOrbit)
Definition: AtlRunQueryUtils.py:477
python.utils.AtlRunQueryUtils.Pileup
def Pileup(args)
Definition: AtlRunQueryUtils.py:502
python.utils.AtlRunQueryUtils.timeStringToSecondsLocalTime
def timeStringToSecondsLocalTime(t)
Definition: AtlRunQueryUtils.py:299
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
python.utils.AtlRunQueryUtils.timeStringToSecondsUTC
def timeStringToSecondsUTC(t)
Definition: AtlRunQueryUtils.py:281
str
Definition: BTagTrackIpAccessor.cxx:11
calibdata.copy
bool copy
Definition: calibdata.py:27
python.utils.AtlRunQueryUtils.full_time_string
def full_time_string(s, startofday)
Definition: AtlRunQueryUtils.py:357
python.utils.AtlRunQueryUtils.SmartRangeCalulator
def SmartRangeCalulator(runlist, singleRuns=True)
Definition: AtlRunQueryUtils.py:406
readCCLHist.float
float
Definition: readCCLHist.py:83
python.utils.AtlRunQueryUtils.Poisson
def Poisson(n, mu)
Definition: AtlRunQueryUtils.py:466