Belle II Software  release-05-01-25
B2A204-LoadAllECLClusters.py
1 #!/usr/bin/env python3
2 
3 
13 
14 import basf2 as b2
15 from modularAnalysis import inputMdst
16 from modularAnalysis import fillParticleList
17 from modularAnalysis import reconstructDecay
18 from modularAnalysis import copyLists
19 from modularAnalysis import variablesToNtuple
20 from variables import variables
21 
22 # create path
23 mypath = b2.create_path()
24 
25 # load input ROOT file
26 inputMdst(environmentType='default',
27  filename=b2.find_file('B2pi0D_D2hh_D2hhh_B2munu_evtgen.root', 'examples', False),
28  path=mypath)
29 
30 # fill an all photon and all charged particle (does not really matter which one) list
31 fillParticleList('gamma:minimumE', 'clusterE > 0.1', path=mypath) # neutral clusters
32 fillParticleList('e-:minimumE', 'clusterE > 0.1', path=mypath) # track matched clusters
33 
34 # reconstruct a pseudo particles with different combinations (implicit charge conjugation)
35 reconstructDecay('vpho:1 -> gamma:minimumE gamma:minimumE', '', 1, path=mypath) # two neutral '00'
36 reconstructDecay('vpho:2 -> gamma:minimumE e-:minimumE', '', 2, path=mypath,
37  allowChargeViolation=True) # neutral and charged '0+' and '0-'
38 reconstructDecay('vpho:3 -> e-:minimumE e+:minimumE', '', 3, path=mypath) # different charge '+-' and '-+'
39 reconstructDecay('vpho:4 -> e-:minimumE e-:minimumE', '', 4, path=mypath, allowChargeViolation=True) # same charge '++' and '--'
40 copyLists('vpho:bhabha', ['vpho:1', 'vpho:2', 'vpho:3', 'vpho:4'], path=mypath)
41 
42 # aliases to make output better readable
43 # For more information on alias definitions (including an intrdouction to
44 # some very handy convenience functions with which you could
45 # define below aliases in very few lines), head over to
46 # ``VariableManager/variableAliases.py``.
47 variables.addAlias('combinationID', 'extraInfo(decayModeID)')
48 variables.addAlias('deltaPhi', 'daughterDiffOfClusterPhi(0, 1)')
49 variables.addAlias('deltaTheta', 'formula(daughter(0, clusterTheta) - daughter(1, clusterTheta))')
50 variables.addAlias('charge_0', 'daughter(0, charge)')
51 variables.addAlias('charge_1', 'daughter(1, charge)')
52 variables.addAlias('clusterE_0', 'daughter(0, clusterE)')
53 variables.addAlias('clusterE_1', 'daughter(1, clusterE)')
54 variables.addAlias('clusterTheta_0', 'daughter(0, clusterTheta)')
55 variables.addAlias('clusterTheta_1', 'daughter(1, clusterTheta)')
56 variables.addAlias('clusterPhi_0', 'daughter(0, clusterPhi)')
57 variables.addAlias('clusterPhi_1', 'daughter(1, clusterPhi)')
58 
59 variables.addAlias('clusterECMS_0', 'daughter(0, useCMSFrame(clusterE))')
60 variables.addAlias('clusterECMS_1', 'daughter(1, useCMSFrame(clusterE))')
61 variables.addAlias('clusterThetaCMS_0', 'daughter(0, useCMSFrame(clusterTheta))')
62 variables.addAlias('clusterThetaCMS_1', 'daughter(1, useCMSFrame(clusterTheta))')
63 variables.addAlias('clusterPhiCMS_0', 'daughter(0, useCMSFrame(clusterPhi))')
64 variables.addAlias('clusterPhiCMS_1', 'daughter(1, useCMSFrame(clusterPhi))')
65 variables.addAlias('deltaPhiCMS', 'daughterDiffOfClusterPhiCMS(0, 1)')
66 
67 # variables to ntuple
68 vars = ['combinationID',
69  'deltaPhi',
70  'deltaPhiCMS',
71  'deltaTheta',
72  'charge_0',
73  'charge_1',
74  'clusterE_0',
75  'clusterE_1',
76  'clusterTheta_0',
77  'clusterTheta_1',
78  'clusterPhi_0',
79  'clusterPhi_1',
80  'clusterECMS_0',
81  'clusterECMS_1',
82  'clusterPhiCMS_0',
83  'clusterPhiCMS_1',
84  'clusterThetaCMS_0',
85  'clusterThetaCMS_1'
86  ]
87 
88 # store variables
89 variablesToNtuple('vpho:bhabha', vars, filename='bhabha.root', path=mypath)
90 
91 # Process the events
92 b2.process(mypath)
93 
94 # print out the summary
95 print(b2.statistics)
variablesToNtuple
Definition: variablesToNtuple.py:1