HighQ2MuonsOnDemand = DataOnDemand(Location = "/Event/Dimuon/Phys/B2XMuMuIncl_InclDiMuHighQ2Line/Particles")


bothstripping = MergedSelection("Selection_mergeddaughters",
       RequiredSelections = [LowQ2MuonsOnDemand,HighQ2MuonsOnDemand])

_filterDimuons = FilterDesktop(Code="ABSID==511") # Dimuons from B0--> mu mu stripping selection
_selDimuons= Selection( "_selDimuons", Algorithm = _filterDimuons, RequiredSelections = [bothstripping] )

from Configurables import SubstitutePID
subalg = SubstitutePID("_B2Jpsi_SubPID", Code="(DECTREE('B0 -> mu+ mu-'))",
                       Substitutions={'B0 -> mu+ mu-' : 'J/psi(1S)'}, MaxChi2PerDoF=-666)
subsel = Selection("subsel",Algorithm = subalg, RequiredSelections = [_selDimuons])

# Try and make B->J/psi K
_B = CombineParticles()
_B.DaughtersCuts = { "K+" : "(PT>500*MeV)&(MIPCHI2DV(PRIMARY) > 9)" }
_B.MotherCut = "(DMASS('B+')<5000*MeV) & (VFASPF(VCHI2)/VFASPF(VDOF)<5.0) & (BPVDIRA > 0.999)" #need to check these cuts
_B.DecayDescriptors = [ "[B+ -> J/psi(1S) K+]cc" ]


_BdecaySelection = Selection( "TurboB", Algorithm = _B, RequiredSelections = [subsel,kaons] )
SeqB = SelectionSequence('SeqB', TopSelection = _BdecaySelection)

# Here we just put the output candidates in an Tuple

tupleB = DecayTreeTuple("bae-muon-data")
tupleB.Inputs = [SeqB.outputLocation()]
tupleB.Decay = "[B+ -> ^K+ ^(J/psi(1S) -> ^mu+ ^mu-)]CC"

Example #2
0
    def __init__(self, name, config):
        LineBuilder.__init__(self, name, config)
        self.__confdict__ = config

        self.GECs = {
            "Code":
            "( recSummaryTrack(LHCb.RecSummary.nLongTracks, TrLONG) < %(GEC_nLongTrk)s )"
            % config,
            "Preambulo": ["from LoKiTracks.decorators import *"]
        }

        #== selection of standard particles
        self.Kaon1Cuts = "(TRCHI2DOF < 3) & (TRGHOSTPROB < 0.5) & (PT > %(K1PT)s *MeV) &"\
                         "(MIPCHI2DV(PRIMARY) < %(K1MinIPChi2)s) & "\
                         "(PIDK-PIDpi > %(K1PIDK)s) & (PIDK-PIDp > 0) & (PIDK-PIDmu > 0)" %config

        self.Kaon1CutsLoose = "(TRCHI2DOF < 3) & (TRGHOSTPROB < 0.5) & (PT > %(K1PTLoose)s *MeV) &"\
                              "(MIPCHI2DV(PRIMARY) < %(K1MinIPChi2)s) & "\
                              "(PIDK-PIDpi > %(K1PIDK)s) & (PIDK-PIDp > 0) & (PIDK-PIDmu > 0)" %config

        self.Kaon2Cuts = "(TRCHI2DOF < 3) & (TRGHOSTPROB < 0.5) & "\
                         "(P > %(K2P)s *MeV) & (PT > %(K2PT)s *MeV) & "\
                         "(MIPCHI2DV(PRIMARY) > %(K2MinIPChi2)s) & "\
                         "(PIDK-PIDpi > %(K2PIDK)s) & (PIDK-PIDp > 0) & (PIDK-PIDmu > 0)" %config

        self.MuonCuts  = "(TRCHI2DOF < 3) & (TRGHOSTPROB < 0.5) & "\
                         "(P > %(MuP)s *MeV) & (PT > %(MuPT)s *MeV) & "\
                         "(MIPCHI2DV(PRIMARY) > %(MuMinIPChi2)s) & "\
                         "(PIDmu-PIDK > 0) & (PIDmu-PIDp > 0) & (PIDmu-PIDpi > %(MuPIDmu)s)" %config

        self.JpsiCuts = "(PFUNA(ADAMASS('J/psi(1S)')) < %(JpsiMassWindow)s * MeV)" % config

        self.SelKaon1 = Selection("K1_for" + name,
                                  Algorithm=FilterDesktop(Code=self.Kaon1Cuts),
                                  RequiredSelections=[StdAllLooseKaons])

        self.SelKaon1Loose = Selection(
            "K1Loose_for" + name,
            Algorithm=FilterDesktop(Code=self.Kaon1CutsLoose),
            RequiredSelections=[StdAllLooseKaons])

        self.SelKaon2 = Selection("K2_for" + name,
                                  Algorithm=FilterDesktop(Code=self.Kaon2Cuts),
                                  RequiredSelections=[StdLooseKaons])

        self.SelMuon = Selection("Mu_for" + name,
                                 Algorithm=FilterDesktop(Code=self.MuonCuts),
                                 RequiredSelections=[StdLooseMuons])

        self.SelJpsi = Selection(
            "Jpsi_for" + name,
            Algorithm=FilterDesktop(Code=self.JpsiCuts),
            RequiredSelections=[StdMassConstrainedJpsi2MuMu])

        # B -> K Mu X, both opposite & same signed K mu can be signals
        self.Bu2KMu = CombineParticles(
            DecayDescriptors=["[B+ -> K+ mu-]cc", "[B+ -> K+ mu+]cc"])
        self.Bu2KMu.CombinationCut = "(AM > %(KMuMassMin)s*MeV) & (AM < %(KMuMassMax)s*MeV)" % config
        self.Bu2KMu.MotherCut      = "(VFASPF(VCHI2/VDOF) < %(KMuVChi2Dof)s) & (BPVDIRA > 0.99) & "\
                                     "(BPVVDCHI2 > %(KMuFdChi2)s)" % config
        self.Bu2KMu.ReFitPVs = True

        self.SelBu2KMu = Selection(
            "Bu2KMu_for" + name,
            Algorithm=self.Bu2KMu,
            RequiredSelections=[self.SelKaon2, self.SelMuon])

        # B -> K J/psi
        self.Bu2KJpsi = CombineParticles(
            DecayDescriptors=["[B+ -> J/psi(1S) K+]cc"])
        self.Bu2KJpsi.CombinationCut = "(AM > %(KJpsiMassMin)s*MeV) & (AM < %(KJpsiMassMax)s*MeV)" % config
        self.Bu2KJpsi.MotherCut      = "(VFASPF(VCHI2/VDOF) < %(KJpsiVChi2Dof)s) & (BPVDIRA > 0.99) & "\
                                       "(BPVVDCHI2 > %(KJpsiFdChi2)s)" % config
        self.Bu2KJpsi.ReFitPVs = True

        self.SelBu2KJpsi = Selection(
            "Bu2KJpsi_for" + name,
            Algorithm=self.Bu2KJpsi,
            RequiredSelections=[self.SelKaon2, self.SelJpsi])

        # B_s2*0 -> (B -> K Mu X) K, signal KK have opposite signed charge.
        self.Bs2KKMu = CombineParticles(DecayDescriptor="[B*_s20 -> B+ K-]cc")
        self.Bs2KKMu.CombinationCut = "(AM-AM1 < %(DMKKMu)s*MeV) & "\
                                      "(abs(ACHILD(BPV(VZ),1)-ACHILD(BPV(VZ),2))<%(DZBPV)s*mm)" % config
        self.Bs2KKMu.MotherCut = "(PT > %(Bs2PT)s*MeV)" % config
        self.Bs2KKMu.ReFitPVs = False

        self.SelBs2KKMu = Selection(
            "Bs2KKMu_for" + name,
            Algorithm=self.Bs2KKMu,
            RequiredSelections=[self.SelBu2KMu, self.SelKaon1])

        # B_s2*0 -> (B -> K Mu X) K, same signed KK for back ground
        self.Bs2KKMuWS = CombineParticles(
            DecayDescriptor="[B*_s20 -> B+ K+]cc")
        self.Bs2KKMuWS.CombinationCut = self.Bs2KKMu.CombinationCut
        self.Bs2KKMuWS.MotherCut = self.Bs2KKMu.MotherCut
        self.Bs2KKMuWS.ReFitPVs = self.Bs2KKMu.ReFitPVs

        self.SelBs2KKMuWS = Selection(
            "Bs2KKMuWS_for" + name,
            Algorithm=self.Bs2KKMuWS,
            RequiredSelections=[self.SelBu2KMu, self.SelKaon1])

        # B_s2*0 -> (B -> K Jpsi) K, signal KK have opposite signed charge.
        self.Bs2KKJpsi = CombineParticles(
            DecayDescriptor="[B*_s20 -> B+ K-]cc")
        self.Bs2KKJpsi.CombinationCut = "(AM-AM1 < %(DMKKJpsi)s*MeV) & "\
                                        "(abs(ACHILD(BPV(VZ),1)-ACHILD(BPV(VZ),2))<%(DZBPV)s*mm)" % config
        self.Bs2KKJpsi.MotherCut = "(PT > %(Bs2PT)s*MeV)" % config
        self.Bs2KKJpsi.ReFitPVs = False

        self.SelBs2KKJpsi = Selection(
            "Bs2KKJpsi_for" + name,
            Algorithm=self.Bs2KKJpsi,
            RequiredSelections=[self.SelBu2KJpsi, self.SelKaon1Loose])

        # B_s2*0 -> (B -> K Jpsi) K, same signed KK for back ground
        self.Bs2KKJpsiWS = CombineParticles(
            DecayDescriptor="[B*_s20 -> B+ K+]cc")
        self.Bs2KKJpsiWS.CombinationCut = self.Bs2KKJpsi.CombinationCut
        self.Bs2KKJpsiWS.MotherCut = self.Bs2KKJpsi.MotherCut
        self.Bs2KKJpsiWS.ReFitPVs = self.Bs2KKJpsi.ReFitPVs

        self.SelBs2KKJpsiWS = Selection(
            "Bs2KKJpsiWS_for" + name,
            Algorithm=self.Bs2KKJpsiWS,
            RequiredSelections=[self.SelBu2KJpsi, self.SelKaon1Loose])

        # register stripping lines
        self.Bs2st2KKMuLine = StrippingLine(
            "Bs2st2KKMuLine",
            prescale=config['Bs2st2KKMuPrescale'],
            FILTER=self.GECs,
            RelatedInfoTools=config['RelatedInfoTools'],
            selection=self.SelBs2KKMu
            #, MDSTFlag  = True
        )

        self.Bs2st2KKMuWSLine = StrippingLine(
            "Bs2st2KKMuWSLine",
            prescale=config['Bs2st2KKMuWSPrescale'],
            FILTER=self.GECs,
            RelatedInfoTools=self.Bs2st2KKMuLine.RelatedInfoTools,
            selection=self.SelBs2KKMuWS
            #, MDSTFlag  = True
        )

        self.Bs2st2KKJpsiLine = StrippingLine(
            "Bs2st2KKJpsiLine",
            prescale=config['Bs2st2KKMuPrescale'],
            FILTER=self.GECs,
            selection=self.SelBs2KKJpsi
            #, MDSTFlag  = True
        )

        self.Bs2st2KKJpsiWSLine = StrippingLine(
            "Bs2st2KKJpsiWSLine",
            prescale=config['Bs2st2KKJpsiWSPrescale'],
            FILTER=self.GECs,
            selection=self.SelBs2KKJpsiWS
            #, MDSTFlag  = True
        )

        # register stripping lines
        self.registerLine(self.Bs2st2KKMuLine)
        self.registerLine(self.Bs2st2KKMuWSLine)
        self.registerLine(self.Bs2st2KKJpsiLine)
        self.registerLine(self.Bs2st2KKJpsiWSLine)
