Belle II Software  release-05-01-25
KlId_data_KLM.py
1 #!/usr/bin/env python3
2 # -*- coding: utf-8 -*-
3 # Jo-Frederik.krohn@desy.de, benjamin.oberhof@lnf.infn.it
4 
5 import basf2
6 from modularAnalysis import *
7 
8 from simulation import add_simulation
9 # from reconstruction import add_mdst_output
10 from reconstruction import add_reconstruction
11 from beamparameters import add_beamparameters
12 from generators import add_evtgen_generator
13 # from L1trigger import add_tsim
14 from ROOT import Belle2
15 # import pandas as pd
16 import sys
17 import time
18 import glob
19 
20 base_path = "."
21 
22 # convert input params
23 try:
24  outPath = str(sys.argv[1])
25 except BaseException:
26  outPath = 'root_files/test/KLID_MDST_TEST.root'
27 try:
28  noEvents = int(sys.argv[2])
29 except BaseException:
30  noEvents = 100
31 try:
32  bkgScale = float(sys.argv[3])
33 except BaseException:
34  bkgScale = 1.0
35 try:
36  useKLM = bool(sys.argv[4])
37 except BaseException:
38  useKLM = True
39 try:
40  useECL = bool(sys.argv[5])
41 except BaseException:
42  useECL = False
43 try:
44  KLMexpertPath = string(sys.argv[6])
45 except BaseException:
46  KLMexpertPath = False
47 
48 
49 if '.root' not in outPath:
50  outPath = outPath + str(noEvents) + '.root'
51 
52 # dec_path_string = base_path + '/dec_files/generic_Btag.dec'
53 mypath = basf2.Path()
54 
55 # '/ghi/fs01/belle2/bdata/MC/release-03-01-00/DB00000547/MC12b/prod00007427/s00/e1003/4S/r00000/mixed/mdst/sub00/mdst_000*.root'
56 # my_path.add_module('RootInput', inputFileNames=inputFilename)
57 
58 dec_file = None
59 final_state = 'mixed'
60 setupEventInfo(noEvents, mypath)
61 # , signaldecfile=Belle2.FileSystem.findFile('analysis/examples/tutorials/B2A101-Y4SEventGeneration.dec'))
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("nether KLM nor ECL data will be written. Aborting...")
78 
79 data_writer = 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 basf2.process(mypath)
86 print(statistics)
basf2.process
def process(path, max_event=0)
Definition: __init__.py:25