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
37b2.conditions.append_globaltag(ma.getAnalysisGlobaltag())
38
39# load input ROOT file
40ma.inputMdst(filename=b2.find_file('Dst2D0pi.root', 'examples', False),
41 path=cft_path)
42
43# create pion and kaon particle lists
44ma.fillParticleList(
45 "pi+:D0", "thetaInCDCAcceptance and dr < 1 and abs(dz) < 3 and pionID>0.1", path=cft_path
46)
47ma.fillParticleList(
48 "K+:D0", "thetaInCDCAcceptance and dr < 1 and abs(dz) < 3 and kaonID>0.1", path=cft_path
49)
50
51# reconstruct D0 signal candidates
52ma.reconstructDecay(
53 decayString="D0:sig -> K-:D0 pi+:D0",
54 cut="1.8 < InvM < 1.9",
55 path=cft_path,
56)
57
58# Does the matching between reconstructed and MC particles
59ma.matchMCTruth(list_name='D0:sig', path=cft_path)
60
61# build the rest of the event associated to the D0
62ma.buildRestOfEvent(target_list_name='D0:sig',
63 path=cft_path)
64
65# Charm Flavor Tagging Function.
66cft.charmFlavorTagger(
67 'D0:sig',
68 path=cft_path)
69
70# Select variables that will be stored to ntuple
71d_vars = vc.kinematics+vc.mc_truth+["CFT_qr", "CFT_prob"]
72d_vars += vu.create_aliases_for_selected(
73 list_of_variables=vc.kinematics
74 + vc.mc_truth,
75 decay_string="D0 -> ^K- ^pi+",
76)
77
78# Saving variables to ntuple
79output_file = 'B2A913-CharmFlavorTagger.root'
80ma.variablesToNtuple(decayString='D0:sig',
81 variables=d_vars,
82 filename=output_file,
83 treename='D0tree',
84 path=cft_path)
85
86# Process the events
87b2.process(cft_path)
88
89# print out the summary
90print(b2.statistics)