Belle II Software development
Run_study_phase1.py
1#!/usr/bin/env python
2
3
10import sys
11import datetime
12import basf2 as b2
13
14d = datetime.datetime.today()
15print(d.strftime('job start: %Y-%m-%d %H:%M:%S\n'))
16
17# parse input
18location = ""
19
20# input file path
21inputs = str(sys.argv[1]) + "/" + str(sys.argv[2]) + "_" + str(sys.argv[3]) + "*.root"
22print(inputs)
23# output file path
24outfile = str(sys.argv[4]) + "/" + str(sys.argv[2]) + "_" + str(sys.argv[3]) + ".root"
25print(outfile)
26
27# Set the global log level
28b2.set_log_level(b2.LogLevel.WARNING)
29seed = str(sys.argv[5])
30print('seed: ', seed)
31b2.set_random_seed(int(seed))
32
33ethres = str(sys.argv[6])
34print('thres: ', ethres)
35erange = str(sys.argv[7])
36print('range: ', erange)
37sampletime = str(sys.argv[8])
38print('sample time: ', sampletime)
39
40# Input
41simpleinput = b2.register_module('RootInput')
42simpleinput.param('inputFileNames', inputs)
43
44# Output
45histo = b2.register_module("HistoManager") # Histogram Manager
46histo.param('histoFileName', outfile)
47
48# suppress info messages during processing:
49# set_log_level(LogLevel.WARNING)
50
51# Gearbox
52gearbox = b2.register_module('Gearbox')
53gearbox.param('fileName', '/geometry/Beast2_phase1.xml')
54
55detector = b2.register_module('QcsmonitorStudy')
56detector.param('Ethres', float(ethres))
57detector.param('Erange', float(erange))
58detector.param('SampleTime', float(sampletime))
59
60# Show progress of processing
61progress = b2.register_module('Progress')
62
63# Register necessary modules
64main = b2.create_path()
65main.add_module(simpleinput)
66main.add_module(gearbox)
67main.add_module(detector)
68main.add_module(histo)
69main.add_module(progress)
70
71b2.process(main)
72
73print('Event Statistics:')
74print(b2.statistics)
75
76d = datetime.datetime.today()
77print(d.strftime('job finish: %Y-%m-%d %H:%M:%S\n'))