Belle II Software  release-08-01-10
RunTPC_daily_report.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 # 1/ mkdir output_directory
18 # 2/ basf2 ./RunTPC_daily_report.py yyyy mm dd TPCposition output_directory
19 
20 location = ""
21 if 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])
32 else:
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 
43 print(inputs)
44 print(outfile)
45 print(date)
46 print(TPCnb)
47 
48 # Register necessary modules
49 main = b2.create_path()
50 
51 # Register RootInput
52 simpleinput = b2.register_module('RootInput')
53 simpleinput.param('inputFileNames', inputs)
54 main.add_module(simpleinput)
55 
56 # Register HistoManager
57 histo = b2.register_module("HistoManager") # Histogram Manager
58 histo.param('histoFileName', outfile)
59 main.add_module(histo)
60 
61 # Register Gearbox
62 gearbox = b2.register_module('Gearbox')
63 gearbox.param('fileName', '/geometry/Beast2_phase1.xml')
64 main.add_module(gearbox)
65 
66 # Register MicrotpcDailyReport
67 daily = b2.register_module('MicrotpcDailyReport')
68 daily.param('inputTPCNumber', int(TPCnb))
69 daily.param('inputReportDate', int(date))
70 main.add_module(daily)
71 
72 
73 b2.process(main)
74 
75 print('Event Statistics:')
76 print(b2.statistics)
77 
78 d = datetime.datetime.today()
79 print(d.strftime('job finish: %Y-%m-%d %H:%M:%S\n'))