def splitPhiPi(self, name, phiPiSelection): """Split the input phi pi+ Selection in to a D+ and D_s+ selection. Returns a two-tuple as (D+ Selection, D_s+ Selection). Keyword arguments: phiPiSelection -- A single Selection instance; output of makeD2PhiPi """ dpFilter = FilterDesktop( 'FilterDp{0}'.format(name), Code="(ADMASS('D+') < {0[Dp_ADAMASS_WIN]})".format(self.config)) dsFilter = FilterDesktop( 'FilterDs{0}'.format(name), Code="(ADMASS('D_s+') < {0[Ds_ADAMASS_WIN]})".format(self.config)) dpSel = Selection('SelFilteredDp{0}'.format(name), Algorithm=dpFilter, RequiredSelections=[phiPiSelection]) dsSel = Selection('SelFilteredDs{0}'.format(name), Algorithm=dsFilter, RequiredSelections=[phiPiSelection]) # The PhiPi selection is labelled as a D_s+, so rename the candidates # in the Dp selection as such dpSubPID = SubstitutePID(name='SubPidDp{0}'.format(name), Code="DECTREE('[D_s+ -> X0 X+]CC')", Substitutions={ 'D_s+ -> X0 X+': 'D+', 'D_s- -> X0 X-': 'D-' }, MaxChi2PerDoF=-1) dpSubPIDSel = Selection('SubPIDDpSel{0}'.format(name), Algorithm=dpSubPID, RequiredSelections=[dpSel]) return dpSubPIDSel, dsSel
def makePhotonConv(self, name, mMax, maxVChi, minPT, inputSel): """ Create photon selection objects starting from converted photons list (StdAllLooseGammaLL, StdAllLooseGammaDD) """ _code = " ( MM < %(mMax)s * MeV ) " \ "&( HASVERTEX ) " \ "&( VFASPF(VCHI2/VDOF)<%(maxVChi)s ) " \ "&( PT > %(minPT)s)" % locals() _filter = FilterDesktop(name="ConvertedGammaFilter_" + name, Code=_code) return Selection(name, Algorithm=_filter, RequiredSelections=inputSel) _DDConvSel = FilterDesktop( Code= "(MM < 100*MeV) & (HASVERTEX) & (VFASPF(VCHI2/VDOF)<9) & (PT > %(B2XGGammaCNVPTMin)s)" % self.__confdict__) self.ConvLLPhoton = Selection('ConvLLPhoton' + self.name, Algorithm=_LLConvSel, RequiredSelections=[StdAllLooseGammaLL]) self.ConvDDPhoton = Selection('ConvDDPhoton' + self.name, Algorithm=_DDConvSel, RequiredSelections=[StdAllLooseGammaDD])
def makeKst2Kpi(name, KaonPT, KaonIPCHI2, PionPT, PionIPCHI2, KstarPT, KaonPIDK, KstarVCHI2, KstarMassWin, PionPIDK): """ Create and return a Kstar -> K+pi- Selection object. Starts from DataOnDemand 'Phys/StdVeryLooseDetachedKst2Kpi'. Arguments: name : name of the Selection. KaonPT : Minimum transverse momentum of K (MeV). KaonIPCHI2 : Minimum impact parameter chi2 of K. PionPT : Minimum transverse momentum of pi (MeV). PionIPCHI2 : Minimum impact parameter chi2 of pi. PionPIDK : Maximum PID_{K-pi} of pi. KstarPT : Minimum transverse momentum of Kstar (MeV). KaonPIDK : Minimum PID_{K-pi} of K. KstarVCHI2 : Maximum Kstar vertex chi2 per degree of freedom. KstarMassWin : Kstar invariant mass window around PDG mass value (MeV). """ KstarCuts = "(INTREE((ABSID=='K+') & (PT > %(KaonPT)s *MeV) & (MIPCHI2DV(PRIMARY)> %(KaonIPCHI2)s) & (PIDK > %(KaonPIDK)s) ))"\ "& (INTREE((ABSID=='pi-') & (PT > %(PionPT)s *MeV) & (MIPCHI2DV(PRIMARY)> %(PionIPCHI2)s) & (PIDK < %(PionPIDK)s ) ))"\ "& (ADMASS('K*(892)0') < %(KstarMassWin)s *MeV)"\ "& (VFASPF(VCHI2/VDOF)< %(KstarVCHI2)s) & (PT > %(KstarPT)s *MeV)"% locals() _KstarFilter = FilterDesktop("_filterFor" + name) _KstarFilter.Code = KstarCuts _stdKst2Kpi = DataOnDemand( Location="Phys/StdVeryLooseDetachedKst2Kpi/Particles") return Selection(name, Algorithm=_KstarFilter, RequiredSelections=[_stdKst2Kpi])
def __init__(self, name, config): LineBuilder.__init__(self, name, config) self.__confdict__ = config ####################### BASIC FINAL STATE PARTICLE SELECTIONS ########################## self.PionCuts = "(PIDK < %(Pion_MAX_PIDK)s) & (MIPDV(PRIMARY) > %(Tag_MIN_IP)s*mm) & (PT > %(Tag_MIN_PT)s*MeV) & (TRGHOSTPROB < %(Tag_MAX_GHPROB)s)" % self.__confdict__ self.KaonCuts = "(PIDK > %(Kaon_MIN_PIDK)s) & (MIPDV(PRIMARY) > %(Tag_MIN_IP)s*mm) & (PT > %(Tag_MIN_PT)s*MeV) & (TRGHOSTPROB < %(Tag_MAX_GHPROB)s)" % self.__confdict__ self.SelLongPions = Selection("SelLongPionsFor" + name, Algorithm=FilterDesktop( name="LongPionFilterFor" + name, Code=self.PionCuts), RequiredSelections=[StdLoosePions]) self.SelLongKaons = Selection("SelLongKaonsFor" + name, Algorithm=FilterDesktop( name="LongKaonFilterFor" + name, Code=self.KaonCuts), RequiredSelections=[StdLooseKaons]) ###### the velo tracking self.VeloProtoOutputLocation = 'Rec/ProtoP/VeloProtosFor%s' % self.name( ) self.VeloTrackOutputLocation = "Rec/Track/MyVeloFor%s" % self.name() self.FittedVeloTrackOutputLocation = "Rec/Track/PreparedVeloFor%s" % self.name( ) self.VeloTracks = self.MakeVeloTracks([]) self.VeloPions = self.MakeVeloParticles("VeloPions", "pion", self.VeloTracks) self.VeloKaons = self.MakeVeloParticles("VeloKaons", "kaon", self.VeloTracks) ##################### MAKE THE LINES ############# self.MissingPion2BodyLine = self.MakeLine( name + "MissingPion2Body", ['[D0 -> K- pi+]cc', '[D~0 -> K+ pi+]cc'], ["[D*(2010)+ -> D0 pi+]cc"], [self.SelLongKaons, self.VeloPions]) self.MissingKaon2BodyLine = self.MakeLine( name + "MissingKaon2Body", ['[D0 -> K+ pi+]cc', '[D~0 -> K+ pi-]cc'], ["[D*(2010)+ -> D0 pi+]cc"], [self.SelLongPions, self.VeloKaons]) if config["VeloLineForTiming"] == True: self.registerLine( StrippingLine(name + 'SelLongKaonsLine', selection=self.SelLongKaons)) self.registerLine( StrippingLine(name + 'SelLongPionsLine', selection=self.SelLongPions)) self.registerLine( StrippingLine(name + 'VeloPionLine', selection=self.VeloPions)) self.registerLine( StrippingLine(name + 'VeloKaonLine', selection=self.VeloKaons)) self.registerLine(self.MissingPion2BodyLine) self.registerLine(self.MissingKaon2BodyLine)
def build_mc_unbiased_selection(decayDesc, arrow = '==>', refitpvs = True) : '''Make a selection for the given decay descriptor that has no cuts besides truth matching.''' preamble = [ "from LoKiPhysMC.decorators import *" , "from LoKiPhysMC.functions import mcMatch" ] decayDesc = decayDesc.copy() decayDesc.clear_aliases() decayDesc.set_carets(False) decayDescCC = decayDesc.copy() decayDescCC.cc = True algname = decayDesc.get_full_alias() + '_MCSel' algnameconj = decayDesc.conjugate().get_full_alias() + '_MCSel' if algname in selections : return selections[algname] elif algnameconj in selections : return selections[algnameconj] if not decayDesc.daughters : alg = FilterDesktop(algname + '_Filter') basicname = decayDesc.particle.name if not basicname in mcbasicinputs : basicname = decayDesc.conjugate().particle.name if basicname in mcbasicinputs : inputsels = [RebuildSelection(getattr(StandardParticles, basicinput)) for basicinput in mcbasicinputs[basicname]] else : raise ValueError("Can't find MC basic input for particle " + repr(decayDesc.particle.name)) alg.Code = 'mcMatch({0!r})'.format(decayDescCC.to_string(arrow)) alg.Preambulo = preamble sel = Selection(algname, Algorithm = alg, RequiredSelections = inputsels) selections[algname] = sel return sel inputs = set() daughtercuts = {} for daughter in decayDescCC.daughters : originaldaughtercc = daughter.cc daughter.cc = True sel = build_mc_unbiased_selection(daughter, arrow, refitpvs) daughter.cc = originaldaughtercc inputs.add(sel) #daughter.caret = True #daughtercuts[daughter.particle.name] = 'mcMatch({0!r})'.format(decayDescCC.to_string(arrow)) #daughter.caret = False #comb = nCombiners[len(decayDesc.daughters)](algname + '_Comb') comb = CombineParticles(algname + '_Comb') # CombineParticles uses small cc, so set ishead = False comb.DecayDescriptors = [decayDesc.to_string(depth = 1).replace('CC', 'cc')] comb.MotherCut = 'mcMatch({0!r})'.format(decayDescCC.to_string(arrow)) comb.Preambulo = preamble comb.DaughtersCuts = daughtercuts comb.ReFitPVs = refitpvs if refitpvs: comb.MotherCut += ' & BPVVALID()' sel = Selection(algname, Algorithm = comb, RequiredSelections = list(inputs)) selections[algname] = sel return sel
def get_selection_sequence(name): """Get the selection from stripping stream""" # Relative lesLoc for uDST, no preceeding '/' tesLoc = 'Phys/B2DPiPiD2HHHCFPIDBeauty2CharmLine/Particles' alg = FilterDesktop('SelFilterFor{}B2D'.format(name)) alg.Code = 'ALL' reqSels = [DataOnDemand(Location=tesLoc)] sel = Selection('Sel' + name, Algorithm=alg, RequiredSelections=reqSels) return SelectionSequence('SelSeq' + name, TopSelection=sel)
def inputSeq(self, outputLevel=INFO): if not allConfigurables.get("AlignInputSeq"): if outputLevel == VERBOSE: print "VERBOSE: Filter Sequencer not defined! Defining!" inputSequencer = GaudiSequencer("AlignInputSeq") inputSequencer.MeasureTime = True trackselections = self.getProp("TrackSelections") if len(trackselections) > 0: trackInputSeq = GaudiSequencer("AlignTrackSelSeq", IgnoreFilterPassed=True) inputSequencer.Members.append(trackInputSeq) # add the algorithms for the track selections to the sequence. # also merge the tracks lists into one list from Configurables import TrackListMerger trackmerger = TrackListMerger( "AlignTracks", outputLocation="Rec/Track/AlignTracks") self.setProp("TrackLocation", trackmerger.outputLocation) for i in trackselections: alg = i.algorithm() if alg: trackInputSeq.Members.append(alg) trackmerger.inputLocations.append(i.location()) trackInputSeq.Members.append(trackmerger) # add all particle selections if len(self.getProp("ParticleSelections")) > 0: particleInputSeq = GaudiSequencer("AlignParticleSelSeq", IgnoreFilterPassed=True) inputSequencer.Members.append(particleInputSeq) from Configurables import FilterDesktop particlemerger = FilterDesktop("AlignParticles", Code="ALL") particlemerger.Code = "ALL" particlemerger.CloneFilteredParticles = False for i in self.getProp("ParticleSelections"): alg = i.algorithm() if alg: particleInputSeq.Members.append(alg) print "adding particleinputsel to sequence: ", i.name( ), i.algorithm(), i.location() particlemerger.Inputs.append(i.location()) particleInputSeq.Members.append(particlemerger) self.setProp("ParticleLocation", '/Event/Phys/AlignParticles/Particles') # add the PV selection if hasattr(self, "PVSelection"): inputSequencer.Members.append( self.getProp("PVSelection").algorithm()) self.setProp("VertexLocation", self.getProp("PVSelection").location()) return inputSequencer else: if outputLevel == VERBOSE: print "VERBOSE: AlignInputSeq already defined!" return allConfigurables.get("AlignInputSeq")
def VMaker(_name, _RequiredSelections, _DecayDescriptor, _Filter, conf, _prescale): _CombiCut = "" if 'KS0' in _DecayDescriptor: _CombiCut = "( (ACHILDCUT(CHILDCUT(ISLONG,1),1)) | (ACHILDCUT(CHILDCUT(ISLONG,1),2)) ) & " if 'phi(1020)' in _DecayDescriptor: _CombiCut += " (APT > %(Phi_PT_MIN)s *MeV) & (AM < %(Phi_MASS_MAX)s + 30*MeV) & (ACUTDOCACHI2(%(Phi_DOCACHI2_MAX)s,''))" % conf _MotherCut = "(M < %(Phi_MASS_MAX)s +20*MeV) & (VFASPF(VCHI2/VDOF) < %(Phi_VCHI2NDOF_MAX)s) & (MIPCHI2DV(PRIMARY) < %(Phi_IPCHI2_MAX)s)" % conf _MassFilter = FilterDesktop(name="MassFilter_" + _name, Code="(M < %(Phi_MASS_MAX)s *MeV)" % conf) elif 'J/psi(1S)' in _DecayDescriptor: _CombiCut += " (ADAMASS('J/psi(1S)') < %(JPsi_MASS_WIN)s +30*MeV) & (APT > %(JPsi_PT_MIN)s*MeV)"\ "& (ACUTDOCACHI2(%(JPsi_DOCACHI2_MAX)s,''))" %conf _MotherCut = "(DMASS('J/psi(1S)') < %(JPsi_MASS_WIN)s +20*MeV)"\ "& (VFASPF(VCHI2/VDOF) < %(JPsi_VCHI2NDOF_MAX)s) & (MIPCHI2DV(PRIMARY) < %(JPsi_IPCHI2_MAX)s)" %conf _MassFilter = FilterDesktop( name="MassFilter_" + _name, Code="(DMASS('J/psi(1S)') < %(JPsi_MASS_WIN)s *MeV)" % conf) Comb = CombineParticles(name="Comb_" + _name, DecayDescriptor=_DecayDescriptor, CombinationCut=_CombiCut, MotherCut=_MotherCut) Sel = Selection(name="Sel_" + _name, Algorithm=Comb, RequiredSelections=_RequiredSelections) if conf['DoDTF'] == True: _MassConstraints = [] if 'KS0' in _DecayDescriptor: _MassConstraints = ['KS0'] FITTER = FitDecayTrees(name="FITTER_" + _name, Code="DECTREE('" + _DecayDescriptor + "')", MaxChi2PerDoF=10, MassConstraints=_MassConstraints, UsePVConstraint=True) FITTER_SEL = Selection("FITTER_SEL_" + _name, Algorithm=FITTER, RequiredSelections=[Sel]) MASS_FILTER = Selection("MASS_FILTER_" + _name, Algorithm=_MassFilter, RequiredSelections=[FITTER_SEL]) else: MASS_FILTER = Selection("MASS_FILTER_" + _name, Algorithm=_MassFilter, RequiredSelections=[Sel]) Line = StrippingLine(_name + 'Line', prescale=_prescale, FILTER=_Filter, selection=MASS_FILTER) return Line
def build_mc_unbiased_selection(decayDesc, arrow = '==>') : preamble = [ "from LoKiPhysMC.decorators import *" , "from LoKiPhysMC.functions import mcMatch" ] decayDesc.set_carets(False) decayDescCC = decayDesc.copy() decayDescCC.cc = True algname = decayDesc.get_full_alias() + '_MCSel' algnameconj = decayDesc.conjugate().get_full_alias() + '_MCSel' if algname in selections : return selections[algname] elif algnameconj in selections : return selections[algnameconj] if not decayDesc.daughters : alg = FilterDesktop(algname + '_Filter') if decayDesc.particle.name in mcbasicinputs : inputsel = mcbasicinputs[decayDesc.particle.name] else : conj = decayDesc.conjugate() if conj.particle.name in mcbasicinputs : inputsel = mcbasicinputs[conj.particle.name] else : raise ValueError("Can't find MC basic input for particle " + repr(decayDesc.particle.name)) alg.Code = 'mcMatch({0!r})'.format(decayDescCC.to_string(arrow)) alg.Preambulo = preamble sel = Selection(algname, Algorithm = alg, RequiredSelections = [inputsel]) selections[algname] = sel return sel inputs = set() daughtercuts = {} for daughter in decayDescCC.daughters : originaldaughtercc = daughter.cc daughter.cc = True sel = build_mc_unbiased_selection(daughter, arrow) daughter.cc = originaldaughtercc inputs.add(sel) #daughter.caret = True #daughtercuts[daughter.particle.name] = 'mcMatch({0!r})'.format(decayDescCC.to_string(arrow)) #daughter.caret = False #comb = nCombiners[len(decayDesc.daughters)](algname + '_Comb') comb = CombineParticles(algname + '_Comb') # CombineParticles uses small cc, so set ishead = False comb.DecayDescriptors = [decayDesc.to_string(depth = 1).replace('CC', 'cc')] comb.MotherCut = 'mcMatch({0!r})'.format(decayDescCC.to_string(arrow)) comb.Preambulo = preamble comb.DaughtersCuts = daughtercuts sel = Selection(algname, Algorithm = comb, RequiredSelections = list(inputs)) selections[algname] = sel return sel
def filterJpsi (localname, _InputLocation=_my_immutable_config['JpsiForExclusiveLinesLocation'], config=default_config): _filterAlgorithm = FilterDesktop(localname+"JpsiMuonFilter"); _myCutOnMuons = ("(PIDmu > %(Muon4Jpsi_PIDmu)s) &"+ " (TRPCHI2 > %(Muon4Jpsi_TRPCHI2)s) &"+ " (PT > %(Muon4Jpsi_PT)s) ")%config _filterAlgorithm.Code = ("(CHILDCUT(("+_myCutOnMuons+"),1) & CHILDCUT(("+_myCutOnMuons+"),2)) &"+ " (VFASPF(VCHI2/VDOF)<%(Jpsi_ENDVERTEXCHI2)s) &"+ " (ADMASS('J/psi(1S)') < %(Jpsi_MassWindowTight)s)") % config return Selection (name = localname + 'JpsiMuonFilterSelection', Algorithm = _filterAlgorithm, RequiredSelections = [ AutomaticData(_InputLocation) ])
def build_mc_unbiased_selection(decayDesc, arrow = '==>') : preamble = [ "from LoKiPhysMC.decorators import *" , "from LoKiPhysMC.functions import mcMatch" ] decayDesc.set_carets(False) decayDescCC = decayDesc.copy() decayDescCC.cc = True algname = decayDesc.get_full_alias() + '_MCSel' if algname in selections : return selections[algname] if not decayDesc.daughters : alg = FilterDesktop(algname + '_Filter') if decayDesc.particle.name in mcbasicinputs : inputsel = mcbasicinputs[decayDesc.particle.name] else : conj = decayDesc.conjugate() if conj.particle.name in mcbasicinputs : inputsel = mcbasicinputs[conj.particle.name] else : raise ValueError("Can't find MC basic input for particle " + repr(decayDesc.particle.name)) alg.Code = 'mcMatch({0!r})'.format(decayDescCC.to_string(arrow)) alg.Preambulo = preamble sel = Selection(algname, Algorithm = alg, RequiredSelections = [inputsel]) selections[algname] = sel return sel inputs = [] daughtercuts = {} for daughter in decayDescCC.daughters : originaldaughtercc = daughter.cc daughter.cc = True sel = build_mc_unbiased_selection(daughter, arrow) daughter.cc = originaldaughtercc inputs.append(sel) #daughter.caret = True #daughtercuts[daughter.particle.name] = 'mcMatch({0!r})'.format(decayDescCC.to_string(arrow)) #daughter.caret = False #comb = nCombiners[len(decayDesc.daughters)](algname + '_Comb') comb = CombineParticles(algname + '_Comb') # CombineParticles uses small cc, so set ishead = False comb.DecayDescriptors = [decayDesc.to_string(depth = 1, ishead = False)] comb.MotherCut = 'mcMatch({0!r})'.format(decayDescCC.to_string(arrow)) comb.Preambulo = preamble comb.DaughtersCuts = daughtercuts sel = Selection(algname, Algorithm = comb, RequiredSelections = inputs) selections[algname] = sel return sel
def makePhi2KK(name, KaonPT, KaonIPCHI2, KaonPIDK, PhiMassWin, PhiPT, PhiVCHI2): """ Create and return a Phi -> KK Selection object. Starts from DataOnDemand 'Phys/StdLoosePhi2KK'. Arguments: name : name of the Selection. KaonPT : Minimum transverse momentum of K (MeV). KaonIPCHI2 : Minimum impact parameter chi2 of K. KaonPIDK : Minimum PID_{K-pi} of K. PhiPT : Minimum transverse momentum of Phi (MeV). PhiMassWin : Phi invariant mass window around PDG mass value (MeV). PhiVCHI2 : Maximum Phi vertex chi2 (per degree of freedom?) """ _params = locals() _code = " (MINTREE('K+'==ABSID,PIDK)> %(KaonPIDK)s)" \ "& (MINTREE(ABSID=='K+',PT)> %(KaonPT)s *MeV)" \ "& (MIPCHI2DV(PRIMARY)> %(KaonIPCHI2)s)" \ "& (ADMASS('phi(1020)') < %(PhiMassWin)s *MeV)" \ "& (PT > %(PhiPT)s *MeV)" \ "& (VFASPF(VCHI2/VDOF) < %(PhiVCHI2)s)" % _params print 'makeJpsiPhi2KK Code =', _code StdLoosePhi2KK = DataOnDemand(Location="Phys/StdLoosePhi2KK/Particles") _phiFilter = FilterDesktop("PhiFilterForBs2JpsiPhi", Code=_code) return Selection(name, Algorithm=_phiFilter, RequiredSelections=[StdLoosePhi2KK])
def makeDCandidate(self, name, PDGName, ContainerName, TrackPT, TrackP, TrackIPCHI2, TrackGHP, KaonProbNNk, PionProbNNpi, DMassWin, DPT, DIPCHI2, DVCHI2): """ Create and return a D candidate Selection object. Starts from DataOnDemand 'Phys/StdLooseD02KPi'. Arguments: name : name of the Selection. TrackPT : Minimum transverse momentum of K,pi (MeV). TrackIPCHI2 : Minimum impact parameter chi2 of K,pi. TrackGHP : Maximum ghost probability of K,pi. KaonProbNNk : Minimum ProbNNK of K. PionProbNNpi : Minimum ProbNNpi of pi. DPT : Minimum transverse momentum of D (MeV). DIPCHI2 : Minimum IP chi2 of D. DMassWin : D invariant mass window around PDG mass value (MeV). DVCHI2 : Maximum D vertex chi2 (per degree of freedom?) """ _params = locals() _code = " (INTREE(('K+'==ABSID) & (PROBNNk > %(KaonProbNNk)s) & (PT>%(TrackPT)s *MeV) & (MIPCHI2DV(PRIMARY)> %(TrackIPCHI2)s) & (TRGHP < %(TrackGHP)s)))" \ "& (INTREE(('pi+'==ABSID) & (PROBNNpi > %(PionProbNNpi)s) & (PT>%(TrackPT)s *MeV) & (MIPCHI2DV(PRIMARY)> %(TrackIPCHI2)s) & (TRGHP < %(TrackGHP)s)))" \ "& (ADMASS('%(PDGName)s') < %(DMassWin)s *MeV)" \ "& (PT > %(DPT)s *MeV)" \ "& (MIPCHI2DV(PRIMARY) > %(DIPCHI2)s)" \ "& (VFASPF(VCHI2/VDOF) < %(DVCHI2)s)" % _params DCandidatesList = DataOnDemand(Location="Phys/" + ContainerName + "/Particles") _dFilter = FilterDesktop(name + "FilterForBs2DDPhi", Code=_code) return Selection(name, Algorithm=_dFilter, RequiredSelections=[DCandidatesList])
def makeKaons(self, name, KaonPT, KaonP, KaonIPCHI2, KaonGPMax, KaonProbNNk): """ Create and return a refined list of Kaons Starts from DataOnDemand 'Phys/StdLooseKaons'. Arguments: name : name of the Selection. KaonPT : Minimum transverse momentum of K (MeV). KaonIPCHI2 : Minimum impact parameter chi2 of K. KaonProbNNk : Minimum ProbNNk of K. """ _params = locals() _code = " ( PROBNNk > %(KaonProbNNk)s)" \ "& ( PT > %(KaonPT)s *MeV)" \ "& ( P > %(KaonP)s *MeV)" \ "& ( TRGHP < %(KaonGPMax)s)"\ "& ( MIPCHI2DV(PRIMARY) > %(KaonIPCHI2)s)" % _params StdLooseKaons = DataOnDemand( Location="Phys/StdAllLooseANNKaons/Particles") _kFilter = FilterDesktop("KFilterForBs2DDPhi", Code=_code) return Selection(name, Algorithm=_kFilter, RequiredSelections=[StdLooseKaons])
def MakeVeloParticles(self, name, particle, protoParticlesMaker): particleMaker = NoPIDsParticleMaker("For%sParticleMaker%s" % (self.name, name), Particle=particle) particleMaker.Input = self.VeloProtoOutputLocation DataOnDemandSvc().AlgMap.update({ "/Event/Phys/" + particleMaker.name() + '/Particles': particleMaker.getFullName(), "/Event/Phys/" + particleMaker.name() + '/Vertices': particleMaker.getFullName() }) AllVeloParticles = Selection("For%sSelAllVeloParts%s" % (self.name, name), Algorithm=particleMaker, RequiredSelections=[protoParticlesMaker], InputDataSetter=None) ### filter on the IP of the velo tracks return Selection( "For%sSelVeloParts%s" % (self.name, name), Algorithm=FilterDesktop( name + "For%sFilterVeloTrackIP%s" % (self.name, name), Code="(MIPDV(PRIMARY) > %(VeloMINIP)s)" % self.__confdict__), RequiredSelections=[AllVeloParticles])
def makeFilter(_name, _input, _preambulo, _code): _filter = FilterDesktop(_name, Preambulo=_preambulo, Code=_code) return Selection("sel" + _name, Algorithm=_filter, RequiredSelections=[_input])
def configuredParticleListFromDST(ParticleLocation, FilterCode=""): from Configurables import GaudiSequencer from Configurables import TrackParticleRefitter, TrackMasterFitter from TrackFitter.ConfiguredFitters import ConfiguredMasterFitter # create a sequence to refit and monitor name = ParticleLocation name = name.replace("/Event", "") name = name.replace("/Phys", "") name = name.replace("/Particles", "") name = name.replace("/", "") fitter = TrackParticleRefitter(name + "Refitter", TrackFitter=TrackMasterFitter(), ParticleLocation=ParticleLocation) ConfiguredMasterFitter(fitter.TrackFitter, SimplifiedGeometry=True) seq = GaudiSequencer(name + "Seq", IgnoreFilterPassed=True) seq.Members.append(fitter) if FilterCode != "": from Configurables import FilterDesktop newLocation = ParticleLocation.replace("/Particles", "") + "Filtered" newfilter = FilterDesktop( #name + "Filter",#Output = newLocation, Inputs=[ParticleLocation], CloneFilteredParticles=False, Code=FilterCode) seq.Members.append(newfilter) ParticleLocation = newLocation + "/Particles" sel = ParticleSelection(Name=name, Location=ParticleLocation, Algorithm=seq) return sel
def makeSelection(_name, _filters): _Algorithm = FilterDesktop(_name, Code='ALL') return Selection("sel" + _name, Algorithm=_Algorithm, RequiredSelections=_filters)
def filterDiMu( self, name, MuonPT, MuonP, MuonTRCHI2DOF, MuonPID, MuMuMinMass, MuMuMaxMass, MuMuVCHI2PDOF, MuMuPT ): _StdLooseDiMuon = DataOnDemand( Location = 'Phys/StdLooseDiMuon/Particles' ) MuonCut = "(MINTREE('mu+'==ABSID,PT) > %(MuonPT)s ) & (MAXTREE('mu+'==ABSID,TRCHI2DOF) < %(MuonTRCHI2DOF)s) & (MINTREE('mu+'==ABSID,PIDmu)> %(MuonPID)s)" % locals() MuonCut += "& (MINTREE('mu+'==ABSID,P) > %(MuonP)s )" % locals() # MuonCut = " (MAXTREE('mu+'==ABSID,TRCHI2DOF) < %(MuonTRCHI2DOF)s) & (MINTREE('mu+'==ABSID,PIDmu)> %(MuonPID)s )" % locals() MuMuCut = "(MM > %(MuMuMinMass)s *GeV) & (MM < %(MuMuMaxMass)s *GeV) & (VFASPF(VCHI2PDOF)< %(MuMuVCHI2PDOF)s) & (PT > %(MuMuPT)s *GeV)" % locals() _MuMu = FilterDesktop( name+"FilterChiCMuMu", Code = MuonCut + " & " + MuMuCut ) return Selection( name + "_SelMuMu", Algorithm = _MuMu, RequiredSelections = [ _StdLooseDiMuon ] )
def __apply_configuration__(self): from Configurables import (CombinedParticleMaker, ProtoParticleMUONFilter, ProtoParticleCALOFilter, FilterDesktop) mName = "TaggingMuons" eName = "TaggingElectrons" pName = "TaggingPions" tagName = 'TaggingParticles' hat = 'Phys/' leaf = '/Particles' mLoc, eLoc, pLoc, tagLoc = [ hat + name + leaf for name in mName, eName, pName, tagName ] taggerMuons = CombinedParticleMaker(mName) taggerMuons.Particle = 'Muon' taggerMuons.addTool(ProtoParticleMUONFilter, name="Muon") taggerMuons.Muon.Selection = [ "RequiresDet='MUON' CombDLL(mu-pi)>'0.0'" ] taggerElectrons = CombinedParticleMaker(eName) taggerElectrons.Particle = 'Electron' taggerElectrons.addTool(ProtoParticleCALOFilter, name="Electron") taggerElectrons.Electron.Selection = [ "RequiresDet='CALO' CombDLL(e-pi)>'4.0'" ] taggerPions = CombinedParticleMaker(pName) taggerPions.Particle = 'Pion' taggingParticles = FilterDesktop(tagName) taggingParticles.Inputs = [eLoc, mLoc, pLoc] taggingParticles.Code = "(P>2.0*GeV)" dod = DataOnDemandSvc() dod.AlgMap.update({mLoc: taggerMuons}) dod.AlgMap.update({eLoc: taggerElectrons}) dod.AlgMap.update({pLoc: taggerPions}) dod.AlgMap.update({tagLoc: taggingParticles}) # configure charm candidate lists import FlavourTagging.CharmTaggerLists
def muonTracksFORmuonAlignment(): # this still needs to be worked out from Configurables import Escher Escher().RecoSequence = [ "Hlt", "Decoding", "AlignTr", "Vertex", "RICH", "CALO", "MUON", "PROTO" ] # ???? Escher().MoniSequence = ["Tr", "OT"] # if the Escher hlt filter is not set, set it here if not hasattr(Escher(), "HltFilterCode") or not Escher().HltFilterCode: Escher( ).HltFilterCode = "HLT_PASS_RE( 'Hlt1DiMuonHighMass*Decision' )" # Hlt2-->Hlt1 requirement # revive only particles used for trigger print 'Hlt lines to be used: ' print ReviveHltTracks(['Hlt1DiMuonHighMassDecision']) # Now create the J/psi candidates from Configurables import CombineParticles, FilterDesktop from CommonParticles.StdAllLooseMuons import StdAllLooseMuons # requires IsMuon==1 from CommonParticles.StdLooseJpsi2MuMu import StdLooseJpsi2MuMu # requires (ADAMASS('J/psi')<100.*MeV)&(ADOCACHI2CUT(30,'')) && "(VFASPF(VCHI2) < 25.)" StdLooseJpsi2MuMu.DaughtersCuts = {"mu-": "( P> 6000*MeV)"} # momentum cut ## tighten the mass window for candidates used in alignment AlignJpsi2MuMu = FilterDesktop( "AlignJpsi2MuMu", Inputs=["Phys/StdLooseJpsi2MuMu"], Code="(ADMASS('J/psi(1S)') < 35.*MeV) & (VFASPF(VCHI2) < 10.)" ) # tighter requirements from Configurables import ChargedProtoParticleMaker, ChargedProtoParticleAddMuonInfo #####, ChargedProtoCombineDLLsAlg from Configurables import TrackParticleMonitor, GaudiSequencer recoJpsiSeq = GaudiSequencer("RecoJpsiSeq") recoJpsiSeq.Members = [ ChargedProtoParticleMaker('ChargedProtoPMaker'), ChargedProtoParticleAddMuonInfo('ChargedProtoPAddMuon'), ###ChargedProtoCombineDLLsAlg('ChargedProtoPCombDLLs'), StdAllLooseMuons, StdLooseJpsi2MuMu, TrackParticleMonitor( 'StdLooseJpsi2MuMuMonitor', InputLocation='/Event/Phys/StdLooseJpsi2MuMu/Particles', MinMass=3000, MaxMass=3190), AlignJpsi2MuMu, TrackParticleMonitor( 'AlignJpsi2MuMuMonitor', InputLocation='/Event/Phys/AlignJpsi2MuMu/Particles', MinMass=3000, MaxMass=3190), ] sel = ParticleSelection(Name='MufromJpsiMuMu', Location='/Event/Phys/AlignJpsi2MuMu/Particles', Algorithm=recoJpsiSeq) return sel
def splitHHH(self, name, hhhSelection): """Split the input h-h+h+ Selection in to a D+ and D_s+ selection. Returns a two-tuple as (D+ Selection, D_s+ Selection). Keyword arguments: hhhSelection -- A single Selection instance; the output of makeD2HHH """ dpFilter = FilterDesktop( 'FilterDp{0}'.format(name), Code="(ADMASS('D+') < {0[Dp_ADAMASS_WIN]})".format(self.config) ) dsFilter = FilterDesktop( 'FilterDs{0}'.format(name), Code="(ADMASS('D_s+') < {0[Ds_ADAMASS_WIN]})".format(self.config) ) dpSel = Selection( 'SelFilteredDp{0}'.format(name), Algorithm=dpFilter, RequiredSelections=[hhhSelection] ) dsSel = Selection( 'SelFilteredDs{0}'.format(name), Algorithm=dsFilter, RequiredSelections=[hhhSelection] ) # The HHH selection is labelled as a D+, so rename the candidates in # the D_s+ selection as such dsSubPID = SubstitutePID( name='SubPidDs{0}'.format(name), Code="DECTREE('[D+ -> X- X+ X+]CC')", Substitutions={ 'D+ -> X- X+ X+': 'D_s+', 'D- -> X+ X- X-': 'D_s-' }, MaxChi2PerDoF=-1 ) dsSubPIDSel = Selection( 'SubPIDDsSel{0}'.format(name), Algorithm=dsSubPID, RequiredSelections=[dsSel] ) return dpSel, dsSubPIDSel
def Pi0ResolvedFilter( self, _name, _config): _code = ( " ( ADMASS('pi0') < %(Pi0MassWin)s )" \ "& ( PT> %(Pi0PtMin)s ) " \ "& ( P> %(Pi0PMin)s )" \ "& ( CHILD(CL,1)> %(PhotonCL)s) " \ "& ( CHILD(CL,2)> %(PhotonCL)s) " % _config ) _pil = FilterDesktop( name = _name, Code = _code ) return _pil
def test_filterDesktop_properties(): fd0 = FilterDesktop('fd0', Code='TestCode0', InputLocations=['a', 'b', 'c'], OutputLevel=2) assert (fd0.Code == 'TestCode0') assert (fd0.InputLocations == ['a', 'b', 'c']) assert (fd0.OutputLevel == 2)
def _KsDDFilter(self, _name): _code = " (P> %(KSDDPMin)s *MeV) & (PT> %(KSDDPTMin)s *MeV)" \ " & (ADMASS('KS0') < %(KSDDCutMass)s *MeV) & (BPVVDCHI2> %(KSDDCutFDChi2)s)" \ " & CHILDCUT((TRCHI2DOF < %(KSDaugTrackChi2)s),1)" \ " & CHILDCUT((TRCHI2DOF < %(KSDaugTrackChi2)s),2)" \ " & (VFASPF(VCHI2PDOF) < %(KSVertexChi2)s)" \ " & (BPVDIRA > %(KSCutDIRA)s)" % self.__confdict__ _pil = FilterDesktop(name=_name, Code=_code) return _pil
def makeW(self, _name): # Define the W->mu cuts _code = '(PT>%(min_mu_pT)s*GeV) & (PT<%(max_mu_pT)s*GeV)' % self._config _filter = FilterDesktop(_name, Code=_code) return Selection("sel" + _name, Algorithm=_filter, RequiredSelections=[StdAllLooseMuons])
def _Bs2JpsieePhiLine( self, dielectron, name, config ) : _jpsi = FilterDesktop("FilterJpsi2eeFor"+name, Code = " (MM > %(JpsiMassMin)s *MeV)" \ " & (MM < %(JpsiMassMax)s *MeV)" \ " & (MINTREE('e+'==ABSID,PIDe-PIDpi) > %(ElectronPID)s )" \ " & (MINTREE('e+'==ABSID,PT) > %(ElectronPT)s *MeV)" \ " & (MAXTREE('e+'==ABSID,TRCHI2DOF) < %(ElectronTrackCHI2pDOF)s)" \ " & (VFASPF(VCHI2/VDOF) < %(JpsiVertexCHI2pDOF)s)" % config ) Jpsi = Selection("SelJpsi2eeFor"+name, Algorithm = _jpsi, RequiredSelections = [dielectron]) _stdPhi = DataOnDemand(Location="Phys/StdLoosePhi2KK/Particles") _phi = FilterDesktop("FilterPhi2KKFor"+name, Code = " (PT > %(PhiPT)s *MeV)" \ " & (MINTREE('K+'==ABSID,PIDK-PIDpi) > %(KaonPID)s )" \ " & (MAXTREE('K+'==ABSID,TRCHI2DOF) < %(KaonTrackCHI2pDOF)s)" \ " & (VFASPF(VCHI2/VDOF) < %(PhiVertexCHI2pDOF)s)" \ " & (MM > %(PhiMassMin)s *MeV)" \ " & (MM < %(PhiMassMax)s *MeV)" % config ) Phi = Selection("SelPhi2KKFor"+name, Algorithm = _phi, RequiredSelections = [_stdPhi]) CC = "(AM > %(BsMassMin)s *MeV) & (AM < %(BsMassMax)s *MeV)" % config MC = "(VFASPF(VCHI2/VDOF) < %(BsVertexCHI2pDOF)s) & (BPVDIRA > %(BsDIRA)s)" % config _Bs = CombineParticles("CombineBsFor"+name, DecayDescriptor = "B_s0 -> J/psi(1S) phi(1020)", CombinationCut = CC , MotherCut = MC, ReFitPVs = False ) Bs = Selection(name, Algorithm = _Bs, RequiredSelections = [Jpsi, Phi]) return StrippingLine(name+"Line" , prescale = config['Prescale'] , postscale = 1 , selection = Bs , EnableFlavourTagging = True )#, MDSTFlag = True )
def example(): mn = 1864.84 mx = 1964.84 ce = ComboEngine([('pi+', 'pi-'), ('K+', 'pi-'), ('pi+', 'K-'), ('K+', 'K-')], ['pi+', 'pi-']) mass = ce.getWMFunctor(min, max) emptyFilter = FilterDesktop("Empty", Code="ALL") return ce.mergedSelection("Combo", mn, mx, Selection("EmptySel", Algorithm=emptyFilter)) return ce
def _MuonFilter(self): Muoncut = "(TRCHI2DOF < 5.0) & (PIDmu > 0.0) & (MIPCHI2DV(PRIMARY) > 4.0) & (PT > 300*MeV)" muonfilter = FilterDesktop("muonfilter", Code=Muoncut) SelectedMuon = Selection( "SelMuon", Algorithm=muonfilter, RequiredSelections=[ DataOnDemand(Location="Phys/StdLooseMuons/Particles") ]) return SelectedMuon
def _PionFilter(self): Pioncut = "(TRCHI2DOF < 5.0) & (PIDK < 6.0) & (MIPCHI2DV(PRIMARY) > 4.0) & (PT > 300*MeV)" pionfilter = FilterDesktop("pionfilter", Code=Pioncut) SelectedPion = Selection( "SelPion", Algorithm=pionfilter, RequiredSelections=[ DataOnDemand(Location="Phys/StdLoosePions/Particles") ]) return SelectedPion
def KSFilter(self, _name, minDz, maxDz, KSCutDIRA, KSCutMass, KSCutFDChi2 ) : _code = " (BPVVDZ > %(minDz)s ) " \ "&(BPVVDZ < %(maxDz)s ) " \ "&(BPVDIRA > %(KSCutDIRA)s ) " \ "&(ADMASS('KS0') < %(KSCutMass)s ) " \ "&(BPVVDCHI2> %(KSCutFDChi2)s )" % locals() _KsFilter = FilterDesktop(name = _name, Code = _code) return _KsFilter
"from LoKiPhysMC.decorators import *", "from LoKiPhysMC.functions import mcMatch" ], DecayDescriptor=lb_decay_template, Inputs=[ "Phys/StdAllNoPIDsMuons", "Phys/CombineCheatedLcpTophh" ], DaughtersCuts=lb_daughters_template, CombinationCut="AALL", MotherCut=lb_mother_template, ) # Lambda_c mass window of 75 MeV around the nominal PDG mass filter_template = FilterDesktop( "FilterOfflineLc2phh", Code="(MINTREE(ABSID=='Lambda_c+', ADMASS('Lambda_c+')) < 75*MeV)" ) mc_filter_template = FilterEventByMCDecay("FilterMCLc2phh") mc_filter_template.addTool(MCDecayFinder) mc_filter_template.MCDecayFinder.Decay = mc_decay_template mc_filter_template.MCDecayFinder.ResonanceThreshold = 5e-10 for line in lines: stripping = lines[line]["stripping"] tracks = lines[line]["tracks"] filter_name = "FilterOffline{0}".format(line) filter = filter_template.clone(filter_name) filter.Inputs = [inputs_template.format(stripping)]
# #----Select my line------------------------------------------------- # MyStream = StrippingStream("MyStream") # MyLines = [ 'StrippingFullDSTDiMuonJpsi2MuMuDetachedLine' ] # for stream in streams: # for line in stream.lines: # if line.name() in MyLines: # MyStream.appendLines( [ line ] ) # sc = StrippingConf( HDRLocation = "MyStrip", Streams = [ MyStream ] ) # #------------------------------------------------------------------------ #----Jpsi->mumu--------------------------------- J2MuMu = AutomaticData(Location = "Phys/FullDSTDiMuonJpsi2MuMuDetachedLine/Particles") _Jpsi2MuMu = FilterDesktop("_J2MuMu") _Jpsi2MuMu.Code = "(ADMASS('J/psi(1S)')<50*MeV)"\ "& (MINTREE(ABSID=='mu+',PT)>500*MeV)"\ "& (MINTREE(ABSID=='mu+',TRCHI2DOF)<4)" Jpsi2MuMu = Selection("FilterJ", Algorithm = _Jpsi2MuMu , RequiredSelections = [ J2MuMu ] ) #----Selection K*->K+ pi- Kstar2Kpi = DataOnDemand(Location = "Phys/StdLooseKstar2Kpi/Particles") _Kst2Kpi = FilterDesktop("_Kst2Kpi") _Kst2Kpi.Code = "(ADMASS('K*(892)0') < 100.*MeV)"\ # "& (VFASPF(VCHI2/VDOF) < 4)"\ # "& (MINTREE(ABSID=='K+',PT)>250*MeV)"\
# # if line.name() in MyLines: # MyStream.appendLines( [ line ] ) # sc = StrippingConf( HDRLocation = "MyStrip", Streams = [ MyStream ] ) # #------------------------------------------------------------------------ #----selection p+ and K- and Lambda0 ------------------------- # protons = DataOnDemand(Location = "Phys/StdNoPIDsProtons/Particles") # protons = DataOnDemand(Location = "Phys/StdLooseProtons/Particles") # pions = DataOnDemand(Location = "Phys/StdLoosePions/Particles") Lambda0LL = DataOnDemand(Location = "Phys/StdLooseLambdaLL/Particles") Lambda0DD = DataOnDemand(Location = "Phys/StdLooseLambdaDD/Particles") AllLambda0 = MergedSelection( "AllLambda0", RequiredSelections = [Lambda0LL, Lambda0DD]) #----Selection /\->p+ pi- _FilterL = FilterDesktop("_FilterL") _FilterL.Code = "(ADMASS('Lambda0') < 30.*MeV)"\ "& (VFASPF(VCHI2/VDOF) < 12.0)" FilterL = Selection( "FilterL", Algorithm = _FilterL , RequiredSelections = [ AllLambda0 ] ) # _L2ppi = CombineParticles( "_L2ppi", # DecayDescriptor = "[Lambda0 -> p+ pi-]cc", # CombinationCut = "(ADMASS('Lambda0') < 30.*MeV) & (VFASPF(VCHI2/VDOF) < 12.0)", # # CombinationCut = "AM < 2700. * MeV", # MotherCut = "(VFASPF(VCHI2/VDOF)<2500) & (BPVDIRA > 0.9)", # # MotherCut = "(VFASPF(VCHI2/VDOF)<25) & (BPVDIRA > 0.999) & (VFASPF(VCHI2PDOF) < 10)",# & (BPVVD > 1.5 *mm)", # # MotherCut = "(ADMASS('Lambda0') < 30.*MeV)"\ # # "& (VFASPF(VCHI2/VDOF) < 12.0)",
#----Jpsi->mumu--------------------------------- location = "/Event/Dimuon/Phys/FullDSTDiMuonJpsi2MuMuDetachedLine/Particles" Jpsi2MuMu = AutomaticData(Location = location) #----selection p+ and K- ------------------------- kaons = DataOnDemand(Location = "/Event/Phys/StdNoPIDsKaons/Particles") protons = DataOnDemand(Location = "/Event/Phys/StdNoPIDsProtons/Particles") Lambda0LL = DataOnDemand(Location = "/Event/Phys/StdLooseLambdaLL/Particles") Lambda0DD = DataOnDemand(Location = "/Event/Phys/StdLooseLambdaDD/Particles") #----Selection /\->p+ pi- AllLambda0 = MergedSelection( "AllLambda0", RequiredSelections = [Lambda0LL, Lambda0DD]) _FilterL = FilterDesktop("_FilterL") _FilterL.Code = "(ADMASS('Lambda0') < 30.*MeV)"\ "& (VFASPF(VCHI2/VDOF) < 12.0)"\ "& (ADWM( 'KS0' , WM( 'pi+' , 'pi-') ) > 20*MeV )" FilterL = Selection( "FilterL", Algorithm = _FilterL , RequiredSelections = [ AllLambda0 ] ) #----Selection /\b -> J/psi p+ K------------------- _Lb2JpsipK = CombineParticles( "_Lb2JpsipK", DecayDescriptor = "[Lambda_b0 -> J/psi(1S) Lambda0]cc", CombinationCut = "AM < 6000. * MeV", MotherCut = "(VFASPF(VCHI2/VDOF)<25) & (BPVDIRA > 0.999) & (VFASPF(VCHI2PDOF) < 10) & (BPVVD > 1.5 *mm)", # DaughtersCuts = { 'K-': DaughtCutK }, ReFitPVs = True )