Belle II Software  release-08-01-10
B2A201-LoadMCParticles.py
1 #!/usr/bin/env python3
2 
3 
10 
11 
31 
32 import basf2 as b2
33 import modularAnalysis as ma
34 
35 # create path
36 my_path = b2.create_path()
37 
38 # load input ROOT file
39 ma.inputMdst(filename=b2.find_file('B2pi0D_D2hh_D2hhh_B2munu_evtgen.root', 'examples', False),
40  path=my_path)
41 
42 # print contents of the DataStore before loading MCParticles
43 ma.printDataStore(path=my_path)
44 
45 # create and fill gamma/e/mu/pi/K/p ParticleLists
46 # second argument are the selection criteria: '' means no cut, take all
47 photons = ('gamma:gen', '')
48 electrons = ('e-:gen', '')
49 muons = ('mu-:gen', '')
50 pions = ('pi-:gen', '')
51 kaons = ('K-:gen', '')
52 protons = ('anti-p-:gen', '')
53 
54 ma.fillParticleListsFromMC([photons, electrons, muons, pions, kaons, protons], path=my_path)
55 
56 # print contents of the DataStore after loading MCParticles
57 # the difference is that DataStore now contains StoreArray<Particle>
58 # filled with Particles created from generated final state particles
59 ma.printDataStore(path=my_path)
60 
61 # print out the contents of each ParticleList
62 ma.printList(list_name='gamma:gen', full=False, path=my_path)
63 ma.printList(list_name='e-:gen', full=False, path=my_path)
64 ma.printList(list_name='mu-:gen', full=False, path=my_path)
65 ma.printList(list_name='pi-:gen', full=False, path=my_path)
66 ma.printList(list_name='K-:gen', full=False, path=my_path)
67 ma.printList(list_name='anti-p-:gen', full=False, path=my_path)
68 
69 # Process the events
70 b2.process(my_path)
71 
72 # print out the summary
73 print(b2.statistics)