Example #1
0
    def splitPhiPi(self, name, phiPiSelection):
        """Split the input phi pi+ Selection in to a D+ and D_s+ selection.

        Returns a two-tuple as (D+ Selection, D_s+ Selection).
        Keyword arguments:
        phiPiSelection -- A single Selection instance; output of makeD2PhiPi
        """
        dpFilter = FilterDesktop(
            'FilterDp{0}'.format(name),
            Code="(ADMASS('D+') < {0[Dp_ADAMASS_WIN]})".format(self.config))
        dsFilter = FilterDesktop(
            'FilterDs{0}'.format(name),
            Code="(ADMASS('D_s+') < {0[Ds_ADAMASS_WIN]})".format(self.config))

        dpSel = Selection('SelFilteredDp{0}'.format(name),
                          Algorithm=dpFilter,
                          RequiredSelections=[phiPiSelection])
        dsSel = Selection('SelFilteredDs{0}'.format(name),
                          Algorithm=dsFilter,
                          RequiredSelections=[phiPiSelection])

        # The PhiPi selection is labelled as a D_s+, so rename the candidates
        # in the Dp selection as such
        dpSubPID = SubstitutePID(name='SubPidDp{0}'.format(name),
                                 Code="DECTREE('[D_s+ -> X0 X+]CC')",
                                 Substitutions={
                                     'D_s+ -> X0 X+': 'D+',
                                     'D_s- -> X0 X-': 'D-'
                                 },
                                 MaxChi2PerDoF=-1)
        dpSubPIDSel = Selection('SubPIDDpSel{0}'.format(name),
                                Algorithm=dpSubPID,
                                RequiredSelections=[dpSel])

        return dpSubPIDSel, dsSel
Example #2
0
    def __init__(self, name, config):

        LineBuilder.__init__(self, name, config)
        self.__confdict__ = config

        ####################### BASIC FINAL STATE PARTICLE SELECTIONS ##########################

        self.PionCuts = "(PIDK < %(Pion_MAX_PIDK)s) & (MIPDV(PRIMARY) > %(Tag_MIN_IP)s*mm) & (PT > %(Tag_MIN_PT)s*MeV) & (TRGHOSTPROB < %(Tag_MAX_GHPROB)s)" % self.__confdict__
        self.KaonCuts = "(PIDK > %(Kaon_MIN_PIDK)s) & (MIPDV(PRIMARY) > %(Tag_MIN_IP)s*mm) & (PT > %(Tag_MIN_PT)s*MeV) & (TRGHOSTPROB < %(Tag_MAX_GHPROB)s)" % self.__confdict__

        self.SelLongPions = Selection("SelLongPionsFor" + name,
                                      Algorithm=FilterDesktop(
                                          name="LongPionFilterFor" + name,
                                          Code=self.PionCuts),
                                      RequiredSelections=[StdLoosePions])

        self.SelLongKaons = Selection("SelLongKaonsFor" + name,
                                      Algorithm=FilterDesktop(
                                          name="LongKaonFilterFor" + name,
                                          Code=self.KaonCuts),
                                      RequiredSelections=[StdLooseKaons])

        ###### the velo tracking
        self.VeloProtoOutputLocation = 'Rec/ProtoP/VeloProtosFor%s' % self.name(
        )
        self.VeloTrackOutputLocation = "Rec/Track/MyVeloFor%s" % self.name()
        self.FittedVeloTrackOutputLocation = "Rec/Track/PreparedVeloFor%s" % self.name(
        )

        self.VeloTracks = self.MakeVeloTracks([])
        self.VeloPions = self.MakeVeloParticles("VeloPions", "pion",
                                                self.VeloTracks)
        self.VeloKaons = self.MakeVeloParticles("VeloKaons", "kaon",
                                                self.VeloTracks)

        ##################### MAKE THE LINES #############

        self.MissingPion2BodyLine = self.MakeLine(
            name + "MissingPion2Body",
            ['[D0 -> K- pi+]cc', '[D~0 -> K+ pi+]cc'],
            ["[D*(2010)+ -> D0 pi+]cc"], [self.SelLongKaons, self.VeloPions])

        self.MissingKaon2BodyLine = self.MakeLine(
            name + "MissingKaon2Body",
            ['[D0 -> K+ pi+]cc', '[D~0 -> K+ pi-]cc'],
            ["[D*(2010)+ -> D0 pi+]cc"], [self.SelLongPions, self.VeloKaons])

        if config["VeloLineForTiming"] == True:
            self.registerLine(
                StrippingLine(name + 'SelLongKaonsLine',
                              selection=self.SelLongKaons))
            self.registerLine(
                StrippingLine(name + 'SelLongPionsLine',
                              selection=self.SelLongPions))
            self.registerLine(
                StrippingLine(name + 'VeloPionLine', selection=self.VeloPions))
            self.registerLine(
                StrippingLine(name + 'VeloKaonLine', selection=self.VeloKaons))
        self.registerLine(self.MissingPion2BodyLine)
        self.registerLine(self.MissingKaon2BodyLine)
