def makeB2X(name,
            decay,
            inputs,
            config,
            useIP=True,
            resVert=False,
            usePi0=False):
    '''Makes all B -> X selections.'''
    from copy import deepcopy
    comboCuts = LoKiCuts(['SUMPT', 'AM'], config).code()
    flightCuts = ['BPVLTIME']
    if useIP:
        flightCuts += ['BPVIPCHI2', 'BPVDIRA']

    momCuts = [
        LoKiCuts(['VCHI2DOF'], config).code(),
        #has1TrackChild(),
        has1TrackChild(),
        hasTopoChildren(),
        LoKiCuts(flightCuts, config).code()
    ]
    momCuts = LoKiCuts.combine(momCuts)
    b2x = CombineParticles(DecayDescriptors=decay,
                           CombinationCut=comboCuts,
                           MotherCut=momCuts)
    if usePi0:
        #b2x = b2x.configurable(name+'Beauty2XGammaCombiner')
        #b2x.ParticleCombiners.update({'':'MomentumCombiner'})
        b2x.ParticleCombiners = {'': 'LoKi::VertexFitter'}
    if resVert:
        b2x = b2x.configurable(name + 'Beauty2XGammaVertexFitter')
        b2x.addTool(OfflineVertexFitter)
        b2x.ParticleCombiners.update({"": "OfflineVertexFitter"})
        b2x.OfflineVertexFitter.useResonanceVertex = False
    return Selection(name, Algorithm=b2x, RequiredSelections=inputs)
Пример #2
0
def makeB2X(name, decay, inputs, config, useIP=True, resVert=True):
    '''Makes all B -> X selections.'''
    from copy import deepcopy
    config = deepcopy(config)
    if name.find('B02') >= 0 or name.find('NoIP') >= 0:
        config['AM_MAX'] = '6000*MeV'
    comboCuts = LoKiCuts(['SUMPT', 'AM'], config).code()
    flightCuts = ['BPVLTIME', 'DZ1', 'DZ2']
    if useIP: flightCuts += ['BPVIPCHI2', 'BPVDIRA']
    momCuts = [
        LoKiCuts(['VCHI2DOF'], config).code(),
        has1TrackChild(),
        hasTopoChildren(),
        LoKiCuts(flightCuts, config).code()
    ]
    momCuts = LoKiCuts.combine(momCuts)
    b2x = CombineParticles(DecayDescriptors=decay,
                           CombinationCut=comboCuts,
                           MotherCut=momCuts)
    if not resVert:
        b2x = b2x.configurable(name + 'Beauty2CharmVertexFitter')
        b2x.addTool(OfflineVertexFitter)
        b2x.ParticleCombiners.update({"": "OfflineVertexFitter"})
        b2x.OfflineVertexFitter.useResonanceVertex = False
    return Selection(name, Algorithm=b2x, RequiredSelections=inputs)
Пример #3
0
def makeBJpsiKTrackEff(name, JpsiSel, KSel, massWin, vertexChi2):
    """
    Create and return a B -> J/psi K Selection object, with a J/psi (long+muonTT) and a Kaon.

    Arguments:
    name                 : name of the selection
    massWin              : width of the mass window
    vertexChi2           : vertexChi2/ndof for vertex
    """

    massWinCombCut = 2 * massWin

    Combine = CombineParticles()
    MuonTTBJpsiK = Combine.configurable(name + "BJpsiK")
    MuonTTBJpsiK.DecayDescriptor = "[B+ -> J/psi(1S) K+]cc"

    MuonTTBJpsiK.OutputLevel = 4

    MuonTTBJpsiK.DaughtersCuts = {
        "J/psi(1S)": "DMASS('J/psi(1S)') < 500",
        "K+": "ALL"
    }

    MuonTTBJpsiK.CombinationCut = "ADAMASS('B+') < %(massWinCombCut)s" % locals(
    )
    MuonTTBJpsiK.MotherCut = "(ADMASS('B+') < %(massWin)s) & (VFASPF(VCHI2/VDOF) < %(vertexChi2)s) & (BPVDIRA > 0.95)" % locals(
    )

    return Selection(name,
                     Algorithm=MuonTTBJpsiK,
                     RequiredSelections=[KSel, JpsiSel])
