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