Belle II Software development
B2A913-CharmFlavorTagger.py
1#!/usr/bin/env python3
2
3
10
11
25
26import basf2 as b2
27import modularAnalysis as ma
28import charmFlavorTagger as cft
29import variables.collections as vc
30import variables.utils as vu
31
32
33# create path
34cft_path = b2.Path()
35
36# append analysis global tag where the CFT payload is stored
37# b2.conditions.append_globaltag(ma.getAnalysisGlobaltag())
38b2.conditions.append_globaltag("analysis_tools_light-2504-deimos")
39
40# load input ROOT file
41ma.inputMdst(filename=b2.find_file('Dst2D0pi.root', 'examples', False),
42 path=cft_path)
43
44# create pion and kaon particle lists
45ma.fillParticleList(
46 "pi+:D0", "thetaInCDCAcceptance and dr < 1 and abs(dz) < 3 and pionID>0.1", path=cft_path
47)
48ma.fillParticleList(
49 "K+:D0", "thetaInCDCAcceptance and dr < 1 and abs(dz) < 3 and kaonID>0.1", path=cft_path
50)
51
52# reconstruct D0 signal candidates
53ma.reconstructDecay(
54 decayString="D0:sig -> K-:D0 pi+:D0",
55 cut="1.8 < InvM < 1.9",
56 path=cft_path,
57)
58
59# Does the matching between reconstructed and MC particles
60ma.matchMCTruth(list_name='D0:sig', path=cft_path)
61
62# build the rest of the event associated to the D0
63ma.buildRestOfEvent(target_list_name='D0:sig',
64 path=cft_path)
65
66# Charm Flavor Tagging Function.
67cft.charmFlavorTagger(
68 'D0:sig',
69 path=cft_path)
70
71# Select variables that will be stored to ntuple
72d_vars = vc.kinematics+vc.mc_truth+["CFT_qr", "CFT_prob"]
73d_vars += vu.create_aliases_for_selected(
74 list_of_variables=vc.kinematics
75 + vc.mc_truth,
76 decay_string="D0 -> ^K- ^pi+",
77)
78
79# Saving variables to ntuple
80output_file = 'B2A913-CharmFlavorTagger.root'
81ma.variablesToNtuple(decayString='D0:sig',
82 variables=d_vars,
83 filename=output_file,
84 treename='D0tree',
85 path=cft_path)
86
87# Process the events
88b2.process(cft_path)
89
90# print out the summary
91print(b2.statistics)