Пример #4
0
def makeDoubleTopo(inputs, config):
    topos = makeTopoCands(inputs, config['ADDSUMPT'])

    topos = [conePtFilter(topos, config)]

    preambulo = [
        'D1 = ACHILD(BPVVD,1)', 'DZ1 = ACHILD(BPVVDZ,1)',
        'DR1 = ACHILD(BPVVDR,1)', 'SIN1 = DR1/D1', 'COS1 = DZ1/D1',
        'SVX1 = ACHILD(VFASPF(VX),1)', 'SVY1 = ACHILD(VFASPF(VY),1)',
        'D2 = ACHILD(BPVVD,2)', 'DZ2 = ACHILD(BPVVDZ,2)',
        'DR2 = ACHILD(BPVVDR,2)', 'SIN2 = DR2/D2', 'COS2 = DZ2/D2',
        'SVX2 = ACHILD(VFASPF(VX),2)', 'SVY2 = ACHILD(VFASPF(VY),2)',
        'DSVX = (SVX1-SVX2)', 'DSVY = (SVY1-SVY2)',
        'COSDPHI = (DR1**2 + DR2**2 - DSVX**2 - DSVY**2)/(2*DR1*DR2)',
        'COSANGLE = SIN1*SIN2*COSDPHI + COS1*COS2'
    ]
    comboCuts = '(COSANGLE < %f) & (COSDPHI < %f) &(AM > %d*MeV)' \
                % (config['COSANGLE_MAX'],config['COSDPHI_MAX'],config['M_MIN'])
    momCuts = 'MAXTREE(ISBASIC,PT) > %d*MeV' % config['MAXPT_MIN']
    cp = CombineParticles(DecayDescriptor='B_c+ -> B0 B0',
                          Preambulo=preambulo,
                          CombinationCut=comboCuts,
                          MotherCut=momCuts)
    cp = cp.configurable('PseudoDoubleTopoBeauty2CharmCombiner')
    cp.ParticleCombiners.update({'': 'MomentumCombiner'})
    sel = Selection('PseudoDoubleTopoSel',
                    Algorithm=cp,
                    RequiredSelections=topos)
    sel = tosSelection(sel, {'Hlt2Topo.*BBDTDecision%TOS': 0})
    return sel
