4 Airflow script to perform BoostVector calibration.
7 from prompt
import CalibrationSettings
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"],
18 "outerLoss":
"pow(rawTime - 8.0, 2) + 10 * pow(maxGap, 2)",
19 "innerLoss":
"pow(rawTime - 8.0, 2) + 10 * pow(maxGap, 2)"},
20 depends_on=[beamspot])
25 def get_calibrations(input_data, **kwargs):
28 input_data (dict): Should contain every name from the 'input_data_names' variable as a key.
29 Each value is a dictionary with {"/path/to/file_e1_r5.root": IoV(1,5,1,5), ...}. Useful for
30 assigning to calibration.files_to_iov
32 **kwargs: Configuration options to be sent in. Since this may change we use kwargs as a way to help prevent
33 backwards compatibility problems. But you could use the correct arguments in b2caf-prompt-run for this
34 release explicitly if you want to.
36 Currently only kwargs["output_iov"] is used. This is the output IoV range that your payloads should
37 correspond to. Generally your highest ExpRun payload should be open ended e.g. IoV(3,4,-1,-1)
40 list(caf.framework.Calibration): All of the calibration objects we want to assign to the CAF process
47 file_to_iov_physics = input_data[
"mumutight_calib"]
52 max_files_per_run = 1000000
58 reduced_file_to_iov_physics = filter_by_max_files_per_run(file_to_iov_physics, max_files_per_run)
59 input_files_physics = list(reduced_file_to_iov_physics.keys())
60 basf2.B2INFO(f
"Total number of files actually used as input = {len(input_files_physics)}")
64 requested_iov = kwargs.get(
"requested_iov",
None)
66 from caf.utils
import IoV
68 output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
73 from ROOT.Belle2
import BoostVectorAlgorithm
74 from basf2
import create_path, register_module
75 import modularAnalysis
as ana
81 from caf.framework
import Calibration
82 from caf.strategies
import SingleIOV
83 from reconstruction
import prepare_cdst_analysis
86 rec_path_1 = create_path()
87 prepare_cdst_analysis(path=rec_path_1, components=[
'CDC',
'ECL',
'KLM'])
89 muSelection =
'[p>1.0]'
90 muSelection +=
' and abs(dz)<2.0 and abs(dr)<0.5'
91 muSelection +=
' and nPXDHits >=1 and nSVDHits >= 8 and nCDCHits >= 20'
92 ana.fillParticleList(
'mu+:BV', muSelection, path=rec_path_1)
93 ana.reconstructDecay(
'Upsilon(4S):BV -> mu+:BV mu-:BV',
'9.5<M<11.5', path=rec_path_1)
94 vertex.treeFit(
'Upsilon(4S):BV', updateAllDaughters=
True, ipConstraint=
True, path=rec_path_1)
96 collector_bv = register_module(
'BoostVectorCollector', Y4SPListName=
'Upsilon(4S):BV')
97 algorithm_bv = BoostVectorAlgorithm()
98 algorithm_bv.setOuterLoss(kwargs[
'expert_config'][
'outerLoss'])
99 algorithm_bv.setInnerLoss(kwargs[
'expert_config'][
'innerLoss'])
102 collector=collector_bv,
103 algorithms=algorithm_bv,
104 input_files=input_files_physics,
105 pre_collector_path=rec_path_1)
107 calibration_bv.strategies = SingleIOV
111 for algorithm
in calibration_bv.algorithms:
112 algorithm.params = {
"iov_coverage": output_iov}
118 return [calibration_bv]