Belle II Software light-2406-ragdoll
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
24# Create path
25path = b2.create_path()
26
27# Run conversion on input file
29 b2.find_file(
30 'analysis/mdstBelle1_exp65_charged.root',
31 'validation',
32 False),
33 applySkim=True,
34 # Actually, the KS finder should be set to True.
35 # However, here it's set to False because the necessary library is only present on kekcc and not on the build server.
36 enableNisKsFinder=False,
37 # Set this argument to True (default value) so that the local database on KEKCC is used.
38 # It's only set to False here so that this example can be run in the GitLab pipeline.
39 enableLocalDB=False,
40 path=path)
41ma.setAnalysisConfigParams({'mcMatchingVersion': 'Belle'}, path)
42
43# Get FEI default channels for a converted training
44# Utilise the arguments to toggle on and off certain channels
45particles = fei.get_default_channels()
46
47# Set up FEI configuration specifying the FEI prefix of the Belle legacy training
48configuration = fei.config.FeiConfiguration(prefix='FEI_B2BII_light-2012-minos',
49 training=False, monitor=False, cache=0)
50
51# Get FEI path
52feistate = fei.get_path(particles, configuration)
53
54# Add FEI path to the path to be processed
55path.add_path(feistate.path)
56
57# Add MC matching when applying to MC. This is required for variables like isSignal and mcErrors below
58path.add_module('MCMatcherParticles', listName='B+:generic', looseMCMatching=True)
59path.add_module('MCMatcherParticles', listName='B+:semileptonic', looseMCMatching=True)
60path.add_module('MCMatcherParticles', listName='B0:generic', looseMCMatching=True)
61path.add_module('MCMatcherParticles', listName='B0:semileptonic', looseMCMatching=True)
62
63# Store tag-side variables of interest.
64ma.variablesToNtuple('B+:generic',
65 ['Mbc',
66 'deltaE',
67 'mcErrors',
68 'extraInfo(decayModeID)',
69 'extraInfo(uniqueSignal)',
70 'extraInfo(SignalProbability)',
71 'isSignal'],
72 filename='B_charged_hadronic.root',
73 path=path)
74ma.variablesToNtuple('B+:semileptonic',
75 ['cosThetaBetweenParticleAndNominalB',
76 'mcErrors',
77 'extraInfo(decayModeID)',
78 'extraInfo(uniqueSignal)',
79 'extraInfo(SignalProbability)',
80 'isSignalAcceptMissingNeutrino'],
81 filename='B_charged_semileptonic.root',
82 path=path)
83
84ma.variablesToNtuple('B0:generic',
85 ['Mbc',
86 'deltaE',
87 'mcErrors',
88 'extraInfo(decayModeID)',
89 'extraInfo(uniqueSignal)',
90 'extraInfo(SignalProbability)',
91 'isSignal'],
92 filename='B_mixed_hadronic.root',
93 path=path)
94ma.variablesToNtuple('B0:semileptonic',
95 ['cosThetaBetweenParticleAndNominalB',
96 'mcErrors',
97 'extraInfo(decayModeID)',
98 'extraInfo(uniqueSignal)',
99 'extraInfo(SignalProbability)',
100 'isSignalAcceptMissingNeutrino'],
101 filename='B_mixed_semileptonic.root',
102 path=path)
103
104# Process 100 events
105b2.process(path, max_event=100)
106print(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)