Exemple #1
0
    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 __apply_configuration__(self):
      from HltLine.HltLine import Hlt1Line   as Line
      #from Hlt1GECs import Hlt1_GEC
      #for i in [ 'VELO','IT','OT' ] :
      #    # WARNING: these imply we always decode Velo & IT
      #    Line('GECPassThrough%s'  % i
      #        , L0DU = 'L0_DECISION_PHYSICS'
      #        , prescale = self.prescale
      #        , postscale = self.postscale
      #        , algos = [Hlt1_GEC(i,reject=False)]
      #        )
      Line('ODINPhysics',   ODIN = self.getProp('ODINPhysics')
          , prescale = self.prescale
          , postscale = self.postscale
          )
      Line('ODINTechnical', ODIN = self.getProp('ODINTechnical')
          , prescale = self.prescale
          , postscale = self.postscale
          )
      from Configurables import FilterByBankType
      Line('Tell1Error'
          , algos = [ FilterByBankType('Hlt1Tell1ErrorDecision'
                                      , PassSelectedEvents = True
                                      , BankNames = [ ".*Error" ]
                                      )
                    ]
          , prescale = self.prescale
          , postscale = self.postscale
          )
      Line('NZSVelo'
          , algos = [ FilterByBankType('Hlt1NZSVeloDecision'
                                      , PassSelectedEvents = True
                                      , BankNames = [ "VeloFull" ]
                                      )
                    ]
          , prescale = self.prescale
          , postscale = self.postscale
          )
      from Configurables import HltIncidentFilter
      Line('Incident'
          , algos = [ HltIncidentFilter('Hlt1IncidentDecision') ]
          , prescale = self.prescale
          , postscale = self.postscale
          , priority = 254
          )
      from DAQSys.Decoders import DecoderDB
      from Configurables import LoKi__HDRFilter   as HDRFilter
      decoder = DecoderDB["HltDecReportsDecoder/Hlt1DecReportsDecoder"]
      # TODO: just want presence, so HLT_ERRORBITS(0xffff) would be nice to have...
      Line('ErrorEvent',prescale = self.prescale, postscale = self.postscale
          , algos = [HDRFilter('Hlt1ErrorEventCounter' ,
                                Code = "HLT_COUNT_ERRORBITS_RE('^Hlt1.*',0xffff) > 0",
                                Location = decoder.listOutputs()[0])]
          , priority = 254
          )
      from HltTracking.HltSharedTracking import MinimalVelo
      from HltLine.HltLine import Hlt1Member   as Member
      Line ( 'VeloClosingMicroBias'
                  , prescale = self.prescale
                  , ODIN = self.getProp('ODINVeloClosing')
                  , algos = [ MinimalVelo
                            , Member( 'Hlt::TrackFilter','All'
                                    , Code = [ 'TrALL' ]
                                    , InputSelection = 'TES:%s' % MinimalVelo.outputSelection()
                                    , OutputSelection = '%Decision'
                                    )
                            ]
                  , postscale = self.postscale
                  )
