Exemplo n.º 1
0
 def create_path(self):
     path = basf2.create_path()
     modularAnalysis.inputMdstList(
         'default',
         self.get_input_file_names("reconstructed_output.root"),
         path=path)
     modularAnalysis.fillParticleLists([('K+', 'kaonID > 0.1'),
                                        ('pi+', 'pionID > 0.1')],
                                       path=path)
     modularAnalysis.reconstructDecay('D0 -> K- pi+',
                                      '1.7 < M < 1.9',
                                      path=path)
     modularAnalysis.matchMCTruth('D0', path=path)
     modularAnalysis.reconstructDecay('B- -> D0 pi-',
                                      '5.2 < Mbc < 5.3',
                                      path=path)
     try:  # treeFit is the new function name in light releases after release 4 (e.g. light-2002-janus)
         vertex.treeFit('B+', 0.1, update_all_daughters=True, path=path)
     except AttributeError:  # vertexTree is the function name in release 4
         vertex.vertexTree('B+', 0.1, update_all_daughters=True, path=path)
     modularAnalysis.matchMCTruth('B-', path=path)
     modularAnalysis.variablesToNtuple(
         'D0', [
             'M', 'p', 'E', 'useCMSFrame(p)', 'useCMSFrame(E)',
             'daughter(0, kaonID)', 'daughter(1, pionID)', 'isSignal',
             'mcErrors'
         ],
         filename=self.get_output_file_name("D_n_tuple.root"),
         path=path)
     modularAnalysis.variablesToNtuple(
         'B-', ['Mbc', 'deltaE', 'isSignal', 'mcErrors', 'M'],
         filename=self.get_output_file_name("B_n_tuple.root"),
         path=path)
     return path
Exemplo n.º 2
0
 def create_path(self):
     path = basf2.create_path()
     modularAnalysis.inputMdstList(
         'default',
         self.get_input_file_names("reconstructed_output.root"),
         path=path)
     modularAnalysis.fillParticleLists([('K+', 'kaonID > 0.1'),
                                        ('pi+', 'pionID > 0.1')],
                                       path=path)
     modularAnalysis.reconstructDecay('D0 -> K- pi+',
                                      '1.7 < M < 1.9',
                                      path=path)
     modularAnalysis.fitVertex('D0', 0.1, path=path)
     modularAnalysis.matchMCTruth('D0', path=path)
     modularAnalysis.reconstructDecay('B- -> D0 pi-',
                                      '5.2 < Mbc < 5.3',
                                      path=path)
     modularAnalysis.fitVertex('B+', 0.1, path=path)
     modularAnalysis.matchMCTruth('B-', path=path)
     modularAnalysis.variablesToNtuple(
         'D0', [
             'M', 'p', 'E', 'useCMSFrame(p)', 'useCMSFrame(E)',
             'daughter(0, kaonID)', 'daughter(1, pionID)', 'isSignal',
             'mcErrors'
         ],
         filename=self.get_output_file_name("D_n_tuple.root"),
         path=path)
     modularAnalysis.variablesToNtuple(
         'B-', ['Mbc', 'deltaE', 'isSignal', 'mcErrors', 'M'],
         filename=self.get_output_file_name("B_n_tuple.root"),
         path=path)
     return path
Exemplo n.º 3
0
def create_analysis_path(
        b_ntuple_filename="B_ntuple.root",
        d_ntuple_filename="D_ntuple.root",
        mbc_range=(5.2, 5.3),
):
    """
    Example of a minimal reconstruction with a cut as a changeable function
    parameter, adapted from code in the ``B2T_Basics_3_FirstAnalysis.ipynb``
    notebook from b2 starter kit.
    """
    path = basf2.create_path()
    # this local inputMdstList will only be used when this steerig file is run locally, gbasf2 overrides it
    local_input_files = [
        "/group/belle2/dataprod/MC/MC13a/prod00009434/s00/e1003/4S/r00000/mixed/mdst/sub00/mdst_000001_prod00009434_task10020000001.root"
    ]
    mA.inputMdstList(
        environmentType="default",
        filelist=local_input_files,
        path=path,
    )
    stdK("higheff", path=path)
    stdPi("higheff", path=path)
    mA.reconstructDecay('D0:Kpi -> K-:higheff pi+:higheff',
                        '1.7 < M < 1.9',
                        path=path)
    # use try except to have this code work for both the old and new function names for the tree fit
    mA.matchMCTruth('D0:Kpi', path=path)
    mA.reconstructDecay('B- -> D0:Kpi pi-:higheff',
                        f"{mbc_range[0]} < Mbc < {mbc_range[1]}",
                        path=path)
    try:
        vx.treeFit('B+', 0.1, path=path)
    except AttributeError:
        vx.vertexTree('B+', 0.1, path=path)
    mA.setAnalysisConfigParams({"mcMatchingVersion": "BelleII"}, path)
    mA.matchMCTruth('B-', path=path)
    vm.addAlias("p_cms",
                "useCMSFrame(p)")  # include aliases to test if they work
    vm.addAlias("E_cms", "useCMSFrame(E)")
    mA.variablesToNtuple('D0:Kpi', [
        'M', 'p', 'E', 'E_cms', 'p_cms', 'daughter(0, kaonID)',
        'daughter(1, pionID)', 'isSignal', 'mcErrors'
    ],
                         filename=d_ntuple_filename,
                         treename="D",
                         path=path)
    mA.variablesToNtuple('B-', ['Mbc', 'deltaE', 'isSignal', 'mcErrors', 'M'],
                         filename=b_ntuple_filename,
                         treename="B",
                         path=path)
    return path
