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