20from ROOT
import TFile, TTree
23from array
import array
26 print(
'usage: basf2', sys.argv[0],
' <reference slot (1-16)> <reference channel (0-511)> <input_file.root> <output_file.root>')
29refSlot = int(sys.argv[1]) - 1
30refChan = int(sys.argv[2])
35inputFile = TFile(str(sys.argv[3]))
36inputTree = inputFile.Get(
'chT0')
38for entry
in inputTree:
39 if int(entry.channel) == refChan:
40 laserT0[int(entry.slot) - 1] = float(entry.fittedTime)
41 laserT0Err[int(entry.slot) - 1] = float(entry.fittedTimeError)
44outFile = TFile(str(sys.argv[4]),
'recreate')
45outTree = TTree(
'moduleT0laser',
'Module T0 constants using the laser')
46moduleT0LaserConst = array(
'f', [0.])
47moduleT0LaserErr = array(
'f', [0.])
48outTree.Branch(
'moduleT0LaserConst', moduleT0LaserConst,
' moduleT0LaserConst/F')
49outTree.Branch(
'moduleT0LaserErr', moduleT0LaserErr,
' moduleT0LaserErr/F')
51print(
'------------------------------------------------------------------')
52print(
'Results of TOP module-by-module sychronization using the Laser data')
54for iSlot
in range(0, 16):
55 moduleT0LaserConst = 0.
57 if laserT0[iSlot] != 0:
58 moduleT0LaserConst = laserT0[iSlot] - laserT0[refSlot]
59 moduleT0LaserErr = math.sqrt(
68 print(
'Slot ' + f
"{int(iSlot + 1):02}" +
': constant = ' + f
"{round(moduleT0LaserConst, 3):06.3f}" +
69 ' ns; Error = ' + f
"{round(moduleT0LaserErr, 3):05.3f}" +
' ns')
72print(
'------------------------------------------------------------------')