Belle II Software  release-08-01-10
B2A911-CreateTrainData.py
1 #!/usr/bin/env python3
2 
3 
10 
11 
17 
18 import basf2 as b2
19 import modularAnalysis as ma
20 import stdV0s as stdV0s
21 import ksSelector as ksSelector
22 
23 # create path
24 my_path = b2.create_path()
25 
26 # load input ROOT file
27 ma.inputMdst(filename=b2.find_file('ccbar_background.root', 'examples', False),
28  path=my_path)
29 
30 # load K_S0 particle list
31 stdV0s.stdKshorts(path=my_path)
32 ma.matchMCTruth(list_name='K_S0:merged', path=my_path)
33 
34 # apply cuts suitable for V0Selector
35 # remove Lambda from particle list
36 ma.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
39 ma.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
45 vars = ['ks_selector_info', 'isNotContinuumEvent', 'isSignal']
46 
47 # output
48 ma.variablesToNtuple('K_S0:V0Selector',
49  variables=vars,
50  filename='KsSelector_train_V0Selector.root',
51  treename='tree',
52  path=my_path)
53 
54 ma.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
61 b2.process(my_path, max_event=10000)
62 
63 # print out the summary
64 print(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