40 arg_parser = argparse.ArgumentParser(description=
'Sector Map Training:\
41 Trains and stores SecMap from provided data sample.\n\
42 Usage: basf2 trainSecMap.py -- --train_sample traindata.root --secmap trainedSecMap.root')
44 arg_parser.add_argument(
'--train_sample',
'-i', type=str, nargs=
'*',
45 help=
'List of prepared training data file names which will be used for the training of the SecMap')
46 arg_parser.add_argument(
'--secmap',
'-s', type=str,
47 help=
'Inclusion of the root file containing the trained SecMap for the application of the VXDTF2.')
48 arg_parser.add_argument(
53 help=
'Relative threshold (in %) used to prune the sector maps. Will remove X % of the least used subgraphs.')
55 arguments = arg_parser.parse_args(sys.argv[1:])
56 train_data = arguments.train_sample
57 secmap_name = arguments.secmap
58 relThreshold = arguments.threshold
59 assert len(train_data) > 0,
'No data sample for training provided!'
63 b2.set_log_level(b2.LogLevel.ERROR)
64 b2.log_to_file(
'logVXDTF2Training.log', append=
False)
68 path = b2.create_path()
73 eventinfosetter = b2.register_module(
'EventInfoSetter')
77 if os.environ.get(
'USE_BEAST2_GEOMETRY'):
79 eventinfosetter.param(
"expList", [exp_number])
80 path.add_module(eventinfosetter)
83 gearbox = b2.register_module(
'Gearbox')
84 path.add_module(gearbox)
87 geometry = b2.register_module(
'Geometry')
88 path.add_module(geometry)
93 secMapBootStrap = b2.register_module(
'SectorMapBootstrap')
94 secMapBootStrap.param(
'ReadSectorMap',
False)
95 secMapBootStrap.param(
'WriteSectorMap',
True)
97 secMapBootStrap.param(
'SectorMapsOutputFile', secmap_name)
98 elif os.environ.get(
'USE_BEAST2_GEOMETRY'):
99 secMapBootStrap.param(
'SectorMapsOutputFile',
'SectorMaps_Beast2.root')
100 path.add_module(secMapBootStrap)
103 merger = b2.register_module(
'RawSecMapMerger')
104 merger.param(
'rootFileNames', train_data)
105 merger.param(
'threshold', relThreshold)
106 path.add_module(merger)