Example #3
0
HighQ2MuonsOnDemand = DataOnDemand(Location = "Phys/B2XMuMuInclusive_InclDiMuHighQ2Line/Particles")


bothstripping = MergedSelection("Selection_mergeddaughters",
       RequiredSelections = [LowQ2MuonsOnDemand,HighQ2MuonsOnDemand])

_filterDimuons = FilterDesktop(Code="ABSID==511") # Dimuons from B0--> mu mu stripping selection
_selDimuons= Selection( "_selDimuons", Algorithm = _filterDimuons, RequiredSelections = [bothstripping] )

from Configurables import SubstitutePID
subalg = SubstitutePID("_B2Jpsi_SubPID", Code="(DECTREE('B0 -> mu+ mu-'))",
                       Substitutions={'B0 -> mu+ mu-' : 'J/psi(1S)'}, MaxChi2PerDoF=-666)
subsel = Selection("subsel",Algorithm = subalg, RequiredSelections = [_selDimuons])

# Try and make B->J/psi K
_B = CombineParticles()
_B.DaughtersCuts = { "K+" : "PT>500*MeV" }
_B.MotherCut = "(DMASS('B+')<5000*MeV) & (VFASPF(VCHI2)<25.0)" #need to check these cuts
_B.DecayDescriptors = [ "[B+ -> J/psi(1S) K+]cc" ] 


_BdecaySelection = Selection( "TurboB", Algorithm = _B, RequiredSelections = [subsel,kaons] )
SeqB = SelectionSequence('SeqB', TopSelection = _BdecaySelection)


tupleB = DecayTreeTuple("bar-muon-tuple")

tupleB.Inputs = [SeqB.outputLocation()]
tupleB.Decay = "[B+ -> ^(J/psi(1S) -> ^mu+ ^mu-) ^K+]CC"

