Exemple #1
0
    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 _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])
Exemple #3
0
    def __init__( self, name, config ):
        LineBuilder.__init__( self, name, config )

        #######################################################################
        ###                                                                 ###
        ###     VELO BASED VERTEXING SEQUENCE                               ###
        ###                                                                 ###
        #######################################################################

        bestTracks = AutomaticData("Rec/Track/Best")

        withVeloTracksForVertexing = bestTracks
        if self.configurationParameter("FilterVelo")["Apply"]:
            from GaudiConfUtils.ConfigurableGenerators import SelectVeloTracksNotFromPV

            veloWithIP = SelectVeloTracksNotFromPV()
            self.validatedSetProps( "FilterVelo", DisplVerticesLinesConf.veloWithIPCuts, veloWithIP )

            withVeloTracksForVertexing = Selection( "%sVeloFilteredTracks" % self.name()
                                           , RequiredSelections = [ bestTracks ]
                                           , Algorithm = veloWithIP
                                           )

        # Displaced Vertex reconstruction with best tracks (dominated by those with a Velo segment)
        from Configurables import PatPV3D, PVOfflineTool, PVSeed3DTool, LSAdaptPV3DFitter, LSAdaptPVFitter

        withVeloVertexFinder = PVOfflineTool( "%sWithVeloVertexFinder" % self.name()
                                 , PVsChi2Separation = 0
                                 , PVsChi2SeparationLowMult = 0
                                 , PVSeedingName   = "PVSeed3DTool"
                                 , PVFitterName    = "LSAdaptPV3DFitter"
                                 )
        withVeloVertexFinder.addTool(PVSeed3DTool)
        withVeloVertexFinder.PVSeed3DTool.MinCloseTracks       = 3

        withVeloVertexFinder.addTool(LSAdaptPV3DFitter)
        withVeloVertexFinder.LSAdaptPV3DFitter.maxIP2PV        = 2.0*units.mm
        withVeloVertexFinder.LSAdaptPV3DFitter.MinTracks       = 4

        withVeloVertexAlg = PatPV3D( "%sWithVeloVertexAlg" )
        withVeloVertexAlg.addTool( withVeloVertexFinder, name="PVOfflineTool" )

        withVeloVertexing = SelectionPatPV3DWrapper( "%sWithVeloVertexing" % self.name()
                              , withVeloVertexAlg
                              , RequiredSelections = [ withVeloTracksForVertexing ]
                              )

        # Make Particles out of the RecVertices
        from GaudiConfUtils.ConfigurableGenerators import LLParticlesFromRecVertices

        rv2pWithVelo = LLParticlesFromRecVertices(
                           VerticesFromVeloOnly = False
                         , WriteP2PVRelations   = False
                         , ForceP2PVBuild       = False
                         , VeloProtoParticlesLocation = "Phys/%s/VeloProtoP" % self.name()
                         )
        self.validatedSetProps( "RV2PWithVelo", DisplVerticesLinesConf.recoCuts + DisplVerticesLinesConf.singleCuts, rv2pWithVelo )

        withVeloCandidates = Selection( "%sWithVeloCandidates" % self.name()
                               , RequiredSelections = [ withVeloVertexing ]
                               , Algorithm          = rv2pWithVelo
                               , InputDataSetter    = "RecVertexLocations"
                               )

        #######################################################################
        ###                                                                 ###
        ###     DOWNSTREAM VERTEXING SEQUENCE                               ###
        ###                                                                 ###
        #######################################################################

        from GaudiConfUtils.ConfigurableGenerators import CopyDownstreamTracks

        downTracks = Selection( "%sDownstreamTracks" % self.name()
                       , RequiredSelections = [ bestTracks ]
                       , Algorithm          = CopyDownstreamTracks()
                       )

        # Displaced Vertex reconstruction from downstream tracks
        downVertexFinder = PVOfflineTool( "%sDownVertexFinder" % self.name()
                                        , RequireVelo     = False
                                        , PVsChi2Separation = 0
                                        , PVsChi2SeparationLowMult = 0
                                        , PVSeedingName   = "PVSeed3DTool"
                                        , PVFitterName    = "LSAdaptPVFitter"
                                        )
        downVertexFinder.addTool(PVSeed3DTool)
        downVertexFinder.PVSeed3DTool.TrackPairMaxDistance = 2.0*units.mm
        downVertexFinder.PVSeed3DTool.zMaxSpread           = 20.0*units.mm
        downVertexFinder.PVSeed3DTool.MinCloseTracks       = 4
        downVertexFinder.addTool(LSAdaptPVFitter)
        downVertexFinder.LSAdaptPVFitter.MinTracks          = 4
        downVertexFinder.LSAdaptPVFitter.maxChi2            = 400.0
        downVertexFinder.LSAdaptPVFitter.maxDeltaZ          = 0.0005 *units.mm
        downVertexFinder.LSAdaptPVFitter.maxDeltaChi2NDoF   = 0.002
        downVertexFinder.LSAdaptPVFitter.acceptTrack        = 0.000000001
        downVertexFinder.LSAdaptPVFitter.trackMaxChi2       = 9
        downVertexFinder.LSAdaptPVFitter.trackMaxChi2Remove = 64

        downVertexAlg = PatPV3D( "%sDownVertexAlg" % self.name() )
        downVertexAlg.addTool(downVertexFinder, name="PVOfflineTool")

        downVertexing = SelectionPatPV3DWrapper( "%sDownVertexing" % self.name()
                          , downVertexAlg
                          , RequiredSelections = [ downTracks ]
                          )

        # Make Particles out of the RecVertices
        rv2pDown = LLParticlesFromRecVertices(
                       VerticesFromVeloOnly = False
                     , WriteP2PVRelations   = False
                     , ForceP2PVBuild       = False
                     #, OutputLevel          = VERBOSE
                     )
        self.validatedSetProps( "RV2PDown", DisplVerticesLinesConf.recoCuts + DisplVerticesLinesConf.singleCuts, rv2pDown )

        downCandidates = Selection( "%sDownCandidates" % self.name()
                           , RequiredSelections = [ downVertexing ]
                           , Algorithm          = rv2pDown
                           , InputDataSetter    = "RecVertexLocations"
                           )

        #######################################################################
        ###                                                                 ###
        ###     LINE DEFINITIONS                                            ###
        ###                                                                 ###
        #######################################################################

        ##============================== Single ===================================##

        singleLineNames = [ p.split("Single")[1].split("Selection")[0]
                                for p in self.configKeys()
                                    if p.startswith("Single")
                                    and p.endswith("Selection")
                          ]

        for lAcroName in singleLineNames:
            lShortName = "Single%s" % lAcroName             # SingleMedium
            lSelName   = "%sSelection" % lShortName         # SingleMediumSelection
            lLineName  = "%s%s" % (self.name(), lShortName) # DisplVerticesSingleMedium

            # Choose between Velo-based and downstream vertexing input
            candidates = withVeloCandidates
            code = None
            if "Down" in lAcroName:
                candidates = downCandidates
                code = self.getLLPSelection( self.validatedGetProps(lSelName, DisplVerticesLinesConf.singleCuts + DisplVerticesLinesConf.downCuts) )
            else:
                code = self.getLLPSelection( self.validatedGetProps(lSelName, DisplVerticesLinesConf.singleCuts) )

            lineFilter = FilterDesktop(
                             DecayDescriptor    = LLPLHCbName
                           , Preambulo          = DisplVerticesLinesConf.llpSelectionPreambulo
                           , Code               = code
                           , WriteP2PVRelations = False
                           , ForceP2PVBuild     = False
                           #, OutputLevel        = VERBOSE
                           )

            lineSel = Selection( "".join(( self.name(), lSelName ))
                        , RequiredSelections = [ candidates ]
                        , Algorithm          = lineFilter
                        )

            line = StrippingLine(lLineName
                     , prescale  = self.validatedGetProps(lSelName, ["PreScale"])["PreScale"]
                     , selection = lineSel
                     ## , FILTER    = { "Preambulo" : [ "nVeloTracks   = RECSUMMARY(13,  0)"
                     ##                               , "nVeloClusters = RECSUMMARY(30, -1)"
                     ##                               , "from LoKiCore.functions import *" ]
                     ##               , "Code"      : "monitor( 1.*nVeloTracks/nVeloClusters , Gaudi.Histo1DDef('Number of Velo Tracks / Clusters', 0., 1., 100) , 'NumVeloTracksPerCluster' ) < 0.2" }
                     )
            if lShortName in self.configurationParameter("HLT"):
                line.HLT = self.configurationParameter("HLT")[lShortName]

            self.registerLine(line)

        ##============================== Double ===================================##

        doubleLineNames = [ p.split("Double")[1].split("Selection")[0]
                                for p in self.configKeys()
                                    if p.startswith("Double")
                                    and p.endswith("Selection")
                          ]
        for lAcroName in doubleLineNames:
            lShortName = "Double%s" % lAcroName
            lSelName   = "%sSelection" % lShortName
            lLineName  = "%s%s" % (self.name(), lShortName)

            combinationCut, motherCut = self.getResonanceSelection( self.validatedGetProps(lSelName, DisplVerticesLinesConf.doubleResonanceCuts) )
            lineFilter = CombineParticles(
                             DecayDescriptor    = "H_10 -> %s %s" % (LLPLHCbName, LLPLHCbName)
                           , Preambulo          = DisplVerticesLinesConf.llpSelectionPreambulo
                           , DaughtersCuts      = { LLPLHCbName : self.getLLPSelection( self.validatedGetProps(lSelName, DisplVerticesLinesConf.singleCuts) ) }
                           , CombinationCut     = combinationCut
                           , MotherCut          = motherCut
                           , WriteP2PVRelations = False
                           , ForceP2PVBuild     = False
                           #, OutputLevel        = VERBOSE
                           )
            lineSel = Selection( "".join(( self.name(), lSelName ))
                        , RequiredSelections = [ withVeloCandidates ]
                        , Algorithm          = lineFilter
                        )
            line = StrippingLine(lLineName
                     , prescale  = self.validatedGetProps(lSelName, ["PreScale"])["PreScale"]
                     , selection = lineSel
                     )
            if lShortName in self.configurationParameter("HLT"):
                line.HLT = self.configurationParameter("HLT")[lShortName]

            self.registerLine(line)

        ##============================== HLT PS ===================================##

        hltPSLineNames = [ p.split("HLTPS")[0]
                               for p in self.configKeys()
                                   if p.endswith("HLTPS")
                         ]
        for lAcroName in hltPSLineNames:
            lShortName = "%sHLTPS" % lAcroName
            lLineName  = "%s%s" % (self.name(), lShortName) # DisplVerticesSingleMedium

            hltSelAlg = GaudiSequenceroid(ModeOR = True, ShortCircuit = False,
                Members = [ GaudiSequencer( "%sHltFilterTCK%s-%s" % (lLineName, tckBegin, tckEnd),
                                            Members = [ ODINFilter("%sODINFilterTCK%s-%s" % (lLineName, tckBegin, tckEnd), Code="( ODIN_TCK >= %s ) & ( ODIN_TCK <= %s )" % (tckBegin, tckEnd))
                                                      , HltFilter("%sHltDecisionFilterTCK%s-%s" % (lLineName, tckBegin, tckEnd), Code=hltFilter) ])
                            for (tckBegin, tckEnd), hltFilter in self.validatedGetProps("HLT", [lShortName])[lShortName]
                          ]
                )

            hltSelection = EventSelection( "%sHltFilter" % lLineName
                              , Algorithm = hltSelAlg
                              )

            line = StrippingLine(lLineName
                     , prescale  = self.validatedGetProps(lShortName, ["PreScale"])["PreScale"]
                     , selection = hltSelection
                     )

            self.registerLine(line)

        ##============================== OTHER  ===================================##

        hltEffLineNames = [ p.split("HltEff")[1].split("Selection")[0]
                                for p in self.configKeys()
                                    if p.startswith("HltEff")
                                    and p.endswith("Selection")
                          ]
        for lShortName in hltEffLineNames:
            lSelName  = "HltEff%sSelection" % lShortName
            lLineName = "%s%s" % (self.name(), lShortName)

            # HltEff lines are single, Velo-vertexing based lines
            lineFilter = FilterDesktop(
                             DecayDescriptor    = LLPLHCbName
                           , Preambulo          = DisplVerticesLinesConf.llpSelectionPreambulo
                           , Code               = self.getLLPSelection( self.validatedGetProps(lSelName, DisplVerticesLinesConf.singleCuts) )
                           , WriteP2PVRelations = False
                           , ForceP2PVBuild     = False
                           #, OutputLevel        = VERBOSE
                           )

            lineSel = Selection( "".join(( self.name(), lSelName ))
                        , RequiredSelections = [ withVeloCandidates ]
                        , Algorithm          = lineFilter
                        )

            line = StrippingLine(lLineName
                     , prescale  = self.validatedGetProps(lSelName, ["PreScale"])["PreScale"]
                     # these lines MUST have an HLT filter
                     , HLT       = self.configurationParameter("HLT")[lShortName]
                     , selection = lineSel
                     )

            self.registerLine(line)
