Belle II Software  release-05-02-19
SVDDQMDoseModuleExample.py
1 #!/usr/bin/env python3
2 
17 """Uses the SVDDQMDose module and makes a rootfile with the histos."""
18 import argparse
19 import os
20 import basf2 as b2
21 from basf2 import conditions
22 from rawdata import add_unpackers
23 from svd import add_svd_reconstruction
24 from svd.executionTime_utils import SVDExtraEventStatisticsModule
25 from svd.dqm_utils import add_svd_dqm_dose
26 
27 
28 def prepend_to_filename(file_path, prefix):
29  dn, bn = os.path.dirname(file_path), os.path.basename(file_path)
30  return os.path.join(dn, f"{prefix}{bn}")
31 
32 
33 parser = argparse.ArgumentParser(description=__doc__)
34 parser.add_argument("files", metavar="FILE", nargs="+",
35  help="The input rootfile(s) with the RAW data.")
36 parser.add_argument("-o", "--out-file", default="SVDDQM.root",
37  help='The output rootfile. Default "SVDDQM.root".')
38 parser.add_argument("--no-trg-filter", action="store_true",
39  help="Take all events instead of TTYP_POIS only.")
40 parser.add_argument("--exec-time", action="store_true",
41  help="Also record execution time statistics.")
42 args = parser.parse_args()
43 
44 conditions.override_globaltags()
45 conditions.globaltags = ['svd_onlySVDinGeoConfiguration', 'online',
46  'Reco_master_patch_rel5'] # For HardwareClockSettings
47 
48 main = b2.create_path()
49 
50 # Read input (RAW data)
51 main.add_module("RootInput", inputFileNames=args.files)
52 
53 # HistoManager and output
54 main.add_module("HistoManager", histoFileName=args.out_file)
55 
56 # Necessary modules
57 main.add_module('Gearbox')
58 main.add_module('Geometry')
59 if args.no_trg_filter:
60  add_unpackers(main, components=['SVD'])
61 else:
62  add_unpackers(main, components=['SVD', 'TRG'])
63 main.add_module(
64  "SVDZeroSuppressionEmulator", SNthreshold=5,
65  ShaperDigits='SVDShaperDigits', ShaperDigitsIN='SVDShaperDigitsZS5',
66  FADCmode=True)
67 if args.exec_time:
68  add_svd_reconstruction(main) # Required for the statistics
69 
70 # SVDDQMDose module (Poisson trigger only)
71 params = {'trgTypes': []} if args.no_trg_filter else {}
72 add_svd_dqm_dose(main, "SVDShaperDigitsZS5", **params)
73 
74 # SVDDQMInjection for execution time comparison
75 main.add_module('SVDDQMInjection', ShaperDigits='SVDShaperDigitsZS5')
76 
77 # Execution time statistics
78 if args.exec_time:
79  main.add_module(SVDExtraEventStatisticsModule(
80  prepend_to_filename(args.out_file, "stats_")))
81 
82 # Necessary for impatient humans :)
83 main.add_module("ProgressBar")
84 
85 # b2.print_path(main)
86 b2.process(main)
87 print(b2.statistics)
svd.dqm_utils
Definition: dqm_utils.py:1
svd.executionTime_utils
Definition: executionTime_utils.py:1