Belle II Software development
TrgEclTimeCalibration.py
1#!/usr/bin/env python
2
3
10
11# -----------------------------------------------------------------------------------
12#
13# TC Time offset Calibration module
14#
15# usage : %> basf2 TrgEclTimeCalibation.py [1. input root file name] [2. output file name]
16#
17# Also you can use wildcard : ex) basf2 TrgEclTimeCalibation.py input\*.root output.root
18#
19# -----------------------------------------------------------------------------------
20
21import basf2 as b2
22
23import sys
24
25argvs = sys.argv # get arg
26argc = len(argvs) # of arg
27
28if argc != 3:
29 sys.exit("ReadEclTrgUnpacker.py> # of arg is strange.\n 1.rootname\n 2.output file name\n Exit.")
30
31if argc == 3:
32 fname_in = argvs[1]
33 fname_out = argvs[2]
34
35b2.set_log_level(b2.LogLevel.ERROR)
36# set_log_level(LogLevel.INFO)
37
38string_length = len(fname_in)
39string_loc = 0
40letter_remove = '\\'
41while (string_loc < string_length):
42 if fname_in[string_loc] == letter_remove:
43 fname_in = fname_in[:string_loc] + fname_in[string_loc + 1::]
44 string_length = len(fname_in)
45 string_loc += 1
46print("input File : ", fname_in)
47print("output File : ", fname_out)
48
49# calibration
50tcal = b2.register_module('TRGECLTimingCal')
51input = b2.register_module('RootInput')
52input.param("inputFileName", fname_in)
53tcal.param("TRGECLCalSim", 0) # 0 data, 1 simulation : default 0
54tcal.param("TRGECLCalType", 0) # 0 beam, 1 cosmic : default 0
55tcal.param("TRGECLCalTCRef", 184) # Reference TC : default 184
56tcal.param("TRGECLCal3DBhabhaVeto", 1) # Use 3DBhabhaVeto bit : default 1
57tcal.param("TRGECLCalHighEnergyCut", 10) # TC high energy cut (GeV) default 9999
58tcal.param("TRGECLCalLowEnergyCut", 1) # TC low energy cut (GeV) default 0
59tcal.param("TRGECLCalofname", fname_out) # Output root file name
60
61# Create main path
62main = b2.create_path()
63
64# Add modules to main path
65main.add_module(input)
66main.add_module(tcal)
67m_progress = b2.register_module('Progress')
68m_progress.param("maxN", 4)
69main.add_module(m_progress)
70
71
72# Process all events
73b2.process(main)
74print(b2.statistics)