Belle II Software  release-08-01-10
B_generic_apply.py
1 #!/usr/bin/env python3
2 
3 
10 
11 import fei
12 import basf2 as b2
13 import modularAnalysis as ma
14 
15 # Create path
16 path = b2.create_path()
17 
18 # Load input ROOT file
19 ma.inputMdst(filename=b2.find_file('mdst14.root', 'validation', False),
20  path=path)
21 
22 # Add the necessary database
23 b2.conditions.prepend_globaltag(ma.getAnalysisGlobaltag())
24 
25 # Get FEI default channels.
26 # Utilise the arguments to toggle on and off certain channels
27 particles = fei.get_default_channels()
28 
29 # Set up FEI configuration specifying the FEI prefix
30 configuration = fei.config.FeiConfiguration(prefix='FEIv4_2021_MC14_release_05_01_12', training=False, monitor=False, cache=0)
31 
32 # Get FEI path
33 feistate = fei.get_path(particles, configuration)
34 
35 # Add FEI path to the path to be processed
36 path.add_path(feistate.path)
37 
38 # Add MC matching when applying to MC. This is required for variables like isSignal and mcErrors below
39 path.add_module('MCMatcherParticles', listName='B+:generic', looseMCMatching=True)
40 path.add_module('MCMatcherParticles', listName='B+:semileptonic', looseMCMatching=True)
41 path.add_module('MCMatcherParticles', listName='B0:generic', looseMCMatching=True)
42 path.add_module('MCMatcherParticles', listName='B0:semileptonic', looseMCMatching=True)
43 
44 # Store tag-side variables of interest.
45 ma.variablesToNtuple('B+:generic',
46  ['Mbc',
47  'deltaE',
48  'mcErrors',
49  'extraInfo(decayModeID)',
50  'extraInfo(uniqueSignal)',
51  'extraInfo(SignalProbability)',
52  'isSignal'],
53  filename='B_charged_hadronic.root',
54  path=path)
55 ma.variablesToNtuple('B+:semileptonic',
56  ['cosThetaBetweenParticleAndNominalB',
57  'mcErrors',
58  'extraInfo(decayModeID)',
59  'extraInfo(uniqueSignal)',
60  'extraInfo(SignalProbability)',
61  'isSignalAcceptMissingNeutrino'],
62  filename='B_charged_semileptonic.root',
63  path=path)
64 
65 ma.variablesToNtuple('B0:generic',
66  ['Mbc',
67  'deltaE',
68  'mcErrors',
69  'extraInfo(decayModeID)',
70  'extraInfo(uniqueSignal)',
71  'extraInfo(SignalProbability)',
72  'isSignal'],
73  filename='B_mixed_hadronic.root',
74  path=path)
75 ma.variablesToNtuple('B0:semileptonic',
76  ['cosThetaBetweenParticleAndNominalB',
77  'mcErrors',
78  'extraInfo(decayModeID)',
79  'extraInfo(uniqueSignal)',
80  'extraInfo(SignalProbability)',
81  'isSignalAcceptMissingNeutrino'],
82  filename='B_mixed_semileptonic.root',
83  path=path)
84 
85 # Process 100 events
86 b2.process(path, max_event=100)
87 print(b2.statistics)