31 from caf.strategies
import SequentialRunByRun
32 from caf.utils
import ExpRun, IoV
33 from caf
import backends
34 from caf.framework
import Calibration, CAF
35 from ROOT.Belle2
import PXDHotPixelMaskCalibrationAlgorithm
38 b2.set_log_level(b2.LogLevel.INFO)
41 parser = argparse.ArgumentParser(
42 description=
"Compute hot pixel masks for PXD from rawhit occupancy")
47 help=
'Compute mask for specific IoV')
48 parser.add_argument(
'--runHigh', default=-1, type=int,
49 help=
'Compute mask for specific IoV')
54 help=
'Compute mask for specific IoV')
55 parser.add_argument(
'--maxSubRuns', default=20, type=int,
56 help=
'Maximum number of subruns to use')
57 args = parser.parse_args()
61 pxd_ignore_run_list = [ExpRun(3, 484), ExpRun(3, 485), ExpRun(3, 486), ExpRun(3, 524)]
64 iov_to_calibrate = IoV(
68 run_high=args.runHigh)
70 map_file_path =
"file_iov_map.pkl"
71 with open(map_file_path,
'br')
as map_file:
72 files_to_iovs = pickle.load(map_file)
75 input_file_iov_set = set(files_to_iovs.values())
76 print(f
'Number of distinct iovs {len(input_file_iov_set)}')
81 for file_iov
in input_file_iov_set:
82 if iov_to_calibrate.contains(file_iov):
83 subruns = [k
for k, v
in files_to_iovs.items()
if v == file_iov]
84 input_files.extend(subruns[:args.maxSubRuns])
87 print(f
'Number selected input files: {len(input_files)}')
90 hotpixelcollector = b2.register_module(
"PXDRawHotPixelMaskCollector")
91 hotpixelcollector.param(
"granularity",
"run")
94 gearbox = b2.register_module(
'Gearbox')
95 gearbox.param(
'fileName',
'geometry/Beast2_phase2.xml')
96 geometry = b2.register_module(
'Geometry')
97 geometry.param(
'components', [
'PXD'])
98 pre_collector_path = b2.create_path()
99 pre_collector_path.add_module(gearbox)
100 pre_collector_path.add_module(geometry)
101 pre_collector_path.add_module(
'PXDUnpacker')
106 hotpixelkiller = PXDHotPixelMaskCalibrationAlgorithm()
109 hotpixelkiller.forceContinueMasking =
False
111 hotpixelkiller.minEvents = 30000
114 hotpixelkiller.minHits = 15
116 hotpixelkiller.pixelMultiplier = 7
118 hotpixelkiller.maskDrains =
True
120 hotpixelkiller.drainMultiplier = 7
122 hotpixelkiller.maskRows =
True
124 hotpixelkiller.rowMultiplier = 7
126 hotpixelkiller.setPrefix(
"PXDRawHotPixelMaskCollector")
130 name=
"PXDHotPixelMaskCalibrationAlgorithm",
131 collector=hotpixelcollector,
132 algorithms=hotpixelkiller,
133 input_files=input_files)
134 cal.pre_collector_path = pre_collector_path
137 cal.files_to_iovs = files_to_iovs
141 cal.strategies = SequentialRunByRun
143 cal.ignored_runs = pxd_ignore_run_list
144 cal.algorithms[0].params[
"iov_coverage"] = iov_to_calibrate
146 cal.max_files_per_collector_job = 1
150 cal_fw.add_calibration(cal)
152 cal_fw.backend = backends.Local(max_processes=20)
155 cal_fw.heartbeat = 30
157 cal_fw.output_dir = f
'calibration_results_range_{args.runLow}_{args.runHigh}'
158 cal_fw.run(iov=iov_to_calibrate)