Exemple #1
0
    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
Exemple #2
0
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
Exemple #3
0
    mcTuple = MCDecayTreeTuple(
        "MCTupleJPsi2KsKs"
    )  # I can put as an argument a name if I use more than a MCDecayTreeTuple
    mcTuple.Decay = "[J/psi(1S) -> ^(KS0 -> ^pi+ ^pi-) ^(KS0 -> ^pi+ ^pi-)]CC"
    mcTuple.Branches = {
        "JPsi": "[J/psi(1S) -> (KS0 -> pi+ pi-) (KS0 -> pi+ pi-)]CC",
        "Ks1": "[J/psi(1S) -> ^(KS0 -> pi+ pi-) (KS0 -> pi+ pi-)]CC",
        "Ks2": "[J/psi(1S) -> (KS0 -> pi+ pi-) ^(KS0 -> pi+ pi-)]CC",
        "pi1": "[J/psi(1S) -> (KS0 -> ^pi+ pi-) (KS0 -> pi+ pi-)]CC",
        "pi2": "[J/psi(1S) -> (KS0 -> pi+ ^pi-) (KS0 -> pi+ pi-)]CC",
        "pi3": "[J/psi(1S) -> (KS0 -> pi+ pi-) (KS0 -> ^pi+ pi-)]CC",
        "pi4": "[J/psi(1S) -> (KS0 -> pi+ pi-) (KS0 -> pi+ ^pi-)]CC",
    }

    mcTuple.addBranches(mcTuple.Branches)
    mcTuple.ToolList = [
        "MCTupleToolKinematic",
        "TupleToolEventInfo",
        "MCTupleToolHierarchy",
        "TupleToolMCBackgroundInfo",
    ]


from Configurables import DaVinci

# Name of tuple file you want to write out.
DaVinci().TupleFile = "JPsi2KsKs.root"
DaVinci().EvtMax = -1
DaVinci().DataType = "2012"
DaVinci().Simulation = isMC
                       'X0' : '[ Xc => ( (phi(1020) => K+ K- ) ) X+ ^X0]CC'}
        numbers_phi_X = [2,1]
        
    mcTuple = MCDecayTreeTuple() # I can put as an argument a name if I use more than a MCDecayTreeTuple
    mcTuple.Decay = MC_DecayDescriptor
    mcTuple.ToolList = ['MCTupleToolKinematic',
                        'TupleToolEventInfo',
                        'MCTupleToolHierarchy',
                      ]

    mcTuple.addTupleTool("LoKi::Hybrid::MCTupleTool/LoKi_All")
    mcTuple.LoKi_All.Variables =  {
        'TRUEID' : 'MCID'
        }
    
    mcTuple.addBranches(MC_branches)

    mcTuple.Head.addTupleTool("LoKi::Hybrid::MCTupleTool/LoKi_Head")
    mcTuple.Head.LoKi_Head.Preambulo = [
        "from LoKiCore.math import sqrt",
        "Phi_E  = MCCHILD(MCE,  {})".format(numbers_phi_X[0]),
        "Phi_PX = MCCHILD(MCPX, {})".format(numbers_phi_X[0]),
        "Phi_PY = MCCHILD(MCPY, {})".format(numbers_phi_X[0]),
        "Phi_PZ = MCCHILD(MCPZ, {})".format(numbers_phi_X[0]),
        "X_P  = MCCHILD(MCP,  {})".format(numbers_phi_X[1]),
        "X_E_asMu  = sqrt(105.6583715**2 + X_P**2)",
        "X_E_asPi  = sqrt(139.57018**2 + X_P**2)",
        "X_PX = MCCHILD(MCPX, {})".format(numbers_phi_X[1]),
        "X_PY = MCCHILD(MCPY, {})".format(numbers_phi_X[1]),
        "X_PZ = MCCHILD(MCPZ, {})".format(numbers_phi_X[1]),
        "PhiMu_M = sqrt( (Phi_E + X_E_asMu)**2 - (Phi_PX + X_PX)**2 - (Phi_PY + X_PY)**2 - (Phi_PZ + X_PZ)**2 )",
Exemple #5
0
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 = {
    "nPhotos": "MCNINTREE(('gamma' == MCABSID))"
}

mctuple.addTupleTool("LoKi::Hybrid::MCTupleTool/LoKi_All")
mctuple.LoKi_All.Variables = {
Exemple #6
0
from Configurables import ( DaVinci
#                          , EventSelector # Uncomment when running locally
                          , MCDecayTreeTuple
                          , LHCbApp
                          )
from DecayTreeTuple.Configuration import *
LHCbApp().XMLSummary='summary.xml'

# Create an MC DTT containing any candidates matching the decay descriptor
mctuple = MCDecayTreeTuple()
mctuple.Decay = "[B_s0 => ^(phi(1020) ==> ^K+ ^K-) ^(phi(1020) ==> ^K+ ^K-)]CC"
mctuple.addBranches({
   "KK" : " [B_s0 => (phi(1020) ==> K+ K-) ^(phi(1020) ==> K+ K-)]CC "
})
mctuple.ToolList = []
mctuple.addTupleTool("MCTupleToolKinematic").Verbose = True


# Name of the .xgen file produced by Gauss
#ev = EventSelector()
#ev.Input = ["DATAFILE='Gauss-13104013-100000ev-20160407.xgen' TYP='POOL_ROOTTREE' Opt='READ'"]

# Configure DaVinci
dv = DaVinci( HistogramFile = "histo.root"
            , TupleFile = "DVntuple.root"
            , UserAlgorithms = [mctuple]
            , Simulation = True
            , Lumi = False
            , DataType = "2012"
            , EvtMax = -1
            )