Exemple #4
0
    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]
Exemple #5
0
    def __init__(self, name, config):
        LineBuilder.__init__(self, name, config)

        #######################################################################
        ###                                                                 ###
        ###     VELO BASED VERTEXING SEQUENCE                               ###
        ###                                                                 ###
        #######################################################################

        bestTracks = AutomaticData("Rec/Track/Best")

        withVeloTracksForVertexing = bestTracks

        if self.configurationParameter("VeloGEC")["Apply"]:
            from GaudiConfUtils.ConfigurableGenerators import VeloEventShapeCutsS20p3

            veloGEC = VeloEventShapeCutsS20p3()
            self.validatedSetProps("VeloGEC",
                                   DisplVerticesLinesConf.veloGECCuts, veloGEC)

            withVeloTracksForVertexing = PassThroughSelection(
                "%sVeloGEC" % self.name(),
                RequiredSelection=withVeloTracksForVertexing,
                Algorithm=veloGEC)

        if self.configurationParameter("FilterVelo")["Apply"]:
            from GaudiConfUtils.ConfigurableGenerators import SelectVeloTracksNotFromPVS20p3

            veloWithIP = SelectVeloTracksNotFromPVS20p3()
            self.validatedSetProps("FilterVelo",
                                   DisplVerticesLinesConf.veloWithIPCuts,
                                   veloWithIP)

            withVeloTracksForVertexing = Selection(
                "%sVeloFilteredTracks" % self.name(),
                RequiredSelections=[withVeloTracksForVertexing],
                Algorithm=veloWithIP)

        # Displaced Vertex reconstruction with best tracks (dominated by those with a Velo segment)
        from Configurables import PatPV3D, PVOfflineTool, PVSeed3DTool, LSAdaptPV3DFitter, LSAdaptPVFitter

        withVeloVertexAlg = PatPV3D("%sWithVeloVertexAlg" % self.name())
        withVeloVertexFinder = addPrivateToolAndGet(withVeloVertexAlg,
                                                    PVOfflineTool)
        withVeloVertexFinder.PVsChi2Separation = 0
        withVeloVertexFinder.PVsChi2SeparationLowMult = 0
        withVeloSeeder = addPrivateToolAndGet(withVeloVertexFinder,
                                              PVSeed3DTool)
        withVeloVertexFinder.PVSeedingName = withVeloSeeder.getTitleName()
        withVeloSeeder.MinCloseTracks = 3
        withVeloFitter = addPrivateToolAndGet(withVeloVertexFinder,
                                              LSAdaptPV3DFitter)
        withVeloVertexFinder.PVFitterName = withVeloFitter.getTitleName()
        withVeloFitter.maxIP2PV = 2.0 * units.mm
        withVeloFitter.MinTracks = 4

        withVeloVertexing = SelectionPatPV3DWrapper(
            "%sWithVeloVertexing" % self.name(),
            withVeloVertexAlg,
            RequiredSelections=[withVeloTracksForVertexing])

        # Make Particles out of the RecVertices
        from GaudiConfUtils.ConfigurableGenerators import LLParticlesFromRecVertices

        rv2pWithVelo = LLParticlesFromRecVertices(
            VerticesFromVeloOnly=False,
            RequireUpstreamPV=False,
            WriteP2PVRelations=False,
            ForceP2PVBuild=False,
            VeloProtoParticlesLocation="Phys/%s/VeloProtoP" % self.name())
        self.validatedSetProps(
            "RV2PWithVelo", DisplVerticesLinesConf.recoCuts +
            DisplVerticesLinesConf.singleCuts, rv2pWithVelo)

        withVeloCandidates = Selection("%sWithVeloCandidates" % self.name(),
                                       RequiredSelections=[withVeloVertexing],
                                       Algorithm=rv2pWithVelo,
                                       InputDataSetter="RecVertexLocations")

        #######################################################################
        ###                                                                 ###
        ###     DOWNSTREAM VERTEXING SEQUENCE                               ###
        ###                                                                 ###
        #######################################################################

        from GaudiConfUtils.ConfigurableGenerators import CopyDownstreamTracks

        downTracks = Selection("%sDownstreamTracks" % self.name(),
                               RequiredSelections=[bestTracks],
                               Algorithm=CopyDownstreamTracks())

        # Displaced Vertex reconstruction from downstream tracks
        downVertexAlg = PatPV3D("%sDownVertexAlg" % self.name())
        downVertexFinder = addPrivateToolAndGet(downVertexAlg, PVOfflineTool)
        downVertexFinder.RequireVelo = False
        downVertexFinder.PVsChi2Separation = 0
        downVertexFinder.PVsChi2SeparationLowMult = 0
        downSeeder = addPrivateToolAndGet(downVertexFinder, PVSeed3DTool)
        downVertexFinder.PVSeedingName = downSeeder.getTitleName()
        downSeeder.TrackPairMaxDistance = 2.0 * units.mm
        downSeeder.zMaxSpread = 20.0 * units.mm
        downSeeder.MinCloseTracks = 4
        downFitter = addPrivateToolAndGet(downVertexFinder, LSAdaptPVFitter)
        downVertexFinder.PVFitterName = downFitter.getTitleName()
        downFitter.MinTracks = 4
        downFitter.maxChi2 = 400.0
        downFitter.maxDeltaZ = 0.0005 * units.mm
        downFitter.maxDeltaChi2NDoF = 0.002
        downFitter.acceptTrack = 0.000000001
        downFitter.trackMaxChi2 = 9
        downFitter.trackMaxChi2Remove = 64

        downVertexing = SelectionPatPV3DWrapper(
            "%sDownVertexing" % self.name(),
            downVertexAlg,
            RequiredSelections=[downTracks])

        # Make Particles out of the RecVertices
        rv2pDown = LLParticlesFromRecVertices(VerticesFromVeloOnly=False,
                                              RequireUpstreamPV=False,
                                              WriteP2PVRelations=False,
                                              ForceP2PVBuild=False
                                              #, OutputLevel          = VERBOSE
                                              )
        self.validatedSetProps(
            "RV2PDown", DisplVerticesLinesConf.recoCuts +
            DisplVerticesLinesConf.singleCuts, rv2pDown)

        downCandidates = Selection("%sDownCandidates" % self.name(),
                                   RequiredSelections=[downVertexing],
                                   Algorithm=rv2pDown,
                                   InputDataSetter="RecVertexLocations")

        #######################################################################
        ###                                                                 ###
        ###     HLT JET SEQUENCE                                            ###
        ###                                                                 ###
        #######################################################################
        # timing is already fine, so one algo with loose JetID is sufficient

        # Hlt prefilter and vertex candidates from Hlt2
        from Configurables import HltVertexConverterS20p3
        revivedHlt2Candidates = "Phys/%sHlt2Cand/Particles" % self.name()
        hltCandReviver = GaudiSequenceroid(
            ModeOR=True,
            ShortCircuit=False,
            Members=[
                GaudiSequencer(
                    "%sHlt2CandFilterTCK%s-%s" %
                    (self.name(), tckBegin, tckEnd),
                    Members=[
                        ODINFilter("%sODINFilterTCK%s-%s" %
                                   (self.name(), tckBegin, tckEnd),
                                   Code="in_range( %s, ODIN_TCK, %s )" %
                                   (tckBegin, tckEnd)),
                        HltFilter("%sHltDecisionFilterTCK%s-%s" %
                                  (self.name(), tckBegin, tckEnd),
                                  Code=" | ".join("HLT_PASS('%s')" % ln
                                                  for ln in hltLines)),
                        HltVertexConverterS20p3(
                            "%sHltConverter%s-%s" %
                            (self.name(), tckBegin, tckEnd),
                            HltLines=hltLines,
                            Recursive=True,
                            Output=revivedHlt2Candidates,
                            WriteP2PVRelations=False,
                            ForceP2PVBuild=False)
                    ]) for (tckBegin, tckEnd), hltLines in
                self.configurationParameter("HLT")["SignalLines"]
            ])
        hltCandSelection = EventSelection("%sHltCandidates" % self.name(),
                                          Algorithm=hltCandReviver)

        hltVeloGEC = VeloEventShapeCutsS20p3()
        self.validatedSetProps("VeloGEC", DisplVerticesLinesConf.veloGECCuts,
                               hltVeloGEC)
        hltVeloGEC.HistoProduce = False
        hltVeloGECSel = EventSelection("%sHltVeloGEC" % self.name(),
                                       Algorithm=hltVeloGEC)

        hlt2CandAndGECSelection = Selection(
            "".join((self.name(), "Hlt2CandVertices")),
            RequiredSelections=[
                hltCandSelection,
                AutomaticData(revivedHlt2Candidates), hltVeloGECSel
            ],
            Algorithm=FilterDesktop(
                Code="( ABSID == '{pid}' )".format(pid=LLPLHCbName),
                WriteP2PVRelations=False,
                ForceP2PVBuild=False))

        hlt2CandWithJets = Selection(
            "".join((self.name(), "Hlt2CandWithJets")),
            RequiredSelections=[hlt2CandAndGECSelection],
            Algorithm=self.makeJetCandidateAlg("".join(
                (self.name(), "HltJetAlg"))))

        #######################################################################
        ###                                                                 ###
        ###     LINE DEFINITIONS                                            ###
        ###                                                                 ###
        #######################################################################
        # one line for every configuratoin key of the format
        # "Single.*Selection"
        # "JetSingle.*Selection"
        # "JetHltSingle.*Selection"
        # "Double.*Selection"
        # ".*HLTPS"
        # "HltEff.*Selection"

        ##============================== Single ===================================##

        singleLineNames = [
            p.split("Single")[1].split("Selection")[0]
            for p in self.configKeys()
            if p.startswith("Single") and p.endswith("Selection")
        ]

        for lAcroName in singleLineNames:
            lShortName = "Single%s" % lAcroName  # SingleMedium
            lSelName = "%sSelection" % lShortName  # SingleMediumSelection
            lLineName = "%s%s" % (self.name(), lShortName
                                  )  # DisplVerticesSingleMedium

            # Choose between Velo-based and downstream vertexing input
            candidates = withVeloCandidates
            code = None
            if "Down" in lAcroName:
                candidates = downCandidates
                code = self.getLLPSelection(
                    self.validatedGetProps(
                        lSelName, DisplVerticesLinesConf.singleCuts +
                        DisplVerticesLinesConf.downCuts))
            else:
                code = self.getLLPSelection(
                    self.validatedGetProps(lSelName,
                                           DisplVerticesLinesConf.singleCuts))

            lineFilter = FilterDesktop(
                DecayDescriptor=LLPLHCbName,
                Preambulo=DisplVerticesLinesConf.llpSelectionPreambulo,
                Code=code,
                WriteP2PVRelations=False,
                ForceP2PVBuild=False
                #, OutputLevel        = VERBOSE
            )

            lineSel = Selection("".join((self.name(), lSelName)),
                                RequiredSelections=[candidates],
                                Algorithm=lineFilter)

            line = StrippingLine(lLineName,
                                 prescale=self.validatedGetProps(
                                     lSelName, ["PreScale"])["PreScale"],
                                 selection=lineSel)
            if lShortName in self.configurationParameter("HLT"):
                line.HLT = self.configurationParameter("HLT")[lShortName]

            self.registerLine(line)

        ##========================= Single with jets ==============================##

        jetSingleLineNames = [
            p.split("JetSingle")[1].split("Selection")[0]
            for p in self.configKeys()
            if p.startswith("JetSingle") and p.endswith("Selection")
        ]

        for lAcroName in jetSingleLineNames:
            lShortName = "JetSingle%s" % lAcroName  # JetSingleMedium
            lSelName = "%sSelection" % lShortName  # JetSingleMediumSelection
            lLineName = "%s%s" % (self.name(), lShortName
                                  )  # DisplVerticesJetSingleMedium

            # Choose between Velo-based and downstream vertexing input
            vertexCandidates = withVeloCandidates
            code = self.getLLPSelection(
                self.validatedGetProps(lSelName,
                                       DisplVerticesLinesConf.singleCuts))

            vertexFilter = FilterDesktop(
                DecayDescriptor=LLPLHCbName,
                Preambulo=DisplVerticesLinesConf.llpSelectionPreambulo,
                Code=code,
                WriteP2PVRelations=False,
                ForceP2PVBuild=False
                #, OutputLevel        = VERBOSE
            )

            goodVertices = Selection("".join(
                (self.name(), lSelName, "Vertices")),
                                     RequiredSelections=[vertexCandidates],
                                     Algorithm=vertexFilter)

            jetProps = self.validatedGetProps(lSelName,
                                              DisplVerticesLinesConf.jetCuts)
            vertWithJets = Selection("".join((self.name(), lSelName, "Jets")),
                                     RequiredSelections=[goodVertices],
                                     Algorithm=self.makeJetCandidateAlg(
                                         "".join((self.name(), lSelName,
                                                  "JetAlg")),
                                         MinNumJets=jetProps["MinNumJets"]))
            jetCode = self.getLLPJetSelection(jetProps,
                                              JetIDCut=jetProps["JetIDCut"])
            jetCandFilter = FilterDesktop(DecayDescriptor=LLPLHCbName,
                                          Preambulo=self.jetSelectionPreambulo,
                                          Code=jetCode,
                                          WriteP2PVRelations=False,
                                          ForceP2PVBuild=False)
            lineSel = Selection("".join((self.name(), lSelName)),
                                RequiredSelections=[vertWithJets],
                                Algorithm=jetCandFilter)

            line = StrippingLine(lLineName,
                                 prescale=self.validatedGetProps(
                                     lSelName, ["PreScale"])["PreScale"],
                                 selection=lineSel)
            if lShortName in self.configurationParameter("HLT"):
                line.HLT = self.configurationParameter("HLT")[lShortName]

            self.registerLine(line)

        ##============= Single with jets based on Hlt candidate ==================##

        jetHltSingleLineNames = [
            p.split("JetHltSingle")[1].split("Selection")[0]
            for p in self.configKeys()
            if p.startswith("JetHltSingle") and p.endswith("Selection")
        ]

        for lAcroName in jetHltSingleLineNames:
            lShortName = "JetHltSingle%s" % lAcroName  # JetHltSingleMedium
            lSelName = "%sSelection" % lShortName  # JetHltSingleMediumSelection
            lLineName = "%s%s" % (self.name(), lShortName
                                  )  # DisplVerticesJetHltSingleMedium

            jetProps = self.validatedGetProps(lSelName,
                                              DisplVerticesLinesConf.jetCuts)
            jetCode = self.getLLPJetSelection(jetProps,
                                              JetIDCut=jetProps["JetIDCut"])
            jetCandFilter = FilterDesktop(DecayDescriptor=LLPLHCbName,
                                          Preambulo=self.jetSelectionPreambulo,
                                          Code=jetCode,
                                          WriteP2PVRelations=False,
                                          ForceP2PVBuild=False)
            lineSel = Selection("".join((self.name(), lSelName)),
                                RequiredSelections=[hlt2CandWithJets],
                                Algorithm=jetCandFilter)

            line = StrippingLine(lLineName,
                                 prescale=self.validatedGetProps(
                                     lSelName, ["PreScale"])["PreScale"],
                                 selection=lineSel)
            if lShortName in self.configurationParameter("HLT"):
                line.HLT = self.configurationParameter("HLT")[lShortName]

            self.registerLine(line)

        ##============================== Double ===================================##

        doubleLineNames = [
            p.split("Double")[1].split("Selection")[0]
            for p in self.configKeys()
            if p.startswith("Double") and p.endswith("Selection")
        ]
        for lAcroName in doubleLineNames:
            lShortName = "Double%s" % lAcroName
            lSelName = "%sSelection" % lShortName
            lLineName = "%s%s" % (self.name(), lShortName)

            combinationCut, motherCut = self.getResonanceSelection(
                self.validatedGetProps(
                    lSelName, DisplVerticesLinesConf.doubleResonanceCuts))
            lineFilter = CombineParticles(
                DecayDescriptor="H_10 -> %s %s" % (LLPLHCbName, LLPLHCbName),
                Preambulo=DisplVerticesLinesConf.llpSelectionPreambulo,
                DaughtersCuts={
                    LLPLHCbName:
                    self.getLLPSelection(
                        self.validatedGetProps(
                            lSelName, DisplVerticesLinesConf.singleCuts))
                },
                CombinationCut=combinationCut,
                MotherCut=motherCut,
                WriteP2PVRelations=False,
                ForceP2PVBuild=False
                #, OutputLevel        = VERBOSE
            )
            lineSel = Selection("".join((self.name(), lSelName)),
                                RequiredSelections=[withVeloCandidates],
                                Algorithm=lineFilter)
            line = StrippingLine(lLineName,
                                 prescale=self.validatedGetProps(
                                     lSelName, ["PreScale"])["PreScale"],
                                 selection=lineSel)
            if lShortName in self.configurationParameter("HLT"):
                line.HLT = self.configurationParameter("HLT")[lShortName]

            self.registerLine(line)

        ##============================== HLT PS ===================================##

        hltPSLineNames = [
            p.split("HLTPS")[0] for p in self.configKeys()
            if p.endswith("HLTPS")
        ]
        for lAcroName in hltPSLineNames:
            lShortName = "%sHLTPS" % lAcroName
            lLineName = "%s%s" % (self.name(), lShortName
                                  )  # DisplVerticesSingleMedium

            hltSelAlg = GaudiSequenceroid(
                ModeOR=True,
                ShortCircuit=False,
                Members=[
                    GaudiSequencer(
                        "%sHltFilterTCK%s-%s" % (lLineName, tckBegin, tckEnd),
                        Members=[
                            ODINFilter("%sODINFilterTCK%s-%s" %
                                       (lLineName, tckBegin, tckEnd),
                                       Code="in_range( %s, ODIN_TCK, %s )" %
                                       (tckBegin, tckEnd)),
                            HltFilter("%sHltDecisionFilterTCK%s-%s" %
                                      (lLineName, tckBegin, tckEnd),
                                      Code=hltFilter)
                        ]) for (tckBegin, tckEnd), hltFilter in
                    self.validatedGetProps("HLT", [lShortName])[lShortName]
                ])

            hltSelection = EventSelection("%sHltFilter" % lLineName,
                                          Algorithm=hltSelAlg)

            line = StrippingLine(lLineName,
                                 prescale=self.validatedGetProps(
                                     lShortName, ["PreScale"])["PreScale"],
                                 selection=hltSelection)

            self.registerLine(line)

        ##============================== OTHER  ===================================##

        hltEffLineNames = [
            p.split("HltEff")[1].split("Selection")[0]
            for p in self.configKeys()
            if p.startswith("HltEff") and p.endswith("Selection")
        ]
        for lShortName in hltEffLineNames:
            lSelName = "HltEff%sSelection" % lShortName
            lLineName = "%s%s" % (self.name(), lShortName)

            # HltEff lines are single, Velo-vertexing based lines
            lineFilter = FilterDesktop(
                DecayDescriptor=LLPLHCbName,
                Preambulo=DisplVerticesLinesConf.llpSelectionPreambulo,
                Code=self.getLLPSelection(
                    self.validatedGetProps(lSelName,
                                           DisplVerticesLinesConf.singleCuts)),
                WriteP2PVRelations=False,
                ForceP2PVBuild=False
                #, OutputLevel        = VERBOSE
            )

            lineSel = Selection("".join((self.name(), lSelName)),
                                RequiredSelections=[withVeloCandidates],
                                Algorithm=lineFilter)

            line = StrippingLine(
                lLineName,
                prescale=self.validatedGetProps(lSelName,
                                                ["PreScale"])["PreScale"]
                # these lines MUST have an HLT filter
                ,
                HLT=self.configurationParameter("HLT")[lShortName],
                selection=lineSel)

            self.registerLine(line)