Belle II Software development
SmartBKGSkimFlag.py
1
8import sys
9
10import basf2 as b2
11from skim.WGs.fei import feiHadronicB0
12import modularAnalysis as ma
13import mdst
14
15from smartBKG.b2modules.NN_trainer_module import SaveFlag
16
17# get job array id from batch job manager (slurm)
18job_id = int(sys.argv[1])
19
20num_events = 1000
21out_dir = "./"
22f_input = "./mdst.root"
23
24main = b2.create_path()
25
26# input Mdst, skip num_events*job_id events used by previous batch jobs
27ma.inputMdst(environmentType="default", filename=f_input, skipNEvents=num_events*job_id, path=main)
28
29# Create the mDST output file before skimming, which will be used in the preprocessing.
30# Not necessary if the whole input mdst is used in one job.
32 path=main,
33 filename=f'{out_dir}_submdst{job_id}.root',
34)
35
36# Arbitrary skimming process, here Hadronic B0 FEI as an example
37skim = feiHadronicB0(analysisGlobaltag=ma.getAnalysisGlobaltag(), udstOutput=False)
38skim(main)
39ma.applyEventCuts("eventExtraInfo(passes_feiHadronicB0)", main)
40# Save the event number of each pass event as the flag for the training of NN
41main.add_module(SaveFlag(f'{out_dir}_flag{job_id}.parquet'))
42
43b2.process(path=main, max_event=num_events)
def add_mdst_output(path, mc=True, filename='mdst.root', additionalBranches=[], dataDescription=None)
Definition: mdst.py:38
Definition: skim.py:1