Example #4
0
    def makeKS2LL(self, name, config):

        # define all the cuts

        #1st daughters cuts
        _piPCut1 = "(P>%s*MeV)" % config['pi_L_Pmin']
        _piMIPCut1 = "(MIPDV(PRIMARY)<%s*mm)" % config['pi_L_MIPDV']
        _pipCuts = _piPCut1 + '&' + _piMIPCut1

        _piPCut2 = "(P>%s*MeV)" % config['pi_L_Pmin']
        _piMIPCut2 = "(MIPDV(PRIMARY)<%s*mm)" % config['pi_L_MIPDV']
        _pimCuts = _piPCut2 + '&' + _piMIPCut2

        # before vretex fit cuts
        _massCut2 = "(ADAMASS('KS0')<%s*MeV)" % config['KS_LL_MassWindowP']
        _docacut = "(ACUTDOCA(%s*mm,''))" % config['KS_LL_DOCA']

        _CombinationCuts = _massCut2 + '&' + _docacut

        # after vertex fit cuts
        _massCut = "(ADMASS('KS0')<%s*MeV)" % config['KS_LL_MassWindow']
        _vtxCut = "(VFASPF(VCHI2)<%s)" % config['KS_LL_VtxChi2']
        _combMIP = "( sqrt( CHILD( MIPCHI2DV(PRIMARY) , 1 ) * CHILD( MIPCHI2DV(PRIMARY) , 1 ) +  CHILD( MIPCHI2DV(PRIMARY) , 2 ) * CHILD( MIPCHI2DV(PRIMARY ) , 2 ) )>%s )" % config[
            'KS_LL_CombMPI']
        _docachi2cut = "(DOCA(1,2)/(sqrt( DOCACHI2(1,2) ))<%s*mm)" % config[
            'KS_LL_DOCA_ERR']
        _nuCut = "(log( CHILD( MIPDV(PRIMARY) , 1 )* CHILD( MIPDV(PRIMARY) , 2 )/ MIPDV( PRIMARY) ) > %s )" % config[
            'KS_LL_nu']
        _ptCut = "((CHILD ( PT , 1 )+CHILD ( PT , 2 ))>%s*MeV)" % config[
            'KS_LL_pT']
        _fdCut = "(BPVVDCHI2>%s)" % config['KS_LL_FDChi2']

        #        _trkChi2Cut1 = "(CHILDCUT((TRCHI2DOF<%s),1))" % config['Trk_Chi2']
        #        _trkChi2Cut2 = "(CHILDCUT((TRCHI2DOF<%s),2))" % config['Trk_Chi2']
        _MotherCuts = _massCut + '&' + _vtxCut + '&' + _combMIP + '&' + _docachi2cut + '&' + _nuCut + '&' + _ptCut + '&' + _fdCut

        ########## EndCuts definition

        print 'KS pipCuts: ', _pipCuts
        print 'KS pimCuts: ', _pimCuts
        print 'KS CombinationCuts: ', _CombinationCuts
        print 'KS MotherCuts: ', _MotherCuts

        # make the Ks from StdAllNoPIDsPions
        _Ks = CombineParticles(DecayDescriptor="KS0 -> pi+ pi-",
                               DaughtersCuts={
                                   "pi+": _pipCuts,
                                   "pi-": _pimCuts
                               },
                               CombinationCut=_CombinationCuts,
                               MotherCut=_MotherCuts)

        #  Ks2PiPi.DaughtersCuts =  { "pi+" : "(P>2*GeV) & (MIPDV(PRIMARY)<20.*mm)",
        #                           "pi-" : "(P>2*GeV) & (MIPDV(PRIMARY)<20.*mm)" }

        # get the KS's to filter
        #        _stdKSLL = DataOnDemand( Location = "Phys/StdLooseKsLL/Particles" )

        # make the filter
        #        _filterKSLL = FilterDesktop( Code = _allCuts )

        # make and store the Selection object
        self.selKS2LL = Selection("selKS2LL_" + name,
                                  Algorithm=_Ks,
                                  RequiredSelections=[self.pions])
Example #5
0
    def __init__(self, name, config):

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

        #### muon selection
        Muon_cuts = "(PT > %(MuonPT)s) & (P> %(MuonP)s)"\
                    "& (TRCHI2DOF < %(MuonChi2)s)"\
                     "& (TRGHOSTPROB < %(MuonGhostProbMax)s)"\
                    "& (MIPCHI2DV(PRIMARY)> %(MuonIPChi2)s)" % config
        self.muons = Selection("Muons_for_" + name,
                               Algorithm=FilterDesktop(Code=Muon_cuts),
                               RequiredSelections=[StdNoPIDsMuons])

        #### additional track selection
        Track_cuts = "(PT > %(TrackPT)s) & (P> %(TrackP)s)"\
                     "& (TRCHI2DOF < %(TrackChi2)s)"\
                     "& (TRGHOSTPROB < %(TrackGhostProbMax)s)"\
                     "& (MIPCHI2DV(PRIMARY)> %(TrackIPChi2)s)" % config
        self.tracks = Selection("Tracks_for_" + name,
                                Algorithm=FilterDesktop(Code=Track_cuts),
                                RequiredSelections=[StdNoPIDsKaons])

        #### J/psi->mumu selection
        self.JPsi_to_mumu = CombineParticles(DecayDescriptor = "J/psi(1S) -> mu+ mu-",
                                             CombinationCut = "(ADAMASS('J/psi(1S)')<%(PsiMasswinPreFit)s) & (ADOCACHI2CUT(%(PsiDocaChi2Max)s,''))" %config,
                                             MotherCut = "(INTREE( (ABSID=='mu+') & ISMUON ) )"\
                                             "& (VFASPF(VCHI2/VDOF)< %(PsiVChi2NdofMax)s)"\
                                             "& (ADMASS('J/psi(1S)')< %(PsiMasswin)s)"
                                             " & (SUMTREE( PT,  ISBASIC )>%(PsiPT)s)"\
                                             "& (BPVVDCHI2 > %(PsiFDChi2Min)s) & (BPVDIRA>%(PsiDIRAMin)s)" %config
                                             )
        self.Sel_JPsi_to_mumu = Selection("JPsi_to_mumu_for_" + name,
                                          Algorithm=self.JPsi_to_mumu,
                                          RequiredSelections=[self.muons])

        #### B -> J/psi + >=1 track selection
        self.B_to_JPsi_track = CombineParticles(DecayDescriptor = "[B+ -> J/psi(1S) K+]cc",
                                                CombinationCut = "(AM > %(BCombMassMin)s) & (AM < %(BCombMassMax)s) & (ADOCACHI2CUT(%(BDocaChi2Max)s,''))" %config,
                                                MotherCut = "(VFASPF(VCHI2/VDOF)< %(BVChi2NdofMax)s)"\
                                                " & (SUMTREE( PT,  ISBASIC )>%(BPTMin)s) & (BPVVDCHI2 > %(BFDChi2Min)s) & (BPVDIRA>%(BDIRAMin)s)" %config
                                                )

        self.Sel_B_to_JPsi_track = Selection(
            "B_to_JPsi_track_For" + name,
            Algorithm=self.B_to_JPsi_track,
            RequiredSelections=[self.Sel_JPsi_to_mumu, self.tracks])

        #### GECs
        GECs = {
            "Code":
            "( recSummaryTrack(LHCb.RecSummary.nLongTracks, TrLONG) < %(nLongTrackMax)s )"
            % config,
            "Preambulo": ["from LoKiTracks.decorators import *"]
        }

        #### register the line
        self.registerLine(
            StrippingLine("SemiIncJpsi2mumu" + name + "Line",
                          prescale=config["PrescaleSemiIncJpsi2mumu"],
                          FILTER=GECs,
                          selection=self.Sel_B_to_JPsi_track))
