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