예제 #1
0
def stdSigmas(listtype='std', gammatype='pi0eff50', path=None):
    """
    Load standard ``Sigma+`` reconstructed from ``Sigma+ -> p+ [pi0 -> gamma gamma]```.
    The ``pi0`` is reconstructed using the specified gamma list and ``pi0``s in mass range
    ``100 ~ 160 MeV`` are combined the with protons from ``p+:loose`` list to form a ``Sigma+``.
    
    Tree fitter is used for the vertex fit with IP constraint and mass constraint on the ``pi0``.
    
    The particle list is named ``Sigma+:std`` with mass range ``1.66 ~ 1.22 GeV``.
    
    Parameters:
        gamma_type (str): the gamma list to use
        path (basf2.path): path to load the particle list
    """

    stdPhotons(gammatype, path=path)
    stdPr('loose', path=path)
    ma.reconstructDecay(
        f'pi0:for_sigma -> gamma:{gammatype} gamma:{gammatype}',
        '0.1 < M < 0.16',
        path=path)
    ma.reconstructDecay('Sigma+:std -> p+:loose pi0:for_sigma',
                        '1.1 < M < 1.3',
                        path=path)
    ma.vertexTree('Sigma+:std',
                  0,
                  ipConstraint=True,
                  massConstraint=[111],
                  updateAllDaughters=False,
                  path=path)
    ma.applyCuts('Sigma+:std', '1.16 < M < 1.22', path=path)

    if listtype == 'std':
        pass
    elif listtype == 'loose':
        vtx_cuts = 'cosaXY > 0.99 and dr > 0.12 and abs(dz) > 0.1 and chiProb > 0.001'
        ma.cutAndCopyList('Sigma+:loose', 'Sigma+:std', vtx_cuts, path=path)
    else:
        B2ERROR(
            f'stdSigmas: Invalid listtype ({listtype}. Choose from std, loose.'
        )
예제 #2
0
def reconstructLambda(outlist, match=False, only=None, path=None):
    """Reconstruct Lambda based on Lambda0:mdst
    
    outlist:
        Output particle list name. You can use for example 'Lambda0:belle'
    match:
        Perform MC truth match or not
    only:
        If only == 'signal', then only keep matched signal
        If only == 'background', then only keep background
        Otherwise, no further cuts.
        This option is for generating balanced training samples
    """
    if path == None:
        raise Exception('Path cannot be None!')
    if outlist == 'Lambda0:mdst':
        raise Exception('outlist name cannot be Lambda0:mdst')

    inlist = 'Lambda0:mdst'
    ma.vertexTree(inlist, path=path)
    if match:
        ma.matchMCTruth(inlist, path=path)
        if only == 'signal':
            ma.cutAndCopyList(outlist, inlist, 'isSignal == 1', path=path)
        elif only == 'background':
            ma.cutAndCopyList(outlist, inlist, 'isSignal == 0', path=path)
        else:
            ma.cutAndCopyList(outlist, inlist, '', path=path)
예제 #3
0
                    'M >= 1.0 and M <= 1.4',
                    path=mp)
## !!! Have to set updateAllDaughters = True because the pi0:mdst list is mass constrained
ma.vertexTree('Sigma+:loose',
              0,
              ipConstraint=True,
              updateAllDaughters=True,
              path=mp)
ma.applyCuts('Sigma+:loose', 'M >= 1.1 and M <= 1.3', path=mp)
# ma.matchMCTruth('Sigma+:loose', path = mp)
# mp.add_module('VariablesToNtuple', particleList = 'Sigma+:loose',
#               variables=ntuple_vars, treeName='sigma_loose', fileName=sys.argv[2])

# Eff of this cut is about 96% and rejects about 50% of the background for Sigma+
pi0_mass_cut = 'daughter(1, M) >= 0.12 and daughter(1, M) <= 0.15'
ma.cutAndCopyList('Sigma+:good', 'Sigma+:loose', pi0_mass_cut, path=mp)
ma.vertexTree('Sigma+:good',
              0,
              ipConstraint=True,
              massConstraint=[],
              updateAllDaughters=False,
              path=mp)
ma.applyCuts('Sigma+:good', 'M >= 1.16 and M <= 1.22', path=mp)
ma.matchMCTruth('Sigma+:good', path=mp)
mp.add_module('VariablesToNtuple',
              particleList='Sigma+:good',
              variables=ntuple_vars,
              treeName='sigma_good',
              fileName=sys.argv[2])

# # Mass constrain pi0 and update the daughters
예제 #4
0
# gamma
gamma_vars = create_aliases_for_selected([
    'phi', 'theta', 'E', 'goodBelleGamma', 'clusterReg', 'clusterE9E21',
    'clusterTiming', 'clusterErrorTiming', 'genMotherPDG', 'isSignal'
],
                                         'Sigma+ -> p+ [pi0 -> ^gamma ^gamma]',
                                         prefix=['gamma1', 'gamma2'])

ntuple_vars = sigma_vars + proton_vars + pi0_vars + gamma_vars + event_vars

# RECONSTRUCTION
# ==============================================
ma.fillParticleList('p+:all', '', path=mp)
# M Berger: standard pairwise PID > 0.6 and impact parameter > 0.003
ma.cutAndCopyList('p+:berger',
                  'p+:all',
                  'pid_ppi > 0.6 and pid_pk > 0.6',
                  path=mp)
