def _createWriter(self, sequence): ''' create writer sequence ''' writeLumiSequence = _sequenceAppender( Sequence('writeLumiSeq', ModeOR=False, ShortCircuit=True, IgnoreFilterPassed=False, MeasureTime=True, OutputLevel=self.getProp("OutputLevel"))) # create ODIN by hand writeLumiSequence(createODIN('createODIN')) # kill non-lumi banks to make output small if self.getProp('KillBanks'): writeLumiSequence( bankKiller('KillAll', BankTypes=['ODIN', 'HltLumiSummary', 'DAQ'], DefaultIsKill=True)) # tag input file --- writeLumiSequence( FileIdBankWriter(OutputLevel=self.getProp("OutputLevel"))) # and activate it sequence.Members += [Sequence('writeLumiSeq')] # create lumi sequence lumiFsrSeq = GaudiSequencer("LumiFsrSeq", OutputLevel=INFO) LumiAlgsConf().LumiSequencer = lumiFsrSeq sequence.Members += [lumiFsrSeq]
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 _createWriter(self, sequence): ''' create writer sequence ''' debugOPL = self.getProp("OutputLevel") debugging = self.getProp("Debug") writeLumiSequence = _sequenceAppender( Sequence('writeLumiSeq', ModeOR = False, ShortCircuit = True, IgnoreFilterPassed = False, MeasureTime = True, OutputLevel = debugOPL ) ) from DAQSys.Decoders import DecoderDB from DAQSys.DecoderClass import decodersForBank # create ODIN by hand for d in decodersForBank(DecoderDB,"ODIN"): writeLumiSequence( d.setup() ) # verbose output if debugging: writeLumiSequence( RawEventDump( 'InputDump', DumpData = False, OutputLevel = debugOPL ) ) pass # select only the right Trigger Type writeLumiSequence( ODINFilter ( 'OdinTriggerTypes', Code = ' ( ODIN_TRGTYP == LHCb.ODIN.LumiTrigger ) ' )) ## Lumi only triggers # decode summary data for d in decodersForBank(DecoderDB,"HltLumiSummary"): writeLumiSequence( d.setup() ) # add filter to check if this was L0 triggered filterRan = FilterOnLumiSummary('LumiRandomFilter', CounterName = "Random", ValueName = "RandomMethod") #filterLow = FilterOnLumiSummary('LumiLowFilter', CounterName = "Method", ValueName = "L0RateMethod") writeLumiSequence( Sequence('filterLumi', Members = [filterRan], #, filterLow], ModeOR = True, ShortCircuit = True, IgnoreFilterPassed = False, MeasureTime = True ) ) # kill non-lumi banks if self.getProp('KillBanks') : writeLumiSequence( bankKiller( 'KillAll', BankTypes=[ 'ODIN','HltLumiSummary','HltRoutingBits','DAQ' ], DefaultIsKill=True ) ) # tag input file --- writeLumiSequence( FileIdBankWriter( OutputLevel = debugOPL ) ) # verbose output if debugging: writeLumiSequence( RawEventDump( 'OutputDump', DumpData = True, OutputLevel = debugOPL ) ) writeLumiSequence( MDFWriter( "MDFWriter" ) ) # configure somewhere else # and activate it sequence.Members+=[ Sequence('writeLumiSeq') ]
def addTupleAlg(self): """ Add TupleHltDecReports to TopAlg """ alg = TupleHltDecReports(self._algName) seq = Sequence("Hlt") algSeq = Sequence("TupleSequence") algSeq.Members = [alg] seq.Members += [algSeq] ApplicationMgr().HistogramPersistency = "ROOT" tupleFile = self._filename ApplicationMgr().ExtSvc += [NTupleSvc()] tup = "FILE1 DATAFILE='" + tupleFile + "' TYP='ROOT' OPT='NEW'" NTupleSvc().Output = [tup] NTupleSvc().OutputLevel = 1
def _createReader(self, sequence): ''' create reader sequence ''' debugOPL = self.getProp("OutputLevel") debugging = self.getProp("Debug") readLumiSequence = _sequenceAppender( Sequence('readLumiSeq', ModeOR=False, ShortCircuit=True, IgnoreFilterPassed=False, MeasureTime=True, OutputLevel=debugOPL)) from DAQSys.Decoders import DecoderDB from DAQSys.DecoderClass import decodersForBank # create ODIN by hand for d in decodersForBank(DecoderDB, "ODIN"): readLumiSequence(d.setup()) # select only the right Trigger Type readLumiSequence( ODINFilter('OdinTriggerTypes', Code=' ( ODIN_TRGTYP == LHCb.ODIN.LumiTrigger ) ')) # decode lumi for d in decodersForBank(DecoderDB, "HltLumiSummary"): readLumiSequence(d.setup()) # add filter to check if this was L0 triggered filterRan = FilterOnLumiSummary('LumiRandomFilter', CounterName="Random", ValueName="RandomMethod") filterLow = FilterOnLumiSummary('LumiLowFilter', CounterName="Method", ValueName="L0RateMethod") readLumiSequence( Sequence('filterLumi', Members=[filterRan, filterLow], ModeOR=True, ShortCircuit=True, IgnoreFilterPassed=False, MeasureTime=True)) # read and decode input file --- readLumiSequence(LumiFileReader(OutputLevel=debugOPL)) # verbose output if debugging: readLumiSequence( RawEventDump('InputDump', DumpData=True, OutputLevel=debugOPL)) # and activate it sequence.Members += [Sequence('readLumiSeq')]
def _persistRecoSeq(self): lines = self._persistRecoLines() code = self._persistRecoFilterCode(lines) print '# List of requested PersistReco lines: {}'.format( [line.name() for line in lines]) from DAQSys.Decoders import DecoderDB decoder = DecoderDB["HltDecReportsDecoder/Hlt2DecReportsDecoder"] from Configurables import LoKi__HDRFilter as HltFilter lineFilter = HltFilter("Hlt2PersistRecoLineFilter", Code=code, Location=decoder.listOutputs()[0]) seq = Sequence("HltPersistReco") HltPersistRecoConf().Sequence = seq return Sequence("HltPersistRecoFilterSequence", Members=[lineFilter, seq])
def __lumiAlgs(self, stream, exclude, rawLocation = None): # Return the list of algorithms that are required to treat lumi events # Don't nanofy after HLT1, of if there is nothing base nanofication on if self.getProp('Split') == 'Hlt1' or not exclude: return [] from DAQSys.Decoders import DecoderDB from Configurables import bankKiller from Configurables import DeterministicPrescaler as Prescale from Configurables import LoKi__HDRFilter as HltFilter # Strip exclusive lumi events decoder = DecoderDB["HltDecReportsDecoder/Hlt2DecReportsDecoder"] prefix = stream + 'Lumi' if stream != 'Lumi' else stream + 'Stream' stripper = Sequence(prefix + 'Stripper') if exclude != self.getProp('LumiPredicate'): # Filter on which events to nanofy for all streams, except Lumi, # where everything is nanofied stripper.Members += [HltFilter(prefix + 'Hlt2StripperFilter', Code = self.__lumiPredicate(exclude, exclusive = True)[1], Location = decoder.listOutputs()[0])] else: # Keep a small fraction of non-nanofied events in the Lumi stream. stripper.Members += [Prescale('LumiStripperPrescaler', AcceptFraction = self.getProp('LumiBankKillerAcceptFraction'))] # The actual nanofier killer = bankKiller(prefix + 'StripperBankKiller', BankTypes = self.__nanoBanks(stream), DefaultIsKill = True) if rawLocation: killer.RawEventLocations = [rawLocation] stripper.Members += [killer] return [stripper]
def __apply_configuration__(self): """ Hlt2 configuration """ Hlt2 = Sequence("Hlt2", Context='HLT', ModeOR=True, ShortCircuit=False) # set Hlt2 PID self.configureReconstruction() # lines if self.getProp("DefaultVoidFilter"): from HltLine.HltLine import Hlt2Line Hlt2Line.setDefaultVoidFilter(self.getProp("DefaultVoidFilter")) self.hlt2Lines(Hlt2)
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 setOutputLevel( self ): """ Recursively set OutputLevel for configurables """ seq = type( Sequence() ) for configurable in self._configurables: if type( configurable ) != seq: typ = configurable.getType().replace( "::", "__" ) name = configurable.name() conf = getattr( Configurables, typ ) conf( name ).OutputLevel = self._level else: for member in configurable.Members: if type( member ) == seq: self.setOutputLevel( member, self._level ) else: typ = member.getType().replace( "::", "__" ) name = member.name() conf = getattr( Configurables, typ ) conf( name ).OutputLevel = self._level
def __apply_configuration__(self): ## Apply ThresholdSettings to HLT1 lines configurables from ThresholdUtils import setThresholds from functools import partial map(partial(setThresholds, self.getProp("ThresholdSettings")), _hlt1linesconfs) ## Create Hlt1Global from HltLine.HltLine import Hlt1Line from Configurables import LoKi__HDRFilter as HDRFilter from DAQSys.Decoders import DecoderDB decoder = DecoderDB["HltDecReportsDecoder/Hlt1DecReportsDecoder"] Hlt1Line('Global', priority=255, algos=[ HDRFilter('Hlt1GlobalFilter', Code="HLT_PASS_SUBSTR('Hlt1') ", Location=decoder.listOutputs()[0]) ]) # add a few thing to our printout def __counter(n): m = 3 while m <= n: yield ''.join(str(i) for i in range(1, m)) m += 1 from HltLine.HltLine import addHlt1Prop addHlt1Prop([ 'RoutingBits', 'Accept', 'FilterDescriptor', 'Code', 'Preambulo', 'InputLocations', 'Input', 'Inputs', 'Output', 'OutputProtoParticleLocation', 'InputTrackLocation', 'DaughtersCuts', 'CombinationCut', 'MotherCut', 'DecayDescriptor', 'OutputSelection', 'Context', 'TisTosSpecs' ] + ['Combination%sCut' % s for s in __counter(8)]) ## finally, define the Hlt1 sequence!! from Configurables import GaudiSequencer as Sequence Sequence('Hlt1', ModeOR=True, ShortCircuit=False)
def configure(self, configuration): from Configurables import LHCbApp app = LHCbApp() for (attr, value) in configuration.items(): if hasattr(app, attr): setattr(app, attr, value) self._config[attr] = value EventSelector().Input = self._config['Input'] if 'Catalogs' in self._config.keys(): FileCatalog().Catalogs = self._config['Catalogs'] from Configurables import DecodeRawEvent importOptions("$L0DUOPTS/L0DUConfig.opts") EventPersistencySvc().CnvServices.append('LHCb::RawDataCnvSvc') EventSelector().PrintFreq = 1000 from Configurables import CondDB CondDB().Online = True from Configurables import GaudiSequencer as Sequence from Configurables import createODIN, HltRoutingBitsFilter seq = Sequence("MonitorSequence") physFilter = HltRoutingBitsFilter("PhysFilter", RequireMask=[0x0, 0x4, 0x0]) co = createODIN() seq.Members = [co, physFilter] from DAQSys.Decoders import DecoderDB from itertools import product for stage, t in product(('Hlt1', 'Hlt2'), ('Dec', 'Sel', 'Vertex')): an = "{0}{1}ReportsDecoder".format(stage, t) seq.Members += [ DecoderDB["Hlt%sReportsDecoder/%s" % (t, an)].setup() ] ApplicationMgr().TopAlg = [seq] self._extra_config(seq)
def configure(self, configuration): from Configurables import LHCbApp app = LHCbApp() for (attr, value) in configuration.items(): if hasattr(app, attr): setattr(app, attr, value) self._config[attr] = value EventSelector().Input = self._config['Input'] FileCatalog().Catalogs = self._config['Catalogs'] EventDataSvc().RootCLID = 1 from Configurables import LHCb__RawDataCnvSvc as RawDataCnvSvc EventPersistencySvc().CnvServices.append( RawDataCnvSvc('RawDataCnvSvc')) EventSelector().PrintFreq = 100 from Configurables import GaudiSequencer as Sequence from Configurables import createODIN seq = Sequence("OdinSequence") co = createODIN() seq.Members = [co] ApplicationMgr().TopAlg = [seq]
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 endSequence(self): """ define end sequence (persistence + monitoring) """ from Configurables import GaudiSequencer as Sequence from Configurables import bankKiller from Configurables import LoKi__HDRFilter as HltFilter from Configurables import Hlt1SelReportsMaker, Hlt2SelReportsMaker, HltSelReportsWriter from Configurables import HltDecReportsWriter from Configurables import HltVertexReportsMaker, HltVertexReportsWriter from Configurables import HltTrackReportsWriter from Configurables import HltRoutingBitsWriter from Configurables import HltLumiWriter from Configurables import DeterministicPrescaler as Prescale from HltLine.HltDecodeRaw import DecodeIT, DecodeVELO, DecodeL0DU from Configurables import LoKi__VoidFilter as Filter sets = self.settings() if sets and hasattr(sets, 'StripEndSequence') and getattr( sets, 'StripEndSequence'): log.warning( '### Setting requests stripped down HltEndSequence ###') strip = getattr(sets, 'StripEndSequence') for option in [ 'EnableHltSelReports', 'EnableHltVtxReports', 'EnableHltTrkReports', 'EnableLumiEventWriting' ]: self._safeSet(option, (option in strip)) activehlt1lines, activehlt2lines = self._runHltLines() # make sure we encode from the locations the decoders will use... from DAQSys.Decoders import DecoderDB hlt1_decrep_loc = DecoderDB[ "HltDecReportsDecoder/Hlt1DecReportsDecoder"].listOutputs()[0] hlt2_decrep_loc = DecoderDB[ "HltDecReportsDecoder/Hlt2DecReportsDecoder"].listOutputs()[0] hlt1_selrep_loc = DecoderDB[ "HltSelReportsDecoder/Hlt1SelReportsDecoder"].listOutputs()[0] hlt2_selrep_loc = DecoderDB[ "HltSelReportsDecoder/Hlt2SelReportsDecoder"].listOutputs()[0] hlt1_vtxrep_loc = DecoderDB[ "HltVertexReportsDecoder/Hlt1VertexReportsDecoder"].listOutputs( )[0] hlt2_vtxrep_loc = DecoderDB[ "HltVertexReportsDecoder/Hlt2VertexReportsDecoder"].listOutputs( )[0] ## L0 decoder from DAQSys.DecoderClass import decodersForBank l0decoder = decodersForBank(DecoderDB, 'L0DU') assert len(l0decoder) l0decoder = l0decoder[0].setup() ### store the BDT response (and a bit more) through ExtraInfo on particles: sel_rep_opts = dict( InfoLevelDecision=3, InfoLevelTrack=3, InfoLevelRecVertex=3, InfoLevelCaloCluster=3, InfoLevelParticle=3, ) ### HLT2 rec summary location, empty if HltAfterburner is disabled if self.getProp("EnableHltAfterburner"): recSumLoc = HltAfterburnerConf().getProp("RecSummaryLocation") else: recSumLoc = "" ### FIXME/TODO: having the routing bits writer(s) in the postamble implies they do NOT run for rejected events. ### Is that really appropriate? Maybe we don't care, as those events (in the pit!) are never seen ### downstream, but eg. for MC they may be kept... ### So maybe the routingbits should be written in the end sequence instead, but then the code must take into ### account that Hlt2 missing on Hlt1 rejected events is not an error... _hlt1postamble = (("EnableHltRoutingBits", type(l0decoder), l0decoder.getName(), {}), ("EnableHltRoutingBits", HltRoutingBitsWriter, 'Hlt1RoutingBitsWriter', { 'Hlt1DecReportsLocation': hlt1_decrep_loc, 'Hlt2DecReportsLocation': '', }), ("EnableHltDecReports", HltDecReportsWriter, 'Hlt1DecReportsWriter', { 'SourceID': 1, 'InputHltDecReportsLocation': hlt1_decrep_loc }), ("EnableHltSelReports", Hlt1SelReportsMaker, 'Hlt1SelReportsMaker', dict(InputHltDecReportsLocation=hlt1_decrep_loc, OutputHltSelReportsLocation=hlt1_selrep_loc, **sel_rep_opts)), ("EnableHltSelReports", HltSelReportsWriter, 'Hlt1SelReportsWriter', { 'SourceID': 1, 'InputHltSelReportsLocation': hlt1_selrep_loc }), ("EnableHltTrkReports", HltTrackReportsWriter, 'Hlt1TrkReportsWriter', {}), ("EnableHltVtxReports", HltVertexReportsMaker, 'Hlt1VtxReportsMaker', { 'OutputHltVertexReportsLocation': hlt1_vtxrep_loc }), ("EnableHltVtxReports", HltVertexReportsWriter, 'Hlt1VtxReportWriter', { 'SourceID': 1, 'InputHltVertexReportsLocation': hlt1_vtxrep_loc })) _hlt2postamble = (("EnableHltRoutingBits", type(l0decoder), l0decoder.getName(), {}), ("EnableHltDecReports", HltDecReportsWriter, 'Hlt2DecReportsWriter', { 'SourceID': 2, 'InputHltDecReportsLocation': hlt2_decrep_loc }), ("EnableHltSelReports", Hlt2SelReportsMaker, 'Hlt2SelReportsMaker', dict(InputHltDecReportsLocation=hlt2_decrep_loc, OutputHltSelReportsLocation=hlt2_selrep_loc, RecSummaryLocation=recSumLoc, **sel_rep_opts)), ("EnableHltSelReports", HltSelReportsWriter, 'Hlt2SelReportsWriter', { 'SourceID': 2, 'InputHltSelReportsLocation': hlt2_selrep_loc }), ("EnableHltVtxReports", HltVertexReportsMaker, 'Hlt2VtxReportsMaker', { 'OutputHltVertexReportsLocation': hlt2_vtxrep_loc }), ("EnableHltVtxReports", HltVertexReportsWriter, 'Hlt2VtxReportWriter', { 'SourceID': 2, 'InputHltVertexReportsLocation': hlt2_vtxrep_loc })) # Don't try to decode L0 for the routing bits writer if no L0TCK has # been set. This allows forward compatibility. if self.getProp('L0TCK') is None: _hlt1postamble = _hlt1postamble[1:] _hlt2postamble = _hlt2postamble[1:] # make sure we only instantiate members which are used... instantiate = lambda name, cfg: Sequence( name, IgnoreFilterPassed=True, Members=[ tp(nm, **props) for (gate, tp, nm, props) in cfg if self.getProp(gate) ]) Monitoring = Sequence("HltMonitorSequence", IgnoreFilterPassed=True) End = Sequence('HltEndSequence', []) Hlt1PostAmble = instantiate('Hlt1Postamble', _hlt1postamble) Hlt2PostAmble = instantiate('Hlt2Postamble', _hlt2postamble) # Configure monitoring from HltMonitoring import HltMonitoringConf HltMonitoringConf().MonitorSequence = Monitoring # Disable L0 monitoring if no L0TCK has been set if self.getProp('L0TCK') is None: HltMonitoringConf().EnableL0Monitor = False # Set end sequence for output HltOutputConf().HltEndSequence = End if self.getProp('RequireL0ForEndSequence'): from Configurables import LoKi__L0Filter as L0Filter from HltLine.HltDecodeRaw import DecodeL0DU L0accept = Sequence( name='HltEndSequenceFilter', Members=DecodeL0DU.members() + [L0Filter('L0Pass', Code="L0_DECISION_PHYSICS")]) End.Members += [L0accept]
def confType(self): """ Decoding of configuration. This is where Hlt1 and 2 configurations are called. """ # # set thresholds if you can # ThresholdSettings = {} thresClass = self.settings() if (thresClass != None): ThresholdSettings = thresClass.Thresholds() else: log.warning( '##################################################################' ) log.warning( '## WARNING You are running the HLT with no defined thresholds ##' ) log.warning( '## WARNING You will get the default cuts and all lines ##' ) log.warning( '## WARNING Set a ThresholdSetting to get something well defined ##' ) log.warning( '## ###############################################################' ) # Overwrite settings if requested newSettings = self.getProp('OverwriteSettings') if newSettings: log.warning( '############################################################') log.warning( '## WARNING You are overwriting the HLT thresholds ##') log.warning( '## WARNING Please make sure you know what you are doing!! ##') log.warning( '## #########################################################') overwriteThresholds(ThresholdSettings, newSettings) ## what L0 configuration are we running on top of? L0TCK = None if thresClass: L0TCK = thresClass.L0TCK() if self.isPropertySet('L0TCK') and self.getProp('L0TCK'): if L0TCK != self.getProp('L0TCK'): log.warning( '####################################################################################' ) log.warning( '## WARNING You are configuring the HLT to run on top of an L0 configuration ##' ) log.warning( '## WARNING which is different then the one it was generated for ##' ) log.warning( '## WARNING This may not work, but if it does, it may result in undefined behavior ##' ) log.warning( '## WARNING Please make sure you know what you are doing!! ##' ) log.warning( '####################################################################################' ) L0TCK = self.getProp('L0TCK') if not self.isPropertySet( 'L0TCK') or not self.getProp('L0TCK') and L0TCK != None: self.setProp('L0TCK', L0TCK) self.defineL0Channels(L0TCK) # obtain list of lines, activehlt1lines, activehlt2lines = self._runHltLines() # and push into the Hlt1Lines and Hlt2Lines code... # (for backwards compatible behaviour, just skip the next three lines... ) from HltLine.HltLine import setRequestedHlt1Lines, setRequestedHlt2Lines setRequestedHlt1Lines(activehlt1lines) setRequestedHlt2Lines(activehlt2lines) Dec = Sequence('HltDecisionSequence', Members=[]) # Decoding at end of Hlt1 and beginning of HLT2. Make sure the decoders do not run, if location already exists. from DAQSys.Decoders import DecoderDB for n in [ "HltDecReportsDecoder/Hlt1DecReportsDecoder", "HltSelReportsDecoder/Hlt1SelReportsDecoder", "HltTrackReportsDecoder" ]: decoder = DecoderDB[n] decoder.setup().VetoObjects = [ loc for loc in decoder.listOutputs() ] # # dispatch Hlt1 configuration, don't do this if there are no HLT1 lines # if activehlt1lines: Dec.Members.append(Sequence("Hlt1")) Dec.Members.append(Sequence("Hlt1Postamble")) Hlt1Conf() Hlt1Conf().ThresholdSettings = ThresholdSettings # # dispatch Hlt2 configuration # # don't do this if there are no HLT2 lines if activehlt2lines: Dec.Members.append(Sequence("Hlt2")) if self.getProp("EnableHltAfterburner"): seq = Sequence("HltAfterburner", IgnoreFilterPassed=True) Dec.Members.append(seq) HltAfterburnerConf().Sequence = seq Dec.Members.append(Sequence("Hlt2Postamble")) Hlt2Conf() self.setOtherProps(Hlt2Conf(), ["DataType"]) Hlt2Conf().ThresholdSettings = ThresholdSettings if thresClass and hasattr(thresClass, 'Hlt2DefaultVoidFilter'): Hlt2Conf().DefaultVoidFilter = getattr( thresClass, 'Hlt2DefaultVoidFilter') # Never try to decode if we want to rerun the HLT1 tracking in HLT2. if Hlt2Conf().getProp('Hlt1TrackOption') == "Rerun": decoder = DecoderDB["HltTrackReportsDecoder"] decoder.setup().Enable = False Hlt = Sequence('Hlt', ModeOR=True, ShortCircuit=False, Members=[ Sequence('HltDecisionSequence'), Sequence('HltEndSequence') ]) if self.getProp('EnableMonitoring'): Hlt.Members.insert(1, Sequence('HltMonitorSequence')) if self.getProp('RequireRoutingBits') or self.getProp( 'VetoRoutingBits'): from Configurables import HltRoutingBitsFilter filter = HltRoutingBitsFilter("PhysFilter") if self.getProp('RequireRoutingBits'): filter.RequireMask = self.getProp('RequireRoutingBits') if self.getProp('VetoRoutingBits'): filter.VetoMask = self.getProp('VetoRoutingBits') Sequence("HltDecisionSequence").Members.insert(0, filter) Sequence("HltEndSequence").Members.insert(0, filter) Sequence('HltMonitorSequence').Members.insert(0, filter) #fix input locations, for the moment do with a post-config action, #TODO: in the future set in Hlt1 and Hlt2 separately #get the vertex locations required loc = onlinePV()["PV3D"] def __setOnlinePV__(hlt=Hlt, loc=loc): __forAll__(hlt, {"InputPrimaryVertices": loc}) appendPostConfigAction(__setOnlinePV__)
def configureANNSelections(self): """ Assigned numbers configuration """ ### TODO: use the computed indices available from the lines... ### TODO: what about shared selections??? (which appear with multiple indices!) ### but which have names not prefixed by the line name ### Make sure that the ANN Svc has everything it will need from HltLine.HltLine import hlt1Selections, hlt1Decisions from HltLine.HltLine import hlt2Selections, hlt2Decisions from Configurables import HltANNSvc hltSelections = { 'Hlt1': (hlt1Selections(), hlt1Decisions(), 1000, 11000), 'Hlt2': (hlt2Selections(), hlt2Decisions(), 5000, 50000) } for stage, (selections, decisions, decStart, selStart) in hltSelections.iteritems(): ids = getattr(HltANNSvc(), '%sSelectionID' % stage) missing = [ i for i in sorted(set(selections['Output']) - set(ids.keys())) if not i.startswith('TES:') ] missing += [i for i in sorted(set(decisions) - set(ids.keys()))] missing = sorted(list(set(missing))) missingDecisions = [i for i in missing if i.endswith('Decision')] __updateDict__(ids, decStart, missingDecisions) missingSelections = [ i for i in missing if not i.endswith('Decision') ] __updateDict__(ids, selStart, missingSelections) log.warning('# added %d %s selections to HltANNSvc' % (len(missingSelections), stage)) log.warning('# added %d %s decisions to HltANNSvc' % (len(missingDecisions), stage)) if self.getProp('PruneHltANNSvc'): # prune all Decisions which are not members of Htl1 or Hlt2... def genName(c): if type(c) != str: c = c.name() return '%sDecision' % c for stage in ('Hlt1', 'Hlt2'): decnames = set([genName(i) for i in Sequence(stage).Members]) # remove 'stale' entries ids = getattr(HltANNSvc(), '%sSelectionID' % stage) extradecnames = [ i for i in ids.keys() if i.endswith('Decision') and i not in decnames ] #print 'stale %s entries : %s ' % (stage, extradecnames) for i in extradecnames: del ids[i] setattr(HltANNSvc(), '%sSelectionID' % stage, ids) # given that both Hlt1 and Hlt2 end up in the same rawbank, and thus # effectively 'share a namespace' we MUST make sure that there is no overlap # between Hlt1SelectionID and Hlt2SelectionID -- because if there is, on # decoding, the Hlt1SelectionID _will_ be used... (as all the decoding knows # is the number, and it first checks Hlt1SelectionID). overlap = set(HltANNSvc().Hlt1SelectionID.values()).intersection( HltANNSvc().Hlt2SelectionID.values()) if overlap: raise RuntimeError, ' # Hlt1 and Hlt2 have overlapping ID values: %s -- this will cause problems when decoding the raw bank' % overlap
def __create_lumi_algos__(self, postfix=''): ''' returns algorithm sequences for Hlt1 Lumi Lines ''' # get counters counters = self.getProp('CounterDefinition') # debugging options debugOPL = self.getProp('OutputLevel') # define reco scaler from Configurables import DeterministicPrescaler as Scaler recoScaler = Scaler( 'LumiRecoScaler', AcceptFraction=1 if self.getProp('EnableReco') else 0) # define empty reco sequence seqRecoName = 'LumiReco' from Configurables import GaudiSequencer as Sequence lumiRecoSequence = Sequence( seqRecoName + 'Seq', ModeOR=True, ShortCircuit=False, OutputLevel=debugOPL, IgnoreFilterPassed=True, Members=[ ] # reset so we build the same things several times TODO: move out of loop... ) # define empty sequence to collect counters seqCountName = 'LumiCount' + postfix from Configurables import GaudiSequencer as Sequence lumiCountSequence = Sequence(seqCountName + 'Seq', ModeOR=True, ShortCircuit=False, OutputLevel=debugOPL, IgnoreFilterPassed=True) # LumiLow lines must be flagged - traditional and low are flagged explicitely from Configurables import LumiFlagMethod if postfix.find('Low') > -1: lumiCountSequence.Members.append( LumiFlagMethod(seqCountName + 'FlagMethod', CounterName='Method', ValueName='L0RateMethod', OutputContainer='Hlt/LumiSummary')) # LumiMid lines are not flagged - to be used for on-line reporting only elif postfix.find('Mid') > -1: pass # flag now also the random lumi lines - needed due to microbias lines else: lumiCountSequence.Members.append( LumiFlagMethod(seqCountName + 'FlagMethod', CounterName='Random', ValueName='RandomMethod', OutputContainer='Hlt/LumiSummary')) # populate count sequence from the definition createdCounters = [] histoThresholds = [] histoMaxBins = [] for key, definition in counters.iteritems(): # example 'CaloEt' : [LumiFromL0DU , True , 'Hadron(Et)' , 500, 6000], (op, flag, inputDef, threshold, bins) = definition if flag: createdCounters.extend( _combine( _createCounter(op, seqCountName, lumiCountSequence, True), {key: inputDef})) histoThresholds.extend([threshold]) histoMaxBins.extend([bins]) if debugOPL <= DEBUG: print '# DEBUG : Hlt1LumiLines::HistoMaker:', postfix, key, threshold, bins from Configurables import LumiCountMuons lumiCountSequence.Members.append( LumiCountMuons(seqCountName + 'Muons', CounterName='Muon', Threshold='2.0', InputSelection='Trig/L0/MuonCtrl', OutputContainer='Hlt/LumiSummary')) # Add L0MuonCandidatesFromRaw to the lumi reco sequence from L0DU.L0Algs import decodeL0Muon lumiRecoSequence.Members.append(decodeL0Muon()) ### get the private lumi velo reco algorithms lumiVeloReco = self.__lumi_track_and_vertex_seq__() lumiRecoSequence.Members.append( Sequence( 'LumiTrackRecoSequence', Members=[recoScaler] + lumiVeloReco, )) # filter to get backward tracks (make sure it always passes by wrapping inside a sequence) from Configurables import Hlt__TrackFilter as HltTrackFilter from Configurables import GaudiSequencer as Sequence lumiRecoFilterSequence = Sequence( 'LumiRecoFilterSequence', Members=[]) # reset, always build the same seq... lumiRecoFilterSequence.Members.append(recoScaler) lumiRecoFilterSequence.Members.append( Sequence('HltVeloBWSequence', Members=[ HltTrackFilter('HltPrepareVeloBW', InputSelection='TES:%s' % self.containerNameLumiTracks, Code=['TrBACKWARD'], OutputSelection='VeloBW', RequirePositiveInputs=False) ], ModeOR=True, ShortCircuit=False)) lumiRecoSequence.Members.append(lumiRecoFilterSequence) # VELO counters of tracks and vertexes with z,R cuts from Configurables import LumiCountVeloWithZRCuts lumiCountSequence.Members.append( LumiCountVeloWithZRCuts( seqCountName + 'VeloWithZRCuts', TrackCounterName='Velo', VertexCounterName='Vertex', AbsZCut='300', RCut='4', TrackInputSelection=self.containerNameLumiTracks, VertexInputSelection=self.containerNameLumiVertex, OutputContainer='Hlt/LumiSummary')) # sequence to get TT tracks # disabled because of https://savannah.cern.ch/bugs/index.php?62933 #from HltLine.HltDecodeRaw import DecodeTT #from Configurables import TTGenericTracking #from Configurables import RawBankToSTClusterAlg #lumiTTTSequence = Sequence( 'LumiTTTSequence', Members = [] ) # reset, always build the same seq... #lumiTTTSequence.Members.append( recoScaler ) #lumiTTTSequence.Members.append( # Sequence('TTTSequence' # # , Members = DecodeTT.members() + [ # , Members = [ RawBankToSTClusterAlg("createTTClusters"), # TTGenericTracking("lumiTTT" # , MaxNumClusters = 2000 # # , InputData = DecodeTT.members()[0].getProp('clusterLocation') // hardwired to use STClusters, not lite ones... # , OutputLocation = 'Hlt/Track/TTIP' # , WindowCenter = [0,0,0] # , HalfWindowXSize = 15 # , HalfWindowYSize = 15 # , OutputLevel = WARNING # ) # ] # , ModeOR = True # , ShortCircuit = False # ) ) #lumiRecoSequence.Members.append(lumiTTTSequence) # define histogrammers #from Configurables import LumiHistoMaker, LumiHisto2dSPD #HistoMembers=[] #HistoMembers.append(LumiHistoMaker('Histo'+postfix # InputVariables = createdCounters, # Thresholds = histoThresholds, # MaxBins = histoMaxBins, # OutputLevel = debugOPL # )) #HistoMembers.append(LumiHisto2dSPD('Histo2D'+postfix # HistoTitle=str(postfix), # OutputLevel = debugOPL )) #lumiHistoSequence = Sequence('LumiHisto'+postfix+'Seq' # , Members = HistoMembers # , ModeOR = True # , ShortCircuit = False # , OutputLevel = debugOPL # ) #return [ lumiRecoSequence, lumiCountSequence, lumiHistoSequence ] return [lumiRecoSequence, lumiCountSequence]
def main(): # Setup the option parser usage = "usage: %prog [options] inputfile <inputfile>" parser = optparse.OptionParser(usage=usage) parser.add_option("-d", "--datatype", action="store", dest="DataType", default="2015", help="DataType to run on.") parser.add_option("-n", "--evtmax", type="int", action="store", dest="EvtMax", default=10000, help="Number of events to run") parser.add_option("--dddbtag", action="store", dest="DDDBtag", default='MC09-20090602', help="DDDBTag to use") parser.add_option("--conddbtag", action="store", dest="CondDBtag", default='sim-20090402-vc-md100', help="CondDBtag to use") parser.add_option("--settings", action="store", dest="ThresholdSettings", default='Physics_25ns_September2015', help="ThresholdSettings to use") parser.add_option("-s", "--simulation", action="store_true", dest="Simulation", default=False, help="Run on simulated data") parser.add_option("--dbsnapshot", action="store_true", dest="UseDBSnapshot", default=False, help="Use a DB snapshot") parser.add_option("-v", "--verbose", action="store_true", dest="Verbose", default=False, help="Verbose output") parser.add_option("--rch", action="store_true", dest="RunChangeHandler", default=False, help="Use the RunChangeHandler") # Parse the arguments (options, args) = parser.parse_args() # Make sure there is data to run on # Put the options into the Moore configurable Moore().ThresholdSettings = options.ThresholdSettings #Moore().OutputLevel="VERBOSE" Moore().EvtMax = options.EvtMax #Moore().UseDBSnapshot = options.UseDBSnapshot # DEPRECATED from Configurables import CondDB CondDB().UseDBSnapshot = options.UseDBSnapshot # Moore().DDDBtag = options.DDDBtag Moore().CondDBtag = options.CondDBtag Moore().Simulation = options.Simulation Moore().DataType = options.DataType Moore().inputFiles = args EventSelector().PrintFreq = 100 # Instanciate the AppMgr to get the Hlt lines from their Sequences appMgr = AppMgr() hlt1Seq = Sequence("Hlt1") hlt1Lines = set() for m in hlt1Seq.Members: hlt1Lines.add(m.name()) hlt2Seq = Sequence("Hlt2") hlt2Lines = set() for m in hlt2Seq.Members: hlt2Lines.add(m.name()) # The AppMgr is no longer needed appMgr.exit() print "HLT1LINES" for line in hlt1Lines: print line print "HLT2LINES" for line in hlt2Lines: print line
def __hlt2_monitoring(self, lines2): monSeq = Sequence("Hlt2MonitorSequence", IgnoreFilterPassed=True) l0Mon = self.__l0_monitoring("Hlt2") monSeq.Members += l0Mon # Tell the monitoring what it should expect.. # the keys are the Labels for the Histograms in the GUI # the values are the Pattern Rules to for the Decisions contributing from Configurables import HltGlobalMonitor globalMon = self.__globalMonitor("Hlt2") globalMon.DecToGroup = self.__groupLines( [i.decision() for i in lines2], [ ("B2HH", "Hlt2B2K{,2}Pi{,2}.*Decision"), ("B2Kpi0", "Hlt2B2K0?[pP]i0?.*Decision"), ("Bc2JpsiX", "Hlt2Bc2JpsiX.*Decision"), ("CaloTest", "Hlt2CaloTest.*Decision"), ("CcDiHadron", "Hlt2CcDiHadron.*Decision"), ("CharmHad", "Hlt2CharmHad.*Decision"), ("Commissioning", "Hlt2Commissioning.*Decision"), ("DPS", "Hlt2DPS.*Decision"), ("DiMuon", "Hlt2DiMuon.*Decision"), ("DisplVertices", "Hlt2DisplVertices.*Decision"), ("EW", "Hlt2EW.*Decision"), ("LowMult", "Hlt2LowMult.*Decision"), ("PID", "Hlt2PID.*Decision"), ("Phi", "Hlt2Phi.*Decision"), ("Radiative", "Hlt2Radiative.*Decision"), ("RareCharm", "Hlt2RareCharm.*Decision"), ("RareStrange", "Hlt2RareStrange.*Decision"), ("RecoTest", "Hlt2RecoTest.*Decision"), ("SingleMuon", "Hlt2SingleMuon.*Decision"), ("Topo", "Hlt2Topo.*Decision"), ("TrackEff", "Hlt2TrackEff.*Decision"), ("TrackEffDiMuon", "Hlt2TrackEffDiMuon.*Decision"), ("TriMuon", "Hlt2TriMuon.*Decision"), ("XcMuXForTau", "Hlt2XcMuXForTau.*Decision"), ("Global", ".*Global.*"), ( "Other", ".*" ) # add a 'catch all' term to pick up all remaining decisions... ]) if self.getProp("EnableGlobalMonitor"): monSeq.Members.append(globalMon) from Configurables import HltMassMonitor massMon = HltMassMonitor("Hlt2MassMonitor") from DAQSys.Decoders import DecoderDB massMon.DecReportsLocation = DecoderDB[ "HltDecReportsDecoder/Hlt2DecReportsDecoder"].listOutputs()[0] massMon.SelReportsLocation = DecoderDB[ "HltSelReportsDecoder/Hlt2SelReportsDecoder"].listOutputs()[0] massMon.Decisions = { "Jpsi": "Hlt2DiMuonJPsiDecision", "Psi2S": "Hlt2DiMuonPsi2STurboDecision", "D+->Kpipi": "Hlt2CharmHadDpToKmPipPipTurboDecision", "Ds+->KKpi": "Hlt2CharmHadDspToKmKpPipTurboDecision", "Lambdac->pKpi": "Hlt2CharmHadLcpToPpKmPipTurboDecision", "Omega->Lambda(LL)K": "Hlt2CharmHadOmm2LamKm_LLLDecision", "Omega->Lambda(DD)K": "Hlt2CharmHadOmm2LamKm_DDLDecision", "Xi->Lambda(LL)pi": "Hlt2CharmHadXim2LambPim_LLLDecision", "Xi->Lambda(DD)pi": "Hlt2CharmHadXim2LambPim_DDLDecision", "D*->(D0->KK)pi": "Hlt2CharmHadDstp2D0Pip_D02KmKpTurboDecision", "D*->(D0->Kpi)pi": "Hlt2CharmHadDstp2D0Pip_D02KmPipTurboDecision", "D*->(D0->Kpipipi)pi": "Hlt2CharmHadDstp2D0Pip_D02KmPimPipPipTurboDecision", "Xc->(D0->Kpi)pi": "Hlt2CharmHadSpec_D0ToKPi_PiTurboDecision", "Xc->(D+->Kpipi)pi": "Hlt2CharmHadSpec_DpPiTurboDecision", "D0->Kpi": "Hlt2RareCharmD02KPiDecision", "phi->KK": "Hlt2IncPhiDecision" } massMon.Histograms = { "Jpsi": [3005, 3186, 50], "Psi2S": [3600, 3770, 50], "D+->Kpipi": [1820., 1920., 100], "Ds+->KKpi": [1920., 2020., 100], "Lambdac->pKpi": [2235., 2335., 100], "Omega->Lambda(LL)K": [1640., 1705., 65], "Omega->Lambda(DD)K": [1640., 1705., 65], "Xi->Lambda(LL)pi": [1290., 1355., 65], "Xi->Lambda(DD)pi": [1290., 1355., 65], "D*->(D0->KK)pi": [1990., 2040., 100], "D*->(D0->Kpi)pi": [1990., 2040., 100], "D*->(D0->Kpipipi)pi": [1990., 2040., 100], "Xc->(D0->Kpi)pi": [1975., 2975., 200], "Xc->(D+->Kpipi)pi": [1995., 2995., 200], "D0->Kpi": [1815., 1915., 100], "phi->KK": [1000., 1040., 80] } if self.getProp("EnableMassMonitor"): monSeq.Members.append(massMon) return monSeq
def main(): # Setup the option parser usage = "usage: %prog [options] inputfile <inputfile>" parser = optparse.OptionParser(usage=usage) parser.add_option("-d", "--datatype", action="store", dest="DataType", default="2009", help="DataType to run on.") parser.add_option("-n", "--evtmax", type="int", action="store", dest="EvtMax", default=1e4, help="Number of events to run") parser.add_option("--dddbtag", action="store", dest="DDDBtag", default='MC09-20090602', help="DDDBTag to use") parser.add_option("--conddbtag", action="store", dest="CondDBtag", default='sim-20090402-vc-md100', help="CondDBtag to use") parser.add_option("--settings", action="store", dest="ThresholdSettings", default='Physics_10000Vis_1000L0_40Hlt1_Apr09', help="ThresholdSettings to use") parser.add_option("-s", "--simulation", action="store_true", dest="Simulation", default=False, help="Run on simulated data") parser.add_option("--dbsnapshot", action="store_true", dest="UseDBSnapshot", default=False, help="Use a DB snapshot") parser.add_option("--snd", action="store", dest="SnapshotDirectory", default='/user/graven/MOORE/conditions', type="string", help="DB Snapshot directory") parser.add_option("--oracle", action="store_true", dest="UseOracle", default=False, help="Use Oracle") parser.add_option("-v", "--verbose", action="store_true", dest="Verbose", default=False, help="Verbose output") parser.add_option("--acceptslow", action="store_true", dest="AcceptIfSlow", default=False, help="Accept slow events") parser.add_option("--hlt1lines", action="store", dest="Hlt1Lines", default="", help="Colon seperated list of additional hlt1 lines") parser.add_option("--hlt2lines", action="store", dest="Hlt2Lines", default="", help="Colon seperated list of additional hlt2 lines") parser.add_option("--rch", action="store_true", dest="RunChangeHandler", default=False, help="Use the RunChangeHandler") parser.add_option("--l0", action="store_true", dest="L0", default=False, help="Rerun L0") parser.add_option("--site", action="store", type="string", dest="Site", default="", help="Site at which we run") parser.add_option("--tempdir", action="store", type="string", dest="Tempdir", default="/tmpdir", help="Tempdir for the filestager") parser.add_option("--tuplefile", action="store", type="string", dest="TupleFile", default="tuples.root", help="NTuple filename") parser.add_option("-f", "--filestager", action="store_true", dest="FileStager", default=False, help="Use the filestager") parser.add_option( "-c", "--verbose_classes", action="store", type="string", dest="VerboseClasses", default="", help="Colon seperated list of classes to be made verbose.") # Parse the command line arguments (options, args) = parser.parse_args() # Put the options into the Moore configurable Moore().ThresholdSettings = options.ThresholdSettings Moore().Verbose = options.Verbose Moore().EvtMax = options.EvtMax Moore().UseDBSnapshot = options.UseDBSnapshot Moore().DBSnapshotDirectory = options.SnapshotDirectory Moore().DDDBtag = options.DDDBtag Moore().CondDBtag = options.CondDBtag Moore().Simulation = options.Simulation Moore().DataType = options.DataType Moore().EnableAcceptIfSlow = options.AcceptIfSlow Moore().outputFile = "" Moore().ForceSingleL0Configuration = False Moore().RequireRoutingBits = [0x0, 0x4, 0x0] Moore().L0 = options.L0 Moore().ReplaceL0BanksWithEmulated = options.L0 if options.UseOracle: CondDB().UseOracle = True site = 'UNKNOWN' try: site = os.environ['DIRACSITE'] except KeyError: if len(options.Site): site = options.Site config = ConfigLFC(site) appendPostConfigAction(config.setLFCSite) # Inputdata is now handled through separate option files, this is for # testing/convenience if len(args): Moore().inputFiles = args try: descriptor = EventSelector().Input[0] if descriptor.find(".raw") != -1: from Configurables import LHCb__RawDataCnvSvc as RawDataCnvSvc EventPersistencySvc().CnvServices.append( RawDataCnvSvc('RawDataCnvSvc')) elif descriptor.find(".dst") != -1: importOptions('$GAUDIPOOLDBROOT/options/GaudiPoolDbRoot.opts') except IndexError: pass freq = 0 if (len(options.VerboseClasses)): freq = 1 else: freq = 100 EventSelector().PrintFreq = freq # RunChangeHandler if options.RunChangeHandler: Moore().EnableRunChangeHandler = True from Configurables import MagneticFieldSvc MagneticFieldSvc().UseSetCurrent = True # XMLSummary from Configurables import LHCbApp LHCbApp().XMLSummary = 'summary.xml' # Use the filestager? if options.FileStager: from FileStager.Configuration import configureFileStager configureFileStager() # Put the comma separated lists of lines into lists hlt1Lines = [] for line in options.Hlt1Lines.split(";"): if (len(line.strip())): hlt1Lines.append(line) hlt2Lines = [] for line in options.Hlt2Lines.split(";"): if (len(line.strip())): hlt2Lines.append(line) # parse the specification of the classes to set to verbose verboseClasses = [] for cl in options.VerboseClasses.split(";"): cl = cl.strip() if (len(cl)): verboseClasses.append(cl.replace("::", "__")) # Instantiate the class to apply the required configuration config = Config(hlt1Lines, hlt2Lines) appendPostConfigAction(config.postConfigAction) # Set the OutputLevel for requested classed if len(verboseClasses): configOL = ConfigOutputLevel(verboseClasses, 1) appendPostConfigAction(configOL.setOutputLevel) # Add the TupleHltDecReports alg to the sequence if options.TupleFile: tupleAlg = TupleHltDecReports("TupleHltDecReports") addTupleAlg = ConfigTupleAlg(filename=options.TupleFile) appendPostConfigAction(addTupleAlg.addTupleAlg) # Instantiate the AppMgr appMgr = AppMgr() # Make sure that we have Hlt lines to run if not len(Sequence("Hlt1").Members) or not len(Sequence("Hlt2").Members): print "error, no lines to run\n" return 2 # Run the required number of events sc = appMgr.run(Moore().EvtMax) if sc.isFailure(): return 2 # Done sc = appMgr.exit() if sc.isFailure(): return 2 else: return 0
def __hlt1_monitoring(self, lines1): monSeq = Sequence("Hlt1MonitorSequence", IgnoreFilterPassed=True) l0Mon = self.__l0_monitoring("Hlt1") monSeq.Members += l0Mon # Tell the monitoring what it should expect.. # the keys are the Labels for the Histograms in the GUI # the values are the Pattern Rules to for the Decisions contributing ## Global monitor from Configurables import HltGlobalMonitor globalMon = self.__globalMonitor("Hlt1") globalMon.DecToGroup = self.__groupLines( [i.decision() for i in lines1], [ ("L0", "Hlt1L0.*Decision"), ("LumiBeamGas", "Hlt1(Lumi|BeamGas).*Decision"), ("SingleMuon", "Hlt1(Single|Track)Muon.*Decision"), ("DiMuon", "Hlt1DiMuon.*Decision"), ("TrackMVA", "Hlt1(Two)?TrackMVADecision"), ("ECAL", "Hlt1.*(Electron|Photon).*Decision"), ("LowMult", "Hlt1LowMult.*Decision"), ("Beauty", "Hlt1B2.*Decision"), ("Commissioning", "Hlt1(ODIN.*|Tell1Error|Incident)Decision"), ("MinBias", "Hlt1MB.*Decision"), ("Calibration", "Hlt1CalibTracking.*"), ("Global", ".*Global.*"), ( "Other", ".*" ) # add a 'catch all' term to pick up all remaining decisions... ]) if self.getProp("EnableGlobalMonitor"): monSeq.Members.append(globalMon) ## Mass monitor from Configurables import HltMassMonitor from DAQSys.Decoders import DecoderDB massMon = HltMassMonitor("Hlt1MassMonitor") massMon.DecReportsLocation = DecoderDB[ "HltDecReportsDecoder/Hlt1DecReportsDecoder"].listOutputs()[0] massMon.SelReportsLocation = DecoderDB[ "HltSelReportsDecoder/Hlt1SelReportsDecoder"].listOutputs()[0] massMon.Decisions = { "Jpsi": "Hlt1DiMuonHighMassDecision", "JpsiAlign": "Hlt1CalibMuonAlignJpsiDecision", "D0->Kpi(det)": 'Hlt1CalibTrackingKPiDetachedDecision', "D0->Kpi": 'Hlt1CalibTrackingKPiDecision', "D0->KK": 'Hlt1CalibTrackingKKDecision', "D0->pipi": "Hlt1CalibTrackingPiPiDecision", "phi->KK": "Hlt1IncPhiDecision" } massMon.DecisionStructure = {"Jpsi": [105.658, 105.658]} massMon.Histograms = { "Jpsi": [3010, 3190, 90], "JpsiAlign": [3010, 3190, 90], "D0->Kpi(det)": [1815, 1915, 50], "D0->Kpi": [1815, 1915, 50], "D0->KK": [1815, 1915, 50], "D0->pipi": [1815, 1915, 50], "phi->KK": [1000, 1040, 80] } if self.getProp("EnableMassMonitor"): monSeq.Members.append(massMon) # Setup the track monitoring from Configurables import Hlt1TrackMonitor import HltTracking from HltTracking.HltSharedTracking import MinimalVelo, VeloTTTracking, HltHPTTracking from Configurables import DeterministicPrescaler trackMon = Hlt1TrackMonitor("Hlt1TrackMonitor") trackMon.VeloTrackLocation = MinimalVelo.outputSelection() trackMon.VeloTTTrackLocation = VeloTTTracking.outputSelection() trackMon.ForwardTrackLocation = HltHPTTracking.outputSelection() # This is not so nice but currently unavoidable from HltTracking.Hlt1TrackNames import Hlt1TrackLoc from HltTracking.HltTrackNames import HltDefaultFitSuffix trackMon.FittedTrackLocation = Hlt1TrackLoc["FitTrack"] from Hlt1Lines.Hlt1GECs import Hlt1GECUnit gecUnit = Hlt1GECUnit(self.getProp("Hlt1TrackMonitorGEC")) prescaler = DeterministicPrescaler( "Hlt1TrackMonitorPrescaler", AcceptFraction=self.getProp("Hlt1TrackMonitorPrescale")) trackMonSeq = Sequence('Hlt1TrackMonitorSequence', Members=[gecUnit, prescaler] + HltHPTTracking.members() + [trackMon]) if self.getProp("EnableTrackMonitor"): monSeq.Members.append(trackMonSeq) return monSeq
def main(): parser = optparse.OptionParser(usage="usage: %prog [options]") parser.add_option("--debug", action="store_true", dest="debug", default=False, help="Debug?") parser.add_option("-d", "--datatype", action="store", dest="DataType", default="2015", help="DataType to run on.") parser.add_option("-n", "--evtmax", type="int", action="store", dest="EvtMax", default=10000, help="Number of events to run") parser.add_option("--dddbtag", action="store", dest="DDDBtag", default='dddb-20150526', help="DDDBTag to use") parser.add_option("--conddbtag", action="store", dest="CondDBtag", default='cond-20150617', help="CondDBtag to use") parser.add_option("--settings", action="store", dest="ThresholdSettings", default='Physics_25ns_September2015', help="ThresholdSettings to use") parser.add_option("--TCK", action="store", dest="TCK", default='', help="HLT TCK. If unspecified,then run from settings") parser.add_option("--simulation", action="store_true", dest="Simulation", default=False, help="Run on simulated data") parser.add_option("--input_rate", action="store", dest="input_rate", default=1.e6, help="Input rate from L0 in Hz") parser.add_option("--tuplefile", action="store", dest="tuplefile", default="", help="Output root file") parser.add_option("--inputdata", action="store", dest="inputdata", default="Physics1600TestNode", help="Name of inputdata") # Parse the arguments (options, args) = parser.parse_args() #### configured from the arguments input_rate = options.input_rate Moore().EvtMax = options.EvtMax Moore().DDDBtag = options.DDDBtag Moore().CondDBtag = options.CondDBtag Moore().Simulation = options.Simulation Moore().DataType = options.DataType if options.TCK != "": Moore().UseTCK = True Moore().InitialTCK = options.TCK else: Moore().ThresholdSettings = options.ThresholdSettings Moore().UseTCK = False #### hard coded here Moore().ForceSingleL0Configuration = False Moore().OutputLevel = 6 Moore().RemoveInputHltRawBanks = True Moore().Simulation = False Moore().Split = "" Moore().CheckOdin = False from Configurables import CondDB CondDB().IgnoreHeartBeat = True CondDB().EnableRunChangeHandler = True EventSelector().PrintFreq = 100 #### configure raw data importOptions('$STDOPTS/DecodeRawEvent.py') EventPersistencySvc().CnvServices.append('LHCb::RawDataCnvSvc') from Configurables import DataOnDemandSvc DataOnDemandSvc().AlgMap['Hlt/DecReports'] = "HltDecReportsDecoder" from GaudiConf import IOHelper if options.inputdata == "Physics1600": IOHelper("MDF").inputFiles([ "mdf:root://eoslhcb.cern.ch//eos/lhcb/wg/HLT/BWdivData/Run164440_L0Filtered_0x00A2_Mika/2015NB_25ns_0x00A2_0.mdf" ]) elif options.inputdata == "Physics1600TestNode": IOHelper("MDF").inputFiles([ "/localdisk/bw_division/run164440_L0Filtered_0x00A2_Mika/2015NB_25ns_0x00A2_0.mdf", "/localdisk/bw_division/run164440_L0Filtered_0x00A2_Mika/2015NB_25ns_0x00A2_1.mdf", "/localdisk/bw_division/run164440_L0Filtered_0x00A2_Mika/2015NB_25ns_0x00A2_2.mdf", "/localdisk/bw_division/run164440_L0Filtered_0x00A2_Mika/2015NB_25ns_0x00A2_3.mdf", "/localdisk/bw_division/run164440_L0Filtered_0x00A2_Mika/2015NB_25ns_0x00A2_4.mdf" ]) ### getting ready for the event loop gaudi = AppMgr(outputlevel=4) gaudi.ExtSvc += ['ToolSvc'] gaudi.ExtSvc.append('DataOnDemandSvc') gaudi.initialize() ### get the list of active line names Lines = {} for level in ["Hlt1", "Hlt2"]: Lines[level] = set() for m in Sequence(level).Members: Lines[level].add(m.name()) ### remove certain lines from the accounting remove = set( ["Hlt1MBNoBias", "Hlt2Transparent", "Hlt1Global", "Hlt2Global"]) Lines["Hlt1"] -= remove Lines["Hlt2"] -= remove ### this is what I would prefer to do... #appendPostConfigAction( setLines(Lines["Hlt1"],Lines["Hlt2"])) ### option to create a tuple with all of the decisions if options.tuplefile != "": from ROOT import (TTree, TFile) from array import array TF = TFile(options.tuplefile, "RECREATE") DecMaps = {} ## dicto of branches for the TTrees DecTrees = {} ## dicto of TTrees for level in ["Hlt1", "Hlt2"]: DecTrees[level] = TTree('Tuple%s' % level, 'Tuple%s' % level) DecMaps[level] = {} for l in Lines[level]: DecMaps[level][l] = array('i', [0]) DecTrees[level].Branch(l, DecMaps[level][l], '%sDecision/I' % l) ### this will be dictionary of lines and their counters for the rates line_stats = {} for line in Lines["Hlt1"].union(Lines["Hlt2"]).union( set(["Hlt1Global", "Hlt2Global"])): line_stats[line] = {"passed_incl": 0, "passed_excl": 0} ### counters for various regex stream_stats = { "Turbo": { "filter": "Hlt2.(?!.*?TurboCalib).*Turbo" }, "Turcal": { "filter": "Hlt2.*TurboCalib" }, "Full": { "filter": "Hlt2.(?!.*?Turbo).(?!.*?TurboCalib)" } } for k, v in stream_stats.iteritems(): v["pass_this_event"] = False v["passed"] = 0 print '*' * 100 print Lines print line_stats print stream_stats print '*' * 100 i = 0 processed = 0 #### start of the event loop while i < Moore().EvtMax: i += 1 # run the sequences on this event gaudi.run(1) processed += 1 if not gaudi.evtsvc()['Hlt1/DecReports']: break ### reset the stream counters for s in stream_stats.keys(): stream_stats[s]["pass_this_event"] = False ### this is a nasty hack since I can't seem to switch ### off some of the Hlt1 lines with a post config action ### so I have to do my own book-keeping to see if one ### of the good hlt1 lines fired. ### I only consider events in Hlt2 if they pass my subset ### of good hlt1 lines. PassMyGlobal = {"Hlt1": False, "Hlt2": False} # loop over levels for level in ["Hlt1", "Hlt2"]: if level == "Hlt2" and not PassMyGlobal["Hlt1"]: continue # do the dec reports exist? # for Hlt2 this check does the job of telling us whether the event passed Hlt1 if gaudi.evtsvc()['%s/DecReports' % level]: # get the dec reports reps = gaudi.evtsvc()['%s/DecReports' % level] # get the list of lines from the reports #lines = reps.decReports().keys() # counter for how many hlt lines fired in this event nPassed = 0 # loop over all lines for line in Lines[level]: # protection. why is this needed though? if not line + "Decision" in reps.decReports().keys(): print '%s not in %s' % (line, reps.decReports().keys()) continue # just check this once LINE_FIRED = reps.decReport(line + "Decision").decision() # my global counter if LINE_FIRED: PassMyGlobal[level] = True # does this event fire any lines that match my "streams"? if LINE_FIRED and level == "Hlt2" and not line == "Hlt2Global": # and not line in remove: for s in stream_stats.keys(): if re.match(stream_stats[s]["filter"], line, flags=0): stream_stats[s]["pass_this_event"] = True # set the variable to be stored in the tuple if options.tuplefile != "": if LINE_FIRED: DecMaps[level][line][0] = 1 else: DecMaps[level][line][0] = 0 # if this is the first fired event then # need to initialise the dictionary entry #if not line in line_stats.keys(): # line_stats[line] = {"passed_incl":0, # "passed_excl":0} # increment the counter for this line if LINE_FIRED: line_stats[line]["passed_incl"] += 1 if not "Global" in line: nPassed += 1 ### for the exclusives # my own global counter if PassMyGlobal[level]: line_stats["%sGlobal" % level]["passed_incl"] += 1 # now go back and count the number of exclusive fires of this line # just need to ignore HltXGlobal for line in Lines[level]: if not line + "Decision" in reps.decReports().keys(): continue # protection if reps.decReport(line + "Decision").decision() and nPassed == 1: if not "Global" in line: line_stats[line]["passed_excl"] += 1 # fill the tree if options.tuplefile != "": DecTrees[level].Fill() # stream accounting for s in stream_stats.keys(): if stream_stats[s]["pass_this_event"] == True: stream_stats[s]["passed"] += 1 # write the root file if options.tuplefile != "": TF.Write() # I was hoping that this would dump all of the gaudi related # printout before I print the summary that I'm interested in. # Apparently this doesn't work, but it's only really a cosmetic thing. #gaudi.finalize() sys.stdout.flush() ############################################# ###### print the summary tables ############# ############################################# for k, v in line_stats.iteritems(): v["processed"] = processed for k, v in stream_stats.iteritems(): v["processed"] = processed GlobalRates = {} print '-' * 100 print 'HLT rates summary starts here' print '-' * 100 #### print the global rates print 'removed lines: %s' % remove print 'processed: %s' % processed print '%s Hlt1Lines' % (len(Lines['Hlt1'])) print '%s Hlt2Lines' % (len(Lines['Hlt2'])) for level in ['Hlt1', 'Hlt2']: rate = getrate(1.e-3 * input_rate, line_stats["%sGlobal" % level]["passed_incl"], line_stats["%sGlobal" % level]["processed"]) print '%sGlobal rate = (%s+-%s)kHz' % (level, rate[0], rate[1]) ### print the stream rates for k, v in stream_stats.iteritems(): print '%s rate = %s kHz' % (k, v["passed"] / float(v["processed"])) #### order by inclusive rate for level in ['Hlt1', 'Hlt2']: iLine = -1 ## counter for line table_row("**", "*Line*", "*Incl.*", "*Excl.*") OrderedStats = {} for key, value in line_stats.iteritems(): if level in key: OrderedStats[key] = value["passed_incl"] for line_name, rate in sorted(OrderedStats.iteritems(), key=lambda (v, k): (k, v), reverse=True): iLine += 1 rate_incl = getrate(1.e-3 * input_rate, line_stats[line_name]["passed_incl"], line_stats[line_name]["processed"]) rate_excl = getrate(1.e-3 * input_rate, line_stats[line_name]["passed_excl"], line_stats[line_name]["processed"]) if "Global" in line_name: GlobalRates[level] = rate_incl else: table_row(iLine, line_name.replace("Decision", ""), "%.2f+-%.2f" % (rate_incl[0], rate_incl[1]), "%.2f+-%.2f" % (rate_excl[0], rate_excl[1])) ## do we pass the test?? MaxRates = {"Hlt1": 400., "Hlt2": 40.} for level in ['Hlt1', 'Hlt2']: if GlobalRates[level][0] > MaxRates[level]: print '%s rate = %s > max = %s' % (level, GlobalRates[level][0], MaxRates[level]) elif GlobalRates[level][0] == 0: print '%s rate is zero' % level else: print '%s rates OK' % level print '-' * 100 print 'HLT rates summary ends here' print '-' * 100 sys.stdout.flush()
def __configureEndSequence(self, streams, routingBits): from Configurables import HltRoutingBitsWriter from Configurables import LoKi__HDRFilter as HltFilter filename = self.getProp('OutputFile') # If there is no output file and we're not running online, or generating a TCK: # don't do anything if not (filename or self.getProp('RunOnline') or self.getProp('GenerateTCK')): return # This is where we plug everything in EndSequence = self.getProp("HltEndSequence") # Filter on writerRequires, if it's empty, the filter will be there, but # pass all writerRequires = self.getProp('WriterRequires') from Configurables import LoKi__VoidFilter as VoidFilter EndSequence.Members += [self.__writerFilter(writerRequires)] # If split is both or HLT1, add the lumi writer to the end sequence. if self.getProp("EnableLumiEventWriting") and self.getProp('Split') != 'Hlt2': from Configurables import HltLumiWriter EndSequence.Members += [HltLumiWriter()] # Routing bits per substream bitsByStream = {sub : (bit, routingBits[bit]) for sub, (bit, _, on) in streams.iteritems() if on} # Configure the output streams if self.getProp('EnableOutputStreaming') and self.getProp('Split') != 'Hlt1': # Case of separate streams # Create a "top-level" stream in OR mode without shortcircuiting to # ensure all streams always run streamsSequence = Sequence("HltOutputStreamsSequence", ModeOR = True, ShortCircuit = False) EndSequence.Members += [streamsSequence] # Location of HLT2 DecReports from DAQSys.Decoders import DecoderDB decoder = DecoderDB["HltDecReportsDecoder/Hlt2DecReportsDecoder"] # Build output streams for streamName, (subs, banks) in self.__outputStreams(streams).iteritems(): # Update with stream specific routing bits substreamBits = {sub : bitsByStream[sub] for sub in subs} # Filter to select events for this stream expressions = sorted([v[1] for v in substreamBits.values()]) if len(expressions) > 1: streamPredicate = " | ".join(['( %s )' % s for s in expressions]) else: streamPredicate = expressions[0] # The output stream sequence, with it's HltFilter streamSequence = Sequence(streamName + "OutputSequence") streamFilter = HltFilter(self.__streamFilterName(streamName), Code = self.__addLumi(subs, streamPredicate), Location = decoder.listOutputs()[0]) streamSequence.Members = [streamFilter] # This is the location for the raw event copy of this stream rawLocation = self.__rawLocationPattern() % streamName # Sequence for the output algorithms prepSequence = Sequence(streamName + "RawEventSequence", ModeOR = True, ShortCircuit = False) streamSequence.Members += [prepSequence] # Always pass the HLT1 routing bits rbs = {k : routingBits[k] for k in routingBits.iterkeys() if k < 64} self.__addLumiToStreamBits(rbs, substreamBits) # Make the expression for not-lumi-exclusive and add it to the routing bits writer self.__addNotExclusiveLumiBit(rbs, streamPredicate) prepSequence.Members = self.__rawEventAlgs(streamName, banks, streamPredicate, rbs, rawLocation) # Add the output sequence to the streams sequence streamsSequence.Members += [streamSequence] # We add the routing bits writer for the original raw event so they # are written there too. This is needed for running in flagging mode # with a single output stream. self.__addLumiToStreamBits(routingBits, bitsByStream) self.__addNotExclusiveLumiBit(routingBits, self.getProp('NotLumiPredicate')) streamsSequence.Members += self.__rawEventAlgs('', [], '', routingBits) else: # Case of single output stream rbs = None if self.getProp("Split") != "Hlt1": # Hlt2 routing bits make no sense when running only Hlt1 rbs = deepcopy(routingBits) # not-exclusive lumi bit self.__addNotExclusiveLumiBit(rbs, self.getProp('NotLumiPredicate')) # Update routing bits that require lumi self.__addLumiToStreamBits(rbs, bitsByStream) # Plug the single global instance directly into the end sequence rawAlgs = self.__rawEventAlgs('', [], self.getProp('NotLumiPredicate'), rbs) prepSequence = Sequence("RawEventSequence", ModeOR = True, ShortCircuit = False, Members = rawAlgs) EndSequence.Members += [prepSequence]
def __apply_configuration__(self): """ HLT Afterburner configuration """ from HltTracking.Hlt2TrackingConfigurations import Hlt2BiKalmanFittedForwardTracking from HltTracking.Hlt2TrackingConfigurations import Hlt2BiKalmanFittedDownstreamTracking Afterburner = self.getProp("Sequence") if self.isPropertySet( "Sequence") else None if not Afterburner: return AfterburnerFilterSeq = Sequence("HltAfterburnerFilterSequence") Afterburner.Members += [AfterburnerFilterSeq] if self.getProp("Hlt2Filter"): from DAQSys.Decoders import DecoderDB decoder = DecoderDB["HltDecReportsDecoder/Hlt2DecReportsDecoder"] from Configurables import LoKi__HDRFilter as HDRFilter hlt2Filter = HDRFilter('HltAfterburnerHlt2Filter', Code=self.getProp("Hlt2Filter"), Location=decoder.listOutputs()[0]) AfterburnerFilterSeq.Members += [hlt2Filter] AfterburnerSeq = Sequence("HltAfterburnerSequence", IgnoreFilterPassed=True) AfterburnerFilterSeq.Members += [AfterburnerSeq] if self.getProp("EnableHltRecSummary"): from Configurables import RecSummaryAlg seq = Sequence("RecSummarySequence") tracks = Hlt2BiKalmanFittedForwardTracking().hlt2PrepareTracks() tracksDown = Hlt2BiKalmanFittedDownstreamTracking( ).hlt2PrepareTracks() muonID = Hlt2BiKalmanFittedForwardTracking().hlt2MuonID() from HltLine.HltDecodeRaw import DecodeVELO, DecodeIT, DecodeTT, DecodeSPD, DecodeMUON decoders = { "Velo": (DecodeVELO, "VeloLiteClustersLocation"), "TT": (DecodeTT, "clusterLocation"), "IT": (DecodeIT, "clusterLocation"), "SPD": (DecodeSPD, "DigitsContainer"), 'Muon': (DecodeMUON, "OutputLocation"), 'MuonTr': (muonID, "MuonTrackLocation") } decoders = { k: (bm.members(), bm.members()[-1].getProp(loc)) for (k, (bm, loc)) in decoders.iteritems() } from HltTracking.HltPVs import PV3D PVs = PV3D("Hlt2") from HltTracking.HltTrackNames import Hlt2TrackLoc recSeq = Sequence("RecSummaryRecoSequence", IgnoreFilterPassed=True) from itertools import chain from Hlt2Lines.Utilities.Utilities import uniqueEverseen recSeq.Members = list( uniqueEverseen( chain.from_iterable( [dec[0] for dec in decoders.itervalues()] + [tracks, tracksDown, muonID, PVs]))) summary = RecSummaryAlg( 'Hlt2RecSummary', SummaryLocation=self.getProp("RecSummaryLocation"), HltSplitTracks=True, SplitLongTracksLocation=tracks.outputSelection(), SplitDownTracksLocation=tracksDown.outputSelection(), PVsLocation=PVs.output, VeloClustersLocation=decoders['Velo'][1], ITClustersLocation=decoders['IT'][1], TTClustersLocation=decoders['TT'][1], SpdDigitsLocation=decoders['SPD'][1], MuonCoordsLocation=decoders['Muon'][1], MuonTracksLocation=decoders['MuonTr'][1]) seq.Members = [recSeq, summary] AfterburnerSeq.Members += [seq] if self.getProp("AddAdditionalTrackInfos"): from GaudiKernel.SystemOfUnits import mm from Configurables import LoKi__VoidFilter as Filter trackLocations = [ Hlt2BiKalmanFittedForwardTracking().hlt2PrepareTracks( ).outputSelection(), Hlt2BiKalmanFittedDownstreamTracking().hlt2PrepareTracks(). outputSelection() ] infoSeq = Sequence("TrackInfoSequence", IgnoreFilterPassed=True) # I don't want to pull in reconstruction if not run before, then there should be also no candidates needing this information # This is anyhow done by the RecSummary above members = [ Hlt2BiKalmanFittedForwardTracking().hlt2PrepareTracks( ).members() + Hlt2BiKalmanFittedDownstreamTracking(). hlt2PrepareTracks().members() ] infoSeq.Members += list( uniqueEverseen(chain.from_iterable(members))) prefix = "Hlt2" trackClones = Sequence(prefix + "TrackClonesSeq") #checkTracks = Filter(prefix+"CheckTrackLoc",Code = "EXISTS('%(trackLocLong)s') & EXISTS('%(trackLocDown)s')" % {"trackLocLong" : trackLocations[0], "trackLocDown" : trackLocations[1]}) #trackClones.Members += [checkTracks] from Configurables import TrackBuildCloneTable, TrackCloneCleaner cloneTable = TrackBuildCloneTable(prefix + "FindTrackClones") cloneTable.maxDz = 500 * mm cloneTable.zStates = [0 * mm, 990 * mm, 9450 * mm] cloneTable.klCut = 5e3 cloneTable.inputLocations = trackLocations cloneTable.outputLocation = trackLocations[ 0] + "Downstream" + "Clones" cloneCleaner = TrackCloneCleaner(prefix + "FlagTrackClones") cloneCleaner.CloneCut = 5e3 cloneCleaner.inputLocations = trackLocations cloneCleaner.linkerLocation = cloneTable.outputLocation trackClones.Members += [cloneTable, cloneCleaner] infoSeq.Members += [trackClones] AfterburnerSeq.Members += [infoSeq] # Add VeloCharge to protoparticles for dedx veloChargeSeq = Sequence("VeloChargeSequence") from Configurables import ChargedProtoParticleAddVeloInfo protoLocation = Hlt2BiKalmanFittedForwardTracking( ).hlt2ChargedAllPIDsProtos().outputSelection() checkProto = Filter("CheckProtoParticles", Code="EXISTS('%(protoLoc)s')" % {"protoLoc": protoLocation}) addVeloCharge = ChargedProtoParticleAddVeloInfo( "Hlt2AddVeloCharge") addVeloCharge.ProtoParticleLocation = protoLocation decodeVeloFullClusters = DecoderDB[ "DecodeVeloRawBuffer/createVeloClusters"].setup() veloChargeSeq.Members += [ checkProto, decodeVeloFullClusters, addVeloCharge ] AfterburnerSeq.Members += [veloChargeSeq] persistRecoLines = self._persistRecoLines() if self.getProp("AddPIDToDownstream") and ( len(persistRecoLines) > 0 or len(self.getProp("Hlt2DownstreamFilter")) > 0): from Configurables import LoKi__HDRFilter as HDRFilter if (len(persistRecoLines) > 0 and len(self.getProp("Hlt2DownstreamFilter")) > 0): code = self._persistRecoFilterCode( persistRecoLines) + " | " + self._filterCode( self.getProp("Hlt2DownstreamFilter")) elif len(persistRecoLines) > 0: code = self._persistRecoFilterCode(persistRecoLines) elif len(self.getProp("Hlt2DownstreamFilter")) > 0: code = self._filterCode(self.getProp("Hlt2DownstreamFilter")) # Activate Downstream RICH for all PersistReco lines from DAQSys.Decoders import DecoderDB decoder = DecoderDB["HltDecReportsDecoder/Hlt2DecReportsDecoder"] hlt2DownstreamFilter = HDRFilter('DownstreamHlt2Filter', Code=code, Location=decoder.listOutputs()[0]) downstreamPIDSequence = Sequence("Hlt2AfterburnerDownstreamPIDSeq") downstreamPIDSequence.Members += [hlt2DownstreamFilter] downstreamTracking = Hlt2BiKalmanFittedDownstreamTracking() tracksDown = downstreamTracking.hlt2PrepareTracks() protosDown = downstreamTracking.hlt2ChargedNoPIDsProtos() chargedProtosOutputLocation = protosDown.outputSelection() richPid = downstreamTracking.hlt2RICHID() downstreamPIDSequence.Members += list( uniqueEverseen( chain.from_iterable([tracksDown, protosDown, richPid]))) from Configurables import ChargedProtoParticleAddRichInfo, ChargedProtoParticleAddMuonInfo downstreamRichDLL_name = "Hlt2AfterburnerDownstreamProtoPAddRich" downstreamRichDLL = ChargedProtoParticleAddRichInfo( downstreamRichDLL_name) downstreamRichDLL.InputRichPIDLocation = richPid.outputSelection() downstreamRichDLL.ProtoParticleLocation = chargedProtosOutputLocation # Add the muon info to the DLL downstreamMuon_name = "Hlt2AfterburnerDownstreamProtoPAddMuon" downstreamMuon = ChargedProtoParticleAddMuonInfo( downstreamMuon_name) downstreamMuon.ProtoParticleLocation = chargedProtosOutputLocation downstreamMuon.InputMuonPIDLocation = downstreamTracking.hlt2MuonID( ).outputSelection() # Add the Calo info to the DLL # from Configurables import (ChargedProtoParticleAddEcalInfo, ChargedProtoParticleAddBremInfo, ChargedProtoParticleAddHcalInfo, ChargedProtoParticleAddPrsInfo, ChargedProtoParticleAddSpdInfo) caloPidLocation = downstreamTracking.hlt2CALOID().outputSelection() downstreamEcal = ChargedProtoParticleAddEcalInfo( "HltAfterburnerDownstreamProtoPAddEcal") downstreamBrem = ChargedProtoParticleAddBremInfo( "HltAfterburnerDownstreamProtoPAddBrem") downstreamHcal = ChargedProtoParticleAddHcalInfo( "HltAfterburnerDownstreamProtoPAddHcal") downstreamPrs = ChargedProtoParticleAddPrsInfo( "HltAfterburnerDownstreamProtoPAddPrs") downstreamSpd = ChargedProtoParticleAddSpdInfo( "HltAfterburnerDownstreamProtoPAddSpd") for alg in (downstreamEcal, downstreamBrem, downstreamHcal, downstreamPrs, downstreamSpd): alg.setProp("ProtoParticleLocation", chargedProtosOutputLocation) alg.setProp("Context", caloPidLocation) downstreamPIDSequence.Members += [alg] from Configurables import ChargedProtoCombineDLLsAlg, ChargedProtoANNPIDConf downstreamCombine_name = "Hlt2AfterburnerDownstreamRichCombDLLs" downstreamCombine = ChargedProtoCombineDLLsAlg( downstreamCombine_name) downstreamCombine.ProtoParticleLocation = downstreamTracking.hlt2ChargedNoPIDsProtos( ).outputSelection() from Hlt2Lines.Utilities.Utilities import uniqueEverseen downstreamPIDSequence.Members += [ downstreamMuon, downstreamRichDLL, downstreamCombine ] probNNDownSeqName = self._instanceName(ChargedProtoANNPIDConf) probNNDownSeq = GaudiSequencer(probNNDownSeqName + "Seq") annconfDown = ChargedProtoANNPIDConf(probNNDownSeqName) annconfDown.DataType = downstreamTracking.DataType annconfDown.TrackTypes = ["Downstream"] annconfDown.RecoSequencer = probNNDownSeq annconfDown.ProtoParticlesLocation = downstreamTracking.hlt2ChargedNoPIDsProtos( ).outputSelection() downstreamPIDSequence.Members += [probNNDownSeq] AfterburnerSeq.Members += [downstreamPIDSequence] # Configure and add the persist reco AfterburnerSeq.Members += [self._persistRecoSeq()]
def setLevel(self, conf): seq = type(Sequence()) conf.OutputLevel = self._level if type(conf) == seq: for member in conf.Members: self.setLevel(member)