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