Example #3
0
    def makePhotonConv(self, name, mMax, maxVChi, minPT, inputSel):
        """
            Create photon selection objects starting from converted photons list
                (StdAllLooseGammaLL, StdAllLooseGammaDD)
        """
        _code = " ( MM < %(mMax)s * MeV ) " \
                "&( HASVERTEX ) " \
                "&( VFASPF(VCHI2/VDOF)<%(maxVChi)s ) " \
                "&( PT >  %(minPT)s)" % locals()

        _filter = FilterDesktop(name="ConvertedGammaFilter_" + name,
                                Code=_code)

        return Selection(name, Algorithm=_filter, RequiredSelections=inputSel)

        _DDConvSel = FilterDesktop(
            Code=
            "(MM < 100*MeV) & (HASVERTEX) & (VFASPF(VCHI2/VDOF)<9) & (PT >  %(B2XGGammaCNVPTMin)s)"
            % self.__confdict__)

        self.ConvLLPhoton = Selection('ConvLLPhoton' + self.name,
                                      Algorithm=_LLConvSel,
                                      RequiredSelections=[StdAllLooseGammaLL])
        self.ConvDDPhoton = Selection('ConvDDPhoton' + self.name,
                                      Algorithm=_DDConvSel,
                                      RequiredSelections=[StdAllLooseGammaDD])
Example #4
0
def VMaker(_name, _RequiredSelections, _DecayDescriptor, _Filter, conf,
           _prescale):

    _CombiCut = ""
    if 'KS0' in _DecayDescriptor:
        _CombiCut = "( (ACHILDCUT(CHILDCUT(ISLONG,1),1)) | (ACHILDCUT(CHILDCUT(ISLONG,1),2)) ) & "
    if 'phi(1020)' in _DecayDescriptor:
        _CombiCut += " (APT > %(Phi_PT_MIN)s *MeV) & (AM < %(Phi_MASS_MAX)s + 30*MeV) & (ACUTDOCACHI2(%(Phi_DOCACHI2_MAX)s,''))" % conf
        _MotherCut = "(M < %(Phi_MASS_MAX)s +20*MeV) & (VFASPF(VCHI2/VDOF) < %(Phi_VCHI2NDOF_MAX)s) & (MIPCHI2DV(PRIMARY) < %(Phi_IPCHI2_MAX)s)" % conf
        _MassFilter = FilterDesktop(name="MassFilter_" + _name,
                                    Code="(M < %(Phi_MASS_MAX)s *MeV)" % conf)
    elif 'J/psi(1S)' in _DecayDescriptor:
        _CombiCut += " (ADAMASS('J/psi(1S)') < %(JPsi_MASS_WIN)s +30*MeV) & (APT > %(JPsi_PT_MIN)s*MeV)"\
            "& (ACUTDOCACHI2(%(JPsi_DOCACHI2_MAX)s,''))" %conf
        _MotherCut = "(DMASS('J/psi(1S)') < %(JPsi_MASS_WIN)s +20*MeV)"\
            "& (VFASPF(VCHI2/VDOF) < %(JPsi_VCHI2NDOF_MAX)s) & (MIPCHI2DV(PRIMARY) < %(JPsi_IPCHI2_MAX)s)" %conf
        _MassFilter = FilterDesktop(
            name="MassFilter_" + _name,
            Code="(DMASS('J/psi(1S)') < %(JPsi_MASS_WIN)s *MeV)" % conf)

    Comb = CombineParticles(name="Comb_" + _name,
                            DecayDescriptor=_DecayDescriptor,
                            CombinationCut=_CombiCut,
                            MotherCut=_MotherCut)

    Sel = Selection(name="Sel_" + _name,
                    Algorithm=Comb,
                    RequiredSelections=_RequiredSelections)

    if conf['DoDTF'] == True:
        _MassConstraints = []
        if 'KS0' in _DecayDescriptor:
            _MassConstraints = ['KS0']
        FITTER = FitDecayTrees(name="FITTER_" + _name,
                               Code="DECTREE('" + _DecayDescriptor + "')",
                               MaxChi2PerDoF=10,
                               MassConstraints=_MassConstraints,
                               UsePVConstraint=True)
        FITTER_SEL = Selection("FITTER_SEL_" + _name,
                               Algorithm=FITTER,
                               RequiredSelections=[Sel])
        MASS_FILTER = Selection("MASS_FILTER_" + _name,
                                Algorithm=_MassFilter,
                                RequiredSelections=[FITTER_SEL])
    else:
        MASS_FILTER = Selection("MASS_FILTER_" + _name,
                                Algorithm=_MassFilter,
                                RequiredSelections=[Sel])

    Line = StrippingLine(_name + 'Line',
                         prescale=_prescale,
                         FILTER=_Filter,
                         selection=MASS_FILTER)

    return Line
def configuredParticleListFromDST(ParticleLocation, FilterCode=""):
    from Configurables import GaudiSequencer
    from Configurables import TrackParticleRefitter, TrackMasterFitter
    from TrackFitter.ConfiguredFitters import ConfiguredMasterFitter
    # create a sequence to refit and monitor
    name = ParticleLocation
    name = name.replace("/Event", "")
    name = name.replace("/Phys", "")
    name = name.replace("/Particles", "")
    name = name.replace("/", "")
    fitter = TrackParticleRefitter(name + "Refitter",
                                   TrackFitter=TrackMasterFitter(),
                                   ParticleLocation=ParticleLocation)
    ConfiguredMasterFitter(fitter.TrackFitter, SimplifiedGeometry=True)
    seq = GaudiSequencer(name + "Seq", IgnoreFilterPassed=True)
    seq.Members.append(fitter)
    if FilterCode != "":
        from Configurables import FilterDesktop
        newLocation = ParticleLocation.replace("/Particles", "") + "Filtered"
        newfilter = FilterDesktop(  #name + "Filter",#Output =
            newLocation,
            Inputs=[ParticleLocation],
            CloneFilteredParticles=False,
            Code=FilterCode)
        seq.Members.append(newfilter)
        ParticleLocation = newLocation + "/Particles"
    sel = ParticleSelection(Name=name,
                            Location=ParticleLocation,
                            Algorithm=seq)
    return sel
