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