11 from PyCool
import cool
12 from TileCalibBlobPython
import TileCalibTools, TileCalibLogger
21 ofcDataPath =
"/afs/cern.ch/user/t/tiledaq/public/tilercd/tile-7.1.0.0/TileDSPofc/share/"
22 ofcFiles = [ofcDataPath+
'W_OF2_PHYSICS_7s.dat',
23 ofcDataPath+
'W_OF1_PHYSICS_7s.dat',
24 ofcDataPath+
'W_OF2_LED_7s.dat',
25 ofcDataPath+
'W_OF1_LED_7s.dat',
26 ofcDataPath+
'W_OF2_CIS_7s.dat',
27 ofcDataPath+
'W_OF1_CIS_7s.dat']
29 re_fileName = re.compile(
"W_(OF\\d)_(.*)_7s\\.dat")
32 iovSince = cool.ValidityKeyMin
33 iovUntil = cool.ValidityKeyMax
36 comment =
"OFC weights (7 samples) imported from TileDSPofc v4r1p4"
48 log = TileCalibLogger.getLogger(
"WriteOfc")
51 db = TileCalibTools.openDb(
'SQLITE',
'CONDBR2',
'UPDATE')
53 spec = cool.RecordSpecification()
55 spec.extend(
'TileCalibBlobOfc', cool.StorageType.Blob16M )
57 folderMode = cool.FolderVersioning.SINGLE_VERSION
58 folderSpec = cool.FolderSpecification(folderMode, spec)
61 for fileName
in [ofcFiles[0]]:
62 log.info(
"Reading file: %s", fileName )
65 fileNameParts = re_fileName.search(fileName).
groups()
66 ofMethod = fileNameParts[0]
67 ofRun = fileNameParts[1][:3]
71 objVersion =
int(ofMethod[2])
72 folderPath = TileCalibTools.getTilePrefix(
False)+
"FILTER/"+ofMethod+
"/"+ofRun
73 log.info(
"Filling COOL folder %s", folderPath )
74 desc = TileCalibTools.getAthenaFolderDescr()
75 folder = db.createFolder(folderPath, folderSpec, desc,
True)
78 for chan
in range(276):
80 data = cool.Record( spec )
81 blob = data[
'TileCalibBlobOfc']
87 drawerOfc = g.TileCalibDrawerOfc.getInstance(blob,objVersion,7,-2001,1,2)
89 phases = g.std.vector(
'float')()
90 for phase
in range(-1000,1001):
91 phases.push_back(phase/10.)
92 drawerOfc.setPhases(0,0,phases)
99 lines =
open(fileName,
"r").readlines()
104 raise Exception(
"Phase out of range: %i" % phase)
111 raise Exception (
"OF1, but len(ofc)=%i" % len(ofc))
112 drawerOfc.setOfc(drawerOfc.FieldA,channel,adc,phaseF,sample,
float(ofc[0]))
113 drawerOfc.setOfc(drawerOfc.FieldB,channel,adc,phaseF,sample,
float(ofc[1]))
114 drawerOfc.setOfc(drawerOfc.FieldG,channel,adc,phaseF,sample,
float(ofc[2]))
117 raise Exception (
"OF2, but len(ofc)=%i" % len(ofc))
118 drawerOfc.setOfc(drawerOfc.FieldA,channel,adc,phaseF,sample,
float(ofc[0]))
119 drawerOfc.setOfc(drawerOfc.FieldB,channel,adc,phaseF,sample,
float(ofc[1]))
120 drawerOfc.setOfc(drawerOfc.FieldC,channel,adc,phaseF,sample,
float(ofc[2]))
121 drawerOfc.setOfc(drawerOfc.FieldG,channel,adc,phaseF,sample,
float(ofc[3]))
123 raise Exception (
"Impossible objVersion: %i" % objVersion)
135 channelId = cool.ChannelId(chan)
136 folder.storeObject(iovSince, iovUntil, data, channelId)
140 data = cool.Record( spec )
141 blob = data[
'TileCalibBlobOfc']
142 cmt = g.TileCalibDrawerCmt.getInstance(blob,author,comment)
143 channelId = cool.ChannelId(g.TileCalibUtils.getCommentChannel())
144 folder.storeObject(iovSince, iovUntil, data, channelId)