16 from ROOT
import Belle2, TTree, TFile, TH1F
19 from array
import array
21 if len(sys.argv)
is not 4:
22 print(
'usage: basf2', argvs[0],
' <reference slot (1-16)> <reference channel (0-511)> <input_file.root> <output_file.root>')
25 refSlot = int(sys.argv[1]) - 1
26 refChan = int(sys.argv[2])
29 laserT0Err = [0.] * 16
31 inputFile = TFile(str(sys.argv[3]))
32 inputTree = inputFile.Get(
'chT0')
34 for entry
in inputTree:
35 if int(entry.channel) == refChan:
36 laserT0[int(entry.slot) - 1] = float(entry.fittedTime)
37 laserT0Err[int(entry.slot) - 1] = float(entry.fittedTimeError)
40 outFile = TFile(str(sys.argv[4]),
'recreate')
41 outTree = TTree(
'moduleT0laser',
'Module T0 constants using the laser')
42 moduleT0LaserConst = array(
'f', [0.])
43 moduleT0LaserErr = array(
'f', [0.])
44 outTree.Branch(
'moduleT0LaserConst', moduleT0LaserConst,
' moduleT0LaserConst/F')
45 outTree.Branch(
'moduleT0LaserErr', moduleT0LaserErr,
' moduleT0LaserErr/F')
47 print(
'------------------------------------------------------------------')
48 print(
'Results of TOP module-by-module sychronization using the Laser data')
50 for iSlot
in range(0, 16):
51 moduleT0LaserConst = 0.
53 if laserT0[iSlot] != 0:
54 moduleT0LaserConst = laserT0[iSlot] - laserT0[refSlot]
55 moduleT0LaserErr = math.sqrt(
64 print(
'Slot ' +
"%02d" % (iSlot + 1) +
': constant = ' +
"%+06.3f" % (round(moduleT0LaserConst, 3)) +
65 ' ns; Error = ' +
"%05.3f" % (round(moduleT0LaserErr, 3)) +
' ns')
68 print(
'------------------------------------------------------------------')