Belle II Software  light-2403-persian
getConvertedPhotonVariables.py
1 #!/usr/bin/env python3
2 
3 
10 
11 """
12 This script loads a specified input ROOT file, reconstructs photon conversions and
13 saves converted-photon variables and some of their generator-level counterparts for comparison.
14 
15 Execute script with:
16  $> basf2 getConvertedPhotonVariables.py -i [input_ROOT_file]
17 """
18 
19 # Doxygen should skip this script
20 # @cond
21 
22 import basf2 as b2
23 import modularAnalysis as ma
24 from variables import variables as vm
25 
26 path = b2.Path()
27 ma.inputMdst(filename=b2.find_file('mdst14.root', 'validation', True),
28  path=path)
29 
30 
31 # variables aliases
32 vm.addAlias('cpDR', 'convertedPhotonDelR(0,1)')
33 vm.addAlias('cpDZ', 'convertedPhotonDelZ(0,1)')
34 vm.addAlias('cpDTL', 'convertedPhotonDelTanLambda(0,1)')
35 vm.addAlias('cpX', 'convertedPhotonX(0,1)')
36 vm.addAlias('cpY', 'convertedPhotonY(0,1)')
37 vm.addAlias('cpZ', 'convertedPhotonZ(0,1)')
38 vm.addAlias('cpRho', 'convertedPhotonRho(0,1)')
39 vm.addAlias('cpM', 'convertedPhotonInvariantMass(0,1)')
40 vm.addAlias('cpPx', 'convertedPhotonPx(0,1)')
41 vm.addAlias('cpPy', 'convertedPhotonPy(0,1)')
42 vm.addAlias('cpPz', 'convertedPhotonPz(0,1)')
43 
44 vm.addAlias('mcX', 'daughter(0,mcProductionVertexX)')
45 vm.addAlias('mcY', 'daughter(0,mcProductionVertexY)')
46 vm.addAlias('mcZ', 'daughter(0,mcProductionVertexZ)')
47 
48 
49 # tuple variables
50 tuple_vars = [
51  'cpDR',
52  'cpDZ',
53  'cpDTL',
54  'cpX',
55  'cpY',
56  'cpZ',
57  'cpRho',
58  'cpM',
59  'cpPx',
60  'cpPy',
61  'cpPz',
62  'isSignal',
63  'mcX',
64  'mcY',
65  'mcZ',
66  'mcPX',
67  'mcPY',
68  'mcPZ']
69 
70 
71 ma.fillParticleList("e+:loose", cut="p > 0.3", path=path)
72 ma.reconstructDecay(
73  'gamma:conv -> e+:loose e-:loose',
74  cut='cpM < 0.1 and cpDR > -0.15 and cpDR < 0.15 and cpDZ > -0.05 and cpDZ < 0.05',
75  path=path)
76 ma.matchMCTruth('gamma:conv', path=path)
77 ma.variablesToNtuple('gamma:conv', tuple_vars, filename='output.root', treename='photonVars', path=path)
78 
79 
80 # progress
81 progress = b2.register_module('Progress')
82 path.add_module(progress)
83 b2.process(path=path)
84 
85 # Print call statistics
86 print(b2.statistics)
87 
88 
89 # @endcond