Exemplo n.º 4
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.'
        )
Exemplo n.º 5
0
             path=my_path)

# use standard final state particle lists
#
# creates "pi0:looseFit" ParticleList
# https://confluence.desy.de/display/BI/Physics+StandardParticles
stdPi0s(listtype='looseFit', path=my_path)
# creates "highPID" ParticleLists (and c.c.)
ma.fillParticleList(decayString='mu+:highPID',
                    cut='muonID > 0.2 and d0 < 2 and abs(z0) < 4',
                    path=my_path)

# reconstruct J/psi -> mu+ mu- decay
# keep only candidates with dM<0.11
ma.reconstructDecay(decayString='J/psi:mumu -> mu+:highPID mu-:highPID',
                    cut='dM<0.11 and 3.07 < M < 3.11',
                    path=my_path)

# reconstruct B0 -> J/psi Ks decay
# keep only candidates with Mbc > 5.1 and abs(deltaE)<0.15
ma.reconstructDecay(decayString='B0:jspipi0 -> J/psi:mumu pi0:looseFit',
                    cut='Mbc > 5.1 and abs(deltaE)<0.15',
                    path=my_path)

vx.vertexTree(
    list_name='B0:jspipi0',
    conf_level=
    -1,  # keep all cadidates, 0:keep only fit survivors, optimise this cut for your need
    ipConstraint=True,
    # pins the B0 PRODUCTION vertex to the IP (increases SIG and BKG rejection) use for better vertex resolution
    updateAllDaughters=True,  # update momenta off ALL particles
ma.inputMdstList(environmentType=magnetic_field,
                 filelist=input_file_list,
                 path=my_path)

ma.fillParticleList(decayString='gamma:all',
                    cut='',
                    path=my_path)
ma.fillParticleList(decayString='pi+:good',
                    cut='chiProb > 0.001 and pionID > 0.5',
                    path=my_path)
ma.fillParticleList(decayString='pi-:good',
                    cut='chiProb > 0.001 and pionID > 0.5',
                    path=my_path)

ma.reconstructDecay(decayString='K_S0 -> pi+:good pi-:good',
                    cut='0.480<=M<=0.516',
                    dmID=1,
                    path=my_path)
ma.reconstructDecay(decayString='pi0  -> gamma:all gamma:all',
                    cut='0.115<=M<=0.152',
                    dmID=1,
                    path=my_path)
ma.reconstructDecay(decayString='B0   -> K_S0 pi0',
                    cut='5.2 < Mbc < 5.3 and -0.3 < deltaE < 0.2',
                    path=my_path)

ma.matchMCTruth(list_name='B0', path=my_path)
ma.buildRestOfEvent(target_list_name='B0', path=my_path)

# The momentum cuts used to be hard-coded in the continuum suppression module. They can now be applied
# via this mask. The nCDCHits requirement is new, and is recommended to remove VXD-only fake tracks.
cleanMask = ('cleanMask', 'nCDCHits > 0 and useCMSFrame(p)<=3.2', 'p >= 0.05 and useCMSFrame(p)<=3.2')
Exemplo n.º 7
0
                                       '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])

b2.process(path=mp)
print(b2.statistics)
Exemplo n.º 8
0
                    cut='0.9 < M < 1.3',
                    path=my_path)
ma.vertexKFit(list_name='Lambda0:V0', conf_level=0.0, path=my_path)

# alternatively, we can create a list of particles combined
# using the analysis ParticleCombiner module
# Before doing it we need to create and fill ParticleLists
# of the V0s' daughters (anti-particle lists are automatically
# created, too)
# A vertex fit should also be performed
# In this example a cut on the candidates mass is applied
ma.fillParticleList(decayString='pi-:all', cut='', path=my_path)
ma.fillParticleList(decayString='p+:all', cut='', path=my_path)

ma.reconstructDecay(decayString='K_S0:RD -> pi+:all pi-:all',
                    cut='0.3 < M < 0.7',
                    path=my_path)
