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