Example #6
0
def makeFilter(_name, _input, _preambulo, _code):

    _filter = FilterDesktop(_name, Preambulo=_preambulo, Code=_code)

    return Selection("sel" + _name,
                     Algorithm=_filter,
                     RequiredSelections=[_input])
Example #7
0
def makeSelection(_name, _filters):

    _Algorithm = FilterDesktop(_name, Code='ALL')

    return Selection("sel" + _name,
                     Algorithm=_Algorithm,
                     RequiredSelections=_filters)
Example #8
0
    def MakeVeloParticles(self, name, particle, protoParticlesMaker):

        particleMaker = NoPIDsParticleMaker("For%sParticleMaker%s" %
                                            (self.name, name),
                                            Particle=particle)
        particleMaker.Input = self.VeloProtoOutputLocation

        DataOnDemandSvc().AlgMap.update({
            "/Event/Phys/" + particleMaker.name() + '/Particles':
            particleMaker.getFullName(),
            "/Event/Phys/" + particleMaker.name() + '/Vertices':
            particleMaker.getFullName()
        })

        AllVeloParticles = Selection("For%sSelAllVeloParts%s" %
                                     (self.name, name),
                                     Algorithm=particleMaker,
                                     RequiredSelections=[protoParticlesMaker],
                                     InputDataSetter=None)

        ### filter on the IP of the velo tracks
        return Selection(
            "For%sSelVeloParts%s" % (self.name, name),
            Algorithm=FilterDesktop(
                name + "For%sFilterVeloTrackIP%s" % (self.name, name),
                Code="(MIPDV(PRIMARY) > %(VeloMINIP)s)" % self.__confdict__),
            RequiredSelections=[AllVeloParticles])
def makeKst2Kpi(name, KaonPT, KaonIPCHI2, PionPT, PionIPCHI2, KstarPT,
                KaonPIDK, KstarVCHI2, KstarMassWin, PionPIDK):
    """
    Create and return a Kstar -> K+pi- Selection object.
    Starts from DataOnDemand 'Phys/StdVeryLooseDetachedKst2Kpi'.
    Arguments:
    name             : name of the Selection.
    KaonPT           : Minimum transverse momentum of K (MeV).
    KaonIPCHI2       : Minimum impact parameter chi2 of K.
    PionPT           : Minimum transverse momentum of pi (MeV).
    PionIPCHI2       : Minimum impact parameter chi2 of pi.
    PionPIDK         : Maximum PID_{K-pi} of pi.
    KstarPT          : Minimum transverse momentum of Kstar (MeV).
    KaonPIDK         : Minimum PID_{K-pi} of K.
    KstarVCHI2       : Maximum Kstar vertex chi2 per degree of freedom.
    KstarMassWin     : Kstar invariant mass window around PDG mass value (MeV).
    """


    KstarCuts = "(INTREE((ABSID=='K+') & (PT > %(KaonPT)s *MeV) & (MIPCHI2DV(PRIMARY)> %(KaonIPCHI2)s) & (PIDK > %(KaonPIDK)s) ))"\
        "& (INTREE((ABSID=='pi-') & (PT > %(PionPT)s *MeV) & (MIPCHI2DV(PRIMARY)> %(PionIPCHI2)s) & (PIDK < %(PionPIDK)s )  ))"\
        "& (ADMASS('K*(892)0') < %(KstarMassWin)s *MeV)"\
        "& (VFASPF(VCHI2/VDOF)< %(KstarVCHI2)s) & (PT > %(KstarPT)s *MeV)"% locals()

    _KstarFilter = FilterDesktop("_filterFor" + name)
    _KstarFilter.Code = KstarCuts
    _stdKst2Kpi = DataOnDemand(
        Location="Phys/StdVeryLooseDetachedKst2Kpi/Particles")

    return Selection(name,
                     Algorithm=_KstarFilter,
                     RequiredSelections=[_stdKst2Kpi])
def makePhi2KK(name, KaonPT, KaonIPCHI2, KaonPIDK, PhiMassWin, PhiPT,
               PhiVCHI2):
    """
    Create and return a Phi -> KK Selection object.
    Starts from DataOnDemand 'Phys/StdLoosePhi2KK'.
    Arguments:
    name             : name of the Selection.
    KaonPT           : Minimum transverse momentum of K (MeV).
    KaonIPCHI2       : Minimum impact parameter chi2 of K.
    KaonPIDK         : Minimum PID_{K-pi} of K.
    PhiPT            : Minimum transverse momentum of Phi (MeV).
    PhiMassWin       : Phi invariant mass window around PDG mass value (MeV).
    PhiVCHI2         : Maximum Phi vertex chi2 (per degree of freedom?)
    """

    _params = locals()
    _code = " (MINTREE('K+'==ABSID,PIDK)> %(KaonPIDK)s)"    \
            "& (MINTREE(ABSID=='K+',PT)> %(KaonPT)s *MeV)"  \
            "& (MIPCHI2DV(PRIMARY)> %(KaonIPCHI2)s)"        \
            "& (ADMASS('phi(1020)') < %(PhiMassWin)s *MeV)" \
            "& (PT > %(PhiPT)s *MeV)" \
            "& (VFASPF(VCHI2/VDOF) < %(PhiVCHI2)s)" % _params
    print 'makeJpsiPhi2KK Code =', _code
    StdLoosePhi2KK = DataOnDemand(Location="Phys/StdLoosePhi2KK/Particles")
    _phiFilter = FilterDesktop("PhiFilterForBs2JpsiPhi", Code=_code)

    return Selection(name,
                     Algorithm=_phiFilter,
                     RequiredSelections=[StdLoosePhi2KK])