ma.vertexKFit(list_name='K_S0:RD', conf_level=0.0, path=my_path)
ma.reconstructDecay(decayString='Lambda0:RD -> p+:all pi-:all',
                    cut='0.9 < M < 1.3',
                    path=my_path)
ma.vertexKFit(list_name='Lambda0:RD', conf_level=0.0, path=my_path)

# another possibility is to use default functions
# for V0s they are defined in analysis/scripts/stdV0s.py
# e.g. stdKshorts():
# - takes all V0 candidates, performs vertex fit, and fills 'K_S0:all' ParticleList
#   a cut on the candidates mass is applied, too
stdv.stdKshorts(path=my_path)
stdv.stdLambdas(path=my_path)
Exemplo n.º 9
0
# apply Bremsstrahlung correction to electrons
variables.addAlias("goodFWDGamma",
                   "passesCut(clusterReg == 1 and clusterE > 0.075)")
variables.addAlias("goodBRLGamma",
                   "passesCut(clusterReg == 2 and clusterE > 0.05)")
variables.addAlias("goodBWDGamma",
                   "passesCut(clusterReg == 3 and clusterE > 0.1)")
variables.addAlias('goodGamma',
                   'passesCut(goodFWDGamma or goodBRLGamma or goodBWDGamma)')
ma.fillParticleList('gamma:brems', 'goodGamma', path=main)
ma.correctBrems('e+:corrected', 'e+:uncorrected', 'gamma:brems', path=main)
variables.addAlias('isBremsCorrected', 'extraInfo(bremsCorrected)')

# combine final state particles to form composite particles
ma.reconstructDecay('J/psi:ee -> e+:corrected e-:corrected ?addbrems',
                    cut='dM < 0.11',
                    path=main)

# perform vertex fit of J/psi candidates
vertex.KFit('J/psi:ee', conf_level=0.0, path=main)

# combine J/psi and KS candidates to form B0 candidates
ma.reconstructDecay('B0 -> J/psi:ee K_S0:merged',
                    cut='Mbc > 5.2 and abs(deltaE) < 0.3',
                    path=main)

# match reconstructed with MC particles
ma.matchMCTruth('B0', path=main)

# build the rest of the event
ma.buildRestOfEvent('B0', fillWithMostLikely=True, path=main)
                   harmonicMoments=False,
                   allMoments=False,
                   collisionAxis=False,
                   sphericity=False,
                   thrust=True,
                   path=my_path)
ma.buildEventKinematics(['tau-:gen', 'tau+:gen'], path=my_path)

# Get information of the generated decay mode calling labelTauPairMC from modular analysis
ma.labelTauPairMC(path=my_path)

######################################################
# Signal and tag sides
#######################################################

ma.reconstructDecay('vpho:photon_B2SS -> tau+:gen tau-:gen', '', path=my_path)

#####################################################
# -- event based variables
##################################################
var.addAlias('nDaug', 'countDaughters(1>0)')
#var.addAlias('InvMass', '')

eventVariables = ['thrust', 'M', 'tauPlusMCMode', 'tauMinusMCMode', 'nDaug']

tauVariables = ['p', 'px', 'py', 'pz', 'E', 'PDG', 'pt', 'M', 'EoverP']

# -- track level variables
#trackVariables = vc.kinematics #+ vc.pid + vc.track + vc.track_hits + vc.vertex
#trackVariables += ['theta','cosTheta','phi', 'charge', 'clusterE','EoverP', 'mcPDG']
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
Exemplo n.º 12
0
    environmentType='default',
    filelist=[
        f'{filedirectory}/mdst_000001_prod00012871_task10020000001.root'
    ],
    path=main)

# fill final state particle lists
impactcut = 'abs(d0)<2.0 and abs(z0)<5.0 '
ma.fillParticleList(decayString='mu+:all',
                    cut=impactcut + ' and muonID > 0.5',
                    path=main)
stdV0s.stdKshorts(path=main)

# combine final state particles to form composite particles
ma.reconstructDecay('J/psi:mumu -> mu+:all mu-:all',
                    cut='dM < 0.11',
                    path=main)

# perform vertex fit of J/psi candidates
vertex.KFit('J/psi:mumu', conf_level=0.0, path=main)

# combine J/psi and KS candidates to form B0 candidates
ma.reconstructDecay('B0 -> J/psi:mumu K_S0:merged',
                    cut='Mbc > 5.2 and abs(deltaE) < 0.3',
                    path=main)

# match reconstructed with MC particles
ma.matchMCTruth('B0', path=main)

# build the rest of the event
ma.buildRestOfEvent('B0', fillWithMostLikely=True, path=main)
Exemplo n.º 13
0
# create path
mypath = b2.create_path()

# load input ROOT file
inputMdst(environmentType='default',
          filename=b2.find_file('B2pi0D_D2hh_D2hhh_B2munu_evtgen.root', 'examples', False),
          path=mypath)

