8 from __future__
import print_function
10 __version__ =
"$Id: LArHVMapDbFiller.py"
14 from PyCool
import cool
26 A simple class used to fill SQLite db file with parameters for simulation
42 print (
" setBegin run,lumi ",run)
48 print (
"setEnd runmlumi ",run)
66 self.
Params[
'LArHVMap'] = value
71 dbFileName =
'HVmap.db'
73 folderPath =
'/LAR/IdentifierOfl/HVLineToElectrodeMap'
76 raise LArHVMapDbFillerError (
'Must set begin run number before generating db')
78 self.
endTime = cool.ValidityKeyMax
80 raise LArHVMapDbFillerError (
'Must give an input file for LArHVToElectrode.data')
82 raise LArHVMapDbFillerError (
'Must give a folder tag')
87 raise LArHVMapDbFillerError (
'No parameters for db ' + dbName)
92 print (
"LArHVMapDbFiller.genDb: Removed db", dbFileName)
97 dbSvc=cool.DatabaseSvcFactory.databaseService()
100 dbstring=
"sqlite://;schema=" + dbFileName +
";dbname=" + dbName
102 db=dbSvc.createDatabase(dbstring)
103 except Exception
as e:
104 print (
'LArHVMapDbFiller.genDb: Problem creating database',e)
106 print (
"LArHVMapDbFiller.genDb: Created database",dbstring)
109 spec=cool.RecordSpecification()
111 spec.extend(key, cool.StorageType.String16M)
114 desc=
'<timeStamp>run-lumi</timeStamp><addrHeader><address_header service_type="71" clid="40774348" /></addrHeader><typeName>AthenaAttributeList</typeName>'
119 myfolder=db.createFolder(folderPath, spec, desc, cool.FolderVersioning.MULTI_VERSION,
True)
121 data=cool.Record(spec)
122 for k, v
in six.iteritems (self.
Params):
125 print (
"LArHVMapDbFiller.genDb: Recording parameters", data)
129 print (
"LArHVMapDbFiller.genDb: Stored object")
139 print (
"LArHVMapDbFiller.dumpDb: Dumping database:", dbstring)
141 dbSvc = cool.DatabaseSvcFactory.databaseService()
144 db = dbSvc.openDatabase(dbstring,
False)
145 except Exception
as e:
146 print (
'LArHVMapDbFiller.dumpDb: Problem opening database',e)
150 folders = db.listAllNodes()
155 print (
"LArHVMapDbFiller.dumpDb: Dumping folder " +
str(ff))
167 nobjs = f.countObjects( cool.ValidityKeyMin,
169 cool.ChannelSelection.all())
171 print (
"LArHVMapDbFiller.dumpDb: number of IOV payloads", nobjs)
173 objs = f.browseObjects( cool.ValidityKeyMin,
175 cool.ChannelSelection.all())
177 while objs.goToNext():
178 obj = objs.currentRef()
179 print (
"LArHVMapDbFiller.dumpDb: Payload", i,)
180 print (
"since [r,l]: [", obj.since() ,
']',)
181 print (
"until [r,l]: [", obj.until() ,
']',)
182 print (
"payload", obj.payload(),)
183 print (
"chan",obj.channelId() )