Belle II Software development
SmartBKGTrainDataProduction.py
1
8import argparse
9import os
10
11from smartBKG import DECORR_LIST
12from smartBKG.b2modules.NN_trainer_module import data_production
13
14parser = argparse.ArgumentParser(
15 description='''Generator variables saver.''',
16 formatter_class=argparse.ArgumentDefaultsHelpFormatter,
17)
18parser.add_argument('-j', type=int, required=False, default=1,
19 help="Job ID for batch. Default for test", metavar="JOB_ID",
20 dest='job_id')
21parser.add_argument('-f', type=str, required=False, default='./',
22 help="Input dir", metavar="IN_DIR",
23 dest='in_dir')
24parser.add_argument('-o', type=str, required=False, default='./',
25 help="Out dir", metavar="OUT_DIR",
26 dest='out_dir')
27parser.add_argument('-d', type=bool, required=False, default=False,
28 help="""Whether to save the preconfigured event-level variables
29 (variables for a certain particle are also seen as event-level,
30 since these variables are not attached to all the particles in the particle list)""",
31 metavar="SAVE_VARS", dest='save_vars')
32parser.add_argument("--workers", type=int, default=False,
33 help="Number of workers (0 means no multiprocessing)")
34args = parser.parse_args()
35
36os.makedirs(args.out_dir, exist_ok=True)
37
38if args.save_vars:
39 dec_list = DECORR_LIST
40else:
41 dec_list = None
42
43data_prod = data_production(
44 in_dir=args.in_dir, out_dir=args.out_dir,
45 job_id=args.job_id, save_vars=dec_list
46 )
47data_prod.process()
48data_prod.clean_up()