397 since, until=(MAXRUN,MAXLBK), untilCmt=None, moduleList=[]):
398 """
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
405 """
406
407 try:
408 if not db.isOpen():
409 raise Exception ("DB not open: ", db.databaseId())
410 except Exception as e:
411 raise( e )
412
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)
417 nUpdates = 0
418 goodComment = True
419
420 if moduleList!=['CMT']:
421 if since != (MINRUN,MINLBK):
422 justBefore = list(since)
423 if justBefore[1]>MINLBK:
424 justBefore[1] = justBefore[1]-1
425 else:
426 justBefore[0] = justBefore[0]-1
427 justBefore[1] = MAXLBK
428 justBefore = tuple(justBefore)
429 if self.__mode!=2:
430 self.log().info("Reading db state just before %s, i.e. at %s", since,justBefore)
431 self.__updateFromDb(db, folderPath, tag, justBefore, 0)
432 else:
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")
435 else:
436 if self.__mode!=2:
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))
441
442
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] )
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 and (len(moduleList)==0 or modName not in moduleList or 'ALL' not in moduleList):
472
473 continue
474 if nChange==-1:
475 nUpdates += 1
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):
478 goodComment = False
479 self.log().
error(
"Comment string - '%s' - doesn't contain drawer %s", comment,modName)
480 writer.zeroBlob(ros,mod)
481 else:
482 nUpdates += 1
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):
485 goodComment = False
486 self.log().
error(
"Comment string - '%s' - doesn't contain drawer %s", comment,modName)
487 drawer = writer.getDrawer(ros,mod)
490
491 wordsLo = bchDecoder.encode(self.getAdcStatus(ros,mod,chn,0))
492 chBits = wordsLo[0]
493 loBits = wordsLo[1]
494
495 wordsHi = bchDecoder.encode(self.getAdcStatus(ros,mod,chn,1))
496 chBits = wordsHi[0] | chBits
497 hiBits = wordsHi[1]
498
499 drawer.setData(chn,0,0, loBits)
500 drawer.setData(chn,1,0, hiBits)
501 drawer.setData(chn,2,0, chBits)
502
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)
511
512
513 if nUpdates>0 or moduleList==['CMT']:
514 if goodComment:
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)
519 if untilCmt>since:
520 writer.register(since,untilCmt,tag,-1)
521 else:
522 writer.register(since,until,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.