Belle II Software  release-08-01-10
ntupleUpsilon4SGenInfo.py
1 #!/usr/bin/env python
2 
3 
10 
11 """
12 make Upsilon(4S) ntuple for checks and studies of the generator file:
13 particles: Upsilon(4S), two daughters (i.e. BBbar) and four granddaughters (e.g. B0->Jpsi+K0S)
14 variables: mcPDG,M,nDaughters,mcDecayTime,mcLifeTime,mcX,mcY,mcZ,mcE,mcPX,mcPY,mcPZ;
15 """
16 
17 import basf2 as b2
18 import modularAnalysis as ma
19 from variables import variables
20 import sys
21 
22 variables.addAlias('B00_mcPDG', 'daughter(0, mcPDG)')
23 variables.addAlias('B00_M', 'daughter(0, M)')
24 variables.addAlias('B00_nDaughters', 'daughter(0, nDaughters)')
25 variables.addAlias('B00_mcDecayTime', 'daughter(0, mcDecayTime)')
26 variables.addAlias('B00_mcLifeTime', 'daughter(0, mcLifeTime)')
27 variables.addAlias('B00_mcX', 'daughter(0, mcDecayVertexX)')
28 variables.addAlias('B00_mcY', 'daughter(0, mcDecayVertexY)')
29 variables.addAlias('B00_mcZ', 'daughter(0, mcDecayVertexZ)')
30 variables.addAlias('B00_mcE', 'daughter(0, mcE)')
31 variables.addAlias('B00_mcPX', 'daughter(0, mcPX)')
32 variables.addAlias('B00_mcPY', 'daughter(0, mcPY)')
33 variables.addAlias('B00_mcPZ', 'daughter(0, mcPZ)')
34 
35 variables.addAlias('B00_daughter0_mcPDG', 'daughter(0, daughter(0, mcPDG))')
36 variables.addAlias('B00_daughter0_M', 'daughter(0, daughter(0, M))')
37 variables.addAlias('B00_daughter0_nDaughters', 'daughter(0, daughter(0, nDaughters))')
38 variables.addAlias('B00_daughter0_mcDecayTime', 'daughter(0, daughter(0, mcDecayTime))')
39 variables.addAlias('B00_daughter0_mcLifeTime', 'daughter(0, daughter(0, mcLifeTime))')
40 variables.addAlias('B00_daughter0_mcX', 'daughter(0, daughter(0, mcDecayVertexX))')
41 variables.addAlias('B00_daughter0_mcY', 'daughter(0, daughter(0, mcDecayVertexY))')
42 variables.addAlias('B00_daughter0_mcZ', 'daughter(0, daughter(0, mcDecayVertexZ))')
43 variables.addAlias('B00_daughter0_mcE', 'daughter(0, daughter(0, mcE))')
44 variables.addAlias('B00_daughter0_mcPX', 'daughter(0, daughter(0, mcPX))')
45 variables.addAlias('B00_daughter0_mcPY', 'daughter(0, daughter(0, mcPY))')
46 variables.addAlias('B00_daughter0_mcPZ', 'daughter(0, daughter(0, mcPZ))')
47 
48 variables.addAlias('B00_daughter1_mcPDG', 'daughter(0, daughter(1, mcPDG))')
49 variables.addAlias('B00_daughter1_M', 'daughter(0, daughter(1, M))')
50 variables.addAlias('B00_daughter1_nDaughters', 'daughter(0, daughter(1, nDaughters))')
51 variables.addAlias('B00_daughter1_mcDecayTime', 'daughter(0, daughter(1, mcDecayTime))')
52 variables.addAlias('B00_daughter1_mcLifeTime', 'daughter(0, daughter(1, mcLifeTime))')
53 variables.addAlias('B00_daughter1_mcX', 'daughter(0, daughter(1, mcDecayVertexX))')
54 variables.addAlias('B00_daughter1_mcY', 'daughter(0, daughter(1, mcDecayVertexY))')
55 variables.addAlias('B00_daughter1_mcZ', 'daughter(0, daughter(1, mcDecayVertexZ))')
56 variables.addAlias('B00_daughter1_mcE', 'daughter(0, daughter(1, mcE))')
57 variables.addAlias('B00_daughter1_mcPX', 'daughter(0, daughter(1, mcPX))')
58 variables.addAlias('B00_daughter1_mcPY', 'daughter(0, daughter(1, mcPY))')
59 variables.addAlias('B00_daughter1_mcPZ', 'daughter(0, daughter(1, mcPZ))')
60 
61 variables.addAlias('B01_mcPDG', 'daughter(1, mcPDG)')
62 variables.addAlias('B01_M', 'daughter(1, M)')
63 variables.addAlias('B01_nDaughters', 'daughter(1, nDaughters)')
64 variables.addAlias('B01_mcDecayTime', 'daughter(1, mcDecayTime)')
65 variables.addAlias('B01_mcLifeTime', 'daughter(1, mcLifeTime)')
66 variables.addAlias('B01_mcX', 'daughter(1, mcDecayVertexX)')
67 variables.addAlias('B01_mcY', 'daughter(1, mcDecayVertexY)')
68 variables.addAlias('B01_mcZ', 'daughter(1, mcDecayVertexZ)')
69 variables.addAlias('B01_mcE', 'daughter(1, mcE)')
70 variables.addAlias('B01_mcPX', 'daughter(1, mcPX)')
71 variables.addAlias('B01_mcPY', 'daughter(1, mcPY)')
72 variables.addAlias('B01_mcPZ', 'daughter(1, mcPZ)')
73 
74 variables.addAlias('B01_daughter0_mcPDG', 'daughter(1, daughter(0, mcPDG))')
75 variables.addAlias('B01_daughter0_M', 'daughter(1, daughter(0, M))')
76 variables.addAlias('B01_daughter0_nDaughters', 'daughter(1, daughter(0, nDaughters))')
77 variables.addAlias('B01_daughter0_mcDecayTime', 'daughter(1, daughter(0, mcDecayTime))')
78 variables.addAlias('B01_daughter0_mcLifeTime', 'daughter(1, daughter(0, mcLifeTime))')
79 variables.addAlias('B01_daughter0_mcX', 'daughter(1, daughter(0, mcDecayVertexX))')
80 variables.addAlias('B01_daughter0_mcY', 'daughter(1, daughter(0, mcDecayVertexY))')
81 variables.addAlias('B01_daughter0_mcZ', 'daughter(1, daughter(0, mcDecayVertexZ))')
82 variables.addAlias('B01_daughter0_mcE', 'daughter(1, daughter(0, mcE))')
83 variables.addAlias('B01_daughter0_mcPX', 'daughter(1, daughter(0, mcPX))')
84 variables.addAlias('B01_daughter0_mcPY', 'daughter(1, daughter(0, mcPY))')
85 variables.addAlias('B01_daughter0_mcPZ', 'daughter(1, daughter(0, mcPZ))')
86 
87 variables.addAlias('B01_daughter1_mcPDG', 'daughter(1, daughter(1, mcPDG))')
88 variables.addAlias('B01_daughter1_M', 'daughter(1, daughter(1, M))')
89 variables.addAlias('B01_daughter1_nDaughters', 'daughter(1, daughter(1, nDaughters))')
90 variables.addAlias('B01_daughter1_mcDecayTime', 'daughter(1, daughter(1, mcDecayTime))')
91 variables.addAlias('B01_daughter1_mcLifeTime', 'daughter(1, daughter(1, mcLifeTime))')
92 variables.addAlias('B01_daughter1_mcX', 'daughter(1, daughter(1, mcDecayVertexX))')
93 variables.addAlias('B01_daughter1_mcY', 'daughter(1, daughter(1, mcDecayVertexY))')
94 variables.addAlias('B01_daughter1_mcZ', 'daughter(1, daughter(1, mcDecayVertexZ))')
95 variables.addAlias('B01_daughter1_mcE', 'daughter(1, daughter(1, mcE))')
96 variables.addAlias('B01_daughter1_mcPX', 'daughter(1, daughter(1, mcPX))')
97 variables.addAlias('B01_daughter1_mcPY', 'daughter(1, daughter(1, mcPY))')
98 variables.addAlias('B01_daughter1_mcPZ', 'daughter(1, daughter(1, mcPZ))')
99 
100 if len(sys.argv) != 2:
101  sys.exit('Must provide one input parameter: [output_root_file_name]'
102  )
103 
104 outRootFileName = sys.argv[1]
105 
106 # create path
107 cp_val_path = b2.create_path()
108 
109 ma.inputMdstList(filelist=[], path=cp_val_path)
110 
111 Upsilon4S = ('Upsilon(4S):all', '')
112 ma.fillParticleListsFromMC([Upsilon4S], True, path=cp_val_path)
113 ma.matchMCTruth('Upsilon(4S):all', path=cp_val_path)
114 
115 ma.variablesToNtuple(decayString='Upsilon(4S):all',
116  variables=["generatorEventWeight",
117  # Upsilon(4S)
118  "mcPDG", "M", "nDaughters", "mcDecayTime", "mcLifeTime",
119  "mcX", "mcY", "mcZ", "mcE", "mcPX", "mcPY", "mcPZ",
120  # first daughter (e.g. 1st B0) and two granddaughters
121  'B00_mcPDG', 'B00_M', 'B00_nDaughters',
122  'B00_mcDecayTime', 'B00_mcLifeTime',
123  'B00_mcX', 'B00_mcY', 'B00_mcZ',
124  'B00_mcE', 'B00_mcPX', 'B00_mcPY', 'B00_mcPZ',
125  'B00_daughter0_mcPDG', 'B00_daughter1_mcPDG',
126  'B00_daughter0_M', 'B00_daughter1_M',
127  'B00_daughter0_mcDecayTime', 'B00_daughter1_mcDecayTime',
128  'B00_daughter0_mcLifeTime', 'B00_daughter1_mcLifeTime',
129  'B00_daughter0_mcX', 'B00_daughter1_mcX',
130  'B00_daughter0_mcY', 'B00_daughter1_mcY',
131  'B00_daughter0_mcZ', 'B00_daughter1_mcZ',
132  'B00_daughter0_mcE', 'B00_daughter1_mcE',
133  'B00_daughter0_mcPX', 'B00_daughter1_mcPX',
134  'B00_daughter0_mcPY', 'B00_daughter1_mcPY',
135  'B00_daughter0_mcPZ', 'B00_daughter1_mcPZ',
136  # second daughter (e.g. 2nd B0) and two granddaughters
137  'B01_mcPDG', 'B01_M', 'B01_nDaughters',
138  'B01_mcDecayTime', 'B01_mcLifeTime',
139  'B01_mcX', 'B01_mcY', 'B01_mcZ',
140  'B01_mcE', 'B01_mcPX', 'B01_mcPY', 'B01_mcPZ',
141  'B01_daughter0_mcPDG', 'B01_daughter1_mcPDG',
142  'B01_daughter0_M', 'B01_daughter1_M',
143  'B01_daughter0_mcDecayTime', 'B01_daughter1_mcDecayTime',
144  'B01_daughter0_mcLifeTime', 'B01_daughter1_mcLifeTime',
145  'B01_daughter0_mcX', 'B01_daughter1_mcX',
146  'B01_daughter0_mcY', 'B01_daughter1_mcY',
147  'B01_daughter0_mcZ', 'B01_daughter1_mcZ',
148  'B01_daughter0_mcE', 'B01_daughter1_mcE',
149  'B01_daughter0_mcPX', 'B01_daughter1_mcPX',
150  'B01_daughter0_mcPY', 'B01_daughter1_mcPY',
151  'B01_daughter0_mcPZ', 'B01_daughter1_mcPZ'],
152  filename=outRootFileName,
153  treename='UpsilonTree',
154  path=cp_val_path)
155 
156 ma.summaryOfLists(particleLists=['Upsilon(4S):all'], path=cp_val_path)
157 
158 # Process the events
159 ma.process(cp_val_path)
160 
161 # print out the summary
162 print(b2.statistics)