test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
timeUnitHelper.py
Go to the documentation of this file.
1 """Some helper classes to convert conditions time units back and forth
2 """
3 def pack(high,low):
4  """pack high,low 32bit unsigned int to one unsigned 64bit long long
5  Note:the print value of result number may appear signed, if the sign bit is used.
6  """
7  h=high<<32
8  return (h|low)
9 
10 def packToString(high,low):
11  """pack high,low 32bit unsigned int to one unsigned 64bit long long in string format
12  Note:the print value of result number may appear signed, if the sign bit is used.
13  """
14  fmt="%u"
15  return fmt%pack(high,low)
16 
17 def unpack(i):
18  """unpack 64bit unsigned long long into 2 32bit unsigned int, return tuple (high,low)
19  """
20  high=i>>32
21  low=i&0xFFFFFFFF
22  return(high,low)
23 
25  """unpack 64bit unsigned long long in string format into 2 32bit unsigned int, return tuple(high,low)
26  """
27  return unpack(int(i))
28 
30  """convert 64bit timestamp to local date in string format
31  """
32  import time
33  return time.ctime(unpack(i)[0])
34 
36  """convert 64bit timestamp to Universal Time in string format
37  """
38  t=unpack(i)[0]
39  import time
40  return time.strftime("%a, %d %b %Y %H:%M:%S +0000",time.gmtime(t))
41 
42 def unpackLumiid(i):
43  """unpack 64bit lumiid to dictionary {'run','lumisection'}
44  """
45  j=unpack(i)
46  return {'run':j[0],'lumisection':j[1]}
return(e1-e2)*(e1-e2)+dp *dp