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