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
19# Doxygen should skip this script
20# @cond
21
22import basf2 as b2
23import modularAnalysis as ma
24from variables import variables as vm
25
26path = b2.Path()
27ma.inputMdst(filename=b2.find_file('mdst16.root', 'validation', True),
28 path=path)
29
30
31# variables aliases
32vm.addAlias('cpDR', 'convertedPhotonDelR(0,1)')
33vm.addAlias('cpDZ', 'convertedPhotonDelZ(0,1)')
34vm.addAlias('cpDTL', 'convertedPhotonDelTanLambda(0,1)')
35vm.addAlias('cpX', 'convertedPhotonX(0,1)')
36vm.addAlias('cpY', 'convertedPhotonY(0,1)')
37vm.addAlias('cpZ', 'convertedPhotonZ(0,1)')
38vm.addAlias('cpRho', 'convertedPhotonRho(0,1)')
39vm.addAlias('cpM', 'convertedPhotonInvariantMass(0,1)')
40vm.addAlias('cpPx', 'convertedPhotonPx(0,1)')
41vm.addAlias('cpPy', 'convertedPhotonPy(0,1)')
42vm.addAlias('cpPz', 'convertedPhotonPz(0,1)')
43
44vm.addAlias('mcX', 'daughter(0,mcProductionVertexX)')
45vm.addAlias('mcY', 'daughter(0,mcProductionVertexY)')
46vm.addAlias('mcZ', 'daughter(0,mcProductionVertexZ)')
47
48
49# tuple variables
50tuple_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
71ma.fillParticleList("e+:loose", cut="p > 0.3", path=path)
72ma.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)
76ma.matchMCTruth('gamma:conv', path=path)
77ma.variablesToNtuple('gamma:conv', tuple_vars, filename='output.root', treename='photonVars', path=path)
78
79
80# progress
81progress = b2.register_module('Progress')
82path.add_module(progress)
83b2.process(path=path)
84
85# Print call statistics
86print(b2.statistics)
87
88
89# @endcond