File indexing completed on 2024-11-25 02:29:11
0001
0002
0003 """ Helper functions for time conversions """
0004
0005 def pack(high,low):
0006 """pack high,low 32bit unsigned int to one unsigned 64bit long long
0007 Note:the print value of result number may appear signed, if the sign bit is used.
0008 """
0009 h=high<<32
0010 return (h|low)
0011
0012 def secondsFromString(i):
0013 """convert from a string in the format output from timeStamptoDate to a 32bit seconds from the epoch.
0014 The format accepted is \"DD/MM/YYYY HH:MM:SS\". The year must be the full number.
0015 """
0016 import time
0017 return int(time.mktime(time.strptime(i, "%d/%m/%Y %H:%M:%S")))
0018
0019 def packFromString(i):
0020 """pack from a string in the format output from timeStamptoUTC to a 64bit timestamp
0021 the format accepted is \"DD/MM/YYYY HH:MM:SS\" . The year must be the full number.
0022 """
0023 return pack(secondsFromString(i), 0)
0024
0025 def intervalSinceEpoch(i):
0026 """ compute the interval of time is seconds since the Epoch and return the packed 64bit value.
0027 """
0028 return( packFromString(i) - packFromString("01/01/1970 00:00:00") )
0029
0030 def unpack(i):
0031 """unpack 64bit unsigned long long into 2 32bit unsigned int, return tuple (high,low)
0032 """
0033 high=i>>32
0034 low=i&0xFFFFFFFF
0035 return(high,low)
0036
0037 def timeStamptoDate(i):
0038 """convert 64bit timestamp to local date in string format
0039 """
0040 import time
0041 return time.ctime(unpack(i)[0])
0042
0043 """ This script does the following:
0044 1- reads the list of iovs (by timestamp) in a sqlite file
0045 2- creates a cfg for each iov and runs them
0046 3- takes the output of each job and builds a single output with the content of each iov
0047 It is recommended to redirect the output to a file.
0048 """
0049
0050 import os
0051 import re
0052 import sys
0053
0054
0055 if len(sys.argv) < 3:
0056 print("Please provide the name of the sqlite file and the tag as in: ", end=' ')
0057 print("./CheckAllIOVs.py Example1a.db SiStripDetVOff_Fake_31X")
0058 sys.exit(1)
0059
0060 print("Reading all IOVs")
0061
0062
0063
0064
0065 database = sys.argv[1]
0066 iovs = os.popen("cmscond_list_iov -c sqlite_file:"+database+" -t "+sys.argv[2])
0067 iovsList = iovs.read()
0068 splittedList = re.split("payloadToken",iovsList)
0069 splittedList = re.split("Total",splittedList[1])
0070 splittedList = re.split("\[DB|\]\[.*\]\[.*\]\[.*\]\[.*\]", splittedList[0])
0071
0072 for i in range(0, len(splittedList), 2):
0073
0074 iov = re.split(" ", splittedList[i])
0075 if len(iov) > 1:
0076 start = iov[0].strip("\n")
0077 end = iov[2].strip("\n")
0078
0079
0080
0081 startDate = timeStamptoDate(int(start))
0082 endDate = timeStamptoDate(int(end))
0083 if end == "18446744073709551615":
0084 end = str(int(start) + 1)
0085 print("start date = ", startDate, end=' ')
0086 print(", end date = ", endDate)
0087 fullDates="_FROM_"+startDate.replace(" ", "_").replace(":", "_")+"_TO_"+endDate.replace(" ", "_").replace(":", "_")
0088 fileName="DetVOffPrint"+fullDates+"_cfg.py"
0089 os.system("cat templateCheckAllIOVs_cfg.py | sed -e \"s/STARTTIME/"+start+"/g\" | sed -e \"s/ENDTIME/"+end+"/g\" | sed -e \"s/DATE/"+fullDates+"/g\" | sed -e \"s/DATABASE/sqlite_file:"+database+"/g\" > "+fileName)
0090
0091 os.system("cmsRun "+fileName+" > /dev/null")
0092
0093 for line in open("DetVOffReaderDebug_"+fullDates+".log", "r"):
0094 if "IOV" in line or "OFF" in line or "ON" in line:
0095 print(line.strip("\n"))
0096
0097
0098
0099
0100
0101
0102
0103