Belle II Software development
029_roe.py
1#!/usr/bin/env python3
2
3import sys
4import basf2 as b2
5import modularAnalysis as ma
6import stdV0s
7import variables.collections as vc
8import variables.utils as vu
9
10# get input file number from the command line
11filenumber = sys.argv[1]
12
13# create path
14main = b2.Path()
15
16# load input data from mdst/udst file
17ma.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
23ma.fillParticleList(
24 "e+:uncorrected",
25 "electronID > 0.1 and dr < 0.5 and abs(dz) < 2 and thetaInCDCAcceptance",
26 path=main,
27)
28stdV0s.stdKshorts(path=main)
29
30# combine final state particles to form composite particles
31ma.reconstructDecay(
32 "J/psi:ee -> e+:uncorrected e-:uncorrected", cut="abs(dM) < 0.11", path=main
33)
34
35# combine J/psi and KS candidates to form B0 candidates
36ma.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
43ma.matchMCTruth("B0", path=main)
44
45# build the rest of the event [S10|S30|S40]
46ma.buildRestOfEvent("B0", fillWithMostLikely=True, path=main) # [E10]
47track_based_cuts = "thetaInCDCAcceptance and pt > 0.075 and dr < 5 and abs(dz) < 10"
48ecl_based_cuts = "thetaInCDCAcceptance and E > 0.05" # [E30]
49roe_mask = ("my_mask", track_based_cuts, ecl_based_cuts)
50ma.appendROEMasks("B0", [roe_mask], path=main) # [E40]
51
52# Create list of variables to save into the output file
53b_vars = []
54
55standard_vars = vc.kinematics + vc.mc_kinematics + vc.mc_truth
56b_vars += vc.deltae_mbc
57b_vars += standard_vars
58
59# ROE variables [S20|S50]
60roe_kinematics = ["roeE()", "roeM()", "roeP()", "roeMbc()", "roeDeltae()"]
61roe_multiplicities = [
62 "nROE_Charged()",
63 "nROE_Photons()",
64 "nROE_NeutralHadrons()",
65]
66b_vars += roe_kinematics + roe_multiplicities # [E20]
67# Let's also add a version of the ROE variables that includes the mask:
68for roe_variable in roe_kinematics + roe_multiplicities:
69 # e.g. instead of 'roeE()' (no mask) we want 'roeE(my_mask)'
70 roe_variable_with_mask = roe_variable.replace("()", "(my_mask)")
71 b_vars.append(roe_variable_with_mask) # [E50]
72
73# Variables for final states (electrons, positrons, pions)
74fs_vars = vc.pid + vc.track + vc.track_hits + standard_vars
75b_vars += vu.create_aliases_for_selected(
76 fs_vars,
77 "B0 -> [J/psi -> ^e+ ^e-] [K_S0 -> ^pi+ ^pi-]",
78 prefix=["ep", "em", "pip", "pim"],
79)
80# Variables for J/Psi, KS
81jpsi_ks_vars = vc.inv_mass + standard_vars
82b_vars += vu.create_aliases_for_selected(jpsi_ks_vars, "B0 -> ^J/psi ^K_S0")
83# Also add kinematic variables boosted to the center of mass frame (CMS)
84# for all particles
85cmskinematics = vu.create_aliases(
86 vc.kinematics, "useCMSFrame({variable})", "CMS"
87)
88b_vars += vu.create_aliases_for_selected(
89 cmskinematics, "^B0 -> [^J/psi -> ^e+ ^e-] [^K_S0 -> ^pi+ ^pi-]"
90)
91
92# Save variables to an output file (ntuple)
93ma.variablesToNtuple(
94 "B0",
95 variables=b_vars,
96 filename="Bd2JpsiKS.root",
97 treename="tree",
98 path=main,
99)
100
101# Start the event loop (actually start processing things)
102b2.process(main)
103
104# print out the summary
105print(b2.statistics)
def stdKshorts(prioritiseV0=True, fitter='TreeFit', path=None, updateAllDaughters=False, writeOut=False)
Definition: stdV0s.py:17