Belle II Software  release-06-00-14
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(environmentType='default',
40  filename=b2.find_file('B2pi0D_D2hh_D2hhh_B2munu.root', 'examples', False),
41  path=my_path)
42 
43 # print contents of the DataStore before loading MCParticles
44 ma.printDataStore(path=my_path)
45 
46 # create and fill gamma/e/mu/pi/K/p ParticleLists
47 # second argument are the selection criteria: '' means no cut, take all
48 photons = ('gamma:gen', '')
49 electrons = ('e-:gen', '')
50 muons = ('mu-:gen', '')
51 pions = ('pi-:gen', '')
52 kaons = ('K-:gen', '')
53 protons = ('anti-p-:gen', '')
54 
55 ma.fillParticleListsFromMC([photons, electrons, muons, pions, kaons, protons], path=my_path)
56 
57 # print contents of the DataStore after loading MCParticles
58 # the difference is that DataStore now contains StoreArray<Particle>
59 # filled with Particles created from generated final state particles
60 ma.printDataStore(path=my_path)
61 
62 # print out the contents of each ParticleList
63 ma.printList(list_name='gamma:gen', full=False, path=my_path)
64 ma.printList(list_name='e-:gen', full=False, path=my_path)
65 ma.printList(list_name='mu-:gen', full=False, path=my_path)
66 ma.printList(list_name='pi-:gen', full=False, path=my_path)
67 ma.printList(list_name='K-:gen', full=False, path=my_path)
68 ma.printList(list_name='anti-p-:gen', full=False, path=my_path)
69 
70 # Process the events
71 b2.process(my_path)
72 
73 # print out the summary
74 print(b2.statistics)