5 from PyCool
import cool
11 vec=getattr(ROOT,
'vector<float>')
12 vecvec=getattr(ROOT,
'vector<vector<float> >')
16 gainDefVec.push_back(defaultValue)
18 defVec.push_back(gainDefVec)
23 if len(valuePairs)>nLArChannels:
24 nChannels=nAllChannels
26 nChannels=nLArChannels
30 print (
"Build CaloCondBlob object")
31 data = cool.Record( spec )
32 blob = data[
'CaloCondBlob16M']
33 fltClass=ROOT.CaloCondBlobFlt
34 flt=fltClass.getInstance(blob)
35 flt.init(defVec,nChannels,1)
37 print (
"Filling CaloCondBlob object")
39 dvec.push_back(defaultValue)
44 for (hashid,value)
in valuePairs:
46 print (
"ERROR: Invalid hash id",hashid)
49 if hashid
in foundChans:
50 print (
"WARNING: Channel with hash",hashid,
"encountered twice!")
52 foundChans.add(hashid)
55 flt.setData(hashid,0,dvec)
58 if len(foundChans)<nChannels:
59 print (
"WARNING No values found for",nChannels-len(foundChans),
"channels. Left at default value",defaultValue)
71 beforecomment=line.split(
'#')[0].strip()
72 if len(beforecomment)==0:
75 tok=beforecomment.split()
77 print (
"ERROR: Unexpected syntax:", line)
84 print (
"ERROR: Expected numbers, got",tok[0],tok[1] )
87 fromfile.append((h,v))
96 def createSqlite(sqliteName,folderName,foldertag,iovMin=cool.ValidityKeyMin,iovMax=cool.ValidityKeyMax,inputFileName=None,defaultvalue=1.0):
98 dbSvc = cool.DatabaseSvcFactory.databaseService()
100 if os.access(sqliteName,os.R_OK):
101 print (
"UPDATING existing sqlite file",sqliteName)
102 db=dbSvc.openDatabase(
"sqlite://;schema="+sqliteName+
";dbname=CONDBR2",
False)
104 print (
"Creating new sqlite file",sqliteName)
105 db=dbSvc.createDatabase(
"sqlite://;schema="+sqliteName+
";dbname=CONDBR2")
108 spec = cool.RecordSpecification()
109 spec.extend(
'CaloCondBlob16M', cool.StorageType.Blob16M )
111 desc=
'<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type="71" clid="40774348" /></addrHeader><typeName>AthenaAttributeList</typeName>'
113 if db.existsFolder(folderName):
114 folder=db.getFolder(folderName)
116 print (
"Creating COOL folder/tag %s/%s" % (folderName,foldertag))
118 folderSpec = cool.FolderSpecification(cool.FolderVersioning.MULTI_VERSION, spec)
119 folder = db.createFolder(folderName, folderSpec, desc,
True)
122 if inputFileName
is None or len(inputFileName)==0:
123 print (
"No input given. Create empty blob")
124 data = cool.Record(spec)
128 print (
"Storing CaloCondBlob object")
129 folder.storeObject(iovMin, iovMax, data, cool.ChannelId(0), foldertag,
True)