# fill an all photon and all charged particle (does not really matter which one) list
# clusterE: Returns ECL cluster's energy corrected for leakage and background
fillParticleList('gamma:all', 'clusterE > 0.1', path=mypath)  # neutral clusters
fillParticleList('e-:all', 'clusterE > 0.1', path=mypath)  # track matched clusters

# reconstruct a pseudo particles with different combinations (implicit charge conjugation)
reconstructDecay('vpho:1 -> gamma:all gamma:all', '', 1, path=mypath)  # two neutral '00'
reconstructDecay('vpho:2 -> gamma:all e-:all', '', 2, path=mypath)  # neutral and charged '0+' and '0-'
reconstructDecay('vpho:3 -> e-:all e+:all', '', 3, path=mypath)  # different charge '+-' and '-+'
reconstructDecay('vpho:4 -> e-:all e-:all', '', 4, path=mypath)  # same charge '++' and '--'
copyLists('vpho:bhabha', ['vpho:1', 'vpho:2', 'vpho:3', 'vpho:4'], path=mypath)

# aliases to make output better readable
variables.addAlias('combinationID', 'extraInfo(decayModeID)')
variables.addAlias('deltaPhi', 'daughterDiffOfClusterPhi(0, 1)')
variables.addAlias('deltaTheta', 'formula(daughter(0, clusterTheta) - daughter(1, clusterTheta))')
variables.addAlias('charge_0', 'daughter(0, charge)')
variables.addAlias('charge_1', 'daughter(1, charge)')
variables.addAlias('clusterE_0', 'daughter(0, clusterE)')
variables.addAlias('clusterE_1', 'daughter(1, clusterE)')
variables.addAlias('clusterTheta_0', 'daughter(0, clusterTheta)')
variables.addAlias('clusterTheta_1', 'daughter(1, clusterTheta)')
Exemplo n.º 14
0
ntuple_vars = sigma_vars + proton_vars + pi0_vars + gamma_vars + event_vars

