Belle II Software  release-05-01-25
B_converted_apply.py
1 #!/usr/bin/env python3
2 
3 # William Sutcliffe 2019
4 
5 import os
6 
7 import fei
8 import basf2 as b2
9 import modularAnalysis as ma
10 
11 import b2biiConversion
12 
13 # To properly read the Belle database the user name is set to g0db
14 os.environ['PGUSER'] = 'g0db'
15 # Add the necessary global tag
16 # b2.conditions.prepend_globaltag(ma.getAnalysisGlobaltag())
17 b2.conditions.prepend_globaltag('analysis_tools_light-2012-minos')
18 
19 # Create path
20 path = b2.create_path()
21 
22 # Run conversion on input file
24  b2.find_file(
25  'analysis/mdstBelle1_exp65_charged.root',
26  'validation',
27  False),
28  applySkim=True,
29  # Actually, the KS finder should be set to True.
30  # However, here it's set to False because the necessary library is only present on kekcc and not on the build server.
31  enableNisKsFinder=False,
32  enableLocalDB=False,
33  path=path)
34 ma.setAnalysisConfigParams({'mcMatchingVersion': 'Belle'}, path)
35 
36 # Get FEI default channels for a converted training
37 # Utilise the arguments to toggle on and off certain channels
38 particles = fei.get_default_channels()
39 
40 # Set up FEI configuration specifying the FEI prefix of the Belle legacy training
41 configuration = fei.config.FeiConfiguration(prefix='FEI_B2BII_light-2012-minos',
42  training=False, monitor=False, cache=0)
43 
44 # Get FEI path
45 feistate = fei.get_path(particles, configuration)
46 
47 # Add FEI path to the path to be processed
48 path.add_path(feistate.path)
49 
50 # Add MC matching when applying to MC. This is required for variables like isSignal and mcErrors below
51 path.add_module('MCMatcherParticles', listName='B+:generic', looseMCMatching=True)
52 path.add_module('MCMatcherParticles', listName='B+:semileptonic', looseMCMatching=True)
53 path.add_module('MCMatcherParticles', listName='B0:generic', looseMCMatching=True)
54 path.add_module('MCMatcherParticles', listName='B0:semileptonic', looseMCMatching=True)
55 
56 # Store tag-side variables of interest.
57 ma.variablesToNtuple('B+:generic',
58  ['Mbc',
59  'deltaE',
60  'mcErrors',
61  'extraInfo(decayModeID)',
62  'extraInfo(uniqueSignal)',
63  'extraInfo(SignalProbability)',
64  'isSignal'],
65  filename='B_charged_hadronic.root',
66  path=path)
67 ma.variablesToNtuple('B+:semileptonic',
68  ['cosThetaBetweenParticleAndNominalB',
69  'mcErrors',
70  'extraInfo(decayModeID)',
71  'extraInfo(uniqueSignal)',
72  'extraInfo(SignalProbability)',
73  'isSignalAcceptMissingNeutrino'],
74  filename='B_charged_semileptonic.root',
75  path=path)
76 
77 ma.variablesToNtuple('B0:generic',
78  ['Mbc',
79  'deltaE',
80  'mcErrors',
81  'extraInfo(decayModeID)',
82  'extraInfo(uniqueSignal)',
83  'extraInfo(SignalProbability)',
84  'isSignal'],
85  filename='B_mixed_hadronic.root',
86  path=path)
87 ma.variablesToNtuple('B0:semileptonic',
88  ['cosThetaBetweenParticleAndNominalB',
89  'mcErrors',
90  'extraInfo(decayModeID)',
91  'extraInfo(uniqueSignal)',
92  'extraInfo(SignalProbability)',
93  'isSignalAcceptMissingNeutrino'],
94  filename='B_mixed_semileptonic.root',
95  path=path)
96 
97 # Process 100 events
98 b2.process(path, max_event=100)
99 print(b2.statistics)
b2biiConversion.convertBelleMdstToBelleIIMdst
def convertBelleMdstToBelleIIMdst(inputBelleMDSTFile, applySkim=True, 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)
Definition: b2biiConversion.py:78