Belle II Software development
B2A911-CreateTrainData.py
1#!/usr/bin/env python3
2
3
10
11
17
18import basf2 as b2
19import modularAnalysis as ma
20import stdV0s as stdV0s
21import ksSelector as ksSelector
22
23# create path
24my_path = b2.create_path()
25
26# load input ROOT file
27ma.inputMdst(filename=b2.find_file('ccbar_background.root', 'examples', False),
28 path=my_path)
29
30# load K_S0 particle list
31stdV0s.stdKshorts(path=my_path)
32ma.matchMCTruth(list_name='K_S0:merged', path=my_path)
33
34# apply cuts suitable for V0Selector
35# remove Lambda from particle list
36ma.cutAndCopyLists('K_S0:V0Selector', 'K_S0:merged', cut='mcPDG!=3122', path=my_path)
37# apply cuts suitable for LambdaVeto
38# only include long lived particle, K_S0 and Lambda
39ma.cutAndCopyLists('K_S0:LambdaVeto', 'K_S0:merged', cut='isSignal==1 or abs(mcPDG)==3122', path=my_path)
40
41# add variable aliases required for KsSelector training
43
44# add variables required for KsSelector training
45vars = ['ks_selector_info', 'isNotContinuumEvent', 'isSignal']
46
47# output
48ma.variablesToNtuple('K_S0:V0Selector',
49 variables=vars,
50 filename='KsSelector_train_V0Selector.root',
51 treename='tree',
52 path=my_path)
53
54ma.variablesToNtuple('K_S0:LambdaVeto',
55 variables=vars,
56 filename='KsSelector_train_LambdaVeto.root',
57 treename='tree',
58 path=my_path)
59
60# Process the events
61b2.process(my_path, max_event=10000)
62
63# print out the summary
64print(b2.statistics)
def add_variable_collection()
Definition: ksSelector.py:42
def stdKshorts(prioritiseV0=True, fitter='TreeFit', path=None, updateAllDaughters=False, writeOut=False)
Definition: stdV0s.py:17