# M Berger: photons > 40 MeV and pi0 lab frame momentum > 100 MeV
ma.cutAndCopyList(
    'pi0:berger',
    'pi0:mdst',
    'daughter(0, E) > 0.05 and daughter(0, E) > 0.05 and p > 0.1',
    path=mp)
ma.reconstructDecay('Sigma+:berger_loose -> p+:berger pi0:berger',
                    'M >= 1.0 and M <= 1.4',
                    path=mp)
# Set updateAllDaughters = True because the pi0:mdst list is mass constrained
ma.vertexTree('Sigma+:berger_loose',
              0,
              ipConstraint=True,
              massConstraint=[111],
예제 #5
0
# pi0
pi0_vars = create_aliases_for_selected(['p', 'M', 'mcPDG', 'genMotherPDG', 'isSignal', 'distance', 'significanceOfDistance'],
                                       'Sigma+ -> p+ ^pi0', prefix = ['pi0'])
# gamma
gamma_vars = create_aliases_for_selected(['phi', 'theta', 'E', 'goodBelleGamma', 'clusterReg', 'clusterE9E21', 
                             'clusterTiming', 'clusterErrorTiming', 'genMotherPDG', 'isSignal'],
                            'Sigma+ -> p+ [pi0 -> ^gamma ^gamma]', prefix = ['gamma1', 'gamma2'])

ntuple_vars = sigma_vars + proton_vars + pi0_vars + gamma_vars + event_vars

# RECONSTRUCTION
# ==============================================
ma.fillParticleList('p+:all', '', path = mp)
# M Berger: standard pairwise PID > 0.6 and impact parameter > 0.003
ma.cutAndCopyList('p+:berger', 'p+:all', 'pid_ppi > 0.6 and pid_pk > 0.6', path = mp)
# M Berger: photons > 40 MeV and pi0 lab frame momentum > 100 MeV
ma.cutAndCopyList('pi0:loose',  'pi0:mdst', '', path = mp)
ma.reconstructDecay('Sigma+:loose -> p+:berger pi0:loose', 'M >= 1.15 and M <= 1.23', path = mp)
# Set updateAllDaughters = True because the pi0:mdst list is mass constrained
ma.vertexTree('Sigma+:loose', 0, ipConstraint = True, updateAllDaughters=True, path = mp)

# M Berger: discard condidates with wrong sign of flight distance
ma.cutAndCopyList('Sigma+:good', 'Sigma+:loose',
                  'gamma1_E > 0.03 and gamma2_E > 0.03 and pi0_M >= 0.11 and pi0_M <= 0.16 and pi0_p > 0.05', 
                   path = mp)
ma.vertexTree('Sigma+:good', 0, ipConstraint = True, massConstraint = [111], path = mp)
ma.applyCuts('Sigma+:good', 'M >= 1.17 and M <= 1.21', path = mp)
ma.matchMCTruth('Sigma+:good', path = mp)
mp.add_module('VariablesToNtuple', particleList = 'Sigma+:good', 
              variables=ntuple_vars, treeName='good', fileName=sys.argv[2])
def reconstruct(infile='default.root', outfile='output_beta.root', path=None):
    """

    Args:
        infile: Input file name (use overwrite from basf2)
        outfile: output file name (use overwrite from basf2)
        path: (optional) basf2 path

    Returns:
        path
    """

    setup()

    # EXAMPE RECONSTRUCTION CODE
    # DELETE OR MODIFY FROM HERE
    just_an_example = True
    if just_an_example:
        with open(outfile, 'w') as f:
            f.write("Proccessed example input " + infile)
    else:
        path = b2.create_path() if path is None else path

        # Input file
        ma.inputMdstList("default", infile, path=path)

        # Event level cuts examples
        ma.applyEventCuts('R2EventLevel<0.6 and nTracks>=3', path=path)

        #
        # Load Primary particles
        #
        from stdPhotons import stdPhotons
        stdPhotons('cdc', path)
        ma.cutAndCopyList('gamma:sig', 'gamma:cdc',
                          'clusterNHits > 1.5 and E > 1.5', True, path)

        from stdPi0s import stdPi0s
        stdPi0s('eff20', path)

        # Loading charged tracks
        good_track = 'thetaInCDCAcceptance and nCDCHits>20 and dr < 0.5 and abs(dz) < 2'
        ma.fillParticleList("pi+:sig",
                            good_track + " and pionID > 0.0",
                            path=path)
        ma.fillParticleList("K+:sig",
                            good_track + " and kaonID > 0.0",
                            path=path)

        #
        # Combine particles
        #
        ma.reconstructDecay('K*0:sig  -> K+:sig pi-:sig',
                            '0.6 < M < 1.6',
                            path=path)

        ma.reconstructDecay('B0:sig ->  K*0:sig gamma:sig',
                            '5.22 < Mbc < 5.3 and  abs(deltaE)< 1',
                            path=path)

        # Final Calculateions
        ma.rankByHighest("B0:ch1",
                         "formula(-1*abs(deltaE))",
                         outputVariable='Rank_deltaE',
                         path=path)

        ma.buildEventShape(allMoments=True, path=path)

        ma.matchMCTruth("B0:sig", path=path)

        #
        # Write out Ntuples
        #
        all_vars = get_variables()
        ma.variablesToNtuple('B0:ch1',
                             all_vars,
                             filename=outfile,
                             treename="B0",
                             path=path)
    # TO HERE

    #ma.printMCParticles(path=path)
    return path