Belle II Software  release-06-01-15
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  environmentType="default",
19  filelist=[b2.find_file(f"starterkit/2021/1111540100_eph3_BGx0_{filenumber}.root", "examples")],
20  path=main,
21 )
22 
23 # fill final state particle lists
24 ma.fillParticleList(
25  "e+:uncorrected",
26  "electronID > 0.1 and dr < 0.5 and abs(dz) < 2 and thetaInCDCAcceptance",
27  path=main,
28 )
29 stdV0s.stdKshorts(path=main)
30 
31 # combine final state particles to form composite particles
32 ma.reconstructDecay(
33  "J/psi:ee -> e+:uncorrected e-:uncorrected", cut="dM < 0.11", path=main
34 )
35 
36 # combine J/psi and KS candidates to form B0 candidates
37 ma.reconstructDecay(
38  "B0 -> J/psi:ee K_S0:merged",
39  cut="Mbc > 5.2 and abs(deltaE) < 0.15",
40  path=main,
41 )
42 
43 # match reconstructed with MC particles
44 ma.matchMCTruth("B0", path=main)
45 
46 # Create list of variables to save into the output file
47 b_vars = []
48 
49 standard_vars = vc.kinematics + vc.mc_kinematics + vc.mc_truth
50 b_vars += vc.deltae_mbc
51 b_vars += standard_vars
52 
53 # Variables for final states (electrons, positrons, pions)
54 fs_vars = vc.pid + vc.track + vc.track_hits + standard_vars
55 b_vars += vu.create_aliases_for_selected(
56  fs_vars,
57  "B0 -> [J/psi -> ^e+ ^e-] [K_S0 -> ^pi+ ^pi-]",
58  prefix=["ep", "em", "pip", "pim"],
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 # Also add kinematic variables boosted to the center of mass frame (CMS)
64 # for all particles
65 cmskinematics = vu.create_aliases(
66  vc.kinematics, "useCMSFrame({variable})", "CMS"
67 )
68 b_vars += vu.create_aliases_for_selected(
69  cmskinematics, "^B0 -> [^J/psi -> ^e+ ^e-] [^K_S0 -> ^pi+ ^pi-]"
70 )
71 
72 # Save variables to an output file (ntuple)
73 ma.variablesToNtuple(
74  "B0",
75  variables=b_vars,
76  filename="Bd2JpsiKS.root",
77  treename="tree",
78  path=main,
79 )
80 
81 # Start the event loop (actually start processing things)
82 b2.process(main)
83 
84 # print out the summary
85 print(b2.statistics)
def stdKshorts(prioritiseV0=True, fitter='TreeFit', path=None)
Definition: stdV0s.py:17