def doMyAlignChanges():
    from Configurables import TESCheck
    TESCheck().Stop = False
    TESCheck().Enable = False

    TweakFitter('FitDownstream')
    TweakFitter('FitMatch')
    TweakFitter('FitSeed')
    TweakFitter('RefitSeed')
    TweakFitter('FitForward')
    TweakFitter('FitVelo')
    TweakFitter('FitVeloTT')
    TweakFitter('FitBest')
    TweakFitter('TrackRefitter')

    TrackEventFitter('TrackRefitter').Fitter.UpdateTransport = True

    ApplicationMgr().ExtSvc += ["DataOnDemandSvc", "ANNDispatchSvc"]

    # insert a filter get only dimuons
    from Configurables import LoKi__HDRFilter as HDRFilter
    hltfilter = HDRFilter(
        'HLT2JPsi',
        Code="HLT_PASS_RE( 'Hlt2.*Muon.*JPsi.*Decision' )"
        #Code = "HLT_PASS_RE( '.*Decision' )"
        #Code = "HLT_PASS_RE('Hlt2.*Decision')"
        #Code ="HLT_PASS('Hlt2ExpressHLT1PhysicsDecision')"
    )
    hltfilter.Preambulo += ["from LoKiCore.functions import *"]

    from Configurables import HltDecReportsDecoder
    DataOnDemandSvc().AlgMap["Hlt/DecReports"] = HltDecReportsDecoder(
        OutputLevel=4)
    GaudiSequencer('EscherSequencer').Members.insert(1, hltfilter)
    #from Configurables import DecReportDumper
    #GaudiSequencer('EscherSequencer').Members.insert(2,DecReportDumper())

    #from Configurables import LoKi__VoidFilter as LokiFilter
    #stripfilter = LokiFilter ( 'JPsiMuMuFilter' ,
    #                           Code = "0 < CONTAINS ( '/Event/Dimuon/Phys/FullDSTDiMuonJpsi2MuMuLine/Particles' )"
    #                           #,Preambulo = [ "from LoKiTrigger.decorators import *" ]
    #                           )
    #GaudiSequencer('EscherSequencer').Members.insert(2,stripfilter)

    # add a filter on Velo tracks
    from Configurables import TrackListFilter
    GaudiSequencer("RecoVELOSeq").Members += [
        TrackListFilter("VeloFilter", inputLocation="Rec/Track/Velo")
    ]

    from Configurables import TrackMultiplicityFilter
    GaudiSequencer("RecoDecodingSeq").Members += [
        TrackMultiplicityFilter("MultFilter", MaxNumITHits=600)
    ]

    from Configurables import TrackDiMuonMonitor
    TrackDiMuonMonitor().MaxTwoProngVertexChi2 = 4

    from Configurables import TrackHitMapMonitor
    GaudiSequencer("MoniTrSeq").Members.append(TrackHitMapMonitor())

    #from Configurables import STOfflinePosition
    #itClusterPosition = STOfflinePosition('ToolSvc.ITClusterPosition')
    #itClusterPosition.ErrorVec = [0.28, 0.22, 0.35, 0.35]
    #itClusterPosition.APE = 0.1

    from Configurables import ST__STClusterMonitor
    ST__STClusterMonitor('ITClusterMonitor').HitMaps = True
