2 from PyCool
import cool
3 from CoolConvUtilities
import AtlCoolLib
6 sys.path.append(
'/afs/cern.ch/user/a/atlcond/utils/python/')
13 p = argparse.ArgumentParser()
14 p.add_argument(
'-f',
'--input_file', type=str, help=
'Please type the path to the input file!',default=
'000000')
15 p.add_argument(
'-r',
'--run', type=int, help=
'Please type the runnumber!',default=
'000000')
17 print(
"Input file: ",args.input_file)
18 print(
"Run number: ",args.run)
20 dbFile =
'PixelModuleFeMask_run'+
str(args.run)+
'.db'
22 path=
'/PIXEL/PixelModuleFeMask'
23 tag =
'PixelModuleFeMask-RUN2-DATA-UPD4-05'
24 print(
"Tag for database: ",tag)
26 if os.path.isfile(dbFile):
30 dbSvc = cool.DatabaseSvcFactory.databaseService()
31 dbString =
"sqlite://;schema=%s;dbname=%s" % (dbFile, dbName)
33 db = dbSvc.createDatabase(dbString)
35 print(
'Problem creating database', e)
37 print (
"Created database", dbString)
39 spec = cool.RecordSpecification()
40 spec.extend(
'data_array', cool.StorageType.String16M)
41 desc =
'<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type="71" clid="1238547719" /></addrHeader><typeName>CondAttrListCollection</typeName>'
42 folderSpec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, spec)
43 folder = db.createFolder(path, folderSpec, desc,
True)
44 data = cool.Record(spec)
46 input_file =
open(args.input_file,
'r')
47 nModules =
sum(1
for line
in input_file)
50 input_file =
open(args.input_file,
'r')
51 input_list=[[0
for x
in range(4)]
for y
in range(nModules)]
53 for line
in input_file:
54 input_list[iterator] =
list(map(int, line.split()[0:4]))
58 input_list =
sorted(input_list, key=
lambda x: x[0])
60 runnumber_large=args.run << 32
61 iov_start_min=100000000000000000000
67 for k
in range(10000):
68 input_file =
open(args.input_file,
'r')
71 for i
in range(nModules):
72 module=input_list[i][0]
73 FEcode=input_list[i][1]
74 iov_start=input_list[i][2]
75 iov_end=input_list[i][3]
77 if (iov_start<=runnumber_large+k
and iov_end>=runnumber_large+k)
or (iov_start==0
and iov_end==0):
78 if(module_old==module):
79 if module==input_list[i-1][0]
and FEcode!=0:
83 remove=
'"'+
str(module_old)+
'":'+
str(FE_code_old)+
","
84 payload=payload.replace(remove,
"")
89 payload=payload+
'"'+
str(module)+
'":'+
str(FEcode)+
','
90 if iov_start<iov_start_min
and iov_start!=0:
91 iov_start_min=iov_start
92 if iov_end>iov_end_max:
95 payload=
"{"+payload+
"}"
96 payload_list.append(payload)
98 iov_end_max=iov_end_max-runnumber_large
99 iov_start_min=iov_start_min-runnumber_large
104 print(iov_end_max,iov_start_min, runnumber_large)
105 for k
in range(1000000):
106 if(k>=iov_start_min
and k<=iov_end_max):
107 if(k==iov_start_min):
108 since=runnumber_large+k
110 if (payload_list[k]==payload_list[k+1]):
111 if(since_bool==
False):
112 since = runnumber_large+k
116 until = runnumber_large+k+1
117 data[
'data_array'] = payload_list[k]
118 folder.storeObject(since,until,data,channel,tag)
120 if(since_bool==
False):
121 since = runnumber_large+k+1