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