22from caf
import backends
23from caf.framework
import Calibration, CAF
24from caf.strategies
import SingleIOV
25from ROOT
import Belle2
26from ROOT.Belle2
import TOP
27from basf2
import B2ERROR
31globalTags = [
'online']
33data_dir =
'/ghi/fs01/belle2/bdata/group/detector/TOP/2019-*/data_sroot_global/'
34main_output_dir =
'top_calibration'
36calpulse_min_time = 50.0
37calpulse_max_time = 120.0
38tts_file =
'/group/belle2/group/detector/TOP/calibration/MCreferences/TTSParametrizations.root'
39laser_mc_fit =
'/group/belle2/group/detector/TOP/calibration/MCreferences/laserMCFit.root'
40fit_mode =
'calibration'
48 print(
"usage: basf2", argvs[0],
"experiment run_1 run_2 ... run_n")
50experiment = int(argvs[1])
51run_numbers = sorted([int(r)
for r
in argvs[2:]])
52run_first = run_numbers[0]
53run_last = run_numbers[-1]
57expNo =
'e' + f
'{experiment:04d}'
58for run
in run_numbers:
59 expRun = f
'{experiment:04d}' +
'.' + f
'{run:05d}'
61 filename = f
"{data_dir}/top.{expRun}.*.sroot"
63 filename = f
"{data_dir}/top.{expRun}.*.root"
64 inputFiles += glob.glob(filename)
65if len(inputFiles) == 0:
66 runs =
"".join([str(r) +
"," for r
in run_numbers])[:-1]
67 B2ERROR(f
'No root files found in {data_dir} for exp={str(experiment)} runs={runs}')
71if not os.path.isfile(tts_file):
72 B2ERROR(f
"File {tts_file} not found")
74if not os.path.isfile(laser_mc_fit):
75 B2ERROR(f
"File {laser_mc_fit} not found")
79run_range =
'r' + f
'{run_first:05d}' +
'-' + f
'{run_last:05d}'
80output_dir = f
"{main_output_dir}/channelT0-local-{expNo}-{run_range}"
86def channelT0_calibration(sroot=False):
88 calibration of channel T0 with laser data
89 :param sroot:
True if input files are
in sroot format,
False if in root format
93 main = basf2.create_path()
97 main.add_module(
'SeqRootInput')
99 main.add_module(
'RootInput')
100 main.add_module(
'TOPGeometryParInitializer')
101 main.add_module(
'TOPUnpacker')
102 main.add_module(
'TOPRawDigitConverter',
103 useSampleTimeCalibration=
True,
104 useAsicShiftCalibration=
True,
105 useChannelT0Calibration=
False,
106 useModuleT0Calibration=
False,
107 useCommonT0Calibration=
False,
108 calpulseHeightMin=200,
109 calpulseHeightMax=680,
110 calpulseWidthMin=1.5,
111 calpulseWidthMax=2.2,
112 calpulseTimeMin=calpulse_min_time,
113 calpulseTimeMax=calpulse_max_time,
114 calibrationChannel=0,
115 lookBackWindows=look_back)
118 collector = basf2.register_module(
'TOPLaserCalibratorCollector')
119 collector.param(
'useReferencePulse',
True)
120 collector.param(
'storeMCTruth',
False)
121 collector.param(
'refChannel', 0)
122 collector.param(
'refSlot', 4)
126 algorithm = TOP.TOPLocalCalFitter()
127 algorithm.setFitMode(fit_mode)
128 algorithm.setTTSFileName(tts_file)
129 algorithm.setFitConstraintsFileName(laser_mc_fit)
132 cal =
Calibration(name=
'TOP_channelT0', collector=collector,
133 algorithms=algorithm, input_files=inputFiles)
134 for globalTag
in reversed(globalTags):
135 cal.use_central_database(globalTag)
136 for localDB
in reversed(localDBs):
137 cal.use_local_database(localDB)
138 cal.pre_collector_path = main
139 cal.max_files_per_collector_job = 1
140 cal.strategies = SingleIOV
145cal = channelT0_calibration(sroot_format)
146cal.backend_args = {
"queue":
"l"}
150cal_fw.add_calibration(cal)
151cal_fw.output_dir = output_dir
152cal_fw.backend = backends.LSF()