408 since, moduleList=[]):
409 """
410 Commits the differences compared to the set of bad channels read in with the
411 initialze function to the provided database.
412 - author : author name (string)
413 - comment : a comment (string)
414 - sinceRun, sinceLbk : start of IOV for which bad channels are valid
415 """
416
417 writer = TileBlobWriterCrest(db,folderPath,'Bch')
418 if len(comment) or isinstance(author,tuple):
419 writer.setComment(author, comment)
420 nUpdates = 0
421 goodComment = True
422
423 if moduleList!=['CMT']:
424 if since != (MINRUN,MINLBK):
425 justBefore = list(since)
426 if justBefore[1]>MINLBK:
427 justBefore[1] = justBefore[1]-1
428 else:
429 justBefore[0] = justBefore[0]-1
430 justBefore[1] = MAXLBK
431 justBefore = tuple(justBefore)
432 if self.__mode!=2:
433 self.log().info("Reading db state just before %s, i.e. at %s", since,justBefore)
434 self.__updateFromDb(None, folderPath, tag, justBefore, 0)
435 else:
436 self.log().info("Using previous bad channel list from input DB")
437 self.log().info("And comparing it with new list of bad channels")
438 else:
439 self.log().info("Filling db from %s, resetting old status cache", list(since))
441
442
443 self.log().info("Committing changes to DB \'%s\'", db)
444 self.log().info("... using tag \'%s\' and [run,lumi] [%i,%i]",
445 tag,since[0],since[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] )
449 else:
450 self.log().info("... author : \'%s\'", author )
451 self.log().info("... comment: \'%s\'", comment )
452
453
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)
464
465
470 nChange = self.checkModuleForChanges(ros,mod)
471 if nChange == 0:
472 if (modName in moduleList or 'ALL' in moduleList):
473
474 drawerR = self.__reader.getDrawer(ros, mod, None, False, False)
475 if drawerR:
476 writer.getDrawer(ros,mod,drawerR)
477 else:
478 writer.zeroBlob(ros,mod)
479 continue
480 if nChange==-1:
481 nUpdates += 1
482 self.log().info("Drawer %s reset to GOOD", modName)
483 if modName not in comment and ("ONL" not in folderPath or "syncALL" not in comment):
484 goodComment = False
485 self.log().
error(
"Comment string - '%s' - doesn't contain drawer %s", comment,modName)
486 writer.zeroBlob(ros,mod)
487 else:
488 nUpdates += 1
489 self.log().info("Applying %2i changes to drawer %s", nChange,modName)
490 if modName not in comment and ("ONL" not in folderPath or "syncALL" not in comment):
491 goodComment = False
492 self.log().
error(
"Comment string - '%s' - doesn't contain drawer %s", comment,modName)
493 drawer = writer.getDrawer(ros,mod)
496
497 wordsLo = bchDecoder.encode(self.getAdcStatus(ros,mod,chn,0))
498 chBits = wordsLo[0]
499 loBits = wordsLo[1]
500
501 wordsHi = bchDecoder.encode(self.getAdcStatus(ros,mod,chn,1))
502 chBits = wordsHi[0] | chBits
503 hiBits = wordsHi[1]
504
505 drawer.setData(chn,0,0, loBits)
506 drawer.setData(chn,1,0, hiBits)
507 drawer.setData(chn,2,0, chBits)
508
509 if wordsLo[0] != chBits:
510 self.log().info("Drawer %s ch %2d - sync LG status with HG ", modName,chn)
512 self.setAdcStatus(ros,mod,chn,0,status)
513 if wordsHi[0] != chBits:
514 self.log().info("Drawer %s ch %2d - sync HG status with LG ", modName,chn)
516 self.setAdcStatus(ros,mod,chn,1,status)
517
518
519 if nUpdates>0 or moduleList==['CMT']:
520 if goodComment:
521 self.log().info("Attempting to register %i modified drawers..." , nUpdates)
522 writer.register(since,tag)
523 else:
524 self.log().
error(
"Aborting update due to errors in comment string")
525 else:
526 self.log().warning("No drawer modifications detected, ignoring commit request")
527
528
static std::string getDrawerString(unsigned int ros, unsigned int drawer)
Return the drawer name, e.g.