# RECONSTRUCTION
# ==============================================
ma.fillParticleList('p+:all', '', path=mp)
ma.fillParticleList('pi+: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',
# load input ROOT file
ma.inputMdst(environmentType='default',
             filename=b2.find_file('B02D0pi0_D02pi0pi0.root', 'examples',
                                   False),
             path=my_path)

# use standard final state particle lists
#
# creates "pi0:looseFit" ParticleList
# https://confluence.desy.de/display/BI/Physics+StandardParticles
stdPi0s(listtype='looseFit', path=my_path)

# reconstruct D0 -> pi0 pi0 decay
# keep only candidates with 1.7 < M(pi0pi0) < 2.0 GeV
ma.reconstructDecay(decayString='D0:pi0pi0 -> pi0:looseFit pi0:looseFit',
                    cut='1.7 < M < 2.0',
                    path=my_path)

# reconstruct B0 -> D0 pi0 decay
# keep only candidates with Mbc > 5.24 GeV
# and -1 < Delta E < 1 GeV
ma.reconstructDecay(decayString='B0:all -> D0:pi0pi0 pi0:looseFit',
                    cut='5.24 < Mbc < 5.29 and abs(deltaE) < 1.0',
                    path=my_path)

# perform MC matching (MC truth asociation)
ma.matchMCTruth(list_name='B0:all', path=my_path)

# Select variables that we want to store to ntuple
B0_vars = vc.inv_mass + \
    vc.mc_truth + \
stdc.stdPi('all', path=my_path)
# rank all pions of the event by momentum magnitude
# variable stored to extraInfo as pi_p_rank
ma.rankByLowest(particleList='pi+:all',
                variable='p',
                outputVariable='pi_p_rank',
                path=my_path)

va.variables.addAlias('pi_p_rank', 'extraInfo(pi_p_rank)')

# creates "K+:loose" ParticleList (and c.c.)
stdc.stdK(listtype='loose', path=my_path)

# keep only candidates with 1.8 < M(Kpi) < 1.9 GeV
ma.reconstructDecay(decayString='D0 -> K-:loose pi+:all',
                    cut='1.8 < M < 1.9',
                    path=my_path)

# perform D0 vertex fit
# keep candidates only passing C.L. value of the fit > 0.0 (no cut)
vx.vertexTree(
    list_name='D0',
    conf_level=
    -1,  # keep all cadidates, 0:keep only fit survivors, optimise this cut for your need
    ipConstraint=True,
    # pins the B0 PRODUCTION vertex to the IP (increases SIG and BKG rejection) use for better vertex resolution
    updateAllDaughters=True,  # update momenta off ALL particles
    path=my_path)

# smaller |M_rec - M| is better, add here a different output variable name, due to parentheses
ma.rankByLowest(particleList='D0',
Exemplo n.º 17
0



ma.inputMdstList("default", [input_file], path=path)


print(b2.conditions.globaltags)

# Book charged Kaons and Pions
from stdCharged import stdK, stdPi
stdK("higheff",  path=path)
stdPi("higheff", path=path)

# Reconstruct D0 decay
ma.reconstructDecay('D0:my -> K-:higheff pi+:higheff', cut='1.75 < M < 1.95', path=path)

# Reconstruct D* decay
ma.reconstructDecay('D*+:my -> D0:my pi+:higheff', cut='1.90 < M < 2.25' , path=path)

# Fit vertex
#vx.treeFit('D*+:my', ipConstraint=True, updateAllDaughters=True, conf_level=0, path=path)
vx.treeFit('D*+:my', conf_level=0, path=path)

#ma.printList('D0:my', True, path=path)
#ma.printVariableValues('D0:my', ['IPX'], path=path)

#ma.printMCParticles(path=path)


from variables import variables as vm
Exemplo n.º 18
0
def reconstruction(input_file, output_file):
    my_path = b2.create_path()
    ma.inputMdst("default", input_file, my_path)

    # Find decay name from the input file name
    decay_name = "_".join(input_file.split("/")[-1].split("_")[0:2])

    # Load configuration file
    config = yaml.safe_load(open("config/reco_config.yaml"))
    options = config[decay_name]

    # Parse list of subdecays in decay chain
    decays = options["sub_decays"]
    decays = DecayList(decays)

    # Create particle lists for final state particles
    fsps = decays.get_fsps()
    for particle in fsps:
        ma.fillParticleList(particle, "", path=my_path)

    # Reconstruct requested decay chains
    for decay in decays:
        ma.reconstructDecay(str(decay), "", path=my_path)

    # Perform truth matching for requested particles
    truth_match_particles = decays.mothers
    for truth_match_particle in truth_match_particles:
        ma.looseMCTruth(truth_match_particle, path=my_path)

    # Perform vertex fitting
    head = decays.get_head()
    vtx_decay_string = decays.get_chain()
    print(vtx_decay_string)

    vx.vertexRave(head, 0, vtx_decay_string, constraint="iptube", path=my_path)

    # ma.rankByLowest("B0", 'chiProb', numBest=3, outputVariable='B_vtx_rank', path=my_path)
    # ma.variables.addAlias('B_vtx_rank', 'extraInfo(B_vtx_rank)')
    ma.buildRestOfEvent(head, path=my_path)

    # Tag-side
    vx.TagV(head, "breco", 0.001, path=my_path)

    ma.buildEventKinematics(path=my_path)
    ma.buildEventShape(path=my_path)

    # Create centre-of-mass frame variables
    cms_kinematics = vu.create_aliases(
        vc.kinematics, "useCMSFrame({variable})", prefix="CMS"
    )

    variables = [
        item
        for sublist in [
            vc.kinematics,
            cms_kinematics,
            vc.deltae_mbc,
            vc.inv_mass,
            vc.event_shape,
            vc.vertex,
            vc.mc_truth,
            vc.mc_kinematics,
            vc.mc_vertex,
            vc.mc_tag_vertex,
        ]
        for item in sublist
    ]

    trees = yaml.safe_load(open("config/tree_names.yaml"))
    for particle in decays.all_particles:
        ma.variablesToNtuple(
            particle,
            variables,
            filename=output_file,
            treename=trees[particle],
            path=my_path,
        )

    b2.process(my_path)
    print(b2.statistics)
Exemplo n.º 19
0
    va.addAlias('cosa', 'cosAngleBetweenMomentumAndVertexVector')
    va.addAlias('cosaXY', 'cosAngleBetweenMomentumAndVertexVectorInXYPlane')
    va.addAlias('abs_dM', 'abs(dM)')
    va.addAlias('abs_dr', 'abs(dr)')
    va.addAlias('pid_ppi', 'atcPIDBelle(4,2)')
    va.addAlias('pid_pk', 'atcPIDBelle(4,3)')
    va.addAlias('pid_kpi', 'atcPIDBelle(3,2)')
    va.addAlias('ppi0_angle', 'daughterAngle(0, 1)')
    va.addAlias('p_decayAngle', 'decayAngle(0)')
    va.addAlias('pi0_decayAngle', 'decayAngle(1)')

    ma.fillParticleList('p+:good', 'pid_ppi > 0.6 and pid_pk > 0.6', path=mp)
    #     ma.vertexTree('pi0:mdst', ipConstraint = True, massConstraint = ['pi0'], path = mp)
    ma.reconstructDecay('Sigma+:std -> p+:good pi0:mdst',
                        '1.1 < M < 1.3',
                        path=mp)
    ma.vertexTree('Sigma+:std',
                  0,
                  ipConstraint=True,
                  updateAllDaughters=True,
                  path=mp)
    # Select good pi0 based on mass and gamma energy
    ma.applyCuts(
        'Sigma+:std',
        'daughter(1, daughter(0, E)) > 0.04 and daughter(1, daughter(1, E)) > 0.04 and daughter(1, abs(dM)) < 0.02',
        path=mp)
    ma.vertexTree('Sigma+:std',
                  0,
                  ipConstraint=True,
                  massConstraint=['pi0'],
Exemplo n.º 20
0
             filename=b2.find_file('Dst2D0pi.root', 'examples', False),
             path=my_path)

# use standard final state particle lists
#
# creates "pi+:all" ParticleList (and c.c.)
stdc.stdPi(listtype='all', path=my_path)
# creates "pi+:loose" ParticleList (and c.c.)
stdc.stdPi(listtype='loose', path=my_path)
# creates "K+:loose" ParticleList (and c.c.)
stdc.stdK(listtype='loose', path=my_path)

# reconstruct D0 -> K- pi+ decay
# keep only candidates with 1.8 < M(Kpi) < 1.9 GeV
ma.reconstructDecay(decayString='D0:kpi -> K-:loose pi+:loose',
                    cut='1.8 < M < 1.9',
                    path=my_path)

# reconstruct D*+ -> D0 pi+ decay
# keep only candidates with Q = M(D0pi) - M(D0) - M(pi) < 20 MeV
# and D* CMS momentum > 2.5 GeV
ma.reconstructDecay(decayString='D*+ -> D0:kpi pi+:all',
                    cut='0.0 < Q < 0.2',
                    path=my_path)

# perform MC matching (MC truth asociation)
ma.matchMCTruth(list_name='D*+', path=my_path)

# Select variables that we want to store to ntuple
dstar_vars = vc.inv_mass + vc.mc_truth
Exemplo n.º 21
0
    'Gen_bbar_gsim-BKGx1-1M-9.root',
    'Gen_bbar_gsim-BKGx1-1M-10.root',
]
outputName = 'testSkimming_BBbar-10M-1.root'

# load files
inputMdstList(inputName)

# create lists of FSPs
pions = ('pi+:all', '')
kaons = ('K+:all', '')

fillParticleListsFromMC([pions, kaons], True)

# reconstruct phi and K_S0
reconstructDecay('phi:all -> K+:all K-:all', 'M < 1.3')
reconstructDecay('K_S0:all -> pi+:all pi-:all', '0.4 < M < 0.6')

# recostruct a B candidate out of those
reconstructDecay('B0:all -> phi:all K_S0:all', '5.0 < M < 5.5')

# add SkimFilter module to set condition variable based on the number of reconstructed B-tag mesons
skim = register_module('SkimFilter')
skim.param('particleLists', ['B0:all'])
analysis_main.add_module(skim)

# save event to a new mdst file if it contained at least one B-tag meson
empty_path = create_path()
skim.if_false(empty_path)
add_mdst_output(analysis_main, True, outputName)
Exemplo n.º 22
0
# load input ROOT file
ma.inputMdst(environmentType='default',
             filename=b2.find_file('B2rhogamma_rho2pipi.root', 'examples',
                                   False),
             path=my_path)

ma.fillParticleList(decayString='gamma:highE', cut='E > 1.5', path=my_path)
ma.fillParticleList(decayString='pi+:loose',
                    cut='abs(d0) < 0.5 and abs(z0) < 0.5 and pionID > 0.002',
                    path=my_path)

# reconstruct rho -> pi+ pi- decay
# keep only candidates with 0.6 < M(pi+pi-) < 1.0 GeV
ma.reconstructDecay(decayString='rho0 -> pi+:loose pi-:loose',
                    cut='0.6 < M < 1.0',
                    path=my_path)

# reconstruct B0 -> rho0 gamma decay
# keep only candidates with Mbc > 5.2 GeV
# and -2 < Delta E < 2 GeV
ma.reconstructDecay(decayString='B0 -> rho0 gamma:highE',
                    cut='5.2 < Mbc and abs(deltaE) < 2.0',
                    path=my_path)

# perform MC matching (MC truth asociation)
ma.matchMCTruth(list_name='B0', path=my_path)

# build RestOfEvent (ROE) object for each B0 candidate
# ROE is required by the veto
ma.buildRestOfEvent(target_list_name='B0', path=my_path)
Exemplo n.º 23
0
ma.inputMdst(environmentType='default',
             filename=b2.find_file('B2rhogamma_rho2pipi.root', 'examples',
                                   False),
             path=my_path)

#
# creates "gamma:tight" ParticleList
stdPhotons(listtype='tight', path=my_path)

# creates "pi+:loose" ParticleList (and c.c.)
stdc.stdPi(listtype='loose', path=my_path)

# reconstruct rho -> pi+ pi- decay
# keep only candidates with 0.6 < M(pi+pi-) < 1.0 GeV
ma.reconstructDecay(decayString='rho0 -> pi+:loose pi-:loose',
                    cut='0.6 < M < 1.0',
                    path=my_path)

# reconstruct B0 -> rho0 gamma decay
# keep only candidates with Mbc > 5.2 GeV
# and -2 < Delta E < 2 GeV
ma.reconstructDecay(decayString='B0 -> rho0 gamma:tight',
                    cut='5.2 < Mbc < 5.29 and abs(deltaE) < 2.0',
                    path=my_path)

# perform MC matching (MC truth asociation)
ma.matchMCTruth(list_name='B0', path=my_path)

# Select variables that we want to store to ntuple

gamma_vars = vc.cluster + vc.mc_truth + vc.kinematics
Exemplo n.º 24
0
                 '/mdst_000001_prod00007426_task10020000001.root'
        outfile = 'test.root'
    else:
        infile = sys.argv[1]
        outfile = sys.argv[2]

    print(f"Input = {infile}")
    print(f"Output = {outfile}")

    ma.inputMdstList('default', [infile], path=mp)

    stdPhotons('all', path=mp)
    stdPhotons('pi0eff50', path=mp)
    ma.copyList('gamma:for_pi0', 'gamma:pi0eff50', path=mp)
    ma.reconstructDecay(f'pi0:for_sigma -> gamma:for_pi0 gamma:for_pi0',
                        '0.1 < M < 0.16',
                        path=mp)

    stdPr('loose', path=mp)  # good tracks and protonID > 0.1
    ma.reconstructDecay('Sigma+:loose -> p+:loose pi0:for_sigma',
                        '1.1 < M < 1.3',
                        path=mp)
    # Have to use ipConstraint otherwise not enough degrees of freedom
    ma.vertexTree('Sigma+:loose',
                  0,
                  ipConstraint=True,
                  massConstraint=[111],
                  updateAllDaughters=False,
                  path=mp)
    ma.applyCuts('Sigma+:loose', 'abs(dM) < 0.03', path=mp)
Exemplo n.º 25
0
# 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],
              path=mp)
