def GetBadLBFilterTool(name, defects, alwaysReturnTrue=False, ignoreRecoverable=False, autoconfigure=True, origDbTag=None): """ Configure an instance of the bad LB filter tool. If called twice with the same options, will return the same instance. Arguments: - name: name of instance to create - defects: the defects to use for LB rejection. Tool will return false if any of these defects is present. These may be virtual defects. NOTE: the value you pass must be a 'hashable' type. The best choice is to pass a tuple; you can create a tuple from any iterable object with tuple(obj). - alwaysReturnTrue (optional; default=False): if True, the tool will never reject any LBs. - ignoreRecoverable (optional; default=False): if True, the tool will ignore defects that are marked as recoverable - autoconfigure (optional; default=True): automatically handle certain cases, e.g. Monte Carlo, where we want to always return True - origDbTag (optional): if set, will override automatic configuration of database tag (only for testing) """ import operator from AthenaMonitoring.DQMonFlags import DQMonFlags from AthenaCommon.GlobalFlags import globalflags from AthenaCommon.AppMgr import ToolSvc from AthenaCommon.Logging import logging log = logging.getLogger('BadLBFilterTool') # if online or MC, we don't want to do any filtering, or even access # the DBs if autoconfigure and (DQMonFlags.monManEnvironment == 'online' or globalflags.DataSource.get_Value() == 'geant4' ): log.info('Disabling bad LB filter tool due to inappropriate environment; returning dummy') from AthenaMonitoring.AthenaMonitoringConf import DQDummyFilterTool monFilterTool = DQDummyFilterTool(name) ToolSvc += monFilterTool return monFilterTool from AthenaMonitoring.AthenaMonitoringConf import DQBadLBFilterTool from DQDefects import DefectsDB dbtag = _resolve_db_tag(origDbTag) dbname=_InstanceFromProjectName() ddb = DefectsDB('COOLOFL_GLOBAL/' + dbname, tag=dbtag) primary_defects = set() for defect in defects: if defect in ddb.defect_names: primary_defects.add(defect) elif defect in ddb.virtual_defect_names: primary_defects |= ddb.virtual_defect_logics(defect).primary_defects else: raise ValueError('%s is not a known defect' % defect) log.info ("Tool name %s to be configured with intolerable defects %s" % (name, list(primary_defects))) primary_defect_ids = [ddb.defect_id_map[id] for id in primary_defects] monFilterTool = DQBadLBFilterTool(name) monFilterTool.defectList = primary_defect_ids monFilterTool.alwaysReturnTrue = alwaysReturnTrue monFilterTool.ignoreRecoverable = ignoreRecoverable if globalflags.DataSource.get_Value() != 'geant4': from IOVDbSvc.CondDB import conddb if not conddb.folderRequested('/GLOBAL/DETSTATUS/DEFECTS'): conddb.addFolder('GLOBAL_OFL', '/GLOBAL/DETSTATUS/DEFECTS') ToolSvc += monFilterTool return monFilterTool
def BadLBFilterAlgCfg(inputFlags,name, defects, writekey, ignoreRecoverable=False, origDbTag=None): log = logging.getLogger('BadLBFilterAlgCfg') result=ComponentAccumulator() from DQDefects import DefectsDB ddb = DefectsDB('COOLOFL_GLOBAL/' + inputFlags.IOVDb.DatabaseInstance, tag=origDbTag or inputFlags.IOVDb.GlobalTag) primary_defects = set() for defect in defects: if defect in ddb.defect_names: primary_defects.add(defect) elif defect in ddb.virtual_defect_names: primary_defects |= ddb.virtual_defect_logics(defect).primary_defects else: raise ValueError('%s is not a known defect' % defect) log.info ("Algorithm %s configured with intolerable defects %s" % (name, list(primary_defects))) primary_defect_ids = [ddb.defect_id_map[id] for id in primary_defects] monFilterAlg =CompFactory.DQBadLBFilterAlg(name) monFilterAlg.defectList = primary_defect_ids monFilterAlg.ignoreRecoverable = ignoreRecoverable monFilterAlg.WriteKey = writekey from IOVDbSvc.IOVDbSvcConfig import addFolders if not inputFlags.Input.isMC: result.merge(addFolders(inputFlags,'/GLOBAL/DETSTATUS/DEFECTS',detDb='GLOBAL_OFL',className='CondAttrListCollection')) result.addCondAlgo(monFilterAlg) return result