def setLines(desiredlines1, desiredlines2): from HltLine.HltLine import hlt1Lines lines1 = [i for i in hlt1Lines() if i.name() in desiredlines1] Sequence("Hlt1").Members = [i.configurable() for i in lines1] from HltLine.HltLine import hlt2Lines lines2 = [i for i in hlt2Lines() if i.name() in desiredlines2] Sequence("Hlt2").Members = [i.configurable() for i in lines2] from HltConf.HltMonitoring import HltMonitoringConf HltMonitoringConf().configureHltMonitoring(lines1, lines2) Sequence("HltEndSequence").Members = []
def configureHltMonitoring(self, lines1, lines2): """ HLT Monitoring configuration """ ## Only do things here that need to know the list of instantiated HLT ## lines. This function is called from the postConfigAction of ## HltConf.Configuration. monSeq = self.getProp("MonitorSequence") monSeq.IgnoreFilterPassed = True # enforce execution of all sub-sequences if lines1: hlt1Mon = self.__hlt1_monitoring(lines1) monSeq.Members += [hlt1Mon] if lines2: hlt2Mon = self.__hlt2_monitoring(lines2) monSeq.Members += [hlt2Mon] # Disable production of histograms for all (most) of the algorithms from HltLine.HltLine import hlt1Lines, hlt2Lines if self.getProp('HistogrammingLevel') == 'None': for i in hlt1Lines() + hlt2Lines(): _disableHistograms(i.configurable()) elif self.getProp('HistogrammingLevel') == 'Line': for i in hlt1Lines() + hlt2Lines(): _disableHistograms(i.configurable(), lambda x: x.getType() != 'Hlt::Line') elif self.getProp('HistogrammingLevel') == 'NotLine': for i in hlt1Lines() + hlt2Lines(): _disableHistograms(i.configurable(), lambda x: x.getType() == 'Hlt::Line') else: ValueError( "HltMonitoringConf: HistogrammingLevel property must be set to 'None', 'Line' or 'NotLine'." ) # Enable production of histograms for some algorithms, see _enableMonitoring() if self.getProp('EnableAlgMonitoring'): for i in hlt1Lines() + hlt2Lines(): _recurse(i.configurable(), _enableMonitoring)
def _runHltLines(self): from HltLine.HltLine import hlt2Lines activeHlt1Lines = [] activeHlt2Lines = [] sets = self.settings() if (sets): activeHlt1Lines = sets.ActiveHlt1Lines() activeHlt2Lines = sets.ActiveHlt2Lines() else: activeHlt1Lines = [i.name() for i in hlt1Lines()] activeHlt2Lines = [i.name() for i in hlt2Lines()] activeHlt1Lines.extend(self.getProp('AdditionalHlt1Lines')) activeHlt2Lines.extend(self.getProp('AdditionalHlt2Lines')) for l in self.getProp('RemoveHlt1Lines'): if l in activeHlt1Lines: activeHlt1Lines.remove(l) for l in self.getProp('RemoveHlt2Lines'): if l in activeHlt2Lines: activeHlt2Lines.remove(l) # make sure Hlt.Global is included as soon as there is at least one Hlt. line... if activeHlt1Lines: activeHlt1Lines += ['Hlt1Global'] if activeHlt2Lines: activeHlt2Lines += ['Hlt2Global'] # Brute force uniquifier, which conserves order def unique(s): u = [] for x in s: if x not in u: u.append(x) else: log.warning( 'Duplicate entry in requested list of lines: %s; please fix ' % x) return u activeHlt1Lines = unique(activeHlt1Lines) activeHlt2Lines = unique(activeHlt2Lines) if self.getProp('Split'): if self.getProp('Split') == 'Hlt1': activeHlt2Lines = [] if self.getProp('Split') == 'Hlt2': activeHlt1Lines = [] if self.getProp('Split') not in ['Hlt1', 'Hlt2', '']: raise KeyError( "invalid value for property 'Split': %s -- must be either 'Hlt1', or 'Hlt2', or ''." % self.getProp('Split')) return activeHlt1Lines, activeHlt2Lines
def postConfigAction(self): from HltLine.HltLine import hlt1Lines from HltLine.HltLine import hlt2Lines # Reconfigure the Hlt sequences lines1 = [i for i in hlt1Lines() if i.name() in self.hlt1Lines] print "HLT1LINES" for hltLine in lines1: print hltLine.name() Sequence("Hlt1").Members = [i.configurable() for i in lines1] lines2 = [i for i in hlt2Lines() if i.name() in self.hlt2Lines] print "HLT2LINES" for hltLine in lines2: print hltLine.name() print "ENDLINES" Sequence("Hlt2").Members = [i.configurable() for i in lines2] # Reconfigure the monitoring to expect the correct lines from HltConf.HltMonitoring import HltMonitoringConf HltMonitoringConf().configureHltMonitoring(lines1, lines2) for hltLine in Sequence("Hlt1").Members + Sequence("Hlt2").Members: try: prescale = getattr(hltLine, "Prescale") if hasattr(prescale, "AcceptFraction"): prescale.AcceptFraction = 1 elif hasattr(prescale, "Code"): prescale.Code = "FALL" postscale = getattr(hltLine, "Postscale") if hasattr(postscale, "AcceptFraction"): postscale.AcceptFraction = 1 elif hasattr(postscale, "Code"): postscale.Code = "FALL" except AttributeError: pass # This is rather nasty, but required. It is possible because we don't need # an output file. Sequence("HltEndSequence").Members = []
def postConfigAction(self): from Configurables import GaudiSequencer as Sequence from Configurables import HltConf from HltLine.HltLine import hlt1Lines from HltLine.HltLine import hlt2Lines # Reconfigure the Hlt sequences lines1 = [i for i in hlt1Lines() if i.name() in self.hlt1Lines] print "HLT1LINES" for hltLine in lines1: print hltLine.name() Sequence("Hlt1").Members = [i.configurable() for i in lines1] lines2 = [i for i in hlt2Lines() if i.name() in self.hlt2Lines] print "HLT2LINES" for hltLine in lines2: print hltLine.name() print "ENDLINES" Sequence("Hlt2").Members = [i.configurable() for i in lines2] # Reconfigure the monitoring to expect the correct lines from HltConf.HltMonitoring import HltMonitoringConf HltMonitoringConf().configureHltMonitoring(lines1, lines2) #HltConf().configureHltMonitoring( lines1, lines2 ) for hltLine in Sequence("Hlt1").Members + Sequence("Hlt2").Members: if hasattr(hltLine, "Prescale"): hltLine.Prescale.AcceptFraction = 1 try: postscale = getattr(hltLine, "Postscale") if hasattr(postscale, "AcceptFraction"): postscale.AcceptFraction = 1 elif hasattr(postscale, "Code"): postscale.Code = "FALL" except AttributeError: pass
def postConfigAction(self): """ Add the configured lines into the Hlt1 and Hlt2 sequencers, provided there is no reason not to do so... @todo remove this method """ from HltLine.HltLine import hlt1Lines from HltLine.HltLine import hlt2Lines activeHlt1Lines, activeHlt2Lines = self._runHltLines() print '# List of requested Hlt1Lines : %s ' % activeHlt1Lines # print '# List of available Hlt1Lines : %s ' % [ i.name() for i in hlt1Lines() ] awol1 = set(activeHlt1Lines) - set([i.name() for i in hlt1Lines()]) if awol1: log.fatal(' # some requested Hlt1 lines are absent : %s ' % awol1) print '# List of requested Hlt2Lines : %s ' % activeHlt2Lines # print '# List of available Hlt2Lines : %s ' % [ i.name() for i in hlt2Lines() ] awol2 = set(activeHlt2Lines) - set([i.name() for i in hlt2Lines()]) if awol2: log.fatal(' # some requested Hlt2 lines are absent : %s ' % awol2) if awol1 or awol2: raise RuntimeError, ' # some requested lines are absent;\n Hlt1: %s\n Hlt2: %s' % ( awol1, awol2) lines1 = [i for i in hlt1Lines() if i.name() in activeHlt1Lines] log.info('# List of configured Hlt1Lines : ' + str(hlt1Lines())) log.info('# List of Hlt1Lines added to Hlt1 : ' + str(lines1)) log.info('# List of configured Hlt1Lines not added to Hlt1 : ' + str(set(hlt1Lines()) - set(lines1))) Sequence('Hlt1').Members = [i.configurable() for i in lines1] # for i in hlt2Lines() : print '# active line :', i.name(), ' found :', i.name() in activeHlt2Lines lines2 = [i for i in hlt2Lines() if i.name() in activeHlt2Lines] log.info('# List of configured Hlt2Lines : ' + str(hlt2Lines())) log.info('# List of Hlt2Lines added to Hlt2 : ' + str(lines2)) log.info('# List of configured Hlt2Lines not added to Hlt2 : ' + str(set(hlt2Lines()) - set(lines2))) Sequence('Hlt2').Members += [i.configurable() for i in lines2] # switch on timing limit / accept if slow for i in lines1: i.configurable().AcceptIfSlow = self.getProp('EnableAcceptIfSlow') i.configurable().FlagAsSlowThreshold = self.getProp( 'SlowHlt1Threshold') for i in lines2: i.configurable().AcceptIfSlow = self.getProp('EnableAcceptIfSlow') i.configurable().FlagAsSlowThreshold = self.getProp( 'SlowHlt2Threshold') for stage, lines in zip(('Hlt1', 'Hlt2'), (lines1, lines2)): self.configurePersistence(lines1, lines, stage) self.configureANNSelections() from HltConf.HltMonitoring import HltMonitoringConf HltMonitoringConf().configureHltMonitoring(lines1, lines2) if self.getProp("Verbose"): print Sequence('Hlt')
def _persistRecoLines(self): from HltLine.HltLine import hlt2Lines return [line for line in hlt2Lines() if line.persistReco()]