Example #11
0
    def filterDiMu( self, name,
                      MuonPT,
                      MuonP,
                      MuonTRCHI2DOF,
                      MuonPID,
                      MuMuMinMass,
                      MuMuMaxMass,
                      MuMuVCHI2PDOF,
                      MuMuPT 
                      ):
        
        _StdLooseDiMuon = DataOnDemand( Location = 'Phys/StdLooseDiMuon/Particles' )
        
        MuonCut = "(MINTREE('mu+'==ABSID,PT) > %(MuonPT)s )  & (MAXTREE('mu+'==ABSID,TRCHI2DOF) < %(MuonTRCHI2DOF)s)  & (MINTREE('mu+'==ABSID,PIDmu)> %(MuonPID)s)" % locals()
        MuonCut += "& (MINTREE('mu+'==ABSID,P) > %(MuonP)s )" % locals()
#        MuonCut = " (MAXTREE('mu+'==ABSID,TRCHI2DOF) < %(MuonTRCHI2DOF)s)  & (MINTREE('mu+'==ABSID,PIDmu)> %(MuonPID)s )" % locals()
        
        MuMuCut = "(MM > %(MuMuMinMass)s *GeV) & (MM < %(MuMuMaxMass)s *GeV) & (VFASPF(VCHI2PDOF)< %(MuMuVCHI2PDOF)s) & (PT > %(MuMuPT)s *GeV)" % locals()
        
        _MuMu = FilterDesktop( name+"FilterChiCMuMu", Code = MuonCut + " & " + MuMuCut  )
        
        return Selection( name + "_SelMuMu",
                          Algorithm = _MuMu,
                          RequiredSelections = [ _StdLooseDiMuon ]
                          )
Example #12
0
    def makeDCandidate(self, name, PDGName, ContainerName, TrackPT, TrackP,
                       TrackIPCHI2, TrackGHP, KaonProbNNk, PionProbNNpi,
                       DMassWin, DPT, DIPCHI2, DVCHI2):
        """
        Create and return a D candidate Selection object.
        Starts from DataOnDemand 'Phys/StdLooseD02KPi'.
        Arguments:
        name             : name of the Selection.
        TrackPT          : Minimum transverse momentum of K,pi (MeV).
        TrackIPCHI2      : Minimum impact parameter chi2 of K,pi.
        TrackGHP         : Maximum ghost probability of K,pi.
        KaonProbNNk      : Minimum ProbNNK of K.
        PionProbNNpi     : Minimum ProbNNpi of pi.
        DPT              : Minimum transverse momentum of D (MeV).
        DIPCHI2          : Minimum IP chi2 of D.
        DMassWin         : D invariant mass window around PDG mass value (MeV).
        DVCHI2           : Maximum D vertex chi2 (per degree of freedom?)
        """

        _params = locals()
        _code = " (INTREE(('K+'==ABSID) & (PROBNNk > %(KaonProbNNk)s) & (PT>%(TrackPT)s *MeV) & (MIPCHI2DV(PRIMARY)> %(TrackIPCHI2)s) & (TRGHP < %(TrackGHP)s)))" \
            "& (INTREE(('pi+'==ABSID) & (PROBNNpi > %(PionProbNNpi)s) & (PT>%(TrackPT)s *MeV) & (MIPCHI2DV(PRIMARY)> %(TrackIPCHI2)s) & (TRGHP < %(TrackGHP)s)))" \
            "& (ADMASS('%(PDGName)s') < %(DMassWin)s *MeV)" \
            "& (PT > %(DPT)s *MeV)" \
            "& (MIPCHI2DV(PRIMARY) > %(DIPCHI2)s)" \
            "& (VFASPF(VCHI2/VDOF) < %(DVCHI2)s)" % _params
        DCandidatesList = DataOnDemand(Location="Phys/" + ContainerName +
                                       "/Particles")
        _dFilter = FilterDesktop(name + "FilterForBs2DDPhi", Code=_code)

        return Selection(name,
                         Algorithm=_dFilter,
                         RequiredSelections=[DCandidatesList])
Example #13
0
    def makeKaons(self, name, KaonPT, KaonP, KaonIPCHI2, KaonGPMax,
                  KaonProbNNk):
        """
        Create and return a refined list of Kaons
        Starts from DataOnDemand 'Phys/StdLooseKaons'.
        Arguments:
        name             : name of the Selection.
        KaonPT           : Minimum transverse momentum of K (MeV).
        KaonIPCHI2       : Minimum impact parameter chi2 of K.
        KaonProbNNk      : Minimum ProbNNk of K.
        """

        _params = locals()
        _code = " ( PROBNNk > %(KaonProbNNk)s)"    \
            "& ( PT > %(KaonPT)s *MeV)"  \
            "& ( P > %(KaonP)s *MeV)" \
            "& ( TRGHP < %(KaonGPMax)s)"\
            "& ( MIPCHI2DV(PRIMARY) > %(KaonIPCHI2)s)" % _params
        StdLooseKaons = DataOnDemand(
            Location="Phys/StdAllLooseANNKaons/Particles")

        _kFilter = FilterDesktop("KFilterForBs2DDPhi", Code=_code)

        return Selection(name,
                         Algorithm=_kFilter,
                         RequiredSelections=[StdLooseKaons])
