Belle II Software development
caf_crude_t0.py
1
8import basf2 as b2
9
10
11from ROOT import Belle2
12from caf.framework import Calibration, CAF
13from caf import backends
14
15b2.set_log_level(b2.LogLevel.INFO)
16data_dir = '/gpfs/fs02/belle2/users/dvthanh/201702_unpacked/'
17runs = []
18with open('runlist') as runlist:
19 lines = runlist.readlines()
20 for line in lines:
21 runs.append('cr.' + line.rstrip() + '.root')
22input_files_test = [data_dir + f for f in runs]
23
24
25def main():
26
27 def cdc_pre_algorithm(algorithm, iteration):
28 b2.B2INFO("Running pre_algorithm function")
29 # evtinfo = register_module('EventInfoSetter', evtNumList=[1], runList=[1630], expList=[1])
30 # gear = register_module('Gearbox')
31 # geom = register_module('Geometry', components=['CDC'])
32 # evtinfo.initialize()
33 # gear.initialize()
34 # geom.initialize()
35
36 calibrations = []
37 for i in range(1):
38 col_test = b2.register_module('CDCCrudeT0Collector')
39 col_test.set_name(f'CDCCrudeT0{i}') # Sets the prefix of the collected data in the datastore
40 col_test.param('granularity', 'all') # Allows us to execute algorithm over all data, in one big IoV
41
43 # Since we're using several instances of the same test algorithm here, we still want the database entries to have
44 # different names. TestCalibrationAlgorithm outputs to the database using the prefix name so we change it
45 # slightly for each calibration. Not something you'd usually have to do.
46 alg_test.setPrefix(f'CDCCrudeT0{i}') # Must be the same as colllector prefix
47
48 cal_test = Calibration(name=f'CrudeT0Calibration{i}',
49 collector=col_test,
50 algorithms=alg_test,
51 input_files=input_files_test)
52 cal_test.pre_algorithms = cdc_pre_algorithm
53 cal_test.max_files_per_collector_job = 1
54 cal_test.backend_args = {"queue": "s"}
55 # cal_test.use_central_database('')
56 cal_test.use_local_database('database.txt', '/home/belle/muchida/basf2/release/work/caf/test/localDB')
57 calibrations.append(cal_test)
58
59
61 cal_fw = CAF()
62 # Add in our list of calibrations
63 for cal in calibrations:
64 cal_fw.add_calibration(cal)
65 # Use the default LSF backend setup, can view the default options in calibration/data/backends.cfg
66 cal_fw.backend = backends.LSF()
67 # Since we're using the LSF batch system we'll up the heartbeat from the default to query for when the jobs are all finished
68 # No point spamming it
69 cal_fw.heartbeat = 15
70 # Start running
71 cal_fw.run()
72 print("End of CAF processing.")
73
74
75if __name__ == "__main__":
76 main()
Algorithm class for crude T0 calibration.
Definition: main.py:1