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