Belle II Software  release-08-01-10
019_first_steering_file.py
1 #!/usr/bin/env python3
2 
3 import sys
4 import basf2 as b2
5 import modularAnalysis as ma
6 import stdV0s
7 import variables.collections as vc
8 import variables.utils as vu
9 
10 # get input file number from the command line
11 filenumber = sys.argv[1]
12 
13 # create path
14 main = b2.Path()
15 
16 # load input data from mdst/udst file
17 ma.inputMdstList(
18  filelist=[b2.find_file(f"starterkit/2021/1111540100_eph3_BGx0_{filenumber}.root", "examples")],
19  path=main,
20 )
21 
22 # fill final state particle lists
23 ma.fillParticleList(
24  "e+:uncorrected",
25  "electronID > 0.1 and dr < 0.5 and abs(dz) < 2 and thetaInCDCAcceptance",
26  path=main,
27 )
28 stdV0s.stdKshorts(path=main)
29 
30 # combine final state particles to form composite particles
31 ma.reconstructDecay(
32  "J/psi:ee -> e+:uncorrected e-:uncorrected", cut="dM < 0.11", path=main
33 )
34 
35 # combine J/psi and KS candidates to form B0 candidates
36 ma.reconstructDecay(
37  "B0 -> J/psi:ee K_S0:merged",
38  cut="Mbc > 5.2 and abs(deltaE) < 0.15",
39  path=main,
40 )
41 
42 # match reconstructed with MC particles
43 ma.matchMCTruth("B0", path=main)
44 
45 # create list of variables to save into the output file
46 b_vars = []
47 
48 standard_vars = vc.kinematics + vc.mc_kinematics + vc.mc_truth
49 b_vars += vc.deltae_mbc
50 b_vars += standard_vars
51 
52 # variables for final states (electrons, positrons, pions) [S50]
53 fs_vars = vc.pid + vc.track + vc.track_hits + standard_vars
54 b_vars += vu.create_aliases_for_selected(
55  fs_vars,
56  "B0 -> [J/psi -> ^e+ ^e-] [K_S0 -> ^pi+ ^pi-]",
57  prefix=["ep", "em", "pip", "pim"],
58 ) # [E50]
59 
60 # variables for J/Psi, KS
61 jpsi_ks_vars = vc.inv_mass + standard_vars
62 b_vars += vu.create_aliases_for_selected(jpsi_ks_vars, "B0 -> ^J/psi ^K_S0")
63 
64 # also add kinematic variables boosted to the center of mass frame (CMS) [S60]
65 # for all particles
66 cmskinematics = vu.create_aliases(
67  vc.kinematics, "useCMSFrame({variable})", "CMS"
68 ) # [E60]
69 b_vars += vu.create_aliases_for_selected(
70  cmskinematics, "^B0 -> [^J/psi -> ^e+ ^e-] [^K_S0 -> ^pi+ ^pi-]"
71 )
72 
73 # save variables to an output file (ntuple)
74 ma.variablesToNtuple(
75  "B0",
76  variables=b_vars,
77  filename="Bd2JpsiKS.root",
78  treename="tree",
79  path=main,
80 )
81 
82 # start the event loop (actually start processing things)
83 b2.process(main)
84 
85 # print out the summary
86 print(b2.statistics)
def stdKshorts(prioritiseV0=True, fitter='TreeFit', path=None, updateAllDaughters=False, writeOut=False)
Definition: stdV0s.py:17