Example #14
0
def build_mc_unbiased_selection(decayDesc, arrow = '==>', refitpvs = True) :
    '''Make a selection for the given decay descriptor that has no cuts besides
    truth matching.'''

    preamble = [ "from LoKiPhysMC.decorators import *" , "from LoKiPhysMC.functions import mcMatch" ]
    decayDesc = decayDesc.copy()
    decayDesc.clear_aliases()
    decayDesc.set_carets(False)
    decayDescCC = decayDesc.copy()
    decayDescCC.cc = True
    algname = decayDesc.get_full_alias() + '_MCSel'
    algnameconj = decayDesc.conjugate().get_full_alias() + '_MCSel'
    if algname in selections :
        return selections[algname]
    elif algnameconj in selections :
        return selections[algnameconj]

    if not decayDesc.daughters :
        alg = FilterDesktop(algname + '_Filter')
        basicname = decayDesc.particle.name
        if not basicname in mcbasicinputs :
            basicname = decayDesc.conjugate().particle.name
        if basicname in mcbasicinputs :
            inputsels = [RebuildSelection(getattr(StandardParticles, basicinput)) for basicinput in mcbasicinputs[basicname]]
        else :
            raise ValueError("Can't find MC basic input for particle " + repr(decayDesc.particle.name))
        alg.Code = 'mcMatch({0!r})'.format(decayDescCC.to_string(arrow))
        alg.Preambulo = preamble
        sel = Selection(algname,
                        Algorithm = alg,
                        RequiredSelections = inputsels)
        selections[algname] = sel
        return sel
    inputs = set()
    daughtercuts = {}
    for daughter in decayDescCC.daughters :
        originaldaughtercc = daughter.cc
        daughter.cc = True
        sel = build_mc_unbiased_selection(daughter, arrow, refitpvs)
        daughter.cc = originaldaughtercc
        inputs.add(sel)
        #daughter.caret = True
        #daughtercuts[daughter.particle.name] = 'mcMatch({0!r})'.format(decayDescCC.to_string(arrow))
        #daughter.caret = False
    #comb = nCombiners[len(decayDesc.daughters)](algname + '_Comb')
    comb = CombineParticles(algname + '_Comb')
    # CombineParticles uses small cc, so set ishead = False
    comb.DecayDescriptors = [decayDesc.to_string(depth = 1).replace('CC', 'cc')]
    comb.MotherCut = 'mcMatch({0!r})'.format(decayDescCC.to_string(arrow))
    comb.Preambulo = preamble
    comb.DaughtersCuts = daughtercuts
    comb.ReFitPVs = refitpvs
    if refitpvs:
        comb.MotherCut += ' & BPVVALID()'
    sel = Selection(algname,
                    Algorithm = comb,
                    RequiredSelections = list(inputs))
    selections[algname] = sel
    return sel
def muonTracksFORmuonAlignment():

    # this still needs to be worked out
    from Configurables import Escher
    Escher().RecoSequence = [
        "Hlt", "Decoding", "AlignTr", "Vertex", "RICH", "CALO", "MUON", "PROTO"
    ]  # ????
    Escher().MoniSequence = ["Tr", "OT"]

    # if the Escher hlt filter is not set, set it here
    if not hasattr(Escher(), "HltFilterCode") or not Escher().HltFilterCode:
        Escher(
        ).HltFilterCode = "HLT_PASS_RE( 'Hlt1DiMuonHighMass*Decision' )"  # Hlt2-->Hlt1 requirement

    # revive only particles used for trigger
    print 'Hlt lines to be used: '
    print ReviveHltTracks(['Hlt1DiMuonHighMassDecision'])

    # Now create the J/psi candidates
    from Configurables import CombineParticles, FilterDesktop
    from CommonParticles.StdAllLooseMuons import StdAllLooseMuons  # requires IsMuon==1
    from CommonParticles.StdLooseJpsi2MuMu import StdLooseJpsi2MuMu  # requires (ADAMASS('J/psi')<100.*MeV)&(ADOCACHI2CUT(30,'')) && "(VFASPF(VCHI2) < 25.)"

    StdLooseJpsi2MuMu.DaughtersCuts = {"mu-": "( P> 6000*MeV)"}  # momentum cut

    ## tighten the mass window for candidates used in alignment
    AlignJpsi2MuMu = FilterDesktop(
        "AlignJpsi2MuMu",
        Inputs=["Phys/StdLooseJpsi2MuMu"],
        Code="(ADMASS('J/psi(1S)') < 35.*MeV) & (VFASPF(VCHI2) < 10.)"
    )  # tighter requirements

    from Configurables import ChargedProtoParticleMaker, ChargedProtoParticleAddMuonInfo
    #####, ChargedProtoCombineDLLsAlg
    from Configurables import TrackParticleMonitor, GaudiSequencer
    recoJpsiSeq = GaudiSequencer("RecoJpsiSeq")
    recoJpsiSeq.Members = [
        ChargedProtoParticleMaker('ChargedProtoPMaker'),
        ChargedProtoParticleAddMuonInfo('ChargedProtoPAddMuon'),
        ###ChargedProtoCombineDLLsAlg('ChargedProtoPCombDLLs'),
        StdAllLooseMuons,
        StdLooseJpsi2MuMu,
        TrackParticleMonitor(
            'StdLooseJpsi2MuMuMonitor',
            InputLocation='/Event/Phys/StdLooseJpsi2MuMu/Particles',
            MinMass=3000,
            MaxMass=3190),
        AlignJpsi2MuMu,
        TrackParticleMonitor(
            'AlignJpsi2MuMuMonitor',
            InputLocation='/Event/Phys/AlignJpsi2MuMu/Particles',
            MinMass=3000,
            MaxMass=3190),
    ]

    sel = ParticleSelection(Name='MufromJpsiMuMu',
                            Location='/Event/Phys/AlignJpsi2MuMu/Particles',
                            Algorithm=recoJpsiSeq)
    return sel
