Ejemplo n.º 1
0
# create list of variables for output ntuple
standard_vars = vc.kinematics + vc.mc_kinematics + vc.mc_truth
fs_vars = vc.pid + vc.track + vc.track_hits + standard_vars
jpsi_ks_vars = vc.inv_mass + vc.vertex + vc.mc_vertex + standard_vars
b_vars = vc.deltae_mbc + vc.tag_vertex + vc.mc_tag_vertex + ft.flavor_tagging + standard_vars

b_vars += vu.create_aliases_for_selected([*fs_vars, 'isBremsCorrected'],
                                         'B0 -> [J/psi -> ^e+ ^e-] K_S0',
                                         prefix=['ep', 'em'])
b_vars += vu.create_aliases_for_selected(fs_vars,
                                         'B0 -> J/psi [K_S0 -> ^pi+ ^pi-]',
                                         prefix=['pip', 'pim'])
b_vars += vu.create_aliases_for_selected(jpsi_ks_vars, 'B0 -> ^J/psi ^K_S0')

cmskinematics = vu.create_aliases(vc.kinematics, 'useCMSFrame({variable})',
                                  'CMS')
b_vars += vu.create_aliases_for_selected(
    cmskinematics, '^B0 -> [^J/psi -> ^e+ ^e-] [^K_S0 -> ^pi+ ^pi-]')

variables.addAlias(
    'withBremsCorrection',
    'passesCut(passesCut(ep_isBremsCorrected == 1) or passesCut(em_isBremsCorrected == 1))'
)
b_vars += ['withBremsCorrection']

# save variables to an ntuple
ma.variablesToNtuple('B0',
                     variables=b_vars,
                     filename='Bd2JpsiKS_ee.root',
                     treename='tree',
                     path=main)
Ejemplo n.º 2
0
    vc.kinematics + \
    vc.inv_mass

pi_vars = vc.track

b_vars = vc.kinematics + \
    vc.deltae_mbc + \
    vc.mc_truth + \
    vu.create_aliases_for_selected(list_of_variables=gamma_vars,
                                   decay_string='B0 -> rho0 ^gamma') + \
    vu.create_aliases_for_selected(list_of_variables=rho_vars,
                                   decay_string='B0 -> ^rho0 gamma') + \
    vu.create_aliases_for_selected(list_of_variables=rho_vars,
                                   decay_string='B0 -> [rho0 -> ^pi+ ^pi-] gamma') + \
    vu.create_aliases(list_of_variables=['Pi0_Prob', 'Eta_Prob', 'pi0veto'],
                      wrapper='extraInfo(variable)',
                      prefix="B")

# Saving variables to ntuple
rootOutputFile = "B2A306-B02RhoGamma-withPi0EtaVeto.root"
ma.variablesToNtuple(decayString='B0',
                     variables=b_vars,
                     filename=rootOutputFile,
                     treename='b0',
                     path=my_path)

# Process the events
b2.process(my_path)

# print out the summary
print(b2.statistics)
                    path=my_path)

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

# 5. build rest of the event
ma.buildRestOfEvent(target_list_name='Upsilon(4S)', path=my_path)

# 6. Select variables that we want to store to ntuple
d_vars = vc.mc_truth + vc.kinematics + vc.inv_mass
b_vars = vc.mc_truth + \
    vc.deltae_mbc + \
    vu.create_aliases_for_selected(list_of_variables=d_vars,
                                   decay_string='B- -> ^D0 pi-') + \
    vu.create_aliases(list_of_variables=['decayModeID'],
                      wrapper='daughter(0,extraInfo(variable))',
                      prefix="D")
mu_vars = vc.mc_truth

u4s_vars = vc.mc_truth + \
    vc.roe_multiplicities + \
    vc.recoil_kinematics + \
    vc.kinematics + \
    vu.create_aliases_for_selected(list_of_variables=b_vars,
                                   decay_string='Upsilon(4S) -> ^B- mu+') + \
    vu.create_aliases_for_selected(list_of_variables=mu_vars,
                                   decay_string='Upsilon(4S) -> B- ^mu+')

# 7. Saving variables to ntuple
rootOutputFile = 'B2A305-Btag+SingleMuon-Reconstruction.root'
ma.variablesToNtuple(decayString='B-:tag',
Ejemplo n.º 4
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)