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