Belle II Software  release-08-01-10
caf_ecl_ee_expected.py
1 
8 
9 """Find expected energies for ee5x5 single crystal energy calibration.
10 Requires Bhabha mc in mdst format, plus ECLCalDigits"""
11 
12 # ..This calibration is run manually on specially requested MC samples.
13 #
14 # nohup b2caf-prompt-run LSF caf_ecl_ee_expected.json input_eeMC.json --permissive &
15 #
16 # The location of the steering file caf_ecl_ee_expected.py must be specified in
17 # the caf control json, caf_ecl_ee_expected.json, e.g.
18 # "caf_script":
19 # "/home/belle2/czhearty/users2022/BII-9711-remove-eclDigits/
20 # calibration/scripts/notPrompt/calibrations/caf_ecl_ee_expected.py",
21 # Environment variable BELLE2_RELEASE_DIR is useful for this purpose.
22 
23 
24 from prompt import CalibrationSettings
25 
26 # --------------------------------------------------------------
27 # ..Tell the automated script some required details
28 settings = CalibrationSettings(
29  name="ecl_ee_expected",
30  expert_username="hearty",
31  description=__doc__,
32  input_data_formats=["mdst"],
33  input_data_names=["bhabha_mc"],
34  depends_on=[],
35  expert_config={"ee5x5_min_entries": 100})
36 
37 # --------------------------------------------------------------
38 # ..The calibration functions
39 
40 
41 def get_calibrations(input_data, **kwargs):
42  import basf2
43  from ROOT import Belle2
44  from caf.utils import IoV
45  from caf.framework import Calibration
46 
47  # --------------------------------------------------------------
48  # ..Bhabha
49 
50  # ..Input data
51  file_to_iov_bhabha = input_data["bhabha_mc"]
52  input_files_bhabha = list(file_to_iov_bhabha.keys())
53 
54  # ..Algorithm
55  algo_ee5x5 = Belle2.ECL.eclee5x5Algorithm()
56  expert_config = kwargs.get("expert_config")
57  ee5x5minEntries = expert_config["ee5x5_min_entries"]
58  algo_ee5x5.setMinEntries(ee5x5minEntries)
59  algo_ee5x5.setPayloadName("ECLExpee5x5E")
60  algo_ee5x5.setStoreConst(True)
61 
62  # ..The calibration
63  eclee5x5_collector = basf2.register_module("eclee5x5Collector")
64  eclee5x5_collector.param("thetaLabMinDeg", 17.)
65  eclee5x5_collector.param("thetaLabMaxDeg", 150.)
66  eclee5x5_collector.param("minE0", 0.45)
67  eclee5x5_collector.param("minE1", 0.40)
68  eclee5x5_collector.param("maxdThetaSum", 2.)
69  eclee5x5_collector.param("dPhiScale", 1.)
70  eclee5x5_collector.param("maxTime", 10.)
71  eclee5x5_collector.param("useCalDigits", True)
72  eclee5x5_collector.param("requireL1", False)
73  eclee5x5_collector.param("granularity", "all")
74  cal_ecl_ee5x5 = Calibration("ecl_ee_expected",
75  collector=eclee5x5_collector,
76  algorithms=[algo_ee5x5],
77  input_files=input_files_bhabha
78  )
79  cal_ecl_ee5x5.backend_args = {"request_memory": "4 GB"}
80 
81  # ..pre_collector_path is empty; this is mdst format data
82  ee5x5_pre_path = basf2.create_path()
83  cal_ecl_ee5x5.pre_collector_path = ee5x5_pre_path
84 
85  # --------------------------------------------------------------
86  # ..Force the output iovs to be open
87  requested_iov = kwargs.get("requested_iov", None)
88  output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
89  for algorithm in cal_ecl_ee5x5.algorithms:
90  algorithm.params = {"apply_iov": output_iov}
91 
92  # --------------------------------------------------------------
93  # ..Return the calibrations
94  return [cal_ecl_ee5x5]
Calibrate ecl crystals using Bhabha events.