File indexing completed on 2024-04-06 12:01:54
0001 """Some helper classes to convert conditions time units back and forth
0002 """
0003 def pack(high,low):
0004 """pack high,low 32bit unsigned int to one unsigned 64bit long long
0005 Note:the print value of result number may appear signed, if the sign bit is used.
0006 """
0007 h=high<<32
0008 return (h|low)
0009
0010 def packToString(high,low):
0011 """pack high,low 32bit unsigned int to one unsigned 64bit long long in string format
0012 Note:the print value of result number may appear signed, if the sign bit is used.
0013 """
0014 fmt="%u"
0015 return fmt%pack(high,low)
0016
0017 def unpack(i):
0018 """unpack 64bit unsigned long long into 2 32bit unsigned int, return tuple (high,low)
0019 """
0020 high=i>>32
0021 low=i&0xFFFFFFFF
0022 return(high,low)
0023
0024 def unpackFromString(i):
0025 """unpack 64bit unsigned long long in string format into 2 32bit unsigned int, return tuple(high,low)
0026 """
0027 return unpack(int(i))
0028
0029 def timeStamptoDate(i):
0030 """convert 64bit timestamp to local date in string format
0031 """
0032 import time
0033 return time.ctime(unpack(i)[0])
0034
0035 def timeStamptoUTC(i):
0036 """convert 64bit timestamp to Universal Time in string format
0037 """
0038 t=unpack(i)[0]
0039 import time
0040 return time.strftime("%a, %d %b %Y %H:%M:%S +0000",time.gmtime(t))
0041
0042 def unpackLumiid(i):
0043 """unpack 64bit lumiid to dictionary {'run','lumisection'}
0044 """
0045 j=unpack(i)
0046 return {'run':j[0],'lumisection':j[1]}