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