Belle II Software light-2406-ragdoll
B2A907-PhotonDetectionEfficiencyRatios.py
1#!/usr/bin/env python3
2
3
10
11
19
20
21import basf2 as b2
22import modularAnalysis as ma
23import variables as va
24
25# create path
26path = b2.create_path()
27
28# load input ROOT file
29ma.inputMdst(filename=b2.find_file('B02D0pi0_D02pi0pi0.root', 'examples', False),
30 path=path)
31
32# ID of weight table
33weight_table_id = "PhotonEfficiencyDataMCRatio_proc13MC15_November2022"
34
35b2.conditions.prepend_globaltag(ma.getAnalysisGlobaltag())
36
37# We know what weight info will be added,
38# so we add aliases and add it to the tools
39va.variables.addAlias('Weight', f'extraInfo({weight_table_id}_Weight)')
40va.variables.addAlias('StatErrUp', f'extraInfo({weight_table_id}_StatErrUp)')
41va.variables.addAlias('StatErrDown', f'extraInfo({weight_table_id}_StatErrDown)')
42va.variables.addAlias('SystErrUp', f'extraInfo({weight_table_id}_SystErrUp)')
43va.variables.addAlias('SystErrDown', f'extraInfo({weight_table_id}_SystErrDown)')
44va.variables.addAlias('TotalErrUp', f'extraInfo({weight_table_id}_TotalErrUp)')
45va.variables.addAlias('TotalErrDown', f'extraInfo({weight_table_id}_TotalErrDown)')
46# Just take any photons for example purposes
47simple_selection = 'theta > 0.296706 and theta < 2.6179'
48ma.fillParticleList(decayString='gamma:full',
49 cut=simple_selection,
50 path=path)
51
52# Apply the photon module
53ma.addPhotonEfficiencyRatioVariables(['gamma:full'], weight_table_id, path=path)
54
55# The ratios are added wrt to E, theta, phi of the photon
56weight_vars = ['p', 'E', 'theta', 'phi',
57 'Weight', 'TotalErrUp', 'TotalErrDown', 'StatErrUp', 'StatErrDown', 'SystErrUp', 'SystErrDown',
58 ]
59
60
61ma.variablesToNtuple(decayString='gamma:full',
62 variables=weight_vars,
63 filename='B2A907-PhotonDetectionEfficiencyRatios.root',
64 path=path)
65
66# process the events
67b2.process(path)
68
69# print out the summary
70print(b2.statistics)