Belle II Software  release-08-01-10
caf_ecl_nOptimal.py
1 
8 
9 """ECL calibration to calculate nOptimal number of crystals for cluster energy."""
10 
11 from prompt import CalibrationSettings, INPUT_DATA_FILTERS
12 
13 
14 # --------------------------------------------------------------
15 # ..Tell the automated script some required details
16 settings = CalibrationSettings(name="ecl_nOptimal",
17  expert_username="hearty",
18  description=__doc__,
19  input_data_formats=["mdst"],
20  input_data_names=["single_gamma_mc"],
21  input_data_filters={
22  "single_gamma_mc": [
23  INPUT_DATA_FILTERS["Data Tag"]["single_gamma_mc"]
24  ]
25  },
26  depends_on=[],
27 
28  # ..The expert_config settings should agree with the parameters of the jobs used
29  # to create the single_gamma_mc samples.
30  # Number of energy points, and the values of these for each of the three ECL regions.
31  # The mc samples include a reduced set of showers and CalDigits, with these names.
32  expert_config={"number_energies": 8,
33  "forward_energies": [0.030, 0.050, 0.100, 0.200, 0.483, 1.166, 2.816, 6.800],
34  "barrel_energies": [0.030, 0.050, 0.100, 0.200, 0.458, 1.049, 2.402, 5.500],
35  "backward_energies": [0.030, 0.050, 0.100, 0.200, 0.428, 0.917, 1.962, 4.200],
36  "digitArrayName": "ECLTrimmedDigits",
37  "showerArrayName": "ECLTrimmedShowers"
38  }
39  )
40 
41 
42 # --------------------------------------------------------------
43 # ..The calibration functions
44 
45 def get_calibrations(input_data, **kwargs):
46  import basf2
47  from ROOT import Belle2
48  from caf.utils import IoV
49  from caf.framework import Calibration
50 
51  # --------------------------------------------------------------
52  # ..Input data
53  file_to_iov_nOptimal = input_data["single_gamma_mc"]
54  input_files_nOptimal = list(file_to_iov_nOptimal.keys())
55 
56  # ..Collector
57  ecl_nOptimal_collector = basf2.register_module("eclNOptimalCollector")
58  ecl_nOptimal_collector.param("granularity", "all")
59 
60  # ..Number of energy points and their values can be set via expert_config
61  expert_config = kwargs.get("expert_config")
62  number_energies = expert_config["number_energies"]
63  ecl_nOptimal_collector.param("numberEnergies", number_energies)
64 
65  forward_energies = expert_config["forward_energies"]
66  ecl_nOptimal_collector.param("energiesForward", forward_energies)
67 
68  barrel_energies = expert_config["barrel_energies"]
69  ecl_nOptimal_collector.param("energiesBarrel", barrel_energies)
70 
71  backward_energies = expert_config["backward_energies"]
72  ecl_nOptimal_collector.param("energiesBackward", backward_energies)
73 
74  digitArrayName = expert_config["digitArrayName"]
75  ecl_nOptimal_collector.param("digitArrayName", digitArrayName)
76 
77  showerArrayName = expert_config["showerArrayName"]
78  ecl_nOptimal_collector.param("showerArrayName", showerArrayName)
79 
80  # ..Algorithm
81  algo_nOptimal = Belle2.ECL.eclNOptimalAlgorithm()
82 
83  # ..The calibration
84  cal_ecl_nOptimal = Calibration(
85  name="ecl_nOptimal",
86  collector=ecl_nOptimal_collector,
87  algorithms=algo_nOptimal,
88  input_files=input_files_nOptimal)
89 
90  # ..pre_path is empty
91  ecl_nOptimal_pre_path = basf2.create_path()
92  cal_ecl_nOptimal.pre_collector_path = ecl_nOptimal_pre_path
93 
94  # --------------------------------------------------------------
95  # ..Force the output iovs to be open
96  requested_iov = kwargs.get("requested_iov", None)
97  output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
98  for algorithm in cal_ecl_nOptimal.algorithms:
99  algorithm.params = {"apply_iov": output_iov}
100 
101  # --------------------------------------------------------------
102  # ..Return the calibrations
103  return [cal_ecl_nOptimal]
Algorithm that works with eclNOptimalCollector to find the number of crystals to be summed to get the...