4 Airflow script to perform BoostVector calibration.
7 from prompt
import CalibrationSettings, input_data_filters
8 from prompt.calibrations.caf_beamspot
import settings
as beamspot
11 settings = CalibrationSettings(
12 name=
"BoostVector Calibrations",
13 expert_username=
"zlebcr",
15 input_data_formats=[
"cdst"],
16 input_data_names=[
"mumutight_calib"],
19 input_data_filters[
"Data Tag"][
"mumutight_calib"],
20 input_data_filters[
"Run Type"][
"physics"],
21 input_data_filters[
"Data Quality Tag"][
"Good Or Recoverable"],
22 input_data_filters[
"Magnet"][
"On"]]},
24 "outerLoss":
"pow(rawTime - 8.0, 2) + 10 * pow(maxGap, 2)",
25 "innerLoss":
"pow(rawTime - 8.0, 2) + 10 * pow(maxGap, 2)"},
26 depends_on=[beamspot])
31 def get_calibrations(input_data, **kwargs):
34 input_data (dict): Should contain every name from the 'input_data_names' variable as a key.
35 Each value is a dictionary with {"/path/to/file_e1_r5.root": IoV(1,5,1,5), ...}. Useful for
36 assigning to calibration.files_to_iov
38 **kwargs: Configuration options to be sent in. Since this may change we use kwargs as a way to help prevent
39 backwards compatibility problems. But you could use the correct arguments in b2caf-prompt-run for this
40 release explicitly if you want to.
42 Currently only kwargs["output_iov"] is used. This is the output IoV range that your payloads should
43 correspond to. Generally your highest ExpRun payload should be open ended e.g. IoV(3,4,-1,-1)
46 list(caf.framework.Calibration): All of the calibration objects we want to assign to the CAF process
53 file_to_iov_physics = input_data[
"mumutight_calib"]
58 max_files_per_run = 1000000
64 reduced_file_to_iov_physics = filter_by_max_files_per_run(file_to_iov_physics, max_files_per_run)
65 input_files_physics = list(reduced_file_to_iov_physics.keys())
66 basf2.B2INFO(f
"Total number of files actually used as input = {len(input_files_physics)}")
70 requested_iov = kwargs.get(
"requested_iov",
None)
72 from caf.utils
import IoV
74 output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
79 from ROOT.Belle2
import BoostVectorAlgorithm
80 from basf2
import create_path, register_module
81 import modularAnalysis
as ana
87 from caf.framework
import Calibration
88 from caf.strategies
import SingleIOV
89 from reconstruction
import prepare_cdst_analysis
92 rec_path_1 = create_path()
93 prepare_cdst_analysis(path=rec_path_1, components=[
'CDC',
'ECL',
'KLM'])
95 muSelection =
'[p>1.0]'
96 muSelection +=
' and abs(dz)<2.0 and abs(dr)<0.5'
97 muSelection +=
' and nPXDHits >=1 and nSVDHits >= 8 and nCDCHits >= 20'
98 ana.fillParticleList(
'mu+:BV', muSelection, path=rec_path_1)
99 ana.reconstructDecay(
'Upsilon(4S):BV -> mu+:BV mu-:BV',
'9.5<M<11.5', path=rec_path_1)
100 vertex.treeFit(
'Upsilon(4S):BV', updateAllDaughters=
True, ipConstraint=
True, path=rec_path_1)
102 collector_bv = register_module(
'BoostVectorCollector', Y4SPListName=
'Upsilon(4S):BV')
103 algorithm_bv = BoostVectorAlgorithm()
104 algorithm_bv.setOuterLoss(kwargs[
'expert_config'][
'outerLoss'])
105 algorithm_bv.setInnerLoss(kwargs[
'expert_config'][
'innerLoss'])
108 collector=collector_bv,
109 algorithms=algorithm_bv,
110 input_files=input_files_physics,
111 pre_collector_path=rec_path_1)
113 calibration_bv.strategies = SingleIOV
117 for algorithm
in calibration_bv.algorithms:
118 algorithm.params = {
"iov_coverage": output_iov}
124 return [calibration_bv]