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