Belle II Software  release-08-01-10
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 
21 import basf2 as b2
22 
23 import sys
24 
25 argvs = sys.argv # get arg
26 argc = len(argvs) # of arg
27 
28 if argc != 3:
29  sys.exit("ReadEclTrgUnpacker.py> # of arg is strange.\n 1.rootname\n 2.output file name\n Exit.")
30 
31 if argc == 3:
32  fname_in = argvs[1]
33  fname_out = argvs[2]
34 
35 b2.set_log_level(b2.LogLevel.ERROR)
36 # set_log_level(LogLevel.INFO)
37 
38 string_length = len(fname_in)
39 string_loc = 0
40 letter_remove = '\\'
41 while (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
46 print("input File : ", fname_in)
47 print("output File : ", fname_out)
48 
49 # calibration
50 tcal = b2.register_module('TRGECLTimingCal')
51 input = b2.register_module('RootInput')
52 input.param("inputFileName", fname_in)
53 tcal.param("TRGECLCalSim", 0) # 0 data, 1 simulation : default 0
54 tcal.param("TRGECLCalType", 0) # 0 beam, 1 cosmic : default 0
55 tcal.param("TRGECLCalTCRef", 184) # Reference TC : default 184
56 tcal.param("TRGECLCal3DBhabhaVeto", 1) # Use 3DBhabhaVeto bit : default 1
57 tcal.param("TRGECLCalHighEnergyCut", 10) # TC high energy cut (GeV) default 9999
58 tcal.param("TRGECLCalLowEnergyCut", 1) # TC low energy cut (GeV) default 0
59 tcal.param("TRGECLCalofname", fname_out) # Output root file name
60 
61 # Create main path
62 main = b2.create_path()
63 
64 # Add modules to main path
65 main.add_module(input)
66 main.add_module(tcal)
67 m_progress = b2.register_module('Progress')
68 m_progress.param("maxN", 4)
69 main.add_module(m_progress)
70 
71 
72 # Process all events
73 b2.process(main)
74 print(b2.statistics)