10Airflow script to perform BeamSpot calibration.
13from prompt
import CalibrationSettings, INPUT_DATA_FILTERS
14from prompt.calibrations.caf_cdcdedx_electron
import settings
as caf_cdc_dedx_electron
15from prompt.calibrations.caf_cdcdedx_hadron
import settings
as caf_cdc_dedx_hadron
17from prompt.calibrations.caf_top
import settings
as caf_top
18from prompt.calibrations.caf_klm_strip_efficiency
import settings
as caf_klm_strip_efficiency
21settings = CalibrationSettings(
22 name=
"BeamSpot Calibrations",
23 expert_username=
"zlebcik",
26 input_data_formats=[
"cdst"],
27 input_data_names=[
"mumu_tight_or_highm_calib"],
29 "mumu_tight_or_highm_calib": [
30 INPUT_DATA_FILTERS[
"Data Tag"][
"mumu_tight_or_highm_calib"],
31 INPUT_DATA_FILTERS[
"Run Type"][
"physics"],
32 INPUT_DATA_FILTERS[
"Data Quality Tag"][
"Good Or Recoverable"],
33 INPUT_DATA_FILTERS[
"Magnet"][
"On"]]},
35 "outerLoss":
"pow(rawTime - 2.0, 2) + 10 * pow(maxGap, 2)",
36 "innerLoss":
"pow(rawTime - 0.5, 2) + 10 * pow(maxGap, 2)",
38 depends_on=[caf_cdc_dedx_electron, caf_cdc_dedx_hadron, caf_top, caf_klm_strip_efficiency],
39 produced_payloads=[
"BeamSpot"])
44def get_calibrations(input_data, **kwargs):
47 input_data (dict): Should contain every name from the 'input_data_names' variable as a key.
48 Each value is a dictionary with {"/path/to/file_e1_r5.root": IoV(1,5,1,5), ...}. Useful for
49 assigning to calibration.files_to_iov
51 **kwargs: Configuration options to be sent in. Since this may change we use kwargs as a way to help prevent
52 backwards compatibility problems. But you could use the correct arguments in b2caf-prompt-run for this
53 release explicitly if you want to.
55 Currently only kwargs["output_iov"] is used. This is the output IoV range that your payloads should
56 correspond to. Generally your highest ExpRun payload should be open ended e.g. IoV(3,4,-1,-1)
59 list(caf.framework.Calibration): All of the calibration objects we want to assign to the CAF process
66 file_to_iov_physics = input_data[
"mumu_tight_or_highm_calib"]
71 max_files_per_run = 1000000
77 reduced_file_to_iov_physics = filter_by_max_files_per_run(file_to_iov_physics, max_files_per_run)
78 input_files_physics = list(reduced_file_to_iov_physics.keys())
79 basf2.B2INFO(f
"Total number of files actually used as input = {len(input_files_physics)}")
83 requested_iov = kwargs.get(
"requested_iov",
None)
85 from caf.utils
import IoV
87 output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
91 from ROOT
import Belle2
92 from ROOT.Belle2
import BeamSpotAlgorithm
93 from basf2
import create_path, register_module
94 import modularAnalysis
as ana
99 from caf.framework
import Calibration
100 from caf.strategies
import SingleIOV
103 rec_path_1 = create_path()
105 minPXDhits = kwargs[
'expert_config'][
'minPXDhits']
106 muSelection =
'[p>1.0]'
107 muSelection +=
' and abs(dz)<2.0 and abs(dr)<0.5'
108 muSelection += f
' and nPXDHits >= {minPXDhits} and nSVDHits >= 8 and nCDCHits >= 20'
109 ana.fillParticleList(
'mu+:BS', muSelection, path=rec_path_1)
110 ana.reconstructDecay(
'Upsilon(4S):BS -> mu+:BS mu-:BS',
'9.5<M<11.5', path=rec_path_1)
112 collector_bs = register_module(
'BeamSpotCollector', Y4SPListName=
'Upsilon(4S):BS')
113 algorithm_bs = BeamSpotAlgorithm()
114 algorithm_bs.setOuterLoss(kwargs[
'expert_config'][
'outerLoss'])
115 algorithm_bs.setInnerLoss(kwargs[
'expert_config'][
'innerLoss'])
117 calibration_bs = Calibration(
'BeamSpot',
118 collector=collector_bs,
119 algorithms=algorithm_bs,
120 input_files=input_files_physics,
121 pre_collector_path=rec_path_1)
123 calibration_bs.strategies = SingleIOV
127 for algorithm
in calibration_bs.algorithms:
128 algorithm.params = {
"iov_coverage": output_iov}
134 return [calibration_bs]