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