Exemple #4
0
    def createConfigurable(self,
                           TESPrefix="Strip",
                           HDRLocation='Phys/DecReports'):

        if self._configurable != None:
            log.info("Configurables already created for line %s, skipping" %
                     self.subname())
            return self._configurable

        if self._HDRLocation == None:
            self.fullHDRLocation = TESPrefix + "/" + HDRLocation
        else:
            self.fullHDRLocation = self._HDRLocation

        # check for forbidden attributes
        args = self._args

        mdict = {}
        for key in args:
            if key in _protected_:
                raise AttributeError, "The attribute'%s' is protected for %s" % (
                    key, self.type())
            mdict[key] = args[key]

        line = self.subname()

        # create the line configurable
        # NOTE: even if pre/postscale = 1, we want the scaler, as we may want to clone configurations
        #       and change them -- and not having the scaler would be problem in that case...
        mdict.update({
            'Prescale':
            Scaler(prescalerName(line, 'Stripping'),
                   AcceptFraction=self._prescale),
            'Postscale':
            Scaler(postscalerName(line, 'Stripping'),
                   AcceptFraction=self._postscale)
        })

        if self._ODIN:
            if isinstance(self._ODIN, str):
                mdict.update(
                    {'ODIN': ODINFilter(odinentryName(line), Code=self._ODIN)})
            elif isinstance(self._ODIN,
                            (tuple, list)) and 2 == len(self._ODIN):
                mdict.update({
                    'ODIN':
                    ODINFilter(odinentryName(line),
                               Code=self._ODIN[0],
                               Preambulo=self._ODIN[1])
                })
            elif isinstance(self._ODIN, dict):
                mdict.update(
                    {'ODIN': ODINFilter(odinentryName(line), **self._ODIN)})
            else:
                raise TypeError, "Wrong ODIN attribute: %s " % self._ODIN

        if self._L0DU:
            if isinstance(self._L0DU, str):
                mdict.update(
                    {'L0DU': L0Filter(l0entryName(line), Code=self._L0DU)})
            if isinstance(self._L0DU, (tuple, list)) and 2 == len(self._L0DU):
                mdict.update({
                    'L0DU':
                    L0Filter(l0entryName(line),
                             Code=self._L0DU[0],
                             Preambulo=self._L0DU[1])
                })
            if isinstance(self._L0DU, dict):
                mdict.update(
                    {'L0DU': L0Filter(l0entryName(line), **self._L0DU)})

        from DAQSys.Decoders import DecoderDB
        Hlt1DecReportsDecoder = DecoderDB[
            "HltDecReportsDecoder/Hlt1DecReportsDecoder"].setup()
        Hlt2DecReportsDecoder = DecoderDB[
            "HltDecReportsDecoder/Hlt2DecReportsDecoder"].setup()
        if self._HLT:

            log.warning(
                self.name() +
                " : The usage of unique HLT is deprecated and will not work on data taken from 2015 onward. Please move to use HLT1 and HLT2."
            )

            if isinstance(self._HLT, str):
                mdict.update(
                    {'HLT': HDRFilter(hltentryName(line), Code=self._HLT)})
            if isinstance(self._HLT, (tuple, list)) and 2 == len(self._HLT):
                mdict.update({
                    'HLT':
                    HDRFilter(hltentryName(line),
                              Code=self._HLT[0],
                              Preambulo=self._HLT[1])
                })
            if isinstance(self._HLT, dict):
                mdict.update(
                    {'HLT': HDRFilter(hltentryName(line), **self._HLT)})

        if self._HLT1:
            if isinstance(self._HLT1, str):
                mdict.update({
                    'HLT1':
                    HDRFilter(hlt1entryName(line),
                              Code=self._HLT1,
                              Location=Hlt1DecReportsDecoder.
                              OutputHltDecReportsLocation)
                })
            if isinstance(self._HLT1, (tuple, list)) and 2 == len(self._HLT1):
                mdict.update({
                    'HLT1':
                    HDRFilter(hlt1entryName(line),
                              Code=self._HLT1[0],
                              Location=Hlt1DecReportsDecoder.
                              OutputHltDecReportsLocation,
                              Preambulo=self._HLT1[1])
                })
            if isinstance(self._HLT1, dict):
                mdict.update(
                    {'HLT1': HDRFilter(hlt1entryName(line), **self._HLT1)})

        if self._HLT2:
            if isinstance(self._HLT2, str):
                mdict.update({
                    'HLT2':
                    HDRFilter(hlt2entryName(line),
                              Code=self._HLT2,
                              Location=Hlt2DecReportsDecoder.
                              OutputHltDecReportsLocation)
                })
            if isinstance(self._HLT2, (tuple, list)) and 2 == len(self._HLT2):
                mdict.update({
                    'HLT2':
                    HDRFilter(hlt2entryName(line),
                              Code=self._HLT2[0],
                              Location=Hlt2DecReportsDecoder.
                              OutputHltDecReportsLocation,
                              Preambulo=self._HLT2[1])
                })
            if isinstance(self._HLT2, dict):
                mdict.update(
                    {'HLT2': HDRFilter(hlt2entryName(line), **self._HLT2)})

# Add extra info tools if needed
        if self.ExtraInfoTools:
            from Configurables import AddExtraInfo
            extraInfoAlg = AddExtraInfo('ExtraInfo_' + self.name())
            if self.ExtraInfoSelections:
                extraInfoAlg.Inputs = self.selectionsToLocations(
                    self.ExtraInfoSelections)
            else:
                extraInfoAlg.Inputs = [self.outputLocation()]
            if self.ExtraInfoDaughters:
                extraInfoAlg.MaxLevel = self.ExtraInfoRecursionLevel
                extraInfoAlg.DaughterLocations = self.selectionsToLocations(
                    self.ExtraInfoDaughters)
            else:
                extraInfoAlg.MaxLevel = 0

            toolNames = []
            toolNum = 0

            for itool in self.ExtraInfoTools:
                toolNum += 1
                toolType = itool["Type"]
                toolName = "Tool%d" % toolNum
                module = __import__("Configurables", globals(), locals(),
                                    [toolType])
                toolClass = getattr(module, toolType)
                extraInfoAlg.addTool(toolClass, toolName)
                toolInstance = getattr(extraInfoAlg, toolName)
                for property, value in itool.iteritems():
                    if property == "Type": continue
                    setattr(toolInstance, property, value)
                toolNames += [toolType + '/' + toolName]
            extraInfoAlg.Tools = toolNames
            self._members.append(extraInfoAlg)

        if self.RelatedInfoTools != None:
            self.addRelatedInfo()
            if self.RelatedInfoFilter:
                if hasattr(type(self.RelatedInfoFilter),
                           "CloneFilteredParticles"):
                    log.debug(
                        "Setting CloneFilteredParticles = True for RelatedInfoFilter %s "
                        % self.RelatedInfoFilter.name())
                    self.RelatedInfoFilter.CloneFilteredParticles = True
                self._members.append(self.RelatedInfoFilter)
                oldOutput = self.outputLocation()
                self._outputloc = "Phys/" + self.RelatedInfoFilter.name(
                ) + "/Particles"
                log.debug('Redefined OutputLocation for line ' + self.name() +
                          ' from ' + oldOutput + ' to ' + self._outputloc)
                self.addRelatedInfo()

        # Add flavour tagging tool to the end of line sequence if needed
        if self._EnableFlavourTagging:
            if not self.outputLocation() or self.outputLocation() == "":
                raise AttributeError, "Line %s does not have output, cannot do flavour tagging" % self.name(
                )
            from Configurables import BTagging
            btag = BTagging("BTag_" + self.name(),
                            Inputs=[self.outputLocation()])
            self._members.append(btag)

        if self._members:

            filterSeq = GaudiSequencer(filterName(line, 'Stripping'),
                                       Members=self._members,
                                       OutputLevel=WARNING)

            mdict.update({'Filter1': filterSeq})

        #print self._members

        mdict.update({'HltDecReportsLocation': self.fullHDRLocation})
        if (self.outputLocation()):
            mdict.update({'OutputLocation': self.outputLocation()})

        __mdict = deepcopy(mdict)
        from Configurables import StrippingAlg
        self._configurable = StrippingAlg(self.name(), **__mdict)

        # put upper limit on combinatorics
        if self.MaxCandidates == "Override": self.MaxCandidates = None
        if self.MaxCombinations == "Override": self.MaxCombinations = None
        limitCombinatorics(self._configurable,
                           MaxCandidates=self.MaxCandidates,
                           MaxCombinations=self.MaxCombinations)

        log.debug(' created StrippingAlg configurable for' + self._name)
        log.debug(self._configurable)

        return self._configurable
