Belle II Software  release-08-01-10
algorithm_only.py
1 #!/usr/bin/env python3
2 
3 
10 
11 from ROOT import Belle2
12 
14 # Set the prefix manually if you want to use the algorithm for a specific collector
15 # algo.setPrefix("CaTest")
16 algo.setDebugHisto(True)
17 
18 # Can use a Python list of input files/wildcards. It will resolve the existing files
19 inputFileNames = ["CollectorOutput.root"]
20 algo.setInputFileNames(inputFileNames)
21 # Python list object of files returned
22 d = algo.getInputFileNames()
23 for name in d:
24  print("Resolved input file to algorithm:", name)
25 
26 # Can use python lists/tuples to define the runs whose data you want to use [(exp,run), ...]
27 # IoV of the payloads will be calculated from this input list
28 print("Result of calibration =", algo.execute([(1, 1), (1, 2)]))
29 output_json_string = algo.dumpOutputJson()
30 print(f"Output JSON was {output_json_string}")
31 # localdb isn't updated until you call this
32 # algo.commit()
33 
34 # Can run over all collected data and auto define the IoV of the payloads
35 print("Result of calibration =", algo.execute())
36 output_json_string = algo.dumpOutputJson()
37 print(f"Output JSON was {output_json_string}")
38 # Can commit multiple times in one process since the payloads are cleared at the start
39 # of each execution
40 # algo.commit()
41 
42 # Can set the input JSON from a previous execution's output JSON
43 algo.loadInputJson(output_json_string)
44 # Could also define an IoV for your calibrations at the start of execution
46 print("Result of calibration =", algo.execute([], 0, iov))
47 output_json_string = algo.dumpOutputJson()
48 print(f"Output JSON was {output_json_string}")
49 # IoV is applied to payloads during execution and gets used during commit
50 algo.commit()
static IntervalOfValidity always()
Function that returns an interval of validity that is always valid, c.f.
Test class implementing calibration algorithm.