Belle II Software  release-08-01-10
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 
25 # create path
26 path = b2.create_path()
27 
28 # load input ROOT file
29 ma.inputMdst(filename=b2.find_file('B02D0pi0_D02pi0pi0.root', 'examples', False),
30  path=path)
31 
32 # ID of weight table
33 weight_table_id = "PhotonEfficiencyDataMCRatio_proc13MC15_November2022"
34 
35 b2.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
39 va.variables.addAlias('Weight', f'extraInfo({weight_table_id}_Weight)')
40 va.variables.addAlias('StatErrUp', f'extraInfo({weight_table_id}_StatErrUp)')
41 va.variables.addAlias('StatErrDown', f'extraInfo({weight_table_id}_StatErrDown)')
42 va.variables.addAlias('SystErrUp', f'extraInfo({weight_table_id}_SystErrUp)')
43 va.variables.addAlias('SystErrDown', f'extraInfo({weight_table_id}_SystErrDown)')
44 va.variables.addAlias('TotalErrUp', f'extraInfo({weight_table_id}_TotalErrUp)')
45 va.variables.addAlias('TotalErrDown', f'extraInfo({weight_table_id}_TotalErrDown)')
46 # Just take any photons for example purposes
47 simple_selection = 'theta > 0.296706 and theta < 2.6179'
48 ma.fillParticleList(decayString='gamma:full',
49  cut=simple_selection,
50  path=path)
51 
52 # Apply the photon module
53 ma.addPhotonEfficiencyRatioVariables(['gamma:full'], weight_table_id, path=path)
54 
55 # The ratios are added wrt to E, theta, phi of the photon
56 weight_vars = ['p', 'E', 'theta', 'phi',
57  'Weight', 'TotalErrUp', 'TotalErrDown', 'StatErrUp', 'StatErrDown', 'SystErrUp', 'SystErrDown',
58  ]
59 
60 
61 ma.variablesToNtuple(decayString='gamma:full',
62  variables=weight_vars,
63  filename='B2A907-PhotonDetectionEfficiencyRatios.root',
64  path=path)
65 
66 # process the events
67 b2.process(path)
68 
69 # print out the summary
70 print(b2.statistics)