Belle II Software development
caf_boundary_strategy.py
1
11
12import basf2 as b2
13
14import sys
15from pathlib import Path
16
17from caf.framework import Calibration, CAF
18from caf.utils import IoV
19from caf.strategies import SequentialBoundaries
20
21
22b2.set_log_level(b2.LogLevel.DEBUG)
23
24
25def main(argv):
26 if len(argv) == 1:
27 data_dir = argv[0]
28 else:
29 print("Usage: basf2 caf_boundary_strategy.py <data directory>")
30 sys.exit(1)
31
32
36 input_files_test = []
37 input_files_test.append(Path(Path(data_dir).absolute(), '*.root').as_posix())
38
39
41 from ROOT import Belle2 # noqa: make the Belle2 namespace available
42 from ROOT.Belle2 import TestCalibrationAlgorithm
43 alg_test = TestCalibrationAlgorithm() # Getting a calibration algorithm instance
44 alg_test.setMinEntries(15000) # This algorithm provides a setting to change when c_NotEnoughData is returned
45 alg_test.setAllowedMeanShift(0.1) # This alters how often boundaries will be requested (smaller = more often)
46
47 # Create a single calibration from a collector module name + algorithm + input files
48 cal_test = Calibration(name="TestCalibration", collector="CaTest", algorithms=alg_test, input_files=input_files_test)
49
50 # The SequentialBoundaries strategy executes your algorithm over runs but only where you have defined a boundary
51 # for new payloads. In order to run this strategy your algorithm must define a "isBoundaryRequired" member function.
52 #
53 # You should only use granularity='run' for the collector when using this strategy.
54
55 cal_test.strategies = SequentialBoundaries
56
57 cal_test.algorithms[0].params["iov_coverage"] = IoV(0, 0, -1, -1)
58
59
61 cal_fw = CAF()
62 cal_fw.add_calibration(cal_test)
63 cal_fw.run()
64 print("End of CAF processing.")
65
66
67if __name__ == "__main__":
68 main(sys.argv[1:])
Definition: main.py:1