Belle II Software development
B_converted_apply.py
1#!/usr/bin/env python3
2
3
10
11import os
12
13import fei
14import basf2 as b2
15import modularAnalysis as ma
16
17import b2biiConversion
18
19# To properly read the Belle database the user name is set to g0db
20os.environ['PGUSER'] = 'g0db'
21# Add the necessary global tag
22b2.conditions.prepend_globaltag(ma.getAnalysisGlobaltag())
23
24b2.set_random_seed("B_converted_apply")
25
26# Create path
27path = b2.create_path()
28
29# Run conversion on input file
31 b2.find_file(
32 'analysis/mdstBelle1_exp65_charged.root',
33 'validation',
34 False),
35 applySkim=True,
36 # Actually, the KS finder should be set to True.
37 # However, here it's set to False because the necessary library is only present on kekcc and not on the build server.
38 enableNisKsFinder=False,
39 # Set this argument to True (default value) so that the local database on KEKCC is used.
40 # It's only set to False here so that this example can be run in the GitLab pipeline.
41 enableLocalDB=False,
42 path=path)
43ma.setAnalysisConfigParams({'mcMatchingVersion': 'Belle'}, path)
44
45# Get FEI default channels for a converted training
46# Utilise the arguments to toggle on and off certain channels
47particles = fei.get_default_channels()
48
49# Set up FEI configuration specifying the FEI prefix of the Belle legacy training
50configuration = fei.config.FeiConfiguration(prefix='FEI_B2BII_light-2012-minos',
51 training=False, monitor=False, cache=0)
52
53# Get FEI path
54feistate = fei.get_path(particles, configuration)
55
56# Add FEI path to the path to be processed
57path.add_path(feistate.path)
58
59# Add MC matching when applying to MC. This is required for variables like isSignal and mcErrors below
60path.add_module('MCMatcherParticles', listName='B+:generic', looseMCMatching=True)
61path.add_module('MCMatcherParticles', listName='B+:semileptonic', looseMCMatching=True)
62path.add_module('MCMatcherParticles', listName='B0:generic', looseMCMatching=True)
63path.add_module('MCMatcherParticles', listName='B0:semileptonic', looseMCMatching=True)
64
65commonVariables = ['mcErrors', 'extraInfo(decayModeID)', 'extraInfo(uniqueSignal)', 'extraInfo(SignalProbability)']
66genericVariables = ['Mbc', 'deltaE', 'isSignal'] + commonVariables
67semiLeptonicVariables = ['cosThetaBetweenParticleAndNominalB', 'isSignalAcceptMissingNeutrino'] + commonVariables
68
69# Store tag-side variables of interest.
70ma.variablesToNtuple('B+:generic',
71 genericVariables,
72 treename='Bplus',
73 filename='B_charged_hadronic.root',
74 path=path)
75ma.variablesToNtuple('B+:semileptonic',
76 semiLeptonicVariables,
77 treename='BplusSL',
78 filename='B_charged_semileptonic.root',
79 path=path)
80
81ma.variablesToNtuple('B0:generic',
82 genericVariables,
83 treename='B0',
84 filename='B_mixed_hadronic.root',
85 path=path)
86ma.variablesToNtuple('B0:semileptonic',
87 semiLeptonicVariables,
88 treename='B0SL',
89 filename='B_mixed_semileptonic.root',
90 path=path)
91
92# Process 100 events
93b2.process(path, max_event=100)
94print(b2.statistics)
def convertBelleMdstToBelleIIMdst(inputBelleMDSTFile, applySkim=True, saveResultExtraInfo=False, useBelleDBServer=None, convertBeamParameters=True, generatorLevelReconstruction=False, generatorLevelMCMatching=False, path=None, entrySequences=None, matchType2E9oE25Threshold=-1.1, enableNisKsFinder=True, HadronA=True, HadronB=True, enableRecTrg=False, enableEvtcls=True, SmearTrack=2, enableLocalDB=True, convertNbar=False)