Belle II Software  release-08-01-10
B2A913-CharmFlavorTagger.py
1 #!/usr/bin/env python3
2 
3 
10 
11 
25 
26 import basf2 as b2
27 import modularAnalysis as ma
28 import charmFlavorTagger as cft
29 import variables.collections as vc
30 import variables.utils as vu
31 
32 
33 # create path
34 cft_path = b2.Path()
35 
36 # append analysis global tag where the CFT payload is stored
37 b2.conditions.append_globaltag('analysis_tools_light-2302-genetta')
38 
39 # load input ROOT file
40 ma.inputMdst(filename=b2.find_file('Dst2D0pi.root', 'examples', False),
41  path=cft_path)
42 
43 # create pion and kaon particle lists
44 ma.fillParticleList(
45  "pi+:D0", "thetaInCDCAcceptance and dr < 1 and abs(dz) < 3 and pionID>0.1", path=cft_path
46 )
47 ma.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
52 ma.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
59 ma.matchMCTruth(list_name='D0:sig', path=cft_path)
60 
61 # build the rest of the event associated to the D0
62 ma.buildRestOfEvent(target_list_name='D0:sig',
63  path=cft_path)
64 
65 # Charm Flavor Tagging Function.
66 cft.charmFlavorTagger(
67  'D0:sig',
68  path=cft_path)
69 
70 # Select variables that will be stored to ntuple
71 d_vars = vc.kinematics+vc.mc_truth+["CFT_qr","CFT_prob"]
72 d_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
79 output_file = 'B2A913-CharmFlavorTagger.root'
80 ma.variablesToNtuple(decayString='D0:sig',
81  variables=d_vars,
82  filename=output_file,
83  treename='D0tree',
84  path=cft_path)
85 
86 # Process the events
87 b2.process(cft_path)
88 
89 # print out the summary
90 print(b2.statistics)
91