Example #16
0
    def splitHHH(self, name, hhhSelection):
        """Split the input h-h+h+ Selection in to a D+ and D_s+ selection.

        Returns a two-tuple as (D+ Selection, D_s+ Selection).
        Keyword arguments:
        hhhSelection -- A single Selection instance; the output of makeD2HHH
        """
        dpFilter = FilterDesktop(
            'FilterDp{0}'.format(name),
            Code="(ADMASS('D+') < {0[Dp_ADAMASS_WIN]})".format(self.config)
        )
        dsFilter = FilterDesktop(
            'FilterDs{0}'.format(name),
            Code="(ADMASS('D_s+') < {0[Ds_ADAMASS_WIN]})".format(self.config)
        )

        dpSel = Selection(
            'SelFilteredDp{0}'.format(name),
            Algorithm=dpFilter,
            RequiredSelections=[hhhSelection]
        )
        dsSel = Selection(
            'SelFilteredDs{0}'.format(name),
            Algorithm=dsFilter,
            RequiredSelections=[hhhSelection]
        )

        # The HHH selection is labelled as a D+, so rename the candidates in
        # the D_s+ selection as such
        dsSubPID = SubstitutePID(
            name='SubPidDs{0}'.format(name),
            Code="DECTREE('[D+ -> X- X+ X+]CC')",
            Substitutions={
                'D+ -> X- X+ X+': 'D_s+',
                'D- -> X+ X- X-': 'D_s-'

            },
            MaxChi2PerDoF=-1
        )
        dsSubPIDSel = Selection(
            'SubPIDDsSel{0}'.format(name),
            Algorithm=dsSubPID,
            RequiredSelections=[dsSel]
        )

        return dpSel, dsSubPIDSel
Example #17
0
 def Pi0ResolvedFilter( self, _name, _config):
     _code = ( "  ( ADMASS('pi0') <  %(Pi0MassWin)s )" \
               "& ( PT> %(Pi0PtMin)s ) " \
               "& ( P> %(Pi0PMin)s )" \
               "& ( CHILD(CL,1)> %(PhotonCL)s) " \
               "& ( CHILD(CL,2)> %(PhotonCL)s) " % _config )
     _pil = FilterDesktop( name = _name, Code = _code )
     return _pil
Example #18
0
    def makeW(self, _name):
        # Define the W->mu cuts
        _code = '(PT>%(min_mu_pT)s*GeV) & (PT<%(max_mu_pT)s*GeV)' % self._config

        _filter = FilterDesktop(_name, Code=_code)

        return Selection("sel" + _name,
                         Algorithm=_filter,
                         RequiredSelections=[StdAllLooseMuons])
Example #19
0
def test_filterDesktop_properties():
    fd0 = FilterDesktop('fd0',
                        Code='TestCode0',
                        InputLocations=['a', 'b', 'c'],
                        OutputLevel=2)

    assert (fd0.Code == 'TestCode0')
    assert (fd0.InputLocations == ['a', 'b', 'c'])
    assert (fd0.OutputLevel == 2)
Example #20
0
 def _KsDDFilter(self, _name):
     _code = " (P> %(KSDDPMin)s *MeV) & (PT> %(KSDDPTMin)s *MeV)" \
             " & (ADMASS('KS0') < %(KSDDCutMass)s *MeV) & (BPVVDCHI2> %(KSDDCutFDChi2)s)" \
             " & CHILDCUT((TRCHI2DOF < %(KSDaugTrackChi2)s),1)" \
             " & CHILDCUT((TRCHI2DOF < %(KSDaugTrackChi2)s),2)" \
             " & (VFASPF(VCHI2PDOF) < %(KSVertexChi2)s)" \
             " & (BPVDIRA > %(KSCutDIRA)s)" % self.__confdict__
     _pil = FilterDesktop(name=_name, Code=_code)
     return _pil
def get_selection_sequence(name):
    """Get the selection from stripping stream"""
    # Relative lesLoc for uDST, no preceeding '/'
    tesLoc = 'Phys/B2DPiPiD2HHHCFPIDBeauty2CharmLine/Particles'
    alg = FilterDesktop('SelFilterFor{}B2D'.format(name))
    alg.Code = 'ALL'
    reqSels = [DataOnDemand(Location=tesLoc)]
    sel = Selection('Sel' + name, Algorithm=alg, RequiredSelections=reqSels)
    return SelectionSequence('SelSeq' + name, TopSelection=sel)
