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