Exemple #5
0
jseq = GaudiSequencer("RawEventSplitSeq")
juggler = RawEventJuggler("rdstJuggler")
juggler.Sequencer = jseq
juggler.Input = 0.3  # 2015 Online (Moore) format
juggler.Output = 4.2  # Reco15 format

#help(juggler)

#from Configurables import DaVinci
#DaVinci().prependToMainSequence( [jseq] )

# filter out events triggered exclusively by CEP lines
from Configurables import LoKi__HDRFilter as HDRFilter
from DAQSys.Decoders import DecoderDB
Hlt2DecReportsDecoder = DecoderDB[
    "HltDecReportsDecoder/Hlt2DecReportsDecoder"].setup()
HLTFilter2 = HDRFilter(
    "LoKiHLT2Filter",
    Code=
    "HLT_PASS_RE('Hlt2(?!Forward)(?!DebugEvent)(?!Lumi)(?!Transparent)(?!PassThrough)(?!LowMult).*Decision')",
    Location=Hlt2DecReportsDecoder.OutputHltDecReportsLocation)
otherseq = GaudiSequencer("filters")
otherseq.Members = [jseq, HLTFilter2]

DaVinci().EventPreFilters = [jseq, HLTFilter2]

#DaVinci().prependToMainSequence(HLTFilter2)

# input file
importOptions("$STRIPPINGSELECTIONSROOT/tests/data/Reco15a_Run164668.py")
    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()]

if DaVinci().Simulation and has_flag('CUTFLOW'):
    line_strip = 'b2D0MuXB2DMuForTauMuLine'  # Name of the stripping line back in 2011.
elif has_flag('MU_MISID'):
    line_strip = 'b2D0MuXFakeB2DMuNuForTauMuLine'
else:
    line_strip = 'b2D0MuXB2DMuNuForTauMuLine'


# Differences between 'HLT_PASS' and 'HLT_PASS_RE':
#   'HLT_PASS' matches the line *exactly*
#   'HLT_PASS_RE' (which was used in the starter kit) use regular expression to
#   check if line given is a part of the lines of the events.
fltr_strip = HDRFilter(
    'StrippedBCands',
    Code="HLT_PASS('Stripping{0}Decision')".format(line_strip))

hlt2_trigger = 'Hlt2CharmHadD02HH_D02KPiDecision'
fltr_hlt = HDRFilter(
    'Hlt2TriggeredD0',
    Code="HLT_PASS('{0}')".format(hlt2_trigger))


if not DaVinci().Simulation and not has_flag('BARE'):
    DaVinci().EventPreFilters = [fltr_strip, fltr_hlt]


#######################
# Particle references #
#######################