def add_mc_unbiased_sequence(self, decayDesc, arrow = '==>', toolList = ["TupleToolPropertime", "TupleToolKinematic", "TupleToolGeometry", "TupleToolEventInfo", "TupleToolPrimaries", "TupleToolPid", "TupleToolANNPID", "TupleToolTrackInfo", "TupleToolRecoStats",], mcToolList = ['TupleToolMCTruth', 'TupleToolMCBackgroundInfo', 'MCTupleToolPrompt'], L0List = [], HLT1List = [], HLT2List = [], strippingList = []) : decayDescCC = decayDesc.copy() decayDescCC.cc = True sel = build_mc_unbiased_selection(decayDesc, arrow) selseq = SelectionSequence(decayDesc.get_full_alias() + '_MCSeq', TopSelection = sel) seq = selseq.sequence() seq.Members.insert(0, CheckPV()) dtt = DecayTreeTuple(decayDesc.get_full_alias() + '_MCTuple', Decay = decayDesc.to_string(carets = True), Inputs = [sel.outputLocation()], ToolList = []) dtt.addBranches(decayDesc.branches()) headBranch = getattr(dtt, decayDesc.get_alias()) dtt.configure_tools(toolList = toolList, mcToolList = mcToolList, L0List = L0List, HLT1List = HLT1List, HLT2List = HLT2List, strippingList = strippingList, headBranch = headBranch) lokituple = headBranch.addTupleTool('LoKi::Hybrid::TupleTool') lokituple.Preambulo = ['from LoKiPhysMC.decorators import *', 'from LoKiPhysMC.functions import mcMatch'] mcmatch = 'switch(mcMatch({0!r}), 1, 0)'.format(decayDescCC.to_string(carets = False, arrow = '==>')) lokituple.Variables = {'mcMatch' : mcmatch} seq.Members.append(dtt) self.UserAlgorithms.append(seq) mcdtt = MCDecayTreeTuple(decayDesc.get_full_alias() + '_MCDecayTreeTuple') mcdtt.addBranches(decayDesc.branches()) mcdtt.Decay = decayDescCC.to_string(arrow = arrow, carets = True) mcdtt.ToolList += filter(lambda t : t.startswith('MC'), mcToolList) self.UserAlgorithms.append(mcdtt) return seq
def mc_decay_tree_tuple(name, decay, mothers, daughters): """Return a configured MCDecayTreeTuple instance. A MCDecayTreeTuple is configured with the given decay descriptor. The mothers dictionary is used to give exclusive tools to vertices, and it should be, as daughters, a dictionary of tuple branch names to branch descriptors. A typical method call might look like mc_decay_tree_tuple( 'MCTupleDstToD0pi_D0ToKpi', '[D*(2010) => ^(D0 => ^K- ^pi+) ^pi+]CC', { 'Dst': '[D*(2010) => (D0 => K- pi+) pi+]CC', 'D0': '[D*(2010) => ^(D0 => K- pi+) pi+]CC' }, { 'D0_K': '[D*(2010) => (D0 => ^K- pi+) pi+]CC', 'D0_pi': '[D*(2010) => (D0 => K- ^pi+) pi+]CC', 'Dst_pi': '[D*(2010) => (D0 => K- pi+) ^pi+]CC' } ) Keyword arguments: name -- TDirectory the DecayTreeTuple TTree will be saved in decay -- Decay descriptor mothers -- Branch descriptors to be added to the tuple as mothers; decaying particles daughters -- Branch descriptors to be added to the tuple as daughters; final state particles """ t = MCDecayTreeTuple(name) t.Decay = decay t.addBranches(dict(mothers.items() + daughters.items())) t.ToolList = [ 'MCTupleToolPID', 'MCTupleToolKinematic', 'MCTupleToolReconstructed', 'MCTupleToolHierarchy', 'TupleToolPrimaries' ] # Verbose reconstruction information t.addTupleTool('TupleToolRecoStats').Verbose = True # Add MCTupleToolPrompt to all mothers for mother in mothers: branch = getattr(t, mother) # Does the particle ancestry contain a particle with a lifetime # above 1e-7 ns? Record the secondaries info if so branch.addTupleTool('MCTupleToolPrompt') return t
# We want to save all of the generated events for each mode. ######################################################################################################### from Configurables import MCDecayTreeTuple, MCTupleToolKinematic, MCTupleToolHierarchy, LoKi__Hybrid__MCTupleTool # LoKi variables LoKi_Photos = LoKi__Hybrid__MCTupleTool("LoKi_Photos") LoKi_Photos.Variables = { "nPhotons": "MCNINTREE ( ('gamma'==MCABSID) )", "MC_PT": "MCPT", "MC_THETA": "MCTHETA", "MC_ETA": "MCETA", "MC_PHI": "MCPHI", "MC_ABSID": "MCABSID" } mctuple_B2Kmumu = MCDecayTreeTuple('MCTuple_B2Kmumu') mctuple_B2Kmumu.Decay = "[ (Beauty & LongLived) --> ^(J/psi(1S) -> ^mu+ ^mu- ...) ^K+ ... ]CC" mctuple_B2Kmumu.Branches = { 'B': "[ (Beauty & LongLived) --> ^(J/psi(1S) -> mu+ mu- ...) K+ ... ]CC", 'Kplus': "[ (Beauty & LongLived) --> ^(J/psi(1S) -> mu+ mu- ...) ^K+ ... ]CC", 'psi': "[ (Beauty & LongLived) --> ^(J/psi(1S) -> mu+ mu- ...) K+ ... ]CC", 'muplus': "[ (Beauty & LongLived) --> ^(J/psi(1S) -> ^mu+ mu- ...) K+ ... ]CC", 'muminus': "[ (Beauty & LongLived) --> ^(J/psi(1S) -> mu+ ^mu- ...) K+ ... ]CC", } # List of the mc tuples
from Configurables import GaudiSequencer, CombineParticles from Configurables import DecayTreeTuple, EventTuple, TupleToolTrigger, TupleToolTISTOS,FilterDesktop, MCDecayTreeTuple,PrintMCTree from Configurables import BackgroundCategory, TupleToolDecay, TupleToolVtxIsoln,TupleToolPid,EventCountHisto,TupleToolRecoStats from Configurables import LoKi__Hybrid__TupleTool, TupleToolVeto # Unit SeqPhys = GaudiSequencer("SeqPhys") #mct = MCDecayTreeTuple('mct') #mct.Decay = "gamma" #mct.Decay = "[Beauty -> ^K*(892)0 ^gamma]CC" #mct.Branches = { # "gamma" :"[Beauty -> K*(892)0 ^gamma]CC" , # "Beauty" :"[Beauty -> K*(892)0 gamma]CC" , # "Kst" :"[Beauty -> ^K*(892)0 gamma]CC" , # } mct = MCDecayTreeTuple('mct') # B0 -> K+pi-pi0 #mct.Decay = "[Beauty -> ^K+ ^pi- ^(pi0 -> ^gamma ^gamma)]CC" #mct.Branches = { # "gamma1" :"[Beauty -> K+ pi- (pi0 -> gamma ^gamma)]CC" , # "gamma2" :"[Beauty -> K+ pi- (pi0 -> ^gamma gamma)]CC" , # "B" :"[Beauty -> K+ pi- (pi0 -> gamma gamma)]CC" , # "K" :"[Beauty -> ^K+ pi- (pi0 -> gamma gamma)]CC" , # "Pi" :"[Beauty -> K+ ^pi- (pi0 -> gamma gamma)]CC" , # } # B+ -> K+pi0 mct.Decay = "[Beauty -> ^K+ ^(pi0 -> ^gamma ^gamma)]CC" mct.Branches = { "gamma1" :"[Beauty -> K+ (pi0 -> gamma ^gamma)]CC" , "gamma2" :"[Beauty -> K+ (pi0 -> ^gamma gamma)]CC" , "B" :"[Beauty -> K+ (pi0 -> gamma gamma)]CC" ,
from DecayTreeTuple.Configuration import * year = 2012 decay = "[KS0 ==> ^pi+ ^pi- ^e+ ^e-]CC" import sys # HOME = "/afs/cern.ch/work/j/jcidvida/tmp/xgen_emu/" # #if len(sys.argv)==1: datafile = HOME+"proba_40112030_mA_2_tA_0.gen" # if len(sys.argv)==1: datafile = "/tmp/jcidvida/proba.gen" # else: datafile = HOME+filter(lambda x: sys.argv[1] in x,os.listdir(HOME))[0] # For a quick and dirty check, you don't need to edit anything below here. ########################################################################## # Create an MC DTT containing any candidates matching the decay descriptor mctuple = MCDecayTreeTuple("MCDecayTreeTuple") mctuple.Decay = decay mctuple.addBranches({ "KSO": "[KS0 ==> pi+ pi- e+ e-]CC", "e+": "[KS0 ==> pi+ pi- ^e+ e-]CC", "e-": "[KS0 ==> pi+ pi- e+ ^e-]CC", "pi+": "[KS0 ==> ^pi+ pi- e+ e-]CC", "pi-": "[KS0 ==> pi+ ^pi- e+ e-]CC" }) mctuple.ToolList = [ "MCTupleToolHierarchy", "LoKi::Hybrid::MCTupleTool/LoKi_Photos" ] # Add a 'number of photons' branch mctuple.addTupleTool("MCTupleToolKinematic").Verbose = True mctuple.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_Photos").Variables = {
## @file DVTrueKs.py # # See DecayTreeTuple documentation # # @author P. Koppenburg # @date 2009-01-22 # ######################################################################## # # The MC truth Tuple # from Configurables import MCDecayTreeTuple mcTuple = MCDecayTreeTuple("MCTuple") mcTuple.Decay = "[KS0 -> ^pi+ ^pi- {, gamma}{, gamma}]cc" mcTuple.ToolList = [ "MCTupleToolKinematic", "TupleToolEventInfo", "MCTupleToolReconstructed", "MCTupleToolAngles" ] #mcTuple.OutputLevel = 1 ######################################################################## # # The reconstructed tuple # from Configurables import DecayTreeTuple tuple = DecayTreeTuple("Tuple") tuple.ToolList += [ "TupleToolMCTruth", "TupleToolMCBackgroundInfo", "TupleToolAngles", "TupleToolPrimaries", "TupleToolGeometry", "TupleToolKinematic", "TupleToolEventInfo", "TupleToolTrackInfo" ] tuple.InputLocations = ["StdLooseKsLL", "StdLooseKsDD"]
'atan2(PY,PX)', 'RAPIDITY': '0.5 * log( (sqrt(P*P+M*M)+PZ)/(sqrt(P*P+M*M)-PZ) )', 'TIP': '1e3 * (PX * (VFASPF(VY)-BPV(VY)) - PY * (VFASPF(VX)-BPV(VX))) / sqrt(PX*PX + PY*PY)' } # refit PVs with exclusion of our tracks of interest tup.ReFitPVs = True # add ntuple to the list of running algorithms DaVinci().UserAlgorithms += [tup] # MCParticle ntuple from Configurables import MCDecayTreeTuple mctuple = MCDecayTreeTuple('mctuple_Lc2pKpi') mctuple.Decay = '[Lambda_c+ => ^p+ ^K- ^pi+]CC' mctuple.Branches = { 'lcplus': '[Lambda_c+ => p+ K- pi+]CC', 'pplus': '[Lambda_c+ => ^p+ K- pi+]CC', 'kminus': '[Lambda_c+ => p+ ^K- pi+]CC', 'piplus': '[Lambda_c+ => p+ K- ^pi+]CC' } #mctuple.ToolList = ["MCTupleToolKinematic"] DaVinci().UserAlgorithms += [mctuple] # Filter events for faster processing #from PhysConf.Filters import LoKi_Filters #if (restripversion == "" and Turbo == False) : # fltrs = LoKi_Filters ( # STRIP_Code = "HLT_PASS_RE('Stripping{0}Decision')".format(lines[0]) # note: only for one line!
from GaudiConf import IOHelper from Configurables import DaVinci, DecayTreeTuple from DecayTreeTuple.Configuration import * from Configurables import MCDecayTreeTuple, MCTupleToolKinematic, MCTupleToolHierarchy, LoKi__Hybrid__MCTupleTool, LoKi__Hybrid__EvtTupleTool, TupleToolEventInfo ############################################################################################# # # # Create The DecayTree # # # ############################################################################################# Trees = [] # Bs -> K Mu Nu DecayTree = MCDecayTreeTuple('TupleBs2KMuNu') DecayTree.Decay = '([ [B_s0]nos -> ^K- ^mu+ ... ]CC || [ [B_s~0]os -> ^K- ^mu+ ... ]CC)' Trees.append(DecayTree) # Bs -> K* Mu Nu DecayTree = MCDecayTreeTuple('TupleBs2KstarMuNu') DecayTree.Decay = '([ [B_s0]nos -> ^( K*(892)- => ^k- ^pi0 ) ^mu+ ... ]CC || [ [B_s~0]os -> ^( K*(892)- => ^k- ^pi0 ) ^mu+ ... ]CC)' Trees.append(DecayTree) #Ds Decays DecayTree = MCDecayTreeTuple('TupleBs2DsMuNu') DecayTree.Decay = '( [ [B_s0]nos -> ^( D_s- => ^K+ ^K- ^pi- ) ^mu+ ... ]CC ) || ([ [B_s~0]os -> ^( D_s- => ^K+ ^K- ^pi- ) ^mu+ ... ]CC )' Trees.append(DecayTree) #DsStar Decays DecayTree = MCDecayTreeTuple('TupleBs2DsStarMuNu_pi0') DecayTree.Decay = '( [ [B_s0]nos -> ^( D*_s- => ^( D_s- => ^K+ ^K- ^pi- ) ^pi0 ) ^mu+ ... ]CC ) || ([ [B_s~0]os -> ^( D*_s- => ^( D_s- => ^K+ ^K- ^pi- ) ^pi0 ) ^mu+ ... ]CC )' Trees.append(DecayTree)
from os import environ from GaudiKernel.SystemOfUnits import * from Gaudi.Configuration import * from Configurables import GaudiSequencer, CombineParticles from Configurables import DecayTreeTuple, EventTuple, TupleToolTrigger, TupleToolTISTOS,FilterDesktop, MCDecayTreeTuple,PrintMCTree from Configurables import BackgroundCategory, TupleToolDecay, TupleToolVtxIsoln,TupleToolPid,EventCountHisto,TupleToolRecoStats from Configurables import LoKi__Hybrid__TupleTool, TupleToolVeto # Unit SeqPhys = GaudiSequencer("SeqPhys") mct = MCDecayTreeTuple('mct') mct.Decay = "gamma" mct.Branches = { "gamma" :"gamma" , } mctB = MCDecayTreeTuple('mctB') mctB.Decay = "[B0]CC" mctB.Branches = { "B0" :"[B0]CC" , } #mct = MCDecayTreeTuple('mct') #mct.Decay = "[Lambda_c+ => ^p+ ^K- ^pi+]CC" #mct.Branches = { # "Lc" :"[Lambda_c+ => p+ K- pi+ ]CC" , # "Lcp":"[Lambda_c+ => ^p+ K- pi+]CC" , # "LcK":"[Lambda_c+ => p+ ^K- pi+]CC" , # "LcH":"[Lambda_c+ => p+ K- ^pi+]CC" , # } #mct = MCDecayTreeTuple('mct') #mct.Decay = "[D0 => ^K- ^pi+]CC" #mct.Branches = {
tuple.addTool(TupleToolTrigger, name="TupleToolTrigger") tuple.addTool(TupleToolTISTOS, name="TupleToolTISTOS") # Get trigger info tuple.TupleToolTrigger.Verbose = True tuple.TupleToolTrigger.TriggerList = tlist tuple.TupleToolTISTOS.Verbose = True tuple.TupleToolTISTOS.TriggerList = tlist from TeslaTools import TeslaTruthUtils seq = TeslaTruthUtils.associateSequence("Tesla", False) relations = TeslaTruthUtils.getRelLoc("Tesla") TeslaTruthUtils.makeTruth( tuple, relations, ["MCTupleToolKinematic", "MCTupleToolHierarchy", "MCTupleToolPID"]) tuple2 = MCDecayTreeTuple("MCTeslaTuple") tuple2.Inputs = ['/Event/Tesla/Particles'] tuple2.Decay = tuple.Decay from Configurables import DataOnDemandSvc, L0SelReportsMaker, L0DecReportsMaker DataOnDemandSvc().AlgMap["HltLikeL0/DecReports"] = L0DecReportsMaker() DataOnDemandSvc().AlgMap["HltLikeL0/SelReports"] = L0SelReportsMaker() from Configurables import L0Conf L0Conf().FullL0MuonDecoding = True L0Conf().EnableL0DecodingOnDemand = True L0Conf().EnsureKnownTCK = False tuple3 = DecayTreeTuple("StrippingTuple") tuple3.Inputs = [ '/Event/AllStreams/Phys/FullDSTDiMuonJpsi2MuMuDetachedLine/Particles' ]
from Gaudi.Configuration import * from GaudiKernel.SystemOfUnits import * ##################################################################### # # Define template MCtuple # ###################################################################### from Configurables import MCDecayTreeTuple MCTupTmp = MCDecayTreeTuple() MCTupTmp.ToolList += ["MCTupleToolHierarchy"] MCTupTmp.ToolList += ["MCTupleToolKinematic"] MCTupTmp.ToolList += ["MCTupleToolPID"] ###################################################################### from Configurables import LoKi__Hybrid__EvtTupleTool MCTupTmp.addTool(LoKi__Hybrid__EvtTupleTool, name="LoKiHybrid") MCTupTmp.ToolList += ["LoKi::Hybrid::EvtTupleTool/LoKiHybrid"] MCTupTmp.LoKiHybrid.Preambulo = ["from LoKiCore.basic import LHCb"] MCTupTmp.LoKiHybrid.VOID_Variables = { "nSPDHits": "RECSUMMARY( LHCb.RecSummary.nSPDhits, -1, '/Event/Rec/Summary', False )" }