Belle II Software development
caf_ecl_time_validate_hadronic.py
1
8
9"""ECL timing validation with an hadronic event selection."""
10
11from prompt import CalibrationSettings
12from reconstruction import prepare_user_cdst_analysis
13
14
15
22
23
26settings = CalibrationSettings(
27 name="ECL time validations - hadronic",
28 expert_username="ehill",
29 description=__doc__,
30 input_data_formats=["cdst"],
31 input_data_names=["hadron_calib"],
32 input_data_filters={
33 "hadron_calib": [
34 "hadron_calib",
35 "4S",
36 "Continuum",
37 "Scan",
38 "Good",
39 "physics",
40 "On"]},
41 depends_on=[])
42
43
44
45
54
55
56def get_calibrations(input_data, **kwargs):
57 """
58 Parameters:
59 input_data (dict): Should contain every name from the 'input_data_names' variable as a key.
60 Each value is a dictionary with {"/path/to/file_e1_r5.root": IoV(1,5,1,5), ...}. Useful for
61 assigning to calibration.files_to_iov
62
63 **kwargs: Configuration options to be sent in. Since this may change we use kwargs as a way to help prevent
64 backwards compatibility problems. But you could use the correct arguments in b2caf-prompt-run for this
65 release explicitly if you want to.
66
67 Currently only kwargs["output_iov"] is used. This is the output IoV range that your payloads should
68 correspond to. Generally your highest ExpRun payload should be open ended e.g. IoV(3,4,-1,-1)
69
70 Returns:
71 list(caf.framework.Calibration): All of the calibration objects we want to assign to the CAF process
72 """
73 import basf2
74 # Set up config options
75
76 # In this script we want to use one sources of input data.
77 # Get the input files from the input_data variable
78 # The input data should be the hadron skim
79 file_to_iov_physics = input_data["hadron_calib"]
80
81 max_events_per_run = 3000
82
83 # We filter addition files if there are more than [max_events_per_run] files per run.
84 # The input data files are sorted alphabetically by b2caf-prompt-run
85 # already. This procedure respects that ordering
86 from prompt.utils import filter_by_max_events_per_run
87
88 reduced_file_to_iov_physics = filter_by_max_events_per_run(file_to_iov_physics, max_events_per_run)
89 input_files_physics = list(reduced_file_to_iov_physics.keys())
90 basf2.B2INFO(f"Total number of files actually used as input = {len(input_files_physics)}")
91
92
93 from basf2 import register_module, create_path
94 from ROOT import Belle2
95 from caf.framework import Collection
96
97
99 root_input = register_module('RootInput')
100 rec_path_hadron = create_path()
101 rec_path_hadron.add_module(root_input)
102 if 'Gearbox' not in rec_path_hadron:
103 rec_path_hadron.add_module('Gearbox')
104 if 'Geometry' not in rec_path_hadron:
105 rec_path_hadron.add_module('Geometry', useDB=True)
106
107 prepare_user_cdst_analysis(rec_path_hadron) # for new 2020 cdst format
108
109 col_hadron = register_module('eclHadronTimeCalibrationValidationCollector')
110 col_hadron.param('timeAbsMax', 70)
111 col_hadron.param('saveTree', False)
112
113 eclValTCol = Collection(collector=col_hadron,
114 input_files=input_files_physics,
115 pre_collector_path=rec_path_hadron)
116
117
119
120 # Give the collector name to the algorithm since one algorithm
121 # is used to analyse the results from several possible collectors
122 eclValTAlgHadronic = Belle2.ECL.eclTValidationAlgorithm("eclHadronTimeCalibrationValidationCollector")
123
124 # Define the CAF algorithm arguments
125 # eclValTAlgHadronic.cellIDLo= 3
126 # eclValTAlgHadronic.cellIDHi = 2
127 eclValTAlgHadronic.meanCleanRebinFactor = 3
128 eclValTAlgHadronic.meanCleanCutMinFactor = 0.4
129 eclValTAlgHadronic.debugFilenameBase = "eclHadronTValidationAlgorithm"
130
131
133
134 from caf.framework import Calibration
135
136 valid_cal_hadron = Calibration("ECLcrystalTimeCalValidation_hadronPhysics")
137 valid_cal_hadron.add_collection(name="hadron", collection=eclValTCol)
138 valid_cal_hadron.algorithms = [eclValTAlgHadronic]
139
140 # Here we set the AlgorithmStrategy for our algorithm
141 from caf.strategies import SingleIOV
142
143 # The default value is SingleIOV, you don't have to set this, it is done automatically.
144 # SingleIOV just takes all of the runs as one big IoV and executes the algorithm once on all of their data.
145 # You can use granularity='run' or granularity='all' for the collector when using this strategy.
146
147 valid_cal_hadron.strategies = SingleIOV
148
149
151
152 # You must return all calibrations you want to run in the prompt process, even if it's only one
153 return [valid_cal_hadron]
Validate the ecl timing calibrations using a hadronic event selection.