Belle II Software development
KlId_data_KLM.py
1#!/usr/bin/env python3
2
3
10
11import basf2 as b2
12import modularAnalysis as ma
13
14from simulation import add_simulation
15from reconstruction import add_reconstruction
16from generators import add_evtgen_generator
17import sys
18import glob
19
20base_path = "."
21
22# convert input params
23try:
24 outPath = str(sys.argv[1])
25except BaseException:
26 outPath = 'root_files/test/KLID_MDST_TEST.root'
27try:
28 noEvents = int(sys.argv[2])
29except BaseException:
30 noEvents = 100
31try:
32 bkgScale = float(sys.argv[3])
33except BaseException:
34 bkgScale = 1.0
35try:
36 useKLM = bool(sys.argv[4])
37except BaseException:
38 useKLM = True
39try:
40 useECL = bool(sys.argv[5])
41except BaseException:
42 useECL = False
43try:
44 KLMexpertPath = str(sys.argv[6])
45except BaseException:
46 KLMexpertPath = False
47
48
49if outPath[-5:] != '.root':
50 outPath = outPath + str(noEvents) + '.root'
51
52# dec_path_string = base_path + '/dec_files/generic_Btag.dec'
53mypath = b2.Path()
54
55# my_path.add_module('RootInput', inputFileNames=b2.find_file('mdst16.root', 'validation'))
56
57dec_file = None
58final_state = 'mixed'
59ma.setupEventInfo(noEvents, mypath)
60
61add_evtgen_generator(mypath, finalstate=final_state, signaldecfile=dec_file)
62
63add_simulation(mypath, bkgfiles=glob.glob('/sw/belle2/bkg/*.root'))
64
65add_reconstruction(mypath)
66
67# for m in path.modules():
68# if m.name() == "KLMExpert":
69# m.logging.log_level = LogLevel.ERROR
70# #m.logging.debug_level = 200
71# if KLMexpertPath:
72# m.logging.info(f"Setting KLMclassifier to {KLMexpertPath}")
73# m.param("classifierPath", KLMexpertPath)
74
75if ((not useKLM) and (not useECL)):
76 sys.exit("neither KLM nor ECL data will be written. Aborting...")
77
78data_writer = b2.register_module('DataWriter')
79data_writer.param("outPath", outPath)
80data_writer.param("useKLM", useKLM)
81data_writer.param("useECL", useECL)
82mypath.add_module(data_writer)
83
84b2.process(mypath)
85print(b2.statistics)