Belle II Software development
RunTPC_daily_report.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# 1/ mkdir output_directory
18# 2/ basf2 ./RunTPC_daily_report.py yyyy mm dd TPCposition output_directory
19
20location = ""
21if len(sys.argv) == 6:
22 # parse input
23 inputs = '/home/belle/igal/beast/data/NTP/TPC/' + \
24 str(sys.argv[1]) + "-" + str(sys.argv[2]) + "-" + str(sys.argv[3]) + "/tpc" + str(sys.argv[4]) + "*.root"
25 # parse output
26 outfile = str(sys.argv[5]) + "/DailyReportOfTPC" + str(sys.argv[4]) + "_" + \
27 str(sys.argv[1]) + str(sys.argv[2]) + str(sys.argv[3]) + ".root"
28 # date yyyymmdd
29 date = str(sys.argv[1]) + str(sys.argv[2]) + str(sys.argv[3])
30 # TPC position
31 TPCnb = str(sys.argv[4])
32else:
33 print
34 print("Usage:")
35 print(" 1/ Create an output directory ")
36 print(" mkdir output_directory")
37 print(" 2/ basf2 ./RunTPC_daily_report.py yyyy mm dd TPCposition output_directory")
38 print("For example: ")
39 print(" basf2 ./RunTPC_daily_report.py 2016 05 30 3 output_directory")
40 print
41 quit()
42
43print(inputs)
44print(outfile)
45print(date)
46print(TPCnb)
47
48# Register necessary modules
49main = b2.create_path()
50
51# Register RootInput
52simpleinput = b2.register_module('RootInput')
53simpleinput.param('inputFileNames', inputs)
54main.add_module(simpleinput)
55
56# Register HistoManager
57histo = b2.register_module("HistoManager") # Histogram Manager
58histo.param('histoFileName', outfile)
59main.add_module(histo)
60
61# Register Gearbox
62gearbox = b2.register_module('Gearbox')
63gearbox.param('fileName', '/geometry/Beast2_phase1.xml')
64main.add_module(gearbox)
65
66# Register MicrotpcDailyReport
67daily = b2.register_module('MicrotpcDailyReport')
68daily.param('inputTPCNumber', int(TPCnb))
69daily.param('inputReportDate', int(date))
70main.add_module(daily)
71
72
73b2.process(main)
74
75print('Event Statistics:')
76print(b2.statistics)
77
78d = datetime.datetime.today()
79print(d.strftime('job finish: %Y-%m-%d %H:%M:%S\n'))