Belle II Software  release-05-01-25
reconstructMCDecay.py
1 #!/usr/bin/env python3
2 
3 # Doxygen should skip this script
4 # @cond
5 
6 """
7 An example script to find a specific decay chain at MC level.
8 """
9 
10 __authors__ = "Yo Sato"
11 
12 import basf2
13 from ROOT import Belle2
14 from modularAnalysis import inputMdst, fillParticleListFromMC, variablesToNtuple, reconstructMCDecay, fillParticleList
15 from variables import variables as vm # shorthand for the variable manager instance
16 
17 basf2.set_log_level(basf2.LogLevel.DEBUG)
18 
19 mypath = basf2.create_path()
20 testinput = Belle2.FileSystem.findFile('analysis/tests/mdst.root')
21 inputMdst("default", testinput, path=mypath)
22 
23 fillParticleListFromMC('K+:MC', 'mcPrimary', path=mypath)
24 fillParticleListFromMC('pi+:MC', 'mcPrimary', path=mypath)
25 fillParticleListFromMC('e+:MC', 'mcPrimary', path=mypath)
26 fillParticleListFromMC('nu_e:MC', 'mcPrimary', path=mypath)
27 fillParticleListFromMC('gamma:MC', 'mcPrimary', path=mypath)
28 
29 reconstructMCDecay('pi0:gg =direct=> gamma:MC gamma:MC', '', path=mypath)
31  'B+:DstENu =direct=> [anti-D*0 =direct=> [anti-D0 =direct=> K+:MC pi-:MC pi0:gg] pi0:gg ] e+:MC nu_e:MC ',
32  '',
33  path=mypath)
34 
35 
36 # One can directly reconstruct pi0:gg in same decay string as following.
37 # But in this case, one has to write sub-decay only once. Otherwise same particles are registered twice.
38 #
39 # reconstructMCDecay(
40 # 'B+:DstENu =direct=>\
41 # [anti-D*0 =direct=> [anti-D0 =direct=> K+:MC pi-:MC [pi0:gg =direct=> gamma:MC gamma:MC]] pi0:gg ]\
42 # e+:MC nu_e:MC ',
43 # '',
44 # path=mypath)
45 
46 
47 interesting_variables = ['isSignal', "Mbc", "deltaE", "mcErrors"]
48 
49 vm.printAliases()
50 
51 variablesToNtuple("B+:DstENu", interesting_variables, path=mypath)
52 
53 basf2.process(mypath)
54 print(basf2.statistics)
55 
56 # @endcond
reconstructMCDecay
Definition: reconstructMCDecay.py:1
variablesToNtuple
Definition: variablesToNtuple.py:1
basf2.process
def process(path, max_event=0)
Definition: __init__.py:25
Belle2::FileSystem::findFile
static std::string findFile(const std::string &path, bool silent=false)
Search for given file or directory in local or central release directory, and return absolute path if...
Definition: FileSystem.cc:147