4 Airflow script to perform BeamSpot calibration.
7 from prompt
import CalibrationSettings, input_data_filters
10 settings = CalibrationSettings(
11 name=
"BeamSpot Calibrations",
12 expert_username=
"zlebcr",
14 input_data_formats=[
"cdst"],
15 input_data_names=[
"mumutight_calib"],
18 input_data_filters[
"Data Tag"][
"mumutight_calib"],
19 input_data_filters[
"Run Type"][
"physics"],
20 input_data_filters[
"Data Quality Tag"][
"Good Or Recoverable"],
21 input_data_filters[
"Magnet"][
"On"]]},
23 "outerLoss":
"pow(rawTime - 2.0, 2) + 10 * pow(maxGap, 2)",
24 "innerLoss":
"pow(rawTime - 0.5, 2) + 10 * pow(maxGap, 2)"},
30 def get_calibrations(input_data, **kwargs):
33 input_data (dict): Should contain every name from the 'input_data_names' variable as a key.
34 Each value is a dictionary with {"/path/to/file_e1_r5.root": IoV(1,5,1,5), ...}. Useful for
35 assigning to calibration.files_to_iov
37 **kwargs: Configuration options to be sent in. Since this may change we use kwargs as a way to help prevent
38 backwards compatibility problems. But you could use the correct arguments in b2caf-prompt-run for this
39 release explicitly if you want to.
41 Currently only kwargs["output_iov"] is used. This is the output IoV range that your payloads should
42 correspond to. Generally your highest ExpRun payload should be open ended e.g. IoV(3,4,-1,-1)
45 list(caf.framework.Calibration): All of the calibration objects we want to assign to the CAF process
52 file_to_iov_physics = input_data[
"mumutight_calib"]
57 max_files_per_run = 1000000
63 reduced_file_to_iov_physics = filter_by_max_files_per_run(file_to_iov_physics, max_files_per_run)
64 input_files_physics = list(reduced_file_to_iov_physics.keys())
65 basf2.B2INFO(f
"Total number of files actually used as input = {len(input_files_physics)}")
69 requested_iov = kwargs.get(
"requested_iov",
None)
71 from caf.utils
import IoV
73 output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
78 from ROOT.Belle2
import BeamSpotAlgorithm
79 from basf2
import create_path, register_module
80 import modularAnalysis
as ana
85 from caf.framework
import Calibration
86 from caf.strategies
import SingleIOV
89 rec_path_1 = create_path()
91 muSelection =
'[p>1.0]'
92 muSelection +=
' and abs(dz)<2.0 and abs(dr)<0.5'
93 muSelection +=
' and nPXDHits >=1 and nSVDHits >= 8 and nCDCHits >= 20'
94 ana.fillParticleList(
'mu+:BS', muSelection, path=rec_path_1)
95 ana.reconstructDecay(
'Upsilon(4S):BS -> mu+:BS mu-:BS',
'9.5<M<11.5', path=rec_path_1)
97 collector_bs = register_module(
'BeamSpotCollector', Y4SPListName=
'Upsilon(4S):BS')
98 algorithm_bs = BeamSpotAlgorithm()
99 algorithm_bs.setOuterLoss(kwargs[
'expert_config'][
'outerLoss'])
100 algorithm_bs.setInnerLoss(kwargs[
'expert_config'][
'innerLoss'])
103 collector=collector_bs,
104 algorithms=algorithm_bs,
105 input_files=input_files_physics,
106 pre_collector_path=rec_path_1)
108 calibration_bs.strategies = SingleIOV
112 for algorithm
in calibration_bs.algorithms:
113 algorithm.params = {
"iov_coverage": output_iov}
119 return [calibration_bs]