31from caf.strategies
import SequentialRunByRun
32from caf.utils
import ExpRun, IoV
33from caf
import backends
34from caf.framework
import Calibration, CAF
35from ROOT
import Belle2
36from ROOT.Belle2
import PXDHotPixelMaskCalibrationAlgorithm
39b2.set_log_level(b2.LogLevel.INFO)
42parser = argparse.ArgumentParser(
43 description=
"Compute hot pixel masks for PXD from rawhit occupancy")
48 help=
'Compute mask for specific IoV')
49parser.add_argument(
'--runHigh', default=-1, type=int,
50 help=
'Compute mask for specific IoV')
55 help=
'Compute mask for specific IoV')
56parser.add_argument(
'--maxSubRuns', default=20, type=int,
57 help=
'Maximum number of subruns to use')
58args = parser.parse_args()
62pxd_ignore_run_list = [ExpRun(3, 484), ExpRun(3, 485), ExpRun(3, 486), ExpRun(3, 524)]
65iov_to_calibrate = IoV(
69 run_high=args.runHigh)
71map_file_path =
"file_iov_map.pkl"
72with open(map_file_path,
'br')
as map_file:
73 files_to_iovs = pickle.load(map_file)
76input_file_iov_set = set(files_to_iovs.values())
77print(f
'Number of distinct iovs {len(input_file_iov_set)}')
82for file_iov
in input_file_iov_set:
83 if iov_to_calibrate.contains(file_iov):
84 subruns = [k
for k, v
in files_to_iovs.items()
if v == file_iov]
85 input_files.extend(subruns[:args.maxSubRuns])
88print(f
'Number selected input files: {len(input_files)}')
91hotpixelcollector = b2.register_module(
"PXDRawHotPixelMaskCollector")
92hotpixelcollector.param(
"granularity",
"run")
95gearbox = b2.register_module(
'Gearbox')
96gearbox.param(
'fileName',
'geometry/Beast2_phase2.xml')
97geometry = b2.register_module(
'Geometry')
98geometry.param(
'components', [
'PXD'])
99pre_collector_path = b2.create_path()
100pre_collector_path.add_module(gearbox)
101pre_collector_path.add_module(geometry)
102pre_collector_path.add_module(
'PXDUnpacker')
107hotpixelkiller = PXDHotPixelMaskCalibrationAlgorithm()
110hotpixelkiller.forceContinueMasking =
False
112hotpixelkiller.minEvents = 30000
115hotpixelkiller.minHits = 15
117hotpixelkiller.pixelMultiplier = 7
119hotpixelkiller.maskDrains =
True
121hotpixelkiller.drainMultiplier = 7
123hotpixelkiller.maskRows =
True
125hotpixelkiller.rowMultiplier = 7
127hotpixelkiller.setPrefix(
"PXDRawHotPixelMaskCollector")
131 name=
"PXDHotPixelMaskCalibrationAlgorithm",
132 collector=hotpixelcollector,
133 algorithms=hotpixelkiller,
134 input_files=input_files)
135cal.pre_collector_path = pre_collector_path
138cal.files_to_iovs = files_to_iovs
142cal.strategies = SequentialRunByRun
144cal.ignored_runs = pxd_ignore_run_list
145cal.algorithms[0].params[
"iov_coverage"] = iov_to_calibrate
147cal.max_files_per_collector_job = 1
151cal_fw.add_calibration(cal)
153cal_fw.backend = backends.Local(max_processes=20)
158cal_fw.output_dir = f
'calibration_results_range_{args.runLow}_{args.runHigh}'
159cal_fw.run(iov=iov_to_calibrate)