Example #6
0
def makeD2KS0KDD(
        name,
        # KS0 selection
        KS0DDSel
    # Bach kaons selection
    ,
        BachKaonsSel
    # Cuts to be used
    # D meson cuts
    # Combo cuts
    ,
        DMesonComboLowMass,
        DMesonComboHighMass,
        DMesonComboDOCA,
        DMesonAPT,
        DMesonADOCAChi2
    # Mother cuts
    ,
        DMesonMotherLowMass,
        DMesonMotherHighMass,
        DMesonMotherVertexChi2,
        DMesonMotherMIPChi2,
        DMesonMotherPT,
        KS0ZDiff,
        DMesonFlightDistChi2,
        D_BPVLTIME_MIN,
        UseTOS,
        TisTosSpecs):
    """
        Create and return a D(s) -> KS0 K Selection object.
        Arguments:
        name             : name of the Selection.
        ks0llSel         : KS0DD -> pi+pi- Selection object.
        All rest         : Cuts used - self-explanatory naming
        """

    # Define the combination, mother and daughter cuts
    #        _combCuts = "(APT > %(DMesonAPT)s) & (ACUTDOCACHI2(%(DMesonADOCAChi2)s,'')) & in_range(%(DMesonComboLowMass)s, AM, %(DMesonComboHighMass)s)" % locals()
    _combCuts = "(APT > %(DMesonAPT)s) & (ACUTDOCACHI2(%(DMesonADOCAChi2)s,'')) & in_range(%(DMesonComboLowMass)s, AM, %(DMesonComboHighMass)s)" % locals(
    )


    _motherCuts = ("(PT > %(DMesonMotherPT)s) & (VFASPF(VCHI2PDOF) < %(DMesonMotherVertexChi2)s) &"\
                  "  in_range(%(DMesonMotherLowMass)s, MM, %(DMesonMotherHighMass)s) &"\
                  " ((CHILD( VFASPF(VZ) , 'KS0' == ID ) - VFASPF(VZ)) > %(KS0ZDiff)s)  &"\
                  " (MIPCHI2DV(PRIMARY) < %(DMesonMotherMIPChi2)s) &"\
                  " (BPVLTIME() > %(D_BPVLTIME_MIN)s) & (BPVVDCHI2 > %(DMesonFlightDistChi2)s)") % locals()

    # Define the combine particles
    _Dmeson = CombineParticles(DecayDescriptor="[D+ -> KS0 K+]cc",
                               CombinationCut=_combCuts,
                               MotherCut=_motherCuts)

    sel = Selection(name,
                    Algorithm=_Dmeson,
                    RequiredSelections=[KS0DDSel, BachKaonsSel])

    if not UseTOS:
        return sel
    else:
        return Selection(name + "_TOS",
                         Algorithm=TisTosParticleTagger(
                             name + "TOSTagger", TisTosSpecs=TisTosSpecs),
                         RequiredSelections=[sel])
def makeD02hhmumu(
  moduleName
  ,combMassWin
  ,massWin
  ,maxDOCA
  ,pt
  ,dauPt
  ,dauMom
  ,vtxChi2DOF
  ,FDChi2
  ,IPChi2
  ,dauMaxIPChi2
  ,dauIPChi2
  ,DIRA
  ,trackChi2DOF
  ,applyKaonPIDK
  ,kaonPIDK
  ,applyPionPIDK
  ,pionPIDK
  ,applyGhostProbCut
  ,ghostProbCut  
  ):
  """Creates a D0->hhmumu Selection object, merging D0->Kpimumu CF
  , D0->Kpimumu DCS, D0->KKmumu and D0->pipimumu, with cuts for physics analysis.
  Uses StandardParticle objects 'StdAllLooseKaons', 'StdAllLoosePions'
  and 'StdAllLooseMuons'

  Arguments:
    - moduleName : name of Selection
    - combMassWin : mass window cut on combination (MeV/c^2)
    - massWin : mass window cut (MeV/c^2)
    - maxDOCA : maximum DOCA of D0 daughters (mm)
    - pt : minimum transverse momentum of D0 (MeV/c)
    - dauPt : minimum transverse momentum of D0 daughters (MeV/c)
    - dauMom : minimum momentum of D0 daughters (MeV/c)
    - vtxChi2DOF : maximum vertex chi2 / d.o.f.
    - FDChi2 : minimum vertex chi2
    - IPChi2 : maximum IP chi2
    - dauMaxIPChi2 :require at leat one D0 daughter with IP chi2 greather than this value
    - dauIPChi2 : minimum IP chi2 of D0 daughters
    - DIRA : cosine of angle sustended by momentum and flight direction vectors of D0
    - trackChi2DOF : maximum track chi2 / d.o.f. of D0 daughters (unitless)
    - applyKaonPIDK : boolean for whether we apply a kaon PIDK cut
    - kaonPIDK : DLL(K-pi) cut applied to kaon
    - applyPionPIDK : boolean for whether we apply a pion PIDK cut
    - pionPIDK : DLL(K-pi) cut applied to pions
  """
  _prefitCuts = "(ADAMASS('D0')<%(combMassWin)s) & (APT>%(pt)s) & " \
                "(AMAXDOCA('')<%(maxDOCA)s) & " \
                "(AHASCHILD(((ABSID=='K+') | (ABSID=='pi+') | (ABSID=='mu+') ) & " \
                "(MIPCHI2DV(PRIMARY)>%(dauMaxIPChi2)s)))" %locals()

  _motherCuts = "(VFASPF(VCHI2/VDOF)<%(vtxChi2DOF)s) & " \
                "(BPVVDCHI2>%(FDChi2)s) & (BPVIPCHI2()<%(IPChi2)s) & " \
                "(BPVDIRA>%(DIRA)s) & (ADMASS('D0')<%(massWin)s) & " \
                "(PT>%(pt)s)" %locals()

  _kaonCuts = "(TRCHI2DOF<%(trackChi2DOF)s)" \
              " &(PT>%(dauPt)s)&(P>%(dauMom)s)" \
              " & (MIPCHI2DV(PRIMARY)>%(dauIPChi2)s)" \
              %locals()
  _pionCuts = copy(_kaonCuts)
  _muonCuts = copy(_kaonCuts)

  if applyKaonPIDK:
    _kaonCutsOLD = copy(_kaonCuts)
    _kaonCuts="(PIDK>%(kaonPIDK)s) & (HASRICH) & " %locals()
    _kaonCuts+=_kaonCutsOLD
  if applyPionPIDK:
    _pionCutsOLD = copy(_pionCuts)
    _pionCuts="(PIDK<%(pionPIDK)s) & (HASRICH) & " %locals()
    _pionCuts+=_pionCutsOLD
  if applyGhostProbCut:
    _ghostCut = "( TRGHOSTPROB < %(ghostProbCut)s )" %locals()
    _kaonCutsOLD = copy(_kaonCuts)
    _pionCutsOLD = copy(_pionCuts)
    _kaonCuts = _kaonCutsOLD + " & " + _ghostCut
    _pionCuts = _pionCutsOLD + " & " + _ghostCut
    

  from StandardParticles import StdAllNoPIDsPions, StdAllNoPIDsKaons
  from StandardParticles import StdAllLoosePions, StdAllLooseKaons, StdAllLooseMuons 

  _kaons = StdAllLooseKaons
  _pions = StdAllLoosePions
  _muons = StdAllLooseMuons


  _d02kpi = CombineParticles (DecayDescriptor = "[D0 -> K- pi+ mu+ mu-]cc"
                               ,CombinationCut = _prefitCuts
                               ,MotherCut = _motherCuts
                               ,DaughtersCuts = { "K+" : _kaonCuts
                                                  ,"pi+" : _pionCuts
                                                  ,"mu+" : _muonCuts}
                               )
  _selD02KPi = Selection('D02KPiFor'+moduleName
                          ,Algorithm=_d02kpi
                          ,RequiredSelections=[_muons,_kaons,_pions])

  _conjPID = ConjugateNeutralPID()

  _selD02KPiConj = Selection('D02KPiConjFor'+moduleName
                             ,Algorithm=_conjPID
                             ,RequiredSelections=[_selD02KPi])

  _d02kk = copy(_d02kpi)
  _d02kk.DecayDescriptor="D0 -> K+ K- mu+ mu-"

  _selD02KK = Selection('D02KKFor'+moduleName
                            ,Algorithm=_d02kk
                            ,RequiredSelections=[_muons,_kaons])

  _selD02KKConj = Selection('D02KKConjFor'+moduleName
                             ,Algorithm=_conjPID
                             ,RequiredSelections=[_selD02KK])

  _d02pipi = copy(_d02kpi)
  _d02pipi.DecayDescriptor="D0 -> pi+ pi- mu+ mu-"
  _d02pipi.DaughtersCuts={ "K+" : _kaonCuts
                           ,"pi+" : _pionCuts
                           ,"mu+" : _muonCuts}

  _selD02PiPi = Selection('D02PiPiFor'+moduleName
                           ,Algorithm=_d02pipi
                           ,RequiredSelections=[_muons,_pions])

  _selD02PiPiConj = Selection('D02PiPiConjFor'+moduleName
                                ,Algorithm=_conjPID
                                ,RequiredSelections=[_selD02PiPi])

  _d0Sel = MergedSelection('D02hhmumuFor'+moduleName
                           ,RequiredSelections=[_selD02KPi
                                                ,_selD02KPiConj
                                                ,_selD02KK
                                                ,_selD02KKConj
                                                ,_selD02PiPi
                                                ,_selD02PiPiConj]
                           )


  return _d0Sel
