396 def commitToDb(self, db, folderPath, tag, bitPatVer, author, comment,
397 since, until=(MAXRUN,MAXLBK), untilCmt=
None, moduleList=[]):
399 Commits the differences compared to the set of bad channels read in with the
400 initialze function to the provided database.
401 - author : author name (string)
402 - comment : a comment (string)
403 - sinceRun, sinceLbk : start of IOV for which bad channels are valid
404 - untilRun, untilLbk : end of IOV for which bad channels are valid
409 raise Exception (
"DB not open: ", db.databaseId())
410 except Exception
as e:
413 multiVersion = self.__multiVersion
414 writer = TileCalibTools.TileBlobWriter(db,folderPath,
'Bch',multiVersion)
415 if len(comment)
or isinstance(author,tuple):
416 writer.setComment(author, comment)
420 if moduleList!=[
'CMT']:
421 if since != (MINRUN,MINLBK):
422 justBefore =
list(since)
423 if justBefore[1]>MINLBK:
424 justBefore[1] = justBefore[1]-1
426 justBefore[0] = justBefore[0]-1
427 justBefore[1] = MAXLBK
428 justBefore = tuple(justBefore)
430 self.log().
info(
"Reading db state just before %s, i.e. at %s", since,justBefore)
431 self.__updateFromDb(db, folderPath, tag, justBefore, 0)
433 self.log().
info(
"Using previous bad channel list from input DB")
434 self.log().
info(
"And comparing it with new list of bad channels")
437 reader = TileCalibTools.TileBlobReader(db,folderPath,tag)
438 multiVersion = reader.folderIsMultiVersion()
439 self.log().
info(
"Filling db from %s, resetting old status cache",
list(since))
443 self.log().
info(
"Committing changes to DB \'%s\'", db.databaseId())
444 self.log().
info(
"... using tag \'%s\' and [run,lumi] range: [%i,%i] - [%i,%i]",
445 tag,since[0],since[1],until[0],until[1])
446 if isinstance(author,tuple)
and len(author)==3:
447 self.log().
info(
"... author : \'%s\'", author[0] )
448 self.log().
info(
"... comment: \'%s\'", author[1] )
450 self.log().
info(
"... author : \'%s\'", author )
451 self.log().
info(
"... comment: \'%s\'", comment )
454 loGainDefVec = cppyy.gbl.std.vector(
'unsigned int')()
455 loGainDefVec.push_back(0)
456 hiGainDefVec = cppyy.gbl.std.vector(
'unsigned int')()
457 hiGainDefVec.push_back(0)
458 comChnDefVec = cppyy.gbl.std.vector(
'unsigned int')()
459 comChnDefVec.push_back(0)
460 defVec = cppyy.gbl.std.vector(
'std::vector<unsigned int>')()
461 defVec.push_back(loGainDefVec)
462 defVec.push_back(hiGainDefVec)
463 defVec.push_back(comChnDefVec)
470 nChange = self.checkModuleForChanges(ros,mod)
471 if nChange == 0
and (len(moduleList)==0
or modName
not in moduleList
or 'ALL' not in moduleList):
476 self.log().
info(
"Drawer %s reset to GOOD", modName)
477 if modName
not in comment
and (
"ONL" not in folderPath
or "syncALL" not in comment):
479 self.log().
error(
"Comment string - '%s' - doesn't contain drawer %s", comment,modName)
480 writer.zeroBlob(ros,mod)
483 self.log().
info(
"Applying %2i changes to drawer %s", nChange,modName)
484 if modName
not in comment
and (
"ONL" not in folderPath
or "syncALL" not in comment):
486 self.log().
error(
"Comment string - '%s' - doesn't contain drawer %s", comment,modName)
487 drawer = writer.getDrawer(ros,mod)
491 wordsLo = bchDecoder.encode(self.getAdcStatus(ros,mod,chn,0))
495 wordsHi = bchDecoder.encode(self.getAdcStatus(ros,mod,chn,1))
496 chBits = wordsHi[0] | chBits
499 drawer.setData(chn,0,0, loBits)
500 drawer.setData(chn,1,0, hiBits)
501 drawer.setData(chn,2,0, chBits)
503 if wordsLo[0] != chBits:
504 self.log().
info(
"Drawer %s ch %2d - sync LG status with HG ", modName,chn)
506 self.setAdcStatus(ros,mod,chn,0,status)
507 if wordsHi[0] != chBits:
508 self.log().
info(
"Drawer %s ch %2d - sync HG status with LG ", modName,chn)
510 self.setAdcStatus(ros,mod,chn,1,status)
513 if nUpdates>0
or moduleList==[
'CMT']:
515 self.log().
info(
"Attempting to register %i modified drawers..." , nUpdates)
516 if untilCmt
is not None and untilCmt!=until:
517 if moduleList!=[
'CMT']
and until>since:
518 writer.register(since,until,tag,1)
520 writer.register(since,untilCmt,tag,-1)
522 writer.register(since,until,tag)
524 self.log().
error(
"Aborting update due to errors in comment string")
526 self.log().warning(
"No drawer modifications detected, ignoring commit request")