# M Berger: discard condidates with wrong sign of flight distance
ma.applyCuts('Sigma+:berger_loose', 'M >= 1.15 and M <= 1.225', path=mp)
ma.matchMCTruth('Sigma+:berger_loose', path=mp)
mp.add_module('VariablesToNtuple',
              particleList='Sigma+:berger_loose',
              variables=ntuple_vars,
              treeName='sigma_loose',
              fileName=sys.argv[2])
# create and fill final state ParticleLists
# use standard lists
# creates "pi+:loose" ParticleList (and c.c.)
stdc.stdPi(listtype='loose', path=my_path)
# creates "K+:loose" ParticleList (and c.c.)
stdc.stdK(listtype='loose', path=my_path)
# creates "mu+:loose" ParticleList (and c.c.)
stdc.stdMu(listtype='loose', path=my_path)

# creates "pi0:looseFit" ParticleList
stdPi0s(listtype='looseFit', path=my_path)

# 1. reconstruct D0 in multiple decay modes
ma.reconstructDecay(decayString='D0:ch1 -> K-:loose pi+:loose',
                    cut='1.8 < M < 1.9',
                    dmID=1,
                    path=my_path)
ma.reconstructDecay(decayString='D0:ch2 -> K-:loose pi+:loose pi0:looseFit',
                    cut='1.8 < M < 1.9',
                    dmID=2,
                    path=my_path)
