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 MakeLine(self,name, D0DecayDescriptor, DstDecayDescriptors, D0Requirements): D0CombinationCut = "(AM > 0.1*GeV) & (AM < 3.0*GeV)" D0CombinationCut += " & (AMAXDOCA('') < 0.05 * mm)" D0CombinationCut += " & (ACHILD(MIPDV(PRIMARY),1)+ACHILD(MIPDV(PRIMARY),2) > 0.2*mm)" D0MotherCut = "(VFASPF(VZ) > 2*mm) & (VFASPF(VCHI2/VDOF) < 4.0)" SlowpionCuts = "(MIPCHI2DV(PRIMARY) < 9)" DstMotherCut = "(PT > 1*MeV)" CombD0 = CombineParticles(name="CombD0for"+name, DecayDescriptors = D0DecayDescriptor, CombinationCut = D0CombinationCut, MotherCut = D0MotherCut) SelD0 = Selection('SelD0for'+name, Algorithm = CombD0, RequiredSelections = D0Requirements) CombDstar = CombineParticles(name = "CombDstarFor"+name, DecayDescriptors = DstDecayDescriptors, DaughtersCuts = {"pi+": SlowpionCuts}, CombinationCut = "(AALLSAMEBPV)", MotherCut = DstMotherCut) SelDstar = Selection("SelDstarfor"+name, Algorithm = CombDstar, RequiredSelections = [SelD0,StdAllLoosePions]) SelDstarTOS = TOSFilter("TOSDstarfor"+name, SelDstar, self.__confdict__["TTSpecs"]) MassFilter =FilterDesktop(name="MassFilter"+name, Code="(DTF_CHI2NDOF(True,'D0') < %(Dst_DTFCHI2_MAX)s) & (DTF_FUN( M ,True,'D0') < %(Dst_M_MAX)s)" %self.__confdict__) MassFilterSel = Selection("MassFilterSel"+name, Algorithm = MassFilter, RequiredSelections = [SelDstarTOS]) if self.__confdict__["Monitor"]: MassFilter.Preambulo = [ "Histo = Gaudi.Histo1DDef" , "mass = monitor ( DTF_FUN( M ,True,'D0') , Histo ( 'Title' , 2000. , 2100. , 100 ) , 'HistoNameInMemory' ) " ] MassFilter.Monitor = True , MassFilter.HistoProduce = True , MassFilter.PostMonitor = """ process ( mass ) >> EMPTY """ LineDstar = StrippingLine(name, HLT1 = self.__confdict__["HLT1"], HLT2 = self.__confdict__["HLT2"], selection = MassFilterSel) return LineDstar
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 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
## configure Data-On-Demand service locations = updateDoD ( algorithm ) ## finally: define the symbol SmrdLoosePions = algorithm #Truth matching matchpion = "(mcMatch('[^pi-]CC'))" #matchpion = "ALL" ####################################### # pions _pions = DataOnDemand(Location='Phys/StdLoosePions') _filter = FilterDesktop("filterPions", Code = matchpion) _filter.Preambulo = [ "from LoKiPhysMC.decorators import *" , "from PartProp.Nodes import CC" ] _selPions = Selection("SelFilterPions", Algorithm = _filter, RequiredSelections = [_pions]) _seqPions = SelectionSequence("SeqFilterPions", TopSelection = _selPions) ####################################### # pions _pions2 = DataOnDemand(Location='Phys/SmrdLoosePions') _filter2 = FilterDesktop("filterPions", Code = matchpion) _filter2.Preambulo = [ "from LoKiPhysMC.decorators import *" , "from PartProp.Nodes import CC" ] _selPions2 = Selection("SelFilterPions2",