Example #22
0
    def MakeLine(self,name,
                 D0DecayDescriptor,
                 DstDecayDescriptors,
                 D0Requirements):
        
        
        D0CombinationCut = "(AM > 0.1*GeV) & (AM < 3.0*GeV)"
        D0CombinationCut += " & (AMAXDOCA('') < 0.05 * mm)"
        D0CombinationCut += " & (ACHILD(MIPDV(PRIMARY),1)+ACHILD(MIPDV(PRIMARY),2) > 0.2*mm)" 
        D0MotherCut  = "(VFASPF(VZ) > 2*mm) & (VFASPF(VCHI2/VDOF) < 4.0)"
        SlowpionCuts = "(MIPCHI2DV(PRIMARY) < 9)" 
        DstMotherCut = "(PT > 1*MeV)" 

        CombD0 = CombineParticles(name="CombD0for"+name,
                                  DecayDescriptors = D0DecayDescriptor,
                                  CombinationCut = D0CombinationCut,
                                  MotherCut = D0MotherCut)
        
        SelD0 = Selection('SelD0for'+name,
                          Algorithm = CombD0,
                          RequiredSelections = D0Requirements)

        CombDstar = CombineParticles(name = "CombDstarFor"+name,
                                     DecayDescriptors = DstDecayDescriptors,
                                     DaughtersCuts = {"pi+": SlowpionCuts},
                                     CombinationCut = "(AALLSAMEBPV)",
                                     MotherCut = DstMotherCut)
    
        SelDstar = Selection("SelDstarfor"+name,
                             Algorithm = CombDstar,
                             RequiredSelections = [SelD0,StdAllLoosePions])
        
        SelDstarTOS = TOSFilter("TOSDstarfor"+name,
                                SelDstar,
                                self.__confdict__["TTSpecs"])
        
        MassFilter =FilterDesktop(name="MassFilter"+name, 
                                  Code="(DTF_CHI2NDOF(True,'D0') < %(Dst_DTFCHI2_MAX)s) & (DTF_FUN( M ,True,'D0') < %(Dst_M_MAX)s)" %self.__confdict__)
     
        MassFilterSel = Selection("MassFilterSel"+name,
                                  Algorithm = MassFilter,
                                  RequiredSelections = [SelDstarTOS])

        if self.__confdict__["Monitor"]:
            MassFilter.Preambulo    = [
                "Histo  = Gaudi.Histo1DDef"  ,
                "mass     = monitor ( DTF_FUN( M ,True,'D0') ,             Histo ( 'Title' , 2000. , 2100. , 100 ) , 'HistoNameInMemory'    ) "
                ]
            MassFilter.Monitor      = True  ,
            MassFilter.HistoProduce = True  ,
            MassFilter.PostMonitor  = """ process ( mass ) >> EMPTY """                                                                                                        
        LineDstar = StrippingLine(name, 
                                  HLT1 = self.__confdict__["HLT1"],
                                  HLT2 = self.__confdict__["HLT2"],
                                  selection = MassFilterSel)
        
        return LineDstar
Example #23
0
    def _Bs2JpsieePhiLine( self, dielectron, name, config ) :

        _jpsi = FilterDesktop("FilterJpsi2eeFor"+name,
                              Code = "   (MM > %(JpsiMassMin)s *MeV)" \
                                     " & (MM < %(JpsiMassMax)s *MeV)" \
                                     " & (MINTREE('e+'==ABSID,PIDe-PIDpi) > %(ElectronPID)s )" \
                                     " & (MINTREE('e+'==ABSID,PT) > %(ElectronPT)s *MeV)" \
                                     " & (MAXTREE('e+'==ABSID,TRCHI2DOF) < %(ElectronTrackCHI2pDOF)s)" \
                                     " & (VFASPF(VCHI2/VDOF) < %(JpsiVertexCHI2pDOF)s)" % config
                             )
        Jpsi = Selection("SelJpsi2eeFor"+name,
                         Algorithm = _jpsi,
                         RequiredSelections = [dielectron])

        _stdPhi = DataOnDemand(Location="Phys/StdLoosePhi2KK/Particles")
        _phi = FilterDesktop("FilterPhi2KKFor"+name,
                             Code = "   (PT > %(PhiPT)s *MeV)" \
                                    " & (MINTREE('K+'==ABSID,PIDK-PIDpi) > %(KaonPID)s )" \
                                    " & (MAXTREE('K+'==ABSID,TRCHI2DOF) < %(KaonTrackCHI2pDOF)s)" \
                                    " & (VFASPF(VCHI2/VDOF) < %(PhiVertexCHI2pDOF)s)" \
                                    " & (MM > %(PhiMassMin)s *MeV)" \
                                    " & (MM < %(PhiMassMax)s *MeV)" % config
                            )
        Phi = Selection("SelPhi2KKFor"+name,
                        Algorithm = _phi,
                        RequiredSelections = [_stdPhi])

        CC = "(AM > %(BsMassMin)s *MeV) & (AM < %(BsMassMax)s *MeV)" % config
        MC = "(VFASPF(VCHI2/VDOF) < %(BsVertexCHI2pDOF)s) & (BPVDIRA > %(BsDIRA)s)" % config
        _Bs = CombineParticles("CombineBsFor"+name,
                               DecayDescriptor = "B_s0 -> J/psi(1S) phi(1020)",
                               CombinationCut = CC ,
                               MotherCut = MC,
                               ReFitPVs = False
                               )
        Bs = Selection(name,
                       Algorithm = _Bs,
                       RequiredSelections = [Jpsi, Phi])

        return StrippingLine(name+"Line"
              , prescale = config['Prescale']
              , postscale = 1
              , selection = Bs
              , EnableFlavourTagging = True )#, MDSTFlag = True )