Example #8
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", DisplVerticesConf.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", DisplVerticesConf.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.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", DisplVerticesConf.recoCuts + DisplVerticesConf.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", DisplVerticesConf.recoCuts + DisplVerticesConf.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 = ( LoKi_Filters(HLT2_Code="in_range( {begin}, HLT_TCK % 0x40000000 , {end} ) & ( {decisions} )".format(begin=tckBegin, end=tckEnd, decisions=" | ".join("HLT_PASS('%s')" % ln for ln in hltLines))).filters("%sHlt2DecisionFilterTCK%s-%s" % (self.name(), tckBegin, tckEnd))
                                                  + [ HltVertexConverterS20p3("%sHltConverter%s-%s" % (self.name(), tckBegin, tckEnd), HltSelReports="Hlt2/SelReports", 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", DisplVerticesConf.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
                                          )
                          )

        #######################################################################
        ###                                                                 ###
        ###     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, DisplVerticesConf.singleCuts + DisplVerticesConf.downCuts) )
            else:
                code = self.getLLPSelection( self.validatedGetProps(lSelName, DisplVerticesConf.singleCuts) )

            lineFilter = FilterDesktop(
                             DecayDescriptor    = LLPLHCbName
                           , Preambulo          = DisplVerticesConf.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
                     , RequiredRawEvents = [ "Calo" ]
                     , RelatedInfoTools = [ { "Type" : "AddVeloEventShapeS21", "TopSelection" : lineSel, "Location" : "P2VES" } ]
                     )
            if lShortName in self.configurationParameter("HLT"):
                line.HLT2 = 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, DisplVerticesConf.singleCuts) )

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

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

            jetProps = self.validatedGetProps(lSelName, DisplVerticesConf.jetCuts)
            vertWithJets = Selection( "".join(( self.name(), lSelName, "Jets" ))
                           , RequiredSelections = [ goodVertices ]
                           , Algorithm          = self.makeJetCandidateAlg("".join((self.name(), lSelName, "JetAlg"))
                                                      , MinNumJets = jetProps["MinNumJets"]
                                                      , ConeSize   = jetProps["ConeSize"]
                                                      , JetIDCut   = jetProps["JetIDCut"]
                                                      , MinDOCABL  = jetProps["MinDOCABL"]
                                                      )
                           )
            jetCode = self.getLLPJetSelection(jetProps)
            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
                     , RequiredRawEvents = [ "Calo" ]
                     , RelatedInfoTools = [ { "Type" : "AddVeloEventShapeS21", "TopSelection" : lineSel, "Location" : "P2VES" } ]
                     )
            if lShortName in self.configurationParameter("HLT"):
                line.HLT2 = 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, DisplVerticesConf.jetCuts)
            vertWithJets = Selection( "".join(( self.name(), lSelName, "HltJets" ))
                           , RequiredSelections = [ hlt2CandAndGECSelection ]
                           , Algorithm          = self.makeJetCandidateAlg("".join((self.name(), lSelName, "HltJetAlg"))
                                                      , MinNumJets = jetProps["MinNumJets"]
                                                      , ConeSize   = jetProps["ConeSize"]
                                                      , JetIDCut   = jetProps["JetIDCut"]
                                                      , MinDOCABL  = jetProps["MinDOCABL"]
                                                      )
                           )
            jetCode = self.getLLPJetSelection(jetProps)
            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
                     , RequiredRawEvents = [ "Calo" ]
                     , RelatedInfoTools = [ { "Type" : "AddVeloEventShapeS21", "TopSelection" : lineSel, "Location" : "P2VES" } ]
                     )
            if lShortName in self.configurationParameter("HLT"):
                line.HLT2 = 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, DisplVerticesConf.doubleResonanceCuts) )
            lineFilter = CombineParticles(
                             DecayDescriptor    = "H_10 -> %s %s" % (LLPLHCbName, LLPLHCbName)
                           , Preambulo          = DisplVerticesConf.llpSelectionPreambulo
                           , DaughtersCuts      = { LLPLHCbName : self.getLLPSelection( self.validatedGetProps(lSelName, DisplVerticesConf.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
                     , RequiredRawEvents = [  "Calo" ]
                     , RelatedInfoTools = [ { "Type" : "AddVeloEventShapeS21", "TopSelection" : lineSel, "Location" : "P2VES" } ]
                     )
            if lShortName in self.configurationParameter("HLT"):
                line.HLT2 = 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

            orFilters = []
            for (tckBegin, tckEnd), hltFilter in self.validatedGetProps("HLT", [lShortName])[lShortName]:
                filters = LoKi_Filters(HLT2_Code="in_range( {begin}, HLT_TCK % 0x40000000, {end} ) & ( {decisions} )".format(begin=tckBegin, end=tckEnd, decisions=hltFilter)).filters("%sHlt2FilterTCK%s-%s" % (lLineName, tckBegin, tckEnd))
                assert len(filters) == 1
                orFilters.append(filters[0])
            assert len(orFilters) == len(self.validatedGetProps("HLT", [lShortName])[lShortName])

            hltSelection = EventSelection( "%sHltFilter" % lLineName
                              , Algorithm = GaudiSequenceroid(ModeOR = True, ShortCircuit = False, Members=orFilters)
                              )

            line = StrippingLine(lLineName
                     , prescale  = self.validatedGetProps(lShortName, ["PreScale"])["PreScale"]
                     , selection = hltSelection
                     , RequiredRawEvents = ["Muon","Calo","Rich","Velo","Tracker"]
                     )

            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          = DisplVerticesConf.llpSelectionPreambulo
                           , Code               = self.getLLPSelection( self.validatedGetProps(lSelName, DisplVerticesConf.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
                     , HLT2      = self.configurationParameter("HLT")[lShortName]
                     , selection = lineSel
                     , RequiredRawEvents = ["Muon","Calo","Rich","Velo","Tracker"]
                     , RelatedInfoTools = [ { "Type" : "AddVeloEventShapeS21", "TopSelection" : lineSel, "Location" : "P2VES" } ]
                     )

            self.registerLine(line)
Example #9
0
def makeLambdac2PKPi(name,
                     inputSel,
                     Daug_All_PT_MIN,
                     Daug_2of3_PT_MIN,
                     Daug_1of3_PT_MIN,
                     Daug_All_BPVIPCHI2_MIN,
                     Daug_2of3_BPVIPCHI2_MIN,
                     Daug_1of3_BPVIPCHI2_MIN,
                     Proton_PIDpPIDpi_MIN,
                     Proton_PIDpPIDK_MIN,
                     K_PIDK_MIN,
                     Pi_PIDK_MAX,
                     Comb_ADAMASS_WIN,
                     Comb_ADOCAMAX_MAX,
                     Lambdac_VCHI2VDOF_MAX,
                     Lambdac_acosBPVDIRA_MAX,
                     Lambdac_PVDispCut,
                     decDescriptors=["[Lambda_c+ -> p+ K- pi+]cc"]):  # {

    ## Construct a preambulo to simplify some calculations.
    lclPreambulo = [
        "from math import cos",
        "bpvdirathresh = cos(%(Lambdac_acosBPVDIRA_MAX)s)" % locals(),
        "pidFiducialPMin = 3.0 * GeV", "pidFiducialPMax = 100.0 * GeV"
    ]


    daugCuts = "(PT > %(Daug_All_PT_MIN)s)" \
               "& (BPVIPCHI2() > %(Daug_All_BPVIPCHI2_MIN)s)" % locals()

    pidFiducialCuts = "(HASRICH)" \
                      "& (in_range(pidFiducialPMin, P, pidFiducialPMax))" \
                      "& (in_range(2.0, ETA, 5.0))"

    pCuts =  pidFiducialCuts + "& ((PIDp-PIDpi) > %(Proton_PIDpPIDpi_MIN)s)" \
             "& ((PIDp-PIDK) > %(Proton_PIDpPIDK_MIN)s)" % locals()
    kCuts = pidFiducialCuts + "& ((PIDK-PIDpi) > %(K_PIDK_MIN)s)" % locals()
    piCuts = pidFiducialCuts + "& ((PIDK-PIDpi) < %(Pi_PIDK_MAX)s)" % locals()


    combCuts = "(ADAMASS('Lambda_c+') < %(Comb_ADAMASS_WIN)s)" \
               "& (AMAXCHILD(PT) > %(Daug_1of3_PT_MIN)s)" \
               "& (AMAXCHILD(BPVIPCHI2()) > %(Daug_1of3_BPVIPCHI2_MIN)s)" \
               "& (ANUM(PT > %(Daug_2of3_PT_MIN)s) >= 2)" \
               "& (ANUM(BPVIPCHI2() > %(Daug_2of3_BPVIPCHI2_MIN)s) >= 2)" \
               "& (ADOCAMAX('') < %(Comb_ADOCAMAX_MAX)s)" % locals()

    lambdacCuts = "(VFASPF(VCHI2/VDOF) < %(Lambdac_VCHI2VDOF_MAX)s)" \
                  "& (%(Lambdac_PVDispCut)s)" \
                  "& (BPVDIRA > bpvdirathresh)" % locals()

    _Lambdac = CombineParticles(DecayDescriptors=decDescriptors,
                                Preambulo=lclPreambulo,
                                DaughtersCuts={
                                    "pi+": daugCuts + '&' + piCuts,
                                    "K+": daugCuts + '&' + kCuts,
                                    "p+": daugCuts + '&' + pCuts
                                },
                                CombinationCut=combCuts,
                                MotherCut=lambdacCuts)

    return Selection(name, Algorithm=_Lambdac, RequiredSelections=inputSel)
    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)
Example #11
0
def makeb2DMuXNEW(module_name,
                  name,
                  BDecays,
                  DDecays,
                  CONFIG,
                  CHARM_DAUGHTERS,
                  MUON):

    DEFAULT_GECs = { "Code":"( recSummaryTrack(LHCb.RecSummary.nLongTracks, TrLONG) < %(GEC_nLongTrk)s )" %CONFIG,
                     "Preambulo": ["from LoKiTracks.decorators import *"]}
    
    DEFAULT_HLT = CONFIG["HLT_FILTER"]
    
    CHARM_DaugCuts = {}
    CHARM_ComboCuts = CONFIG["CharmComboCuts"]
    CHARM_MotherCuts = CONFIG["CharmMotherCuts"]
    
    if "CharmDaugCuts" in CONFIG.keys():
        CHARM_DaugCuts = CONFIG["CharmDaugCuts"]
    if "CharmExtraComboCuts" in CONFIG.keys():
        CHARM_ComboCuts += CONFIG["CharmExtraComboCuts"]
    if "CharmExtraMotherCuts" in CONFIG.keys():
        CHARM_MotherCuts += CONFIG["CharmExtraMotherCuts"]
    
    CHARM = Selection("CharmSelFor"+name+module_name,
                      Algorithm=CombineParticles(DecayDescriptors = DDecays,
                                                 DaughtersCuts = CHARM_DaugCuts,
                                                 CombinationCut = CHARM_ComboCuts,
                                                 MotherCut = CHARM_MotherCuts),
                      RequiredSelections = CHARM_DAUGHTERS)

    USED_CHARM = CHARM
    if "D*" in BDecays:
        DST = makeDstar("CharmSelDstFor"+name+module_name,CHARM,CONFIG)
        USED_CHARM = DST

    B_combinationCut = "(AM > %(BMassMin)s*GeV) & (AM < %(BMassMax)s*GeV) & (ADOCACHI2CUT( %(B_DocaChi2Max)s, ''))" %CONFIG
    B_motherCut = " (MM>%(BMassMin)s*GeV) & (MM<%(BMassMax)s*GeV) &  (VFASPF(VCHI2/VDOF)< %(BVCHI2DOF)s) & (BPVDIRA> %(B_DIRA)s)  " \
        "& (MINTREE(((ABSID=='D+') | (ABSID=='D0') | (ABSID=='Lambda_c+')) , VFASPF(VZ))-VFASPF(VZ) > %(B_D_DZ)s *mm ) " %CONFIG
    if "ExtraComboCuts" in CONFIG.keys():
        B_combinationCut += CONFIG["ExtraComboCuts"]
    if "ExtraMotherCuts" in CONFIG.keys():
        B_motherCut += CONFIG["ExtraMotherCuts"]
        
    B_DaugCuts = {}
    if "ExtraMuonCuts" in CONFIG.keys():
        B_DaugCuts = {"mu+":CONFIG["ExtraMuonCuts"]}
    if "ExtraElectronCuts" in CONFIG.keys():
        B_DaugCuts = {"e+":CONFIG["ExtraElectronCuts"]}
    _B = CombineParticles(DecayDescriptors = BDecays,
                          DaughtersCuts = B_DaugCuts,
                          CombinationCut = B_combinationCut,
                          MotherCut = B_motherCut)
                     
    BSel = Selection ("BSelFor"+name+module_name,
                      Algorithm = _B,
                      RequiredSelections = [MUON,USED_CHARM])
    
    ### invert the order for the fakes line
    ### to be more efficient
    if "fakes" in name:
        BSel.RequiredSelections = [USED_CHARM,MUON]
    
    BSelTOS = TOSFilter( "BSelFor"+name+module_name+"TOS"
                         ,BSel
                         ,CONFIG["TTSpecs"])
    
    debug = False
    if debug:
        print [name,DEFAULT_HLT,CHARM_DaugCuts,Charm_ComboCuts,CHARM_MotherCuts,B_DaugCuts,B_combinationCut,B_motherCut]
    _prescale = 1.0
    if name in CONFIG["prescales"].keys():
        _prescale = CONFIG["prescales"][name]

    return StrippingLine(name + module_name + 'Line', 
                         HLT = DEFAULT_HLT,
                         FILTER=DEFAULT_GECs,
                         prescale = _prescale,
                         selection = BSelTOS)
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])
 def DiCharm ( self ) :
     """
     Di-Charm selection
     """
     sel = self._selection ( 'DiCharm_Selection' )
     if sel : return sel
     
     ## prepare Di-charm
     cmb = CombineParticles (
         ## the decays to be reconstructed 
         DecayDescriptors = [
         #
         # charm-anti-charm
         #
         "   psi(3770) -> D0        D~0            "  ,
         " [ psi(3770) -> D0        D*(2010)-  ]cc "  ,
         " [ psi(3770) -> D0        D-         ]cc "  ,
         " [ psi(3770) -> D0        D_s-       ]cc "  ,
         " [ psi(3770) -> D0        Lambda_c~- ]cc "  ,
         #
         "   psi(3770) -> D*(2010)+ D*(2010)-      "  ,
         " [ psi(3770) -> D*(2010)+ D-         ]cc "  ,
         " [ psi(3770) -> D*(2010)+ D_s-       ]cc "  ,
         " [ psi(3770) -> D*(2010)+ Lambda_c~- ]cc "  ,
         #
         "   psi(3770) -> D+        D-             "  ,
         " [ psi(3770) -> D+        D_s-       ]cc "  ,
         " [ psi(3770) -> D+        Lambda_c~- ]cc "  ,
         #
         "   psi(3770) -> D_s+      D_s-           "  ,
         " [ psi(3770) -> D_s+      Lambda_c~- ]cc "  ,
         #
         "   psi(3770) -> Lambda_c+ Lambda_c~-     "  ,
         #
         # double charm
         #
         " [ psi(3770) -> D0        D0         ]cc"  ,
         " [ psi(3770) -> D0        D*(2010)+  ]cc "  ,
         " [ psi(3770) -> D0        D+         ]cc "  ,
         " [ psi(3770) -> D0        D_s+       ]cc "  ,
         " [ psi(3770) -> D0        Lambda_c+  ]cc "  ,
         #
         " [ psi(3770) -> D*(2010)+ D*(2010)+  ]cc "  ,
         " [ psi(3770) -> D*(2010)+ D+         ]cc "  ,
         " [ psi(3770) -> D*(2010)+ D_s+       ]cc "  ,
         " [ psi(3770) -> D*(2010)+ Lambda_c+  ]cc "  ,
         #
         " [ psi(3770) -> D+        D+         ]cc "  ,
         " [ psi(3770) -> D+        D_s+       ]cc "  ,
         " [ psi(3770) -> D+        Lambda_c+  ]cc "  ,
         #
         " [ psi(3770) -> D_s+      D_s+       ]cc "  ,
         " [ psi(3770) -> D_s+      Lambda_c+  ]cc "  ,
         #
         " [ psi(3770) -> Lambda_c+ Lambda_c+  ]cc "
         
         ] ,
         ## combination cut : accept all 
         CombinationCut = " AALL " ,
         ##      mother cut : accept all 
         MotherCut      = "  ALL " 
         )
     
     sel = Selection (
         ##
         'SelDiCharmFor'    + self.name() ,
         ##
         Algorithm          = cmb    ,
         ##
         RequiredSelections = [ self.PromptCharm () ]
         )
     
     return self._add_selection ( 'DiCharm_Selection' , sel ) 
Example #14
0
def makeEE(
        name,
        #
        Both_PT,
        Both_P,
        Both_TRCHI2DOF,
        Both_MIPCHI2,
        #
        Tag_PT,
        Tag_P,
        Tag_PIDe,
        Tag_MIPCHI2,
        #
        Probe_PT,
        Probe_P,
        Probe_MIPCHI2,
        #
        eeCombMinMass,
        eeCombMaxMass,
        eeVCHI2PDOF,
        eeMinMass,
        eeMaxMass,
        #
        eeFDCHI2,
        eeVZ):

    _StdNoPIDsDownElectrons = DataOnDemand(
        Location='Phys/StdNoPIDsDownElectrons/Particles')

    InAccCuts = "(0.5<PPINFO(LHCb.ProtoParticle.InAccEcal,-1))"

    BothCuts = "(PT> %(Both_PT)s *MeV)"\
               " & (TRCHI2DOF < %(Both_TRCHI2DOF)s)"\
               " & (MINTREE('e+'==ABSID,MIPCHI2DV(PRIMARY))> %(Both_MIPCHI2)s )" % locals()

    EEComCut = "(in_range(%(eeCombMinMass)s *MeV, AM, %(eeCombMaxMass)s *MeV))" % locals(
    )

    EEMomCut = "(VFASPF(VCHI2)< %(eeVCHI2PDOF)s)"\
               " & (in_range(%(eeMinMass)s *MeV, MM, %(eeMaxMass)s *MeV))"\
               " & (BPVVDCHI2>%(eeFDCHI2)s)"\
               " & (VFASPF(VZ)>%(eeVZ)s *mm)" % locals()

    Tag1Cuts = "(CHILDCUT((PT>%(Tag_PT)s*MeV),1)) & (CHILDCUT((PIDe>%(Tag_PIDe)s),1)) & (CHILDCUT((P>%(Tag_P)s*MeV),1))"\
               " & (CHILDCUT((MIPCHI2DV(PRIMARY)> %(Tag_MIPCHI2)s),1))" % locals()
    Tag2Cuts = "(CHILDCUT((PT>%(Tag_PT)s*MeV),2)) & (CHILDCUT((PIDe>%(Tag_PIDe)s),2)) & (CHILDCUT((P>%(Tag_P)s*MeV),2))"\
               " & (CHILDCUT((MIPCHI2DV(PRIMARY)> %(Tag_MIPCHI2)s),2))" % locals()

    Probe1Cuts = "(CHILDCUT((PT>%(Probe_PT)s*MeV),1)) & (CHILDCUT((P>%(Probe_P)s*MeV),1))"\
                 " & (CHILDCUT((MIPCHI2DV(PRIMARY)> %(Probe_MIPCHI2)s),1))" % locals()
    Probe2Cuts = "(CHILDCUT((PT>%(Probe_PT)s*MeV),2)) & (CHILDCUT((P>%(Probe_P)s*MeV),2))"\
                 " & (CHILDCUT((MIPCHI2DV(PRIMARY)> %(Probe_MIPCHI2)s),2))" % locals()

    Tag1Probe2Cuts = Tag1Cuts + " & " + Probe2Cuts
    Tag2Probe1Cuts = Tag2Cuts + " & " + Probe1Cuts

    _EE = CombineParticles(DecayDescriptor="J/psi(1S) -> e+ e-",
                           DaughtersCuts={"e+": InAccCuts + "&" + BothCuts},
                           CombinationCut=EEComCut,
                           MotherCut=EEMomCut + " & ( ( " + Tag1Probe2Cuts +
                           " ) | (" + Tag2Probe1Cuts + " ) ) ")

    return Selection(name,
                     Algorithm=_EE,
                     RequiredSelections=[_StdNoPIDsDownElectrons])
Example #15
0
    def _Bs2PhiPhi_X_Line( self, name, config, wide ) :

            Phi2KK_DC = "(TRGHOSTPROB < 0.5) & (PT>%(KaonPT)s*MeV)&(MIPCHI2DV(PRIMARY)>%(KaonIPCHI2)s)" % config
            Phi2KK_CC = "(AM<(%(PhiMassMax)s+30)*MeV)" % config
            #Phi2KK_CC = "(AM<(%(PhiMassMax)s+30)*MeV)&(ADOCACHI2CUT(40, ''))" % config

            Phi2KK_MassCut = ""
            if wide == False :
              Phi2KK_MassCut = "&(ADMASS('phi(1020)')<%(PhiMassWindow)s*MeV)" % config
            else :
              Phi2KK_MassCut = "&(MM<%(PhiMassMax)s*MeV)" % config

            Phi2KK_MC = "(VFASPF(VCHI2/VDOF)<%(PhiVertexCHI2pDOF)s)" % config + Phi2KK_MassCut

    	    Bs2PhiPhi_DC = "(PT>%(PhiPT)s*MeV)" % config
    	    Bs2PhiPhi_CC = "(ADAMASS('B_s0')<((%(BsMassWindow)s+30)*MeV))&(ACHILD(PT,1)*ACHILD(PT,2)>%(PhiPTsq)s*GeV*GeV)" % config
    	    Bs2PhiPhi_MC = "(BPVDIRA > 0.999) & (VFASPF(VCHI2/VDOF)<%(BsVertexCHI2pDOF)s)&(ADMASS('B_s0')<%(BsMassWindow)s*MeV)" % config
            ps = 1.0
            if wide == True :
              ps = config['WidePrescale']

    	    #print "Cuts for "+name+"Line"
            #print Phi2KK_DC
            #print Phi2KK_CC
            #print Phi2KK_MC

    	    #print Bs2PhiPhi_DC
    	    #print Bs2PhiPhi_CC
    	    #print Bs2PhiPhi_MC
            #print "Prescale: ", ps

	    #_stdLooseKaons = DataOnDemand(Location = "Phys/StdLooseKaons/Particles")

            _Bs2PhiPhiLooseDetachedPhi2KK = CombineParticles(
                            DecayDescriptor = "phi(1020) -> K+ K-"
                          , DaughtersCuts = {"K+": Phi2KK_DC}
                          , CombinationCut = Phi2KK_CC
                          , MotherCut = Phi2KK_MC
                       )


    	    _Bs2PhiPhi = CombineParticles(
             DecayDescriptor =  "B_s0 -> phi(1020) phi(1020)"
    	    , DaughtersCuts   = {"phi(1020)" : Bs2PhiPhi_DC}
            , CombinationCut  = Bs2PhiPhi_CC
            , MotherCut       = Bs2PhiPhi_MC
            )


	    Bs2PhiPhiLooseDetachedPhi2KK = Selection(
		name+ "_LoosePhi2KK",
		Algorithm = _Bs2PhiPhiLooseDetachedPhi2KK,
		RequiredSelections = [MyLooseKaons])
	    Bs2PhiPhi = Selection(
		 name,
		 Algorithm = _Bs2PhiPhi,
		 RequiredSelections = [Bs2PhiPhiLooseDetachedPhi2KK])

            if wide == True:
      	      return StrippingLine(name+"Line"
                , prescale = ps
                , postscale = 1
                , selection = Bs2PhiPhi
                , EnableFlavourTagging = True,
                RelatedInfoTools = [ 
                    { "Type"         : "RelInfoConeVariables",
                    "ConeAngle"    : 0.8,
                    "Variables"    : ['CONEANGLE', 'CONEMULT', 'CONEPTASYM'],
                    'RecursionLevel' : 2,
                    "Locations"     : {'Phys/StdAllLooseANNKaons' : ['P2ConeVar08_1','P2ConeVar08_2','P2ConeVar08_3','P2ConeVar08_4'] } },
                    { "Type"         : "RelInfoConeVariables",
                    "ConeAngle"    : 1.0,
                    "Variables"    : ['CONEANGLE', 'CONEMULT', 'CONEPTASYM'],
                    'RecursionLevel' : 2,
                    "Locations"     : {'Phys/StdAllLooseANNKaons' : ['P2ConeVar10_1','P2ConeVar10_2','P2ConeVar10_3','P2ConeVar10_4'] } },
                    { "Type"         : "RelInfoConeVariables",
                    "ConeAngle"    : 1.3,
                    "Variables"    : ['CONEANGLE', 'CONEMULT', 'CONEPTASYM'],
                    'RecursionLevel' : 2,
                    "Locations"     : {'Phys/StdAllLooseANNKaons' : ['P2ConeVar13_1','P2ConeVar13_2','P2ConeVar13_3','P2ConeVar13_4'] } },
                    { "Type"         : "RelInfoConeVariables",
                    "ConeAngle"    : 1.7,
                    "Variables"    : ['CONEANGLE', 'CONEMULT', 'CONEPTASYM'],
                    'RecursionLevel' : 2,
                    "Locations"     : {'Phys/StdAllLooseANNKaons' : ['P2ConeVar17_1','P2ConeVar17_2','P2ConeVar17_3','P2ConeVar17_4'] } },
                    { "Type"         : "RelInfoVertexIsolation", "Location"     : "VertexIsoInfo" } ] 
              )
            else:
              return StrippingLine(name+"Line"
                , prescale = ps
                , postscale = 1
                , selection = Bs2PhiPhi
                , EnableFlavourTagging = True
                , RequiredRawEvents = ['Trigger', 'Muon', 'Calo', 'Rich', 'Velo', 'Tracker'])
 def psi_Kst ( self ) :
     """
     This is just a control line to study
     the reconstruction efficiency for pi0 and gamma
     see LHCb-INT-2012-001 
     
     """
     sel = self._selection ( 'PsiK*+_Selection')
     if sel : return sel
     
     alg  = CombineParticles (
         ##
         DecayDescriptors = [
         "[B+ -> J/psi(1S) K+ pi0 ]cc" ,
         ] ,
         ##
         DaughtersCuts = {
         'J/psi(1S)' : " M < 3.3 * GeV "       ,    ## keep only J/psi
         ## 'pi0'       : """
         ## ( abs ( LV01 ) < 0.9 ) &
         ## ( MINTREE ( 'gamma' == ID , PT ) > 250 * MeV ) 
         ## """ , 
         } , 
         ##
         Preambulo = self['Preambulo'] ,
         ##
         CombinationCut = """
         in_range ( 4.95 * GeV , AM   , 5.75 * GeV ) &
         in_range ( 750  * MeV , AM23 , 1050 * MeV ) &
         ( APT23 > 1.5 * GeV ) 
         """ ,
         ## 
         MotherCut = """
         in_range ( 5.0 * GeV , M , 5.7 * GeV ) & 
         ( chi2vx    < 16 ) &
         ( ctau_9    > %s ) 
         """ % self['CTAU_Kst'] , 
         ## 
         ParticleCombiners = {'' : "LoKi::VertexFitter" }
         )
     #
     sel_ = Selection (
         "SelPrePsiK*+For"  + self.name ()    ,
         Algorithm          =   alg           ,
         RequiredSelections = [ self.psi   () , 
                                self.kaons () ,
                                self.pi0s  () ] 
         )
     
     tag = Pi0Veto__Tagger2g (
         MassWindow     = 25 * MeV  ,
         MassChi2       = -1        ,
         ExtraInfoIndex = 25020     ## unique ! 
         )
     
     sel  = Selection (
         "SelPsiK*+For"     + self.name ()   ,
         Algorithm          =   tag           ,
         RequiredSelections = [ sel_          ]  
         )
     
     return self._add_selection( 'PsiK*+_Selection' , sel )