Belle II Software  release-08-01-10
EvtGen_with_NN.py
1 
8 import basf2 as b2
9 import generators as ge
10 import simulation as si
11 import reconstruction as re
12 from skim.WGs.fei import feiHadronicB0
13 import modularAnalysis as ma
14 import mdst
15 
16 from smartBKG.NN_filter_module import NNFilterModule
17 
18 num_events = 1000
19 out_dir = "./"
20 
21 # create path
22 main = b2.create_path()
23 
24 # default to early phase 3 (exp=1003), run 0
25 main.add_module("EventInfoSetter", expList=1003, runList=0, evtNumList=num_events)
26 
27 # generate BBbar events
28 ge.add_evtgen_generator(path=main, finalstate='mixed')
29 
30 # GAT prediction
31 NNFilterModule_m = NNFilterModule(
32  extra_info_var='GAT_AfterGen'
33  )
34 dead_path = b2.create_path()
35 NNFilterModule_m.if_false(dead_path)
36 main.add_module(NNFilterModule_m)
37 
38 # Create the mDST output file directly after EvtGen, can be used for training NN
40  path=main,
41  filename=f'{out_dir}AfterGen.root',
42  additionalBranches=["EventExtraInfo"]
43 )
44 
45 # detector simulation
46 si.add_simulation(path=main)
47 
48 # reconstruction
49 re.add_reconstruction(path=main)
50 
51 # FEI skims from Leptonic WG
52 fei_skim = feiHadronicB0(udstOutput=False, analysisGlobaltag=ma.getAnalysisGlobaltag())
53 fei_skim(path=main)
54 
55 # Create the mDST output file after Skim
57  path=main,
58  filename=f'{out_dir}AfterFEI.root',
59  additionalBranches=["EventExtraInfo"]
60 )
61 
62 b2.process(path=main)
63 print(b2.statistics)
def add_mdst_output(path, mc=True, filename='mdst.root', additionalBranches=[], dataDescription=None)
Definition: mdst.py:37