Belle II Software  release-06-01-15
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_mdst_output
17 from reconstruction import add_reconstruction
18 from generators import add_evtgen_generator
19 # import pandas as pd
20 import sys
21 import glob
22 
23 base_path = "."
24 
25 # convert input params
26 try:
27  outPath = str(sys.argv[1])
28 except BaseException:
29  outPath = 'root_files/test/KLID_MDST_TEST.root'
30 try:
31  noEvents = int(sys.argv[2])
32 except BaseException:
33  noEvents = 100
34 try:
35  bkgScale = float(sys.argv[3])
36 except BaseException:
37  bkgScale = 1.0
38 try:
39  useKLM = bool(sys.argv[4])
40 except BaseException:
41  useKLM = True
42 try:
43  useECL = bool(sys.argv[5])
44 except BaseException:
45  useECL = False
46 try:
47  KLMexpertPath = str(sys.argv[6])
48 except BaseException:
49  KLMexpertPath = False
50 
51 
52 if '.root' not in outPath:
53  outPath = outPath + str(noEvents) + '.root'
54 
55 # dec_path_string = base_path + '/dec_files/generic_Btag.dec'
56 mypath = b2.Path()
57 
58 # '/ghi/fs01/belle2/bdata/MC/release-03-01-00/DB00000547/MC12b/prod00007427/s00/e1003/4S/r00000/mixed/mdst/sub00/mdst_000*.root'
59 # my_path.add_module('RootInput', inputFileNames=inputFilename)
60 
61 dec_file = None
62 final_state = 'mixed'
63 ma.setupEventInfo(noEvents, mypath)
64 
65 add_evtgen_generator(mypath, finalstate=final_state, signaldecfile=dec_file)
66 
67 add_simulation(mypath, bkgfiles=glob.glob('/sw/belle2/bkg/*.root'))
68 
69 add_reconstruction(mypath)
70 
71 # for m in path.modules():
72 # if m.name() == "KLMExpert":
73 # m.logging.log_level = LogLevel.ERROR
74 # #m.logging.debug_level = 200
75 # if KLMexpertPath:
76 # m.logging.info("Setting KLMclassifier to {}".format(KLMexpertPath))
77 # m.param("classifierPath",KLMexpertPath)
78 
79 if((not useKLM) and (not useECL)):
80  sys.exit("nether KLM nor ECL data will be written. Aborting...")
81 
82 data_writer = b2.register_module('DataWriter')
83 data_writer.param("outPath", outPath)
84 data_writer.param("useKLM", useKLM)
85 data_writer.param("useECL", useECL)
86 mypath.add_module(data_writer)
87 
88 b2.process(mypath)
89 print(b2.statistics)