Пример #5
0
    def makeLb2V0LDhh( self, name, config ) :
        """
        Create and store a Lb ->Lambda0(LD) p+ h- Selection object.
        Arguments:
        name             : name of the Selection.
        config           : config dictionary
        """

        _massCutLow     = "(AM>(5619-%s)*MeV)"               % config['Lb_Mlow']
        _massCutHigh    = "(AM<(5619+%s)*MeV)"               % config['Lb_Mhigh']
        _aptCut         = "(APT>%s*MeV)"                     % config['Lb_APTmin']
        _daugMedPtCut   = "(ANUM(PT>%s*MeV)>=2)"             % config['LbDaug_MedPT_PT']
        _daugMaxPtIPCut = "(AVAL_MAX(MIPDV(PRIMARY),PT)>%s)" % config['LbDaug_MaxPT_IP']
        _maxDocaChi2Cut = "(ACUTDOCACHI2(%s,''))"            % config['LbDaug_LD_maxDocaChi2']
        _daugPtSumCut   = "((APT1+APT2+APT3)>%s*MeV)"        % config['LbDaug_LD_PTsum']

        _combCuts = _aptCut+'&'+_daugPtSumCut+'&'+_daugMedPtCut+'&'+_massCutLow+'&'+_massCutHigh+'&'+_daugMaxPtIPCut+'&'+_maxDocaChi2Cut

        _ptCut      = "(PT>%s*MeV)"                    % config['Lb_PTmin']
        _vtxChi2Cut = "(VFASPF(VCHI2)<%s)"             % config['Lb_VtxChi2']
        _diraCut    = "(BPVDIRA>%s)"                   % config['Lb_LD_Dira']
        _ipChi2Cut  = "(MIPCHI2DV(PRIMARY)<%s)"        % config['Lb_LD_IPCHI2wrtPV']
        _fdCut      = "(VFASPF(VMINVDDV(PRIMARY))>%s)" % config['Lb_FDwrtPV']
        _fdChi2Cut  = "(BPVVDCHI2>%s)"                 % config['Lb_LD_FDChi2']

        _motherCuts = _ptCut+'&'+_vtxChi2Cut+'&'+_diraCut+'&'+_ipChi2Cut+'&'+_fdChi2Cut

        _Lb = CombineParticles()

        if 'SS' in name: # Same sign

            _Lb.DecayDescriptors = [ "Lambda_b0 -> pi+ pi+ Lambda0", "Lambda_b~0 -> pi+ pi+ Lambda~0",
                                     "Lambda_b0 -> pi- pi- Lambda0", "Lambda_b~0 -> pi- pi- Lambda~0"]

        else:

            _Lb.DecayDescriptors = [ "Lambda_b0 -> pi+ pi- Lambda0", "Lambda_b~0 -> pi+ pi- Lambda~0"]

        _trkGhostProbCut  = "(TRGHOSTPROB<%s)" % config['Trk_GhostProb']
        _trkChi2Cut       = "(TRCHI2DOF<%s)"   % config['Trk_Chi2']

        _daughtersCuts = _trkChi2Cut + '&' + _trkGhostProbCut

        _Lb.DaughtersCuts = { "pi+" : _daughtersCuts }
        _Lb.CombinationCut = _combCuts
        _Lb.MotherCut = _motherCuts
        _Lb.ReFitPVs = True
        
        _LbConf = _Lb.configurable(name + '_combined')

        if 'SS' in name: # Same sign
            self.selLb2V0LDhhSS = Selection (name, Algorithm = _LbConf, RequiredSelections = [self.selLambda2LD, self.pions ])
            return self.selLb2V0LDhhSS
        else:
            self.selLb2V0LDhh = Selection (name, Algorithm = _LbConf, RequiredSelections = [self.selLambda2LD, self.pions ])
            return self.selLb2V0LDhh
 def _makeDstar02D0X0(self,name,decays,inputs):
     ''' Makes all X+ -> HH selections involving neutrals.'''
     comboCuts = "(ADAMASS('D*(2007)0') < %(MASS_WINDOW)s) " % self.config
     momCuts = "ALL" 
     cp = CombineParticles(CombinationCut=comboCuts,MotherCut=momCuts,
                           DecayDescriptors=decays)
     cp = cp.configurable(name+'Beauty2CharmCombiner')
     cp.ParticleCombiners.update({'':'MomentumCombiner'})
     return Selection('Dstar02D0'+name+'Beauty2Charm',Algorithm=cp,
                      RequiredSelections=self.d.hh+inputs)
Пример #7
0
 def _makeX2HHH(self,name,decays,amass,config,inputs,pi0=False):
     ''' Makes all X -> HHH selections involving neutrals.'''
     comboCuts = [LoKiCuts(['ASUMPT'],config).code(),amass,hasTopoChild()]
     comboCuts = LoKiCuts.combine(comboCuts)
     momCuts = LoKiCuts(['VCHI2DOF','BPVVDCHI2'],config).code()
     cp = CombineParticles(CombinationCut=comboCuts,MotherCut=momCuts,DecayDescriptors=decays)
     if pi0:
         cp = cp.configurable(name+'Beauty2XGammaCombiner')
         cp.ParticleCombiners = { '' : 'LoKi::VertexFitter' }
     return Selection(name+'Beauty2XGamma',Algorithm=cp,RequiredSelections=inputs)
Пример #8
0
 def _dSPlus(self, name, Pion, Kaons):
     """
     Make Ds -> K K Pi
     """
     _dsPlus = CombineParticles()
     _dsPlus.DecayDescriptor = "[D_s+ -> K+ K- pi+]cc"
     _dsPlus.MotherCut = "(ADMASS('D_s+') < 300 *MeV)"
     _dsPlusConf = _dsPlus.configurable("Combine_" + name + "_Dsplus")
     _selDsPlus = Selection("Selection_" + name + "_DsPlus",
                            Algorithm=_dsPlusConf,
                            RequiredSelections=[Pion, Kaons])
     return _selDsPlus