ma.reconstructDecay(
    decayString='D0:ch3 -> K-:loose pi+:loose pi+:loose pi-:loose',
    cut='1.8 < M < 1.9',
    dmID=3,
    path=my_path)
ma.reconstructDecay(decayString='D0:ch4 -> K-:loose K+:loose',
                    cut='1.8 < M < 1.9',
                    dmID=4,
                    path=my_path)
ma.reconstructDecay(decayString='D0:ch5 -> pi-:loose pi+:loose',
Exemplo n.º 27
0
variables.addAlias(
    'gamma_E_asym',
    'abs(formula((gamma1_E - gamma2_E) / (gamma1_E + gamma2_E)))')
gamma_vars += [
    'gamma_min_E', 'gamma_phi_diff', 'gamma_theta_diff', 'gamma_E_asym',
    'gamma1_theta', 'gamma2_theta', 'gamma1_E', 'gamma2_E'
]

ntuple_vars = sigma_vars + proton_vars + pi0_vars + gamma_vars + event_vars

# Reconstruction
# ==============================================
# Standard PID cuts for charged final state particles
ma.fillParticleList('p+:good', 'pid_ppi >= 0.6 and pid_pk >= 0.6', path=mp)
ma.reconstructDecay('Sigma+:loose -> p+:good pi0:mdst',
                    '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)
Exemplo n.º 28
0
variables.addAlias('pCMS','useCMSFrame(p)')
variables.addAlias('ECMS','useCMSFrame(E)')
variables.addAlias('m12','daughterInvariantMass(0,1)')
variables.addAlias('m13','daughterInvariantMass(0,2)')
variables.addAlias('m23','daughterInvariantMass(1,2)')

main_path = b2.create_path() # Declaration of main path
bp.add_beamparameters(main_path,'Y4S')
ma.inputMdst('MC10', inputFilename, path=main_path)
sv.goodBelleKshort(path=main_path)
sg.stdPhotons('loose', path=main_path)
sc.stdPi('95eff', path=main_path)
ma.applyCuts('gamma:loose','1.4 < E < 4', path=main_path)
krescuts = " and daughterInvM(0,1,2) < 2 and daughterInvM(0,1) > 0.6 and daughterInvM(0,1) < 0.9"
#reconstructDecay(Kres+":all -> pi+:good pi-:good K_S0:all", krescuts)
ma.reconstructDecay("B0:signal -> pi+:95eff pi-:95eff K_S0:legacyGoodKS gamma:loose",
        "Mbc > 5.2 and deltaE < 0.2 and deltaE > -0.2 and  -0.65 < daughter(1, cosTheta) < 0.85"+krescuts, path=main_path)
ma.vertexRave('B0:signal',0.0001, 'B0 -> ^pi+ ^pi- ^K_S0 gamma', path=main_path)
#vertexTree('B0:signal',0.0001)

ma.rankByHighest('B0:signal',ratingVar, 1, outputVariable='myRating', path=main_path)

ma.buildRestOfEvent('B0:signal', path=main_path)


# define the "cleaner" mask
eclCut = '[E > 0.062 and abs(clusterTiming) < 18 and clusterReg==1] or \
[E>0.060 and abs(clusterTiming) < 20 and clusterReg==2] or \
[E>0.056 and abs(clusterTiming) < 44 and clusterReg==3]'
cleanMask = ('cleanMask', 'abs(d0) < 10.0 and abs(z0) < 20.0', eclCut)

# append both masks to ROE
Exemplo n.º 29
0
                   harmonicMoments=False,
                   allMoments=False,
                   collisionAxis=False,
                   sphericity=False,
                   thrust=True,
                   path=my_path)
ma.buildEventKinematics(['e-:good', 'pi-:good', 'mu+:mugood'], path=my_path)

# Get information of the generated decay mode calling labelTauPairMC from modular analysis
ma.labelTauPairMC(path=my_path)

######################################################
# Signal and tag sides
#######################################################

ma.reconstructDecay('tau+:signal -> mu+:mugood', '', path=my_path)

if tauMinus == '1':
    ma.reconstructDecay('tau-:tag -> e-:good', 'charge == -1', path=my_path)
    decay_chain = 'vpho -> [^tau+ -> ^mu+] [^tau- -> ^e-]'
    ma.reconstructDecay('vpho:photon_B2SS -> tau+:signal tau-:tag',
                        'tauPlusMCMode == 2 and tauMinusMCMode == 1',
                        path=my_path)

if tauMinus == '3':
    ma.reconstructDecay('tau-:tag -> pi-:good', 'charge == -1', path=my_path)
    decay_chain = 'vpho -> [^tau+ -> ^mu+] [^tau- -> ^pi-]'
    ma.reconstructDecay('vpho:photon_B2SS -> tau+:signal tau-:tag',
                        'tauPlusMCMode == 2 and tauMinusMCMode == 3',
                        path=my_path)
Exemplo n.º 30
0
ma.looseMCTruth(list_name='e+:uncorrected', path=my_path)
ma.looseMCTruth(list_name='gamma:all', path=my_path)

# fsr correction
ma.correctFSR(outputListName='e+:corrected',
              inputListName='e+:uncorrected',
              gammaListName='gamma:all',
              angleThreshold=5.0,
              energyThreshold=1.0,
              writeOut=False,
              path=my_path)
ma.looseMCTruth(list_name='e+:corrected', path=my_path)

# uncorrected
ma.reconstructDecay(
    decayString='J/psi:uncorrected -> e+:uncorrected e-:uncorrected',
    cut='',
    path=my_path)
ma.reconstructDecay(decayString='J/psi:corrected -> e+:corrected e-:corrected',
                    cut='',
                    path=my_path)

# loose MC matching
ma.looseMCTruth(list_name='J/psi:uncorrected', path=my_path)
ma.looseMCTruth(list_name='J/psi:corrected', path=my_path)

# get all MC particles
ma.fillParticleListFromMC(decayString='J/psi:MC', cut="", path=my_path)

# write out ntuples

# Please note, a new lepton is generated, with the old electron and -if found- a gamma as daughters.