Example #24
0
    def inputSeq(self, outputLevel=INFO):
        if not allConfigurables.get("AlignInputSeq"):
            if outputLevel == VERBOSE:
                print "VERBOSE: Filter Sequencer not defined! Defining!"

            inputSequencer = GaudiSequencer("AlignInputSeq")
            inputSequencer.MeasureTime = True
            trackselections = self.getProp("TrackSelections")
            if len(trackselections) > 0:
                trackInputSeq = GaudiSequencer("AlignTrackSelSeq",
                                               IgnoreFilterPassed=True)
                inputSequencer.Members.append(trackInputSeq)
                # add the algorithms for the track selections to the sequence.
                # also merge the tracks lists into one list
                from Configurables import TrackListMerger
                trackmerger = TrackListMerger(
                    "AlignTracks", outputLocation="Rec/Track/AlignTracks")
                self.setProp("TrackLocation", trackmerger.outputLocation)
                for i in trackselections:
                    alg = i.algorithm()
                    if alg: trackInputSeq.Members.append(alg)
                    trackmerger.inputLocations.append(i.location())
                trackInputSeq.Members.append(trackmerger)

            # add all particle selections
            if len(self.getProp("ParticleSelections")) > 0:
                particleInputSeq = GaudiSequencer("AlignParticleSelSeq",
                                                  IgnoreFilterPassed=True)
                inputSequencer.Members.append(particleInputSeq)
                from Configurables import FilterDesktop
                particlemerger = FilterDesktop("AlignParticles", Code="ALL")
                particlemerger.Code = "ALL"
                particlemerger.CloneFilteredParticles = False
                for i in self.getProp("ParticleSelections"):
                    alg = i.algorithm()
                    if alg:
                        particleInputSeq.Members.append(alg)
                        print "adding particleinputsel to sequence: ", i.name(
                        ), i.algorithm(), i.location()
                    particlemerger.Inputs.append(i.location())
                particleInputSeq.Members.append(particlemerger)
                self.setProp("ParticleLocation",
                             '/Event/Phys/AlignParticles/Particles')

            # add the PV selection
            if hasattr(self, "PVSelection"):
                inputSequencer.Members.append(
                    self.getProp("PVSelection").algorithm())
                self.setProp("VertexLocation",
                             self.getProp("PVSelection").location())

            return inputSequencer
        else:
            if outputLevel == VERBOSE:
                print "VERBOSE: AlignInputSeq already defined!"
            return allConfigurables.get("AlignInputSeq")
def test_VoidEventSelection_with_existing_configurable_name_raises():

    selFilter = FilterDesktop('SelFilter0')
    sel = AutomaticData(Location='Phys/Sel')

    raises(NameError,
           VoidEventSelection,
           'SelFilter0',
           Code='<Location>',
           RequiredSelection=sel)
def test_mergedselection_with_existing_configurable_name_raises():
    sel00 = AutomaticData(Location='Phys/Sel00')
    sel01 = AutomaticData(Location='Phys/Sel01')
    sel02 = AutomaticData(Location='Phys/Sel02')
    sel03 = AutomaticData(Location='Phys/Sel03')
    selFilter = FilterDesktop('MergeFilter')
    raises(NameError,
           MergedSelection,
           'MergeFilter',
           RequiredSelections=[sel00, sel01, sel02, sel03])
def example():
    mn = 1864.84
    mx = 1964.84
    ce = ComboEngine([('pi+', 'pi-'), ('K+', 'pi-'), ('pi+', 'K-'),
                      ('K+', 'K-')], ['pi+', 'pi-'])
    mass = ce.getWMFunctor(min, max)
    emptyFilter = FilterDesktop("Empty", Code="ALL")
    return ce.mergedSelection("Combo", mn, mx,
                              Selection("EmptySel", Algorithm=emptyFilter))
    return ce
 def _MuonFilter(self):
     Muoncut = "(TRCHI2DOF < 5.0) & (PIDmu > 0.0)  & (MIPCHI2DV(PRIMARY) > 4.0) & (PT > 300*MeV)"
     muonfilter = FilterDesktop("muonfilter", Code=Muoncut)
     SelectedMuon = Selection(
         "SelMuon",
         Algorithm=muonfilter,
         RequiredSelections=[
             DataOnDemand(Location="Phys/StdLooseMuons/Particles")
         ])
     return SelectedMuon
 def _PionFilter(self):
     Pioncut = "(TRCHI2DOF < 5.0) & (PIDK < 6.0)  & (MIPCHI2DV(PRIMARY) > 4.0)  & (PT > 300*MeV)"
     pionfilter = FilterDesktop("pionfilter", Code=Pioncut)
     SelectedPion = Selection(
         "SelPion",
         Algorithm=pionfilter,
         RequiredSelections=[
             DataOnDemand(Location="Phys/StdLoosePions/Particles")
         ])
     return SelectedPion
Example #30
0
 def KSFilter(self, _name,
              minDz, maxDz,
              KSCutDIRA, KSCutMass, KSCutFDChi2 ) :
     _code = " (BPVVDZ > %(minDz)s ) " \
             "&(BPVVDZ < %(maxDz)s ) " \
             "&(BPVDIRA > %(KSCutDIRA)s ) " \
             "&(ADMASS('KS0') < %(KSCutMass)s ) " \
             "&(BPVVDCHI2> %(KSCutFDChi2)s )" % locals()
     _KsFilter = FilterDesktop(name = _name, Code = _code)
     return _KsFilter