Пример #9
0
 def _kpipiZero(self, name, Kaons, Pions):
     """
     Make K1(1270)0 -> KS pi- pi+
     """
     _kpipi = CombineParticles()
     _kpipi.DecayDescriptors = ["K_1(1270)0 -> KS0 pi- pi+"]
     _kpipi.MotherCut = "in_range(500*MeV, M, 3000*MeV) & ( VFASPF(VCHI2PDOF) < 36 )"
     _kpipiConf = _kpipi.configurable("Combine_" + name + "_KSPiPi")
     _selKPiPiZero = Selection("Selection_" + name + "_kspipi",
                               Algorithm=_kpipiConf,
                               RequiredSelections=[Kaons, Pions])
     return _selKPiPiZero
 def _makeXPLUS2HH(self,name,decays,amass,config,inputs,pi0=False):
     ''' Makes all X+ -> HH selections involving neutrals.'''
     comboCuts = [LoKiCuts(['ASUMPT'],config).code(),amass,hasTopoChild()]
     comboCuts = LoKiCuts.combine(comboCuts)
     momCuts = "ALL" 
     cp = CombineParticles(CombinationCut=comboCuts,MotherCut=momCuts,
                           DecayDescriptors=decays)
     if pi0:
         cp = cp.configurable(name+'Beauty2XGammaCombiner')
         cp.ParticleCombiners.update({'':'MomentumCombiner'})
     return Selection(name+'Beauty2XGamma',Algorithm=cp,
                      RequiredSelections=inputs)
Пример #11
0
 def _dSStarPlus(self, name, DPlus, Gamma):
     """
     Make Ds* -> Ds (=D_s+ for us) Gamma
     """
     _dsstar = CombineParticles()
     _dsstar.DecayDescriptor = "[D*_s+ -> D_s+ gamma]cc"
     _dsstar.MotherCut = "(ADMASS('D*_s+') < 300 *MeV)"
     _dsstar.DaughtersCuts = {'gamma': '(CL > 0.25)'}
     _dsstarConf = _dsstar.configurable("Combine_" + name + "_Dsstar")
     _selDsSTAR = Selection("Selection_" + name + "_DsStar",
                            Algorithm=_dsstarConf,
                            RequiredSelections=[DPlus, Gamma])
     return _selDsSTAR
Пример #12
0
 def _myf0(self, name, pions):
     """
     Copy of the stuff which makes the StdLooseDetachedDipion
     """
     _f0 = CombineParticles()
     _f0.DecayDescriptor = "f_0(980) -> pi+ pi-"
     _f0.CombinationCut = "(AM<2700.0*MeV)"
     _f0.MotherCut = "(M<2700.0*MeV)"
     _f0Conf = _f0.configurable("Combine_" + name)
     _self0 = Selection("SelectionOff0For" + name,
                        RequiredSelections=[pions],
                        Algorithm=_f0Conf)
     return _self0
Пример #13
0
    def __Kstar2KPi0__( self, Kaons, Pi0, conf):
        """
        Make K*(892)+ -> K+ pi0 
        """
        _kstar2kpizero = CombineParticles()
        _kstar2kpizero.DecayDescriptor = "[K*(892)+ -> K+ pi0]cc"
        _kstar2kpizero.MotherCut = "(ADMASS('K*(892)+') < %(KstarplusWINDOW)s *MeV)" % conf

        _kstarConf = _kstar2kpizero.configurable("Combine_"+self.name+"_KPi0")
                                                 
        _selKSTAR2KPIZERO = Selection( "Selection_"+self.name+"_Kstar2kpizero",
                                       Algorithm = _kstarConf,
                                       RequiredSelections = [ Kaons, Pi0 ] )
        return _selKSTAR2KPIZERO
