Belle II Software  release-06-02-00
caf_ecl_gg_expected.py
1 # -*- coding: utf-8 -*-
2 
3 
10 
11 """Find expected energies for ECL e+e- --> gamma gamma single crystal
12 energy calibration. Requires e+e- --> gamma gamma mc in mdst format."""
13 
14 from prompt import CalibrationSettings, input_data_filters
15 
16 # --------------------------------------------------------------
17 # ..Tell the automated script some required details
18 settings = CalibrationSettings(
19  name="ecl_gg_expected",
20  expert_username="hearty",
21  description=__doc__,
22  input_data_formats=["mdst"],
23  input_data_names=["gamma_gamma_mc"],
24  depends_on=[])
25 
26 # --------------------------------------------------------------
27 # ..The calibration functions
28 
29 
30 def get_calibrations(input_data, **kwargs):
31  import basf2
32  from ROOT import Belle2
33  from caf.utils import IoV
34  from caf.framework import Calibration
35  from reconstruction import prepare_cdst_analysis
36 
37  # --------------------------------------------------------------
38  # ..gamma gamma
39 
40  # ..Input data
41  file_to_iov_gamma_gamma = input_data["gamma_gamma_mc"]
42  input_files_gamma_gamma = list(file_to_iov_gamma_gamma.keys())
43 
44  # ..Algorithm
45  algo_gamma_gamma = Belle2.ECL.eclGammaGammaEAlgorithm()
46  algo_gamma_gamma.setOutputName("eclGammaGammaE_algorithm.root")
47  algo_gamma_gamma.setCellIDLo(1)
48  algo_gamma_gamma.setCellIDHi(8736)
49  algo_gamma_gamma.setMinEntries(150)
50  algo_gamma_gamma.setMaxIterations(10)
51  algo_gamma_gamma.setTRatioMin(0.45)
52  algo_gamma_gamma.setTRatioMax(0.70)
53  algo_gamma_gamma.setTRatioMinHiStat(0.70)
54  algo_gamma_gamma.setTRatioMaxHiStat(0.95)
55  algo_gamma_gamma.setUpperEdgeThresh(0.02)
56  algo_gamma_gamma.setPerformFits(True)
57  algo_gamma_gamma.setFindExpValues(True)
58  algo_gamma_gamma.setStoreConst(0)
59 
60  # ..The calibration
61  eclGammaGamma_collector = basf2.register_module("eclGammaGammaECollector")
62  eclGammaGamma_collector.param("granularity", "all")
63  eclGammaGamma_collector.param("thetaLabMinDeg", 0.)
64  eclGammaGamma_collector.param("thetaLabMaxDeg", 180.)
65  eclGammaGamma_collector.param("minPairMass", 9.)
66  eclGammaGamma_collector.param("mindPhi", 179.)
67  eclGammaGamma_collector.param("maxTime", 999.)
68  eclGammaGamma_collector.param("measureTrueEnergy", True)
69  eclGammaGamma_collector.param("requireL1", False)
70  cal_ecl_gamma_gamma = Calibration("ecl_gg_expected",
71  collector=eclGammaGamma_collector,
72  algorithms=[algo_gamma_gamma],
73  input_files=input_files_gamma_gamma
74  )
75 
76  # ..Add prepare_cdst_analysis to pre_collector_path
77  gamma_gamma_pre_path = basf2.create_path()
78  cal_ecl_gamma_gamma.pre_collector_path = gamma_gamma_pre_path
79 
80  # --------------------------------------------------------------
81  # ..Force the output iovs to be open
82  requested_iov = kwargs.get("requested_iov", None)
83  output_iov = IoV(requested_iov.exp_low, requested_iov.run_low, -1, -1)
84  for algorithm in cal_ecl_gamma_gamma.algorithms:
85  algorithm.params = {"apply_iov": output_iov}
86 
87  # --------------------------------------------------------------
88  # ..Return the calibrations
89  return [cal_ecl_gamma_gamma]
Calibrate ecl crystals using gamma pair events.