Belle II Software development
b2bii_example.py
1#!/usr/bin/env python3
2
3
10
11import os
12
13import basf2 as b2
14import modularAnalysis as ma
15import variables as va
16import variables.collections as vc
17import variables.utils as vu
18from b2biiConversion import convertBelleMdstToBelleIIMdst
19
20os.environ["USE_GRAND_REPROCESS_DATA"] = "1"
21os.environ["PGUSER"] = "g0db"
22
23# Convert
24main = b2.create_path()
25inputfile = b2.find_file(
26 "b2bii_input_evtgen_exp_07_BptoD0pip-D0toKpipi0-0.mdst", "examples", False
27)
28convertBelleMdstToBelleIIMdst(inputfile, path=main)
29
30# Only charged final state particles need to be loaded. The neutral particles
31# gamma, pi0, K_S0, K_L0, and Lambda0 are already loaded to the 'gamma:mdst',
32# 'pi0:mdst', 'K_S0:mdst', 'K_L0:mdst', and 'Lambda0:mdst' particle lists,
33# respectively.
34ma.fillParticleList("pi+:sig", "atcPIDBelle(3,2)<0.4", path=main)
35ma.fillParticleList("K+:sig", "atcPIDBelle(3,2)>0.6", path=main)
36
37# The Belle PID variables are: atcPIDBelle(sigHyp, bkgHyp), muIDBelle, and eIDBelle
38va.variables.addAlias("Lkpi", "atcPIDBelle(3,2)")
39
40# Now, let's really reconstruct a B decay with an intermediate D meson:
41ma.reconstructDecay(
42 "D0:Kpipi0 -> K-:sig pi+:sig pi0:mdst", cut="1.7 < M < 2.0", path=main
43)
44ma.reconstructDecay(
45 "B+:D0pi -> anti-D0:Kpipi0 pi+:sig",
46 cut="4.8 < Mbc >5.2 and abs(deltaE) < 0.15",
47 path=main,
48)
49
50ma.matchMCTruth("B+:D0pi", path=main)
51
52# create and fill flat Ntuple with MCTruth and kinematic information
53# Create list of variables to save into the output file
54b_vars = []
55
56standard_vars = vc.kinematics + vc.mc_kinematics + vc.mc_truth + vc.inv_mass
57b_vars += vc.deltae_mbc
58b_vars += standard_vars
59
60# Variables for D0 and all final state particles (kaons, pions, neutral pions)
61b_vars += vu.create_aliases_for_selected(
62 standard_vars,
63 "B+ -> [ ^D0 -> ^K- ^pi+ ^pi0] ^pi+",
64 prefix=["D0", "K", "pip1", "pi0", "pip2"],
65)
66
67# Variables for charged final states (kaons, pions)
68belle1pid = (
69 ["eIDBelle", "muIDBelleQuality", "muIDBelle", "Lkpi"]
70 + vc.track
71 + vc.track_hits
72)
73
74b_vars += vu.create_aliases_for_selected(
75 belle1pid, "B+ -> [ D0 -> ^K- ^pi+ pi0] ^pi+", prefix=["K", "pip1", "pip2"]
76)
77
78ma.variablesToNtuple(
79 "B+:D0pi", b_vars, filename="B2BII_B2D0pi_D2Kpipi0.root", path=main
80)
81
82# progress
83main.add_module("Progress")
84
85b2.process(main)
86
87# Print call statistics
88print(b2.statistics)