Пример #14
0
    def __Rho2PiPi0__( self, Pions, Pi0, conf):
        """
        Make rho(770)+ -> pi+ pi0 
        """
        _rho2pipizero = CombineParticles()
        _rho2pipizero.DecayDescriptor = "[rho(770)+ -> pi+ pi0]cc"
        _rho2pipizero.MotherCut = "(ADMASS('rho(770)+') < %(KstarplusWINDOW)s *MeV)" % conf

        _rhoConf = _rho2pipizero.configurable("Combine_"+self.name+"_PiPi0")
                                                 
        _selRHO2PIPIZERO = Selection( "Selection_"+self.name+"_rho2pipizero",
                                       Algorithm = _rhoConf,
                                       RequiredSelections = [ Pions, Pi0 ] )
        return _selRHO2PIPIZERO
Пример #15
0
 def _kstarPlus(self, name, Kaons, Pions):
     """
     Make K*(892)+ -> K+ pi0 or Kspi+
     """
     _kstar = CombineParticles()
     _kstar.DecayDescriptors = [
         "[K*(892)+ -> K+ pi0]cc", "[K*(892)+ -> KS0 pi+]cc"
     ]
     _kstar.MotherCut = "(ADMASS('K*(892)+') < 300 *MeV)"
     _kstarConf = _kstar.configurable("Combine_" + name + "_KPi")
     _selKSTAR2KPIZERO = Selection("Selection_" + name + "_Kstar2kaonpion",
                                   Algorithm=_kstarConf,
                                   RequiredSelections=[Kaons, Pions])
     return _selKSTAR2KPIZERO
Пример #16
0
def makeKstar(name, Kaons, Pions, KstMassWin, MesonPT):
    """
    Make K*(892)+ -> K+ pi0 or Kspi+
    """
    kstar = CombineParticles()
    kstar.DecayDescriptors = [
        "[K*(892)+ -> K+ pi0]cc", "[K*(892)+ -> KS0 pi+]cc"
    ]
    kstar.MotherCut = "((ADMASS('K*(892)+') < %(KstMassWin)s ) & (PT > %(MesonPT)s))" % locals(
    )

    kstarConf = kstar.configurable("Combine_" + name + "_KPi")
    return Selection(name,
                     Algorithm=kstarConf,
                     RequiredSelections=[Kaons, Pions])
Пример #17
0
 def _omega2PiPiPi0(self, name, Pions, Pi0):
     """
     Make omega -> pi+ pi- pi0
     """
     _omega2pipipizero = CombineParticles()
     _omega2pipipizero.DecayDescriptor = "omega(782) -> pi+ pi- pi0"
     _omega2pipipizero.CombinationCut = "(ADAMASS('omega(782)') < 200 *MeV)"
     _omega2pipipizero.MotherCut = "(ADMASS('omega(782)') < 200 *MeV) & (VFASPF(VPCHI2)> 0.00001)"
     _omegaConf = _omega2pipipizero.configurable("Combine_" + name +
                                                 "_PiPiPi0")
     _selOMEGA2PIPIPIZERO = Selection("Selection_" + name +
                                      "_omega2pipipizero",
                                      Algorithm=_omegaConf,
                                      RequiredSelections=[Pions, Pi0])
     return _selOMEGA2PIPIPIZERO
Пример #18
0
def makeY2X(name,decay,inputs,config,vertex=True):
    wm = ['in_range(%s,AM,%s)' % (config['MASS_MIN']['Y'],
                                  config['MASS_MAX']['Y'])]

    wm = '('+('|'.join(wm))+')'
    comboCuts = [LoKiCuts(['SUMPT'],config).code(),wm]
    comboCuts = LoKiCuts.combine(comboCuts)
    momCuts = LoKiCuts(['VCHI2DOF','BPVDIRA'],config).code()
    y2x = CombineParticles(DecayDescriptors=decay,CombinationCut=comboCuts,
                           MotherCut=momCuts)
    if not vertex:
        y2x = y2x.configurable(name+'B2MuMuXVertexFitter')
        y2x.addTool(OfflineVertexFitter)
        y2x.ParticleCombiners.update( { "" : "OfflineVertexFitter"} )
        y2x.OfflineVertexFitter.useResonanceVertex = False
    return Selection(name,Algorithm=y2x,RequiredSelections=inputs)
Пример #19
0
    def _makeDstar02D0Gamma( self, name, d2x ):
        decays = [ "D*(2007)0 -> D0 gamma" ]
        # return [ self._makeDstar02D0X0( name + 'Gamma', decays, d2x + [ self.photons ] ) ]

        combinationCuts = "(AALL)"
        motherCuts      = "(M-MAXTREE(ABSID=='D0',M)<200*MeV)"

        cp = CombineParticles( CombinationCut   = combinationCuts,
                               MotherCut        = motherCuts     ,
                               DecayDescriptors = decays          )

        cp = cp.configurable( name + 'Beauty2CharmCombiner' )
        #cp.ParticleCombiners.update( { '' : 'MomentumCombiner' } )

        return [ Selection( 'Dstar02D0' + name + 'Beauty2Charm'        ,
                            Algorithm          = cp                    ,
                            RequiredSelections = d2x + [ self.photons ] ) ]
Пример #20
0
def makeZ02TauTauEX_ss( name, _MMmin, _ecut, _picut ) :

    _Z0 = CombineParticles( DecayDescriptor = '[Z0 -> e+ pi+]cc',
                            DaughtersCuts = { 'e+' : _ecut ,
                                              'e-' : _ecut ,
                                              'pi+' : _picut ,
                                              'pi-' : _picut },
                            MotherCut = _MMmin,
                            WriteP2PVRelations = False
                            )

    _Z0Conf = _Z0.configurable("Combine_"+name+"_Z")
    _Z0Conf.ParticleCombiners.update({'':'MomentumCombiner'})
    _stdallnopidselectrons = StdAllNoPIDsElectrons
    _stdallnopidspions     = StdAllNoPIDsPions

    return Selection ( name,
                       Algorithm = _Z0,
                       RequiredSelections = [_stdallnopidselectrons, _stdallnopidspions])
Пример #21
0
def createZ_SameSign(name, tauSel, config):
    """
  Z0 selection Same Sign
  """

    _combcut = "(AM > " + config['Z_MASS_LOW'] + "*MeV)"
    _Zcut = "ALL"

    _CombineZ = CombineParticles(DecayDescriptors=['[Z0 -> tau+ tau+]cc'],
                                 CombinationCut=_combcut,
                                 MotherCut=_Zcut,
                                 WriteP2PVRelations=False
                                 #Preambulo           = "",#_preambulo
                                 )
    _CombineZConf = _CombineZ.configurable("Combine_" + name + "_Z")
    _CombineZConf.ParticleCombiners.update({'': 'MomentumCombiner'})

    return Selection(name + "_TauTau",
                     Algorithm=_CombineZConf,
                     RequiredSelections=[tauSel])
Пример #22
0
    def __Omega2PiPiPi0__(self, Pions, Pi0, conf):
        """
        Make omega -> pi+ pi- pi0 
        """
        _omega2pipipizero = CombineParticles()
        _omega2pipipizero.DecayDescriptor = "omega(782) -> pi+ pi- pi0"
        _omega2pipipizero.CombinationCut = "(ADAMASS('omega(782)') < %(Omega_CombMassWin)s * MeV) " % conf
        #"(ADOCACHI2CUT(20.,''))"

        _omega2pipipizero.MotherCut = "(ADMASS('omega(782)') < %(Omega_MassWin)s *MeV) & " \
                                      "(VFASPF(VPCHI2)> %(OmegaChi2Prob)s )"  %conf

        _omegaConf = _omega2pipipizero.configurable("Combine_" + self.name +
                                                    "_PiPiPi0")
        _omegaConf.ParticleCombiners.update({'': 'OfflineVertexFitter:PUBLIC'})

        _selOMEGA2PIPIPIZERO = Selection("Selection_" + self.name +
                                         "_omega2pipipizero",
                                         Algorithm=_omegaConf,
                                         RequiredSelections=[Pions, Pi0])
        return _selOMEGA2PIPIPIZERO
Пример #23
0
def makeOmega(name, MesonPT, OmegaMassWin, selPion0):
    """
    Create and return a omega -> pi+ pi- pi0 Selection object, starting from DataOnDemand 'Phys/StdLoosePions'.
    
    @arg name: name of the Selection.
    @arg MesonPT: PT of combined particle
    @arg OmegaMassWin: omega(782) mass window
    @arg selPion0: selected pion0 candidates
    
    @return: Selection object
    
    """
    stdPions = DataOnDemand(Location="Phys/StdLoosePions/Particles")
    omega2pipipizero = CombineParticles()
    omega2pipipizero.DecayDescriptor = "omega(782) -> pi+ pi- pi0"
    omega2pipipizero.CombinationCut = "(ADAMASS('omega(782)') < %(OmegaMassWin)s )" % locals(
    )
    omega2pipipizero.MotherCut = "((ADMASS('omega(782)') < %(OmegaMassWin)s ) & (PT > %(MesonPT)s))" % locals(
    )
    omegaConf = omega2pipipizero.configurable("Combine_" + name + "_PiPiPi0")

    return Selection(name,
                     Algorithm=omegaConf,
                     RequiredSelections=[stdPions, selPion0])
Пример #24
0
def makeResonanceMuMuTrackEff(name, resonanceName, decayDescriptor, plusCharge,
                              minusCharge, mode, massWin, vertexChi2,
                              resonancePT, muonTTPT, longPT, longMuonPID,
                              longMuonMinIP, longMuonTrackCHI2):
    """
    Create and return a Resonance -> mu mu Selection object, with one track a long track
    and the other a MuonTT track.
    Arguments:
    name                 : name of the selection
    resonanceName        : name of the resonance
    decayDescriptor      : decayDescriptor of the decay
    plusCharge           : algorithm for selection positvely charged tracks
    minusCharge          : algorithm for selection negatively charged tracks
    mode                 : Tag(-)-and-Probe(+) (1) or  Tag(+)-and-Probe(-) (2)
    massWin              : mass window around J/psi mass
    VertexChi2           : vertex chi2 / ndof of mu mu vertex
    resonancePT          : Pt of the resonance particle (f.ex. J/psi)
    muonTTPT             : Pt of MuonTT-track muon
    longPT               : Pt of Long-track muon
    longMuonPID          : CombDLL(mu-pi) of long-track muon
    NOT IMPLEMENTED YET:
    longMuonMinIPCHI2    : MinIPCHI2 of long-track muon
    longMuonTrackCHI2    : Track-Chi2 of long-track muon
    """

    massWinCombCut = 2 * massWin

    Combine = CombineParticles()
    MuonTTResonance = Combine.configurable(name + "MuonTTResonance")
    MuonTTResonance.DecayDescriptor = decayDescriptor

    MuonTTResonance.OutputLevel = 4

    if (mode == 1):
        MuonTTResonance.DaughtersCuts = {
            "mu+": "PT > %(muonTTPT)s" % locals(),
            "mu-": "(PT > %(longPT)s) & (PIDmu > %(longMuonPID)s)" % locals()
        }

        MuonTTResonance.CombinationCut = "ADAMASS('%(resonanceName)s') < %(massWinCombCut)s" % locals(
        )
        MuonTTResonance.MotherCut = "(ADMASS('%(resonanceName)s') < %(massWin)s) & (VFASPF(VCHI2/VDOF) < %(vertexChi2)s)" % locals(
        )

        return Selection(name,
                         Algorithm=MuonTTResonance,
                         RequiredSelections=[minusCharge, plusCharge])

    if (mode == 2):
        MuonTTResonance.DaughtersCuts = {
            "mu-": "PT > %(muonTTPT)s" % locals(),
            "mu+": "(PT > %(longPT)s) & (PIDmu > %(longMuonPID)s)" % locals()
        }

        MuonTTResonance.CombinationCut = "ADAMASS('%(resonanceName)s') < %(massWinCombCut)s" % locals(
        )
        MuonTTResonance.MotherCut = "(ADMASS('%(resonanceName)s') < %(massWin)s) & (VFASPF(VCHI2/VDOF) < %(vertexChi2)s)" % locals(
        )

        return Selection(name,
                         Algorithm=MuonTTResonance,
                         RequiredSelections=[plusCharge, minusCharge])